@agent-spaces/server 0.3.64 → 0.3.65

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 (294) hide show
  1. package/dist/adapters/claude-code-runtime/index.js +68 -2
  2. package/dist/adapters/claude-code-runtime/message-format.js +26 -0
  3. package/dist/adapters/claude-code-runtime/sdk-config.js +12 -0
  4. package/dist/adapters/git.js +13 -6
  5. package/dist/agents/agent-message-parts.js +1 -1
  6. package/dist/agents/commit-agent.js +4 -2
  7. package/dist/agents/issue-task-controller.js +6 -2
  8. package/dist/app.js +6 -68
  9. package/dist/routes/agent-sse.js +1 -0
  10. package/dist/routes/agent.js +3 -0
  11. package/dist/routes/database.js +1 -0
  12. package/dist/routes/git.js +197 -317
  13. package/dist/routes/robot-account.js +68 -0
  14. package/dist/services/agent.js +36 -2
  15. package/dist/services/builtin-tools/kanban-tools.js +4 -0
  16. package/dist/services/git-operation-log.js +40 -0
  17. package/dist/services/global-wechat-qr.js +72 -0
  18. package/dist/services/hook-engine.js +175 -17
  19. package/dist/services/notification-hub/bot-agent.js +3 -1
  20. package/dist/services/notification-hub/service.js +12 -2
  21. package/dist/services/robot-account.js +34 -0
  22. package/dist/services/workspace.js +2 -0
  23. package/dist/storage/robot-account-store.js +39 -0
  24. package/dist/web/404.html +1 -1
  25. package/dist/web/__next.__PAGE__.txt +4 -4
  26. package/dist/web/__next._full.txt +23 -25
  27. package/dist/web/__next._head.txt +4 -4
  28. package/dist/web/__next._index.txt +13 -13
  29. package/dist/web/__next._tree.txt +2 -2
  30. package/dist/web/_next/static/chunks/{04a4vsq2wknm4.js → 0-a.-hl3wv99k.js} +1 -1
  31. package/dist/web/_next/static/chunks/{0ctg5qmw7uu.1.js → 0-pi.67w.ymsr.js} +3 -3
  32. package/dist/web/_next/static/chunks/0-v_p6j5u3_9l.js +1 -0
  33. package/dist/web/_next/static/chunks/0.-x29t-8gk0r.js +1 -0
  34. package/dist/web/_next/static/chunks/0.6b64sy0g5.3.js +3 -0
  35. package/dist/web/_next/static/chunks/0.l5e8~r7_0~p.js +1 -0
  36. package/dist/web/_next/static/chunks/00-syqzi-6zxr.js +1 -0
  37. package/dist/web/_next/static/chunks/02802taez976w.js +67 -0
  38. package/dist/web/_next/static/chunks/02j4sr9psucf-.js +1 -0
  39. package/dist/web/_next/static/chunks/033.awk90g6eh.js +1 -0
  40. package/dist/web/_next/static/chunks/06.kdsa9rr2h1.js +1 -0
  41. package/dist/web/_next/static/chunks/06si8l0doqe8p.js +1 -0
  42. package/dist/web/_next/static/chunks/08ugbvzr20drp.js +2 -0
  43. package/dist/web/_next/static/chunks/{0n6_4so_afuwk.js → 08x85faoz58i7.js} +2 -2
  44. package/dist/web/_next/static/chunks/{0v3a_x4vt42kx.js → 0_cqojbge48kq.js} +1 -1
  45. package/dist/web/_next/static/chunks/{0a5y-vhf4i5id.js → 0d6~~lv0-6kex.js} +1 -1
  46. package/dist/web/_next/static/chunks/{0vbqaynjq8ga..js → 0db14450oqzhg.js} +1 -1
  47. package/dist/web/_next/static/chunks/0gdwop9cnpmtu.js +1 -0
  48. package/dist/web/_next/static/chunks/0j-l7l_k9jt45.js +1 -0
  49. package/dist/web/_next/static/chunks/0kbvoxla7f751.js +1 -0
  50. package/dist/web/_next/static/chunks/{1442stwa0gbxe.js → 0l2w0qz1ea7ql.js} +2 -2
  51. package/dist/web/_next/static/chunks/0p3h-h3zj5ujg.js +30 -0
  52. package/dist/web/_next/static/chunks/0paaat8y96ayc.js +7 -0
  53. package/dist/web/_next/static/chunks/0pm-un~-sy3rl.js +1 -0
  54. package/dist/web/_next/static/chunks/0pq318f8xgafg.js +1 -0
  55. package/dist/web/_next/static/chunks/0t6s8of0qr6nc.js +1 -0
  56. package/dist/web/_next/static/chunks/0u6h-hqc_i52e.js +1 -0
  57. package/dist/web/_next/static/chunks/0uxzi~9b~k4mn.js +31 -0
  58. package/dist/web/_next/static/chunks/{08ckpwmmwlors.js → 0vis~lx0nxgn-.js} +2 -2
  59. package/dist/web/_next/static/chunks/{10l-9myrdo3x9.js → 0w7.tb29958zj.js} +1 -1
  60. package/dist/web/_next/static/chunks/0yd.m1afqg.2t.js +3 -0
  61. package/dist/web/_next/static/chunks/0yhbr8hl09b-5.js +1 -0
  62. package/dist/web/_next/static/chunks/0zncg76rgtbm-.js +1 -0
  63. package/dist/web/_next/static/chunks/0~~_ltu6dx_ch.js +1 -0
  64. package/dist/web/_next/static/chunks/{0iuf30t0rjsjv.js → 11cchuwoupmbf.js} +1 -1
  65. package/dist/web/_next/static/chunks/12oxcgyhpaxw~.js +1 -0
  66. package/dist/web/_next/static/chunks/1452eibz62gs6.css +1 -0
  67. package/dist/web/_next/static/chunks/16zlreiems5cn.js +1 -0
  68. package/dist/web/_next/static/chunks/18awqjk9-o5m0.js +1 -0
  69. package/dist/web/_next/static/chunks/18c7g84y01mj0.js +1 -0
  70. package/dist/web/_next/static/chunks/{turbopack-0ndm2zc_pdptk.js → turbopack-11qjwlynmfc-n.js} +1 -1
  71. package/dist/web/_not-found/__next._full.txt +30 -29
  72. package/dist/web/_not-found/__next._head.txt +4 -4
  73. package/dist/web/_not-found/__next._index.txt +13 -13
  74. package/dist/web/_not-found/__next._not-found.__PAGE__.txt +2 -2
  75. package/dist/web/_not-found/__next._not-found.txt +3 -3
  76. package/dist/web/_not-found/__next._tree.txt +2 -2
  77. package/dist/web/_not-found.html +1 -1
  78. package/dist/web/_not-found.txt +30 -29
  79. package/dist/web/index.html +1 -1
  80. package/dist/web/index.txt +23 -25
  81. package/dist/web/login/__next._full.txt +28 -28
  82. package/dist/web/login/__next._head.txt +4 -4
  83. package/dist/web/login/__next._index.txt +13 -13
  84. package/dist/web/login/__next._tree.txt +2 -2
  85. package/dist/web/login/__next.login.__PAGE__.txt +4 -4
  86. package/dist/web/login/__next.login.txt +3 -3
  87. package/dist/web/login.html +1 -1
  88. package/dist/web/login.txt +28 -28
  89. package/dist/web/settings/__next._full.txt +33 -32
  90. package/dist/web/settings/__next._head.txt +4 -4
  91. package/dist/web/settings/__next._index.txt +13 -13
  92. package/dist/web/settings/__next._tree.txt +2 -2
  93. package/dist/web/settings/__next.settings.__PAGE__.txt +4 -4
  94. package/dist/web/settings/__next.settings.txt +5 -5
  95. package/dist/web/settings/agents/__next._full.txt +24 -24
  96. package/dist/web/settings/agents/__next._head.txt +4 -4
  97. package/dist/web/settings/agents/__next._index.txt +13 -13
  98. package/dist/web/settings/agents/__next._tree.txt +2 -2
  99. package/dist/web/settings/agents/__next.settings.agents.__PAGE__.txt +4 -4
  100. package/dist/web/settings/agents/__next.settings.agents.txt +3 -3
  101. package/dist/web/settings/agents/__next.settings.txt +5 -5
  102. package/dist/web/settings/agents.html +1 -1
  103. package/dist/web/settings/agents.txt +24 -24
  104. package/dist/web/settings/mcps/__next._full.txt +24 -24
  105. package/dist/web/settings/mcps/__next._head.txt +4 -4
  106. package/dist/web/settings/mcps/__next._index.txt +13 -13
  107. package/dist/web/settings/mcps/__next._tree.txt +2 -2
  108. package/dist/web/settings/mcps/__next.settings.mcps.__PAGE__.txt +4 -4
  109. package/dist/web/settings/mcps/__next.settings.mcps.txt +3 -3
  110. package/dist/web/settings/mcps/__next.settings.txt +5 -5
  111. package/dist/web/settings/mcps.html +1 -1
  112. package/dist/web/settings/mcps.txt +24 -24
  113. package/dist/web/settings/models/__next._full.txt +24 -24
  114. package/dist/web/settings/models/__next._head.txt +4 -4
  115. package/dist/web/settings/models/__next._index.txt +13 -13
  116. package/dist/web/settings/models/__next._tree.txt +2 -2
  117. package/dist/web/settings/models/__next.settings.models.__PAGE__.txt +4 -4
  118. package/dist/web/settings/models/__next.settings.models.txt +3 -3
  119. package/dist/web/settings/models/__next.settings.txt +5 -5
  120. package/dist/web/settings/models.html +1 -1
  121. package/dist/web/settings/models.txt +24 -24
  122. package/dist/web/settings/output-styles/__next._full.txt +24 -24
  123. package/dist/web/settings/output-styles/__next._head.txt +4 -4
  124. package/dist/web/settings/output-styles/__next._index.txt +13 -13
  125. package/dist/web/settings/output-styles/__next._tree.txt +2 -2
  126. package/dist/web/settings/output-styles/__next.settings.output-styles.__PAGE__.txt +4 -4
  127. package/dist/web/settings/output-styles/__next.settings.output-styles.txt +3 -3
  128. package/dist/web/settings/output-styles/__next.settings.txt +5 -5
  129. package/dist/web/settings/output-styles.html +1 -1
  130. package/dist/web/settings/output-styles.txt +24 -24
  131. package/dist/web/settings/prompts/__next._full.txt +24 -24
  132. package/dist/web/settings/prompts/__next._head.txt +4 -4
  133. package/dist/web/settings/prompts/__next._index.txt +13 -13
  134. package/dist/web/settings/prompts/__next._tree.txt +2 -2
  135. package/dist/web/settings/prompts/__next.settings.prompts.__PAGE__.txt +4 -4
  136. package/dist/web/settings/prompts/__next.settings.prompts.txt +3 -3
  137. package/dist/web/settings/prompts/__next.settings.txt +5 -5
  138. package/dist/web/settings/prompts.html +1 -1
  139. package/dist/web/settings/prompts.txt +24 -24
  140. package/dist/web/settings/providers/__next._full.txt +24 -24
  141. package/dist/web/settings/providers/__next._head.txt +4 -4
  142. package/dist/web/settings/providers/__next._index.txt +13 -13
  143. package/dist/web/settings/providers/__next._tree.txt +2 -2
  144. package/dist/web/settings/providers/__next.settings.providers.__PAGE__.txt +4 -4
  145. package/dist/web/settings/providers/__next.settings.providers.txt +3 -3
  146. package/dist/web/settings/providers/__next.settings.txt +5 -5
  147. package/dist/web/settings/providers.html +1 -1
  148. package/dist/web/settings/providers.txt +24 -24
  149. package/dist/web/settings/skills/__next._full.txt +24 -24
  150. package/dist/web/settings/skills/__next._head.txt +4 -4
  151. package/dist/web/settings/skills/__next._index.txt +13 -13
  152. package/dist/web/settings/skills/__next._tree.txt +2 -2
  153. package/dist/web/settings/skills/__next.settings.skills.__PAGE__.txt +4 -4
  154. package/dist/web/settings/skills/__next.settings.skills.txt +3 -3
  155. package/dist/web/settings/skills/__next.settings.txt +5 -5
  156. package/dist/web/settings/skills.html +1 -1
  157. package/dist/web/settings/skills.txt +24 -24
  158. package/dist/web/settings/tools/__next._full.txt +24 -24
  159. package/dist/web/settings/tools/__next._head.txt +4 -4
  160. package/dist/web/settings/tools/__next._index.txt +13 -13
  161. package/dist/web/settings/tools/__next._tree.txt +2 -2
  162. package/dist/web/settings/tools/__next.settings.tools.__PAGE__.txt +4 -4
  163. package/dist/web/settings/tools/__next.settings.tools.txt +3 -3
  164. package/dist/web/settings/tools/__next.settings.txt +5 -5
  165. package/dist/web/settings/tools.html +1 -1
  166. package/dist/web/settings/tools.txt +24 -24
  167. package/dist/web/settings.html +1 -1
  168. package/dist/web/settings.txt +33 -32
  169. package/dist/web/workflows/__next._full.txt +31 -33
  170. package/dist/web/workflows/__next._head.txt +4 -4
  171. package/dist/web/workflows/__next._index.txt +13 -13
  172. package/dist/web/workflows/__next._tree.txt +2 -2
  173. package/dist/web/workflows/__next.workflows.__PAGE__.txt +4 -4
  174. package/dist/web/workflows/__next.workflows.txt +3 -3
  175. package/dist/web/workflows.html +1 -1
  176. package/dist/web/workflows.txt +31 -33
  177. package/dist/web/workspace/_/__next._full.txt +28 -29
  178. package/dist/web/workspace/_/__next._head.txt +4 -4
  179. package/dist/web/workspace/_/__next._index.txt +13 -13
  180. package/dist/web/workspace/_/__next._tree.txt +2 -2
  181. package/dist/web/workspace/_/__next.workspace.$d$id.__PAGE__.txt +3 -3
  182. package/dist/web/workspace/_/__next.workspace.$d$id.txt +3 -3
  183. package/dist/web/workspace/_/__next.workspace.txt +3 -3
  184. package/dist/web/workspace/_.html +1 -1
  185. package/dist/web/workspace/_.txt +28 -29
  186. package/dist/web/workspaces/__next._full.txt +29 -31
  187. package/dist/web/workspaces/__next._head.txt +4 -4
  188. package/dist/web/workspaces/__next._index.txt +13 -13
  189. package/dist/web/workspaces/__next._tree.txt +2 -2
  190. package/dist/web/workspaces/__next.workspaces.__PAGE__.txt +4 -4
  191. package/dist/web/workspaces/__next.workspaces.txt +3 -3
  192. package/dist/web/workspaces.html +1 -1
  193. package/dist/web/workspaces.txt +29 -31
  194. package/dist/ws/agent-runner.js +82 -6
  195. package/package.json +10 -11
  196. package/dist/web/_next/static/chunks/0-9194nbxy_6d.js +0 -1
  197. package/dist/web/_next/static/chunks/02mf61htij8g0.js +0 -31
  198. package/dist/web/_next/static/chunks/04dg4l4hv11q2.js +0 -3
  199. package/dist/web/_next/static/chunks/04fxddw-y20~-.js +0 -7
  200. package/dist/web/_next/static/chunks/04w7~5ooz_pwm.js +0 -1
  201. package/dist/web/_next/static/chunks/05oc21sj24wtq.js +0 -1
  202. package/dist/web/_next/static/chunks/08k~meqbd8d6v.js +0 -1
  203. package/dist/web/_next/static/chunks/099h96wjsdb25.js +0 -2
  204. package/dist/web/_next/static/chunks/09h23logvq65m.js +0 -1
  205. package/dist/web/_next/static/chunks/0ake2f3x2uan4.js +0 -24
  206. package/dist/web/_next/static/chunks/0ck8dw_9-1cdx.js +0 -1
  207. package/dist/web/_next/static/chunks/0ewceguykiut5.js +0 -1
  208. package/dist/web/_next/static/chunks/0f7cb9li~3jra.js +0 -67
  209. package/dist/web/_next/static/chunks/0ghs9on7wodrm.js +0 -1
  210. package/dist/web/_next/static/chunks/0h9cu-k6z5o08.js +0 -1
  211. package/dist/web/_next/static/chunks/0jb4~3qqkw2ps.js +0 -1
  212. package/dist/web/_next/static/chunks/0nb8.iteznuvx.js +0 -1
  213. package/dist/web/_next/static/chunks/0os58q93stt7j.js +0 -3
  214. package/dist/web/_next/static/chunks/0ppr271hz0xoq.js +0 -1
  215. package/dist/web/_next/static/chunks/0s9lmk8iauou3.js +0 -1
  216. package/dist/web/_next/static/chunks/0sp_zbx~w0am7.js +0 -1
  217. package/dist/web/_next/static/chunks/0tel~zsv4z8l_.js +0 -1
  218. package/dist/web/_next/static/chunks/0twamv4wr_dbv.js +0 -1
  219. package/dist/web/_next/static/chunks/0uhol5wafdbl~.js +0 -1
  220. package/dist/web/_next/static/chunks/0v7q4mys.mnm..css +0 -1
  221. package/dist/web/_next/static/chunks/0~3xm80~j9ddg.js +0 -1
  222. package/dist/web/_next/static/chunks/14s37n6h0_q3x.js +0 -16
  223. package/dist/web/_next/static/chunks/161ik5kfyuwtd.js +0 -1
  224. package/dist/web/_next/static/chunks/17k~zbv0_4rep.js +0 -1
  225. package/public/output-styles/carmack-mode.md +0 -381
  226. package/public/output-styles/codex-rigor-mode.md +0 -114
  227. package/public/output-styles/dhh-mode.md +0 -265
  228. package/public/output-styles/evan-you-mode.md +0 -539
  229. package/public/output-styles/index.json +0 -37
  230. package/public/output-styles/jobs-mode.md +0 -369
  231. package/public/output-styles/linus-mode.md +0 -135
  232. package/public/output-styles/uncle-bob-mode.md +0 -221
  233. package/public/prompt/andrej-karpathy-skills.md +0 -65
  234. package/public/prompt/claude-token-efficient-coding.md +0 -35
  235. package/public/prompt/index.json +0 -12
  236. package/public/skills/index.json +0 -92
  237. package/public/skills/planning-with-files/planning-with-files-zh/SKILL.md +0 -243
  238. package/public/skills/planning-with-files/planning-with-files-zh/scripts/check-complete.ps1 +0 -44
  239. package/public/skills/planning-with-files/planning-with-files-zh/scripts/check-complete.sh +0 -46
  240. package/public/skills/planning-with-files/planning-with-files-zh/scripts/init-session.ps1 +0 -124
  241. package/public/skills/planning-with-files/planning-with-files-zh/scripts/init-session.sh +0 -124
  242. package/public/skills/planning-with-files/planning-with-files-zh/scripts/session-catchup.py +0 -438
  243. package/public/skills/planning-with-files/planning-with-files-zh/templates/findings.md +0 -29
  244. package/public/skills/planning-with-files/planning-with-files-zh/templates/progress.md +0 -40
  245. package/public/skills/planning-with-files/planning-with-files-zh/templates/task_plan.md +0 -58
  246. package/public/skills/superpowers/brainstorming/SKILL.md +0 -164
  247. package/public/skills/superpowers/brainstorming/scripts/frame-template.html +0 -214
  248. package/public/skills/superpowers/brainstorming/scripts/helper.js +0 -88
  249. package/public/skills/superpowers/brainstorming/scripts/server.cjs +0 -354
  250. package/public/skills/superpowers/brainstorming/scripts/start-server.sh +0 -148
  251. package/public/skills/superpowers/brainstorming/scripts/stop-server.sh +0 -56
  252. package/public/skills/superpowers/brainstorming/spec-document-reviewer-prompt.md +0 -49
  253. package/public/skills/superpowers/brainstorming/visual-companion.md +0 -287
  254. package/public/skills/superpowers/dispatching-parallel-agents/SKILL.md +0 -182
  255. package/public/skills/superpowers/executing-plans/SKILL.md +0 -70
  256. package/public/skills/superpowers/finishing-a-development-branch/SKILL.md +0 -251
  257. package/public/skills/superpowers/receiving-code-review/SKILL.md +0 -213
  258. package/public/skills/superpowers/requesting-code-review/SKILL.md +0 -103
  259. package/public/skills/superpowers/requesting-code-review/code-reviewer.md +0 -168
  260. package/public/skills/superpowers/subagent-driven-development/SKILL.md +0 -279
  261. package/public/skills/superpowers/subagent-driven-development/code-quality-reviewer-prompt.md +0 -25
  262. package/public/skills/superpowers/subagent-driven-development/implementer-prompt.md +0 -113
  263. package/public/skills/superpowers/subagent-driven-development/spec-reviewer-prompt.md +0 -61
  264. package/public/skills/superpowers/systematic-debugging/CREATION-LOG.md +0 -119
  265. package/public/skills/superpowers/systematic-debugging/SKILL.md +0 -296
  266. package/public/skills/superpowers/systematic-debugging/condition-based-waiting-example.ts +0 -158
  267. package/public/skills/superpowers/systematic-debugging/condition-based-waiting.md +0 -115
  268. package/public/skills/superpowers/systematic-debugging/defense-in-depth.md +0 -122
  269. package/public/skills/superpowers/systematic-debugging/find-polluter.sh +0 -63
  270. package/public/skills/superpowers/systematic-debugging/root-cause-tracing.md +0 -169
  271. package/public/skills/superpowers/systematic-debugging/test-academic.md +0 -14
  272. package/public/skills/superpowers/systematic-debugging/test-pressure-1.md +0 -58
  273. package/public/skills/superpowers/systematic-debugging/test-pressure-2.md +0 -68
  274. package/public/skills/superpowers/systematic-debugging/test-pressure-3.md +0 -69
  275. package/public/skills/superpowers/test-driven-development/SKILL.md +0 -371
  276. package/public/skills/superpowers/test-driven-development/testing-anti-patterns.md +0 -299
  277. package/public/skills/superpowers/using-git-worktrees/SKILL.md +0 -215
  278. package/public/skills/superpowers/using-superpowers/SKILL.md +0 -117
  279. package/public/skills/superpowers/using-superpowers/references/codex-tools.md +0 -59
  280. package/public/skills/superpowers/using-superpowers/references/copilot-tools.md +0 -42
  281. package/public/skills/superpowers/using-superpowers/references/gemini-tools.md +0 -51
  282. package/public/skills/superpowers/verification-before-completion/SKILL.md +0 -139
  283. package/public/skills/superpowers/writing-plans/SKILL.md +0 -152
  284. package/public/skills/superpowers/writing-plans/plan-document-reviewer-prompt.md +0 -49
  285. package/public/skills/superpowers/writing-skills/SKILL.md +0 -655
  286. package/public/skills/superpowers/writing-skills/anthropic-best-practices.md +0 -1150
  287. package/public/skills/superpowers/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -189
  288. package/public/skills/superpowers/writing-skills/graphviz-conventions.dot +0 -172
  289. package/public/skills/superpowers/writing-skills/persuasion-principles.md +0 -187
  290. package/public/skills/superpowers/writing-skills/render-graphs.js +0 -168
  291. package/public/skills/superpowers/writing-skills/testing-skills-with-subagents.md +0 -384
  292. /package/dist/web/_next/static/{e8w3vd9Eov_LDYWj_0zsE → x4-CsKe6qUQyFDWVtfvUg}/_buildManifest.js +0 -0
  293. /package/dist/web/_next/static/{e8w3vd9Eov_LDYWj_0zsE → x4-CsKe6qUQyFDWVtfvUg}/_clientMiddlewareManifest.js +0 -0
  294. /package/dist/web/_next/static/{e8w3vd9Eov_LDYWj_0zsE → x4-CsKe6qUQyFDWVtfvUg}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,940361,e=>{"use strict";var t=e.i(344180);e.s([],2365),e.i(2365);var n=e.i(764556),s=e.i(394822),a=e.i(174465),r=e.i(648224),i=e.i(35359);e.i(8890);var o=e.i(422561),l=e.i(526850),d=e.i(232449),c=e.i(410421),u=e.i(150129),m=e.i(969490),x=e.i(602453),p=e.i(817955),g=e.i(742665),f=e.i(87709);let h=n.forwardRef(function(e,t){let{render:s,className:r,style:h,...v}=e,{setAnchor:j,actionsRef:w,internalBackdropRef:b,backdropRef:k,positionerRef:C,allowMouseUpTriggerRef:y,initialCursorPointRef:N,rootId:D}=(0,a.useContextMenuRootContext)(!1),{store:M}=(0,i.useMenuRootContext)(!1),S=M.useState("open"),T=M.useState("disabled"),I=n.useRef(null),A=n.useRef(null),R=(0,d.useTimeout)(),z=(0,d.useTimeout)(),P=n.useRef(!1);function _(e,t,n){let s=n.type.startsWith("touch");N.current={x:e,y:t},j({getBoundingClientRect:()=>DOMRect.fromRect({width:10*!!s,height:10*!!s,x:e,y:t})}),P.current=!1,w.current?.setOpen(!0,(0,x.createChangeEventDetails)(g.REASONS.triggerPress,n)),z.start(500,()=>{P.current=!0})}function O(){R.clear(),A.current=null}return n.useEffect(()=>{let e=(0,l.ownerDocument)(I.current);return(0,o.addEventListener)(e,"contextmenu",function(e){if(T)return;let t=(0,c.getTarget)(e);((0,c.contains)(I.current,t)||(0,c.contains)(b.current,t)||(0,c.contains)(k.current,t))&&e.preventDefault()})},[k,T,b]),(0,m.useRenderElement)("div",e,{state:{open:S},ref:[I,t],props:[{onContextMenu:function(e){if(T)return;y.current=!0,(0,u.stopEvent)(e),_(e.clientX,e.clientY,e.nativeEvent);let t=(0,l.ownerDocument)(I.current);(0,o.addEventListener)(t,"mouseup",e=>{if(y.current=!1,!P.current)return;z.clear(),P.current=!1;let t=(0,c.getTarget)(e);(0,c.contains)(C.current,t)||D&&t&&(0,f.findRootOwnerId)(t)===D||w.current?.setOpen(!1,(0,x.createChangeEventDetails)(g.REASONS.cancelOpen,e))},{once:!0})},onTouchStart:function(e){if(!T&&(y.current=!1,1===e.touches.length)){e.stopPropagation();let t=e.touches[0];A.current={x:t.clientX,y:t.clientY},R.start(500,()=>{A.current&&_(A.current.x,A.current.y,e.nativeEvent)})}},onTouchMove:function(e){if(R.isStarted()&&A.current&&1===e.touches.length){let t=e.touches[0],n=Math.abs(t.clientX-A.current.x),s=Math.abs(t.clientY-A.current.y);(n>10||s>10)&&R.clear()}},onTouchEnd:O,onTouchCancel:O,style:{WebkitTouchCallout:"none"}},v],stateAttributesMapping:p.pressableTriggerOpenStateMapping})});var v=e.i(487455),j=e.i(293209),w=e.i(503662),b=e.i(33427),k=e.i(324573),C=e.i(582883),y=e.i(277658),N=e.i(349204),D=e.i(28051),M=e.i(597375),S=e.i(81752),T=e.i(59354),I=e.i(300637),A=e.i(281478),R=e.i(65255),z=e.i(327794),P=e.i(362962);e.s(["Arrow",()=>k.MenuArrow,"Backdrop",()=>v.MenuBackdrop,"CheckboxItem",()=>D.MenuCheckboxItem,"CheckboxItemIndicator",()=>M.MenuCheckboxItemIndicator,"Group",()=>C.MenuGroup,"GroupLabel",()=>y.MenuGroupLabel,"Item",()=>N.MenuItem,"LinkItem",()=>S.MenuLinkItem,"Popup",()=>b.MenuPopup,"Portal",()=>j.MenuPortal,"Positioner",()=>w.MenuPositioner,"RadioGroup",()=>T.MenuRadioGroup,"RadioItem",()=>I.MenuRadioItem,"RadioItemIndicator",()=>A.MenuRadioItemIndicator,"Root",0,function(e){let[o,l]=n.useState({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,x:0,y:0})}),d=n.useRef(null),c=n.useRef(null),u=n.useRef(null),m=n.useRef(null),x=n.useRef(!0),p=n.useRef(null),g=(0,s.useId)(),f=n.useMemo(()=>({anchor:o,setAnchor:l,actionsRef:u,backdropRef:d,internalBackdropRef:c,positionerRef:m,allowMouseUpTriggerRef:x,initialCursorPointRef:p,rootId:g}),[o,g]);return(0,t.jsx)(a.ContextMenuRootContext.Provider,{value:f,children:(0,t.jsx)(i.MenuRootContext.Provider,{value:void 0,children:(0,t.jsx)(r.Menu.Root,{...e})})})},"Separator",()=>P.Separator,"SubmenuRoot",()=>R.MenuSubmenuRoot,"SubmenuTrigger",()=>z.MenuSubmenuTrigger,"Trigger",0,h],912001);var _=e.i(912001),_=_,O=e.i(465458),E=e.i(932031);function W({className:e,align:n="start",alignOffset:s=4,side:a="right",sideOffset:r=0,...i}){return(0,t.jsx)(_.Portal,{children:(0,t.jsx)(_.Positioner,{className:"isolate z-50 outline-none",align:n,alignOffset:s,side:a,sideOffset:r,children:(0,t.jsx)(_.Popup,{"data-slot":"context-menu-content",className:(0,O.cn)("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...i})})})}e.i(299648),e.s(["ContextMenu",0,function({...e}){return(0,t.jsx)(_.Root,{"data-slot":"context-menu",...e})},"ContextMenuContent",0,W,"ContextMenuItem",0,function({className:e,inset:n,variant:s="default",...a}){return(0,t.jsx)(_.Item,{"data-slot":"context-menu-item","data-inset":n,"data-variant":s,className:(0,O.cn)("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",e),...a})},"ContextMenuSeparator",0,function({className:e,...n}){return(0,t.jsx)(_.Separator,{"data-slot":"context-menu-separator",className:(0,O.cn)("-mx-1 my-1 h-px bg-border",e),...n})},"ContextMenuSub",0,function({...e}){return(0,t.jsx)(_.SubmenuRoot,{"data-slot":"context-menu-sub",...e})},"ContextMenuSubContent",0,function({...e}){return(0,t.jsx)(W,{"data-slot":"context-menu-sub-content",className:"shadow-lg",side:"right",...e})},"ContextMenuSubTrigger",0,function({className:e,inset:n,children:s,...a}){return(0,t.jsxs)(_.SubmenuTrigger,{"data-slot":"context-menu-sub-trigger","data-inset":n,className:(0,O.cn)("flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...a,children:[s,(0,t.jsx)(E.ChevronRightIcon,{className:"ml-auto"})]})},"ContextMenuTrigger",0,function({className:e,...n}){return(0,t.jsx)(_.Trigger,{"data-slot":"context-menu-trigger",className:(0,O.cn)("select-none",e),...n})}],940361)},302773,e=>{"use strict";let t=(0,e.i(816709).create)((e,t)=>({workflows:[],currentWorkflow:null,isLoading:!1,loadWorkflows:async()=>{e({isLoading:!0});try{let t=await fetch("/api/workflows"),n=await t.json();e({workflows:n,isLoading:!1})}catch{e({isLoading:!1})}},createWorkflow:async t=>{let n=await fetch("/api/workflows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),s=await n.json();return e(e=>({workflows:[...e.workflows,s]})),s},updateWorkflow:async(e,n)=>{let s=await fetch(`/api/workflows/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),a=await s.json();t().upsertWorkflow(a)},deleteWorkflow:async e=>{await fetch(`/api/workflows/${e}`,{method:"DELETE"}),t().removeWorkflow(e)},duplicateWorkflow:async t=>{let n=await fetch(`/api/workflows/${t}/duplicate`,{method:"POST"}),s=await n.json();e(e=>({workflows:[...e.workflows,s]}))},setCurrentWorkflow:t=>e({currentWorkflow:t}),upsertWorkflow:t=>{e(e=>{let n=e.workflows.findIndex(e=>e.id===t.id);if(-1!==n){let s=[...e.workflows];return s[n]=t,{workflows:s}}return{workflows:[...e.workflows,t]}})},removeWorkflow:t=>{e(e=>({workflows:e.workflows.filter(e=>e.id!==t),currentWorkflow:e.currentWorkflow?.id===t?null:e.currentWorkflow}))}}));e.s(["useWorkflowStore",0,t])},358989,e=>{"use strict";var t=e.i(344180),n=e.i(764556),s=e.i(244073),a=e.i(209988),r=e.i(260218),i=e.i(681622),o=e.i(788010),l=e.i(595390),d=e.i(272736),c=e.i(302773);let u=["draft","planned","in_progress","review_pending","changes_requested","approved","completed","archived"];e.s(["EditIssueDialog",0,function({issue:e,open:m,onOpenChange:x,agents:p=[],onSave:g}){let[f,h]=(0,n.useState)(e.title),[v,j]=(0,n.useState)(e.description),[w,b]=(0,n.useState)(e.status),[k,C]=(0,n.useState)(e.members||[]),[y,N]=(0,n.useState)(!1),[D,M]=(0,n.useState)(e.workflowId??""),{workflows:S,loadWorkflows:T}=(0,c.useWorkflowStore)(),I=(0,s.useTranslations)("issue"),A=(0,s.useTranslations)("common");(0,n.useEffect)(()=>{m&&(h(e.title),j(e.description),b(e.status),C(e.members?.length?[...e.members]:[]),M(e.workflowId??""))},[m,e]),(0,n.useEffect)(()=>{m&&T()},[m,T]);let R=async()=>{if(f.trim()){N(!0);try{await g({title:f.trim(),description:v.trim(),status:w,members:k,workflowId:"__none__"===D?null:D||null}),x(!1)}finally{N(!1)}}},z=(0,n.useMemo)(()=>p.filter(e=>!1!==e.enabled).map((e,t)=>({id:e.id,label:(0,d.getMemberDisplayName)(p,e.id),description:e.role,sortIndex:t})),[p]);return(0,t.jsx)(a.Dialog,{open:m,onOpenChange:x,children:(0,t.jsxs)(a.DialogContent,{className:"sm:max-w-md max-h-[85vh] p-0 gap-0 flex flex-col overflow-hidden",children:[(0,t.jsxs)(a.DialogHeader,{className:"px-4 py-4 shrink-0",children:[(0,t.jsx)(a.DialogTitle,{children:I("edit.title")}),(0,t.jsx)(a.DialogDescription,{children:I("edit.description")})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 pb-4",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(i.Input,{placeholder:I("edit.titlePlaceholder"),value:f,onChange:e=>h(e.target.value),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()}),(0,t.jsx)(o.Textarea,{placeholder:I("edit.descriptionPlaceholder"),value:v,onChange:e=>j(e.target.value),rows:3}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:I("edit.statusLabel")}),(0,t.jsx)("select",{value:w,onChange:e=>b(e.target.value),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:u.map(e=>(0,t.jsx)("option",{value:e,children:I(`status.${e}`)},e))})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Workflow Template"}),(0,t.jsxs)("select",{value:D||"__none__",onChange:e=>(e=>{if(M(e),!e)return;let t=S.find(t=>t.id===e);if(!t)return;let n=t.nodes.map(e=>e.data.agentConfigId);C(e=>Array.from(new Set([...e,...n])))})("__none__"===e.target.value?"":e.target.value),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[(0,t.jsx)("option",{value:"__none__",children:"None (use default pipeline)"}),S.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name," (",e.nodes.length," agents)"]},e.id))]})]}),(0,t.jsx)(l.MemberPicker,{candidates:z,selected:k,onToggle:e=>{C(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},label:I("edit.membersLabel"),searchPlaceholder:I("edit.searchAgent"),emptyText:I("edit.noAgents")}),(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,t.jsx)(r.Button,{variant:"outline",onClick:()=>x(!1),children:A("cancel")}),(0,t.jsx)(r.Button,{onClick:R,disabled:!f.trim()||y,children:A(y?"saving":"save")})]})]})})]})})}])},595390,e=>{"use strict";var t=e.i(344180),n=e.i(764556),s=e.i(681622),a=e.i(611176),r=e.i(972846);let i=e=>!["scheduler","task_creator","bot"].includes(e.description||"")&&"agent-generator"!==e.id;e.s(["MemberPicker",0,function({candidates:e,selected:o,onToggle:l,searchPlaceholder:d,emptyText:c,label:u,filter:m}){let[x,p]=(0,n.useState)(""),g=e.filter(m??i).sort((e,t)=>(e.sortIndex??0)-(t.sortIndex??0)).filter(e=>`${e.label} ${e.description||""}`.toLowerCase().includes(x.toLowerCase()));return(0,t.jsxs)("div",{className:"space-y-2",children:[u&&(0,t.jsx)("label",{className:"text-sm font-medium",children:u}),(0,t.jsx)(s.Input,{value:x,onChange:e=>p(e.target.value),placeholder:d}),(0,t.jsxs)("div",{className:"max-h-40 overflow-y-auto space-y-0.5",children:[0===g.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-2 text-center",children:c||"No items found"}),g.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>l(e.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[(0,t.jsx)(a.AgentIcon,{agentId:"user"!==e.id?e.id:void 0,name:e.label,className:"size-5 rounded-full"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate",children:e.label}),e.description&&(0,t.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,t.jsx)("div",{className:`flex items-center justify-center size-4 rounded border shrink-0 ${o.includes(e.id)?"bg-primary border-primary text-primary-foreground":"border-input"}`})]},e.id))]}),o.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:o.map(n=>{let s=e.find(e=>e.id===n),i=s?.label||n;return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs max-w-[160px] min-w-0",children:["user"===n?(0,t.jsx)("span",{className:"truncate",children:i}):(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 min-w-0",children:[(0,t.jsx)(a.AgentIcon,{agentId:n,name:i,className:"size-3.5 rounded-full shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:i})]}),(0,t.jsx)("button",{type:"button",onClick:()=>l(n),className:"hover:text-destructive shrink-0 cursor-pointer",children:(0,t.jsx)(r.X,{className:"size-3"})})]},n)})})]})}])},272736,e=>{"use strict";function t(e){return e.name?.trim()||e.role}e.s(["getAgentDisplayName",0,t,"getMemberDisplayName",0,function(e,n){if("user"===n)return"user";let s=e.find(e=>e.id===n);return s?t(s):n},"normalizeChannelMembersToAgentIds",0,function(e,t){let n=new Set(e.map(e=>e.id)),s=[],a=new Set;for(let e of t)n.has(e)&&(a.has(e)||(a.add(e),s.push(e)));return s}])},79882,e=>{"use strict";let t=(0,e.i(433721).default)("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);e.s(["Archive",0,t],79882)},734649,e=>{"use strict";var t=e.i(344180),n=e.i(764556);e.s([],764940),e.i(764940);var s=e.i(956834),a=e.i(625386),r=e.i(530089),i=e.i(975983),o=e.i(16223),l=e.i(583901),d=e.i(512519),c=e.i(152851),u=e.i(481181),m=e.i(476343),x=e.i(272248),p=e.i(625144),g=e.i(225171);e.s(["Backdrop",()=>o.DialogBackdrop,"Close",()=>l.DialogClose,"Description",()=>d.DialogDescription,"Handle",()=>g.DialogHandle,"Popup",()=>c.DialogPopup,"Portal",()=>u.DialogPortal,"Root",0,function(e){let{children:o,open:l,defaultOpen:d=!1,onOpenChange:c,onOpenChangeComplete:u,actionsRef:m,handle:x,triggerId:p,defaultTriggerId:g=null}=e,f=(0,r.useDialogRootContext)(!0),h=!!f,v=i.DialogStore.useStore(x?.store,{open:d,openProp:l,activeTriggerId:g,triggerIdProp:p,modal:!0,disablePointerDismissal:!0,nested:h,role:"alertdialog"});v.useControlledProp("openProp",l),v.useControlledProp("triggerIdProp",p),v.useSyncedValue("nested",h),v.useContextCallback("onOpenChange",c),v.useContextCallback("onOpenChangeComplete",u);let j=v.useState("payload");(0,a.useDialogRoot)({store:v,actionsRef:m,parentContext:f?.store.context,isDrawer:!1,onOpenChange:c,triggerIdProp:p});let w=n.useMemo(()=>({store:v}),[v]);return(0,t.jsx)(s.IsDrawerContext.Provider,{value:!1,children:(0,t.jsx)(r.DialogRootContext.Provider,{value:w,children:"function"==typeof o?o({payload:j}):o})})},"Title",()=>m.DialogTitle,"Trigger",()=>x.DialogTrigger,"Viewport",()=>p.DialogViewport,"createHandle",0,function(){return new g.DialogHandle(new i.DialogStore({modal:!0,disablePointerDismissal:!0,role:"alertdialog"}))}],756198);var f=e.i(756198),f=f,h=e.i(465458),v=e.i(260218),j=e.i(250226);function w({...e}){return(0,t.jsx)(f.Portal,{"data-slot":"alert-dialog-portal",...e})}function b({className:e,...n}){return(0,t.jsx)(f.Backdrop,{"data-slot":"alert-dialog-overlay",className:(0,h.cn)("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...n})}e.s(["AlertDialog",0,function({ignoreBack:e=!1,...s}){let a=n.useId(),r=(0,j.useMobilePanelStore)(e=>e.registerOverlay),i=(0,j.useMobilePanelStore)(e=>e.unregisterOverlay),o="open"in s?s.open:"defaultOpen"in s?s.defaultOpen:void 0,l=s.onOpenChange,d=n.useRef(l);return n.useEffect(()=>{d.current=l},[l]),n.useEffect(()=>o&&!e&&d.current?(r(a,()=>d.current?.(!1,{reason:void 0})),()=>i(a)):void i(a),[e,o,a,r,i]),(0,t.jsx)(f.Root,{"data-slot":"alert-dialog",...s})},"AlertDialogAction",0,function({className:e,...n}){return(0,t.jsx)(v.Button,{"data-slot":"alert-dialog-action",className:(0,h.cn)(e),...n})},"AlertDialogCancel",0,function({className:e,variant:n="outline",size:s="default",...a}){return(0,t.jsx)(f.Close,{"data-slot":"alert-dialog-cancel",className:(0,h.cn)(e),render:(0,t.jsx)(v.Button,{variant:n,size:s}),...a})},"AlertDialogContent",0,function({className:e,size:n="default",...s}){return(0,t.jsxs)(w,{children:[(0,t.jsx)(b,{}),(0,t.jsx)(f.Popup,{"data-slot":"alert-dialog-content","data-size":n,className:(0,h.cn)("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...s})]})},"AlertDialogDescription",0,function({className:e,...n}){return(0,t.jsx)(f.Description,{"data-slot":"alert-dialog-description",className:(0,h.cn)("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...n})},"AlertDialogFooter",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,h.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...n})},"AlertDialogHeader",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,h.cn)("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...n})},"AlertDialogTitle",0,function({className:e,...n}){return(0,t.jsx)(f.Title,{"data-slot":"alert-dialog-title",className:(0,h.cn)("font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...n})}],734649)},414053,725161,e=>{"use strict";var t=e.i(433721);let n=(0,t.default)("archive-restore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);e.s(["ArchiveRestore",0,n],414053);let s=(0,t.default)("arrow-up-down",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);e.s(["ArrowUpDown",0,s],725161)},308557,e=>{"use strict";var t=e.i(344180),n=e.i(764556),s=e.i(244073),a=e.i(327964),r=e.i(355819),i=e.i(562918),o=e.i(260218),l=e.i(191118),d=e.i(940361),c=e.i(256186),u=e.i(917955),m=e.i(734649),x=e.i(953700),p=e.i(592039),g=e.i(962562),f=e.i(137340),h=e.i(612505),h=h,v=e.i(79882),j=e.i(414053),w=e.i(315775),b=e.i(992764),k=e.i(344118),C=e.i(725161),y=e.i(613087),N=e.i(465458),D=e.i(209988),M=e.i(681622),S=e.i(788010),T=e.i(595390),I=e.i(272736),A=e.i(302773);function R({open:e,onOpenChange:a,agents:r=[],onSubmit:i}){let[l,d]=(0,n.useState)(""),[c,u]=(0,n.useState)(""),[m,x]=(0,n.useState)([]),[p,g]=(0,n.useState)(""),{workflows:f,loadWorkflows:h}=(0,A.useWorkflowStore)(),v=(0,s.useTranslations)("issue"),j=(0,s.useTranslations)("common"),w=r.filter(e=>!1!==e.enabled).map((e,t)=>({id:e.id,label:(0,I.getMemberDisplayName)(r,e.id),sortIndex:t}));(0,n.useEffect)(()=>{e&&h()},[e,h]);let b=e=>{e||(d(""),u(""),x([]),g("")),a(e)};return(0,t.jsx)(D.Dialog,{open:e,onOpenChange:b,children:(0,t.jsxs)(D.DialogContent,{className:"sm:max-w-md",children:[(0,t.jsxs)(D.DialogHeader,{children:[(0,t.jsx)(D.DialogTitle,{children:v("create.title")}),(0,t.jsx)(D.DialogDescription,{children:v("create.description")})]}),(0,t.jsxs)("div",{className:"space-y-3 pt-2",children:[(0,t.jsx)(M.Input,{placeholder:v("create.titlePlaceholder"),value:l,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()}),(0,t.jsx)(S.Textarea,{placeholder:v("create.descriptionPlaceholder"),value:c,onChange:e=>u(e.target.value),rows:3}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Workflow Template"}),(0,t.jsxs)("select",{value:p,onChange:e=>{let t=e.target.value;if(g(t),t){let e=f.find(e=>e.id===t);if(e){let t=e.nodes.map(e=>e.data.agentConfigId);x(e=>Array.from(new Set([...e,...t])))}}},className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[(0,t.jsx)("option",{value:"",children:"None (use default pipeline)"}),f.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name," (",e.nodes.length," agents)"]},e.id))]})]}),(0,t.jsx)(T.MemberPicker,{candidates:w,selected:m,onToggle:e=>{x(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},label:v("create.membersLabel"),searchPlaceholder:v("create.searchAgent"),emptyText:v("create.noAgents")},String(e)),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(o.Button,{variant:"outline",onClick:()=>b(!1),children:j("cancel")}),(0,t.jsx)(o.Button,{onClick:()=>{l.trim()&&(i({title:l.trim(),description:c.trim(),members:m,workflowId:p||void 0}),b(!1))},disabled:!l.trim(),children:v("create.submit")})]})]})]})})}var z=e.i(358989);let P={draft:"bg-muted text-muted-foreground",planned:"bg-blue-500/10 text-blue-600 dark:text-blue-400",in_progress:"bg-amber-500/10 text-amber-600 dark:text-amber-400",review_pending:"bg-purple-500/10 text-purple-600 dark:text-purple-400",changes_requested:"bg-orange-500/10 text-orange-600 dark:text-orange-400",approved:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",completed:"bg-green-600/10 text-green-600 dark:text-green-400",archived:"bg-muted text-muted-foreground",error:"bg-destructive/10 text-destructive"},_=["in_progress","review_pending","changes_requested","draft","planned","approved","completed","error"],O=["today","yesterday","thisWeek","earlier"],E={today:"timeToday",yesterday:"timeYesterday",thisWeek:"timeThisWeek",earlier:"timeEarlier"};e.s(["IssueList",0,function({workspaceId:e}){let{issues:D,activeIssueId:M,loading:S,loadIssues:T,createIssue:I,updateIssue:A,updateIssueStatus:W,deleteIssue:B,setActiveIssue:L}=(0,a.useIssueStore)(),{agents:$,ensure:H}=(0,r.useAgentStore)(),[G,q]=(0,n.useState)(!1),[U,V]=(0,n.useState)(null),[Y,K]=(0,n.useState)(!1),[X,F]=(0,n.useState)("status"),[J,Q]=(0,n.useState)({}),[Z,ee]=(0,n.useState)(!1),[et,en]=(0,n.useState)("createdAt"),[es,ea]=(0,n.useState)("desc"),er=(0,s.useTranslations)("issue"),ei=(0,s.useTranslations)("common");(0,n.useEffect)(()=>{T(e),H()},[e,T,H]);let eo=async t=>{await I(e,t.title,t.description,t.members,t.workflowId)},el=(0,n.useMemo)(()=>D.filter(e=>"archived"!==e.status),[D]),ed=(0,n.useMemo)(()=>D.filter(e=>"archived"===e.status),[D]),ec=(0,n.useMemo)(()=>{let e=[...el];return e.sort((e,t)=>{let n=0;switch(et){case"createdAt":n=new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime();break;case"updatedAt":n=new Date(e.updatedAt).getTime()-new Date(t.updatedAt).getTime();break;case"status":{let s=_.indexOf(e.status),a=_.indexOf(t.status);n=(-1===s?99:s)-(-1===a?99:a)}}return"desc"===es?-n:n}),e},[el,et,es]),eu=_.map(e=>({status:e,items:ec.filter(t=>t.status===e)})).filter(e=>e.items.length>0),em=(0,n.useMemo)(()=>{let e={};for(let t of ec){let n=function(e){let t=new Date(e),n=new Date,s=new Date(n.getFullYear(),n.getMonth(),n.getDate()),a=new Date(s.getTime()-864e5),r=new Date(s.getTime()-6048e5);return t>=s?"today":t>=a?"yesterday":t>=r?"thisWeek":"earlier"}(t.createdAt);e[n]||(e[n]=[]),e[n].push(t)}return O.filter(t=>e[t]?.length).map(t=>({key:t,label:ei(E[t]),items:e[t]}))},[ec,ei]),ex=n=>(0,t.jsxs)(d.ContextMenu,{children:[(0,t.jsxs)(d.ContextMenuTrigger,{onClick:()=>L(n.id),className:`w-full text-left px-3 py-2 hover:bg-accent/50 transition-colors flex items-start gap-2 ${M===n.id?"bg-accent":""}`,children:[(0,t.jsx)(p.CircleDot,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:"text-sm font-medium truncate",children:n.title}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:er("list.taskCount",{count:n.tasks.length})})]}),(0,t.jsx)(i.Badge,{variant:"outline",className:`text-[10px] shrink-0 border-none ${P[n.status]}`,children:er(`status.${n.status}`)})]}),(0,t.jsxs)(d.ContextMenuContent,{children:[(0,t.jsxs)(d.ContextMenuItem,{onClick:()=>V(n),children:[(0,t.jsx)(g.Pencil,{className:"size-4 mr-2"}),ei("edit")]}),(0,t.jsx)(d.ContextMenuSeparator,{}),(0,t.jsxs)(d.ContextMenuItem,{onClick:()=>ep(n),children:[(0,t.jsx)(v.Archive,{className:"size-4 mr-2"}),er("list.archive")]}),(0,t.jsx)(d.ContextMenuSeparator,{}),(0,t.jsxs)(d.ContextMenuItem,{variant:"destructive",onClick:()=>B(e,n.id),children:[(0,t.jsx)(f.Trash2,{className:"size-4 mr-2"}),ei("delete")]})]})]},n.id),ep=async t=>{let n="archived"===t.status?"completed":"archived";await W(e,t.id,n)},eg=async()=>{await Promise.all(ed.map(t=>B(e,t.id))),ee(!1)};return S?(0,t.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,t.jsx)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b text-xs font-medium text-muted-foreground shrink-0",children:(0,t.jsx)("span",{children:er("list.title")})}),(0,t.jsx)("div",{className:"p-2 space-y-1",children:(0,t.jsx)(y.SkeletonGroup,{count:5,children:e=>(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md",children:[(0,t.jsx)(y.Skeleton,{className:"size-4 rounded-full shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 space-y-1.5",children:[(0,t.jsx)(y.Skeleton,{className:"h-4 w-3/4"}),(0,t.jsx)(y.Skeleton,{className:"h-3 w-1/2"})]}),(0,t.jsx)(y.Skeleton,{className:"h-4 w-12 rounded-full"})]},e)})})]}):(0,t.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b text-xs font-medium text-muted-foreground shrink-0",children:[(0,t.jsx)("span",{children:er("list.title")}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,t.jsx)("button",{onClick:()=>q(!0),className:"p-0.5 hover:bg-accent rounded cursor-pointer",children:(0,t.jsx)(x.Plus,{className:"size-3.5"})}),(0,t.jsxs)(u.DropdownMenu,{children:[(0,t.jsx)(u.DropdownMenuTrigger,{className:"p-0.5 hover:bg-accent rounded",children:(0,t.jsx)(C.ArrowUpDown,{className:"size-3.5"})}),(0,t.jsx)(u.DropdownMenuContent,{align:"end",className:"min-w-40",children:[{field:"createdAt",label:ei("sortByCreated")},{field:"updatedAt",label:ei("sortByLastReply")},{field:"status",label:ei("sortByStatus")}].map(({field:e,label:n})=>(0,t.jsxs)(u.DropdownMenuItem,{onClick:()=>{et===e?ea(e=>"asc"===e?"desc":"asc"):(en(e),ea("desc"))},children:[et===e&&(0,t.jsx)(k.Check,{className:"size-3.5"}),n,et===e&&(0,t.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"asc"===es?"↑":"↓"})]},e))})]}),(0,t.jsxs)(u.DropdownMenu,{children:[(0,t.jsx)(u.DropdownMenuTrigger,{className:"p-0.5 hover:bg-accent rounded",children:(0,t.jsx)(w.MoreHorizontal,{className:"size-3.5"})}),(0,t.jsxs)(u.DropdownMenuContent,{align:"end",className:"min-w-48",children:[(0,t.jsxs)(u.DropdownMenuItem,{onClick:()=>F("none"),children:["none"===X&&(0,t.jsx)(k.Check,{className:"size-3.5"}),ei("groupNone")]}),(0,t.jsxs)(u.DropdownMenuItem,{onClick:()=>F("time"),children:["time"===X&&(0,t.jsx)(k.Check,{className:"size-3.5"}),ei("groupByTime")]}),(0,t.jsxs)(u.DropdownMenuItem,{onClick:()=>F("status"),children:["status"===X&&(0,t.jsx)(k.Check,{className:"size-3.5"}),ei("groupByStatus")]}),(0,t.jsx)(u.DropdownMenuSeparator,{}),(0,t.jsxs)(u.DropdownMenuItem,{disabled:0===ed.length,onClick:()=>ee(!0),children:[(0,t.jsx)(f.Trash2,{className:"size-3.5"}),er("list.clearArchived")]})]})]})]})]}),(0,t.jsxs)(l.ScrollArea,{className:"min-h-0 flex-1 overflow-hidden",children:[0===eu.length&&0===ed.length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 px-4 text-center py-12",children:[(0,t.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,t.jsx)(h.default,{className:"h-5 w-5 text-muted-foreground"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:er("list.emptyTitle")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:er("list.emptyDescription")})]}),(0,t.jsxs)(o.Button,{size:"sm",variant:"outline",onClick:()=>q(!0),children:[(0,t.jsx)(x.Plus,{className:"h-3.5 w-3.5 mr-1"}),er("list.addIssue")]})]}),"none"===X&&ec.map(e=>ex(e)),"status"===X&&eu.map(e=>(0,t.jsxs)(c.Collapsible,{open:!1!==J[e.status],onOpenChange:t=>Q(n=>({...n,[e.status]:t})),children:[(0,t.jsxs)(c.CollapsibleTrigger,{className:"flex items-center gap-1 w-full px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent transition-colors",children:[(0,t.jsx)(b.ChevronRight,{className:(0,N.cn)("size-3 transition-transform",!1!==J[e.status]&&"rotate-90")}),er(`status.${e.status}`)," (",e.items.length,")"]}),(0,t.jsx)(c.CollapsibleContent,{children:e.items.map(e=>ex(e))})]},e.status)),"time"===X&&em.map(e=>(0,t.jsxs)(c.Collapsible,{open:!1!==J[e.key],onOpenChange:t=>Q(n=>({...n,[e.key]:t})),children:[(0,t.jsxs)(c.CollapsibleTrigger,{className:"flex items-center gap-1 w-full px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent transition-colors",children:[(0,t.jsx)(b.ChevronRight,{className:(0,N.cn)("size-3 transition-transform",!1!==J[e.key]&&"rotate-90")}),e.label," (",e.items.length,")"]}),(0,t.jsx)(c.CollapsibleContent,{children:e.items.map(e=>ex(e))})]},e.key)),ed.length>0&&(0,t.jsxs)(c.Collapsible,{open:Y,onOpenChange:K,children:[(0,t.jsxs)(c.CollapsibleTrigger,{className:"flex items-center gap-1 w-full px-3 py-1 text-xs font-medium text-muted-foreground hover:bg-accent transition-colors",children:[(0,t.jsx)(b.ChevronRight,{className:(0,N.cn)("size-3 transition-transform",Y&&"rotate-90")}),(0,t.jsx)(v.Archive,{className:"size-3"}),er("list.archived")," (",ed.length,")"]}),(0,t.jsx)(c.CollapsibleContent,{children:ed.map(n=>(0,t.jsxs)(d.ContextMenu,{children:[(0,t.jsxs)(d.ContextMenuTrigger,{onClick:()=>L(n.id),className:`w-full text-left px-3 py-2 hover:bg-accent/50 transition-colors flex items-start gap-2 opacity-60 ${M===n.id?"bg-accent opacity-100":""}`,children:[(0,t.jsx)(p.CircleDot,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:"text-sm font-medium truncate",children:n.title}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:er("list.taskCount",{count:n.tasks.length})})]}),(0,t.jsx)(i.Badge,{variant:"outline",className:`text-[10px] shrink-0 border-none ${P.archived}`,children:er("status.archived")})]}),(0,t.jsxs)(d.ContextMenuContent,{children:[(0,t.jsxs)(d.ContextMenuItem,{onClick:()=>ep(n),children:[(0,t.jsx)(j.ArchiveRestore,{className:"size-4 mr-2"}),er("list.unarchive")]}),(0,t.jsx)(d.ContextMenuSeparator,{}),(0,t.jsxs)(d.ContextMenuItem,{variant:"destructive",onClick:()=>B(e,n.id),children:[(0,t.jsx)(f.Trash2,{className:"size-4 mr-2"}),ei("delete")]})]})]},n.id))})]})]}),(0,t.jsx)(R,{open:G,onOpenChange:q,agents:$,onSubmit:eo}),U&&(0,t.jsx)(z.EditIssueDialog,{issue:U,open:!!U,onOpenChange:e=>{e||V(null)},agents:$,onSave:async t=>{await A(e,U.id,t),V(null)}}),(0,t.jsx)(m.AlertDialog,{open:Z,onOpenChange:ee,children:(0,t.jsxs)(m.AlertDialogContent,{children:[(0,t.jsxs)(m.AlertDialogHeader,{children:[(0,t.jsx)(m.AlertDialogTitle,{children:er("list.clearArchived")}),(0,t.jsx)(m.AlertDialogDescription,{children:er("list.clearArchivedConfirm",{count:ed.length})})]}),(0,t.jsxs)(m.AlertDialogFooter,{children:[(0,t.jsx)(m.AlertDialogCancel,{children:ei("cancel")}),(0,t.jsx)(m.AlertDialogAction,{onClick:eg,children:ei("delete")})]})]})})]})}],308557)},783481,e=>{e.n(e.i(308557))}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,282738,e=>{"use strict";var t=e.i(344180),r=e.i(764556),s=e.i(141889),n=e.i(368942),a=e.i(953700),o=e.i(433721);let d=(0,o.default)("trash",[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);var l=e.i(972846),i=e.i(887354),c=e.i(650654),u=e.i(810051),x=e.i(137340),m=e.i(943997),p=e.i(990336),h=e.i(344118),f=e.i(293818),g=e.i(444204),b=e.i(465458),j=e.i(244073),v=e.i(751962),N=e.i(917955),w=e.i(992764);let y=(0,o.default)("move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]),k=["📁","📄","📎","🚀","💡","⭐","🎯","🎨","📇","📈","☑️","🔥","🔍","📮","🧪","✍️","✅","📸","🔀","🧭"];function C({node:e,state:s,rowProps:n,onSelect:o,onAddChild:d,onDelete:l,onRename:i,onUpdateIcon:m,onToggleExpand:p,children:h}){let[f,g]=(0,r.useState)(!1),[j,v]=(0,r.useState)(e.title),[N,D]=(0,r.useState)(!1),S=(0,r.useRef)(null);(0,r.useEffect)(()=>{v(e.title)},[e.title]),(0,r.useEffect)(()=>{let e=e=>{S.current&&!S.current.contains(e.target)&&D(!1)};return N&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[N]);let E=()=>{i(e.id,j.trim()||"未命名文档"),g(!1)};return(0,t.jsxs)("div",{className:"flex flex-col select-none",children:[(0,t.jsxs)("div",{...n,className:(0,b.cn)("group flex items-center h-9 justify-between pr-2 rounded-lg cursor-pointer transition-all gap-1.5 border border-transparent my-0.5",s.isActive?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground",s.isDraggedOver&&"border-2 border-dashed border-primary/40 bg-primary/5 scale-95",n.className),children:[(0,t.jsxs)("div",{className:"flex items-center min-w-0 flex-1 h-full py-1",children:[(0,t.jsx)("button",{onClick:t=>{t.stopPropagation(),p(e.id)},className:(0,b.cn)("p-1 rounded-sm text-muted-foreground hover:text-foreground transition-colors shrink-0",!s.hasChildren&&"opacity-0 cursor-default","cursor-pointer"),children:s.isExpanded?(0,t.jsx)(c.ChevronDown,{className:"w-3.5 h-3.5"}):(0,t.jsx)(w.ChevronRight,{className:"w-3.5 h-3.5"})}),(0,t.jsxs)("div",{className:"relative shrink-0",ref:S,children:[(0,t.jsx)("button",{onClick:e=>{e.stopPropagation(),D(!N)},className:"text-base p-1.5 rounded-md hover:bg-accent shrink-0 transition-all select-none cursor-pointer",children:e.icon||(s.hasChildren?"📁":"📄")}),N&&(0,t.jsx)("div",{className:"absolute left-1 top-7 bg-popover shadow-2xl rounded-xl border border-border p-2 grid grid-cols-5 gap-1 w-44 z-50",children:k.map(r=>(0,t.jsx)("button",{onClick:t=>{t.stopPropagation(),m(e.id,r),D(!1)},className:"w-7 h-7 flex items-center justify-center rounded-lg hover:bg-accent text-base cursor-pointer text-foreground",children:r},r))})]}),(0,t.jsx)("div",{onClick:()=>o(e.id),className:"flex-1 min-w-0 pr-1.5 h-full flex items-center",children:f?(0,t.jsx)("input",{type:"text",value:j,onChange:e=>v(e.target.value),onBlur:E,onKeyDown:t=>{"Enter"===t.key&&E(),"Escape"===t.key&&(v(e.title),g(!1))},onClick:e=>e.stopPropagation(),className:"w-full text-xs font-semibold bg-background border border-border rounded-md px-1.5 py-0.5 focus:outline-none focus:ring-1 focus:ring-ring text-foreground",autoFocus:!0}):(0,t.jsx)("span",{className:(0,b.cn)("text-xs truncate font-medium select-none",s.isActive?"text-primary":"text-foreground/80"),children:e.title||"未命名文档"})})]}),!f&&(0,t.jsxs)("div",{className:"opacity-0 group-hover:opacity-100 flex items-center gap-0.5 shrink-0 transition-opacity",children:[(0,t.jsx)("button",{onClick:e=>{e.stopPropagation(),g(!0)},className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground cursor-pointer",title:"重命名",children:(0,t.jsx)(u.Edit2,{className:"w-3 h-3"})}),(0,t.jsx)("button",{onClick:t=>{t.stopPropagation(),d(e.id)},className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground cursor-pointer",title:"新建子页面",children:(0,t.jsx)(a.Plus,{className:"w-3 h-3"})}),(0,t.jsx)("button",{onClick:t=>{t.stopPropagation(),confirm(`要将 "${e.title||"未命名文档"}" 移动到回收站吗?`)&&l(e.id)},className:"p-1 rounded hover:bg-rose-950/60 text-muted-foreground hover:text-rose-400 cursor-pointer",title:"删除",children:(0,t.jsx)(x.Trash2,{className:"w-3 h-3"})}),(0,t.jsx)("div",{className:"p-1 cursor-grab text-muted-foreground/40 pointer-events-none",children:(0,t.jsx)(y,{className:"w-3 h-3"})})]})]}),h&&(0,t.jsx)("div",{className:"flex flex-col",children:h})]})}var D=e.i(833237),S=e.i(437122);function E({workspaceId:e,onOpenSearch:n,onOpenTrash:o,onOpenCreateDatabase:w,onOpenEditDatabase:y,onOpenVectorDialog:k,onSave:I}){let{databases:T,activeDatabaseId:M,nodes:O,activeId:L,openFolders:P,sidebarSearch:A,recentIds:F,setActiveDatabaseId:R,deleteDatabase:z,setActiveId:B,createNode:$,renameNode:U,updateIcon:H,trashNode:V,toggleFolder:X,setSidebarSearch:K}=(0,s.useDatabaseStore)(),W=(0,j.useTranslations)("database"),[q,J]=(0,r.useState)(!1),[G,Q]=(0,r.useState)(!1),[Y,Z]=(0,r.useState)(null),[_,ee]=(0,r.useState)(null),et=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=e=>{et.current&&!et.current.contains(e.target)&&J(!1)};return q&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[q]);let er=T.find(e=>e.id===M)??T[0]??null,es=O.filter(e=>!e.isTrash),en=es.filter(e=>!A||(e.title||"").toLowerCase().includes(A.toLowerCase())).filter(e=>null===e.parentId),ea=(0,r.useCallback)(async(t,r)=>{await $(e,t,r),I()},[e,$,I]),eo=(0,r.useCallback)((t,r)=>{let s=r,n=O.find(e=>e.id===t);n?.icon&&s.trim().startsWith(n.icon)&&(s=s.trim().substring(n.icon.length).trim()),U(e,t,s),I()},[e,O,U,I]),ed=(0,r.useCallback)((e,t)=>{let r=O.find(e=>e.id===t),s=0;for(;r?.parentId&&s<20;){if(r.parentId===e)return!0;r=O.find(e=>e.id===r.parentId),s++}return!1},[O]),el=(0,r.useCallback)((e,t)=>{Z(t),e.dataTransfer.setData("text/plain",t),e.dataTransfer.effectAllowed="move"},[]),ei=(0,r.useCallback)((e,t)=>{if(e.preventDefault(),Y&&Y!==t){if(ed(Y,t)){e.dataTransfer.dropEffect="none";return}ee(t),e.dataTransfer.dropEffect="move"}},[Y,ed]),ec=(0,r.useCallback)(()=>ee(null),[]),eu=(0,r.useCallback)((t,r)=>{t.preventDefault(),ee(null),!Y||Y===r||ed(Y,r)||(s.useDatabaseStore.getState().moveNode(e,Y,r),Z(null),I())},[Y,e,ed,I]),ex=(0,r.useCallback)(t=>{t.preventDefault(),Y&&(s.useDatabaseStore.getState().moveNode(e,Y,null),Z(null),I())},[Y,e,I]),em=(0,r.useCallback)(async()=>{!er||T.length<=1||confirm(W("deleteConfirm",{name:er.name}))&&await z(e,er.id)},[er,T.length,z,e]),ep=(0,r.useCallback)(async t=>{let{activeDatabaseId:r}=s.useDatabaseStore.getState();if(r){for(let n of t){let t=await n.text(),a=n.name.replace(/\.md$/i,""),o=await (0,S.fetchWithAuth)(`/api/workspaces/${e}/database?databaseId=${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:a,icon:"📝",content:t,parentId:null})});if(!o.ok)throw Error("Failed to create node");let d=await o.json();s.useDatabaseStore.setState(e=>({nodes:[...e.nodes,d]}))}I()}},[e,I]);return(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[(0,t.jsx)("div",{className:"px-4 py-3 border-b border-border bg-sidebar/80 backdrop-blur-md shrink-0",children:(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl bg-gradient-to-tr from-muted to-muted-foreground/20 flex items-center justify-center font-bold text-base text-foreground border border-muted-foreground/20",children:"📁"}),(0,t.jsxs)("div",{className:"hidden",children:[(0,t.jsx)("span",{className:"text-xs font-bold text-foreground tracking-tight",children:W("knowledgeBase")}),(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground font-medium font-mono leading-none mt-0.5",children:"Database"})]}),(0,t.jsxs)(N.DropdownMenu,{children:[(0,t.jsxs)(N.DropdownMenuTrigger,{className:"min-w-0 flex-1 flex items-center justify-between gap-2 rounded-lg px-1.5 py-1 text-left hover:bg-accent outline-none",title:er?.name??"Database",children:[(0,t.jsxs)("div",{className:"min-w-0 flex flex-col",children:[(0,t.jsx)("span",{className:"text-xs font-bold text-foreground tracking-tight truncate",children:er?.name??"Database"}),(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground font-medium font-mono leading-none mt-0.5",children:"Database"})]}),(0,t.jsx)(c.ChevronDown,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"})]}),(0,t.jsxs)(N.DropdownMenuContent,{align:"start",className:"w-56",children:[T.map(r=>(0,t.jsxs)(N.DropdownMenuItem,{onClick:()=>{r.id!==M&&R(e,r.id)},className:"cursor-pointer",children:[(0,t.jsx)(m.Database,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"truncate flex-1",children:r.name}),r.id===M&&(0,t.jsx)(h.Check,{className:"w-4 h-4"})]},r.id)),(0,t.jsx)(N.DropdownMenuSeparator,{}),(0,t.jsxs)(N.DropdownMenuItem,{onClick:w,className:"cursor-pointer",children:[(0,t.jsx)(a.Plus,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:W("createDatabase")})]}),(0,t.jsxs)(N.DropdownMenuItem,{onClick:y,disabled:!er,className:"cursor-pointer",children:[(0,t.jsx)(u.Edit2,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:W("editDatabase")})]}),(0,t.jsxs)(N.DropdownMenuItem,{onClick:k,disabled:!er,className:"cursor-pointer",children:[(0,t.jsx)(p.Brain,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:W("vectorSettings")})]}),(0,t.jsxs)(N.DropdownMenuItem,{onClick:em,disabled:!er||T.length<=1,variant:"destructive",className:"cursor-pointer",children:[(0,t.jsx)(x.Trash2,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:W("deleteDatabase")})]})]})]})]})}),(0,t.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto px-3.5 py-4",onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move"},onDrop:ex,children:[(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-[11px] font-bold text-muted-foreground px-1 mb-2.5 uppercase tracking-wider",children:[(0,t.jsx)("span",{children:W("sidebarTree")}),(0,t.jsxs)("span",{children:["(",es.length,")"]})]}),(0,t.jsxs)("div",{className:"px-1 mb-4 flex items-center gap-2 relative",ref:et,children:[(0,t.jsxs)("div",{className:"relative flex-1",children:[(0,t.jsx)("input",{type:"text",placeholder:W("filterPlaceholder"),value:A,onChange:e=>K(e.target.value),className:"w-full text-xs bg-background border border-border rounded-lg px-2.5 py-1.5 pr-7 text-foreground focus:outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/60"}),A?(0,t.jsx)("button",{onClick:()=>K(""),className:"absolute right-2 top-2 text-muted-foreground hover:text-foreground cursor-pointer",children:(0,t.jsx)(l.X,{className:"w-3.5 h-3.5"})}):(0,t.jsx)(f.SlidersHorizontal,{className:"absolute right-2 top-2.5 w-3 h-3 text-muted-foreground/60 pointer-events-none"})]}),(0,t.jsx)("button",{onClick:()=>J(!q),className:"h-8 w-8 rounded-lg bg-muted hover:bg-muted/80 border border-border hover:border-muted-foreground/40 text-foreground transition-all cursor-pointer flex items-center justify-center shrink-0",title:W("newItem"),children:(0,t.jsx)(a.Plus,{className:"w-4 h-4"})}),q&&(0,t.jsxs)("div",{className:"absolute right-1 top-[calc(100%+4px)] w-36 bg-popover border border-border rounded-lg shadow-2xl py-1 z-50",children:[(0,t.jsxs)("button",{onClick:()=>{ea(null,"folder"),J(!1)},className:"w-full text-left px-3 py-1.5 flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer",children:[(0,t.jsx)("span",{className:"text-sm",children:"📂"}),(0,t.jsx)("span",{className:"font-medium",children:W("newFolder")})]}),(0,t.jsxs)("button",{onClick:()=>{ea(null,"document"),J(!1)},className:"w-full text-left px-3 py-1.5 flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer",children:[(0,t.jsx)("span",{className:"text-sm",children:"📝"}),(0,t.jsx)("span",{className:"font-medium",children:W("newDocument")})]}),(0,t.jsxs)("button",{onClick:()=>{Q(!0),J(!1)},className:"w-full text-left px-3 py-1.5 flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer",children:[(0,t.jsx)("span",{className:"text-sm",children:"📥"}),(0,t.jsx)("span",{className:"font-medium",children:W("importMarkdown")})]})]})]}),0===en.length?(0,t.jsx)("div",{className:"px-2 py-6 text-center text-xs text-muted-foreground italic",children:A?W("noMatch"):W("emptyState")}):(0,t.jsx)("div",{className:"space-y-0.5",children:(0,t.jsx)(v.NestedTree,{nodes:en,getNodeId:e=>e.id,getChildren:e=>es.filter(t=>t.parentId===e.id),activeId:L,expandedIds:P,draggedOverId:_,onDragStart:el,onDragOver:ei,onDragLeave:ec,onDrop:eu,shouldRenderChildren:(e,t)=>t.isExpanded,renderNode:({node:r,state:s,rowProps:n,children:a})=>(0,t.jsx)(C,{node:r,state:s,rowProps:n,onSelect:B,onAddChild:ea,onDelete:t=>{V(e,t),I()},onRename:eo,onUpdateIcon:(t,r)=>{H(e,t,r),I()},onToggleExpand:X,children:a})})})]}),F.length>0&&(0,t.jsxs)("div",{className:"mb-6 pt-4 border-t border-border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] font-bold text-muted-foreground px-1 mb-2 uppercase tracking-wider",children:[(0,t.jsx)(g.Clock,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,t.jsx)("span",{children:W("recentEdits")})]}),(0,t.jsx)("div",{className:"space-y-1",children:F.map(e=>O.find(t=>t.id===e&&!t.isTrash)).filter(e=>!!e).map(e=>(0,t.jsxs)("button",{onClick:()=>B(e.id),className:(0,b.cn)("w-full text-left p-1.5 rounded-lg flex items-center gap-2 text-xs transition-colors",L===e.id?"bg-accent text-foreground font-semibold":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[(0,t.jsx)("span",{className:"text-sm shrink-0 select-none",children:e.icon||"📝"}),(0,t.jsx)("span",{className:"truncate flex-1",children:e.title||W("untitled")})]},e.id))})]})]}),(0,t.jsxs)("div",{className:"px-2 py-1.5 border-t border-border bg-sidebar flex items-center gap-1.5 shrink-0",children:[(0,t.jsx)("button",{onClick:n,className:"flex-1 flex items-center justify-between bg-background hover:bg-muted border border-border text-muted-foreground hover:text-foreground transition-all h-7 px-2.5 rounded-md text-[11px] cursor-pointer",children:(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(i.Search,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:W("globalSearch")})]})}),(0,t.jsxs)("button",{onClick:o,className:"relative w-7 h-7 shrink-0 flex items-center justify-center rounded-md bg-background hover:bg-muted text-muted-foreground hover:text-rose-400 border border-border transition-all cursor-pointer group",title:W("trashBin"),children:[(0,t.jsx)(d,{className:"w-3 h-3 text-rose-500"}),O.filter(e=>e.isTrash).length>0&&(0,t.jsx)("span",{className:"absolute -top-1 -right-1 bg-rose-600 text-white text-[8px] w-3.5 h-3.5 rounded-full flex items-center justify-center font-semibold border border-sidebar",children:O.filter(e=>e.isTrash).length})]})]}),(0,t.jsx)(D.ImportFileDialog,{open:G,onOpenChange:Q,workspaceId:e,targetPath:"",onImported:I,accept:{"text/markdown":[".md"],"text/x-markdown":[".md"]},onUploadFiles:ep})]})}var I=e.i(209988);function T({open:e,database:s,onOpenChange:n,onSave:a}){let[o,d]=(0,r.useState)(""),[l,i]=(0,r.useState)(""),[c,u]=(0,r.useState)(!1);(0,r.useEffect)(()=>{e&&(d(s?.name??""),i(s?.description??""))},[s,e]);let x=async e=>{e.preventDefault();let t=o.trim();if(t&&!c){u(!0);try{await a({name:t,description:l.trim()}),n(!1)}finally{u(!1)}}};return(0,t.jsx)(I.Dialog,{open:e,onOpenChange:n,children:(0,t.jsx)(I.DialogContent,{className:"sm:max-w-md p-0 gap-0 overflow-hidden",children:(0,t.jsxs)("form",{onSubmit:x,children:[(0,t.jsx)(I.DialogHeader,{className:"px-5 py-4 border-b border-border",children:(0,t.jsx)(I.DialogTitle,{className:"text-sm",children:s?"Edit database":"Create database"})}),(0,t.jsxs)("div",{className:"p-5 space-y-4",children:[(0,t.jsxs)("label",{className:"block space-y-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Name"}),(0,t.jsx)("input",{value:o,onChange:e=>d(e.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring",autoFocus:!0})]}),(0,t.jsxs)("label",{className:"block space-y-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Description"}),(0,t.jsx)("textarea",{value:l,onChange:e=>i(e.target.value),className:"min-h-20 w-full resize-none rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring"})]})]}),(0,t.jsxs)(I.DialogFooter,{className:"px-5 py-4",children:[(0,t.jsx)("button",{type:"button",onClick:()=>n(!1),className:"px-3 py-1.5 rounded-lg text-xs font-semibold text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer",children:"Cancel"}),(0,t.jsx)("button",{type:"submit",disabled:!o.trim()||c,className:"px-3 py-1.5 rounded-lg text-xs font-semibold bg-primary text-primary-foreground disabled:opacity-50 cursor-pointer",children:c?"Saving...":"Save"})]})]})})})}var M=e.i(100559),O=e.i(889445),L=e.i(260218),P=e.i(681622);function A({open:e,onClose:s,onConfirm:n,title:a="Select Model",description:o,models:d,selected:i,onToggle:c,cancelText:u,confirmText:x,loading:m}){let[h,f]=(0,r.useState)(""),g=(0,r.useMemo)(()=>{if(!h.trim())return d;let e=h.toLowerCase();return d.filter(t=>t.name.toLowerCase().includes(e)||t.modelId.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e))},[d,h]),j=(0,r.useMemo)(()=>(function(e){let t={};for(let r of e){let e=r.provider||"Other";(t[e]??=[]).push(r)}return t})(g),[g]);return(0,t.jsx)(I.Dialog,{open:e,onOpenChange:e=>{e||s()},children:(0,t.jsxs)(I.DialogContent,{className:"sm:max-w-sm flex flex-col gap-0 overflow-hidden p-0",children:[(0,t.jsxs)(I.DialogHeader,{className:"shrink-0 px-6 py-4",children:[(0,t.jsx)(I.DialogTitle,{children:a}),o&&(0,t.jsx)(I.DialogDescription,{children:o})]}),(0,t.jsx)("div",{className:"px-6 pb-2",children:(0,t.jsx)(P.Input,{placeholder:"Search models...",value:h,onChange:e=>f(e.target.value),className:"h-8 text-sm"})}),(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-2 space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[Object.entries(j).map(([e,r])=>(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-1",children:e}),(0,t.jsx)("div",{className:"space-y-0.5",children:r.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>c(e.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[(0,t.jsx)(p.Brain,{className:"size-4 text-muted-foreground shrink-0"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate",children:e.name}),(0,t.jsx)("span",{className:"block truncate text-xs text-muted-foreground font-mono",children:e.modelId})]}),(0,t.jsx)("div",{className:(0,b.cn)("flex items-center justify-center size-4 rounded border shrink-0",i.includes(e.id)?"bg-primary border-primary text-primary-foreground":"border-input")})]},e.id))})]},e)),0===g.length&&(0,t.jsx)("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No models found"})]}),i.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:i.map(e=>{let r=d.find(t=>t.id===e);return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs max-w-[160px] min-w-0",children:[(0,t.jsx)(p.Brain,{className:"size-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"truncate",children:r?.name||e}),(0,t.jsx)("button",{type:"button",onClick:()=>c(e),className:"hover:text-destructive shrink-0 cursor-pointer",children:(0,t.jsx)(l.X,{className:"size-3"})})]},e)})})]}),(0,t.jsxs)("div",{className:"shrink-0 flex justify-end gap-2 border-t px-6 py-4",children:[(0,t.jsx)(L.Button,{variant:"outline",onClick:s,children:u||"Cancel"}),(0,t.jsx)(L.Button,{onClick:n,disabled:m||0===i.length,children:x||"Confirm"})]})]})})}function F({open:e,database:s,models:n,providers:a,stats:o,loading:d,indexing:l,onOpenChange:i,onBind:c,onIndex:u}){let[x,m]=(0,r.useState)(!1),[p,h]=(0,r.useState)(null),[f,g]=(0,r.useState)(!1),[b,j]=(0,r.useState)(null),[v,N]=(0,r.useState)(null),w=o?.embeddingModelId??s?.embeddingModelId??null,y=n.find(e=>e.id===w),k=y?a.find(e=>e.name===y.provider):void 0,C=n.filter(e=>e.embedding);(0,r.useEffect)(()=>{e&&(h(w),j(null),N(null))},[w,e]);let D=async()=>{g(!0),N(null),j(null);try{await c(p),j("Embedding model saved."),m(!1)}catch(e){N(e instanceof Error?e.message:"Failed to save embedding model.")}finally{g(!1)}},S=async()=>{g(!0),N(null),j(null);try{await c(null),h(null),j("Embedding model cleared.")}catch(e){N(e instanceof Error?e.message:"Failed to clear embedding model.")}finally{g(!1)}},E=async()=>{N(null),j(null);try{await u(),j("Vector index completed.")}catch(e){N(e instanceof Error?e.message:"Failed to index database.")}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(I.Dialog,{open:e,onOpenChange:i,children:(0,t.jsxs)(I.DialogContent,{className:"sm:max-w-lg p-0 gap-0 overflow-hidden",children:[(0,t.jsx)(I.DialogHeader,{className:"px-5 py-4 border-b border-border",children:(0,t.jsx)(I.DialogTitle,{className:"text-sm",children:"Database vectors"})}),(0,t.jsxs)("div",{className:"p-5 space-y-4",children:[(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 p-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-xs font-semibold text-foreground",children:"Embedding model"}),(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,t.jsx)(M.Server,{className:"w-3.5 h-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:y?`${y.name} (${k?.name||y.provider})`:"No model bound"})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>m(!0),className:"shrink-0 rounded-lg border border-border bg-background px-3 py-1.5 text-xs font-semibold hover:bg-muted cursor-pointer",children:"Select"})]}),w&&(0,t.jsx)("button",{type:"button",onClick:S,disabled:f||l,className:"mt-3 text-xs font-semibold text-muted-foreground hover:text-destructive disabled:opacity-50 cursor-pointer",children:"Clear binding"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[(0,t.jsxs)("div",{className:"rounded-lg border border-border p-3",children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Documents"}),(0,t.jsx)("div",{className:"mt-1 text-lg font-bold text-foreground",children:o?.nodeCount??"-"})]}),(0,t.jsxs)("div",{className:"rounded-lg border border-border p-3",children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Indexed"}),(0,t.jsx)("div",{className:"mt-1 text-lg font-bold text-foreground",children:o?.indexedCount??"-"})]}),(0,t.jsxs)("div",{className:"rounded-lg border border-border p-3",children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Updated"}),(0,t.jsx)("div",{className:"mt-1 truncate text-xs font-semibold text-foreground",children:o?.lastIndexedAt?new Date(o.lastIndexedAt).toLocaleString():"-"})]})]}),v&&(0,t.jsx)("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:v}),b&&(0,t.jsx)("div",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-xs text-emerald-700",children:b})]}),(0,t.jsxs)(I.DialogFooter,{className:"px-5 py-4",children:[(0,t.jsx)("button",{type:"button",onClick:()=>i(!1),className:"px-3 py-1.5 rounded-lg text-xs font-semibold text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer",children:"Close"}),(0,t.jsxs)("button",{type:"button",onClick:E,disabled:d||l||f||!w,className:"px-3 py-1.5 rounded-lg text-xs font-semibold bg-primary text-primary-foreground disabled:opacity-50 inline-flex items-center gap-1.5 cursor-pointer",children:[(0,t.jsx)(O.Play,{className:"w-3.5 h-3.5"}),l?"Indexing...":"Start indexing"]})]})]})}),(0,t.jsx)(A,{open:x,onClose:()=>m(!1),onConfirm:D,title:"Select embedding model",description:"Pick one embedding model. Its provider supplies API base and key.",models:C,selected:p?[p]:[],onToggle:e=>h(t=>t===e?null:e),confirmText:f?"Saving...":"Save",loading:f})]})}var R=e.i(451534);let z=(0,o.default)("corner-down-left",[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]]);function B({isOpen:e,onClose:s,nodes:n,onSelectNode:a}){let[o,d]=(0,r.useState)(""),[c,u]=(0,r.useState)(0),x=(0,r.useRef)(null),m=(0,r.useRef)(null);(0,r.useEffect)(()=>{e&&setTimeout(()=>{m.current?.focus(),d("")},50)},[e]);let p=(0,r.useMemo)(()=>{if(!o)return n.filter(e=>!e.isTrash).sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,5);let e=o.toLowerCase().trim();return n.filter(t=>!t.isTrash&&((t.title||"").toLowerCase().includes(e)||(t.content||"").toLowerCase().includes(e)))},[o,n]);return((0,r.useEffect)(()=>{let t=t=>{e&&("Escape"===t.key?(t.preventDefault(),s()):"ArrowDown"===t.key?(t.preventDefault(),u(e=>(e+1)%Math.max(1,p.length))):"ArrowUp"===t.key?(t.preventDefault(),u(e=>(e-1+p.length)%Math.max(1,p.length))):"Enter"===t.key&&p[c]&&(t.preventDefault(),a(p[c].id),s()))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e,p,c,s,a]),(0,r.useEffect)(()=>{let t=e=>{x.current&&!x.current.contains(e.target)&&s()};return e&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[e,s]),e)?(0,t.jsx)("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-xs flex items-start justify-center pt-[15vh] px-4 z-50",children:(0,t.jsxs)("div",{ref:x,className:"w-full max-w-2xl bg-card rounded-2xl shadow-2xl border border-border flex flex-col overflow-hidden max-h-[500px]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3.5 border-b border-border shrink-0",children:[(0,t.jsx)(i.Search,{className:"w-5 h-5 text-muted-foreground"}),(0,t.jsx)("input",{ref:m,type:"text",placeholder:"搜索文档...",value:o,onChange:e=>{d(e.target.value),u(0)},className:"flex-1 bg-transparent text-foreground placeholder:text-muted-foreground text-sm focus:outline-none"}),(0,t.jsx)("button",{onClick:s,className:"p-1 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground cursor-pointer",children:(0,t.jsx)(l.X,{className:"w-4 h-4"})})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto p-2",children:[(0,t.jsx)("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted-foreground uppercase tracking-wider",children:o?`匹配结果 (${p.length})`:"最近编辑"}),0===p.length?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,t.jsx)("span",{className:"text-3xl mb-2",children:"🔍"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"没有找到相关文档"})]}):(0,t.jsx)("div",{className:"space-y-0.5",children:p.map((e,o)=>{let d=(e=>{let t=[],r=e,s=0;for(;r?.parentId&&s<10;){let e=n.find(e=>e.id===r.parentId);if(e)t.unshift(e.title||"未命名"),r=e;else break;s++}return t})(e);return(0,t.jsxs)("button",{onClick:()=>{a(e.id),s()},className:(0,b.cn)("w-full text-left p-3 rounded-xl flex items-center gap-3.5 transition-all text-sm cursor-pointer",o===c?"bg-accent text-foreground border-l-2 border-foreground":"text-muted-foreground hover:bg-muted"),children:[(0,t.jsx)("div",{className:"text-lg bg-muted p-1.5 rounded-lg shrink-0 border border-border",children:e.icon||"📝"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"font-medium text-foreground truncate block",children:e.title||"未命名"}),d.length>0&&(0,t.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground mt-1 truncate",children:[(0,t.jsx)(R.FolderOpen,{className:"w-3 h-3 text-muted-foreground/60"}),d.map((e,s)=>(0,t.jsxs)(r.default.Fragment,{children:[(0,t.jsx)("span",{children:e}),(0,t.jsx)(w.ChevronRight,{className:"w-2.5 h-2.5 mx-0.5 text-muted-foreground/40"})]},s))]})]}),o===c&&(0,t.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground bg-muted border border-border px-2 py-0.5 rounded-md font-mono",children:[(0,t.jsx)(z,{className:"w-2.5 h-2.5"}),"Enter"]})]},e.id)})})]})]})}):null}var $=e.i(357301),U=e.i(486657),H=e.i(583705);function V({isOpen:e,onClose:s,nodes:n,onRestore:a,onDeletePermanent:o}){let[d,c]=(0,r.useState)(""),u=n.filter(e=>e.isTrash),m=u.filter(e=>(e.title||"").toLowerCase().includes(d.toLowerCase()));return e?(0,t.jsx)("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-xs flex items-start justify-center pt-[15vh] px-4 z-50",children:(0,t.jsxs)("div",{className:"w-full max-w-lg bg-card rounded-2xl shadow-2xl border border-border flex flex-col overflow-hidden max-h-[500px]",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border shrink-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(x.Trash2,{className:"w-5 h-5 text-red-400"}),(0,t.jsx)("h3",{className:"font-semibold text-foreground",children:"回收站"}),(0,t.jsx)("span",{className:"bg-red-950/40 text-red-400 border border-red-900/30 text-[10px] px-1.5 py-0.5 rounded-full font-bold",children:u.length})]}),(0,t.jsx)("button",{onClick:s,className:"p-1 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground cursor-pointer",children:(0,t.jsx)(l.X,{className:"w-4 h-4"})})]}),u.length>0&&(0,t.jsxs)("div",{className:"px-4 py-2 border-b border-border flex items-center gap-2 bg-muted/40",children:[(0,t.jsx)(i.Search,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,t.jsx)("input",{type:"text",placeholder:"搜索回收站...",value:d,onChange:e=>c(e.target.value),className:"flex-1 bg-transparent text-xs text-foreground placeholder:text-muted-foreground focus:outline-none"}),d&&(0,t.jsx)("button",{onClick:()=>c(""),className:"text-[10px] text-muted-foreground hover:text-foreground cursor-pointer",children:"清除"})]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto p-3",children:0===u.length?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,t.jsx)("span",{className:"text-3xl mb-1.5",children:"🍃"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"回收站是空的"})]}):0===m.length?(0,t.jsxs)("div",{className:"py-12 text-center text-xs text-muted-foreground italic",children:['未匹配到 "',d,'"']}):(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] text-amber-500 bg-amber-950/20 py-1.5 px-3 rounded-lg mb-2 border border-amber-900/30",children:[(0,t.jsx)(H.Info,{className:"w-3.5 h-3.5 shrink-0"}),(0,t.jsx)("span",{children:"永久删除不可逆,子文件也会被清除。"})]}),m.map(e=>(0,t.jsxs)("div",{className:"group hover:bg-muted/40 p-2.5 rounded-xl border border-transparent hover:border-border flex items-center justify-between gap-3 transition-all",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,t.jsx)("span",{className:"text-lg bg-muted border border-border p-1 rounded-md shrink-0",children:e.icon||"📝"}),(0,t.jsx)("span",{className:"text-xs font-medium text-foreground truncate",children:e.title||"未命名"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,t.jsx)("button",{onClick:()=>a(e.id),className:"p-1.5 rounded-lg hover:bg-muted text-muted-foreground hover:text-emerald-400 cursor-pointer",title:"恢复",children:(0,t.jsx)($.RotateCcw,{className:"w-4 h-4"})}),(0,t.jsx)("button",{onClick:()=>{confirm(`永久删除 "${e.title}"?`)&&o(e.id)},className:"p-1.5 rounded-lg hover:bg-muted text-muted-foreground hover:text-red-400 cursor-pointer",title:"永久删除",children:(0,t.jsx)(x.Trash2,{className:"w-4 h-4"})})]})]},e.id))]})}),(0,t.jsxs)("div",{className:"bg-muted border-t border-border px-5 py-3 text-xs text-muted-foreground flex items-center gap-2 shrink-0",children:[(0,t.jsx)(U.AlertTriangle,{className:"w-4 h-4 text-muted-foreground/60"}),"点击按钮恢复或永久删除"]})]})}):null}e.s(["DatabaseSidebarPanel",0,function({workspaceId:e}){let{databases:a,activeDatabaseId:o,nodes:d,vectorStats:l,vectorLoading:i,vectorIndexing:c,loading:u,loaded:x,load:m,loadVectorStats:p,bindEmbeddingModel:h,indexVectors:f,restoreNode:g,deleteNode:b,setActiveId:j,createDatabase:v,updateDatabase:N}=(0,s.useDatabaseStore)(),{models:w,providers:y,ensure:k}=(0,n.useLLMStore)(),[C,D]=(0,r.useState)(!1),[S,I]=(0,r.useState)(!1),[M,O]=(0,r.useState)(!1),[L,P]=(0,r.useState)(!1),[A,R]=(0,r.useState)(null);(0,r.useEffect)(()=>{x||m(e)},[x,m,e]),(0,r.useEffect)(()=>{L&&(k(),o&&p(e,o))},[o,k,p,L,e]);let z=(0,r.useCallback)(()=>{},[]),$=a.find(e=>e.id===o)??a[0]??null,U=(0,r.useCallback)(()=>{R(null),O(!0)},[]),H=(0,r.useCallback)(()=>{R($),O(!0)},[$]),X=(0,r.useCallback)(async t=>{A?await N(e,A.id,t):await v(e,t)},[v,A,N,e]),K=(0,r.useCallback)(async t=>{$&&await h(e,$.id,t)},[$,h,e]),W=(0,r.useCallback)(async()=>{$&&await f(e,$.id)},[$,f,e]);return u&&!x?(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"加载中..."}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(E,{workspaceId:e,onOpenSearch:()=>D(!0),onOpenTrash:()=>I(!0),onOpenCreateDatabase:U,onOpenEditDatabase:H,onOpenVectorDialog:()=>P(!0),onSave:z}),(0,t.jsx)(B,{isOpen:C,onClose:()=>D(!1),nodes:d,onSelectNode:e=>{j(e),D(!1)}}),(0,t.jsx)(V,{isOpen:S,onClose:()=>I(!1),nodes:d,onRestore:t=>{g(e,t)},onDeletePermanent:t=>{b(e,t)}}),(0,t.jsx)(T,{open:M,database:A,onOpenChange:O,onSave:X}),(0,t.jsx)(F,{open:L,database:$,models:w,providers:y,stats:l,loading:i,indexing:c,onOpenChange:P,onBind:K,onIndex:W})]})}],282738)},115133,e=>{e.n(e.i(282738))}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,515104,e=>{"use strict";function t(){return"__FLUTTER_INTERNALS__"in window}function n(){return t()&&"u">typeof navigator&&/android/i.test(navigator.userAgent)}async function r(){return t()?s():"Notification"in window?u(Notification.permission):"unsupported"}async function i(){return t()?d():c()}async function o(e,n,r={}){return t()?f(e,n,r):function(e,t){if(!("Notification"in window))throw Error("Notification API not available");if("granted"!==Notification.permission)throw Error(`Notification permission is "${Notification.permission}", not "granted"`);try{new Notification(e,{body:t,icon:"/favicon.ico"}).onerror=()=>{console.warn("[NativeNotification] browser notification error event")}}catch(e){throw Error(`Failed to create Notification: ${e instanceof Error?e.message:e}`)}}(e,n)}async function a(e){if(n())return o("Agent Spaces",e,{id:10001,ongoing:!0})}async function c(){return"Notification"in window?u(await Notification.requestPermission()):"unsupported"}function u(e){switch(e){case"granted":return"granted";case"denied":return"denied";default:return"default"}}function l(){return window.__flutterBridge??null}async function s(){try{let e=l();if(!e)return"unsupported";let t=await e.invoke("getNotificationPermission",null);return!0===t?"granted":"default"}catch{return"unsupported"}}async function d(){try{let e=l();if(!e)return"unsupported";let t=await e.invoke("requestNotificationPermission",null);return!0===t?"granted":"denied"}catch{return"unsupported"}}async function f(e,t,n){try{let r=l();if(!r)return;await r.invoke("sendNotification",{title:e,body:t,...n})}catch{}}e.s(["getNotificationPermission",0,r,"isFlutterEnvironment",0,t,"isNativeAndroidEnvironment",0,n,"isNativeEnvironment",0,function(){return t()},"requestNotificationPermission",0,i,"sendAndroidOngoingTaskNotification",0,a,"sendNativeNotification",0,o])},233297,e=>{"use strict";var t=e.i(515104);function n(e){let[t,n=""]=e.split("#",2),[r,i=""]=t.split("?",2);if(!r.startsWith("/")||r.startsWith("/api/"))return e;if("/"===r)return`/${i?`?${i}`:""}${n?`#${n}`:""}`;if(r.startsWith("/workspace/")){let e=r.slice(11).split("/")[0],t=new URLSearchParams(i);return t.set("workspaceId",e),`/workspace/_.html${t.toString()?`?${t.toString()}`:""}${n?`#${n}`:""}`}let o=r.endsWith(".html")?r:`${r}.html`;return`${o}${i?`?${i}`:""}${n?`#${n}`:""}`}e.s(["tauriNavigate",0,function(e,r,i=!1){let o=(0,t.isFlutterEnvironment)()&&"8080"===window.location.port;(0,t.isFlutterEnvironment)()&&!o?i?e.replace(r):e.push(r):(r=n(r),i?window.location.replace(r):window.location.href=r)},"toStaticHref",0,n])},437122,286117,e=>{"use strict";var t=e.i(523592),n=e.i(233297);function r(e){return"/index.html"===e?"/":e.endsWith(".html")?e.slice(0,-5):e}function i(e){return"/login"===r(e)}e.s(["isLoginPath",0,i,"isWorkspacePath",0,function(e){return r(e).startsWith("/workspace/")},"workspaceIdFromLocation",0,function(e,t){let n=new URLSearchParams(t).get("workspaceId");if(n)return n;let i=r(e).match(/^\/workspace\/([^/]+)/);return i?.[1]??null}],286117);let o="agent-spaces-token",a="agent-spaces-auth-verified";function c(){return`${o}:${(0,t.loadActiveId)()}`}function u(){let e=localStorage.getItem(c());if(null!==e)return e;let n=(0,t.getActiveServer)()?.secret;return void 0!==n?n:null}function l(){localStorage.removeItem(c()),localStorage.removeItem(a)}function s(){let e=u();return null===e?{}:{Authorization:`Bearer ${e}`}}async function d(e,r){let o=function(e){if("string"!=typeof e||e.startsWith("http"))return e;let n=(0,t.getActiveServerUrl)();return n?`${n}${e.startsWith("/")?"":"/"}${e}`:e}(e),a={...s(),...r?.headers},c=await fetch(o,{...r,headers:a});return(401===c.status||403===c.status)&&(l(),i(window.location.pathname)||window.location.replace((0,n.toStaticHref)("/login"))),c}e.s(["authHeaders",0,s,"fetchWithAuth",0,d,"getToken",0,u,"isAuthenticated",0,function(){return"1"===localStorage.getItem(a)},"removeToken",0,l,"setToken",0,function(e){localStorage.setItem(c(),e),localStorage.setItem(a,"1"),localStorage.removeItem(o)}],437122)},344118,e=>{"use strict";var t=e.i(50153);e.s(["Check",()=>t.default])},558680,e=>{"use strict";let t=(0,e.i(433721).default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);e.s(["default",0,t])},650654,e=>{"use strict";var t=e.i(558680);e.s(["ChevronDown",()=>t.default])},950396,e=>{"use strict";var t=e.i(344180),n=e.i(764556),r=e.i(799543);let i=(0,n.createContext)({theme:"system",setTheme:()=>{},resolvedTheme:"light"}),o="agent-spaces-theme",a={light:"#ffffff",dark:"#0f1117"};function c(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function u(e){var t;let n,r="system"===e?c():e,i=document.documentElement;i.classList.remove("light","dark"),i.classList.add(r),i.style.colorScheme=r,t=r,(n=document.querySelector('meta[name="theme-color"]'))||((n=document.createElement("meta")).name="theme-color",document.head.appendChild(n)),n.content=a[t],window.AgentSpacesStatusBar?.setTheme(t)}e.s(["ThemeProvider",0,function({children:e,defaultTheme:l="system"}){(0,r.useServerInsertedHTML)(()=>(0,t.jsx)("script",{dangerouslySetInnerHTML:{__html:`(function(){try{var t=localStorage.getItem('${o}');var d=t==='dark'||((!t||t==='system')&&matchMedia('(prefers-color-scheme:dark)').matches);var r=d?'dark':'light';document.documentElement.classList.add(r);document.documentElement.style.colorScheme=r;var m=document.querySelector('meta[name="theme-color"]');if(!m){m=document.createElement('meta');m.name='theme-color';document.head.appendChild(m)}m.content=d?'${a.dark}':'${a.light}';if(window.AgentSpacesStatusBar){window.AgentSpacesStatusBar.setTheme(r)}var f=localStorage.getItem('customFont');document.documentElement.dataset.customFont=f?'true':'false';if(f){var ff=f;try{var c=JSON.parse(localStorage.getItem('customFonts')||'[]');var cf=Array.isArray(c)&&c.find(function(x){return x&&x.name===f});if(cf&&cf.url){ff=f.replace(/\\.\\w+$/,'');var id='font-'+f.replace(/[^a-zA-Z0-9]/g,'-');if(!document.getElementById(id)){var s=document.createElement('style');s.id=id;s.textContent='@font-face { font-family: "'+ff.replace(/"/g,'\\\\22 ')+'"; src: url("'+String(cf.url).replace(/"/g,'\\\\22 ')+'"); }';document.head.appendChild(s)}}}catch(e){}var v=ff==='system-ui'||ff==='monospace'?ff:'"'+ff.replace(/"/g,'\\\\22 ')+'"';['--font-app','--font-sans','--font-heading','--font-mid','--font-mono'].forEach(function(k){document.documentElement.style.setProperty(k,v)})}}catch(e){}})()`}},"theme-init"));let s=(0,n.useSyncExternalStore)(e=>{let t=window.matchMedia("(prefers-color-scheme: dark)");return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>c(),()=>"light"),d=(0,n.useSyncExternalStore)(e=>(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)),()=>localStorage.getItem(o)||l,()=>l),f="system"===d?s:d,m=(0,n.useCallback)(e=>{localStorage.setItem(o,e),u(e),window.dispatchEvent(new StorageEvent("storage",{key:o}))},[]);return(0,n.useEffect)(()=>{u(d)},[d,s]),(0,t.jsx)(i.Provider,{value:{theme:d,setTheme:m,resolvedTheme:f},children:e})},"useTheme",0,function(){return(0,n.useContext)(i)}])},564822,e=>{"use strict";var t=e.i(764556);e.s(["useIsMobile",0,function(){let[e,n]=t.useState(void 0);return t.useEffect(()=>{let e=window.matchMedia("(max-width: 767px)"),t=()=>{n(window.innerWidth<768)};return e.addEventListener("change",t),n(window.innerWidth<768),()=>e.removeEventListener("change",t)},[]),!!e}])},304271,485599,e=>{"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){var n,i;n=t,i=r[t],(n=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(n))in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function a(e){return function t(){for(var n=this,r=arguments.length,i=Array(r),o=0;o<r;o++)i[o]=arguments[o];return i.length>=e.length?e.apply(this,i):function(){for(var e=arguments.length,r=Array(e),o=0;o<e;o++)r[o]=arguments[o];return t.apply(n,[].concat(i,r))}}}function c(e){return({}).toString.call(e).includes("Object")}function u(e){return"function"==typeof e}var l,s,d=a(function(e,t){throw Error(e[t]||e.default)})({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"}),f=function(e,t){return c(t)||d("changeType"),Object.keys(t).some(function(t){return!Object.prototype.hasOwnProperty.call(e,t)})&&d("changeField"),t},m=function(e){u(e)||d("selectorType")},h=function(e){u(e)||c(e)||d("handlerType"),c(e)&&Object.values(e).some(function(e){return!u(e)})&&d("handlersType")},g=function(e){e||d("initialIsRequired"),c(e)||d("initialType"),Object.keys(e).length||d("initialContent")};function p(e,t){return u(t)?t(e.current):t}function v(e,t){return e.current=o(o({},e.current),t),t}function y(e,t,n){return u(t)?t(e.current):Object.keys(n).forEach(function(n){var r;return null==(r=t[n])?void 0:r.call(t,e.current[n])}),n}var w={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!\n You are using deprecated way of configuration.\n\n Instead of using\n monaco.config({ urls: { monacoBase: '...' } })\n use\n monaco.config({ paths: { vs: '...' } })\n\n For more please check the link https://github.com/suren-atoyan/monaco-loader#config\n "},b=(l=function(e,t){throw Error(e[t]||e.default)},function e(){for(var t=this,n=arguments.length,r=Array(n),i=0;i<n;i++)r[i]=arguments[i];return r.length>=l.length?l.apply(this,r):function(){for(var n=arguments.length,i=Array(n),o=0;o<n;o++)i[o]=arguments[o];return e.apply(t,[].concat(r,i))}})(w),x=function(e){return(e||b("configIsRequired"),({}).toString.call(e).includes("Object")||b("configType"),e.urls)?(console.warn(w.deprecation),{paths:{vs:e.urls.monacoBase}}):e},j=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){return t.reduceRight(function(e,t){return t(e)},e)}},S={type:"cancelation",msg:"operation is manually canceled"};function k(e){var t=!1,n=new Promise(function(n,r){e.then(function(e){return t?r(S):n(e)}),e.catch(r)});return n.cancel=function(){return t=!0},n}var E=["monaco"],M=function(e){if(Array.isArray(e))return e}(s=({create:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};g(e),h(t);var n={current:e},r=a(y)(n,t),i=a(v)(n),o=a(f)(e),c=a(p)(n);return[function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(e){return e};return m(e),e(n.current)},function(e){(function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){return t.reduceRight(function(e,t){return t(e)},e)}})(r,i,o,c)(e)}]}}).create({config:{paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}},isInitialized:!1,resolve:null,reject:null,monaco:null}))||function(e){var t=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,r,i,o,a=[],c=!0,u=!1;try{i=(t=t.call(e)).next,!1;for(;!(c=(n=i.call(t)).done)&&(a.push(n.value),2!==a.length);c=!0);}catch(e){u=!0,r=e}finally{try{if(!c&&null!=t.return&&(o=t.return(),Object(o)!==o))return}finally{if(u)throw r}}return a}}(s)||function(e){if(e){if("string"==typeof e)return t(e,2);var n=({}).toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,2):void 0}}(s)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),O=M[0],N=M[1];function P(e){return document.body.appendChild(e)}function L(e){var t,n,r=O(function(e){return{config:e.config,reject:e.reject}}),i=(t="".concat(r.config.paths.vs,"/loader.js"),n=document.createElement("script"),t&&(n.src=t),n);return i.onload=function(){return e()},i.onerror=r.reject,i}function A(){var e=O(function(e){return{config:e.config,resolve:e.resolve,reject:e.reject}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(t){var n=t.m||t;I(n),e.resolve(n)},function(t){e.reject(t)})}function I(e){O().monaco||N({monaco:e})}var T=new Promise(function(e,t){return N({resolve:e,reject:t})}),C={config:function(e){var t=x(e),n=t.monaco,i=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,E);N(function(e){return{config:function e(t,n){return Object.keys(n).forEach(function(r){n[r]instanceof Object&&t[r]&&Object.assign(n[r],e(t[r],n[r]))}),r(r({},t),n)}(e.config,i),monaco:n}})},init:function(){var e=O(function(e){return{monaco:e.monaco,isInitialized:e.isInitialized,resolve:e.resolve}});if(!e.isInitialized){if(N({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),k(T);if(window.monaco&&window.monaco.editor)return I(window.monaco),e.resolve(window.monaco),k(T);j(P,L)(A)}return k(T)},__getMonacoInstance:function(){return O(function(e){return e.monaco})}};e.s(["default",0,C],485599);var R=e.i(764556),$={display:"flex",position:"relative",textAlign:"initial"},_={width:"100%"},F={display:"none"},z={display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"},q=function({children:e}){return R.default.createElement("div",{style:z},e)},D=(0,R.memo)(function({width:e,height:t,isEditorReady:n,loading:r,_ref:i,className:o,wrapperProps:a}){return R.default.createElement("section",{style:{...$,width:e,height:t},...a},!n&&R.default.createElement(q,null,r),R.default.createElement("div",{ref:i,style:{..._,...!n&&F},className:o}))}),V=function(e){(0,R.useEffect)(e,[])},B=function(e,t,n=!0){let r=(0,R.useRef)(!0);(0,R.useEffect)(r.current||!n?()=>{r.current=!1}:e,t)};function W(){}function U(e,t,n,r){var i,o,a,c,u,l;return i=e,o=r,i.editor.getModel(H(i,o))||(a=e,c=t,u=n,l=r,a.editor.createModel(c,u,l?H(a,l):void 0))}function H(e,t){return e.Uri.parse(t)}var K=(0,R.memo)(function({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:i,originalModelPath:o,modifiedModelPath:a,keepCurrentOriginalModel:c=!1,keepCurrentModifiedModel:u=!1,theme:l="light",loading:s="Loading...",options:d={},height:f="100%",width:m="100%",className:h,wrapperProps:g={},beforeMount:p=W,onMount:v=W}){let[y,w]=(0,R.useState)(!1),[b,x]=(0,R.useState)(!0),j=(0,R.useRef)(null),S=(0,R.useRef)(null),k=(0,R.useRef)(null),E=(0,R.useRef)(v),M=(0,R.useRef)(p),O=(0,R.useRef)(!1);V(()=>{let e=C.init();return e.then(e=>(S.current=e)&&x(!1)).catch(e=>e?.type!=="cancelation"&&console.error("Monaco initialization: error:",e)),()=>{let t;return j.current?(t=j.current?.getModel(),void(c||t?.original?.dispose(),u||t?.modified?.dispose(),j.current?.dispose())):e.cancel()}}),B(()=>{if(j.current&&S.current){let t=j.current.getOriginalEditor(),i=U(S.current,e||"",r||n||"text",o||"");i!==t.getModel()&&t.setModel(i)}},[o],y),B(()=>{if(j.current&&S.current){let e=j.current.getModifiedEditor(),r=U(S.current,t||"",i||n||"text",a||"");r!==e.getModel()&&e.setModel(r)}},[a],y),B(()=>{let e=j.current.getModifiedEditor();e.getOption(S.current.editor.EditorOption.readOnly)?e.setValue(t||""):t!==e.getValue()&&(e.executeEdits("",[{range:e.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),e.pushUndoStop())},[t],y),B(()=>{j.current?.getModel()?.original.setValue(e||"")},[e],y),B(()=>{let{original:e,modified:t}=j.current.getModel();S.current.editor.setModelLanguage(e,r||n||"text"),S.current.editor.setModelLanguage(t,i||n||"text")},[n,r,i],y),B(()=>{S.current?.editor.setTheme(l)},[l],y),B(()=>{j.current?.updateOptions(d)},[d],y);let N=(0,R.useCallback)(()=>{if(!S.current)return;M.current(S.current);let c=U(S.current,e||"",r||n||"text",o||""),u=U(S.current,t||"",i||n||"text",a||"");j.current?.setModel({original:c,modified:u})},[n,t,i,e,r,o,a]),P=(0,R.useCallback)(()=>{!O.current&&k.current&&(j.current=S.current.editor.createDiffEditor(k.current,{automaticLayout:!0,...d}),N(),S.current?.editor.setTheme(l),w(!0),O.current=!0)},[d,l,N]);return(0,R.useEffect)(()=>{y&&E.current(j.current,S.current)},[y]),(0,R.useEffect)(()=>{b||y||P()},[b,y,P]),R.default.createElement(D,{width:m,height:f,isEditorReady:y,loading:s,_ref:k,className:h,wrapperProps:g})}),Q=function(e){let t=(0,R.useRef)();return(0,R.useEffect)(()=>{t.current=e},[e]),t.current},J=new Map,Y=(0,R.memo)(function({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:i,path:o,theme:a="light",line:c,loading:u="Loading...",options:l={},overrideServices:s={},saveViewState:d=!0,keepCurrentModel:f=!1,width:m="100%",height:h="100%",className:g,wrapperProps:p={},beforeMount:v=W,onMount:y=W,onChange:w,onValidate:b=W}){let[x,j]=(0,R.useState)(!1),[S,k]=(0,R.useState)(!0),E=(0,R.useRef)(null),M=(0,R.useRef)(null),O=(0,R.useRef)(null),N=(0,R.useRef)(y),P=(0,R.useRef)(v),L=(0,R.useRef)(),A=(0,R.useRef)(r),I=Q(o),T=(0,R.useRef)(!1),$=(0,R.useRef)(!1);V(()=>{let e=C.init();return e.then(e=>(E.current=e)&&k(!1)).catch(e=>e?.type!=="cancelation"&&console.error("Monaco initialization: error:",e)),()=>M.current?void(L.current?.dispose(),f?d&&J.set(o,M.current.saveViewState()):M.current.getModel()?.dispose(),M.current.dispose()):e.cancel()}),B(()=>{let a=U(E.current,e||r||"",t||i||"",o||n||"");a!==M.current?.getModel()&&(d&&J.set(I,M.current?.saveViewState()),M.current?.setModel(a),d&&M.current?.restoreViewState(J.get(o)))},[o],x),B(()=>{M.current?.updateOptions(l)},[l],x),B(()=>{M.current&&void 0!==r&&(M.current.getOption(E.current.editor.EditorOption.readOnly)?M.current.setValue(r):r!==M.current.getValue()&&($.current=!0,M.current.executeEdits("",[{range:M.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),M.current.pushUndoStop(),$.current=!1))},[r],x),B(()=>{let e=M.current?.getModel();e&&i&&E.current?.editor.setModelLanguage(e,i)},[i],x),B(()=>{void 0!==c&&M.current?.revealLine(c)},[c],x),B(()=>{E.current?.editor.setTheme(a)},[a],x);let _=(0,R.useCallback)(()=>{if(!(!O.current||!E.current)&&!T.current){P.current(E.current);let u=o||n,f=U(E.current,r||e||"",t||i||"",u||"");M.current=E.current?.editor.create(O.current,{model:f,automaticLayout:!0,...l},s),d&&M.current.restoreViewState(J.get(u)),E.current.editor.setTheme(a),void 0!==c&&M.current.revealLine(c),j(!0),T.current=!0}},[e,t,n,r,i,o,l,s,d,a,c]);return(0,R.useEffect)(()=>{x&&N.current(M.current,E.current)},[x]),(0,R.useEffect)(()=>{S||x||_()},[S,x,_]),A.current=r,(0,R.useEffect)(()=>{x&&w&&(L.current?.dispose(),L.current=M.current?.onDidChangeModelContent(e=>{$.current||w(M.current.getValue(),e)}))},[x,w]),(0,R.useEffect)(()=>{if(x){let e=E.current.editor.onDidChangeMarkers(e=>{let t=M.current.getModel()?.uri;if(t&&e.find(e=>e.path===t.path)){let e=E.current.editor.getModelMarkers({resource:t});b?.(e)}});return()=>{e?.dispose()}}return()=>{}},[x,b]),R.default.createElement(D,{width:m,height:h,isEditorReady:x,loading:u,_ref:O,className:g,wrapperProps:p})});e.s(["DiffEditor",0,K,"Editor",0,Y,"default",0,Y,"useMonaco",0,function(){let[e,t]=(0,R.useState)(C.__getMonacoInstance());return V(()=>{let n;return e||(n=C.init()).then(e=>{t(e)}),()=>n?.cancel()}),e}],304271)},462506,e=>{"use strict";e.i(304271);var t=e.i(485599),t=t;t.default.config({paths:{vs:"/monaco/vs"}}),e.s([],462506)},969170,457318,e=>{"use strict";var t=e.i(433721);let n=(0,t.default)("file-question-mark",[["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 17h.01",key:"p32p05"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]]);e.s(["FileQuestion",0,n],969170);let r=(0,t.default)("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]);e.s(["Filter",0,r],457318)},355479,e=>{"use strict";let t=(0,e.i(433721).default)("split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]);e.s(["Split",0,t],355479)},613812,e=>{"use strict";var t=e.i(344180);e.i(462506);var n=e.i(304271),r=e.i(764556),i=e.i(950396),o=e.i(564822),a=e.i(465458),c=e.i(344118),u=e.i(969170),l=e.i(457318),s=e.i(355479);function d({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"empty",className:(0,a.cn)("flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance",e),...n})}function f({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"empty-header",className:(0,a.cn)("flex max-w-sm flex-col items-center gap-2",e),...n})}let m=(0,e.i(294237).cva)("mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",icon:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{variant:"default"}});function h({className:e,variant:n="default",...r}){return(0,t.jsx)("div",{"data-slot":"empty-icon","data-variant":n,className:(0,a.cn)(m({variant:n,className:e})),...r})}function g({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"empty-title",className:(0,a.cn)("font-heading text-sm font-medium tracking-tight",e),...n})}function p({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"empty-description",className:(0,a.cn)("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...n})}e.s(["DiffViewer",0,function({oldContent:e,newContent:m,path:v,isBinary:y,compactDiff:w=!0,mergeMode:b=!1,onResolve:x}){let j,S=(j=v.split(".").pop()?.toLowerCase())?({ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",json:"json",md:"markdown",css:"css",html:"html",py:"python",rs:"rust",go:"go",yaml:"yaml",yml:"yaml"})[j]:void 0,k=(0,r.useRef)(null),{resolvedTheme:E}=(0,i.useTheme)(),M=(0,o.useIsMobile)(),[O,N]=(0,r.useState)(w),[P,L]=(0,r.useState)(null),A=(0,r.useCallback)(e=>{k.current=e},[]);(0,r.useEffect)(()=>()=>{let e=k.current;e&&(e.setModel(null),k.current=null)},[]);let I=(0,r.useMemo)(()=>O?function(e,t){let n=e.split("\n"),r=t.split("\n"),i=n.length,o=r.length;if(e===t||i*o>4e6)return null;let a=Array.from({length:i+1},()=>Array(o+1).fill(0));for(let e=i-1;e>=0;e--)for(let t=o-1;t>=0;t--)n[e]===r[t]?a[e][t]=a[e+1][t+1]+1:a[e][t]=Math.max(a[e+1][t],a[e][t+1]);let c=new Set,u=new Set,l=0,s=0;for(;l<i&&s<o;)n[l]===r[s]?(c.add(l),u.add(s),l++,s++):a[l+1][s]>=a[l][s+1]?l++:s++;let d=new Set,f=new Set;for(let e=0;e<i;e++)if(!c.has(e))for(let t=Math.max(0,e-10);t<=Math.min(i-1,e+10);t++)d.add(t);for(let e=0;e<o;e++)if(!u.has(e))for(let t=Math.max(0,e-10);t<=Math.min(o-1,e+10);t++)f.add(t);function m(e){let t=Array.from(e).sort((e,t)=>e-t);if(0===t.length)return[];let n=[[t[0],t[0]]];for(let e=1;e<t.length;e++){let r=n[n.length-1];t[e]<=r[1]+1?r[1]=t[e]:n.push([t[e],t[e]])}return n}let h=m(d),g=m(f);if(0===h.length&&0===g.length)return null;let p="···";function v(e,t){let n=[];for(let r=0;r<t.length;r++){let[i,o]=t[r];(r>0||i>0)&&n.push(p);for(let t=i;t<=o;t++)n.push(e[t])}return t.length>0&&t[t.length-1][1]<e.length-1&&n.push(p),n}return{oldLines:v(n,h),newLines:v(r,g)}}(e,m):null,[O,e,m]),T=I?I.oldLines.join("\n"):e,C=I?I.newLines.join("\n"):m,R=(0,r.useCallback)(async t=>{if(x&&!P){L(t);try{await x("left"===t?e:m,t)}finally{L(null)}}},[m,e,x,P]),$=!e,_=!m,F=$&&_;return(0,t.jsxs)("div",{className:"h-full w-full flex flex-col",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 border-b bg-muted/30",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",children:v}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[b&&x&&(0,t.jsxs)(t.Fragment,{children:[!$&&(0,t.jsxs)("button",{onClick:()=>R("left"),disabled:null!==P,className:"flex items-center gap-1 text-xs px-1.5 py-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent disabled:opacity-50",title:"保留左侧",children:["left"===P?(0,t.jsx)(c.Check,{className:"h-3 w-3"}):(0,t.jsx)(s.Split,{className:"h-3 w-3 rotate-180"}),"保留左侧"]}),!_&&(0,t.jsxs)("button",{onClick:()=>R("right"),disabled:null!==P,className:"flex items-center gap-1 text-xs px-1.5 py-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent disabled:opacity-50",title:"保留右侧",children:["right"===P?(0,t.jsx)(c.Check,{className:"h-3 w-3"}):(0,t.jsx)(s.Split,{className:"h-3 w-3"}),"保留右侧"]})]}),!F&&!y&&(0,t.jsxs)("button",{onClick:()=>N(e=>!e),className:(0,a.cn)("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",O?"text-blue-600 dark:text-blue-400 bg-blue-500/10":"text-muted-foreground hover:text-foreground"),title:O?"显示全部代码":"只看修改部分",children:[(0,t.jsx)(l.Filter,{className:"h-3 w-3"}),O?"紧凑":"全部"]})]})]}),(0,t.jsx)("div",{className:"flex-1",children:y?(0,t.jsxs)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm gap-2",children:[(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,t.jsx)("polyline",{points:"14 2 14 8 20 8"})]}),"二进制文件,不支持预览"]}):F?(0,t.jsx)(d,{className:"h-full border-0",children:(0,t.jsxs)(f,{children:[(0,t.jsx)(h,{variant:"icon",children:(0,t.jsx)(u.FileQuestion,{})}),(0,t.jsx)(g,{children:"无内容"}),(0,t.jsx)(p,{children:"该文件没有可显示的内容"})]})}):$?(0,t.jsx)(n.DiffEditor,{original:"",modified:C,language:S,theme:"dark"===E?"vs-dark":"vs",onMount:A,options:{readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:"on"}}):(0,t.jsx)(n.DiffEditor,{original:T,modified:C,language:S,theme:"dark"===E?"vs-dark":"vs",onMount:A,options:{readOnly:!0,renderSideBySide:!M,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:"on"}})})]})}],613812)}]);
@@ -16,4 +16,4 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
16
16
  `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(t0(n,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(eB(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let i=0;i<e;i++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
17
17
  `&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=I)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,i){this._liveRegionDebouncer.refresh(e,i,this._terminal.rows)}_renderRows(e,i){let s=this._terminal.buffer,r=s.lines.length.toString();for(let n=e;n<=i;n++){let e=s.lines.get(s.ydisp+n),i=[],o=e?.translateToString(!0,void 0,void 0,i)||"",a=(s.ydisp+n+1).toString(),h=this._rowElements[n];h&&(0===o.length?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=o,this._rowColumns.set(h,i)),h.setAttribute("aria-posinset",a),h.setAttribute("aria-setsize",r),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,i){let s,r,n=e.target,o=this._rowElements[0===i?1:this._rowElements.length-2];if(n.getAttribute("aria-posinset")!==(0===i?"1":`${this._terminal.buffer.lines.length}`)&&e.relatedTarget===o){if(0===i?(s=n,r=this._rowElements.pop(),this._rowContainer.removeChild(r)):(s=this._rowElements.shift(),r=n,this._rowContainer.removeChild(s)),s.removeEventListener("focus",this._topBoundaryFocusListener),r.removeEventListener("focus",this._bottomBoundaryFocusListener),0===i){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement("afterbegin",e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===i?-1:1),this._rowElements[0===i?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode)return void console.error("anchorNode and/or focusNode are null");let i={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((i.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||i.node===s.node&&i.offset>s.offset)&&([i,s]=[s,i]),i.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(i={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(i.node))return;let r=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let n=({node:e,offset:i})=>{let s=e instanceof Text?e.parentNode:e,r=parseInt(s?.getAttribute("aria-posinset"),10)-1;if(isNaN(r))return console.warn("row is invalid. Race condition?"),null;let n=this._rowColumns.get(s);if(!n)return console.warn("columns is null. Race condition?"),null;let o=i<n.length?n[i]:n.slice(-1)[0]+1;return o>=this._terminal.cols&&(++r,o=0),{row:r,column:o}},o=n(i),a=n(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let i=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let r=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/i})`}};r4=A([O(1,ei),O(2,ec),O(3,eu)],r4);var r8=class extends eL{constructor(e,i,s,r,n){super(),this._element=e,this._mouseService=i,this._renderService=s,this._bufferService=r,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new eG),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new eG),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(eB(()=>{eD(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(t0(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(t0(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(t0(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(t0(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let i=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!i)return;this._isMouseOut=!1;let s=e.composedPath();for(let e=0;e<s.length;e++){let i=s[e];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}this._lastBufferCell&&i.x===this._lastBufferCell.x&&i.y===this._lastBufferCell.y||(this._handleHover(i),this._lastBufferCell=i)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,i){this._activeProviderReplies&&i||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[r,n]of this._linkProviderService.linkProviders.entries())i?this._activeProviderReplies?.get(r)&&(s=this._checkLinkProviderResult(r,e,s)):n.provideLinks(e.y,i=>{if(this._isMouseOut)return;let n=i?.map(e=>({link:e}));this._activeProviderReplies?.set(r,n),s=this._checkLinkProviderResult(r,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,i){let s=new Set;for(let r=0;r<i.size;r++){let n=i.get(r);if(n)for(let i=0;i<n.length;i++){let r=n[i],o=r.link.range.start.y<e?0:r.link.range.start.x,a=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=o;e<=a;e++){if(s.has(e)){n.splice(i--,1);break}s.add(e)}}}}_checkLinkProviderResult(e,i,s){if(!this._activeProviderReplies)return s;let r=this._activeProviderReplies.get(e),n=!1;for(let i=0;i<e;i++)(!this._activeProviderReplies.has(i)||this._activeProviderReplies.get(i))&&(n=!0);if(!n&&r){let e=r.find(e=>this._linkAtPosition(e.link,i));e&&(s=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,i));if(r){s=!0,this._handleNewLink(r);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){var i,s;if(!this._currentLink)return;let r=this._positionFromMouseEvent(e,this._element,this._mouseService);r&&this._mouseDownLink&&(i=this._mouseDownLink.link,s=this._currentLink.link,i.text===s.text&&i.range.start.x===s.range.start.x&&i.range.start.y===s.range.start.y&&i.range.end.x===s.range.end.x&&i.range.end.y===s.range.end.y)&&this._linkAtPosition(this._currentLink.link,r)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,i){this._currentLink&&this._lastMouseEvent&&(!e||!i||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=i)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,eD(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let i=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);i&&this._linkAtPosition(e.link,i)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let i=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(i,s),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,i,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),i.hover&&i.hover(s,i.text)}_fireUnderlineEvent(e,i){let s=e.range,r=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-r-1,s.end.x,s.end.y-r-1,void 0);(i?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,i,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),i.leave&&i.leave(s,i.text)}_linkAtPosition(e,i){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,n=i.y*this._bufferService.cols+i.x;return s<=n&&n<=r}_positionFromMouseEvent(e,i,s){let r=s.getCoords(e,i,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,i,s,r,n){return{x1:e,y1:i,x2:s,y2:r,cols:this._bufferService.cols,fg:n}}};r8=A([O(1,ed),O(2,eu),O(3,Z),O(4,eg)],r8);var r7=class extends rJ{constructor(e={}){super(e),this._linkifier=this._register(new eP),this.browser=sd,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new eP),this._onCursorMove=this._register(new eG),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new eG),this.onKey=this._onKey.event,this._onRender=this._register(new eG),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new eG),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new eG),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new eG),this.onBell=this._onBell.event,this._onFocus=this._register(new eG),this._onBlur=this._register(new eG),this._onA11yCharEmitter=this._register(new eG),this._onA11yTabEmitter=this._register(new eG),this._onWillOpen=this._register(new eG),this._setup(),this._decorationService=this._instantiationService.createInstance(r5),this._instantiationService.setService(ea,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(sa),this._instantiationService.setService(eg,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(eh)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(e$.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(e$.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(e$.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(e$.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(eB(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}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}_handleColorEvent(e){if(this._themeService)for(let i of e){let e,s="";switch(i.index){case 256:e="foreground",s="10";break;case 257:e="background",s="11";break;case 258:e="cursor",s="12";break;default:e="ansi",s="4;"+i.index}switch(i.type){case 0:let r=rg.toColorRGB("ansi"===e?this._themeService.colors.ansi[i.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${iP.ESC}]${s};${function(e,i=16){let[s,r,n]=e;return`rgb:${rF(s,i)}/${rF(r,i)}/${rF(n,i)}`}(r)}${iA.ST}`);break;case 1:if("ansi"===e)this._themeService.modifyColors(e=>e.ansi[i.index]=iO.toColor(...i.color));else{let s=e;this._themeService.modifyColors(e=>e[s]=iO.toColor(...i.color))}break;case 2:this._themeService.restoreColor(i.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(r4,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(iP.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(iP.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,i=this.buffer.lines.get(e);if(!i)return;let s=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,n=i.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,h=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(t0(this.element,"copy",e=>{var i;this.hasSelection()&&(i=this._selectionService,e.clipboardData&&e.clipboardData.setData("text/plain",i.selectionText),e.preventDefault())}));let e=e=>{var i,s,r;return i=this.textarea,s=this.coreService,r=this.optionsService,void(e.stopPropagation(),e.clipboardData&&W(e.clipboardData.getData("text/plain"),i,s,r))};this._register(t0(this.textarea,"paste",e)),this._register(t0(this.element,"paste",e)),sm?this._register(t0(this.element,"mousedown",e=>{2===e.button&&z(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(t0(this.element,"contextmenu",e=>{z(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),sk&&this._register(t0(this.element,"auxclick",e=>{1===e.button&&H(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(t0(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(t0(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(t0(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(t0(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(t0(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(t0(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(t0(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let i=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),i.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(t0(this.screenElement,"mousemove",e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),i.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",N),sE||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._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(sn,this.textarea,e.ownerDocument.defaultView??window,this._document??"u">typeof window?window.document:null)),this._instantiationService.setService(ec,this._coreBrowserService),this._register(t0(this.textarea,"focus",e=>this._handleTextAreaFocus(e))),this._register(t0(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(st,this._document,this._helperContainer),this._instantiationService.setService(el,this._charSizeService),this._themeService=this._instantiationService.createInstance(sG),this._instantiationService.setService(ep,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(iJ),this._instantiationService.setService(ef,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(sP,this.rows,this.screenElement)),this._instantiationService.setService(eu,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(iE,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(sl),this._instantiationService.setService(ed,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(r8,this.screenElement));this.element.appendChild(i);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),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._viewport=this._register(this._instantiationService.createInstance(iS,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(sj,this.element,this.screenElement,r)),this._instantiationService.setService(e_,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(e$.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(ib,this.screenElement)),this._register(t0(this.element,"mousedown",e=>this._selectionService.handleMouseDown(e))),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(r4,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ik,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ik,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(se,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,i=this.element;function s(i){let s,r,n=e._mouseService.getMouseReportCoords(i,e.screenElement);if(!n)return!1;switch(i.overrideType||i.type){case"mousemove":r=32,void 0===i.buttons?(s=3,void 0!==i.button&&(s=i.button<3?i.button:3)):s=1&i.buttons?0:4&i.buttons?1:2&i.buttons?2:3;break;case"mouseup":r=0,s=i.button<3?i.button:3;break;case"mousedown":r=1,s=i.button<3?i.button:3;break;case"wheel":if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(i))return!1;let o=i.deltaY;if(0===o||0===e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return!1;r=o<0?0:1,s=4;break;default:return!1}return void 0!==r&&void 0!==s&&!(s>4)&&e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:s,action:r,ctrl:i.ctrlKey,alt:i.altKey,shift:i.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n=e=>(s(e),e.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(e)),o=e=>(s(e),this.cancel(e,!0)),a=e=>{e.buttons&&s(e)},h=e=>{e.buttons||s(e)};this._register(this.coreMouseService.onProtocolChange(e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(e)),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&e?r.mousemove||(i.addEventListener("mousemove",h),r.mousemove=h):(i.removeEventListener("mousemove",r.mousemove),r.mousemove=null),16&e?r.wheel||(i.addEventListener("wheel",o,{passive:!1}),r.wheel=o):(i.removeEventListener("wheel",r.wheel),r.wheel=null),2&e?r.mouseup||(r.mouseup=n):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),4&e?r.mousedrag||(r.mousedrag=a):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(t0(i,"mousedown",e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return s(e),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(e)})),this._register(t0(i,"wheel",i=>{if(!r.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(i))return!1;if(!this.buffer.hasScrollback){if(0===i.deltaY)return!1;if(0===e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return this.cancel(i,!0);let s=iP.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(i.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(s,!0),this.cancel(i,!0)}}},{passive:!1}))}refresh(e,i){this._renderService?.refreshRows(e,i)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?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(e,i){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,i),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let i=e-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}paste(e){W(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let i=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),i}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(e,i,s){this._selectionService.setSelection(e,i,s)}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(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,i){this._selectionService?.selectLines(e,i)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;let i=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!i&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;i||"Dead"!==e.key&&"AltGraph"!==e.key||(this._unprocessedDeadKey=!0);let s=function(e,i,s,r){let n={type:0,cancel:!1,key:void 0},o=!!e.shiftKey|2*!!e.altKey|4*!!e.ctrlKey|8*!!e.metaKey;switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?i?n.key=iP.ESC+"OA":n.key=iP.ESC+"[A":"UIKeyInputLeftArrow"===e.key?i?n.key=iP.ESC+"OD":n.key=iP.ESC+"[D":"UIKeyInputRightArrow"===e.key?i?n.key=iP.ESC+"OC":n.key=iP.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(i?n.key=iP.ESC+"OB":n.key=iP.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":iP.DEL,e.altKey&&(n.key=iP.ESC+n.key);break;case 9:if(e.shiftKey){n.key=iP.ESC+"[Z";break}n.key=iP.HT,n.cancel=!0;break;case 13:n.key=e.altKey?iP.ESC+iP.CR:iP.CR,n.cancel=!0;break;case 27:n.key=iP.ESC,e.altKey&&(n.key=iP.ESC+iP.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=iP.ESC+"[1;"+(o+1)+"D":i?n.key=iP.ESC+"OD":n.key=iP.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=iP.ESC+"[1;"+(o+1)+"C":i?n.key=iP.ESC+"OC":n.key=iP.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=iP.ESC+"[1;"+(o+1)+"A":i?n.key=iP.ESC+"OA":n.key=iP.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=iP.ESC+"[1;"+(o+1)+"B":i?n.key=iP.ESC+"OB":n.key=iP.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(n.key=iP.ESC+"[2~");break;case 46:o?n.key=iP.ESC+"[3;"+(o+1)+"~":n.key=iP.ESC+"[3~";break;case 36:o?n.key=iP.ESC+"[1;"+(o+1)+"H":i?n.key=iP.ESC+"OH":n.key=iP.ESC+"[H";break;case 35:o?n.key=iP.ESC+"[1;"+(o+1)+"F":i?n.key=iP.ESC+"OF":n.key=iP.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=iP.ESC+"[5;"+(o+1)+"~":n.key=iP.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=iP.ESC+"[6;"+(o+1)+"~":n.key=iP.ESC+"[6~";break;case 112:o?n.key=iP.ESC+"[1;"+(o+1)+"P":n.key=iP.ESC+"OP";break;case 113:o?n.key=iP.ESC+"[1;"+(o+1)+"Q":n.key=iP.ESC+"OQ";break;case 114:o?n.key=iP.ESC+"[1;"+(o+1)+"R":n.key=iP.ESC+"OR";break;case 115:o?n.key=iP.ESC+"[1;"+(o+1)+"S":n.key=iP.ESC+"OS";break;case 116:o?n.key=iP.ESC+"[15;"+(o+1)+"~":n.key=iP.ESC+"[15~";break;case 117:o?n.key=iP.ESC+"[17;"+(o+1)+"~":n.key=iP.ESC+"[17~";break;case 118:o?n.key=iP.ESC+"[18;"+(o+1)+"~":n.key=iP.ESC+"[18~";break;case 119:o?n.key=iP.ESC+"[19;"+(o+1)+"~":n.key=iP.ESC+"[19~";break;case 120:o?n.key=iP.ESC+"[20;"+(o+1)+"~":n.key=iP.ESC+"[20~";break;case 121:o?n.key=iP.ESC+"[21;"+(o+1)+"~":n.key=iP.ESC+"[21~";break;case 122:o?n.key=iP.ESC+"[23;"+(o+1)+"~":n.key=iP.ESC+"[23~";break;case 123:o?n.key=iP.ESC+"[24;"+(o+1)+"~":n.key=iP.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if((!s||r)&&e.altKey&&!e.metaKey){let i=rZ[e.keyCode]?.[+!!e.shiftKey];if(i)n.key=iP.ESC+i;else if(e.keyCode>=65&&e.keyCode<=90){let i=String.fromCharCode(e.ctrlKey?e.keyCode-64:e.keyCode+32);e.shiftKey&&(i=i.toUpperCase()),n.key=iP.ESC+i}else if(32===e.keyCode)n.key=iP.ESC+(e.ctrlKey?iP.NUL:" ");else if("Dead"===e.key&&e.code.startsWith("Key")){let i=e.code.slice(3,4);e.shiftKey||(i=i.toLowerCase()),n.key=iP.ESC+i,n.cancel=!0}}else!s||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?!e.key||e.ctrlKey||e.altKey||e.metaKey||!(e.keyCode>=48)||1!==e.key.length?e.key&&e.ctrlKey&&("_"===e.key&&(n.key=iP.US),"@"===e.key&&(n.key=iP.NUL)):n.key=e.key:65===e.keyCode&&(n.type=1);else e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?n.key=iP.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?n.key=iP.DEL:219===e.keyCode?n.key=iP.ESC:220===e.keyCode?n.key=iP.FS:221===e.keyCode&&(n.key=iP.GS)}return n}(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===s.type||2===s.type){let i=this.rows-1;return this.scrollLines(2===s.type?-i:i),this.cancel(e,!0)}return 1===s.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&1===e.key.length&&e.key.charCodeAt(0)>=65&&90>=e.key.charCodeAt(0))||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((s.key===iP.ETX||s.key===iP.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)?this.cancel(e,!0):void(this._keyDownHandled=!0))}_isThirdLevelShift(e,i){let s=e.isMac&&!this.options.macOptionIsMeta&&i.altKey&&!i.ctrlKey&&!i.metaKey||e.isWindows&&i.altKey&&i.ctrlKey&&!i.metaKey||e.isWindows&&i.getModifierState("AltGraph");return"keypress"===i.type?s:s&&(!i.keyCode||i.keyCode>47)}_keyUp(e){var i;this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(16===(i=e).keyCode||17===i.keyCode||18===i.keyCode||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let i;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)i=e.charCode;else if(null===e.which||void 0===e.which)i=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;i=e.which}return!!i&&(!e.altKey&&!e.ctrlKey&&!e.metaKey||!!this._isThirdLevelShift(this.browser,e))&&(i=String.fromCharCode(i),this._onKey.fire({key:i,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&"insertText"===e.inputType&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let i=e.data;return this.coreService.triggerDataEvent(i,!0),this.cancel(e),!0}return!1}resize(e,i){if(e===this.cols&&i===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,i)}_afterResize(e,i){this._charSizeService?.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){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 e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(s5));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(iP.ESC+"[I"):this.coreService.triggerDataEvent(iP.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let i=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${iP.ESC}[4;${s};${i}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${iP.ESC}[6;${n};${r}t`)}}cancel(e,i){if(!(!this.options.cancelEvents&&!i))return e.preventDefault(),e.stopPropagation(),!1}},r9=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,i){let s={instance:i,dispose:i.dispose,isDisposed:!1};this._addons.push(s),i.dispose=()=>this._wrappedAddonDispose(s),i.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let i=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){i=s;break}if(-1===i)throw Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(i,1)}},ne=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,i){if(!(e<0||e>=this._line.length))return i?(this._line.loadCell(e,i),i):this._line.loadCell(e,new V)}translateToString(e,i,s){return this._line.translateToString(e,i,s)}},nt=class{constructor(e,i){this._buffer=e,this.type=i}init(e){return this._buffer=e,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(e){let i=this._buffer.lines.get(e);if(i)return new ne(i)}getNullCell(){return new V}},ni=class extends eL{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new eG),this.onBufferChange=this._onBufferChange.event,this._normal=new nt(this._core.buffers.normal,"normal"),this._alternate=new nt(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 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)}},ns=class{constructor(e){this._core=e}registerCsiHandler(e,i){return this._core.registerCsiHandler(e,e=>i(e.toArray()))}addCsiHandler(e,i){return this.registerCsiHandler(e,i)}registerDcsHandler(e,i){return this._core.registerDcsHandler(e,(e,s)=>i(e,s.toArray()))}addDcsHandler(e,i){return this.registerDcsHandler(e,i)}registerEscHandler(e,i){return this._core.registerEscHandler(e,i)}addEscHandler(e,i){return this.registerEscHandler(e,i)}registerOscHandler(e,i){return this._core.registerOscHandler(e,i)}addOscHandler(e,i){return this.registerOscHandler(e,i)}},nr=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},nn=["cols","rows"],no=0,na=class extends eL{constructor(e){super(),this._core=this._register(new r7(e)),this._addonManager=this._register(new r9),this._publicOptions={...this._core.options};let i=e=>this._core.options[e],s=(e,i)=>{this._checkReadonlyOptions(e),this._core.options[e]=i};for(let e in this._core.options){let r={get:i.bind(this,e),set:s.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(nn.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw 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 ns(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new nr(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 ni(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,i="none";switch(this._core.coreMouseService.activeProtocol){case"X10":i="x10";break;case"VT200":i="vt200";break;case"DRAG":i="drag";break;case"ANY":i="any"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:i,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let i in e)this._publicOptions[i]=e[i]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,i=!0){this._core.input(e,i)}resize(e,i){this._verifyIntegers(e,i),this._core.resize(e,i)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,i,s){this._verifyIntegers(e,i,s),this._core.select(e,i,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,i){this._verifyIntegers(e,i),this._core.selectLines(e,i)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,i){this._core.write(e,i)}writeln(e,i){this._core.write(e),this._core.write(`\r
18
18
  `,i)}paste(e){this._core.paste(e)}refresh(e,i){this._verifyIntegers(e,i),this._core.refresh(e,i)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return N},set promptLabel(t){N=t},get tooMuchOutput(){return I},set tooMuchOutput(t){I=t}}}_verifyIntegers(...e){for(no of e)if(no===1/0||isNaN(no)||no%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(no of e)if(no&&(no===1/0||isNaN(no)||no%1!=0||no<0))throw Error("This API only accepts positive integers")}},nh=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let i=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(i._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(0===e.css.cell.width||0===e.css.cell.height)return;let i=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),n=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},h=a.top+a.bottom;return{cols:Math.max(2,Math.floor((n-(a.right+a.left)-i)/e.css.cell.width)),rows:Math.max(1,Math.floor((r-h)/e.css.cell.height))}}},nl=class{constructor(e,i,s,r={}){this._terminal=e,this._regex=i,this._handler=s,this._options=r}provideLinks(e,i){let s=nc.computeLink(e,this._regex,this._terminal,this._handler);i(this._addCallbacks(s))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(i,s)=>{if(this._options.hover){let{range:r}=e;this._options.hover(i,s,r)}},e))}},nc=class e{static computeLink(i,s,r,n){let o=RegExp(s.source,(s.flags||"")+"g"),[a,h]=e._getWindowedLineStrings(i-1,r),l=a.join(""),c,d=[];for(;c=o.exec(l);){let i=c[0];if(!function(e){try{let i=new URL(e),s=i.password&&i.username?`${i.protocol}//${i.username}:${i.password}@${i.host}`:i.username?`${i.protocol}//${i.username}@${i.host}`:`${i.protocol}//${i.host}`;return e.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}(i))continue;let[s,o]=e._mapStrIdx(r,h,0,c.index),[a,l]=e._mapStrIdx(r,s,o,i.length);if(-1===s||-1===o||-1===a||-1===l)continue;let u={start:{x:o+1,y:s+1},end:{x:l,y:a+1}};d.push({range:u,text:i,activate:n})}return d}static _getWindowedLineStrings(e,i){let s,r=e,n=e,o=0,a="",h=[];if(s=i.buffer.active.getLine(e)){let e=s.translateToString(!0);if(s.isWrapped&&" "!==e[0]){for(o=0;(s=i.buffer.active.getLine(--r))&&o<2048&&(o+=(a=s.translateToString(!0)).length,h.push(a),!(!s.isWrapped||-1!==a.indexOf(" "))););h.reverse()}for(h.push(e),o=0;(s=i.buffer.active.getLine(++n))&&s.isWrapped&&o<2048&&(o+=(a=s.translateToString(!0)).length,h.push(a),-1===a.indexOf(" ")););}return[h,r]}static _mapStrIdx(e,i,s,r){let n=e.buffer.active,o=n.getNullCell(),a=s;for(;r;){let e=n.getLine(i);if(!e)return[-1,-1];for(let s=a;s<e.length;++s){e.getCell(s,o);let a=o.getChars();if(o.getWidth()&&(r-=a.length||1,s===e.length-1&&""===a)){let e=n.getLine(i+1);e&&e.isWrapped&&(e.getCell(0,o),2===o.getWidth()&&(r+=1))}if(r<0)return[i,s]}i++,a=0}return[i,a]}},nd=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function nu(e,i){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=i}else console.warn("Opening link blocked as opener could not be cleared")}var n_=class{constructor(e=nu,i={}){this._handler=e,this._options=i}activate(e){this._terminal=e;let i=this._options,s=i.urlRegex||nd;this._linkProvider=this._terminal.registerLinkProvider(new nl(this._terminal,s,this._handler,i))}dispose(){this._linkProvider?.dispose()}},nf=e.i(950396);let np=new Map,ng={background:"#ffffff",foreground:"#222222",cursor:"#1456f0",cursorAccent:"#ffffff",selectionBackground:"rgba(20, 86, 240, 0.2)",black:"#222222",red:"#ef4444",green:"#16a34a",yellow:"#ca8a04",blue:"#1456f0",magenta:"#ea5ec1",cyan:"#0891b2",white:"#e5e7eb",brightBlack:"#45515e",brightRed:"#f87171",brightGreen:"#22c55e",brightYellow:"#eab308",brightBlue:"#3b82f6",brightMagenta:"#f472b6",brightCyan:"#06b6d4",brightWhite:"#f9fafb"},nm={background:"#0f1117",foreground:"#e5e7eb",cursor:"#3b82f6",cursorAccent:"#0f1117",selectionBackground:"rgba(59, 130, 246, 0.25)",black:"#0f1117",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#ea5ec1",cyan:"#06b6d4",white:"#e5e7eb",brightBlack:"#8b8fa3",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#f472b6",brightCyan:"#22d3ee",brightWhite:"#f9fafb"};function nv({sessionId:e,workspaceId:i}){let s=(0,p.useRef)(null),r=(0,p.useRef)(null),n=(0,p.useRef)(null),{resolvedTheme:o}=(0,nf.useTheme)(),a=(0,p.useRef)(o);(0,p.useEffect)(()=>{a.current=o},[o]);let h=(0,p.useCallback)(i=>{let{sessionId:s,data:n}=i;s===e&&r.current&&r.current.write(n)},[e]);return(0,p.useEffect)(()=>{let o,l,c;if(!s.current)return;let d=(0,B.getWS)(i),u=np.get(e);u?(o=u.xterm,l=u.fit,o.element&&s.current.appendChild(o.element),requestAnimationFrame(()=>l.fit())):(o=new na({cursorBlink:!0,fontSize:13,fontFamily:'Menlo, Monaco, "Courier New", monospace',rightClickSelectsWord:!0,macOptionClickForcesSelection:!0,theme:"dark"===a.current?nm:ng}),l=new nh,o.loadAddon(l),o.loadAddon(new n_((e,i)=>{window.open(i)})),o.open(s.current),o.attachCustomKeyEventHandler(e=>!((e.ctrlKey||e.metaKey)&&"c"===e.key.toLowerCase()&&o.hasSelection())||(navigator.clipboard?.writeText(o.getSelection()),!1)),requestAnimationFrame(()=>l.fit()),np.set(e,{xterm:o,fit:l})),(c=o.textarea)&&(c.inputMode="none",c.setAttribute("inputmode","none"));let _=(0,k.consumeSessionBuffer)(e);_&&(u&&o.clear(),o.write(_)),r.current=o,n.current=l;let f=o.onData(i=>{d.send("terminal.input",{sessionId:e,data:i})});d.on("terminal.output",h),d.send("terminal.resize",{sessionId:e,cols:o.cols,rows:o.rows});let p=new ResizeObserver(()=>{try{l.fit()}catch{}d.send("terminal.resize",{sessionId:e,cols:o.cols,rows:o.rows})}),g=s.current;p.observe(g);let m=e=>{e.preventDefault(),o.hasSelection()&&navigator.clipboard?.writeText(o.getSelection())};return g.addEventListener("contextmenu",m,{capture:!0}),()=>{let i;p.disconnect(),g.removeEventListener("contextmenu",m,{capture:!0}),f.dispose(),d.off("terminal.output",h);let{sessions:s}=k.useTerminalStore.getState();!s.some(i=>i.id===e)&&(i=np.get(e))&&(i.xterm.dispose(),np.delete(e))}},[e,i,h]),(0,p.useEffect)(()=>{r.current&&o&&(r.current.options.theme="dark"===o?nm:ng)},[o]),(0,f.jsx)("div",{ref:s,className:"h-full w-full select-text touch-pan-x touch-pan-y",style:{WebkitTouchCallout:"none"}})}var nS=e.i(260218),nb=e.i(681622),nw=e.i(226624),ny=e.i(817854),nC=e.i(244073);function nx({open:e,onOpenChange:i,command:s,defaultCwd:r,onSubmit:n}){let o=(0,nC.useTranslations)("commands"),[a,h]=(0,p.useState)(s?.name??""),[l,c]=(0,p.useState)(s?.command??""),[d,u]=(0,p.useState)(s?.cwd??r??""),[_,m]=(0,p.useState)(s?.shell??""),[S,b]=(0,p.useState)(s?.env?Object.entries(s.env).map(([e,i])=>({key:e,value:i})):[]),[w,y]=(0,p.useState)(s?.autoRestart??!1),[x,k]=(0,p.useState)(!1);(0,p.useEffect)(()=>{e&&(h(s?.name??""),c(s?.command??""),u(s?.cwd??r??""),m(s?.shell??""),b(s?.env?Object.entries(s.env).map(([e,i])=>({key:e,value:i})):[]),y(s?.autoRestart??!1))},[e,s,r]);let E=async()=>{if(a.trim()&&l.trim()){k(!0);try{let e={};for(let i of S)i.key.trim()&&(e[i.key.trim()]=i.value);await n({name:a.trim(),command:l,cwd:d||void 0,shell:_||void 0,env:Object.keys(e).length>0?e:void 0,autoRestart:w||void 0}),i(!1)}finally{k(!1)}}};return(0,f.jsx)(C.Dialog,{open:e,onOpenChange:i,children:(0,f.jsxs)(C.DialogContent,{className:"sm:max-w-[480px]",children:[(0,f.jsx)(C.DialogHeader,{children:(0,f.jsx)(C.DialogTitle,{children:o(s?"editCommand":"addCommand")})}),(0,f.jsxs)("div",{className:"flex flex-col gap-3 py-2",children:[(0,f.jsxs)("div",{children:[(0,f.jsx)(ny.Label,{className:"text-xs",children:o("name")}),(0,f.jsx)(nb.Input,{value:a,onChange:e=>h(e.target.value),placeholder:"dev",className:"mt-1"})]}),(0,f.jsxs)("div",{children:[(0,f.jsx)(ny.Label,{className:"text-xs",children:o("command")}),(0,f.jsx)(nb.Input,{value:l,onChange:e=>c(e.target.value),placeholder:"pnpm dev",className:"mt-1 font-mono text-sm"})]}),(0,f.jsxs)("div",{children:[(0,f.jsx)(ny.Label,{className:"text-xs",children:o("workingDirectory")}),(0,f.jsx)(nb.Input,{value:d,onChange:e=>u(e.target.value),placeholder:r,className:"mt-1 font-mono text-xs"})]}),(0,f.jsxs)("div",{children:[(0,f.jsx)(ny.Label,{className:"text-xs",children:o("shell")}),(0,f.jsx)(nb.Input,{value:_,onChange:e=>m(e.target.value),placeholder:"Default",className:"mt-1"})]}),(0,f.jsxs)("div",{children:[(0,f.jsxs)("div",{className:"flex items-center justify-between",children:[(0,f.jsx)(ny.Label,{className:"text-xs",children:o("environmentVariables")}),(0,f.jsx)(nS.Button,{variant:"ghost",size:"sm",className:"h-5 px-1 text-xs",onClick:()=>b(e=>[...e,{key:"",value:""}]),children:(0,f.jsx)(g.Plus,{size:12})})]}),(0,f.jsx)("div",{className:"flex flex-col gap-1 mt-1",children:S.map((e,i)=>(0,f.jsxs)("div",{className:"flex items-center gap-1",children:[(0,f.jsx)(nb.Input,{value:e.key,onChange:e=>b(s=>s.map((s,r)=>r===i?{...s,key:e.target.value}:s)),placeholder:"KEY",className:"h-7 text-xs font-mono flex-1"}),(0,f.jsx)(nb.Input,{value:e.value,onChange:e=>b(s=>s.map((s,r)=>r===i?{...s,value:e.target.value}:s)),placeholder:"value",className:"h-7 text-xs font-mono flex-1"}),(0,f.jsx)(nS.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:()=>b(e=>e.filter((e,s)=>s!==i)),children:(0,f.jsx)(v.X,{size:12})})]},i))})]}),(0,f.jsxs)("div",{className:"flex items-center gap-2",children:[(0,f.jsx)(nw.Switch,{checked:w,onCheckedChange:y}),(0,f.jsx)(ny.Label,{className:"text-xs",children:o("autoRestart")})]})]}),(0,f.jsxs)(C.DialogFooter,{children:[(0,f.jsx)(nS.Button,{variant:"outline",onClick:()=>i(!1),children:o("cancel")}),(0,f.jsx)(nS.Button,{onClick:E,disabled:!a.trim()||!l.trim()||x,children:o(s?"save":"addCommand")})]})]})})}var nk=e.i(434805),nE=e.i(344118),nD=e.i(62669);function nB({open:e,onOpenChange:i,defaultPath:s,onImport:r}){let n=(0,nC.useTranslations)("commands"),[o,a]=(0,p.useState)(s??""),[h,l]=(0,p.useState)([]),[c,d]=(0,p.useState)(!1),[u,_]=(0,p.useState)(!1);(0,p.useEffect)(()=>{e&&(a(s??""),l([]))},[e,s]);let g=(0,p.useCallback)(async e=>{if(a(e),l([]),e){d(!0);try{let i=await (0,D.fetchWithAuth)(`/api/folder/read-file?path=${encodeURIComponent(e)}`);if(!i.ok)return void l([]);let s=await i.json();s.scripts&&"object"==typeof s.scripts?l(Object.entries(s.scripts).map(([e,i])=>({name:e,command:String(i),selected:!0}))):l([])}catch{l([])}finally{d(!1)}}},[]),m=async()=>{let e=h.filter(e=>e.selected);if(0!==e.length){_(!0);try{let s=o.includes("/")?o.substring(0,o.lastIndexOf("/")):o;await r(e.map(e=>({name:e.name,command:e.command,folder:s}))),i(!1)}finally{_(!1)}}};return(0,f.jsx)(C.Dialog,{open:e,onOpenChange:i,children:(0,f.jsxs)(C.DialogContent,{className:"sm:max-w-[520px]",children:[(0,f.jsxs)(C.DialogHeader,{children:[(0,f.jsx)(C.DialogTitle,{children:n("importTitle")}),(0,f.jsx)(C.DialogDescription,{children:n("importDescription")})]}),(0,f.jsxs)("div",{className:"flex flex-col gap-3 py-2 min-w-0",children:[(0,f.jsxs)("div",{children:[(0,f.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:n("selectProject")}),(0,f.jsx)(nk.FolderPicker,{value:o,onChange:g,allowFiles:!0,fileFilter:"package.json"})]}),h.length>0&&(0,f.jsxs)("div",{className:"w-full flex flex-col border border-border rounded-lg overflow-hidden",children:[(0,f.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-muted/50 border-b border-border",children:[(0,f.jsx)("button",{onClick:()=>{let e=h.every(e=>e.selected);l(i=>i.map(i=>({...i,selected:!e})))},className:`shrink-0 w-4 h-4 rounded border flex items-center justify-center transition-colors ${h.every(e=>e.selected)?"bg-primary border-primary text-primary-foreground":"border-border hover:border-primary"}`,children:h.every(e=>e.selected)&&(0,f.jsx)(nE.Check,{size:10})}),(0,f.jsxs)("span",{className:"text-xs font-medium",children:[n("parsedScripts")," (",h.length,")"]})]}),(0,f.jsx)("div",{className:"max-h-[280px] overflow-y-auto",children:h.map((e,i)=>(0,f.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-accent cursor-pointer border-b border-border last:border-b-0 min-w-0",onClick:()=>{l(e=>e.map((e,s)=>s===i?{...e,selected:!e.selected}:e))},children:[(0,f.jsx)("button",{className:`shrink-0 w-4 h-4 rounded border flex items-center justify-center transition-colors ${e.selected?"bg-primary border-primary text-primary-foreground":"border-border hover:border-primary"}`,children:e.selected&&(0,f.jsx)(nE.Check,{size:10})}),(0,f.jsx)("span",{className:"text-xs font-medium w-24 truncate shrink-0",children:e.name}),(0,f.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate flex-1 min-w-0",children:e.command})]},e.name))})]}),!c&&o&&0===h.length&&(0,f.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:n("noScripts")}),c&&(0,f.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,f.jsx)(nD.Loader2,{className:"size-4 animate-spin text-muted-foreground"})})]}),(0,f.jsxs)(C.DialogFooter,{children:[(0,f.jsx)(nS.Button,{variant:"outline",onClick:()=>i(!1),children:n("cancel")}),(0,f.jsx)(nS.Button,{onClick:m,disabled:0===h.filter(e=>e.selected).length||u,children:n("addSelected")})]})]})})}var nM=e.i(992764),nR=e.i(887354),nL=e.i(129981),nP=e.i(889445),nT=e.i(962562),nA=e.i(137340),nO=e.i(256186);function nN({command:e,running:i,onRun:s,onClose:r,onEdit:n,onDelete:o,onSelect:a}){let[h,l]=(0,p.useState)(!1);return(0,f.jsxs)("div",{onClick:i?a:void 0,className:`flex items-center gap-1 px-2 py-1 text-xs hover:bg-accent group ${i?"cursor-pointer":"cursor-default"}`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[(0,f.jsx)("button",{onClick:e=>{e.stopPropagation(),i?r():s()},className:`shrink-0 p-0.5 rounded ${i?"text-green-500 hover:text-destructive":"text-muted-foreground hover:text-foreground"}`,children:i?(0,f.jsx)(v.X,{size:12}):(0,f.jsx)(nP.Play,{size:12})}),(0,f.jsx)("span",{className:"truncate flex-1 font-mono",children:e.name}),i&&(0,f.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}),h&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("button",{onClick:e=>{e.stopPropagation(),n()},className:"shrink-0 p-0.5 text-muted-foreground hover:text-foreground cursor-pointer",children:(0,f.jsx)(nT.Pencil,{size:11})}),(0,f.jsx)("button",{onClick:e=>{e.stopPropagation(),o()},className:"shrink-0 p-0.5 text-muted-foreground hover:text-destructive cursor-pointer",children:(0,f.jsx)(nA.Trash2,{size:11})})]})]})}function nI({search:e,onSearchChange:i,commands:s,customCommands:r,folderGroups:n,customOpen:o,onCustomOpenChange:a,collapsedFolders:h,onToggleFolder:l,onImport:c,onAddCommand:d,workspaceId:u,isRunning:_,runningMap:p,removeSession:S,run:b,remove:w,setEditingCommand:y,setDialogOpen:C,onSelectSession:x,tc:k}){return(0,f.jsxs)("div",{className:"flex flex-col h-full max-h-[50vh]",children:[(0,f.jsxs)("div",{className:"flex items-center gap-1 px-1.5 py-1.5 border-b border-border",children:[(0,f.jsxs)("div",{className:"flex items-center gap-1 flex-1 bg-muted rounded px-1.5 py-0.5",children:[(0,f.jsx)(nR.Search,{size:12,className:"text-muted-foreground shrink-0"}),(0,f.jsx)(nb.Input,{value:e,onChange:e=>i(e.target.value),placeholder:k("searchPlaceholder"),className:"h-5 bg-transparent text-xs border-0 focus-visible:ring-0 focus-visible:border-0 px-1 min-w-0"}),e&&(0,f.jsx)("button",{onClick:()=>i(""),className:"text-muted-foreground hover:text-foreground cursor-pointer",children:(0,f.jsx)(v.X,{size:10})})]}),(0,f.jsx)("button",{onClick:c,className:"shrink-0 p-1 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:k("import"),children:(0,f.jsx)(nL.Upload,{size:13})})]}),(0,f.jsx)("div",{className:"flex-1 overflow-y-auto py-1",children:0===s.length?(0,f.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:k("noCommands")}):(0,f.jsxs)(f.Fragment,{children:[r.length>0&&(0,f.jsxs)(nO.Collapsible,{open:o,onOpenChange:a,children:[(0,f.jsxs)("div",{className:"flex items-center gap-1 px-2 py-0.5 group",children:[(0,f.jsxs)(nO.CollapsibleTrigger,{className:"flex items-center gap-1 flex-1 text-[10px] font-semibold text-muted-foreground uppercase tracking-wider hover:text-foreground",children:[o?(0,f.jsx)(m.ChevronDown,{size:10,className:"shrink-0"}):(0,f.jsx)(nM.ChevronRight,{size:10,className:"shrink-0"}),(0,f.jsx)("span",{children:k("customCommands")}),(0,f.jsxs)("span",{className:"text-muted-foreground/60",children:["(",r.length,")"]})]}),(0,f.jsx)("button",{onClick:d,className:"shrink-0 p-0.5 text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",title:k("addCommand"),children:(0,f.jsx)(g.Plus,{size:12})})]}),(0,f.jsx)(nO.CollapsibleContent,{children:r.map(e=>(0,f.jsx)(nN,{command:e,running:_(e.id),onRun:()=>b(u,e.id),onClose:()=>{let i=p[e.id];i&&S(i.sessionId)},onSelect:()=>{let i=p[e.id];i&&x(i.sessionId)},onEdit:()=>{y(e),C(!0)},onDelete:()=>w(u,e.id)},e.id))})]}),Object.entries(n).map(([e,i])=>{let s=!0!==h[e];return(0,f.jsxs)(nO.Collapsible,{open:s,onOpenChange:()=>l(e),children:[(0,f.jsx)("div",{className:"flex items-center gap-1 px-2 py-0.5 mt-1 group",children:(0,f.jsxs)(nO.CollapsibleTrigger,{className:"flex items-center gap-1 flex-1 text-[10px] font-semibold text-muted-foreground uppercase tracking-wider hover:text-foreground",children:[s?(0,f.jsx)(m.ChevronDown,{size:10,className:"shrink-0"}):(0,f.jsx)(nM.ChevronRight,{size:10,className:"shrink-0"}),(0,f.jsx)("span",{className:"truncate",children:e.split("/").pop()||e}),(0,f.jsxs)("span",{className:"text-muted-foreground/60",children:["(",i.length,")"]})]})}),(0,f.jsx)(nO.CollapsibleContent,{children:i.map(e=>(0,f.jsx)(nN,{command:e,running:_(e.id),onRun:()=>b(u,e.id),onClose:()=>{let i=p[e.id];i&&S(i.sessionId)},onSelect:()=>{let i=p[e.id];i&&x(i.sessionId)},onEdit:()=>{y(e),C(!0)},onDelete:()=>w(u,e.id)},e.id))})]},e)}),0===r.length&&(0,f.jsxs)("div",{className:"flex items-center gap-1 px-2 py-0.5 group",children:[(0,f.jsx)("span",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wider flex-1",children:k("customCommands")}),(0,f.jsx)("button",{onClick:d,className:"shrink-0 p-0.5 text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",title:k("addCommand"),children:(0,f.jsx)(g.Plus,{size:12})})]})]})})]})}var nW=e.i(106206),nH=e.i(346038),nz=e.i(433721);let nF=(0,nz.default)("power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]),nj=(0,nz.default)("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]),n$=(0,nz.default)("clipboard-paste",[["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"}]]);var nK=e.i(378371),nU=e.i(212965),nq=e.i(767467);let nV=(0,nz.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var nY=e.i(237597),nX=e.i(600304);function nG(e="light"){try{navigator.vibrate?.("heavy"===e?30:"medium"===e?15:5)}catch{}}let nJ={a:"\x01",b:"\x02",c:"\x03",d:"\x04",e:"\x05",f:"\x06",g:"\x07",h:"\b",i:" ",j:"\n",k:"\v",l:"\f",m:"\r",n:"\x0e",o:"\x0f",p:"\x10",q:"\x11",r:"\x12",s:"\x13",t:"\x14",u:"\x15",v:"\x16",w:"\x17",x:"\x18",y:"\x19",z:"\x1a","[":"\x1b","]":"\x1d","\\":"\x1c"},nZ=[["`","1","2","3","4","5","6","7","8","9","0","-","="],["q","w","e","r","t","y","u","i","o","p","[","]","\\"],["a","s","d","f","g","h","j","k","l",";","'","Enter"],["z","x","c","v","b","n","m",",",".","/","⌫"]];function nQ({onKey:e}){let[i,s]=(0,p.useState)(new Set),r=(0,p.useCallback)(e=>{nG("medium"),s(i=>{let s=new Set(i);return s.has(e)?s.delete(e):s.add(e),s})},[]),n=(0,p.useCallback)(r=>{let n,o=i.has("ctrl"),a=i.has("alt"),h=i.has("shift");n="Enter"===r?"\r":"⌫"===r?"":o&&nJ[r]?nJ[r]:h?r.toUpperCase():r,a&&(n="\x1b"+n),e(n),nG(),s(new Set)},[i,e]),o="flex-1 h-10 min-w-0 flex items-center justify-center rounded text-sm font-mono bg-muted hover:bg-accent active:scale-92 active:bg-primary/20 select-none cursor-pointer transition-all duration-100";return(0,f.jsxs)("div",{className:"flex flex-col gap-1 p-2 max-w-[800px] w-[calc(100vw-16px)]",children:[(0,f.jsxs)("div",{className:"flex gap-0.5 mb-0.5",children:[["ctrl","alt","shift"].map(e=>(0,f.jsx)("button",{onClick:()=>r(e),className:`flex-1 h-9 rounded text-xs font-semibold uppercase tracking-wide select-none cursor-pointer transition-all duration-100 active:scale-92 ${i.has(e)?"bg-primary text-primary-foreground":"bg-muted hover:bg-accent text-muted-foreground active:bg-primary/20"}`,children:e},e)),(0,f.jsx)("button",{onClick:()=>{nG(),e(" ")},className:o,children:"Tab"}),(0,f.jsx)("button",{onClick:()=>{nG(),e("\x1b")},className:o,children:"Esc"}),(0,f.jsx)("button",{onClick:()=>{nG(),e("\x1b[A")},className:o,children:"↑"}),(0,f.jsx)("button",{onClick:()=>{nG(),e("\x1b[B")},className:o,children:"↓"}),(0,f.jsx)("button",{onClick:()=>{nG(),e("\x1b[D")},className:o,children:"←"}),(0,f.jsx)("button",{onClick:()=>{nG(),e("\x1b[C")},className:o,children:"→"})]}),nZ.map((e,s)=>(0,f.jsx)("div",{className:"flex gap-0.5",children:e.map((e,r)=>{let a="Enter"===e,h="⌫"===e;return(0,f.jsx)("button",{onClick:()=>n(e),className:`${o} ${a?"flex-[1.5]":""} ${h?"flex-[1.2]":""} ${i.has("ctrl")&&nJ[e]?"text-primary font-bold":""}`,children:e},`${s}-${r}`)})},s)),(0,f.jsx)("div",{className:"flex gap-0.5",children:(0,f.jsx)("button",{onClick:()=>{nG(),n(" ")},className:`${o} flex-[5]`,children:"Space"})})]})}function n0({activeId:e,sendInput:i,onPaste:s}){let r=(0,nC.useTranslations)("terminal"),[n,o]=(0,p.useState)(!1),[a,h]=(0,p.useState)(""),l=(0,p.useRef)(null),c=s=>{e&&i(e,s)};return(0,f.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1 border-t border-border bg-muted/50 shrink-0",children:[n&&(0,f.jsxs)("div",{className:"relative",children:[(0,f.jsx)("textarea",{ref:l,value:a,onChange:e=>h(e.target.value),className:"min-h-16 max-h-28 w-full resize-y rounded-md border border-input bg-background px-2 py-1.5 pr-14 text-sm font-mono leading-5 outline-none focus:border-ring focus:ring-1 focus:ring-ring disabled:opacity-50",placeholder:r("mobileInputPlaceholder"),disabled:!e,rows:2}),(0,f.jsx)("button",{onClick:()=>{a&&e&&(i(e,/[\r\n]$/.test(a)?a:`${a}
19
- `),h(""))},disabled:!e||!a,className:"absolute bottom-2 right-2 flex h-7 w-7 items-center justify-center rounded-md bg-primary text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50 cursor-pointer",title:r("sendInput"),children:(0,f.jsx)(nX.Send,{size:14})})]}),(0,f.jsxs)("div",{className:"flex items-center gap-1 overflow-x-auto",children:[(0,f.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,f.jsx)("button",{onClick:()=>c("\x1b[A"),className:"p-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:"↑ cursor-pointer",children:(0,f.jsx)(nK.ArrowUp,{size:14})}),(0,f.jsx)("button",{onClick:()=>c("\x1b[B"),className:"p-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:"↓ cursor-pointer",children:(0,f.jsx)(nU.ArrowDown,{size:14})}),(0,f.jsx)("button",{onClick:()=>c("\x1b[D"),className:"p-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:"← cursor-pointer",children:(0,f.jsx)(nq.ArrowLeft,{size:14})}),(0,f.jsx)("button",{onClick:()=>c("\x1b[C"),className:"p-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:"→ cursor-pointer",children:(0,f.jsx)(nV,{size:14})})]}),(0,f.jsx)("div",{className:"w-px h-4 bg-border shrink-0"}),(0,f.jsxs)("button",{onClick:()=>{n?o(!1):((0,nW.flushSync)(()=>o(!0)),l.current?.focus({preventScroll:!0}))},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors data-[active=true]:bg-accent data-[active=true]:text-foreground cursor-pointer","data-active":n,title:r("editInput"),children:[(0,f.jsx)(nY.Edit3,{size:14}),(0,f.jsx)("span",{className:"hidden sm:inline",children:r("editInput")})]}),(0,f.jsxs)(x.Popover,{children:[(0,f.jsx)(x.PopoverTrigger,{render:(0,f.jsxs)("button",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer",title:r("virtualKeyboard"),children:[(0,f.jsx)(nH.Keyboard,{size:14}),(0,f.jsx)("span",{className:"hidden sm:inline",children:r("virtualKeyboard")})]})}),(0,f.jsx)(x.PopoverContent,{align:"start",side:"top",sideOffset:4,className:"p-0 max-w-[800px] w-[calc(100vw-16px)]",children:(0,f.jsx)(nQ,{onKey:e=>c(e)})})]}),(0,f.jsxs)("button",{onClick:()=>c("\x03"),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer",title:"Ctrl+C",children:[(0,f.jsx)(nF,{size:14}),(0,f.jsx)("span",{className:"hidden sm:inline",children:r("sendCtrlC")})]}),(0,f.jsxs)("button",{onClick:()=>c("clear\n"),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer",title:r("clearScreen"),children:[(0,f.jsx)(nj,{size:14}),(0,f.jsx)("span",{className:"hidden sm:inline",children:r("clearScreen")})]}),(0,f.jsxs)("button",{onClick:s,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer",title:r("pasteCommand"),children:[(0,f.jsx)(n$,{size:14}),(0,f.jsx)("span",{className:"hidden sm:inline",children:r("pasteCommand")})]})]})]})}let n1=[{value:"/bin/zsh",label:"zsh"},{value:"/bin/bash",label:"bash"}],n2=[{value:"cmd.exe",label:"CMD"},{value:"powershell.exe",label:"PowerShell"}],n5=null;async function n3(){if(n5)return n5;try{let e=await fetch("/api/health"),i=await e.json();n5="win32"===i.platform?n2:n1}catch{n5=n1}return n5}e.s(["TerminalPanel",0,function({workspaceId:e,boundDirs:i}){let{sessions:s,activeId:r,init:n,createSession:o,setActive:a,removeSession:h}=(0,k.useTerminalStore)(),{commands:l,load:c,run:d,remove:u,update:_,create:E,isRunning:D,runningMap:M}=R(),{sendInput:L}=(0,k.useTerminalStore)(),P=(0,nC.useTranslations)("terminal"),T=(0,nC.useTranslations)("commands"),[A,O]=(0,p.useState)(!1),[N,I]=(0,p.useState)(void 0),[W,H]=(0,p.useState)(!1),[z,F]=(0,p.useState)(),[j,$]=(0,p.useState)(!1),[K,U]=(0,p.useState)(""),[q,V]=(0,p.useState)(!0),[Y,X]=(0,p.useState)({}),[G,J]=(0,p.useState)(!1),[Z,Q]=(0,p.useState)(!1),[ee,et]=(0,p.useState)(""),[ei,es]=(0,p.useState)([]),er=(0,p.useCallback)(()=>{if(0!==i.length&&1===i.length)return i[0]},[i]),en=(0,p.useCallback)(e=>{let s=er();if(void 0===s&&i.length>1){I(e),O(!0);return}o(e,s)},[er,i.length,o]),eo=(0,p.useCallback)(e=>{O(!1),o(N,e),I(void 0)},[N,o]),ea=(0,p.useRef)(null);(0,p.useEffect)(()=>{n((0,B.getWS)(e),()=>{0===k.useTerminalStore.getState().sessions.length&&en()}),ea.current!==e&&(ea.current=e)},[e]),(0,p.useEffect)(()=>{e&&c(e)},[e]),(0,p.useEffect)(()=>{n3().then(es)},[]);let{customCommands:eh,folderGroups:el}=(0,p.useMemo)(()=>{let e=K?l.filter(e=>e.name.toLowerCase().includes(K.toLowerCase())||e.command.toLowerCase().includes(K.toLowerCase())):l,i=[],s={};for(let r of e)r.folder?(s[r.folder]||(s[r.folder]=[]),s[r.folder].push(r)):i.push(r);let r=(e,i)=>!!D(i.id)-!!D(e.id);return{customCommands:i.sort(r),folderGroups:Object.fromEntries(Object.entries(s).map(([e,i])=>[e,i.sort(r)]))}},[l,K,D]),ec=e=>{X(i=>({...i,[e]:!i[e]}))},ed=async i=>{for(let s of i)await E(e,{name:s.name,command:s.command,folder:s.folder,cwd:s.folder})},eu=async()=>{try{let e=await navigator.clipboard.readText();et(e)}catch{et("")}Q(!0)};return(0,f.jsxs)("div",{className:"flex flex-col h-full bg-background",children:[(0,f.jsxs)("div",{className:"flex items-center gap-0.5 px-1 py-0.5 bg-muted border-b border-border overflow-x-auto",children:[s.map(e=>{var i;let n;return(0,f.jsxs)(y.ContextMenu,{children:[(0,f.jsx)(y.ContextMenuTrigger,{children:(0,f.jsxs)("button",{onClick:()=>a(e.id),className:`flex items-center gap-1 px-2 py-1 text-xs rounded-t transition-colors shrink-0 ${r===e.id?"bg-background text-foreground":"text-muted-foreground hover:text-foreground hover:bg-background/50"}`,children:[(0,f.jsx)("span",{className:"font-mono text-[10px] opacity-60",children:e.name??(i=e.shell,n=ei?.length?ei:n1,i?n.find(e=>e.value===i)?.label??i:n[0].label)}),!e.name&&(0,f.jsx)("span",{children:s.indexOf(e)+1}),(0,f.jsx)("span",{onClick:i=>{i.stopPropagation(),h(e.id)},className:"ml-1 hover:text-destructive cursor-pointer",children:(0,f.jsx)(v.X,{size:12})})]})}),(0,f.jsx)(y.ContextMenuContent,{children:(0,f.jsx)(y.ContextMenuItem,{onClick:()=>{navigator.clipboard?.writeText(e.id)},className:"text-xs",children:"复制终端id"})})]},e.id)}),(0,f.jsxs)(w.DropdownMenu,{children:[(0,f.jsx)(w.DropdownMenuTrigger,{render:(0,f.jsxs)("button",{className:"flex items-center gap-0.5 h-6 px-1.5 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:P("newTerminal"),children:[(0,f.jsx)(g.Plus,{size:14}),(0,f.jsx)(m.ChevronDown,{size:10})]})}),(0,f.jsx)(w.DropdownMenuContent,{align:"start",className:"min-w-[120px]",children:ei.map(e=>(0,f.jsx)(w.DropdownMenuItem,{onClick:()=>en(e.value),className:"text-xs",children:e.label},e.value))})]}),(0,f.jsx)("div",{className:"md:hidden ml-auto",children:(0,f.jsxs)(x.Popover,{open:G,onOpenChange:J,children:[(0,f.jsx)(x.PopoverTrigger,{render:(0,f.jsx)("button",{className:"flex items-center gap-1 h-6 px-1.5 text-muted-foreground hover:text-foreground cursor-pointer transition-colors",title:T("title"),children:(0,f.jsx)(b.Terminal,{size:14})})}),(0,f.jsx)(x.PopoverContent,{align:"end",sideOffset:4,className:"w-[260px] p-0 overflow-hidden",children:(0,f.jsx)(nI,{search:K,onSearchChange:U,commands:l,customCommands:eh,folderGroups:el,customOpen:q,onCustomOpenChange:V,collapsedFolders:Y,onToggleFolder:ec,onImport:()=>{$(!0),J(!1)},onAddCommand:()=>{F(void 0),H(!0),J(!1)},workspaceId:e,isRunning:D,runningMap:M,removeSession:h,run:d,remove:u,setEditingCommand:F,setDialogOpen:e=>{if(H(e),!e)return},onSelectSession:e=>{a(e),J(!1)},tc:T})})]})})]}),(0,f.jsxs)("div",{className:"flex flex-row flex-1 overflow-hidden",children:[(0,f.jsx)("div",{className:"hidden md:flex w-[200px] flex-col border-r border-border shrink-0 overflow-hidden",children:(0,f.jsx)(nI,{search:K,onSearchChange:U,commands:l,customCommands:eh,folderGroups:el,customOpen:q,onCustomOpenChange:V,collapsedFolders:Y,onToggleFolder:ec,onImport:()=>$(!0),onAddCommand:()=>{F(void 0),H(!0)},workspaceId:e,isRunning:D,runningMap:M,removeSession:h,run:d,remove:u,setEditingCommand:F,setDialogOpen:H,onSelectSession:a,tc:T})}),(0,f.jsx)("div",{className:"flex-1 overflow-hidden relative",children:0===s.length?(0,f.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:P("noSession")}):s.map(i=>(0,f.jsx)("div",{className:"absolute inset-0",style:{display:r===i.id?"block":"none"},children:(0,f.jsx)(nv,{sessionId:i.id,workspaceId:e})},i.id))})]}),(0,f.jsx)(n0,{activeId:r,sendInput:L,onPaste:eu}),(0,f.jsx)(C.Dialog,{open:A,onOpenChange:O,children:(0,f.jsxs)(C.DialogContent,{children:[(0,f.jsxs)(C.DialogHeader,{children:[(0,f.jsx)(C.DialogTitle,{children:P("selectWorkingDirectory")}),(0,f.jsx)(C.DialogDescription,{children:P("selectWorkingDirectoryDescription")})]}),(0,f.jsx)("div",{className:"flex flex-col gap-2 py-2",children:i.map(e=>(0,f.jsxs)("button",{onClick:()=>eo(e),className:"flex items-center gap-2 px-3 py-2 text-sm text-left rounded-md border border-border hover:bg-accent hover:text-accent-foreground transition-colors cursor-pointer",children:[(0,f.jsx)(S.FolderOpen,{size:14,className:"shrink-0 text-muted-foreground"}),(0,f.jsx)("span",{className:"truncate font-mono text-xs",children:e})]},e))})]})}),(0,f.jsx)(nx,{open:W,onOpenChange:H,command:z,defaultCwd:i[0],onSubmit:async i=>{z?await _(e,z.id,i):await E(e,i)}}),(0,f.jsx)(nB,{open:j,onOpenChange:$,defaultPath:i[0],onImport:ed}),(0,f.jsx)(C.Dialog,{open:Z,onOpenChange:Q,children:(0,f.jsxs)(C.DialogContent,{children:[(0,f.jsxs)(C.DialogHeader,{children:[(0,f.jsx)(C.DialogTitle,{children:P("pasteCommand")}),(0,f.jsx)(C.DialogDescription,{children:P("pasteCommandDescription")})]}),(0,f.jsx)("textarea",{value:ee,onChange:e=>et(e.target.value),className:"w-full h-40 rounded-md border border-border bg-background px-3 py-2 text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-ring",placeholder:P("pasteCommandPlaceholder")}),(0,f.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,f.jsx)("button",{onClick:()=>Q(!1),className:"px-3 py-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer",children:P("cancel")}),(0,f.jsx)("button",{disabled:!ee.trim()||!r,onClick:()=>{if(!r)return;let e=ee.split("\n"),i=0;for(let s of e){let e=s.trim();e&&(setTimeout(()=>L(r,e+"\n"),i),i+=300)}Q(!1)},className:"px-3 py-1.5 rounded-md text-xs bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50",children:P("confirm")})]})]})})]})}],225335)},608745,e=>{e.n(e.i(225335))}]);
19
+ `),h(""))},disabled:!e||!a,className:"absolute bottom-2 right-2 flex h-7 w-7 items-center justify-center rounded-md bg-primary text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50 cursor-pointer",title:r("sendInput"),children:(0,f.jsx)(nX.Send,{size:14})})]}),(0,f.jsxs)("div",{className:"flex items-center gap-1 overflow-x-auto",children:[(0,f.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,f.jsx)("button",{onClick:()=>c("\x1b[A"),className:"p-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:"↑ cursor-pointer",children:(0,f.jsx)(nK.ArrowUp,{size:14})}),(0,f.jsx)("button",{onClick:()=>c("\x1b[B"),className:"p-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:"↓ cursor-pointer",children:(0,f.jsx)(nU.ArrowDown,{size:14})}),(0,f.jsx)("button",{onClick:()=>c("\x1b[D"),className:"p-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:"← cursor-pointer",children:(0,f.jsx)(nq.ArrowLeft,{size:14})}),(0,f.jsx)("button",{onClick:()=>c("\x1b[C"),className:"p-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:"→ cursor-pointer",children:(0,f.jsx)(nV,{size:14})})]}),(0,f.jsx)("div",{className:"w-px h-4 bg-border shrink-0"}),(0,f.jsxs)("button",{onClick:()=>{n?o(!1):((0,nW.flushSync)(()=>o(!0)),l.current?.focus({preventScroll:!0}))},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors data-[active=true]:bg-accent data-[active=true]:text-foreground cursor-pointer","data-active":n,title:r("editInput"),children:[(0,f.jsx)(nY.Edit3,{size:14}),(0,f.jsx)("span",{className:"hidden sm:inline",children:r("editInput")})]}),(0,f.jsxs)(x.Popover,{children:[(0,f.jsx)(x.PopoverTrigger,{render:(0,f.jsxs)("button",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer",title:r("virtualKeyboard"),children:[(0,f.jsx)(nH.Keyboard,{size:14}),(0,f.jsx)("span",{className:"hidden sm:inline",children:r("virtualKeyboard")})]})}),(0,f.jsx)(x.PopoverContent,{align:"start",side:"top",sideOffset:4,className:"p-0 max-w-[800px] w-[calc(100vw-16px)]",children:(0,f.jsx)(nQ,{onKey:e=>c(e)})})]}),(0,f.jsxs)("button",{onClick:()=>c("\x03"),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer",title:"Ctrl+C",children:[(0,f.jsx)(nF,{size:14}),(0,f.jsx)("span",{className:"hidden sm:inline",children:r("sendCtrlC")})]}),(0,f.jsxs)("button",{onClick:()=>c("clear\n"),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer",title:r("clearScreen"),children:[(0,f.jsx)(nj,{size:14}),(0,f.jsx)("span",{className:"hidden sm:inline",children:r("clearScreen")})]}),(0,f.jsxs)("button",{onClick:s,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer",title:r("pasteCommand"),children:[(0,f.jsx)(n$,{size:14}),(0,f.jsx)("span",{className:"hidden sm:inline",children:r("pasteCommand")})]})]})]})}let n1=[{value:"/bin/zsh",label:"zsh"},{value:"/bin/bash",label:"bash"}],n2=[{value:"cmd.exe",label:"CMD"},{value:"powershell.exe",label:"PowerShell"}],n5=null;async function n3(){if(n5)return n5;try{let e=await fetch("/api/health"),i=await e.json();n5="win32"===i.platform?n2:n1}catch{n5=n1}return n5}var n6=e.i(441781);let n4="agent-spaces:terminal-layout",n8="sidebar",n7="terminal";e.s(["TerminalPanel",0,function({workspaceId:e,boundDirs:i}){let{sessions:s,activeId:r,init:n,createSession:o,setActive:a,removeSession:h}=(0,k.useTerminalStore)(),{commands:l,load:c,run:d,remove:u,update:_,create:E,isRunning:D,runningMap:M}=R(),{sendInput:L}=(0,k.useTerminalStore)(),P=(0,nC.useTranslations)("terminal"),T=(0,nC.useTranslations)("commands"),A=(0,p.useMemo)(()=>(function(){try{let e=localStorage.getItem(n4);if(!e)return;let i=JSON.parse(e),s=i[n8],r=i[n7];return"number"==typeof s&&"number"==typeof r&&s>=12&&s<=40&&r>=30?{[n8]:s,[n7]:r}:void 0}catch{return}})(),[]),O=(0,p.useCallback)(e=>{let i,s;if(i=e[n8],s=e[n7],"number"==typeof i&&"number"==typeof s&&i>=12&&i<=40&&s>=30)try{localStorage.setItem(n4,JSON.stringify(e))}catch{}},[]),[N,I]=(0,p.useState)(!1),[W,H]=(0,p.useState)(void 0),[z,F]=(0,p.useState)(!1),[j,$]=(0,p.useState)(),[K,U]=(0,p.useState)(!1),[q,V]=(0,p.useState)(""),[Y,X]=(0,p.useState)(!0),[G,J]=(0,p.useState)({}),[Z,Q]=(0,p.useState)(!1),[ee,et]=(0,p.useState)(!1),[ei,es]=(0,p.useState)(""),[er,en]=(0,p.useState)([]),eo=(0,p.useCallback)(()=>{if(0!==i.length&&1===i.length)return i[0]},[i]),ea=(0,p.useCallback)(e=>{let s=eo();if(void 0===s&&i.length>1){H(e),I(!0);return}o(e,s)},[eo,i.length,o]),eh=(0,p.useCallback)(e=>{I(!1),o(W,e),H(void 0)},[W,o]),el=(0,p.useRef)(null);(0,p.useEffect)(()=>{n((0,B.getWS)(e),()=>{0===k.useTerminalStore.getState().sessions.length&&ea()}),el.current!==e&&(el.current=e)},[e]),(0,p.useEffect)(()=>{e&&c(e)},[e]),(0,p.useEffect)(()=>{n3().then(en)},[]);let{customCommands:ec,folderGroups:ed}=(0,p.useMemo)(()=>{let e=q?l.filter(e=>e.name.toLowerCase().includes(q.toLowerCase())||e.command.toLowerCase().includes(q.toLowerCase())):l,i=[],s={};for(let r of e)r.folder?(s[r.folder]||(s[r.folder]=[]),s[r.folder].push(r)):i.push(r);let r=(e,i)=>!!D(i.id)-!!D(e.id);return{customCommands:i.sort(r),folderGroups:Object.fromEntries(Object.entries(s).map(([e,i])=>[e,i.sort(r)]))}},[l,q,D]),eu=e=>{J(i=>({...i,[e]:!i[e]}))},e_=async i=>{for(let s of i)await E(e,{name:s.name,command:s.command,folder:s.folder,cwd:s.folder})},ef=async()=>{try{let e=await navigator.clipboard.readText();es(e)}catch{es("")}et(!0)};return(0,f.jsxs)("div",{className:"flex flex-col h-full bg-background",children:[(0,f.jsxs)("div",{className:"flex items-center gap-0.5 px-1 py-0.5 bg-muted border-b border-border overflow-x-auto",children:[s.map(e=>{var i;let n;return(0,f.jsxs)(y.ContextMenu,{children:[(0,f.jsx)(y.ContextMenuTrigger,{children:(0,f.jsxs)("button",{onClick:()=>a(e.id),className:`flex items-center gap-1 px-2 py-1 text-xs rounded-t transition-colors shrink-0 ${r===e.id?"bg-background text-foreground":"text-muted-foreground hover:text-foreground hover:bg-background/50"}`,children:[(0,f.jsx)("span",{className:"font-mono text-[10px] opacity-60",children:e.name??(i=e.shell,n=er?.length?er:n1,i?n.find(e=>e.value===i)?.label??i:n[0].label)}),!e.name&&(0,f.jsx)("span",{children:s.indexOf(e)+1}),(0,f.jsx)("span",{onClick:i=>{i.stopPropagation(),h(e.id)},className:"ml-1 hover:text-destructive cursor-pointer",children:(0,f.jsx)(v.X,{size:12})})]})}),(0,f.jsx)(y.ContextMenuContent,{children:(0,f.jsx)(y.ContextMenuItem,{onClick:()=>{navigator.clipboard?.writeText(e.id)},className:"text-xs",children:"复制终端id"})})]},e.id)}),(0,f.jsxs)(w.DropdownMenu,{children:[(0,f.jsx)(w.DropdownMenuTrigger,{render:(0,f.jsxs)("button",{className:"flex items-center gap-0.5 h-6 px-1.5 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:P("newTerminal"),children:[(0,f.jsx)(g.Plus,{size:14}),(0,f.jsx)(m.ChevronDown,{size:10})]})}),(0,f.jsx)(w.DropdownMenuContent,{align:"start",className:"min-w-[120px]",children:er.map(e=>(0,f.jsx)(w.DropdownMenuItem,{onClick:()=>ea(e.value),className:"text-xs",children:e.label},e.value))})]}),(0,f.jsx)("div",{className:"md:hidden ml-auto",children:(0,f.jsxs)(x.Popover,{open:Z,onOpenChange:Q,children:[(0,f.jsx)(x.PopoverTrigger,{render:(0,f.jsx)("button",{className:"flex items-center gap-1 h-6 px-1.5 text-muted-foreground hover:text-foreground cursor-pointer transition-colors",title:T("title"),children:(0,f.jsx)(b.Terminal,{size:14})})}),(0,f.jsx)(x.PopoverContent,{align:"end",sideOffset:4,className:"w-[260px] p-0 overflow-hidden",children:(0,f.jsx)(nI,{search:q,onSearchChange:V,commands:l,customCommands:ec,folderGroups:ed,customOpen:Y,onCustomOpenChange:X,collapsedFolders:G,onToggleFolder:eu,onImport:()=>{U(!0),Q(!1)},onAddCommand:()=>{$(void 0),F(!0),Q(!1)},workspaceId:e,isRunning:D,runningMap:M,removeSession:h,run:d,remove:u,setEditingCommand:$,setDialogOpen:e=>{if(F(e),!e)return},onSelectSession:e=>{a(e),Q(!1)},tc:T})})]})})]}),(0,f.jsxs)(n6.ResizablePanelGroup,{orientation:"horizontal",defaultLayout:A,onLayoutChange:O,className:"flex-1 overflow-hidden",children:[(0,f.jsx)(n6.ResizablePanel,{id:n8,defaultSize:"18%",minSize:"12%",maxSize:"40%",className:"hidden md:flex flex-col overflow-hidden",children:(0,f.jsx)(nI,{search:q,onSearchChange:V,commands:l,customCommands:ec,folderGroups:ed,customOpen:Y,onCustomOpenChange:X,collapsedFolders:G,onToggleFolder:eu,onImport:()=>U(!0),onAddCommand:()=>{$(void 0),F(!0)},workspaceId:e,isRunning:D,runningMap:M,removeSession:h,run:d,remove:u,setEditingCommand:$,setDialogOpen:F,onSelectSession:a,tc:T})}),(0,f.jsx)(n6.ResizableHandle,{withHandle:!0}),(0,f.jsx)(n6.ResizablePanel,{id:n7,defaultSize:"82%",minSize:"30%",className:"overflow-hidden relative",children:0===s.length?(0,f.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:P("noSession")}):s.map(i=>(0,f.jsx)("div",{className:"absolute inset-0",style:{display:r===i.id?"block":"none"},children:(0,f.jsx)(nv,{sessionId:i.id,workspaceId:e})},i.id))})]}),(0,f.jsx)(n0,{activeId:r,sendInput:L,onPaste:ef}),(0,f.jsx)(C.Dialog,{open:N,onOpenChange:I,children:(0,f.jsxs)(C.DialogContent,{children:[(0,f.jsxs)(C.DialogHeader,{children:[(0,f.jsx)(C.DialogTitle,{children:P("selectWorkingDirectory")}),(0,f.jsx)(C.DialogDescription,{children:P("selectWorkingDirectoryDescription")})]}),(0,f.jsx)("div",{className:"flex flex-col gap-2 py-2",children:i.map(e=>(0,f.jsxs)("button",{onClick:()=>eh(e),className:"flex items-center gap-2 px-3 py-2 text-sm text-left rounded-md border border-border hover:bg-accent hover:text-accent-foreground transition-colors cursor-pointer",children:[(0,f.jsx)(S.FolderOpen,{size:14,className:"shrink-0 text-muted-foreground"}),(0,f.jsx)("span",{className:"truncate font-mono text-xs",children:e})]},e))})]})}),(0,f.jsx)(nx,{open:z,onOpenChange:F,command:j,defaultCwd:i[0],onSubmit:async i=>{j?await _(e,j.id,i):await E(e,i)}}),(0,f.jsx)(nB,{open:K,onOpenChange:U,defaultPath:i[0],onImport:e_}),(0,f.jsx)(C.Dialog,{open:ee,onOpenChange:et,children:(0,f.jsxs)(C.DialogContent,{children:[(0,f.jsxs)(C.DialogHeader,{children:[(0,f.jsx)(C.DialogTitle,{children:P("pasteCommand")}),(0,f.jsx)(C.DialogDescription,{children:P("pasteCommandDescription")})]}),(0,f.jsx)("textarea",{value:ei,onChange:e=>es(e.target.value),className:"w-full h-40 rounded-md border border-border bg-background px-3 py-2 text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-ring",placeholder:P("pasteCommandPlaceholder")}),(0,f.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,f.jsx)("button",{onClick:()=>et(!1),className:"px-3 py-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer",children:P("cancel")}),(0,f.jsx)("button",{disabled:!ei.trim()||!r,onClick:()=>{if(!r)return;let e=ei.split("\n"),i=0;for(let s of e){let e=s.trim();e&&(setTimeout(()=>L(r,e+"\n"),i),i+=300)}et(!1)},className:"px-3 py-1.5 rounded-md text-xs bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50",children:P("confirm")})]})]})})]})}],225335)},608745,e=>{e.n(e.i(225335))}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,600304,759309,e=>{"use strict";let t=(0,e.i(433721).default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);e.s(["default",0,t],759309),e.s(["Send",0,t],600304)},595390,e=>{"use strict";var t=e.i(344180),s=e.i(764556),l=e.i(681622),r=e.i(611176),a=e.i(972846);let i=e=>!["scheduler","task_creator","bot"].includes(e.description||"")&&"agent-generator"!==e.id;e.s(["MemberPicker",0,function({candidates:e,selected:n,onToggle:o,searchPlaceholder:d,emptyText:c,label:u,filter:f}){let[m,p]=(0,s.useState)(""),h=e.filter(f??i).sort((e,t)=>(e.sortIndex??0)-(t.sortIndex??0)).filter(e=>`${e.label} ${e.description||""}`.toLowerCase().includes(m.toLowerCase()));return(0,t.jsxs)("div",{className:"space-y-2",children:[u&&(0,t.jsx)("label",{className:"text-sm font-medium",children:u}),(0,t.jsx)(l.Input,{value:m,onChange:e=>p(e.target.value),placeholder:d}),(0,t.jsxs)("div",{className:"max-h-40 overflow-y-auto space-y-0.5",children:[0===h.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-2 text-center",children:c||"No items found"}),h.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>o(e.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[(0,t.jsx)(r.AgentIcon,{agentId:"user"!==e.id?e.id:void 0,name:e.label,className:"size-5 rounded-full"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate",children:e.label}),e.description&&(0,t.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,t.jsx)("div",{className:`flex items-center justify-center size-4 rounded border shrink-0 ${n.includes(e.id)?"bg-primary border-primary text-primary-foreground":"border-input"}`})]},e.id))]}),n.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:n.map(s=>{let l=e.find(e=>e.id===s),i=l?.label||s;return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs max-w-[160px] min-w-0",children:["user"===s?(0,t.jsx)("span",{className:"truncate",children:i}):(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 min-w-0",children:[(0,t.jsx)(r.AgentIcon,{agentId:s,name:i,className:"size-3.5 rounded-full shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:i})]}),(0,t.jsx)("button",{type:"button",onClick:()=>o(s),className:"hover:text-destructive shrink-0 cursor-pointer",children:(0,t.jsx)(a.X,{className:"size-3"})})]},s)})})]})}])},272736,e=>{"use strict";function t(e){return e.name?.trim()||e.role}e.s(["getAgentDisplayName",0,t,"getMemberDisplayName",0,function(e,s){if("user"===s)return"user";let l=e.find(e=>e.id===s);return l?t(l):s},"normalizeChannelMembersToAgentIds",0,function(e,t){let s=new Set(e.map(e=>e.id)),l=[],r=new Set;for(let e of t)s.has(e)&&(r.has(e)||(r.add(e),l.push(e)));return l}])},889445,e=>{"use strict";let t=(0,e.i(433721).default)("play",[["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"}]]);e.s(["Play",0,t],889445)},444204,e=>{"use strict";let t=(0,e.i(433721).default)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]);e.s(["Clock",0,t],444204)},583705,e=>{"use strict";let t=(0,e.i(433721).default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);e.s(["Info",0,t],583705)},302773,e=>{"use strict";let t=(0,e.i(816709).create)((e,t)=>({workflows:[],currentWorkflow:null,isLoading:!1,loadWorkflows:async()=>{e({isLoading:!0});try{let t=await fetch("/api/workflows"),s=await t.json();e({workflows:s,isLoading:!1})}catch{e({isLoading:!1})}},createWorkflow:async t=>{let s=await fetch("/api/workflows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await s.json();return e(e=>({workflows:[...e.workflows,l]})),l},updateWorkflow:async(e,s)=>{let l=await fetch(`/api/workflows/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),r=await l.json();t().upsertWorkflow(r)},deleteWorkflow:async e=>{await fetch(`/api/workflows/${e}`,{method:"DELETE"}),t().removeWorkflow(e)},duplicateWorkflow:async t=>{let s=await fetch(`/api/workflows/${t}/duplicate`,{method:"POST"}),l=await s.json();e(e=>({workflows:[...e.workflows,l]}))},setCurrentWorkflow:t=>e({currentWorkflow:t}),upsertWorkflow:t=>{e(e=>{let s=e.workflows.findIndex(e=>e.id===t.id);if(-1!==s){let l=[...e.workflows];return l[s]=t,{workflows:l}}return{workflows:[...e.workflows,t]}})},removeWorkflow:t=>{e(e=>({workflows:e.workflows.filter(e=>e.id!==t),currentWorkflow:e.currentWorkflow?.id===t?null:e.currentWorkflow}))}}));e.s(["useWorkflowStore",0,t])},358989,e=>{"use strict";var t=e.i(344180),s=e.i(764556),l=e.i(244073),r=e.i(209988),a=e.i(260218),i=e.i(681622),n=e.i(788010),o=e.i(595390),d=e.i(272736),c=e.i(302773);let u=["draft","planned","in_progress","review_pending","changes_requested","approved","completed","archived"];e.s(["EditIssueDialog",0,function({issue:e,open:f,onOpenChange:m,agents:p=[],onSave:h}){let[x,w]=(0,s.useState)(e.title),[g,k]=(0,s.useState)(e.description),[y,b]=(0,s.useState)(e.status),[j,v]=(0,s.useState)(e.members||[]),[N,C]=(0,s.useState)(!1),[_,S]=(0,s.useState)(e.workflowId??""),{workflows:T,loadWorkflows:W}=(0,c.useWorkflowStore)(),I=(0,l.useTranslations)("issue"),D=(0,l.useTranslations)("common");(0,s.useEffect)(()=>{f&&(w(e.title),k(e.description),b(e.status),v(e.members?.length?[...e.members]:[]),S(e.workflowId??""))},[f,e]),(0,s.useEffect)(()=>{f&&W()},[f,W]);let M=async()=>{if(x.trim()){C(!0);try{await h({title:x.trim(),description:g.trim(),status:y,members:j,workflowId:"__none__"===_?null:_||null}),m(!1)}finally{C(!1)}}},P=(0,s.useMemo)(()=>p.filter(e=>!1!==e.enabled).map((e,t)=>({id:e.id,label:(0,d.getMemberDisplayName)(p,e.id),description:e.role,sortIndex:t})),[p]);return(0,t.jsx)(r.Dialog,{open:f,onOpenChange:m,children:(0,t.jsxs)(r.DialogContent,{className:"sm:max-w-md max-h-[85vh] p-0 gap-0 flex flex-col overflow-hidden",children:[(0,t.jsxs)(r.DialogHeader,{className:"px-4 py-4 shrink-0",children:[(0,t.jsx)(r.DialogTitle,{children:I("edit.title")}),(0,t.jsx)(r.DialogDescription,{children:I("edit.description")})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 pb-4",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(i.Input,{placeholder:I("edit.titlePlaceholder"),value:x,onChange:e=>w(e.target.value),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()}),(0,t.jsx)(n.Textarea,{placeholder:I("edit.descriptionPlaceholder"),value:g,onChange:e=>k(e.target.value),rows:3}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:I("edit.statusLabel")}),(0,t.jsx)("select",{value:y,onChange:e=>b(e.target.value),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:u.map(e=>(0,t.jsx)("option",{value:e,children:I(`status.${e}`)},e))})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Workflow Template"}),(0,t.jsxs)("select",{value:_||"__none__",onChange:e=>(e=>{if(S(e),!e)return;let t=T.find(t=>t.id===e);if(!t)return;let s=t.nodes.map(e=>e.data.agentConfigId);v(e=>Array.from(new Set([...e,...s])))})("__none__"===e.target.value?"":e.target.value),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[(0,t.jsx)("option",{value:"__none__",children:"None (use default pipeline)"}),T.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name," (",e.nodes.length," agents)"]},e.id))]})]}),(0,t.jsx)(o.MemberPicker,{candidates:P,selected:j,onToggle:e=>{v(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},label:I("edit.membersLabel"),searchPlaceholder:I("edit.searchAgent"),emptyText:I("edit.noAgents")}),(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,t.jsx)(a.Button,{variant:"outline",onClick:()=>m(!1),children:D("cancel")}),(0,t.jsx)(a.Button,{onClick:M,disabled:!x.trim()||N,children:D(N?"saving":"save")})]})]})})]})})}])}]);