@surething/cockpit 1.0.266 → 1.0.268

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 (691) hide show
  1. package/.next-prod/BUILD_ID +1 -1
  2. package/.next-prod/app-path-routes-manifest.json +4 -3
  3. package/.next-prod/build-manifest.json +2 -2
  4. package/.next-prod/cockpit-build.json +1 -1
  5. package/.next-prod/prerender-manifest.json +4 -4
  6. package/.next-prod/routes-manifest.json +6 -0
  7. package/.next-prod/server/app/_global-error/page.js +2 -2
  8. package/.next-prod/server/app/_global-error/page.js.nft.json +1 -1
  9. package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
  10. package/.next-prod/server/app/_global-error.html +1 -1
  11. package/.next-prod/server/app/_global-error.rsc +1 -1
  12. package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
  13. package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  14. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  15. package/.next-prod/server/app/_not-found/page.js +1 -1
  16. package/.next-prod/server/app/_not-found/page.js.nft.json +1 -1
  17. package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
  18. package/.next-prod/server/app/_not-found.html +2 -2
  19. package/.next-prod/server/app/_not-found.rsc +3 -3
  20. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +3 -3
  21. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +3 -3
  22. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  23. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  24. package/.next-prod/server/app/api/agent/test/route.js +1 -1
  25. package/.next-prod/server/app/api/agent/test/route.js.nft.json +1 -1
  26. package/.next-prod/server/app/api/bash/route.js +1 -1
  27. package/.next-prod/server/app/api/bash/route.js.nft.json +1 -1
  28. package/.next-prod/server/app/api/chat/codex/route.js +1 -1
  29. package/.next-prod/server/app/api/chat/codex/route.js.nft.json +1 -1
  30. package/.next-prod/server/app/api/chat/deepseek/route.js +1 -1
  31. package/.next-prod/server/app/api/chat/deepseek/route.js.nft.json +1 -1
  32. package/.next-prod/server/app/api/chat/glm/route.js +1 -1
  33. package/.next-prod/server/app/api/chat/glm/route.js.nft.json +1 -1
  34. package/.next-prod/server/app/api/chat/kimi/route.js +1 -1
  35. package/.next-prod/server/app/api/chat/kimi/route.js.nft.json +1 -1
  36. package/.next-prod/server/app/api/chat/ollama/route.js +1 -1
  37. package/.next-prod/server/app/api/chat/ollama/route.js.nft.json +1 -1
  38. package/.next-prod/server/app/api/chat/route.js +1 -1
  39. package/.next-prod/server/app/api/chat/route.js.nft.json +1 -1
  40. package/.next-prod/server/app/api/chat/stop/route.js +1 -1
  41. package/.next-prod/server/app/api/chat/stop/route.js.nft.json +1 -1
  42. package/.next-prod/server/app/api/claude-stats/route.js +1 -1
  43. package/.next-prod/server/app/api/claude-stats/route.js.nft.json +1 -1
  44. package/.next-prod/server/app/api/commands/route.js +1 -1
  45. package/.next-prod/server/app/api/commands/route.js.nft.json +1 -1
  46. package/.next-prod/server/app/api/comments/route.js +1 -1
  47. package/.next-prod/server/app/api/comments/route.js.nft.json +1 -1
  48. package/.next-prod/server/app/api/db/columns/route.js +1 -1
  49. package/.next-prod/server/app/api/db/columns/route.js.nft.json +1 -1
  50. package/.next-prod/server/app/api/db/connect/route.js +2 -2
  51. package/.next-prod/server/app/api/db/connect/route.js.nft.json +1 -1
  52. package/.next-prod/server/app/api/db/disconnect/route.js +1 -1
  53. package/.next-prod/server/app/api/db/disconnect/route.js.nft.json +1 -1
  54. package/.next-prod/server/app/api/db/export/route.js +1 -1
  55. package/.next-prod/server/app/api/db/export/route.js.nft.json +1 -1
  56. package/.next-prod/server/app/api/db/query/route.js +1 -1
  57. package/.next-prod/server/app/api/db/query/route.js.nft.json +1 -1
  58. package/.next-prod/server/app/api/db/schemas/route.js +2 -2
  59. package/.next-prod/server/app/api/db/schemas/route.js.nft.json +1 -1
  60. package/.next-prod/server/app/api/deepseek/balance/route.js +1 -1
  61. package/.next-prod/server/app/api/deepseek/balance/route.js.nft.json +1 -1
  62. package/.next-prod/server/app/api/deepseek/credentials/route.js +1 -1
  63. package/.next-prod/server/app/api/deepseek/credentials/route.js.nft.json +1 -1
  64. package/.next-prod/server/app/api/deepseek/models/route.js +1 -1
  65. package/.next-prod/server/app/api/deepseek/models/route.js.nft.json +1 -1
  66. package/.next-prod/server/app/api/dev/spans/route.js +1 -1
  67. package/.next-prod/server/app/api/dev/spans/route.js.nft.json +1 -1
  68. package/.next-prod/server/app/api/extension/version/route.js +1 -1
  69. package/.next-prod/server/app/api/extension/version/route.js.nft.json +1 -1
  70. package/.next-prod/server/app/api/file/route.js +1 -1
  71. package/.next-prod/server/app/api/file/route.js.nft.json +1 -1
  72. package/.next-prod/server/app/api/files/blame/route.js +1 -1
  73. package/.next-prod/server/app/api/files/blame/route.js.nft.json +1 -1
  74. package/.next-prod/server/app/api/files/clipboard/route.js +1 -1
  75. package/.next-prod/server/app/api/files/clipboard/route.js.nft.json +1 -1
  76. package/.next-prod/server/app/api/files/copy/route.js +1 -1
  77. package/.next-prod/server/app/api/files/copy/route.js.nft.json +1 -1
  78. package/.next-prod/server/app/api/files/delete/route.js +1 -1
  79. package/.next-prod/server/app/api/files/delete/route.js.nft.json +1 -1
  80. package/.next-prod/server/app/api/files/expanded/route.js +1 -1
  81. package/.next-prod/server/app/api/files/expanded/route.js.nft.json +1 -1
  82. package/.next-prod/server/app/api/files/index/route.js +1 -1
  83. package/.next-prod/server/app/api/files/index/route.js.nft.json +1 -1
  84. package/.next-prod/server/app/api/files/init/route.js +1 -1
  85. package/.next-prod/server/app/api/files/init/route.js.nft.json +1 -1
  86. package/.next-prod/server/app/api/files/paste/route.js +1 -1
  87. package/.next-prod/server/app/api/files/paste/route.js.nft.json +1 -1
  88. package/.next-prod/server/app/api/files/read/route.js +1 -1
  89. package/.next-prod/server/app/api/files/read/route.js.nft.json +1 -1
  90. package/.next-prod/server/app/api/files/readdir/route.js +1 -1
  91. package/.next-prod/server/app/api/files/readdir/route.js.nft.json +1 -1
  92. package/.next-prod/server/app/api/files/recent/route.js +1 -1
  93. package/.next-prod/server/app/api/files/recent/route.js.nft.json +1 -1
  94. package/.next-prod/server/app/api/files/save/route.js +1 -1
  95. package/.next-prod/server/app/api/files/save/route.js.nft.json +1 -1
  96. package/.next-prod/server/app/api/files/search/route.js +1 -1
  97. package/.next-prod/server/app/api/files/search/route.js.nft.json +1 -1
  98. package/.next-prod/server/app/api/files/stat/route.js +1 -1
  99. package/.next-prod/server/app/api/files/stat/route.js.nft.json +1 -1
  100. package/.next-prod/server/app/api/files/text/route.js +1 -1
  101. package/.next-prod/server/app/api/files/text/route.js.nft.json +1 -1
  102. package/.next-prod/server/app/api/git/blob/route.js +1 -1
  103. package/.next-prod/server/app/api/git/blob/route.js.nft.json +1 -1
  104. package/.next-prod/server/app/api/git/branch-diff/route.js +1 -1
  105. package/.next-prod/server/app/api/git/branch-diff/route.js.nft.json +1 -1
  106. package/.next-prod/server/app/api/git/branches/route.js +1 -1
  107. package/.next-prod/server/app/api/git/branches/route.js.nft.json +1 -1
  108. package/.next-prod/server/app/api/git/commit-diff/route.js +1 -1
  109. package/.next-prod/server/app/api/git/commit-diff/route.js.nft.json +1 -1
  110. package/.next-prod/server/app/api/git/commits/route.js +1 -1
  111. package/.next-prod/server/app/api/git/commits/route.js.nft.json +1 -1
  112. package/.next-prod/server/app/api/git/current-branch/route.js +1 -1
  113. package/.next-prod/server/app/api/git/current-branch/route.js.nft.json +1 -1
  114. package/.next-prod/server/app/api/git/diff/route.js +1 -1
  115. package/.next-prod/server/app/api/git/diff/route.js.nft.json +1 -1
  116. package/.next-prod/server/app/api/git/discard/route.js +1 -1
  117. package/.next-prod/server/app/api/git/discard/route.js.nft.json +1 -1
  118. package/.next-prod/server/app/api/git/stage/route.js +1 -1
  119. package/.next-prod/server/app/api/git/stage/route.js.nft.json +1 -1
  120. package/.next-prod/server/app/api/git/status/route.js +1 -1
  121. package/.next-prod/server/app/api/git/status/route.js.nft.json +1 -1
  122. package/.next-prod/server/app/api/git/unstage/route.js +1 -1
  123. package/.next-prod/server/app/api/git/unstage/route.js.nft.json +1 -1
  124. package/.next-prod/server/app/api/git/worktree/route.js +1 -1
  125. package/.next-prod/server/app/api/git/worktree/route.js.nft.json +1 -1
  126. package/.next-prod/server/app/api/glm/credentials/route.js +1 -1
  127. package/.next-prod/server/app/api/glm/credentials/route.js.nft.json +1 -1
  128. package/.next-prod/server/app/api/glm/models/route.js +1 -1
  129. package/.next-prod/server/app/api/glm/models/route.js.nft.json +1 -1
  130. package/.next-prod/server/app/api/glm/usage/route.js +1 -1
  131. package/.next-prod/server/app/api/glm/usage/route.js.nft.json +1 -1
  132. package/.next-prod/server/app/api/global-state/route.js +1 -1
  133. package/.next-prod/server/app/api/global-state/route.js.nft.json +1 -1
  134. package/.next-prod/server/app/api/health/route.js +1 -1
  135. package/.next-prod/server/app/api/health/route.js.nft.json +1 -1
  136. package/.next-prod/server/app/api/html-apps/[id]/route.js +1 -1
  137. package/.next-prod/server/app/api/html-apps/[id]/route.js.nft.json +1 -1
  138. package/.next-prod/server/app/api/html-apps/route.js +1 -1
  139. package/.next-prod/server/app/api/html-apps/route.js.nft.json +1 -1
  140. package/.next-prod/server/app/api/jupyter/load/route.js +1 -1
  141. package/.next-prod/server/app/api/jupyter/load/route.js.nft.json +1 -1
  142. package/.next-prod/server/app/api/jupyter/save/route.js +1 -1
  143. package/.next-prod/server/app/api/jupyter/save/route.js.nft.json +1 -1
  144. package/.next-prod/server/app/api/jupyter/shutdown/route.js +1 -1
  145. package/.next-prod/server/app/api/jupyter/shutdown/route.js.nft.json +1 -1
  146. package/.next-prod/server/app/api/kimi/credentials/route.js +1 -1
  147. package/.next-prod/server/app/api/kimi/credentials/route.js.nft.json +1 -1
  148. package/.next-prod/server/app/api/kimi/models/route.js +1 -1
  149. package/.next-prod/server/app/api/kimi/models/route.js.nft.json +1 -1
  150. package/.next-prod/server/app/api/kimi/usage/route.js +1 -1
  151. package/.next-prod/server/app/api/kimi/usage/route.js.nft.json +1 -1
  152. package/.next-prod/server/app/api/lsp/definition/route.js +1 -1
  153. package/.next-prod/server/app/api/lsp/definition/route.js.nft.json +1 -1
  154. package/.next-prod/server/app/api/lsp/hover/route.js +1 -1
  155. package/.next-prod/server/app/api/lsp/hover/route.js.nft.json +1 -1
  156. package/.next-prod/server/app/api/lsp/references/route.js +1 -1
  157. package/.next-prod/server/app/api/lsp/references/route.js.nft.json +1 -1
  158. package/.next-prod/server/app/api/lsp/status/route.js +1 -1
  159. package/.next-prod/server/app/api/lsp/status/route.js.nft.json +1 -1
  160. package/.next-prod/server/app/api/lsp/warmup/route.js +1 -1
  161. package/.next-prod/server/app/api/lsp/warmup/route.js.nft.json +1 -1
  162. package/.next-prod/server/app/api/mysql/columns/route.js +1 -1
  163. package/.next-prod/server/app/api/mysql/columns/route.js.nft.json +1 -1
  164. package/.next-prod/server/app/api/mysql/connect/route.js +1 -1
  165. package/.next-prod/server/app/api/mysql/connect/route.js.nft.json +1 -1
  166. package/.next-prod/server/app/api/mysql/disconnect/route.js +1 -1
  167. package/.next-prod/server/app/api/mysql/disconnect/route.js.nft.json +1 -1
  168. package/.next-prod/server/app/api/mysql/export/route.js +1 -1
  169. package/.next-prod/server/app/api/mysql/export/route.js.nft.json +1 -1
  170. package/.next-prod/server/app/api/mysql/query/route.js +1 -1
  171. package/.next-prod/server/app/api/mysql/query/route.js.nft.json +1 -1
  172. package/.next-prod/server/app/api/mysql/schemas/route.js +2 -2
  173. package/.next-prod/server/app/api/mysql/schemas/route.js.nft.json +1 -1
  174. package/.next-prod/server/app/api/neo4j/connect/route.js +1 -1
  175. package/.next-prod/server/app/api/neo4j/connect/route.js.nft.json +1 -1
  176. package/.next-prod/server/app/api/neo4j/disconnect/route.js +1 -1
  177. package/.next-prod/server/app/api/neo4j/disconnect/route.js.nft.json +1 -1
  178. package/.next-prod/server/app/api/neo4j/query/route.js +1 -1
  179. package/.next-prod/server/app/api/neo4j/query/route.js.nft.json +1 -1
  180. package/.next-prod/server/app/api/neo4j/schema/route.js +1 -1
  181. package/.next-prod/server/app/api/neo4j/schema/route.js.nft.json +1 -1
  182. package/.next-prod/server/app/api/note/route.js +1 -1
  183. package/.next-prod/server/app/api/note/route.js.nft.json +1 -1
  184. package/.next-prod/server/app/api/ollama/config/route.js +1 -1
  185. package/.next-prod/server/app/api/ollama/config/route.js.nft.json +1 -1
  186. package/.next-prod/server/app/api/ollama/models/route.js +1 -1
  187. package/.next-prod/server/app/api/ollama/models/route.js.nft.json +1 -1
  188. package/.next-prod/server/app/api/ollama/start/route.js +1 -1
  189. package/.next-prod/server/app/api/ollama/start/route.js.nft.json +1 -1
  190. package/.next-prod/server/app/api/open-cursor/route.js +1 -1
  191. package/.next-prod/server/app/api/open-cursor/route.js.nft.json +1 -1
  192. package/.next-prod/server/app/api/open-vscode/route.js +1 -1
  193. package/.next-prod/server/app/api/open-vscode/route.js.nft.json +1 -1
  194. package/.next-prod/server/app/api/pick-folder/route.js +1 -1
  195. package/.next-prod/server/app/api/pick-folder/route.js.nft.json +1 -1
  196. package/.next-prod/server/app/api/pinned-sessions/route.js +1 -1
  197. package/.next-prod/server/app/api/pinned-sessions/route.js.nft.json +1 -1
  198. package/.next-prod/server/app/api/project-settings/route.js +1 -1
  199. package/.next-prod/server/app/api/project-settings/route.js.nft.json +1 -1
  200. package/.next-prod/server/app/api/project-state/route.js +2 -2
  201. package/.next-prod/server/app/api/project-state/route.js.nft.json +1 -1
  202. package/.next-prod/server/app/api/projectGraph/affected/route.js +1 -1
  203. package/.next-prod/server/app/api/projectGraph/affected/route.js.nft.json +1 -1
  204. package/.next-prod/server/app/api/projectGraph/callees/route.js +1 -1
  205. package/.next-prod/server/app/api/projectGraph/callees/route.js.nft.json +1 -1
  206. package/.next-prod/server/app/api/projectGraph/callers/route.js +1 -1
  207. package/.next-prod/server/app/api/projectGraph/callers/route.js.nft.json +1 -1
  208. package/.next-prod/server/app/api/projectGraph/coedit/route.js +1 -1
  209. package/.next-prod/server/app/api/projectGraph/coedit/route.js.nft.json +1 -1
  210. package/.next-prod/server/app/api/projectGraph/context/route.js +1 -1
  211. package/.next-prod/server/app/api/projectGraph/context/route.js.nft.json +1 -1
  212. package/.next-prod/server/app/api/projectGraph/file/route.js +1 -1
  213. package/.next-prod/server/app/api/projectGraph/file/route.js.nft.json +1 -1
  214. package/.next-prod/server/app/api/projectGraph/file-functions/route.js +1 -1
  215. package/.next-prod/server/app/api/projectGraph/file-functions/route.js.nft.json +1 -1
  216. package/.next-prod/server/app/api/projectGraph/impact/route.js +1 -1
  217. package/.next-prod/server/app/api/projectGraph/impact/route.js.nft.json +1 -1
  218. package/.next-prod/server/app/api/projectGraph/related/route.js +1 -1
  219. package/.next-prod/server/app/api/projectGraph/related/route.js.nft.json +1 -1
  220. package/.next-prod/server/app/api/projectGraph/risk/route.js +1 -1
  221. package/.next-prod/server/app/api/projectGraph/risk/route.js.nft.json +1 -1
  222. package/.next-prod/server/app/api/projectGraph/search/route.js +1 -1
  223. package/.next-prod/server/app/api/projectGraph/search/route.js.nft.json +1 -1
  224. package/.next-prod/server/app/api/projects/route.js +1 -1
  225. package/.next-prod/server/app/api/projects/route.js.nft.json +1 -1
  226. package/.next-prod/server/app/api/prompts/config/route.js +1 -1
  227. package/.next-prod/server/app/api/prompts/config/route.js.nft.json +1 -1
  228. package/.next-prod/server/app/api/push/public-key/route.js +1 -1
  229. package/.next-prod/server/app/api/push/public-key/route.js.nft.json +1 -1
  230. package/.next-prod/server/app/api/push/subscribe/route.js +1 -1
  231. package/.next-prod/server/app/api/push/subscribe/route.js.nft.json +1 -1
  232. package/.next-prod/server/app/api/push/unsubscribe/route.js +1 -1
  233. package/.next-prod/server/app/api/push/unsubscribe/route.js.nft.json +1 -1
  234. package/.next-prod/server/app/api/redis/command/route.js +1 -1
  235. package/.next-prod/server/app/api/redis/command/route.js.nft.json +1 -1
  236. package/.next-prod/server/app/api/redis/connect/route.js +1 -1
  237. package/.next-prod/server/app/api/redis/connect/route.js.nft.json +1 -1
  238. package/.next-prod/server/app/api/redis/delete/route.js +1 -1
  239. package/.next-prod/server/app/api/redis/delete/route.js.nft.json +1 -1
  240. package/.next-prod/server/app/api/redis/disconnect/route.js +1 -1
  241. package/.next-prod/server/app/api/redis/disconnect/route.js.nft.json +1 -1
  242. package/.next-prod/server/app/api/redis/get/route.js +1 -1
  243. package/.next-prod/server/app/api/redis/get/route.js.nft.json +1 -1
  244. package/.next-prod/server/app/api/redis/keys/route.js +1 -1
  245. package/.next-prod/server/app/api/redis/keys/route.js.nft.json +1 -1
  246. package/.next-prod/server/app/api/redis/set/route.js +1 -1
  247. package/.next-prod/server/app/api/redis/set/route.js.nft.json +1 -1
  248. package/.next-prod/server/app/api/restart/route.js +1 -1
  249. package/.next-prod/server/app/api/restart/route.js.nft.json +1 -1
  250. package/.next-prod/server/app/api/review/[id]/comments/route.js +1 -1
  251. package/.next-prod/server/app/api/review/[id]/comments/route.js.nft.json +1 -1
  252. package/.next-prod/server/app/api/review/[id]/replies/route.js +1 -1
  253. package/.next-prod/server/app/api/review/[id]/replies/route.js.nft.json +1 -1
  254. package/.next-prod/server/app/api/review/[id]/route.js +1 -1
  255. package/.next-prod/server/app/api/review/[id]/route.js.nft.json +1 -1
  256. package/.next-prod/server/app/api/review/identify/route.js +1 -1
  257. package/.next-prod/server/app/api/review/identify/route.js.nft.json +1 -1
  258. package/.next-prod/server/app/api/review/order/route.js +1 -1
  259. package/.next-prod/server/app/api/review/order/route.js.nft.json +1 -1
  260. package/.next-prod/server/app/api/review/route.js +1 -1
  261. package/.next-prod/server/app/api/review/route.js.nft.json +1 -1
  262. package/.next-prod/server/app/api/review/share-info/route.js +1 -1
  263. package/.next-prod/server/app/api/review/share-info/route.js.nft.json +1 -1
  264. package/.next-prod/server/app/api/review/users/route.js +1 -1
  265. package/.next-prod/server/app/api/review/users/route.js.nft.json +1 -1
  266. package/.next-prod/server/app/api/scheduled-tasks/route.js +2 -2
  267. package/.next-prod/server/app/api/scheduled-tasks/route.js.nft.json +1 -1
  268. package/.next-prod/server/app/api/services/config/route.js +1 -1
  269. package/.next-prod/server/app/api/services/config/route.js.nft.json +1 -1
  270. package/.next-prod/server/app/api/services/scripts/route.js +1 -1
  271. package/.next-prod/server/app/api/services/scripts/route.js.nft.json +1 -1
  272. package/.next-prod/server/app/api/session/[sessionId]/fork/route.js +1 -1
  273. package/.next-prod/server/app/api/session/[sessionId]/fork/route.js.nft.json +1 -1
  274. package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -1
  275. package/.next-prod/server/app/api/session/[sessionId]/history/route.js.nft.json +1 -1
  276. package/.next-prod/server/app/api/session-by-path/route.js +1 -1
  277. package/.next-prod/server/app/api/session-by-path/route.js.nft.json +1 -1
  278. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js +1 -1
  279. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js.nft.json +1 -1
  280. package/.next-prod/server/app/api/sessions/projects/route.js +1 -1
  281. package/.next-prod/server/app/api/sessions/projects/route.js.nft.json +1 -1
  282. package/.next-prod/server/app/api/sessions/route.js +1 -1
  283. package/.next-prod/server/app/api/sessions/route.js.nft.json +1 -1
  284. package/.next-prod/server/app/api/settings/route.js +1 -1
  285. package/.next-prod/server/app/api/settings/route.js.nft.json +1 -1
  286. package/.next-prod/server/app/api/shutdown/route.js +1 -1
  287. package/.next-prod/server/app/api/shutdown/route.js.nft.json +1 -1
  288. package/.next-prod/server/app/api/skills/[id]/route.js +1 -1
  289. package/.next-prod/server/app/api/skills/[id]/route.js.nft.json +1 -1
  290. package/.next-prod/server/app/api/skills/content/route.js +1 -1
  291. package/.next-prod/server/app/api/skills/content/route.js.nft.json +1 -1
  292. package/.next-prod/server/app/api/skills/route.js +1 -1
  293. package/.next-prod/server/app/api/skills/route.js.nft.json +1 -1
  294. package/.next-prod/server/app/api/snapshots/blob/route.js +1 -0
  295. package/.next-prod/server/app/api/snapshots/blob/route.js.nft.json +1 -0
  296. package/.next-prod/server/app/api/snapshots/blob/route_client-reference-manifest.js +1 -0
  297. package/.next-prod/server/app/api/snapshots/diff/route.js +1 -1
  298. package/.next-prod/server/app/api/snapshots/diff/route.js.nft.json +1 -1
  299. package/.next-prod/server/app/api/snapshots/route.js +1 -1
  300. package/.next-prod/server/app/api/snapshots/route.js.nft.json +1 -1
  301. package/.next-prod/server/app/api/terminal/aliases/route.js +1 -1
  302. package/.next-prod/server/app/api/terminal/aliases/route.js.nft.json +1 -1
  303. package/.next-prod/server/app/api/terminal/autocomplete/route.js +1 -1
  304. package/.next-prod/server/app/api/terminal/autocomplete/route.js.nft.json +1 -1
  305. package/.next-prod/server/app/api/terminal/bubble-order/route.js +1 -1
  306. package/.next-prod/server/app/api/terminal/bubble-order/route.js.nft.json +1 -1
  307. package/.next-prod/server/app/api/terminal/env/route.js +1 -1
  308. package/.next-prod/server/app/api/terminal/env/route.js.nft.json +1 -1
  309. package/.next-prod/server/app/api/terminal/history/route.js +1 -1
  310. package/.next-prod/server/app/api/terminal/history/route.js.nft.json +1 -1
  311. package/.next-prod/server/app/api/update/route.js +1 -1
  312. package/.next-prod/server/app/api/update/route.js.nft.json +1 -1
  313. package/.next-prod/server/app/api/update-state/route.js +1 -1
  314. package/.next-prod/server/app/api/update-state/route.js.nft.json +1 -1
  315. package/.next-prod/server/app/api/version/route.js +1 -1
  316. package/.next-prod/server/app/api/version/route.js.nft.json +1 -1
  317. package/.next-prod/server/app/apps/[...path]/route.js +1 -1
  318. package/.next-prod/server/app/apps/[...path]/route.js.nft.json +1 -1
  319. package/.next-prod/server/app/favicon.ico/route.js +1 -1
  320. package/.next-prod/server/app/favicon.ico/route.js.nft.json +1 -1
  321. package/.next-prod/server/app/m/page.js +1 -1
  322. package/.next-prod/server/app/m/page.js.nft.json +1 -1
  323. package/.next-prod/server/app/m/page_client-reference-manifest.js +1 -1
  324. package/.next-prod/server/app/manifest.webmanifest/route.js +2 -2
  325. package/.next-prod/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  326. package/.next-prod/server/app/page.js +1 -1
  327. package/.next-prod/server/app/page.js.nft.json +1 -1
  328. package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
  329. package/.next-prod/server/app/project/page.js +1 -1
  330. package/.next-prod/server/app/project/page.js.nft.json +1 -1
  331. package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
  332. package/.next-prod/server/app/review/[id]/page.js +1 -1
  333. package/.next-prod/server/app/review/[id]/page.js.nft.json +1 -1
  334. package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
  335. package/.next-prod/server/app-paths-manifest.json +4 -3
  336. package/.next-prod/server/chunks/2493.js +3 -3
  337. package/.next-prod/server/chunks/3286.js +3 -3
  338. package/.next-prod/server/chunks/{3641.js → 3583.js} +1 -1
  339. package/.next-prod/server/chunks/4949.js +1 -0
  340. package/.next-prod/server/chunks/516.js +1 -1
  341. package/.next-prod/server/chunks/5750.js +14 -14
  342. package/.next-prod/server/chunks/6548.js +1 -1
  343. package/.next-prod/server/chunks/7184.js +4 -4
  344. package/.next-prod/server/chunks/816.js +1 -1
  345. package/.next-prod/server/chunks/9312.js +1 -1
  346. package/.next-prod/server/chunks/9352.js +1 -1
  347. package/.next-prod/server/chunks/9830.js +1 -1
  348. package/.next-prod/server/middleware-build-manifest.js +1 -1
  349. package/.next-prod/server/pages/404.html +2 -2
  350. package/.next-prod/server/pages/500.html +1 -1
  351. package/.next-prod/server/server-reference-manifest.json +1 -1
  352. package/.next-prod/static/MM6vZhLQFwtUo_vz7BSfe/_buildManifest.js +1 -0
  353. package/.next-prod/static/chunks/33372-a2d65ba0d112fc24.js +35 -0
  354. package/.next-prod/static/chunks/46784-24ed72109d7c318b.js +716 -0
  355. package/.next-prod/static/chunks/{5504-583edbefcb22ed17.js → 87834-dfec736663e6aac2.js} +2 -2
  356. package/.next-prod/static/chunks/96911-08609dc685108dcc.js +15 -0
  357. package/.next-prod/static/chunks/app/_global-error/{page-c1a2c7e62ce669f7.js → page-db8b43ac5e6e9ac5.js} +1 -1
  358. package/.next-prod/static/chunks/app/api/agent/test/{route-c1a2c7e62ce669f7.js → route-db8b43ac5e6e9ac5.js} +1 -1
  359. package/.next-prod/static/chunks/app/api/bash/{route-c1a2c7e62ce669f7.js → route-db8b43ac5e6e9ac5.js} +1 -1
  360. package/.next-prod/static/chunks/app/api/chat/codex/{route-c1a2c7e62ce669f7.js → route-db8b43ac5e6e9ac5.js} +1 -1
  361. package/.next-prod/static/chunks/app/api/chat/deepseek/route-db8b43ac5e6e9ac5.js +1 -0
  362. package/.next-prod/static/chunks/app/api/chat/glm/route-db8b43ac5e6e9ac5.js +1 -0
  363. package/.next-prod/static/chunks/app/api/chat/kimi/route-db8b43ac5e6e9ac5.js +1 -0
  364. package/.next-prod/static/chunks/app/api/chat/ollama/route-db8b43ac5e6e9ac5.js +1 -0
  365. package/.next-prod/static/chunks/app/api/chat/route-db8b43ac5e6e9ac5.js +1 -0
  366. package/.next-prod/static/chunks/app/api/chat/stop/route-db8b43ac5e6e9ac5.js +1 -0
  367. package/.next-prod/static/chunks/app/api/claude-stats/route-db8b43ac5e6e9ac5.js +1 -0
  368. package/.next-prod/static/chunks/app/api/commands/route-db8b43ac5e6e9ac5.js +1 -0
  369. package/.next-prod/static/chunks/app/api/comments/route-db8b43ac5e6e9ac5.js +1 -0
  370. package/.next-prod/static/chunks/app/api/db/columns/route-db8b43ac5e6e9ac5.js +1 -0
  371. package/.next-prod/static/chunks/app/api/db/connect/route-db8b43ac5e6e9ac5.js +1 -0
  372. package/.next-prod/static/chunks/app/api/db/disconnect/route-db8b43ac5e6e9ac5.js +1 -0
  373. package/.next-prod/static/chunks/app/api/db/export/route-db8b43ac5e6e9ac5.js +1 -0
  374. package/.next-prod/static/chunks/app/api/db/query/route-db8b43ac5e6e9ac5.js +1 -0
  375. package/.next-prod/static/chunks/app/api/db/schemas/route-db8b43ac5e6e9ac5.js +1 -0
  376. package/.next-prod/static/chunks/app/api/deepseek/balance/route-db8b43ac5e6e9ac5.js +1 -0
  377. package/.next-prod/static/chunks/app/api/deepseek/credentials/route-db8b43ac5e6e9ac5.js +1 -0
  378. package/.next-prod/static/chunks/app/api/deepseek/models/route-db8b43ac5e6e9ac5.js +1 -0
  379. package/.next-prod/static/chunks/app/api/dev/spans/route-db8b43ac5e6e9ac5.js +1 -0
  380. package/.next-prod/static/chunks/app/api/extension/version/route-db8b43ac5e6e9ac5.js +1 -0
  381. package/.next-prod/static/chunks/app/api/file/route-db8b43ac5e6e9ac5.js +1 -0
  382. package/.next-prod/static/chunks/app/api/files/blame/route-db8b43ac5e6e9ac5.js +1 -0
  383. package/.next-prod/static/chunks/app/api/files/clipboard/route-db8b43ac5e6e9ac5.js +1 -0
  384. package/.next-prod/static/chunks/app/api/files/copy/route-db8b43ac5e6e9ac5.js +1 -0
  385. package/.next-prod/static/chunks/app/api/files/delete/route-db8b43ac5e6e9ac5.js +1 -0
  386. package/.next-prod/static/chunks/app/api/files/expanded/route-db8b43ac5e6e9ac5.js +1 -0
  387. package/.next-prod/static/chunks/app/api/files/index/route-db8b43ac5e6e9ac5.js +1 -0
  388. package/.next-prod/static/chunks/app/api/files/init/route-db8b43ac5e6e9ac5.js +1 -0
  389. package/.next-prod/static/chunks/app/api/files/paste/route-db8b43ac5e6e9ac5.js +1 -0
  390. package/.next-prod/static/chunks/app/api/files/read/route-db8b43ac5e6e9ac5.js +1 -0
  391. package/.next-prod/static/chunks/app/api/files/readdir/route-db8b43ac5e6e9ac5.js +1 -0
  392. package/.next-prod/static/chunks/app/api/files/recent/route-db8b43ac5e6e9ac5.js +1 -0
  393. package/.next-prod/static/chunks/app/api/files/save/route-db8b43ac5e6e9ac5.js +1 -0
  394. package/.next-prod/static/chunks/app/api/files/search/route-db8b43ac5e6e9ac5.js +1 -0
  395. package/.next-prod/static/chunks/app/api/files/stat/route-db8b43ac5e6e9ac5.js +1 -0
  396. package/.next-prod/static/chunks/app/api/files/text/route-db8b43ac5e6e9ac5.js +1 -0
  397. package/.next-prod/static/chunks/app/api/git/blob/route-db8b43ac5e6e9ac5.js +1 -0
  398. package/.next-prod/static/chunks/app/api/git/branch-diff/route-db8b43ac5e6e9ac5.js +1 -0
  399. package/.next-prod/static/chunks/app/api/git/branches/route-db8b43ac5e6e9ac5.js +1 -0
  400. package/.next-prod/static/chunks/app/api/git/commit-diff/route-db8b43ac5e6e9ac5.js +1 -0
  401. package/.next-prod/static/chunks/app/api/git/commits/route-db8b43ac5e6e9ac5.js +1 -0
  402. package/.next-prod/static/chunks/app/api/git/current-branch/route-db8b43ac5e6e9ac5.js +1 -0
  403. package/.next-prod/static/chunks/app/api/git/diff/route-db8b43ac5e6e9ac5.js +1 -0
  404. package/.next-prod/static/chunks/app/api/git/discard/route-db8b43ac5e6e9ac5.js +1 -0
  405. package/.next-prod/static/chunks/app/api/git/stage/route-db8b43ac5e6e9ac5.js +1 -0
  406. package/.next-prod/static/chunks/app/api/git/status/route-db8b43ac5e6e9ac5.js +1 -0
  407. package/.next-prod/static/chunks/app/api/git/unstage/route-db8b43ac5e6e9ac5.js +1 -0
  408. package/.next-prod/static/chunks/app/api/git/worktree/route-db8b43ac5e6e9ac5.js +1 -0
  409. package/.next-prod/static/chunks/app/api/glm/credentials/route-db8b43ac5e6e9ac5.js +1 -0
  410. package/.next-prod/static/chunks/app/api/glm/models/route-db8b43ac5e6e9ac5.js +1 -0
  411. package/.next-prod/static/chunks/app/api/glm/usage/route-db8b43ac5e6e9ac5.js +1 -0
  412. package/.next-prod/static/chunks/app/api/global-state/route-db8b43ac5e6e9ac5.js +1 -0
  413. package/.next-prod/static/chunks/app/api/health/route-db8b43ac5e6e9ac5.js +1 -0
  414. package/.next-prod/static/chunks/app/api/html-apps/[id]/route-db8b43ac5e6e9ac5.js +1 -0
  415. package/.next-prod/static/chunks/app/api/html-apps/route-db8b43ac5e6e9ac5.js +1 -0
  416. package/.next-prod/static/chunks/app/api/jupyter/load/route-db8b43ac5e6e9ac5.js +1 -0
  417. package/.next-prod/static/chunks/app/api/jupyter/save/route-db8b43ac5e6e9ac5.js +1 -0
  418. package/.next-prod/static/chunks/app/api/jupyter/shutdown/route-db8b43ac5e6e9ac5.js +1 -0
  419. package/.next-prod/static/chunks/app/api/kimi/credentials/route-db8b43ac5e6e9ac5.js +1 -0
  420. package/.next-prod/static/chunks/app/api/kimi/models/route-db8b43ac5e6e9ac5.js +1 -0
  421. package/.next-prod/static/chunks/app/api/kimi/usage/route-db8b43ac5e6e9ac5.js +1 -0
  422. package/.next-prod/static/chunks/app/api/lsp/definition/route-db8b43ac5e6e9ac5.js +1 -0
  423. package/.next-prod/static/chunks/app/api/lsp/hover/route-db8b43ac5e6e9ac5.js +1 -0
  424. package/.next-prod/static/chunks/app/api/lsp/references/route-db8b43ac5e6e9ac5.js +1 -0
  425. package/.next-prod/static/chunks/app/api/lsp/status/route-db8b43ac5e6e9ac5.js +1 -0
  426. package/.next-prod/static/chunks/app/api/lsp/warmup/route-db8b43ac5e6e9ac5.js +1 -0
  427. package/.next-prod/static/chunks/app/api/mysql/columns/route-db8b43ac5e6e9ac5.js +1 -0
  428. package/.next-prod/static/chunks/app/api/mysql/connect/route-db8b43ac5e6e9ac5.js +1 -0
  429. package/.next-prod/static/chunks/app/api/mysql/disconnect/route-db8b43ac5e6e9ac5.js +1 -0
  430. package/.next-prod/static/chunks/app/api/mysql/export/route-db8b43ac5e6e9ac5.js +1 -0
  431. package/.next-prod/static/chunks/app/api/mysql/query/route-db8b43ac5e6e9ac5.js +1 -0
  432. package/.next-prod/static/chunks/app/api/mysql/schemas/route-db8b43ac5e6e9ac5.js +1 -0
  433. package/.next-prod/static/chunks/app/api/neo4j/connect/route-db8b43ac5e6e9ac5.js +1 -0
  434. package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-db8b43ac5e6e9ac5.js +1 -0
  435. package/.next-prod/static/chunks/app/api/neo4j/query/route-db8b43ac5e6e9ac5.js +1 -0
  436. package/.next-prod/static/chunks/app/api/neo4j/schema/route-db8b43ac5e6e9ac5.js +1 -0
  437. package/.next-prod/static/chunks/app/api/note/route-db8b43ac5e6e9ac5.js +1 -0
  438. package/.next-prod/static/chunks/app/api/ollama/config/route-db8b43ac5e6e9ac5.js +1 -0
  439. package/.next-prod/static/chunks/app/api/ollama/models/route-db8b43ac5e6e9ac5.js +1 -0
  440. package/.next-prod/static/chunks/app/api/ollama/start/route-db8b43ac5e6e9ac5.js +1 -0
  441. package/.next-prod/static/chunks/app/api/open-cursor/route-db8b43ac5e6e9ac5.js +1 -0
  442. package/.next-prod/static/chunks/app/api/open-vscode/route-db8b43ac5e6e9ac5.js +1 -0
  443. package/.next-prod/static/chunks/app/api/pick-folder/route-db8b43ac5e6e9ac5.js +1 -0
  444. package/.next-prod/static/chunks/app/api/pinned-sessions/route-db8b43ac5e6e9ac5.js +1 -0
  445. package/.next-prod/static/chunks/app/api/project-settings/route-db8b43ac5e6e9ac5.js +1 -0
  446. package/.next-prod/static/chunks/app/api/project-state/route-db8b43ac5e6e9ac5.js +1 -0
  447. package/.next-prod/static/chunks/app/api/projectGraph/affected/route-db8b43ac5e6e9ac5.js +1 -0
  448. package/.next-prod/static/chunks/app/api/projectGraph/callees/route-db8b43ac5e6e9ac5.js +1 -0
  449. package/.next-prod/static/chunks/app/api/projectGraph/callers/route-db8b43ac5e6e9ac5.js +1 -0
  450. package/.next-prod/static/chunks/app/api/projectGraph/coedit/route-db8b43ac5e6e9ac5.js +1 -0
  451. package/.next-prod/static/chunks/app/api/projectGraph/context/route-db8b43ac5e6e9ac5.js +1 -0
  452. package/.next-prod/static/chunks/app/api/projectGraph/file/route-db8b43ac5e6e9ac5.js +1 -0
  453. package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-db8b43ac5e6e9ac5.js +1 -0
  454. package/.next-prod/static/chunks/app/api/projectGraph/impact/route-db8b43ac5e6e9ac5.js +1 -0
  455. package/.next-prod/static/chunks/app/api/projectGraph/related/route-db8b43ac5e6e9ac5.js +1 -0
  456. package/.next-prod/static/chunks/app/api/projectGraph/risk/route-db8b43ac5e6e9ac5.js +1 -0
  457. package/.next-prod/static/chunks/app/api/projectGraph/search/route-db8b43ac5e6e9ac5.js +1 -0
  458. package/.next-prod/static/chunks/app/api/projects/route-db8b43ac5e6e9ac5.js +1 -0
  459. package/.next-prod/static/chunks/app/api/prompts/config/route-db8b43ac5e6e9ac5.js +1 -0
  460. package/.next-prod/static/chunks/app/api/push/public-key/route-db8b43ac5e6e9ac5.js +1 -0
  461. package/.next-prod/static/chunks/app/api/push/subscribe/route-db8b43ac5e6e9ac5.js +1 -0
  462. package/.next-prod/static/chunks/app/api/push/unsubscribe/route-db8b43ac5e6e9ac5.js +1 -0
  463. package/.next-prod/static/chunks/app/api/redis/command/route-db8b43ac5e6e9ac5.js +1 -0
  464. package/.next-prod/static/chunks/app/api/redis/connect/route-db8b43ac5e6e9ac5.js +1 -0
  465. package/.next-prod/static/chunks/app/api/redis/delete/route-db8b43ac5e6e9ac5.js +1 -0
  466. package/.next-prod/static/chunks/app/api/redis/disconnect/route-db8b43ac5e6e9ac5.js +1 -0
  467. package/.next-prod/static/chunks/app/api/redis/get/route-db8b43ac5e6e9ac5.js +1 -0
  468. package/.next-prod/static/chunks/app/api/redis/keys/route-db8b43ac5e6e9ac5.js +1 -0
  469. package/.next-prod/static/chunks/app/api/redis/set/route-db8b43ac5e6e9ac5.js +1 -0
  470. package/.next-prod/static/chunks/app/api/restart/route-db8b43ac5e6e9ac5.js +1 -0
  471. package/.next-prod/static/chunks/app/api/review/[id]/comments/route-db8b43ac5e6e9ac5.js +1 -0
  472. package/.next-prod/static/chunks/app/api/review/[id]/replies/route-db8b43ac5e6e9ac5.js +1 -0
  473. package/.next-prod/static/chunks/app/api/review/[id]/route-db8b43ac5e6e9ac5.js +1 -0
  474. package/.next-prod/static/chunks/app/api/review/identify/route-db8b43ac5e6e9ac5.js +1 -0
  475. package/.next-prod/static/chunks/app/api/review/order/route-db8b43ac5e6e9ac5.js +1 -0
  476. package/.next-prod/static/chunks/app/api/review/route-db8b43ac5e6e9ac5.js +1 -0
  477. package/.next-prod/static/chunks/app/api/review/share-info/route-db8b43ac5e6e9ac5.js +1 -0
  478. package/.next-prod/static/chunks/app/api/review/users/route-db8b43ac5e6e9ac5.js +1 -0
  479. package/.next-prod/static/chunks/app/api/scheduled-tasks/route-db8b43ac5e6e9ac5.js +1 -0
  480. package/.next-prod/static/chunks/app/api/services/config/route-db8b43ac5e6e9ac5.js +1 -0
  481. package/.next-prod/static/chunks/app/api/services/scripts/route-db8b43ac5e6e9ac5.js +1 -0
  482. package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-db8b43ac5e6e9ac5.js +1 -0
  483. package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-db8b43ac5e6e9ac5.js +1 -0
  484. package/.next-prod/static/chunks/app/api/session-by-path/route-db8b43ac5e6e9ac5.js +1 -0
  485. package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-db8b43ac5e6e9ac5.js +1 -0
  486. package/.next-prod/static/chunks/app/api/sessions/projects/route-db8b43ac5e6e9ac5.js +1 -0
  487. package/.next-prod/static/chunks/app/api/sessions/route-db8b43ac5e6e9ac5.js +1 -0
  488. package/.next-prod/static/chunks/app/api/settings/route-db8b43ac5e6e9ac5.js +1 -0
  489. package/.next-prod/static/chunks/app/api/shutdown/route-db8b43ac5e6e9ac5.js +1 -0
  490. package/.next-prod/static/chunks/app/api/skills/[id]/route-db8b43ac5e6e9ac5.js +1 -0
  491. package/.next-prod/static/chunks/app/api/skills/content/route-db8b43ac5e6e9ac5.js +1 -0
  492. package/.next-prod/static/chunks/app/api/skills/route-db8b43ac5e6e9ac5.js +1 -0
  493. package/.next-prod/static/chunks/app/api/snapshots/blob/route-db8b43ac5e6e9ac5.js +1 -0
  494. package/.next-prod/static/chunks/app/api/snapshots/diff/route-db8b43ac5e6e9ac5.js +1 -0
  495. package/.next-prod/static/chunks/app/api/snapshots/route-db8b43ac5e6e9ac5.js +1 -0
  496. package/.next-prod/static/chunks/app/api/terminal/aliases/route-db8b43ac5e6e9ac5.js +1 -0
  497. package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-db8b43ac5e6e9ac5.js +1 -0
  498. package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-db8b43ac5e6e9ac5.js +1 -0
  499. package/.next-prod/static/chunks/app/api/terminal/env/route-db8b43ac5e6e9ac5.js +1 -0
  500. package/.next-prod/static/chunks/app/api/terminal/history/route-db8b43ac5e6e9ac5.js +1 -0
  501. package/.next-prod/static/chunks/app/api/update/route-db8b43ac5e6e9ac5.js +1 -0
  502. package/.next-prod/static/chunks/app/api/update-state/route-db8b43ac5e6e9ac5.js +1 -0
  503. package/.next-prod/static/chunks/app/api/version/route-db8b43ac5e6e9ac5.js +1 -0
  504. package/.next-prod/static/chunks/app/apps/[...path]/route-db8b43ac5e6e9ac5.js +1 -0
  505. package/.next-prod/static/chunks/app/{layout-60f41d682cd860e9.js → layout-9585d7901d2a6c15.js} +1 -1
  506. package/.next-prod/static/chunks/app/m/{page-7eabf179a8b13f49.js → page-69cf611ceae66f33.js} +1 -1
  507. package/.next-prod/static/chunks/app/manifest.webmanifest/route-db8b43ac5e6e9ac5.js +1 -0
  508. package/.next-prod/static/chunks/app/page-340e8a5ca67a0dad.js +1 -0
  509. package/.next-prod/static/chunks/app/project/page-340e8a5ca67a0dad.js +1 -0
  510. package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-db8b43ac5e6e9ac5.js +1 -0
  511. package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-db8b43ac5e6e9ac5.js +1 -0
  512. package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-db8b43ac5e6e9ac5.js +1 -0
  513. package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-db8b43ac5e6e9ac5.js +1 -0
  514. package/.next-prod/static/css/303e8ac791ff3d31.css +1 -0
  515. package/.next-prod/trace +15 -14
  516. package/.next-prod/trace-build +1 -1
  517. package/.next-prod/types/app/api/snapshots/blob/route.ts +353 -0
  518. package/.next-prod/types/routes.d.ts +2 -1
  519. package/.next-prod/types/validator.ts +9 -0
  520. package/bin/cock-service.mjs +10 -8
  521. package/bin/cock.mjs +8 -6
  522. package/bin/postinstall.mjs +9 -8
  523. package/bin/updater.mjs +64 -26
  524. package/dist/{chunk-FBAFMLUC.mjs → chunk-6EMR3NZV.mjs} +9 -5
  525. package/dist/{chunk-ZE2JXL6E.mjs → chunk-ETYX2YQF.mjs} +141 -59
  526. package/dist/{chunk-H6AI4XJC.mjs → chunk-SGUW2QJI.mjs} +1 -1
  527. package/dist/httpApi.mjs +2 -2
  528. package/dist/scheduledTasks.mjs +187 -37
  529. package/dist/{server-HRP33LCV.mjs → server-C6LPAKPM.mjs} +2 -2
  530. package/dist/wsServer.mjs +8 -4
  531. package/package.json +6 -5
  532. package/public/html-lib/json-viewer.js +12 -12
  533. package/scripts/agentBinaries.mjs +86 -0
  534. package/.next-prod/server/chunks/9281.js +0 -1
  535. package/.next-prod/static/YOIsQRqVhYPuRyXlhwhoY/_buildManifest.js +0 -1
  536. package/.next-prod/static/chunks/33940-9631b513c48757f4.js +0 -35
  537. package/.next-prod/static/chunks/46784-031e2d50dc5f9fba.js +0 -716
  538. package/.next-prod/static/chunks/72353-f1aaa693ddc49568.js +0 -15
  539. package/.next-prod/static/chunks/app/api/chat/deepseek/route-c1a2c7e62ce669f7.js +0 -1
  540. package/.next-prod/static/chunks/app/api/chat/glm/route-c1a2c7e62ce669f7.js +0 -1
  541. package/.next-prod/static/chunks/app/api/chat/kimi/route-c1a2c7e62ce669f7.js +0 -1
  542. package/.next-prod/static/chunks/app/api/chat/ollama/route-c1a2c7e62ce669f7.js +0 -1
  543. package/.next-prod/static/chunks/app/api/chat/route-c1a2c7e62ce669f7.js +0 -1
  544. package/.next-prod/static/chunks/app/api/chat/stop/route-c1a2c7e62ce669f7.js +0 -1
  545. package/.next-prod/static/chunks/app/api/claude-stats/route-c1a2c7e62ce669f7.js +0 -1
  546. package/.next-prod/static/chunks/app/api/commands/route-c1a2c7e62ce669f7.js +0 -1
  547. package/.next-prod/static/chunks/app/api/comments/route-c1a2c7e62ce669f7.js +0 -1
  548. package/.next-prod/static/chunks/app/api/db/columns/route-c1a2c7e62ce669f7.js +0 -1
  549. package/.next-prod/static/chunks/app/api/db/connect/route-c1a2c7e62ce669f7.js +0 -1
  550. package/.next-prod/static/chunks/app/api/db/disconnect/route-c1a2c7e62ce669f7.js +0 -1
  551. package/.next-prod/static/chunks/app/api/db/export/route-c1a2c7e62ce669f7.js +0 -1
  552. package/.next-prod/static/chunks/app/api/db/query/route-c1a2c7e62ce669f7.js +0 -1
  553. package/.next-prod/static/chunks/app/api/db/schemas/route-c1a2c7e62ce669f7.js +0 -1
  554. package/.next-prod/static/chunks/app/api/deepseek/balance/route-c1a2c7e62ce669f7.js +0 -1
  555. package/.next-prod/static/chunks/app/api/deepseek/credentials/route-c1a2c7e62ce669f7.js +0 -1
  556. package/.next-prod/static/chunks/app/api/deepseek/models/route-c1a2c7e62ce669f7.js +0 -1
  557. package/.next-prod/static/chunks/app/api/dev/spans/route-c1a2c7e62ce669f7.js +0 -1
  558. package/.next-prod/static/chunks/app/api/extension/version/route-c1a2c7e62ce669f7.js +0 -1
  559. package/.next-prod/static/chunks/app/api/file/route-c1a2c7e62ce669f7.js +0 -1
  560. package/.next-prod/static/chunks/app/api/files/blame/route-c1a2c7e62ce669f7.js +0 -1
  561. package/.next-prod/static/chunks/app/api/files/clipboard/route-c1a2c7e62ce669f7.js +0 -1
  562. package/.next-prod/static/chunks/app/api/files/copy/route-c1a2c7e62ce669f7.js +0 -1
  563. package/.next-prod/static/chunks/app/api/files/delete/route-c1a2c7e62ce669f7.js +0 -1
  564. package/.next-prod/static/chunks/app/api/files/expanded/route-c1a2c7e62ce669f7.js +0 -1
  565. package/.next-prod/static/chunks/app/api/files/index/route-c1a2c7e62ce669f7.js +0 -1
  566. package/.next-prod/static/chunks/app/api/files/init/route-c1a2c7e62ce669f7.js +0 -1
  567. package/.next-prod/static/chunks/app/api/files/paste/route-c1a2c7e62ce669f7.js +0 -1
  568. package/.next-prod/static/chunks/app/api/files/read/route-c1a2c7e62ce669f7.js +0 -1
  569. package/.next-prod/static/chunks/app/api/files/readdir/route-c1a2c7e62ce669f7.js +0 -1
  570. package/.next-prod/static/chunks/app/api/files/recent/route-c1a2c7e62ce669f7.js +0 -1
  571. package/.next-prod/static/chunks/app/api/files/save/route-c1a2c7e62ce669f7.js +0 -1
  572. package/.next-prod/static/chunks/app/api/files/search/route-c1a2c7e62ce669f7.js +0 -1
  573. package/.next-prod/static/chunks/app/api/files/stat/route-c1a2c7e62ce669f7.js +0 -1
  574. package/.next-prod/static/chunks/app/api/files/text/route-c1a2c7e62ce669f7.js +0 -1
  575. package/.next-prod/static/chunks/app/api/git/blob/route-c1a2c7e62ce669f7.js +0 -1
  576. package/.next-prod/static/chunks/app/api/git/branch-diff/route-c1a2c7e62ce669f7.js +0 -1
  577. package/.next-prod/static/chunks/app/api/git/branches/route-c1a2c7e62ce669f7.js +0 -1
  578. package/.next-prod/static/chunks/app/api/git/commit-diff/route-c1a2c7e62ce669f7.js +0 -1
  579. package/.next-prod/static/chunks/app/api/git/commits/route-c1a2c7e62ce669f7.js +0 -1
  580. package/.next-prod/static/chunks/app/api/git/current-branch/route-c1a2c7e62ce669f7.js +0 -1
  581. package/.next-prod/static/chunks/app/api/git/diff/route-c1a2c7e62ce669f7.js +0 -1
  582. package/.next-prod/static/chunks/app/api/git/discard/route-c1a2c7e62ce669f7.js +0 -1
  583. package/.next-prod/static/chunks/app/api/git/stage/route-c1a2c7e62ce669f7.js +0 -1
  584. package/.next-prod/static/chunks/app/api/git/status/route-c1a2c7e62ce669f7.js +0 -1
  585. package/.next-prod/static/chunks/app/api/git/unstage/route-c1a2c7e62ce669f7.js +0 -1
  586. package/.next-prod/static/chunks/app/api/git/worktree/route-c1a2c7e62ce669f7.js +0 -1
  587. package/.next-prod/static/chunks/app/api/glm/credentials/route-c1a2c7e62ce669f7.js +0 -1
  588. package/.next-prod/static/chunks/app/api/glm/models/route-c1a2c7e62ce669f7.js +0 -1
  589. package/.next-prod/static/chunks/app/api/glm/usage/route-c1a2c7e62ce669f7.js +0 -1
  590. package/.next-prod/static/chunks/app/api/global-state/route-c1a2c7e62ce669f7.js +0 -1
  591. package/.next-prod/static/chunks/app/api/health/route-c1a2c7e62ce669f7.js +0 -1
  592. package/.next-prod/static/chunks/app/api/html-apps/[id]/route-c1a2c7e62ce669f7.js +0 -1
  593. package/.next-prod/static/chunks/app/api/html-apps/route-c1a2c7e62ce669f7.js +0 -1
  594. package/.next-prod/static/chunks/app/api/jupyter/load/route-c1a2c7e62ce669f7.js +0 -1
  595. package/.next-prod/static/chunks/app/api/jupyter/save/route-c1a2c7e62ce669f7.js +0 -1
  596. package/.next-prod/static/chunks/app/api/jupyter/shutdown/route-c1a2c7e62ce669f7.js +0 -1
  597. package/.next-prod/static/chunks/app/api/kimi/credentials/route-c1a2c7e62ce669f7.js +0 -1
  598. package/.next-prod/static/chunks/app/api/kimi/models/route-c1a2c7e62ce669f7.js +0 -1
  599. package/.next-prod/static/chunks/app/api/kimi/usage/route-c1a2c7e62ce669f7.js +0 -1
  600. package/.next-prod/static/chunks/app/api/lsp/definition/route-c1a2c7e62ce669f7.js +0 -1
  601. package/.next-prod/static/chunks/app/api/lsp/hover/route-c1a2c7e62ce669f7.js +0 -1
  602. package/.next-prod/static/chunks/app/api/lsp/references/route-c1a2c7e62ce669f7.js +0 -1
  603. package/.next-prod/static/chunks/app/api/lsp/status/route-c1a2c7e62ce669f7.js +0 -1
  604. package/.next-prod/static/chunks/app/api/lsp/warmup/route-c1a2c7e62ce669f7.js +0 -1
  605. package/.next-prod/static/chunks/app/api/mysql/columns/route-c1a2c7e62ce669f7.js +0 -1
  606. package/.next-prod/static/chunks/app/api/mysql/connect/route-c1a2c7e62ce669f7.js +0 -1
  607. package/.next-prod/static/chunks/app/api/mysql/disconnect/route-c1a2c7e62ce669f7.js +0 -1
  608. package/.next-prod/static/chunks/app/api/mysql/export/route-c1a2c7e62ce669f7.js +0 -1
  609. package/.next-prod/static/chunks/app/api/mysql/query/route-c1a2c7e62ce669f7.js +0 -1
  610. package/.next-prod/static/chunks/app/api/mysql/schemas/route-c1a2c7e62ce669f7.js +0 -1
  611. package/.next-prod/static/chunks/app/api/neo4j/connect/route-c1a2c7e62ce669f7.js +0 -1
  612. package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-c1a2c7e62ce669f7.js +0 -1
  613. package/.next-prod/static/chunks/app/api/neo4j/query/route-c1a2c7e62ce669f7.js +0 -1
  614. package/.next-prod/static/chunks/app/api/neo4j/schema/route-c1a2c7e62ce669f7.js +0 -1
  615. package/.next-prod/static/chunks/app/api/note/route-c1a2c7e62ce669f7.js +0 -1
  616. package/.next-prod/static/chunks/app/api/ollama/config/route-c1a2c7e62ce669f7.js +0 -1
  617. package/.next-prod/static/chunks/app/api/ollama/models/route-c1a2c7e62ce669f7.js +0 -1
  618. package/.next-prod/static/chunks/app/api/ollama/start/route-c1a2c7e62ce669f7.js +0 -1
  619. package/.next-prod/static/chunks/app/api/open-cursor/route-c1a2c7e62ce669f7.js +0 -1
  620. package/.next-prod/static/chunks/app/api/open-vscode/route-c1a2c7e62ce669f7.js +0 -1
  621. package/.next-prod/static/chunks/app/api/pick-folder/route-c1a2c7e62ce669f7.js +0 -1
  622. package/.next-prod/static/chunks/app/api/pinned-sessions/route-c1a2c7e62ce669f7.js +0 -1
  623. package/.next-prod/static/chunks/app/api/project-settings/route-c1a2c7e62ce669f7.js +0 -1
  624. package/.next-prod/static/chunks/app/api/project-state/route-c1a2c7e62ce669f7.js +0 -1
  625. package/.next-prod/static/chunks/app/api/projectGraph/affected/route-c1a2c7e62ce669f7.js +0 -1
  626. package/.next-prod/static/chunks/app/api/projectGraph/callees/route-c1a2c7e62ce669f7.js +0 -1
  627. package/.next-prod/static/chunks/app/api/projectGraph/callers/route-c1a2c7e62ce669f7.js +0 -1
  628. package/.next-prod/static/chunks/app/api/projectGraph/coedit/route-c1a2c7e62ce669f7.js +0 -1
  629. package/.next-prod/static/chunks/app/api/projectGraph/context/route-c1a2c7e62ce669f7.js +0 -1
  630. package/.next-prod/static/chunks/app/api/projectGraph/file/route-c1a2c7e62ce669f7.js +0 -1
  631. package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-c1a2c7e62ce669f7.js +0 -1
  632. package/.next-prod/static/chunks/app/api/projectGraph/impact/route-c1a2c7e62ce669f7.js +0 -1
  633. package/.next-prod/static/chunks/app/api/projectGraph/related/route-c1a2c7e62ce669f7.js +0 -1
  634. package/.next-prod/static/chunks/app/api/projectGraph/risk/route-c1a2c7e62ce669f7.js +0 -1
  635. package/.next-prod/static/chunks/app/api/projectGraph/search/route-c1a2c7e62ce669f7.js +0 -1
  636. package/.next-prod/static/chunks/app/api/projects/route-c1a2c7e62ce669f7.js +0 -1
  637. package/.next-prod/static/chunks/app/api/prompts/config/route-c1a2c7e62ce669f7.js +0 -1
  638. package/.next-prod/static/chunks/app/api/push/public-key/route-c1a2c7e62ce669f7.js +0 -1
  639. package/.next-prod/static/chunks/app/api/push/subscribe/route-c1a2c7e62ce669f7.js +0 -1
  640. package/.next-prod/static/chunks/app/api/push/unsubscribe/route-c1a2c7e62ce669f7.js +0 -1
  641. package/.next-prod/static/chunks/app/api/redis/command/route-c1a2c7e62ce669f7.js +0 -1
  642. package/.next-prod/static/chunks/app/api/redis/connect/route-c1a2c7e62ce669f7.js +0 -1
  643. package/.next-prod/static/chunks/app/api/redis/delete/route-c1a2c7e62ce669f7.js +0 -1
  644. package/.next-prod/static/chunks/app/api/redis/disconnect/route-c1a2c7e62ce669f7.js +0 -1
  645. package/.next-prod/static/chunks/app/api/redis/get/route-c1a2c7e62ce669f7.js +0 -1
  646. package/.next-prod/static/chunks/app/api/redis/keys/route-c1a2c7e62ce669f7.js +0 -1
  647. package/.next-prod/static/chunks/app/api/redis/set/route-c1a2c7e62ce669f7.js +0 -1
  648. package/.next-prod/static/chunks/app/api/restart/route-c1a2c7e62ce669f7.js +0 -1
  649. package/.next-prod/static/chunks/app/api/review/[id]/comments/route-c1a2c7e62ce669f7.js +0 -1
  650. package/.next-prod/static/chunks/app/api/review/[id]/replies/route-c1a2c7e62ce669f7.js +0 -1
  651. package/.next-prod/static/chunks/app/api/review/[id]/route-c1a2c7e62ce669f7.js +0 -1
  652. package/.next-prod/static/chunks/app/api/review/identify/route-c1a2c7e62ce669f7.js +0 -1
  653. package/.next-prod/static/chunks/app/api/review/order/route-c1a2c7e62ce669f7.js +0 -1
  654. package/.next-prod/static/chunks/app/api/review/route-c1a2c7e62ce669f7.js +0 -1
  655. package/.next-prod/static/chunks/app/api/review/share-info/route-c1a2c7e62ce669f7.js +0 -1
  656. package/.next-prod/static/chunks/app/api/review/users/route-c1a2c7e62ce669f7.js +0 -1
  657. package/.next-prod/static/chunks/app/api/scheduled-tasks/route-c1a2c7e62ce669f7.js +0 -1
  658. package/.next-prod/static/chunks/app/api/services/config/route-c1a2c7e62ce669f7.js +0 -1
  659. package/.next-prod/static/chunks/app/api/services/scripts/route-c1a2c7e62ce669f7.js +0 -1
  660. package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-c1a2c7e62ce669f7.js +0 -1
  661. package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-c1a2c7e62ce669f7.js +0 -1
  662. package/.next-prod/static/chunks/app/api/session-by-path/route-c1a2c7e62ce669f7.js +0 -1
  663. package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-c1a2c7e62ce669f7.js +0 -1
  664. package/.next-prod/static/chunks/app/api/sessions/projects/route-c1a2c7e62ce669f7.js +0 -1
  665. package/.next-prod/static/chunks/app/api/sessions/route-c1a2c7e62ce669f7.js +0 -1
  666. package/.next-prod/static/chunks/app/api/settings/route-c1a2c7e62ce669f7.js +0 -1
  667. package/.next-prod/static/chunks/app/api/shutdown/route-c1a2c7e62ce669f7.js +0 -1
  668. package/.next-prod/static/chunks/app/api/skills/[id]/route-c1a2c7e62ce669f7.js +0 -1
  669. package/.next-prod/static/chunks/app/api/skills/content/route-c1a2c7e62ce669f7.js +0 -1
  670. package/.next-prod/static/chunks/app/api/skills/route-c1a2c7e62ce669f7.js +0 -1
  671. package/.next-prod/static/chunks/app/api/snapshots/diff/route-c1a2c7e62ce669f7.js +0 -1
  672. package/.next-prod/static/chunks/app/api/snapshots/route-c1a2c7e62ce669f7.js +0 -1
  673. package/.next-prod/static/chunks/app/api/terminal/aliases/route-c1a2c7e62ce669f7.js +0 -1
  674. package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-c1a2c7e62ce669f7.js +0 -1
  675. package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-c1a2c7e62ce669f7.js +0 -1
  676. package/.next-prod/static/chunks/app/api/terminal/env/route-c1a2c7e62ce669f7.js +0 -1
  677. package/.next-prod/static/chunks/app/api/terminal/history/route-c1a2c7e62ce669f7.js +0 -1
  678. package/.next-prod/static/chunks/app/api/update/route-c1a2c7e62ce669f7.js +0 -1
  679. package/.next-prod/static/chunks/app/api/update-state/route-c1a2c7e62ce669f7.js +0 -1
  680. package/.next-prod/static/chunks/app/api/version/route-c1a2c7e62ce669f7.js +0 -1
  681. package/.next-prod/static/chunks/app/apps/[...path]/route-c1a2c7e62ce669f7.js +0 -1
  682. package/.next-prod/static/chunks/app/manifest.webmanifest/route-c1a2c7e62ce669f7.js +0 -1
  683. package/.next-prod/static/chunks/app/page-e83cd7365efbf878.js +0 -1
  684. package/.next-prod/static/chunks/app/project/page-e83cd7365efbf878.js +0 -1
  685. package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-c1a2c7e62ce669f7.js +0 -1
  686. package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-c1a2c7e62ce669f7.js +0 -1
  687. package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-c1a2c7e62ce669f7.js +0 -1
  688. package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-c1a2c7e62ce669f7.js +0 -1
  689. package/.next-prod/static/css/45835d91c2519c62.css +0 -1
  690. package/scripts/claudeBinary.mjs +0 -38
  691. /package/.next-prod/static/{YOIsQRqVhYPuRyXlhwhoY → MM6vZhLQFwtUo_vz7BSfe}/_ssgManifest.js +0 -0
@@ -0,0 +1,15 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[96911],{1058:(e,t,n)=>{n.d(t,{_:()=>a});var r=n(12115),s=n(90717),l=n(86957),o=n(46456);function a({cwd:e,filePath:t}){let[n,i]=(0,r.useState)([]),[c,d]=(0,r.useState)(!1),[u,h]=(0,r.useState)(null),m=(0,r.useCallback)(async()=>{if(!e||!t)return;d(!0),h(null);let n=await l.t4.runPromiseExit((0,o.lb)(e,t));if("Success"===n._tag)i(n.value.comments??[]);else{let e="Fail"===n.cause._tag?n.cause.error:null,t=e?.cause;h(t instanceof Error?t.message:"Failed to load comments")}d(!1)},[e,t]);(0,r.useEffect)(()=>{m()},[m]),(0,r.useEffect)(()=>(0,s.zL)(()=>{m()}),[m]);let f=(0,r.useCallback)(async(n,r,s,a)=>{let c=await l.t4.runPromiseExit((0,o.BC)({cwd:e,filePath:t,startLine:n,endLine:r,content:s,...a?{selectedText:a}:{}}));if("Success"===c._tag&&c.value.comment){let e=c.value.comment;return i(t=>[...t,e]),e}return"Failure"===c._tag&&console.error("Failed to add comment:",c.cause),null},[e,t]),x=(0,r.useCallback)(async(t,n)=>{let r=await l.t4.runPromiseExit((0,o.vv)(e,t,n));if("Success"===r._tag&&r.value.comment){let e=r.value.comment;return i(n=>n.map(n=>n.id===t?e:n)),!0}return"Failure"===r._tag&&console.error("Failed to update comment:",r.cause),!1},[e]),p=(0,r.useCallback)(async t=>{let n=await l.t4.runPromiseExit((0,o.Tu)(e,t));return"Success"===n._tag?(i(e=>e.filter(e=>e.id!==t)),!0):(console.error("Failed to delete comment:",n.cause),!1)},[e]),g=(0,r.useCallback)(e=>n.filter(t=>e>=t.startLine&&e<=t.endLine),[n]);return{comments:n,isLoading:c,error:u,addComment:f,updateComment:x,deleteComment:p,refresh:m,getCommentsForLine:g}}},3292:(e,t,n)=>{n.d(t,{P:()=>c});var r=n(12115),s=n(95045),l=n(75346),o=n(49433),a=n(86957),i=n(82680);function c(){let[e,t]=(0,r.useState)([]),n=(0,r.useCallback)(()=>{let e=o.tryPromise({try:async()=>{let e=await fetch("/api/pinned-sessions");return await e.json()},catch:e=>new i.uV({message:"loadPinnedSessions failed",cause:e})});a.t4.runPromise(e.pipe(o.match({onSuccess:e=>t(e.sessions||[]),onFailure:()=>{}})))},[]);(0,r.useEffect)(()=>{n()},[n]),(0,r.useEffect)(()=>{let e=e=>{e.data?.type==="PINNED_SESSIONS_CHANGED"&&n()};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[n]);let c=(0,r.useCallback)(e=>{t(e);let n=o.tryPromise({try:async()=>{await fetch("/api/pinned-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessions:e})})},catch:e=>new i.uV({message:"savePinnedSessions failed",cause:e})});a.t4.runFork(n.pipe(o.orElse(()=>o.void))),(0,s.F)(l.n.PinnedSessionsChanged,{})},[]),d=(0,r.useCallback)(t=>e.some(e=>e.sessionId===t),[e]),u=(0,r.useCallback)((t,n,r)=>{e.some(e=>e.sessionId===t)||c([...e,{sessionId:t,cwd:n,customTitle:r}])},[e,c]),h=(0,r.useCallback)(t=>{c(e.filter(e=>e.sessionId!==t))},[e,c]),m=(0,r.useCallback)((t,n)=>{c(e.map(e=>e.sessionId===t?{...e,customTitle:n}:e))},[e,c]);return{pinnedSessions:e,isPinned:d,pinSession:u,unpinSession:h,updateTitle:m,reorder:(0,r.useCallback)(e=>{c(e)},[c]),reload:n}}},4055:(e,t,n)=>{n.d(t,{h:()=>s});let r=new Set(["Read","Grep","Glob","LS","WebSearch","WebFetch","NotebookRead","TodoRead","AskUserQuestion","ExitPlanMode","TodoWrite","Skill"]),s=e=>!r.has(e)},5135:(e,t,n)=>{n.d(t,{M:()=>L});var r=n(95155),s=n(12115),l=n(79114),o=n(14341),a=n(47650),i=n(70188),c=n(34075),d=n(89109),u=n(7320),h=n(37614),m=n(1058),f=n(48347),x=n(90717),p=n(69809),g=n(13219),b=n(34582),v=n(97251),y=n(11890),w=n(47215),k=n(10794),j=n(47176),C=n(79968),N=n(27570);let S=[v.W];function L({content:e,filePath:t,cwd:n,onClose:v,sourceFile:E,embedded:M=!1,onLocalMdLink:R,scrollToAnchor:T}){let $=E||(n&&t.startsWith(n)?t.slice(n.endsWith("/")?n.length:n.length+1):t),{t:I}=(0,l.Bd)(),P=(0,i.iN)(),A=(0,f.r)(),_=(0,k.U)(),{comments:F,addComment:B,updateComment:D,deleteComment:W,refresh:O}=(0,m._)({cwd:n,filePath:t}),[V,z]=(0,s.useState)(!1),[H,U]=(0,s.useState)(null),[q,K]=(0,s.useState)(null),[Z,J]=(0,s.useState)(null),X=(0,s.useMemo)(()=>e.split("\n"),[e]),G=(0,s.useMemo)(()=>(0,b.J4)(t,n),[t,n]);(0,s.useEffect)(()=>{queueMicrotask(()=>z(!0))},[]);let[Q,Y]=(0,s.useState)(null),ee=(0,s.useRef)(null);(0,s.useEffect)(()=>{ee.current!==Q&&Y(ee.current)});let et=(0,s.useRef)({onLocalMdLink:R,sourceFile:$});et.current={onLocalMdLink:R,sourceFile:$};let en=(0,s.useRef)(e=>{let{onLocalMdLink:t,sourceFile:n}=et.current;if(!t||/^[a-z][a-z0-9+.-]*:/i.test(e))return!1;let r=e.indexOf("#"),s=r>=0?e.slice(0,r):e,l=r>=0?e.slice(r+1):null;if(!s)return!1;let o=s;try{o=decodeURIComponent(s)}catch{}return!!(0,w.e$)(o)&&(t((0,w.WU)(n,o),l),!0)}).current;(0,s.useEffect)(()=>{if(!T)return;let e=setTimeout(()=>{(0,y.O)(ee.current,T)},80);return()=>clearTimeout(e)},[T,e]);let{toolbarRef:er,bumpRef:es,clearToolbar:el}=(0,N.L)({enabled:!0,container:Q,resolveLineRange:e=>{let t=function(e){let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;if(!t||!("closest"in t))return null;let n=t.closest("[data-source-start]");if(!n)return null;let r=n.getAttribute("data-source-start"),s=n.getAttribute("data-source-end");return r&&s?{start:parseInt(r,10),end:parseInt(s,10)}:null}(e);return t?{start:t.start,end:t.end}:null},buildLineSnapshot:({start:e,end:t})=>{let n=Math.max(0,e-1),r=Math.min(X.length,t);return X.slice(n,r).join("\n")}}),eo=(0,s.useCallback)(()=>{let e=er.current;e&&(U({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),el())},[el,er]),ea=(0,s.useCallback)(()=>{let e=er.current;e&&(K({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),el())},[el,er]),ei=(0,s.useCallback)(()=>{let e=er.current;e&&A&&(el(),(0,x.Ff)(A.sendMessage,{filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot},p.A.t("explain.selectionMessage")))},[A,t,el,er]),ec=(0,s.useCallback)(async e=>{H&&(await B(H.range.start,H.range.end,e,H.selectedText),U(null))},[H,B]),ed=(0,s.useCallback)(async(e,r)=>{if(A)try{let s=await (0,x.$3)(n),l=[];for(let e of s)l.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});l.push({filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot});let o=(0,x.Gw)(l,r);A.sendMessage(o),await (0,x.RP)(n),O()}catch(e){console.error("Failed to send to AI:",e)}},[A,t,n,O]),eu=(0,s.useCallback)(e=>{q&&ed(q,e)},[q,ed]),eh=(0,s.useCallback)(e=>{H&&ed(H,e)},[H,ed]),em=(0,s.useMemo)(()=>{if(0===F.length)return[];let e=new Map;for(let t of F){let n=`${t.startLine}-${t.endLine}`;e.has(n)||e.set(n,[]),e.get(n).push(t)}return Array.from(e.entries()).map(([e,t])=>({key:e,startLine:t[0].startLine,endLine:t[0].endLine,comments:t}))},[F]),[ef,ex]=(0,s.useState)([]);return(0,s.useEffect)(()=>{if(0===em.length||!ee.current)return void queueMicrotask(()=>ex([]));let e=setTimeout(()=>{let e=ee.current;if(!e)return;let t=[],n=e.querySelectorAll("[data-source-start]");for(let r of em){let s=null,l=1/0;for(let e of n){let t=parseInt(e.getAttribute("data-source-start"),10),n=parseInt(e.getAttribute("data-source-end"),10);if(t<=r.startLine&&n>=r.endLine){let r=n-t;r<l&&(l=r,s=e)}}if(s){let n=e.getBoundingClientRect(),l=s.getBoundingClientRect();t.push({key:r.key,top:l.top-n.top+e.scrollTop,comments:r.comments})}}ex(t)},100);return()=>clearTimeout(e)},[em,e]),(0,s.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(q){K(null),e.stopPropagation();return}if(H){U(null),e.stopPropagation();return}if(er.current){er.current=null,es.current(),e.stopPropagation();return}if(Z){J(null),e.stopPropagation();return}v?.()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[q,H,Z,v]),(0,r.jsxs)(r.Fragment,{children:[!M&&(0,r.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-shrink-0",children:[(0,r.jsxs)("span",{className:"text-sm font-medium text-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-brand transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":t,onClick:()=>{navigator.clipboard.writeText(t),(0,c.oR)(I("common.copiedPath"))},children:["‎",t]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(C.ShareReviewToggle,{content:e,sourceFile:$}),(0,w.C_)(t)&&(0,r.jsx)("button",{onClick:()=>_(t.startsWith("/")||!n?t:`${n.replace(/\/$/,"")}/${t}`),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:I("skills.addTooltip"),children:(0,r.jsx)(o.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:v,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:I("common.close"),children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,r.jsx)(j.l,{content:e,containerRef:ee}),(0,r.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:ee,children:[(0,r.jsx)("div",{className:"p-6",children:(0,r.jsx)(g.T,{content:e,basePath:G,rehypePlugins:S,onLinkClick:en})}),ef.map(({key:e,top:t,comments:n})=>(0,r.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:t},onClick:e=>{e.stopPropagation(),J({comment:n[0],x:e.clientX,y:e.clientY})},children:(0,r.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-lv1 hover:bg-amber-500 transition-colors",children:n.length})},e))]})]}),V&&P&&(0,a.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.fS,{floatingToolbarRef:er,bumpRef:es,container:P,onAddComment:eo,onSendToAI:ea,onExplain:A?ei:void 0,isChatLoading:A?.isLoading}),H&&(0,r.jsx)(u.t,{x:H.x,y:H.y,range:H.range,filePath:t,lineSnapshot:H.lineSnapshot,container:P,onSubmit:ec,onSendToAI:A?eh:void 0,onClose:()=>U(null),isChatLoading:A?.isLoading}),q&&(0,r.jsx)(u.G,{x:q.x,y:q.y,range:q.range,filePath:t,lineSnapshot:q.lineSnapshot,container:P,onSubmit:eu,onClose:()=>K(null),isChatLoading:A?.isLoading}),Z&&(0,r.jsx)(h.t,{x:Z.x,y:Z.y,comment:Z.comment,container:P,onClose:()=>J(null),onUpdateComment:D,onDeleteComment:W})]}),P)]})}},7320:(e,t,n)=>{n.d(t,{G:()=>a,t:()=>o});var r=n(95155),s=n(12115),l=n(79114);function o({x:e,y:t,range:n,filePath:a,lineSnapshot:i,container:c,onSubmit:d,onSendToAI:u,onClose:h,isChatLoading:m}){let{t:f}=(0,l.Bd)(),[x,p]=(0,s.useState)(""),[g,b]=(0,s.useState)(!1),v=(0,s.useRef)(null),y=(0,s.useRef)(null),[w,k]=(0,s.useState)({x:0,y:0}),j=i?.split("\n").slice(0,5).join("\n"),C=!!i&&i.split("\n").length>5;(0,s.useEffect)(()=>{if(v.current&&c){let n=c.getBoundingClientRect(),r=v.current.getBoundingClientRect(),s=e-n.left,l=t-n.top;s+r.width>n.width-16&&(s=n.width-r.width-16),s<16&&(s=16),l+r.height>n.height-16&&(l=l-r.height-8),l<16&&(l=16),queueMicrotask(()=>k({x:s,y:l}))}},[e,t,c]),(0,s.useEffect)(()=>{y.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{g||!v.current||v.current.contains(e.target)||h()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[h,g]);let N=()=>{!g&&x.trim()&&(b(!0),d(x.trim()))};return(0,r.jsxs)("div",{ref:v,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:w.x,top:w.y},children:[(0,r.jsxs)("div",{className:"px-3 py-2 bg-amber-9/10 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-amber-11",children:f("comments.addComment")}),(n.start>0||n.end>0)&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:f("comments.lineRange",{start:n.start,end:n.end})})]}),a&&(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:a})]}),i&&(0,r.jsx)("div",{className:"px-3 py-2 border-b border-border max-h-24 overflow-hidden",children:(0,r.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[j,C&&(0,r.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,r.jsxs)("div",{className:"p-2",children:[(0,r.jsx)("textarea",{ref:y,value:x,onChange:e=>p(e.target.value),placeholder:f("comments.inputPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:g,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),N()),"Escape"!==e.key||g||h()}}),(0,r.jsxs)("div",{className:"mt-1 flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:f(g?"comments.submitting":"comments.enterSubmit")}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("button",{className:"px-3 py-1 text-xs font-medium border border-amber-11 text-amber-11 rounded-md hover:bg-amber-9/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:N,disabled:g||!x.trim(),children:f("comments.submitComment")}),u&&(0,r.jsx)("button",{className:"px-3 py-1 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:()=>{!g&&!m&&u&&x.trim()&&(b(!0),u(x.trim()),h())},disabled:g||m||!x.trim(),title:m?f("comments.aiResponding"):void 0,children:f("comments.sendToAI")})]})]})]})]})}function a({x:e,y:t,range:n,filePath:o,lineSnapshot:i,container:c,onSubmit:d,onClose:u,isChatLoading:h}){let{t:m}=(0,l.Bd)(),[f,x]=(0,s.useState)(""),p=(0,s.useRef)(null),g=(0,s.useRef)(null),[b,v]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(p.current&&c){let n=c.getBoundingClientRect(),r=p.current.getBoundingClientRect(),s=e-n.left,l=t-n.top;s+r.width>n.width-16&&(s=n.width-r.width-16),s<16&&(s=16),l+r.height>n.height-16&&(l=l-r.height-8),l<16&&(l=16),queueMicrotask(()=>v({x:s,y:l}))}},[e,t,c]),(0,s.useEffect)(()=>{g.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&u()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]);let y=i?.split("\n").slice(0,5).join("\n"),w=!!i&&i.split("\n").length>5;return(0,r.jsxs)("div",{ref:p,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:b.x,top:b.y},children:[(0,r.jsxs)("div",{className:"px-3 py-2 bg-brand/10 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-brand",children:m("comments.askAI")}),(n.start>0||n.end>0)&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:m("comments.lineRange",{start:n.start,end:n.end})})]}),o&&(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:o})]}),i&&(0,r.jsx)("div",{className:"px-3 py-2 border-b border-border max-h-24 overflow-hidden",children:(0,r.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[y,w&&(0,r.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,r.jsxs)("div",{className:"p-2",children:[(0,r.jsx)("textarea",{ref:g,value:f,onChange:e=>x(e.target.value),placeholder:m("comments.inputQuestion"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:h,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),!h&&f.trim()&&(d(f.trim()),u())),"Escape"===e.key&&u()}}),(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:m(h?"comments.aiGenerating":"comments.enterSend")})]})]})}},9573:(e,t,n)=>{n.d(t,{se:()=>a,xK:()=>o});var r=n(49433),s=n(82680);let l=e=>r.tryPromise({try:async()=>{let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status}`);return await t.json()},catch:t=>new s.uV({message:`GET ${e} failed`,cause:t})}),o=(e,t,n,s)=>l(`/api/snapshots?cwd=${encodeURIComponent(e)}&toolIds=${encodeURIComponent(t.join(","))}${n?`&sessionKey=${encodeURIComponent(n)}`:""}${s?`&runId=${encodeURIComponent(s)}`:""}`).pipe(r.map(e=>e.commits??[])),a=(e,t,n,s)=>o(e,t,n,s).pipe(r.flatMap(t=>r.all(t.map(t=>{let n;return n=t.hash,l(`/api/snapshots/diff?cwd=${encodeURIComponent(e)}&commit=${encodeURIComponent(n)}`)}),{concurrency:4})))},10794:(e,t,n)=>{n.d(t,{U:()=>c});var r=n(12115),s=n(79114),l=n(34075),o=n(48764),a=n(58250),i=n(86957);function c(){let{t:e}=(0,s.Bd)();return(0,r.useCallback)(async t=>{let n=await i.t4.runPromiseExit((0,o.L5)(t));if("Success"===n._tag)n.value.alreadyExists?(0,l.oR)(e("skills.alreadyAdded"),"info"):((0,l.oR)(e("skills.added"),"success"),(0,a.k)());else{let t="Fail"===n.cause._tag?n.cause.error:null,r=t?.cause,s=r instanceof Error?r.message:e("skills.addFailed");(0,l.oR)(s,"error")}},[e])}},14575:(e,t,n)=>{n.d(t,{o:()=>o});var r=n(95155);n(12115);let s={ts:"#3178c6",tsx:"#3178c6",js:"#f1e05a",jsx:"#61dafb",mjs:"#f1e05a",cjs:"#f1e05a",html:"#e44d26",css:"#563d7c",scss:"#cd6799",sass:"#cd6799",less:"#1d365d",vue:"#41b883",svelte:"#ff3e00",json:"#cbcb41",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4121",xml:"#e37933",env:"#ecd53f",md:"#519aba",mdx:"#519aba",txt:"#89898a",py:"#3572a5",go:"#00add8",rs:"#dea584",java:"#b07219",kt:"#a97bff",kts:"#a97bff",c:"#555555",h:"#555555",cpp:"#f34b7d",hpp:"#f34b7d",rb:"#701516",php:"#4f5d95",sh:"#89e051",bash:"#89e051",zsh:"#89e051",png:"#a074c4",jpg:"#a074c4",jpeg:"#a074c4",gif:"#a074c4",svg:"#ffb13b",webp:"#a074c4",ico:"#a074c4",lock:"#89898a",gitignore:"#f14e32",dockerfile:"#2496ed",sql:"#e38c00",graphql:"#e535ab",gql:"#e535ab",default:"#8a8a8a"},l={"package.json":"#cb3837","package-lock.json":"#cb3837","tsconfig.json":"#3178c6","jsconfig.json":"#f1e05a",".gitignore":"#f14e32",".eslintrc":"#4b32c3",".eslintrc.js":"#4b32c3",".eslintrc.json":"#4b32c3",".prettierrc":"#56b3b4",dockerfile:"#2496ed",".env":"#ecd53f",".env.local":"#ecd53f",".env.development":"#ecd53f",".env.production":"#ecd53f","readme.md":"#519aba",license:"#d4af37",makefile:"#6d8086","cargo.toml":"#dea584","go.mod":"#00add8","go.sum":"#00add8","requirements.txt":"#3572a5","yarn.lock":"#2c8ebb","pnpm-lock.yaml":"#f9ad00","vite.config.ts":"#646cff","vite.config.js":"#646cff","next.config.js":"#000000","next.config.mjs":"#000000","tailwind.config.js":"#38bdf8","tailwind.config.ts":"#38bdf8"};function o({name:e,className:t="",size:n=16}){let a,i=l[a=e.toLowerCase()]?l[a]:s[e.split(".").pop()?.toLowerCase()||""]||s.default,c=e.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(c)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,r.jsx)("path",{d:"M7 10h10M12 10v8",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):["js","jsx","mjs","cjs"].includes(c)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,r.jsx)("path",{d:"M10 10v6c0 1-1 2-2 2M14 10v4c0 2 4 2 4 0v-4",stroke:"#323330",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):"jsx"===c||"tsx"===c&&e.includes("component")?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(60 12 12)"}),(0,r.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(120 12 12)"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"2",fill:"#61dafb"})]}):"json"===c?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("path",{d:"M6 4C4 4 4 6 4 8v2c0 1-1 2-2 2 1 0 2 1 2 2v2c0 2 0 4 2 4",stroke:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,r.jsx)("path",{d:"M18 4c2 0 2 2 2 4v2c0 1 1 2 2 2-1 0-2 1-2 2v2c0 2 0 4-2 4",stroke:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:i})]}):["md","mdx"].includes(c)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("path",{d:"M5 15V9l3 4 3-4v6M17 12l-2-3v6M17 12l2-3v6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["py","pyi","pyx"].includes(c)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("path",{d:"M12 4c-4 0-4 2-4 3v2h5v1H6c-2 0-3 2-3 4s1 4 3 4h2v-2c0-2 1-3 3-3h4c1 0 2-1 2-2V7c0-2-2-3-5-3z",fill:"#3572a5"}),(0,r.jsx)("path",{d:"M12 20c4 0 4-2 4-3v-2h-5v-1h7c2 0 3-2 3-4s-1-4-3-4h-2v2c0 2-1 3-3 3h-4c-1 0-2 1-2 2v4c0 2 2 3 5 3z",fill:"#ffd43b"}),(0,r.jsx)("circle",{cx:"9",cy:"7",r:"1",fill:"white"}),(0,r.jsx)("circle",{cx:"15",cy:"17",r:"1",fill:"white"})]}):"go"===c?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6",fill:i}),(0,r.jsx)("circle",{cx:"9",cy:"11",r:"1.5",fill:"white"}),(0,r.jsx)("circle",{cx:"15",cy:"11",r:"1.5",fill:"white"}),(0,r.jsx)("circle",{cx:"9",cy:"11",r:"0.7",fill:"#333"}),(0,r.jsx)("circle",{cx:"15",cy:"11",r:"0.7",fill:"#333"})]}):"rs"===c?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:i,strokeWidth:"2",fill:"none"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:i}),(0,r.jsx)("path",{d:"M12 3v3M12 18v3M3 12h3M18 12h3",stroke:i,strokeWidth:"2",strokeLinecap:"round"})]}):["png","jpg","jpeg","gif","webp","ico","bmp"].includes(c)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("circle",{cx:"8",cy:"9",r:"2",fill:i}),(0,r.jsx)("path",{d:"M3 16l5-5 3 3 4-4 6 6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"svg"===c?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("path",{d:"M7 12 Q12 6 17 12 Q12 18 7 12",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"html"===c?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,r.jsx)("path",{d:"M8 7h8l-.5 6-3.5 1-3.5-1-.2-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["css","scss","sass","less"].includes(c)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,r.jsx)("path",{d:"M15 8H9l.3 3h5.2l-.4 4-2.1.7-2.1-.7-.1-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["yaml","yml"].includes(c)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("path",{d:"M7 8l3 4v5M17 8l-3 4v5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["sh","bash","zsh","fish"].includes(c)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",fill:"#1e1e1e",stroke:"#555",strokeWidth:"1"}),(0,r.jsx)("path",{d:"M6 9l3 3-3 3M12 15h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"gitignore"===c||".gitignore"===e.toLowerCase()?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:i}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"white"}),(0,r.jsx)("path",{d:"M12 6v3M12 15v3M6 12h3M15 12h3",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):"dockerfile"===c||"dockerfile"===e.toLowerCase()||e.toLowerCase().startsWith("dockerfile")?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("path",{d:"M3 12h3v3H3zM7 12h3v3H7zM11 12h3v3h-3zM7 8h3v3H7zM11 8h3v3h-3zM11 4h3v3h-3zM15 12h3v3h-3z",fill:i}),(0,r.jsx)("path",{d:"M21 13c-1-2-3-2-4-2h-1c0-1 0-2-2-3h-1v1c0 1-1 2-2 2H3c-1 3 0 6 2 8s5 3 9 3c5 0 8-2 10-6",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"env"===c||e.startsWith(".env")?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:i}),(0,r.jsx)("path",{d:"M12 8h6M8 12h8M8 16h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round"})]}):"sql"===c?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("ellipse",{cx:"12",cy:"7",rx:"8",ry:"3",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("path",{d:"M4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("path",{d:"M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"vue"===c?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("path",{d:"M2 4h4l6 10 6-10h4L12 22 2 4z",fill:i}),(0,r.jsx)("path",{d:"M6 4h4l2 4 2-4h4l-6 10L6 4z",fill:"#35495e"})]}):(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("path",{d:"M6 3h8l5 5v13H6V3z",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("path",{d:"M14 3v5h5",stroke:i,strokeWidth:"1.5",fill:"none"})]})}},14594:(e,t,n)=>{function r(e,t,n){return t?e?n?`${e.replace(/\n+$/,"")}
2
+
3
+ ${t}`:e+t:t:e}function s(e,t,n=!1){let r=e||[];if(!t)return r;let l=r[r.length-1];return n||l?.type!=="text"?[...r,{type:"text",text:t}]:[...r.slice(0,-1),{type:"text",text:l.text+t}]}function l(e,t,n){let{engine:l,assistantId:o}=n;if("stream_event"===t.type){let n=t.event;if(n?.type==="content_block_delta"&&n.delta?.type==="text_delta"&&n.delta.text){let t=n.delta.text;return e.map(e=>e.id===o?{...e,content:r(e.content||"",t,!!e.pendingTextBreak),parts:s(e.parts,t,!!e.pendingTextBreak),pendingTextBreak:!1}:e)}return e}if("assistant"===t.type){let n=t.message?.content;if(!Array.isArray(n))return e;let a=e,i=t.message?.model==="<synthetic>";if("codex"===l||"ollama"===l||i){let e=n.filter(e=>"text"===e.type&&e.text).map(e=>e.text).join("");e&&(a=a.map(t=>t.id===o?{...t,content:r(t.content||"",e,!!t.pendingTextBreak),parts:s(t.parts,e,!!t.pendingTextBreak),pendingTextBreak:!1}:t))}for(let e of n)if(e.name){let t={id:e.id||`tool-${o}-${e.name}`,name:e.name,input:e.input||{},isLoading:!0};a=a.map(e=>e.id!==o||e.toolCalls?.some(e=>e.id===t.id)?e:{...e,toolCalls:[...e.toolCalls||[],t],parts:function(e,t){let n=e||[];return n.some(e=>"tool"===e.type&&e.id===t)?n:[...n,{type:"tool",id:t}]}(e.parts,t.id),pendingTextBreak:!0})}return a}if("user"===t.type){let n=t.message?.content;if(!Array.isArray(n))return e;let r=e;for(let e of n)if(e.tool_use_id){let t=e.tool_use_id,n="string"==typeof e.content?e.content:JSON.stringify(e.content);r=r.map(e=>e.id===o?{...e,toolCalls:e.toolCalls?.map(e=>e.id===t?{...e,result:n,isLoading:!1}:e)}:e)}return r}if("error"===t.type){let n=t.error||"An error occurred. Please try again.",l=`⚠️ ${n}`;return e.map(e=>e.id===o?{...e,content:r(e.content||"",l,!0),parts:s(e.parts,l,!0),isStreaming:!1}:e)}if("result"===t.type){let n="string"==typeof t.result?t.result.trim():"";return e.map(e=>e.id===o?{...e,content:!e.content&&n?n:e.content,parts:!e.content&&n?s(e.parts,n):e.parts,isStreaming:!1,toolCalls:e.toolCalls?.map(e=>({...e,isLoading:!1}))}:e)}return e}n.d(t,{F:()=>l})},17196:(e,t,n)=>{n.d(t,{Np:()=>d,ZD:()=>a,ZR:()=>i,b8:()=>c,kS:()=>l,sQ:()=>o});let r=null,s=["typescript","tsx","javascript","jsx","html","css","scss","json","yaml","python","go","rust","java","ruby","php","bash","shell","markdown","sql","c","cpp","swift","kotlin","dart","lua","graphql","xml"];function l(){return r||(r=Promise.all([n.e(49304),n.e(64523)]).then(n.bind(n,64523)).then(({createHighlighter:e})=>e({themes:["github-dark","github-light"],langs:[...s]}))),r}function o(e){let t=e.split("/").pop()?.toLowerCase()||"",n=t.split(".").pop()?.toLowerCase();if(".env"===t||t.startsWith(".env.")||"dockerfile"===t||t.startsWith("dockerfile.")||"makefile"===t)return"bash";let r={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",html:"html",htm:"html",css:"css",scss:"scss",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",py:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",rb:"ruby",php:"php",cs:"cpp",cpp:"cpp",c:"c",h:"c",sh:"bash",bash:"bash",zsh:"bash",md:"markdown",mdx:"markdown",sql:"sql",swift:"swift",dart:"dart",lua:"lua",graphql:"graphql",gql:"graphql",toml:"yaml",sass:"scss",less:"css",scala:"java",r:"python",vim:"bash",env:"bash"}[n||""]||"text";return s.includes(r)?r:"text"}function a(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}let i=2e3;function c(e){return e.length>i?a(e.map(e=>e.content).join("")):e.map(e=>e.color?`<span style="color:${e.color}">${a(e.content)}</span>`:a(e.content)).join("")}function d(e,t,n,r){if(!t)return[];let s=[],l=n?t:t.toLowerCase();for(let t=0;t<e.length;t++){let o=n?e[t]:e[t].toLowerCase(),a=0;for(;;){let e=o.indexOf(l,a);if(-1===e)break;let n=e+l.length;if(r){let r=e>0?o[e-1]:" ",l=n<o.length?o[n]:" ",a=!/\w/.test(r),i=!/\w/.test(l);a&&i&&s.push({lineIndex:t,startCol:e,endCol:n})}else s.push({lineIndex:t,startCol:e,endCol:n});a=e+1}}return s}},19095:(e,t,n)=>{n.d(t,{r:()=>r});function r(e){let t=0,n=0;for(let r of e)/[\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\u{20000}-\u{2a6df}\uac00-\ud7af]/u.test(r)?t+=1:n+=1;return Math.max(1,Math.ceil(t+n/4))}},20080:(e,t,n)=>{n.d(t,{K:()=>a});var r=n(95155),s=n(12115),l=n(79114);function o({label:e,labelClassName:t,src:n,node:a,alt:i}){let{t:c}=(0,l.Bd)(),[d,u]=(0,s.useState)(!1);return(0,r.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col items-center gap-2",children:[(0,r.jsx)("div",{className:`text-xs font-medium ${t}`,children:e}),(0,r.jsx)("div",{className:"w-full flex-1 flex items-center justify-center rounded border border-border bg-secondary p-3 min-h-[8rem]",children:a??(d?(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:c("diffViewer.imageLoadFailed")}):(0,r.jsx)("img",{src:n,alt:i,onError:()=>u(!0),className:"max-w-full max-h-[60vh] object-contain"}))})]})}function a({filePath:e,oldSrc:t,newSrc:n,oldNode:s,newNode:i}){let{t:c}=(0,l.Bd)(),d=!!s||!!t,u=!!i||!!n;return(0,r.jsxs)("div",{className:"h-full overflow-auto p-4",children:[(0,r.jsx)("div",{className:"text-xs font-mono text-muted-foreground mb-3 truncate",children:e}),d||u?(0,r.jsxs)("div",{className:"flex flex-wrap items-stretch gap-4",children:[d&&(0,r.jsx)(o,{label:c(u?"diffViewer.imageBefore":"diffViewer.imageDeleted"),labelClassName:"text-red-11",src:t,node:s,alt:`${e} (before)`}),u&&(0,r.jsx)(o,{label:c(d?"diffViewer.imageAfter":"diffViewer.imageAdded"),labelClassName:"text-green-11",src:n,node:i,alt:`${e} (after)`})]}):(0,r.jsx)("div",{className:"text-sm text-muted-foreground",children:c("diffViewer.imageUnavailable")})]})}},20917:(e,t,n)=>{n.d(t,{e:()=>i});var r=n(12115),s=n(19095),l=n(14594),o=n(69809),a=n(2111);function i(e,t,{sessionId:n,cwd:c,engine:d,planMode:u,noHistory:h,ollamaModel:m,engineModel:f,claudeModel:x,claudeEffort:p,claudeContextWindow:g,claudeFastMode:b,claudeThinking:v,codexModel:y,codexReasoningEffort:w,onSessionId:k,onFetchTitle:j,onRunComplete:C}){let[N,S]=(0,r.useState)(!1),[L,E]=(0,r.useState)(null),[M,R]=(0,r.useState)(null),[T,$]=(0,r.useState)(null),[I,P]=(0,r.useState)(null),[A,_]=(0,r.useState)(null),F=(0,r.useRef)(null),[B,D]=(0,r.useState)(null),W=(0,r.useRef)(B);W.current=B;let O=(0,r.useRef)(!1),V=(0,r.useRef)(C);V.current=C;let z=(0,r.useRef)(!1),H=(0,r.useRef)(null),U=(0,r.useRef)(n);U.current=n;let q=(0,r.useRef)(null),K=(0,r.useRef)(null),Z=(0,r.useRef)(null),J=(0,r.useRef)(!1),X=(0,r.useRef)(!1),G=(0,r.useRef)(0),Q=(0,r.useCallback)(()=>{let e=q.current;if(e&&e.text){let{messageId:n,text:r}=e;t(e=>(0,l.F)(e,{type:"stream_event",event:{type:"content_block_delta",delta:{type:"text_delta",text:r}}},{engine:d,assistantId:n})),q.current={messageId:n,text:""}}K.current=null},[t,d]),Y=(0,r.useCallback)(()=>{K.current&&(clearTimeout(K.current),K.current=null),H.current&&(clearTimeout(H.current),H.current=null),Q(),S(!1),R(null),$(null);let e=W.current,n=Z.current;e&&t(t=>t.map(t=>t.id===e.assistantId||t.id===n?{...t,isStreaming:!1}:t)),D(null),V.current?.()},[Q,t]),ee=(0,r.useCallback)(()=>{let e=W.current;fetch("/api/chat/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:U.current,runId:e?.runKey})}).catch(()=>{}),Y()},[Y]),et=(0,r.useCallback)((e,n)=>{let r=e.type,a=e=>{if(O.current||"string"!=typeof e||!e)return;let t=(0,s.r)(e);R(e=>({outputTokens:(e?.outputTokens||0)+t}))};if("system"===r&&"init"===e.subtype){let n=e.session_id,r=J.current;if(k(n),U.current=n,r||($(e=>e??Date.now()),R(null),O.current=!1),_(null),r){let e=`auto-asst-${++G.current}`;Z.current=e,t(t=>[...t,{id:e,role:"assistant",content:"",toolCalls:[],isStreaming:!0,runKey:W.current?.runKey,runId:W.current?.runId}])}X.current=!0;return}if("system"===r&&"task_notification"===e.subtype){if(!X.current){let n=e.status,r=e.summary||"",s=e.task_id,l=`<task-notification>
4
+ `+(s?`<task-id>${s}</task-id>
5
+ `:"")+(n?`<status>${n}</status>
6
+ `:"")+(r?`<summary>${r}</summary>
7
+ `:"")+(e.output_file?`<output-file>${e.output_file}</output-file>
8
+ `:"")+"</task-notification>",o=`auto-tasknotif-${s||++G.current}`;t(e=>[...e,{id:o,role:"system",content:r,systemEvent:{kind:"task-notification",...n?{status:n}:{},detail:l},runKey:W.current?.runKey}])}return}if("system"===r&&"api_retry"===e.subtype)return void _({attempt:e.attempt??0,maxRetries:e.max_retries??0,delayMs:e.retry_delay_ms??0,errorStatus:e.error_status,error:e.error});if("rate_limit_event"===r){let t=e.rate_limit_info;t&&P({status:t.status||"allowed",resetsAt:t.resetsAt,rateLimitType:t.rateLimitType,utilization:t.utilization,overageStatus:t.overageStatus,overageDisabledReason:t.overageDisabledReason,isUsingOverage:t.isUsingOverage,surpassedThreshold:t.surpassedThreshold});return}if("usage_update"===r){let t=e.output_tokens;if("number"==typeof t&&Number.isFinite(t)){O.current=!0;let e=Math.max(0,Math.round(t));R(t=>({outputTokens:Math.max(t?.outputTokens||0,e)}))}return}if("error"===r){let r=e.error||o.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});_(null),K.current&&(clearTimeout(K.current),K.current=null),Q(),t(e=>e.map(e=>e.id===n?{...e,content:e.content?`${e.content}
9
+
10
+ ⚠️ ${r}`:`⚠️ ${r}`,isStreaming:!1}:e));return}if("stream_event"===r){_(e=>e?null:e);let t=e.event;if(t?.type==="content_block_delta"&&t.delta?.type==="text_delta"){let e=t.delta.text||"";a(e),q.current&&q.current.messageId===n?q.current.text+=e:q.current={messageId:n,text:e},K.current||(K.current=setTimeout(Q,50))}return}if("assistant"===r){let r=e.message?.content;if(Array.isArray(r))for(let e of r)e.text?a(e.text):e.name&&a(`${e.name} ${JSON.stringify(e.input??{})}`);t(t=>(0,l.F)(t,e,{engine:d,assistantId:n}))}if("user"===r){let r=e.message?.content;if(Array.isArray(r))for(let e of r)a("string"==typeof e.content?e.content:JSON.stringify(e.content??""));t(t=>(0,l.F)(t,e,{engine:d,assistantId:n}))}if("result"===r){X.current=!1,J.current=!0,_(null),K.current&&(clearTimeout(K.current),K.current=null),Q();let r=U.current;r&&c&&t(e=>(2===e.length&&j(r),e));let s=e.usage,o=e.total_cost_usd;s&&E({inputTokens:s.input_tokens||0,outputTokens:s.output_tokens||0,cacheCreationInputTokens:s.cache_creation_input_tokens||0,cacheReadInputTokens:s.cache_read_input_tokens||0,totalCostUsd:o||0}),t(t=>(0,l.F)(t,e,{engine:d,assistantId:n}))}},[t,Q,k,j,c,d]);return(0,a.h)({url:B?`/ws/session-stream?sessionId=${encodeURIComponent(B.runKey)}`:"/ws/session-stream",enabled:!!B,onMessage:e=>{z.current=!0,H.current&&(clearTimeout(H.current),H.current=null);let n=W.current;if(n)if("run-snapshot"===e.type&&Array.isArray(e.events)){K.current&&(clearTimeout(K.current),K.current=null),q.current=null,Z.current=n.assistantId,J.current=!1,X.current=!1,O.current=!1,R(null);let r="number"==typeof e.outputTokens&&Number.isFinite(e.outputTokens)?Math.max(0,Math.round(e.outputTokens)):null;for(let s of(null!==r&&(O.current=!0,R({outputTokens:r})),t(e=>e.filter(e=>!("string"==typeof e.id&&e.id.startsWith("auto-")&&e.runKey===n.runKey)).map(e=>e.id===n.assistantId?{...e,content:"",toolCalls:[]}:e)),e.events))et(s,Z.current??n.assistantId);e.status&&"running"!==e.status&&Y()}else if("run-event"===e.type&&e.message){if("run-ended"===e.message.type)return void Y();et(e.message,Z.current??n.assistantId)}else"run-idle"===e.type&&Y()}}),{isLoading:N,tokenUsage:L,liveOutputTokens:M,runningStartedAt:T,rateLimitInfo:I,apiRetryInfo:A,handleSend:(0,r.useCallback)(async(e,n,r)=>{let s=r&&"permissionMode"in r?"plan"===r.permissionMode:u,l=n?.map(e=>({type:"base64",media_type:e.media_type,data:e.data})),a={id:`user-${Date.now()}`,role:"user",content:e,images:l};t(e=>[...e,a]),S(!0),R(null),O.current=!1,$(Date.now()),_(null);let i=function(){try{return crypto.randomUUID()}catch{return`run-${Date.now()}-${Math.floor(1e9*Math.random())}`}}(),k=`assistant-${Date.now()}`,j={id:k,role:"assistant",content:"",toolCalls:[],isStreaming:!0,runId:i};t(e=>[...e,j]),Z.current=k,J.current=!1,X.current=!1;let C=!d||"claude"===d,N="deepseek"===d||"kimi"===d||"glm"===d,L="ollama"===d||N||C||"codex"===d;try{if("ollama"===d&&!m)throw Error("Please select an Ollama model first (click the model picker above)");let n="codex"===d?"/api/chat/codex":"kimi"===d?"/api/chat/kimi":"ollama"===d?"/api/chat/ollama":"deepseek"===d?"/api/chat/deepseek":"glm"===d?"/api/chat/glm":"/api/chat",r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,sessionId:U.current,runId:i,images:l,cwd:c,language:o.A.language,..."ollama"===d&&m&&{model:m},...N&&f&&{model:f},...C&&x&&{model:x},...C&&p&&{claudeEffort:p},...C&&g&&{claudeContextWindow:g},...C&&void 0!==b&&{claudeFastMode:b},...C&&void 0!==v&&{claudeThinking:v},..."codex"===d&&y&&{model:y},..."codex"===d&&w&&{codexReasoningEffort:w},...s&&C&&{permissionMode:"plan"},...L&&h&&{noHistory:!0}})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(e?.error||o.A.t("chat.requestFailed",{defaultValue:"Request failed"}))}let a=await r.json().catch(()=>({}));D({runKey:a.runKey||i,assistantId:k,runId:i}),z.current=!1,H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{W.current&&!z.current&&(t(e=>e.map(e=>e.id!==k||e.content?e:{...e,content:o.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."})})),Y())},15e3)}catch(n){console.error("Chat error:",n);let e=n instanceof Error?n.message:o.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});t(t=>t.map(t=>t.id===k?{...t,content:e,isStreaming:!1}:t)),S(!1),D(null)}},[c,d,u,h,m,f,x,p,g,b,v,y,w,t,Y]),handleStop:ee,abortControllerRef:F}}},22576:(e,t,n)=>{n.d(t,{X:()=>r});function r(e,t){let n=e.split("\n"),r=t.split("\n"),s=[],l=n.length,o=r.length,a=Array(l+1).fill(null).map(()=>Array(o+1).fill(0));for(let e=1;e<=l;e++)for(let t=1;t<=o;t++)n[e-1]===r[t-1]?a[e][t]=a[e-1][t-1]+1:a[e][t]=Math.max(a[e-1][t],a[e][t-1]);let i=l,c=o,d=[];for(;i>0||c>0;)i>0&&c>0&&n[i-1]===r[c-1]?(d.push({type:"unchanged",content:n[i-1],oldLineNum:i,newLineNum:c}),i--,c--):c>0&&(0===i||a[i][c-1]>=a[i-1][c])?(d.push({type:"added",content:r[c-1],newLineNum:c}),c--):(d.push({type:"removed",content:n[i-1],oldLineNum:i}),i--);for(;d.length>0;)s.push(d.pop());return s}},24602:(e,t,n)=>{n.d(t,{N:()=>N});var r=n(95155),s=n(12115),l=n(79114),o=n(64428),a=n(34075),i=n(14341),c=n(42804),d=n(22164),u=n(34582),h=n(85269),m=n(86304),f=n(17243),x=n(28132),p=n(86957),g=n(38408),b=n(60938),v=n(51145);let y=new Set(["png","jpg","jpeg","gif","webp","svg","ico","bmp","avif"]),w=new Set(["js","mjs","cjs","jsx","ts","tsx","css","json","html","htm","md","markdown","txt","yml","yaml","sh","bash","xml","csv"]),k=e=>{let t=e.replace(/\\/g,"/");return t.slice(t.lastIndexOf("/")+1)},j=e=>{let t,n,r=(n=(t=k(e).toLowerCase()).lastIndexOf("."))<0?"":t.slice(n+1);return y.has(r)?"image":w.has(r)?"text":null};function C({entryPath:e,entryContent:t}){let n=(0,s.useMemo)(()=>{let t,n;return(n=(t=e.replace(/\\/g,"/")).lastIndexOf("/"))<=0?"/":t.slice(0,n)},[e]),l=e=>e.startsWith(n+"/")?e.slice(n.length+1):k(e),o=(0,s.useRef)(new Map),[a,i]=(0,s.useState)([]),[c,d]=(0,s.useState)(e),[u,h]=(0,s.useState)(!0);(0,s.useEffect)(()=>{o.current=new Map([[e,t]]);let r={abs:e,rel:k(e),kind:"text"};i([r]),d(e),h(!0);let s=!1;return(async()=>{let a=new Set([e]),c=[r],d=[t];for(;d.length&&c.length<40&&!s;)for(let e of function(e){let t,n=/(?<![.\w])\.\/([\w./-]+\.\w+)/g,r=new Set;for(;null!==(t=n.exec(e));)r.add(t[1]);return[...r]}(d.shift())){if(c.length>=40)break;let t=function(e,t){let n=e.replace(/\\/g,"/").replace(/\/+$/,""),r=[];for(let e of(n+"/"+t).split("/"))if(""!==e&&"."!==e){if(".."===e){if(!r.length)return null;r.pop();continue}r.push(e)}let s="/"+r.join("/");return s===n||s.startsWith(n+"/")?s:null}(n,e);if(!t||a.has(t))continue;a.add(t);let r=j(t);if(r)if("image"===r){let e=await p.t4.runPromise((0,b.r6)(n,t)).catch(()=>null);e?.ok&&e.data&&!s&&(c.push({abs:t,rel:l(t),kind:r}),i([...c]))}else{let e=await p.t4.runPromise((0,v.K)(n,t)).catch(()=>null);e?.ok&&e.data?.content!=null&&(o.current.set(t,e.data.content),d.push(e.data.content),s||(c.push({abs:t,rel:l(t),kind:r}),i([...c])))}}s||h(!1)})(),()=>{s=!0}},[e,t,n]);let m=a.find(e=>e.abs===c),y=a.length>1||u;return(0,r.jsxs)("div",{className:"flex h-full",children:[y&&(0,r.jsxs)("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto",children:[a.map(e=>(0,r.jsxs)("button",{onClick:()=>d(e.abs),"data-tooltip":e.rel,className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 min-w-0 transition-colors ${c===e.abs?"bg-accent text-foreground":"text-muted-foreground hover:bg-hover"}`,children:["image"===e.kind?(0,r.jsx)(f.A,{className:"w-3.5 h-3.5 flex-shrink-0"}):(0,r.jsx)(x.A,{className:"w-3.5 h-3.5 flex-shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:e.rel})]},e.abs)),u&&(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"…"})]}),(0,r.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:m?.kind==="image"?(0,r.jsx)("div",{className:"h-full flex items-center justify-center p-4 overflow-auto bg-background",children:(0,r.jsx)("img",{src:`/api/file?path=${encodeURIComponent(c)}&raw=true`,alt:k(c),className:"max-w-full max-h-full object-contain"})}):(0,r.jsx)(g.Cv,{content:o.current.get(c)??"",filePath:c,cwd:n},c)})]})}function N({filePath:e,content:t,cwd:n,onClose:f,onContentSearch:x}){let{t:p}=(0,l.Bd)(),g=(0,m.P)(),[b,v]=(0,s.useState)("preview");return(0,r.jsx)(o.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:f,children:(0,r.jsxs)("div",{className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("span",{className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":e,onClick:()=>{navigator.clipboard.writeText(e),(0,a.oR)(p("common.copiedPath"))},children:["‎",e]}),(0,r.jsx)("button",{onClick:()=>v(e=>"preview"===e?"source":"preview"),className:`px-1.5 py-0.5 text-xs rounded transition-colors flex-shrink-0 ${"preview"===b?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:"preview"===b?p("fileBrowser.exitPreview"):p("common.preview")}),(0,r.jsx)("button",{onClick:()=>g(e),title:p("htmlApps.addTooltip"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,r.jsx)(i.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:()=>{window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:e}})),f()},title:p("common.openInConsole"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,r.jsx)(c.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:()=>{let t=(0,u.Xe)(e,n);window.open((0,u.PB)(t,window.location.origin),"_blank")},title:p("browser.openInNewWindow"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,r.jsx)(d.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:f,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:"preview"===b?(0,r.jsx)(h.O,{content:t,filePath:e,cwd:n,onContentSearch:x?e=>{x(e),f()}:void 0}):(0,r.jsx)(C,{entryPath:e,entryContent:t,cwd:n})})]})})})}},27570:(e,t,n)=>{n.d(t,{L:()=>s});var r=n(12115);function s({enabled:e,container:t,resolveLineRange:n,buildLineSnapshot:l,dragThresholdPx:o=5}){let a=(0,r.useRef)(null),i=(0,r.useRef)(()=>{}),c=(0,r.useRef)(n),d=(0,r.useRef)(l),u=(0,r.useRef)(o);return c.current=n,d.current=l,u.current=o,(0,r.useEffect)(()=>{if(!e||!t)return;let n=!1,r=0,s=0,l=()=>{a.current&&(a.current=null,i.current())},o=e=>{n=!0,r=e.clientX,s=e.clientY;let t=e.target;t?.closest?.(".floating-toolbar")||l()},h=e=>{n=!1;let o=e.target;if(o?.closest?.(".floating-toolbar"))return;let h=u.current,m=Math.abs(e.clientX-r)>h||Math.abs(e.clientY-s)>h,f=window.getSelection();if(!f||f.isCollapsed||!f.toString().trim()||!m)return void l();let x=f.getRangeAt(0);if(!t.contains(x.commonAncestorContainer))return void l();let p=c.current(x.startContainer),g=c.current(x.endContainer);if(!p||!g)return void l();let b=Math.min(p.start,g.start),v=Math.max(p.end,g.end),y=f.toString(),w=d.current({start:b,end:v});a.current={x:e.clientX,y:e.clientY,range:{start:b,end:v},selectedText:y,lineSnapshot:w},i.current()},m=()=>{if(n||!a.current)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||l()};return t.addEventListener("mousedown",o),document.addEventListener("mouseup",h),document.addEventListener("selectionchange",m),()=>{t.removeEventListener("mousedown",o),document.removeEventListener("mouseup",h),document.removeEventListener("selectionchange",m)}},[e,t]),{toolbarRef:a,bumpRef:i,clearToolbar:()=>{a.current&&(a.current=null,i.current())}}}},30133:(e,t,n)=>{n.d(t,{y:()=>l});var r=n(95155),s=n(79114);function l({value:e,onChange:t,className:n}){let{t:o}=(0,s.Bd)();return(0,r.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${n??""}`,children:["compact","full"].map(n=>(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),t(n)},className:`px-2 py-0.5 text-xs transition-colors ${e===n?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:o("compact"===n?"diffViewer.compact":"diffViewer.full")},n))})}},32041:(e,t,n)=>{n.d(t,{C0:()=>h});var r=n(95155),s=n(12115),l=n(61878),o=n(33210),a=n(9921),i=n(66088),c=n(79114);let d=/^-?[\d,]*\.?\d+%?$/;function u(e){return d.test(e)?parseFloat(e.replace(/,/g,"")):NaN}function h({content:e,filePath:t,className:n="",action:m}){let{t:f}=(0,c.Bd)(),[x,p]=(0,s.useState)(500),[g,b]=(0,s.useState)(""),[v,y]=(0,s.useState)(-1),[w,k]=(0,s.useState)(null),{header:j,body:C,columnCount:N}=(0,s.useMemo)(()=>{let n=(function(e,t){let n=[],r=[],s="",l=!1,o=!1,a=()=>{r.push(s),n.push(r),r=[],s="",o=!1};for(let n=0;n<e.length;n++){let i=e[n];if(l){if('"'!==i){s+=i;continue}'"'===e[n+1]?(s+='"',n++):l=!1;continue}if('"'===i&&""===s){l=!0,o=!0;continue}if(i===t){r.push(s),s="",o=!0;continue}if("\r"===i){"\n"===e[n+1]&&n++,a();continue}if("\n"===i){a();continue}s+=i,o=!0}return(o||""!==s||r.length>0)&&a(),n})(e,function(e,t){if(t&&/\.tsv$/i.test(t))return" ";let n=e.slice(0,65536),r={",":0,";":0," ":0,"|":0},s=!1,l=0;for(let e=0;e<n.length&&l<5;e++){let t=n[e];if('"'===t){s=!s;continue}if(!s){if("\n"===t){l++;continue}t in r&&r[t]++}}let o=Object.entries(r).sort((e,t)=>t[1]-e[1])[0];return o[1]>0?o[0]:","}(e,t)).filter(e=>e.length>1||""!==e[0]),r=n.reduce((e,t)=>Math.max(e,t.length),0),s=n.slice(1).map((e,t)=>({index:t,cells:e}));return{header:n[0]??[],body:s,columnCount:r}},[e,t]);(0,s.useEffect)(()=>{p(500),b(""),y(-1),k(null)},[e,t]);let S=(0,s.useMemo)(()=>{let e=g.trim().toLowerCase();return e?C.filter(t=>v>=0?(t.cells[v]??"").toLowerCase().includes(e):t.cells.some(t=>t.toLowerCase().includes(e))):C},[C,g,v]),L=(0,s.useMemo)(()=>{if(!w)return S;let e="asc"===w.dir?1:-1;return[...S].sort((t,n)=>(function(e,t,n){if(""===e||""===t)return e===t?0:""===e?1:-1;let r=u(e),s=u(t);return isNaN(r)||isNaN(s)?e.localeCompare(t,void 0,{numeric:!0})*n:(r-s)*n})(t.cells[w.col]??"",n.cells[w.col]??"",e))},[S,w]);(0,s.useEffect)(()=>{p(500)},[g,v]);let E=(0,s.useCallback)(e=>{k(t=>t&&t.col===e?"asc"===t.dir?{col:e,dir:"desc"}:null:{col:e,dir:"asc"})},[]);if(0===N)return(0,r.jsx)("div",{className:`flex items-center justify-center ${n}`,children:(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:f("csv.empty")})});let M=L.slice(0,x);return(0,r.jsxs)("div",{className:`flex flex-col min-h-0 ${n}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 flex-1 min-w-0 px-1.5 py-0.5 rounded border border-border bg-card focus-within:border-brand transition-colors",children:[(0,r.jsx)(l.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0","aria-hidden":!0}),(0,r.jsx)("input",{value:g,onChange:e=>b(e.target.value),placeholder:f("csv.filterPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs text-foreground placeholder:text-muted-foreground outline-none"}),g&&(0,r.jsx)("button",{onClick:()=>b(""),className:"text-muted-foreground hover:text-foreground flex-shrink-0",title:f("csv.clearFilter"),children:(0,r.jsx)(o.A,{className:"w-3.5 h-3.5"})})]}),(0,r.jsxs)("select",{value:v,onChange:e=>y(Number(e.target.value)),className:"text-xs bg-card text-muted-foreground border border-border rounded px-1 py-1 max-w-[10rem] flex-shrink-0",title:f("csv.filterColumn"),children:[(0,r.jsx)("option",{value:-1,children:f("csv.allColumns")}),Array.from({length:N},(e,t)=>(0,r.jsx)("option",{value:t,children:j[t]||`#${t+1}`},t))]}),m&&(0,r.jsx)("button",{onClick:m.onClick,className:"text-xs px-2 py-1 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:m.label})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-auto",children:[(0,r.jsxs)("table",{className:"text-xs border-collapse w-max min-w-full",children:[(0,r.jsx)("thead",{className:"sticky top-0 z-10",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"sticky left-0 z-20 bg-accent border-b border-r border-border px-2 py-1.5 text-right font-normal text-muted-foreground select-none",children:"#"}),Array.from({length:N},(e,t)=>(0,r.jsx)("th",{onClick:()=>E(t),className:"bg-accent border-b border-border px-2 py-1.5 text-left font-medium text-foreground whitespace-nowrap cursor-pointer select-none hover:bg-hover",title:f("csv.sortHint"),children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[j[t]??"",w?.col===t&&("asc"===w.dir?(0,r.jsx)(a.A,{className:"w-3 h-3 text-brand","aria-hidden":!0}):(0,r.jsx)(i.A,{className:"w-3 h-3 text-brand","aria-hidden":!0}))]})},t))]})}),(0,r.jsx)("tbody",{children:M.map(e=>(0,r.jsxs)("tr",{className:"hover:bg-hover",children:[(0,r.jsx)("td",{className:"sticky left-0 bg-card border-b border-r border-border px-2 py-1 text-right text-muted-foreground tabular-nums select-none",children:e.index+1}),Array.from({length:N},(t,n)=>{let s=e.cells[n]??"";return(0,r.jsx)("td",{title:s.length>60?s:void 0,className:`border-b border-border px-2 py-1 max-w-[28rem] truncate text-foreground ${d.test(s)?"text-right tabular-nums":""}`,children:s},n)})]},e.index))})]}),0===M.length&&(0,r.jsx)("div",{className:"p-4 text-xs text-muted-foreground",children:f("csv.noMatch")})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3 px-3 py-1.5 border-t border-border text-xs text-muted-foreground flex-shrink-0",children:[(0,r.jsx)("span",{children:S.length===C.length?f("csv.summary",{rows:C.length,cols:N}):f("csv.summaryFiltered",{rows:S.length,total:C.length,cols:N})}),M.length<L.length&&(0,r.jsx)("button",{onClick:()=>p(e=>e+500),className:"px-1.5 py-0.5 rounded hover:bg-hover hover:text-foreground transition-colors",children:f("csv.loadMore",{shown:M.length,total:L.length})})]})]})}},37614:(e,t,n)=>{n.d(t,{t:()=>o});var r=n(95155),s=n(12115),l=n(79114);function o({x:e,y:t,comment:n,container:a,onClose:i,onUpdateComment:c,onDeleteComment:d}){let{t:u}=(0,l.Bd)(),[h,m]=(0,s.useState)(!1),[f,x]=(0,s.useState)(n.content),p=(0,s.useRef)(null),[g,b]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(p.current&&a){let n=a.getBoundingClientRect(),r=p.current.getBoundingClientRect(),s=e-n.left,l=t-n.top;s+r.width>n.width-16&&(s=n.width-r.width-16),s<16&&(s=16),l+r.height>n.height-16&&(l=l-r.height-8),l<16&&(l=16),queueMicrotask(()=>b({x:s,y:l}))}},[e,t,a]),(0,s.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&i()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let v=async()=>{f.trim()&&(await c(n.id,f.trim()),m(!1))},y=async()=>{await d(n.id),i()};return(0,r.jsx)("div",{ref:p,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:g.x,top:g.y},children:(0,r.jsx)("div",{className:"p-3",children:h?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("textarea",{value:f,onChange:e=>x(e.target.value),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring",rows:3,autoFocus:!0,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),v()),"Escape"===e.key&&(m(!1),x(n.content))}}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{onClick:()=>{m(!1),x(n.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:u("common.cancel")}),(0,r.jsx)("button",{onClick:v,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:u("common.save")})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.content}),(0,r.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:u("comments.lineRange",{start:n.startLine,end:n.endLine})}),(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)("button",{onClick:()=>m(!0),className:"p-1 rounded hover:bg-hover text-muted-foreground",title:u("common.edit"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,r.jsx)("button",{onClick:y,className:"p-1 rounded hover:bg-hover text-muted-foreground hover:text-red-9",title:u("common.delete"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]})]})})})}},38408:(e,t,n)=>{n.d(t,{Cv:()=>A,XO:()=>_});var r=n(95155),s=n(12115),l=n(79114),o=n(47650),a=n(86957),i=n(60938),c=n(51145),d=n(70188),u=n(7320),h=n(56978),m=n(17196),f=n(89109),x=n(37614),p=n(69809),g=n(64428),b=n(96497);function v({blame:e,onClick:t}){let{t:n}=(0,l.Bd)(),o=(0,s.useRef)(null),a=(0,s.useRef)(null),i=(0,g.F2)(),c=(0,s.useRef)(!1),d=(0,s.useRef)(!1),u=(0,s.useRef)(null),h=(0,s.useRef)(null),m=(0,s.useRef)(null),f=(0,s.useRef)(e);(0,s.useEffect)(()=>{f.current=e},[e]);let x=(0,s.useRef)(t);(0,s.useEffect)(()=>{x.current=t},[t]);let b=(0,s.useCallback)(()=>{let e,t=a.current,n=o.current;if(!t||!n)return;let r=n.getBoundingClientRect(),s=t.getBoundingClientRect(),l=i?.getBoundingClientRect(),c=l?.left??0,d=l?.top??0,u=l?.width??window.innerWidth,h=l?.height??window.innerHeight,m=r.left-c;m+s.width>u-8&&(m=u-s.width-8),m<8&&(m=8);let f=r.top-d,x=r.bottom-d;(e=f-s.height-4<0?x+4:f-s.height-4)+s.height>h-8&&(e=h-s.height-8),t.style.left=`${m}px`,t.style.top=`${e}px`},[i]),y=(0,s.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),h.current&&(clearTimeout(h.current),h.current=null),c.current=!1,d.current=!1,a.current&&(a.current.style.display="none"),m.current&&(document.removeEventListener("mousedown",m.current.down),document.removeEventListener("mouseup",m.current.up),m.current=null)},[]),w=(0,s.useCallback)(()=>{let e=a.current;if(!e||c.current)return;c.current=!0,e.style.left="-9999px",e.style.top="-9999px",e.style.display="block",requestAnimationFrame(()=>requestAnimationFrame(b));let t=0,n=0,r=e=>{t=e.clientX,n=e.clientY},s=e=>{if(!(Math.abs(e.clientX-t)>5||Math.abs(e.clientY-n)>5)){let t;t=e.target,a.current?.contains(t)||o.current?.contains(t)||y()}};document.addEventListener("mousedown",r),document.addEventListener("mouseup",s),m.current={down:r,up:s}},[b,y]),k=(0,s.useCallback)(()=>{if(u.current&&clearTimeout(u.current),h.current&&(clearTimeout(h.current),h.current=null),c.current)return;let e=window.getSelection();(!e||e.isCollapsed)&&(u.current=setTimeout(w,500))},[w]),j=(0,s.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),c.current&&(h.current=setTimeout(()=>{d.current||y()},200))},[y]),C=(0,s.useCallback)(()=>{d.current=!0,h.current&&(clearTimeout(h.current),h.current=null)},[]),N=(0,s.useCallback)(()=>{d.current=!1,y()},[y]),S=(0,s.useCallback)(e=>{e.stopPropagation();let t=window.getSelection();t&&t.toString().length>0&&a.current?.contains(t.anchorNode)||(x.current?.(f.current),y())},[y]);(0,s.useEffect)(()=>()=>y(),[y]);let L=e.message.split("\n")[0]||"",E=e.message.split("\n").slice(1).join("\n").trim();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{ref:o,className:"select-none text-xs text-muted-foreground/50 ml-6 cursor-default hover:text-muted-foreground/80",onMouseEnter:k,onMouseLeave:j,children:[e.author.split(" ")[0],", ",function(e){let t=p.A.t,n=Math.floor((Date.now()-1e3*e)/1e3);if(n<60)return t("common.justNow");let r=Math.floor(n/60);if(r<60)return t("common.minutesAgo",{count:r});let s=Math.floor(r/60);if(s<24)return t("common.hoursAgo",{count:s});let l=Math.floor(s/24);if(l<30)return t("common.daysAgo",{count:l});let o=Math.floor(l/30);return o<12?t("common.monthsAgo",{count:o}):t("common.yearsAgo",{count:Math.floor(o/12)})}(e.time)," \xb7 ",L]}),(0,r.jsx)(g.ZL,{children:(0,r.jsxs)("div",{ref:a,className:"fixed z-[9999] bg-card border border-border rounded-lg shadow-lv3 p-3 text-xs text-foreground whitespace-pre-wrap max-w-md select-text",style:{display:"none",minWidth:280,cursor:"text"},"data-inline-blame-tip":"",onMouseEnter:C,onMouseLeave:N,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,r.jsx)("span",{className:"font-mono text-brand",children:e.hash}),(0,r.jsx)("span",{className:"text-muted-foreground",children:e.author}),(0,r.jsx)("span",{className:"text-muted-foreground/60",children:new Date(1e3*e.time).toLocaleString()})]}),(0,r.jsx)("div",{className:"font-medium",children:L}),E&&(0,r.jsx)("div",{className:"mt-1 text-muted-foreground",children:E}),(0,r.jsx)("div",{className:"mt-2 text-[11px] text-brand border-t border-border pt-2 cursor-pointer hover:underline",onClick:S,children:n("codeViewer.clickToViewDetails")})]})})]})}let y=[{bg:"rgba(59, 130, 246, 0.15)",border:"rgb(59, 130, 246)"},{bg:"rgba(16, 185, 129, 0.15)",border:"rgb(16, 185, 129)"},{bg:"rgba(245, 158, 11, 0.15)",border:"rgb(245, 158, 11)"},{bg:"rgba(239, 68, 68, 0.15)",border:"rgb(239, 68, 68)"},{bg:"rgba(168, 85, 247, 0.15)",border:"rgb(168, 85, 247)"},{bg:"rgba(236, 72, 153, 0.15)",border:"rgb(236, 72, 153)"},{bg:"rgba(20, 184, 166, 0.15)",border:"rgb(20, 184, 166)"},{bg:"rgba(249, 115, 22, 0.15)",border:"rgb(249, 115, 22)"}],w=(0,s.memo)(function({virtualKey:e,lineNum:t,highlightedHtml:n,hasComments:o,firstComment:a,lineCommentsCount:i,isInRange:c,showLineNumbers:d,lineNumChars:u,commentsEnabled:h,virtualItemSize:m,virtualItemStart:f,onCommentBubbleClick:x,onCmdClick:p,onTokenHover:g,onTokenHoverLeave:y,flashLine:w,blameLine:k,showBlameInfo:j,blameAuthorColor:C,isBlameHovered:N,onBlameClick:S,onBlameMouseEnter:L,onBlameMouseLeave:E,inlineBlameData:M,onInlineBlameClick:R,isCursorLine:T,cursorCol:$}){let{t:I}=(0,l.Bd)(),P=(0,s.useMemo)(()=>T&&null!=$?function(e,t){let n=0,r=0;for(;r<e.length;){if("<"===e[r]){let t=e.indexOf(">",r);if(-1!==t){r=t+1;continue}}if(n===t){let t;if("&"===e[r]){let n=e.indexOf(";",r);t=-1!==n&&n-r<10?n+1:r+1}else t=r+1;let n=e.substring(r,t);return e.substring(0,r)+'<span class="vi-char-cursor">'+n+"</span>"+e.substring(t)}if("&"===e[r]){let t=e.indexOf(";",r);r=-1!==t&&t-r<10?t+1:r+1}else r++;n++}return e+'<span class="vi-char-cursor"> </span>'}(n,$):n,[n,T,$]),A=(0,s.useCallback)(e=>{if(!e.metaKey||!p)return;e.preventDefault(),e.stopPropagation();let n=e.currentTarget,r=(0,b.j)(e,n);window.getSelection()?.removeAllRanges(),p(t,r)},[t,p]),_=(0,s.useCallback)(e=>{if(!g)return;let n=(0,b.A)(e,e.currentTarget);n&&g(t,n.column,n.rect)},[t,g]),F=(0,s.useCallback)(()=>{k&&S&&S(k)},[k,S]),B=(0,s.useCallback)(e=>{k&&L&&L(k,e)},[k,L]);return(0,r.jsxs)("div",{"data-line":t,style:{position:"absolute",top:0,left:0,width:"100%",height:`${m}px`,transform:`translateY(${f}px)`,backgroundColor:N&&C?C.bg:void 0},className:`flex ${w===t?"flash-line":""} ${T?"vi-cursor-line":""} ${c?"bg-blue-9/20":o?"bg-amber-9/10":"hover:bg-hover"}`,children:[(0,r.jsxs)("div",{className:"flex shrink-0 sticky left-0 z-[2] bg-card",style:{backgroundImage:N&&C?`linear-gradient(${C.bg}, ${C.bg})`:void 0},children:[k&&C&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-1 flex-shrink-0",style:{backgroundColor:C.border}}),(0,r.jsx)("div",{className:"w-48 flex-shrink-0 px-2 flex items-center gap-2 border-r border-border text-muted-foreground cursor-pointer hover:bg-hover",onMouseEnter:B,onMouseLeave:E,onClick:F,title:I("codeViewer.clickToViewCommit"),children:j?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"font-medium",style:{color:C.border},children:k.hash}),(0,r.jsx)("span",{className:"truncate flex-1",children:k.author.split(" ")[0]})]}):null})]}),d&&(0,r.jsxs)("span",{className:`flex-shrink-0 flex items-center justify-end gap-0.5 pr-2 select-none border-r border-border font-variant-tabular ${c?"bg-blue-9/30 text-blue-11":"bg-card/50 text-foreground-subtle"}`,children:[h&&o&&a&&(0,r.jsx)("button",{onClick:e=>x(a,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:I("codeViewer.nComments",{count:i}),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),h&&!o&&(0,r.jsx)("span",{className:"w-4"}),(0,r.jsx)("span",{className:"text-right",style:{minWidth:`${u}ch`},children:t})]})]}),(0,r.jsxs)("span",{className:"flex-1 px-3 whitespace-pre select-text",onClick:A,onMouseOver:_,onMouseLeave:y,"data-code-content":!0,children:[(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:P}}),M&&(0,r.jsx)(v,{blame:M,onClick:R})]})]},e)});var k=n(64702),j=n(1058),C=n(90717),N=n(48347),S=n(27570);function L(e,t,n){let r,s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),l=0;for(;(r=s.nextNode())&&r!==t;)l+=r.textContent.length;return l+n}function E(e,t){let n,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s=t,l=null;for(;n=r.nextNode();){l=n;let e=n.textContent.length;if(s<=e)return{node:n,offset:s};s-=e}return l?{node:l,offset:l.textContent.length}:null}var M=n(82292),R=n(34075);let T="white-space:pre;padding:0 12px;min-height:20px;line-height:20px";function $(e){let t=window.getSelection();if(!t?.rangeCount)return null;let n=t.getRangeAt(0),r=n.startContainer;for(;r&&r.parentElement!==e;)r=r.parentElement;if(!r)return null;let s=Array.from(e.children).indexOf(r);if(s<0)return null;let l=document.createRange();return l.selectNodeContents(r),l.setEnd(n.startContainer,n.startOffset),{line:s,offset:l.toString().length}}function I(e,t){let n,r=e.children[t.line];if(!r)return;let s=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),l=t.offset;for(;n=s.nextNode();){let e=n.textContent?.length||0;if(l<=e){let e=window.getSelection(),t=document.createRange();t.setStart(n,l),t.collapse(!0),e?.removeAllRanges(),e?.addRange(t);return}l-=e}let o=window.getSelection(),a=document.createRange();a.selectNodeContents(r),a.collapse(!1),o?.removeAllRanges(),o?.addRange(a)}function P(e){return e.map(e=>`<div style="${T}">${e}</div>`).join("")}let A=(0,s.forwardRef)(function({content:e,filePath:t,showLineNumbers:n=!0,showSearch:g=!0,className:b="",cwd:v,enableComments:A=!1,scrollToLine:_=null,scrollToLineAlign:F="center",onScrollToLineComplete:B,highlightKeyword:D=null,visibleLineRef:W,onCmdClick:O,onTokenHover:V,onTokenHoverLeave:z,onTokenHoverCancel:H,blameLines:U,inlineBlameLines:q,onSelectCommit:K,editable:Z=!1,initialMtime:J,onEditorClose:X,onSaved:G,onEditorStateChange:Q,viMode:Y=!1,onContentMutate:ee,onEnterInsertMode:et,onViSave:en,viStateRef:er,initialCursorLine:es,initialCursorCol:el,onInitialCursorSet:eo,onContentSearch:ea},ei){let{t:ec}=(0,l.Bd)(),ed=(0,s.useRef)(e),eu=(0,s.useRef)(!1),[eh,em]=(0,s.useState)(!1),[ef,ex]=(0,s.useState)(!1),[ep,eg]=(0,s.useState)(()=>e.split("\n").length),eb=(0,s.useRef)(e.split("\n").length),[ev,ey]=(0,s.useState)({show:!1}),ew=(0,s.useRef)(null),ek=(0,s.useRef)(null),ej=(0,s.useRef)(J),eC=(0,s.useRef)(null),eN=(0,s.useRef)(!1),eS=(0,s.useRef)(!1),{parentRef:eL,containerRef:eE,searchInputRef:eM,floatingToolbarRef:eR,suppressHoverRef:eT,bumpToolbarRef:e$,savedSelectionRef:eI,highlightedLines:eP,isMounted:eA,cmdHeld:e_,flashLine:eF,isSearchVisible:eB,searchQuery:eD,caseSensitive:eW,wholeWord:eO,currentMatchIndex:eV,viewingComment:ez,addCommentInput:eH,sendToAIInput:eU,aiBridge:eq,commentsEnabled:eK,updateComment:eZ,deleteComment:eJ,lines:eX,matches:eG,rowData:eQ,virtualizer:eY,commentsByEndLine:e0,linesWithComments:e1,setIsSearchVisible:e2,setSearchQuery:e5,setCaseSensitive:e4,setWholeWord:e3,setViewingComment:e8,setAddCommentInput:e6,setSendToAIInput:e9,goToNextMatch:e7,goToPrevMatch:te,handleSearchKeyDown:tt,handleCommentBubbleClick:tn,handleToolbarAddComment:tr,handleToolbarSendToAI:ts,handleToolbarExplain:tl,handleToolbarSearch:to,handleCommentSubmit:ta,handleSendToAISubmit:ti,handleCommentSendToAI:tc,getHighlightedLineHtml:td,suppressMatchScrollRef:tu,inlineBlameLineRef:th,inlineBlameVersion:tm}=function({content:e,filePath:t,showSearch:n=!0,cwd:r,enableComments:l=!1,scrollToLine:o=null,scrollToLineAlign:a="center",onScrollToLineComplete:i,visibleLineRef:c,onContentSearch:d}){let[u,f]=(0,s.useState)(!1),x=(0,s.useRef)(null),g=(0,s.useRef)(null),b=(0,s.useRef)(null),v=(0,N.r)();(0,s.useEffect)(()=>{f(!0)},[]);let[y,w]=(0,s.useState)(!1),[E,M]=(0,s.useState)(null),R=(0,s.useRef)(null),[T,$]=(0,s.useState)(!1),[I,P]=(0,s.useState)(""),[A,_]=(0,s.useState)(!1),[F,B]=(0,s.useState)(!1),[D,W]=(0,s.useState)(0),[O,V]=(0,s.useState)(0),z=(0,s.useRef)(!1),[H,U]=(0,s.useState)(null),q=(0,s.useRef)(!1),K=(0,s.useRef)(null),[Z,J]=(0,s.useState)(null),[X,G]=(0,s.useState)(null),Q=(0,s.useMemo)(()=>e.split("\n"),[e]),[Y,ee]=(0,s.useState)(null);(0,s.useEffect)(()=>{x.current!==Y&&ee(x.current)});let et=l&&!!r,{toolbarRef:en,bumpRef:er,clearToolbar:es}=(0,S.L)({enabled:et,container:Y,resolveLineRange:e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,n=t?.closest("[data-line]");if(!n)return null;let r=parseInt(n.getAttribute("data-line")||"0",10);return!Number.isFinite(r)||r<=0?null:{start:r,end:r}},buildLineSnapshot:({start:e,end:t})=>Q.slice(e-1,t).join("\n")}),el=(0,s.useRef)(null),[eo,ea]=(0,s.useState)(0),{comments:ei,addComment:ec,updateComment:ed,deleteComment:eu,refresh:eh}=(0,j._)({cwd:r||"",filePath:t}),em=(0,h.C)(Q,t),ef=(0,s.useMemo)(()=>{let e=new Map;for(let t of ei){let n=t.endLine;e.has(n)||e.set(n,[]),e.get(n).push(t)}return e},[ei]),ex=(0,s.useMemo)(()=>{let e=new Set;for(let t of ei)for(let n=t.startLine;n<=t.endLine;n++)e.add(n);return e},[ei]),ep=(0,s.useMemo)(()=>(0,m.Np)(Q,I,A,F),[Q,I,A,F]);(0,s.useEffect)(()=>{ep.length>0&&W(0)},[ep.length,I,A,F]);let eg=(0,s.useMemo)(()=>{let e=[];for(let t=0;t<Q.length;t++)e.push({type:"code",lineIndex:t});return e},[Q.length]),eb=(0,k.Te)({count:eg.length,getScrollElement:()=>x.current,estimateSize:()=>20,overscan:10});(0,s.useEffect)(()=>{if(!c)return;let e=x.current;if(!e)return;let t=()=>{if(!eb.range)return;let t=e.scrollTop;for(let e of eb.getVirtualItems())if(e.start>=t){let t=eg[e.index];t?.type==="code"&&(c.current=t.lineIndex+1);return}};return e.addEventListener("scroll",t,{passive:!0}),t(),()=>e.removeEventListener("scroll",t)},[c,eg]),(0,s.useEffect)(()=>{let e=e=>{"Meta"===e.key&&w(!0)},t=e=>{"Meta"===e.key&&w(!1)},n=()=>w(!1);return window.addEventListener("keydown",e),window.addEventListener("keyup",t),window.addEventListener("blur",n),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",t),window.removeEventListener("blur",n)}},[]),(0,s.useEffect)(()=>{if(!n)return;let e=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),$(!0),setTimeout(()=>b.current?.focus(),0)),"Escape"===e.key&&(T?($(!1),P("")):X?G(null):Z?J(null):en.current?es():H&&U(null))},t=g.current;if(t)return t.addEventListener("keydown",e),()=>t.removeEventListener("keydown",e)},[n,T,X,Z,H]),(0,s.useEffect)(()=>{if(z.current){z.current=!1;return}if(ep.length>0&&D>=0&&D<ep.length){let e=ep[D],t=eg.findIndex(t=>"code"===t.type&&t.lineIndex===e.lineIndex);t>=0&&eb.scrollToIndex(t,{align:"center"})}},[D,ep,eb,eg,O]);let ev=(0,s.useCallback)(()=>{0!==ep.length&&(W(e=>(e+1)%ep.length),V(e=>e+1))},[ep.length]),ey=(0,s.useCallback)(()=>{0!==ep.length&&(W(e=>(e-1+ep.length)%ep.length),V(e=>e+1))},[ep.length]),ew=(0,s.useRef)(o);ew.current=o,(0,s.useEffect)(()=>{if(null!==ew.current&&ew.current>0&&eg.length>0){let e=ew.current,t=e-1,n=eg.findIndex(e=>"code"===e.type&&e.lineIndex===t);if(n>=0){let t=()=>{eb.scrollToIndex(n,{align:a}),"center"===a&&(R.current&&clearTimeout(R.current),M(null),requestAnimationFrame(()=>M(e)),R.current=setTimeout(()=>M(null),1600)),i?.()};"start"===a?requestAnimationFrame(t):setTimeout(t,150)}}},[o,a,eg.length,eb,i]);let ek=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?ey():ev()),"Escape"===e.key&&($(!1),P(""))},[ev,ey]),ej=(0,s.useCallback)((e,t)=>{et&&(t.stopPropagation(),U({comment:e,x:t.clientX,y:t.clientY}),es(),J(null),G(null))},[et,es]);(0,s.useEffect)(()=>{if(!et)return;let e=x.current,t=!1,n=()=>{t=!0,K.current=null,q.current=!0},r=()=>{t=!1;let e=window.getSelection();if(!e||e.isCollapsed||!e.toString().trim()){q.current=!1;return}let n=e.getRangeAt(0),r=x.current;if(!r||!r.contains(n.commonAncestorContainer))return;let s=n.startContainer,l=n.endContainer,o=(s.nodeType===Node.TEXT_NODE?s.parentElement:s)?.closest("[data-line]"),a=(l.nodeType===Node.TEXT_NODE?l.parentElement:l)?.closest("[data-line]");if(!o||!a)return;let i=parseInt(o.getAttribute("data-line")||"0",10),c=parseInt(a.getAttribute("data-line")||"0",10);i&&c&&(q.current=!0,K.current={startLine:i,startOffset:L(o,n.startContainer,n.startOffset),endLine:c,endOffset:L(a,n.endContainer,n.endOffset)})},s=()=>{if(t)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||(K.current=null,q.current=!1)};return e?.addEventListener("mousedown",n),document.addEventListener("mouseup",r),document.addEventListener("selectionchange",s),()=>{e?.removeEventListener("mousedown",n),document.removeEventListener("mouseup",r),document.removeEventListener("selectionchange",s)}},[et]),(0,s.useEffect)(()=>{let e=x.current;if(!e)return;let t=t=>{let n,r;if(!e.contains(t.target)){if(t.target.closest?.("[data-inline-blame-tip]"))return;null!==el.current&&(el.current=null,ea(e=>e+1));return}let s=window.getSelection();if(s&&!s.isCollapsed&&s.toString().trim())return;let l=(n=t.target,(r=n.closest?.("[data-line]"))?parseInt(r.getAttribute("data-line")||"0",10):null);l!==el.current&&(el.current=l,requestAnimationFrame(()=>ea(e=>e+1)))};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]);let eC=(0,s.useCallback)(()=>{let e=en.current;e&&(J({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),es())},[es,en]),eN=(0,s.useCallback)(()=>{let e=en.current;e&&(G({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),es())},[es,en]),eS=(0,s.useCallback)(()=>{let e=en.current;e&&v&&(es(),(0,C.Ff)(v.sendMessage,{filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot},p.A.t("explain.selectionMessage")))},[v,t,es,en]),eL=(0,s.useCallback)(()=>{let e=en.current;if(!e||!d)return;let t=e.selectedText.trim();es(),t&&d(t)},[d,es,en]),eE=(0,s.useCallback)(async e=>{Z&&(await ec(Z.range.start,Z.range.end,e,Z.selectedText),J(null))},[Z,ec]),eM=(0,s.useCallback)(async(e,n)=>{if(v&&r)try{let s=await (0,C.$3)(r),l=[];for(let e of s)l.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});l.push({filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot});let o=(0,C.Gw)(l,n);v.sendMessage(o),await (0,C.RP)(r),eh()}catch(e){console.error("Failed to send to AI:",e)}},[v,t,r,eh]),eR=(0,s.useCallback)(e=>{X&&eM(X,e)},[X,eM]),eT=(0,s.useCallback)(e=>{Z&&eM(Z,e)},[Z,eM]),e$=(0,s.useCallback)((e,t,n)=>{let r=Q[e];if(!r)return t;let s=[];if(I&&ep.length>0)for(let t of ep.filter(t=>t.lineIndex===e)){let n=ep[D]?.lineIndex===e&&ep[D]?.startCol===t.startCol;s.push({start:t.startCol,end:t.endCol,cls:n?"hl-cur":"hl-m"})}if(n&&!I&&n.length>=1){let e=n.toLowerCase(),t=r.toLowerCase(),l=0;for(;-1!==(l=t.indexOf(e,l));)s.push({start:l,end:l+n.length,cls:"hl-kw"}),l+=1}if(0===s.length)return t;if(s.sort((e,t)=>e.start-t.start||e.end-t.end),s.length>m.ZR){let e=s.findIndex(e=>"hl-cur"===e.cls),t=s.slice(0,m.ZR);e>=m.ZR&&(t[t.length-1]=s[e]),s=t}let l=[],o=0;for(let e of s){if(e.start<o)continue;e.start>o&&l.push((0,m.ZD)(r.substring(o,e.start)));let t=(0,m.ZD)(r.substring(e.start,e.end));l.push(`<span class="${e.cls}">${t}</span>`),o=e.end}if(o<r.length&&l.push((0,m.ZD)(r.substring(o))),t!==(0,m.ZD)(r)){let e=t;for(let t of s){let n=r.substring(t.start,t.end),s=(0,m.ZD)(n),l=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=RegExp(`(?<=>)([^<]*?)(${l})`,""),a=`$1<span class="${t.cls}">${s}</span>`,i=e.replace(o,a);i.length>e.length+200||(e=i)}return e}return l.join("")},[I,ep,D,Q]);return{parentRef:x,containerRef:g,searchInputRef:b,floatingToolbarRef:en,suppressHoverRef:q,savedSelectionRef:K,highlightedLines:em,isMounted:u,cmdHeld:y,flashLine:E,isSearchVisible:T,searchQuery:I,caseSensitive:A,wholeWord:F,currentMatchIndex:D,viewingComment:H,bumpToolbarRef:er,addCommentInput:Z,sendToAIInput:X,aiBridge:v,commentsEnabled:et,comments:ei,updateComment:ed,deleteComment:eu,lines:Q,matches:ep,rowData:eg,virtualizer:eb,commentsByEndLine:ef,linesWithComments:ex,setIsSearchVisible:$,setSearchQuery:P,suppressMatchScrollRef:z,setCaseSensitive:_,setWholeWord:B,setViewingComment:U,setAddCommentInput:J,setSendToAIInput:G,goToNextMatch:ev,goToPrevMatch:ey,handleSearchKeyDown:ek,handleCommentBubbleClick:ej,handleToolbarAddComment:eC,handleToolbarSendToAI:eN,handleToolbarExplain:eS,handleToolbarSearch:eL,handleCommentSubmit:eE,handleSendToAISubmit:eR,handleCommentSendToAI:eT,getHighlightedLineHtml:e$,inlineBlameLineRef:el,inlineBlameVersion:eo}}({content:e,filePath:t,showSearch:g,cwd:v,enableComments:!Z&&A,scrollToLine:Z?null:_,scrollToLineAlign:Z?"center":F,onScrollToLineComplete:Z?void 0:B,visibleLineRef:Z?void 0:W,onContentSearch:ea}),tf=(0,d.iN)(),tx=(0,s.useRef)(null),tp=(0,s.useRef)(null),tg=(0,s.useRef)({line:0,col:0}),tb=(0,s.useRef)({line:0,col:0}),tv=function({lines:e,enabled:t,onContentChange:n,onEnterInsert:r,onSave:l,getVisibleLineCount:o,scrollToLine:a,onSearchExecute:i,onSearchNext:c,onSearchPrev:d,onSearchClear:u}){let[h,m]=(0,s.useState)("normal"),[f,x]=(0,s.useState)(-1),[p,g]=(0,s.useState)(0),[b,v]=(0,s.useState)(!1),[y,w]=(0,s.useState)(""),[k,j]=(0,s.useState)(""),[C,N]=(0,s.useState)(""),[S,L]=(0,s.useState)(""),E=(0,s.useRef)([]),M=(0,s.useRef)([]),R=(0,s.useRef)([]),T=(0,s.useRef)(null),$=(0,s.useRef)(e);(0,s.useEffect)(()=>{$.current=e}),(0,s.useEffect)(()=>{0!==e.length&&queueMicrotask(()=>x(t=>Math.min(t,e.length-1)))},[e.length]);let I=(0,s.useCallback)((e,t)=>Math.max(0,Math.min(t,Math.max(0,($.current[e]??"").length-1))),[]),P=(0,s.useRef)(e.length);(0,s.useEffect)(()=>{let t=Math.abs(e.length-P.current);P.current=e.length,t>10&&(queueMicrotask(()=>{x(-1),g(0),v(!1)}),E.current=[],M.current=[],R.current=[])},[e]);let A=(0,s.useCallback)(()=>{T.current&&(clearTimeout(T.current),T.current=null),w("")},[]),_=(0,s.useCallback)(()=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{w(""),T.current=null},500)},[]),F=(0,s.useCallback)((e,t)=>{E.current.push(t),M.current=[],v(!0),n(e.join("\n"))},[n]),B=(0,s.useCallback)((e,t)=>{let n=Math.max(0,Math.min(e,$.current.length-1));x(n),g(I(n,t??0)),a(n,"auto")},[a,I]),D=(0,s.useCallback)(e=>{x(t=>{let n=Math.max(0,Math.min(t+e,$.current.length-1));return a(n,"auto"),g(e=>Math.max(0,Math.min(e,Math.max(0,($.current[n]??"").length-1)))),n})},[a]),W=(0,s.useCallback)(()=>{let e=$.current,t=Math.min(f,e.length-1);if(0===e.length)return;let n=e[t];R.current=[n];let r=[...e];r.splice(t,1),0===r.length&&r.push("");let s=Math.min(t,r.length-1);F(r,{lineIndex:t,oldLines:[n],newLines:[],cursorLine:t}),x(s),g(0)},[f,F]),O=(0,s.useCallback)(()=>{let e=$.current,t=Math.min(f,e.length-1);e.length>0&&(R.current=[e[t]])},[f]),V=(0,s.useCallback)(()=>{let e=R.current;if(0===e.length)return;let t=$.current,n=Math.min(f,t.length-1)+1,r=[...t];r.splice(n,0,...e),F(r,{lineIndex:n,oldLines:[],newLines:[...e],cursorLine:f}),x(n),g(0),a(n,"auto")},[f,F,a]),z=(0,s.useCallback)(()=>{let e=$.current,t=Math.min(f,e.length-1),n=e[t];if(!n||0===n.length)return;let r=n.substring(1),s=[...e];s[t]=r,F(s,{lineIndex:t,oldLines:[n],newLines:[r],cursorLine:f})},[f,F]),H=(0,s.useCallback)(()=>{let e=E.current;if(0===e.length)return;let t=e.pop(),r=[...$.current];0===t.newLines.length&&t.oldLines.length>0?r.splice(t.lineIndex,0,...t.oldLines):0===t.oldLines.length&&t.newLines.length>0?(r.splice(t.lineIndex,t.newLines.length),0===r.length&&r.push("")):r.splice(t.lineIndex,t.newLines.length,...t.oldLines),M.current.push(t),n(r.join("\n")),x(Math.min(t.cursorLine,r.length-1)),a(Math.min(t.cursorLine,r.length-1),"auto"),0===e.length&&v(!1)},[n,a]),U=(0,s.useCallback)(()=>{let e=M.current;if(0===e.length)return;let t=e.pop(),r=[...$.current];0===t.newLines.length&&t.oldLines.length>0?(r.splice(t.lineIndex,t.oldLines.length),0===r.length&&r.push("")):0===t.oldLines.length&&t.newLines.length>0?r.splice(t.lineIndex,0,...t.newLines):r.splice(t.lineIndex,t.oldLines.length,...t.newLines),E.current.push(t),v(!0),n(r.join("\n"));let s=t.lineIndex+Math.max(0,t.newLines.length-1);x(Math.min(s,r.length-1)),a(Math.min(s,r.length-1),"auto")},[n,a]),q=(0,s.useCallback)(e=>{let t=$.current,n=Math.min(f,t.length-1);if("o"===e||"O"===e){let r="o"===e?n+1:n,s=[...t];s.splice(r,0,""),F(s,{lineIndex:r,oldLines:[],newLines:[""],cursorLine:f}),n=r,x(r)}m("insert"),r(n,p,e)},[f,p,F,r]),K=(0,s.useCallback)(()=>{m("normal"),A()},[A]),Z=(0,s.useCallback)(()=>{m("command"),j("")},[]),J=(0,s.useCallback)(()=>{m("normal"),j("")},[]),X=(0,s.useCallback)(()=>{m("search"),N("")},[]),G=(0,s.useCallback)(()=>{m("normal"),N("")},[]),Q=(0,s.useCallback)(e=>{let t=e.trim();if("w"===t){l?.(),m("normal"),j("");return}if("q"===t){m("normal"),j("");return}if("wq"===t){l?.(),m("normal"),j("");return}if("noh"===t||"nohlsearch"===t){u?.(),m("normal"),j("");return}let n=parseInt(t,10);if(!isNaN(n)&&n>0){let e=Math.min(n-1,$.current.length-1);x(e),a(e,"center"),m("normal"),j("");return}m("normal"),j("")},[l,u,a]),Y=(0,s.useCallback)(e=>{if(!e){m("normal"),N("");return}L(e),i?.(e),m("normal"),N("")},[i]),ee=(0,s.useCallback)(e=>{if(!t)return!1;let n=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;if("insert"===h)return("Escape"===e.key||!!n)&&(K(),!0);if("command"===h)return!e.isComposing&&("Escape"===e.key||n?J():"Enter"===e.key?Q(k):"Backspace"===e.key?0===k.length?J():j(e=>e.slice(0,-1)):1!==e.key.length||e.metaKey||e.ctrlKey||j(t=>t+e.key),!0);if("search"===h)return!e.isComposing&&("Escape"===e.key||n?G():"Enter"===e.key?Y(C):"Backspace"===e.key?0===C.length?G():N(e=>e.slice(0,-1)):1!==e.key.length||e.metaKey||e.ctrlKey||N(t=>t+e.key),!0);if(f<0&&(x(0),g(0)),e.metaKey)return!1;if(e.ctrlKey)return"d"===e.key?(D(Math.max(1,Math.floor(o()/2))),A(),!0):"u"===e.key?(D(-Math.max(1,Math.floor(o()/2))),A(),!0):"r"===e.key&&(U(),A(),!0);let r=e.key,s=y+r;if("g"===s)return w("g"),_(),!0;if("gg"===s)return B(0),A(),!0;if("d"===s)return w("d"),_(),!0;if("dd"===s)return W(),A(),!0;if("y"===s)return w("y"),_(),!0;if("yy"===s)return O(),A(),!0;if(y&&s!==r&&A(),"j"===r||"ArrowDown"===r)return D(1),!0;if("k"===r||"ArrowUp"===r)return D(-1),!0;if("h"===r||"ArrowLeft"===r)return g(e=>Math.max(0,e-1)),!0;if("l"===r||"ArrowRight"===r){let e=Math.max(0,($.current[f]??"").length-1);return g(t=>Math.min(e,t+1)),!0}if("0"===r)return g(0),!0;if("$"===r)return g(Math.max(0,($.current[f]??"").length-1)),!0;if("^"===r){let e=($.current[f]??"").search(/\S/);return g(e>=0?e:0),!0}return"G"===r?(B($.current.length-1),!0):"x"===r?(z(),!0):"p"===r?(V(),!0):"u"===r?(H(),!0):"i"===r||"a"===r||"I"===r||"A"===r||"o"===r||"O"===r?(q(r),!0):"/"===r?(X(),!0):"n"===r?(c?.(),!0):"N"===r?(d?.(),!0):":"===r?(Z(),!0):"Escape"!==r&&1===r.length},[t,h,y,k,C,f,K,q,Z,J,X,G,Q,Y,D,B,o,W,O,V,z,H,U,A,_,c,d]);return{state:{mode:h,cursorLine:f,cursorCol:p,isDirty:b,keyBuffer:y,commandInput:k,searchInput:C,lastSearch:S},handleKeyDown:ee,enterNormal:K,enterInsert:q,setCursorLine:x,setCursorCol:g,setCommandInput:j,setSearchInput:N,setIsDirty:v,clearUndoHistory:(0,s.useCallback)(()=>{E.current=[],M.current=[]},[])}}({lines:eX,enabled:Y&&!Z,onContentChange:e=>{tg.current={line:tb.current.line,col:tb.current.col},ee?.(e)},onEnterInsert:(e,t,n)=>{let r=t;if("a"===n)r=t+1;else if("A"===n)r=(eX[e]??"").length;else if("I"===n){let t=(eX[e]??"").search(/\S/);r=t>=0?t:0}else("o"===n||"O"===n)&&(r=0);tg.current={line:e,col:r},et?.(e)},onSave:en,getVisibleLineCount:()=>{let e=eL.current;return e?Math.floor(e.clientHeight/20):20},scrollToLine:(e,t)=>{let n=eQ.findIndex(t=>"code"===t.type&&t.lineIndex===e);n>=0&&eY.scrollToIndex(n,{align:t||"auto"})},onSearchExecute:e=>{e5(e),e2(!1)},onSearchNext:e7,onSearchPrev:te,onSearchClear:()=>{e5("")}});(0,s.useEffect)(()=>{er&&(er.current={cursorLine:tv.state.cursorLine,cursorCol:tv.state.cursorCol}),tb.current={line:tv.state.cursorLine,col:tv.state.cursorCol}},[er,tv.state.cursorLine,tv.state.cursorCol]);let ty=(0,s.useRef)(null);(0,s.useEffect)(()=>{Y&&!Z&&null!=es&&t&&ty.current!==t&&(ty.current=t,tv.setCursorLine(es-1),null!=el&&tv.setCursorCol(el-1),eo?.())},[Y,Z,es,el,t]),(0,s.useEffect)(()=>{if(!Y||Z)return;let e=eE.current;if(!e)return;let t=e=>{let t=e.target;"TEXTAREA"===t.tagName||"INPUT"===t.tagName||t.isContentEditable||tv.handleKeyDown(e)&&(e.preventDefault(),e.stopPropagation())};return e.addEventListener("keydown",t,!0),()=>e.removeEventListener("keydown",t,!0)},[Y,Z,tv.handleKeyDown]),(0,s.useEffect)(()=>{if(!Y||Z)return;let e=eE.current;e&&"normal"===tv.state.mode&&requestAnimationFrame(()=>{let t=document.activeElement;t&&("TEXTAREA"===t.tagName||"INPUT"===t.tagName||t.isContentEditable)||e.focus()})},[Y,Z,tv.state.mode,e]);let tw=(0,s.useCallback)(e=>{if(!Y||Z)return;let t=e.target.closest("[data-line]");if(t){let n=parseInt(t.getAttribute("data-line"),10);if(!isNaN(n)){tv.setCursorLine(n-1);let r=t.querySelector("[data-code-content]");if(r){let t=document.caretRangeFromPoint(e.clientX,e.clientY);if(t&&r.contains(t.startContainer)){let e,s=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),l=0;for(;e=s.nextNode();){if(e===t.startContainer){l+=t.startOffset;break}l+=e.textContent?.length||0}let o=eX[n-1]??"";tv.setCursorCol(Math.max(0,Math.min(l,Math.max(0,o.length-1))))}}}}let n=e.target;if("TEXTAREA"===n.tagName||"INPUT"===n.tagName||n.isContentEditable)return;let r=eE.current;r&&r.focus()},[Y,Z,tv.setCursorLine,tv.setCursorCol,eX]),tk=(0,s.useCallback)(e=>{Y&&!Z&&requestAnimationFrame(()=>{let e=window.getSelection(),t=e?.toString().trim();t&&/^\S+$/.test(t)&&(tu.current=!0,e5(t))})},[Y,Z,e5,tu]);(0,s.useEffect)(()=>{"command"===tv.state.mode?setTimeout(()=>tx.current?.focus(),0):"search"===tv.state.mode&&setTimeout(()=>tp.current?.focus(),0)},[tv.state.mode]),(0,s.useEffect)(()=>{let e=eL.current;if(!e)return;let t=()=>{(H??z)?.()};return e.addEventListener("mousedown",t),()=>e.removeEventListener("mousedown",t)},[H,z]),(0,s.useEffect)(()=>{eH||eU?(eT.current=!0,z?.()):eR.current||(eT.current=!1)},[eH,eU,z]),(0,s.useLayoutEffect)(()=>{let e=eI.current;if(!e)return;let t=window.getSelection();if(t&&!t.isCollapsed)return;let n=eL.current;if(!n)return;let r=n.querySelector(`[data-line="${e.startLine}"]`),s=n.querySelector(`[data-line="${e.endLine}"]`);if(!r||!s)return;let l=E(r,e.startOffset),o=E(s,e.endOffset);if(l&&o)try{let e=document.createRange();e.setStart(l.node,l.offset),e.setEnd(o.node,o.offset),t?.removeAllRanges(),t?.addRange(e)}catch{}});let tj=(0,s.useCallback)((e,t,n)=>{eT.current||V?.(e,t,n)},[V]),tC=(0,s.useCallback)((e,t)=>{eT.current||O?.(e,t)},[O]),tN=Math.max(4,String(Z?ep:eX.length).length),tS=(0,s.useMemo)(()=>{let e=0;for(let t of eX){let n=0;for(let e=0;e<t.length;e++)" "===t[e]?n+=2-n%2:n+=1;n>e&&(e=n)}return e},[eX]);(0,s.useEffect)(()=>{if(Z){ed.current=e;let t=e.split("\n").length;eb.current=t,eg(t),eu.current=!1,em(!1),ey({show:!1}),ej.current=J}},[Z,e,J]),(0,s.useEffect)(()=>{if(!Z)return;let t=ew.current;if(!t)return;let n=e.split("\n");t.innerHTML=P(n.map((e,t)=>eP[t]||(0,m.ZD)(e||" "))),requestAnimationFrame(()=>{let e,r;Y?(e=Math.max(0,Math.min(tg.current.line,n.length-1)),r=tg.current.col):(e=Math.max(0,Math.min((W?.current??1)-1,n.length-1)),r=0),t.focus(),I(t,{line:e,offset:r});let s=W?.current??1;ek.current&&(ek.current.scrollTop=(s-1)*20)})},[Z]),(0,s.useEffect)(()=>{Z&&Q?.({isDirty:eh,isSaving:ef})},[Z,eh,ef,Q]);let tL=(0,s.useCallback)(()=>{let e=ew.current;if(!e)return ed.current;let t=[];for(let n of e.childNodes){let e=n.textContent||"";t.push(" "===e?"":e)}return t.join("\n")},[]),tE=(0,s.useCallback)(()=>{eC.current&&clearTimeout(eC.current),eC.current=setTimeout(async()=>{let e=ew.current;if(e&&!eS.current){ed.current=tL();try{let n=await (0,m.kS)(),r=(0,m.sQ)(t),s=document.documentElement.classList.contains("dark"),l=ed.current.split("\n"),o=n.codeToTokens(l.join("\n"),{lang:r,theme:s?"github-dark":"github-light"}).tokens.map(e=>(0,m.b8)(e)),a=$(e);eN.current=!0,e.innerHTML=P(o),eN.current=!1,a&&I(e,a)}catch{}}},300)},[t,tL]);(0,s.useEffect)(()=>{if(Z)return()=>{eC.current&&clearTimeout(eC.current)}},[Z]);let tM=(0,s.useCallback)(()=>{let e=ew.current;if(!e)return;eu.current||(eu.current=!0,em(!0));let t=e.children.length;t!==eb.current&&(eb.current=t,eg(t))},[]),tR=(0,s.useCallback)(()=>{eN.current||eS.current||(tM(),tE())},[tM,tE]),tT=(0,s.useCallback)(e=>{if(!e.nativeEvent.isComposing&&("Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," ")),"Enter"===e.key)){e.preventDefault();let t=ew.current;if(!t)return;let n=window.getSelection();if(!n?.rangeCount)return;let r=n.getRangeAt(0);r.deleteContents();let s=r.startContainer;for(;s&&s.parentElement!==t;)s=s.parentElement;if(!s||!(s instanceof HTMLElement))return;let l=$(t),o=Array.from(t.children).indexOf(s),a=s.textContent||"",i=l?.offset??a.length,c=a.substring(0,i),d=a.substring(i);s.innerHTML=(0,m.ZD)(c||" ");let u=document.createElement("div");u.setAttribute("style",T),u.innerHTML=(0,m.ZD)(d||" "),s.after(u),I(t,{line:o+1,offset:0}),tM(),tE()}},[tM,tE]),t$=(0,s.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)},[]),tI=(0,s.useCallback)(async(e=!1)=>{if(!v)return;ed.current=tL(),ex(!0);let n=await a.t4.runPromiseExit((0,i.OJ)({cwd:v,path:t,content:ed.current,expectedMtime:e?void 0:ej.current}));if("Failure"===n._tag){console.error("Error saving file:",n.cause),(0,R.oR)(ec("toast.saveFailed"),"error"),ex(!1);return}let r=n.value,s=r.data;if(409===r.status&&s?.conflict){let e=await a.t4.runPromiseExit((0,c.K)(v,t));"Success"===e._tag&&e.value.ok&&"string"==typeof e.value.data?.content?ey({show:!0,diskContent:e.value.data.content}):ey({show:!0}),ex(!1);return}if(!r.ok){console.error("Error saving file: status",r.status),(0,R.oR)(ec("toast.saveFailed"),"error"),ex(!1);return}let l=s?.mtime;l&&(ej.current=l),eu.current=!1,em(!1),ey({show:!1}),(0,R.oR)(ec("toast.savedSuccess"),"success"),G?.(),ex(!1)},[v,t,tL,G,ec]),tP=(0,s.useCallback)(async()=>{eh&&!ef&&await tI(!1)},[eh,ef,tI]),tA=(0,s.useCallback)(async()=>{ey({show:!1}),await tI(!0)},[tI]),t_=(0,s.useCallback)(()=>{if(void 0!==ev.diskContent){ed.current=ev.diskContent;let t=ev.diskContent.split("\n").length;eb.current=t,eg(t);let n=ev.diskContent!==e;eu.current=n,em(n);let r=ew.current;r&&(r.innerHTML=P(ev.diskContent.split("\n").map(e=>(0,m.ZD)(e||" "))),tE())}ey({show:!1}),G?.()},[ev.diskContent,e,G,tE]),tF=(0,s.useCallback)(()=>{let e=ek.current;return e?Math.floor(e.scrollTop/20)+1:W?.current??1},[W]),tB=(0,s.useCallback)(async()=>{(!eh||await (0,R.lJ)(ec("codeViewer.unsavedConfirm"),{danger:!0,confirmText:ec("codeViewer.discardChanges"),cancelText:ec("codeViewer.continueEditing")}))&&X?.(tF())},[eh,X,tF]);(0,s.useEffect)(()=>{if(!Z)return;let e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&(e.preventDefault(),tP())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[Z,tP]);let tD=(0,s.useCallback)(()=>{let e=tL();ee?.(e);let t=ew.current,n=t?$(t):null,r=tF();if(tv.enterNormal(),n){tv.setCursorLine(n.line);let t=e.split("\n")[n.line]??"";tv.setCursorCol(Math.max(0,Math.min(n.offset,Math.max(0,t.length-1))))}else tv.setCursorLine(Math.max(0,r-1));X?.(r)},[tL,ee,tF,X,tv]);(0,s.useEffect)(()=>{if(!Z)return;let e=e=>{let t="Escape"===e.key,n=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;(t||Y&&n)&&(e.preventDefault(),e.stopPropagation(),Y?eu.current?(0,R.lJ)(ec("codeViewer.unsavedExitConfirm"),{danger:!0,confirmText:ec("codeViewer.discardChanges"),cancelText:ec("codeViewer.continueEditing")}).then(e=>{e&&tD()}):tD():tB())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[Z,Y,tB,tD]);let tW=(0,s.useCallback)(()=>{eu.current||(eu.current=!0,em(!0))},[]);(0,s.useImperativeHandle)(ei,()=>({save:tP,close:tB,markDirty:tW,get isDirty(){return eu.current},get isSaving(){return ef}}),[tP,tB,tW,ef]);let tO=!!(U&&U.length>0),tV=(0,s.useMemo)(()=>{if(!U)return new Map;let e=[...new Set(U.map(e=>e.author))],t=new Map;return e.forEach((e,n)=>{t.set(e,y[n%y.length])}),t},[U]),[tz,tH]=(0,s.useState)(null),[tU,tq]=(0,s.useState)(null);(0,s.useEffect)(()=>{tH(null),tq(null)},[U]);let tK=(0,s.useCallback)((e,t)=>{tH(e.author);let n=t.currentTarget.getBoundingClientRect();tq({line:e,x:n.right+8,y:n.top})},[]),tZ=(0,s.useCallback)(()=>{tH(null),tq(null)},[]),tJ=(0,s.useCallback)(e=>{K&&(K({hash:e.hashFull,shortHash:e.hash,author:e.author,authorEmail:e.authorEmail,date:new Date(1e3*e.time).toISOString(),subject:e.message.split("\n")[0]||"",body:e.message.split("\n").slice(1).join("\n").trim(),time:e.time}),tq(null))},[K]),tX=`${tN+2}ch`;return(0,r.jsxs)("div",{ref:eE,className:`h-full flex flex-col outline-none ${b}`,tabIndex:0,onClick:tw,onDoubleClick:tk,children:[Z&&ev.show&&(0,r.jsxs)("div",{className:"px-4 py-2 bg-amber-500/15 border-b border-amber-500/30 flex items-center gap-3 flex-shrink-0",children:[(0,r.jsx)("svg",{className:"w-5 h-5 text-amber-11 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),(0,r.jsx)("span",{className:"text-sm text-foreground flex-1",children:ec("codeViewer.fileModifiedExternally")}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:t_,className:"px-3 py-1 text-sm rounded border border-border hover:bg-hover transition-colors",children:ec("codeViewer.useDiskVersion")}),(0,r.jsx)("button",{onClick:tA,className:"px-3 py-1 text-sm rounded bg-amber-500 text-white hover:bg-amber-600 transition-colors",children:ec("codeViewer.forceOverwrite")})]})]}),!Z&&g&&eB&&(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,r.jsx)("input",{ref:eM,type:"text",value:eD,onChange:e=>e5(e.target.value),onKeyDown:tt,placeholder:ec("codeViewer.searchPlaceholder"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("button",{onClick:()=>e4(!eW),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${eW?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-hover"}`,title:ec("codeViewer.caseSensitive"),children:"Aa"}),(0,r.jsx)("button",{onClick:()=>e3(!eO),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${eO?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-hover"}`,title:ec("codeViewer.wholeWordMatch"),children:"[ab]"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:eG.length>0?`${eV+1}/${eG.length}`:ec("common.noMatch")}),(0,r.jsx)("button",{onClick:te,disabled:0===eG.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ec("common.previous"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,r.jsx)("button",{onClick:e7,disabled:0===eG.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ec("common.next"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,r.jsx)("button",{onClick:()=>{e2(!1),e5("")},className:"p-1 rounded hover:bg-hover",title:ec("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),Z?(0,r.jsx)("div",{ref:ek,className:"flex-1 overflow-auto bg-card",children:(0,r.jsxs)("div",{className:"flex",style:{minHeight:"100%"},children:[(0,r.jsx)("div",{className:"flex-shrink-0 font-mono text-sm select-none sticky left-0 z-[2] bg-card",style:{width:tX},children:Array.from({length:ep},(e,t)=>(0,r.jsx)("div",{className:"text-right text-muted-foreground/50 pr-3",style:{height:20,lineHeight:"20px"},children:t+1},t))}),(0,r.jsx)("div",{ref:ew,contentEditable:!0,suppressContentEditableWarning:!0,onInput:tR,onKeyDown:tT,onPaste:t$,onCompositionStart:()=>{eS.current=!0},onCompositionEnd:()=>{eS.current=!1,tR()},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",className:"flex-1 font-mono text-sm outline-none",style:{caretColor:"var(--foreground)",tabSize:2}})]})}):(0,r.jsx)("div",{ref:eL,className:`flex-1 overflow-auto font-mono text-sm bg-card${e_?" cmd-held-container":""}`,children:(0,r.jsx)("div",{style:{height:`${eY.getTotalSize()}px`,minWidth:"100%",width:tO?`calc(${tN+tS+10}ch + 13rem)`:`${tN+tS+10}ch`,position:"relative"},children:eY.getVirtualItems().map(e=>{let t=eQ[e.index];if("code"!==t.type)return null;let s=t.lineIndex,l=s+1,o=eP[s]||(0,m.ZD)(eX[s]||""),a=td(s,o,D),i=e1.has(l),c=e0.get(l),d=c?.[0],u=!!(eH&&l>=eH.range.start&&l<=eH.range.end),h=tm>=0?th.current:null,f=!Z&&q&&h===l?q[s]??null:null,x=tO?U[s]:void 0,p=tO&&s>0?U[s-1]:void 0,g=!!x&&(!p||p.hash!==x.hash),b=x?tV.get(x.author):void 0;return(0,r.jsx)(w,{virtualKey:e.key,lineNum:l,highlightedHtml:a,hasComments:i,firstComment:d,lineCommentsCount:c?.length,isInRange:u,showLineNumbers:n,lineNumChars:tN,commentsEnabled:eK,virtualItemSize:e.size,virtualItemStart:e.start,onCommentBubbleClick:tn,onCmdClick:tC,onTokenHover:tj,onTokenHoverLeave:z,flashLine:eF,blameLine:x,showBlameInfo:g,blameAuthorColor:b,isBlameHovered:!!(x&&tz===x.author),onBlameClick:tJ,onBlameMouseEnter:tK,onBlameMouseLeave:tZ,inlineBlameData:f,onInlineBlameClick:tJ,isCursorLine:Y&&!Z&&tv.state.cursorLine===s,cursorCol:Y&&!Z&&tv.state.cursorLine===s?tv.state.cursorCol:void 0},e.key)})})}),Y&&(0,r.jsxs)("div",{className:"vi-status-bar flex-shrink-0 h-6 bg-card border-t border-border flex items-center px-3 text-xs font-mono select-none",children:["normal"===tv.state.mode&&(0,r.jsx)("span",{className:"text-green-11 font-medium",children:"NORMAL"}),"insert"===tv.state.mode&&(0,r.jsx)("span",{className:"text-blue-11 font-medium",children:"INSERT"}),"command"===tv.state.mode&&(0,r.jsxs)("div",{className:"flex items-center flex-1",children:[(0,r.jsx)("span",{className:"text-foreground",children:":"}),(0,r.jsx)("input",{ref:tx,value:tv.state.commandInput,onChange:e=>tv.setCommandInput(e.target.value),onKeyDown:e=>{if(e.nativeEvent.isComposing)return;let t=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;("Enter"===e.key||"Escape"===e.key||t)&&(e.preventDefault(),e.stopPropagation(),tv.handleKeyDown(e.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),"search"===tv.state.mode&&(0,r.jsxs)("div",{className:"flex items-center flex-1",children:[(0,r.jsx)("span",{className:"text-foreground",children:"/"}),(0,r.jsx)("input",{ref:tp,value:tv.state.searchInput,onChange:e=>tv.setSearchInput(e.target.value),onKeyDown:e=>{if(e.nativeEvent.isComposing)return;let t=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;("Enter"===e.key||"Escape"===e.key||t)&&(e.preventDefault(),e.stopPropagation(),tv.handleKeyDown(e.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),tv.state.keyBuffer&&"normal"===tv.state.mode&&(0,r.jsx)("span",{className:"ml-2 text-muted-foreground",children:tv.state.keyBuffer}),tv.state.isDirty&&("normal"===tv.state.mode||"command"===tv.state.mode)&&(0,r.jsx)("span",{className:"ml-2 text-amber-11",children:"[+]"}),(0,r.jsxs)("span",{className:"ml-auto text-muted-foreground",children:[tv.state.cursorLine+1,":",tv.state.cursorCol+1]})]}),eA&&tf&&(0,o.createPortal)((0,r.jsxs)(r.Fragment,{children:[!Z&&(0,r.jsx)(f.fS,{floatingToolbarRef:eR,bumpRef:e$,container:tf,onAddComment:tr,onSendToAI:ts,onSearch:ea?to:void 0,onExplain:eq?tl:void 0,isChatLoading:eq?.isLoading}),!Z&&eH&&(0,r.jsx)(u.t,{x:eH.x,y:eH.y,range:eH.range,filePath:t,lineSnapshot:eH.lineSnapshot,container:tf,onSubmit:ta,onSendToAI:eq?tc:void 0,onClose:()=>e6(null),isChatLoading:eq?.isLoading}),!Z&&eU&&(0,r.jsx)(u.G,{x:eU.x,y:eU.y,range:eU.range,filePath:t,lineSnapshot:eU.lineSnapshot,container:tf,onSubmit:ti,onClose:()=>e9(null),isChatLoading:eq?.isLoading}),!Z&&ez&&(0,r.jsx)(x.t,{x:ez.x,y:ez.y,comment:ez.comment,container:tf,onClose:()=>e8(null),onUpdateComment:eZ,onDeleteComment:eJ}),tU&&(0,r.jsxs)("div",{className:"fixed z-50 bg-card border border-border rounded-lg shadow-lv2 p-3 max-w-lg",style:{left:Math.min(tU.x,window.innerWidth-450),top:Math.max(8,Math.min(tU.y,window.innerHeight-200))},children:[(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"px-2 py-0.5 rounded text-xs font-mono font-medium text-white flex-shrink-0",style:{backgroundColor:tV.get(tU.line.author)?.border||"#666"},children:tU.line.hash}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:tU.line.author}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:tU.line.authorEmail})]})]}),(0,r.jsx)("div",{className:"mt-2 text-sm text-foreground whitespace-pre-wrap max-h-48 overflow-y-auto",children:tU.line.message}),(0,r.jsxs)("div",{className:"mt-2 text-xs text-muted-foreground border-t border-border pt-2",children:[(0,M.fw)(tU.line.time)," \xb7 ",new Date(1e3*tU.line.time).toLocaleString(),(0,r.jsx)("span",{className:"ml-2 text-brand",children:ec("codeViewer.clickToViewDetails")})]})]})]}),tf)]})});function _({content:e,filePath:t,className:n=""}){let l=(0,s.useMemo)(()=>e.split("\n"),[e]),o=(0,h.C)(l,t),a=Math.max(4,String(l.length).length);return(0,r.jsx)("pre",{className:`overflow-auto text-sm font-mono bg-muted p-2 ${n}`,children:l.map((e,t)=>(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"text-foreground-subtle select-none pr-4 text-right",style:{minWidth:`${a+2}ch`},children:t+1}),(0,r.jsx)("span",{className:"flex-1",dangerouslySetInnerHTML:{__html:o[t]||(0,m.ZD)(e||" ")}})]},t))})}},38987:(e,t,n)=>{n.d(t,{zB:()=>F,e$:()=>_,vP:()=>$});var r=n(95155),s=n(12115),l=n(79114),o=n(49433),a=n(77725),i=n(62111),c=n(70188),d=n(64428),u=n(12710),h=n(33210),m=n(32967),f=n(88780),x=n(30133),p=n(48661),g=n(20080),b=n(53377),v=n(47215),y=n(5135),w=n(24602),k=n(9573);let j=[/(^|\/)__tests__\//,/(^|\/)tests?\//,/\.(test|spec)\.[^/]+$/],C=[/\.(md|mdx)$/i,/(^|\/)docs\//,/(^|\/)README[^/]*$/i,/(^|\/)LICENSE[^/]*$/i,/(^|\/)CHANGELOG[^/]*$/i];function N(e){return j.some(t=>t.test(e))?"test":C.some(t=>t.test(e))?"docs":null}var S=n(4055);let L=(e,t,n)=>`/api/snapshots/blob?cwd=${encodeURIComponent(e)}&rev=${encodeURIComponent(t)}&file=${encodeURIComponent(n)}`;function E(e){return e.fullSubject||e.subject}function M(e,t,n){let r=E(e),s=r.split("\n"),l=s.length>n?s.slice(0,n).join("\n"):r,o=l.length>t?l.slice(0,t):l;return s.length>n||l.length>t?`${o.trimEnd()}…`:o}function R(e,t){if(t&&e.startsWith(t)){let n=e.slice(t.length);return n.startsWith("/")?n.slice(1):n}return e}function T(e,t){let n=[];for(let r of e)if("Edit"===r.name){let e=r.input;if(e.file_path&&"string"==typeof e.old_string&&"string"==typeof e.new_string){let s=R(e.file_path,t);n.push({key:r.id,toolName:"Edit",subject:`[Edit] ${s}`,legacy:!0,changeClass:N(s),files:[{path:s,status:"modified",old_string:e.old_string,new_string:e.new_string,fileClass:N(s)}]})}}else if("Write"===r.name){let e=r.input;if(e.file_path&&"string"==typeof e.content){let s=R(e.file_path,t);n.push({key:r.id,toolName:"Write",subject:`[Write] ${s}`,legacy:!0,changeClass:N(s),files:[{path:s,status:"added",old_string:"",new_string:e.content,fileClass:N(s)}]})}}return n}function $(e,t,n){var r;let s,l=e.map(e=>{let t=new Set(e.commit.toolFiles);return{key:e.commit.toolId??e.commit.hash,shortHash:e.commit.hash.slice(0,7),toolName:e.commit.toolName??"tool",subject:e.commit.subject,timestamp:e.commit.timestamp,truncated:!0===e.truncated,changeClass:function(e){if(0===e.length)return null;let t=N(e[0]);return null===t?null:e.every(e=>N(e)===t)?t:null}(e.files.map(e=>e.path)),files:e.files.map(e=>({path:e.path,status:e.status,additions:e.additions,deletions:e.deletions,old_string:e.oldContent??"",new_string:e.newContent??"",unviewable:!e.isImage&&(e.binary||null===e.oldContent&&null===e.newContent),isImage:e.isImage,oldRev:e.oldRev,newRev:e.newRev,external:t.size>0&&!t.has(e.path),fileClass:N(e.path)}))}});return r=l.length>0?l:T(t,n),s=new Map(t.map(e=>[e.id,e])),r.map(e=>{let t=function(e){if(!e)return;let t=e.input;return"string"==typeof t.description&&t.description?t.description:"string"==typeof t.command&&t.command?t.command:"string"==typeof t.prompt&&t.prompt?t.prompt:"string"==typeof t.file_path&&t.file_path?t.file_path:"string"==typeof t.notebook_path&&t.notebook_path?t.notebook_path:void 0}(s.get(e.key));return t?{...e,fullSubject:`[${e.toolName}] ${t}`}:e})}function I({additions:e,deletions:t}){return(0,r.jsxs)("span",{className:"flex items-center gap-1 font-mono",children:[(0,r.jsxs)("span",{className:"text-green-11",children:["+",e]}),(0,r.jsxs)("span",{className:"text-red-11",children:["-",t]})]})}function P({cls:e}){return(0,r.jsx)("span",{className:`text-[10px] px-1 py-px rounded flex-shrink-0 ${"test"===e?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400/80":"bg-sky-500/15 text-sky-600 dark:text-sky-400/80"}`,children:e})}function A(e){let t=new Date(1e3*e),n=new Date,r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),l=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0"),a=`${r}-${s} ${l}:${o}`;return t.getFullYear()===n.getFullYear()?a:`${t.getFullYear()}-${a}`}function _({toolCalls:e,cwd:t,sessionId:n,runId:d,onClose:j,onContentSearch:C}){let{t:N}=(0,l.Bd)(),R=(0,s.useRef)(null),[F,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{B(R.current)},[]);let D=(0,s.useMemo)(()=>e.map(e=>e.id).filter(Boolean),[e]),W=D.join(","),[O,V]=(0,s.useState)(0);(0,s.useEffect)(()=>{V(0)},[W]);let z=(0,a.Z)(t&&D.length>0?(0,k.se)(t,D,n,d):o.succeed([]),[t,n,d,W,O]),H=(0,s.useMemo)(()=>e.filter(e=>(0,S.h)(e.name)).map(e=>e.id),[e]);(0,s.useEffect)(()=>{if("success"!==z.status||O>=2)return;let e=new Set(z.data.map(e=>e.commit.toolId));if(H.some(t=>!e.has(t))){let e=setTimeout(()=>V(e=>e+1),2e3);return()=>clearTimeout(e)}},[z,O,H]);let U=(0,s.useRef)([]),q="loading"===z.status&&0===U.current.length,K=(0,s.useMemo)(()=>{if("success"===z.status){let n=$(z.data,e,t);return n.length>0&&(U.current=n),n}return"loading"===z.status&&U.current.length>0?U.current:"loading"===z.status?[]:T(e,t)},[z,e,t]),[Z,J]=(0,s.useState)(null),[X,G]=(0,s.useState)(null),[Q,Y]=(0,s.useState)(new Set),[ee,et]=(0,s.useState)(()=>window.innerWidth>=768),[en,er]=(0,s.useState)("compact"),[es,el]=(0,s.useState)("unified"),[eo,ea]=(0,s.useState)(!1),[ei,ec]=(0,s.useState)(!1),[ed,eu]=(0,s.useState)(null),eh=(0,s.useMemo)(()=>K.find(e=>e.key===Z)??null,[K,Z]),em=(0,s.useRef)(null);(0,s.useEffect)(()=>{eh&&(em.current=eh)},[eh]);let ef=eh??em.current,ex=(0,s.useMemo)(()=>ef?(0,f.Do)(ef.files):[],[ef]),ep=(0,s.useMemo)(()=>ef?.files.find(e=>e.path===X)??null,[ef,X]),eg=(0,s.useCallback)(e=>{J(e.key),G(e.files[0]?.path??null),Y(new Set((0,f.Sz)((0,f.Do)(e.files))))},[]);(0,s.useEffect)(()=>{K.length>0&&null==Z&&eg(K[0])},[K,Z,eg]),(0,s.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(eo)return void ea(!1);if(ei)return void ec(!1);if(ed)return void eu(null);(0,i.k)(),j()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[j,eo,ei,ed]);let eb=(0,s.useMemo)(()=>K.reduce((e,t)=>e+t.files.length,0),[K]),ev=e=>(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:e});return(0,r.jsx)(c.SU,{container:F,children:(0,r.jsxs)("div",{ref:R,className:"relative bg-card shadow-lv3 w-full h-full flex flex-col rounded-lg",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:()=>et(e=>!e),"aria-label":N("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors ${ee?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:(0,r.jsx)(u.A,{className:"w-4 h-4"})}),(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:N("diffViewer.fileChanges",{count:eb})})]}),(0,r.jsx)("button",{onClick:j,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)(h.A,{className:"w-5 h-5"})})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[ee&&(0,r.jsx)("div",{className:"w-60 flex-shrink-0 border-r border-border overflow-y-auto",children:K.map(e=>{let t;return(0,r.jsxs)("div",{onClick:()=>eg(e),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${Z===e.key?"bg-brand/10":""}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.shortHash&&(0,r.jsx)("span",{className:"font-mono text-xs text-brand",children:e.shortHash}),void 0!==e.timestamp&&(0,r.jsx)("span",{className:"text-xs text-foreground-subtle",children:A(e.timestamp)}),e.changeClass&&(0,r.jsx)("span",{className:"ml-auto",children:(0,r.jsx)(P,{cls:e.changeClass})})]}),(0,r.jsx)("div",{className:"text-sm text-foreground whitespace-pre-wrap break-words mt-0.5","data-tooltip":E(e),children:M(e,320,10)}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:N("commitDetail.nChanges",{count:e.files.length})}),(t=function(e){let t=!1,n=0,r=0;for(let s of e.files)(void 0!==s.additions||void 0!==s.deletions)&&(t=!0),n+=s.additions??0,r+=s.deletions??0;return t?{additions:n,deletions:r}:null}(e))&&(t.additions>0||t.deletions>0)?(0,r.jsx)(I,{additions:t.additions,deletions:t.deletions}):null]})]},e.key)})}),(0,r.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:q?ev(N("diffViewer.loadingSnapshots")):0===K.length?ev(N("diffViewer.noChanges")):ef?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-border text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,r.jsx)(m.A,{className:"w-3.5 h-3.5"}),ef.toolName]}),ef.shortHash&&(0,r.jsx)("span",{className:"font-mono text-brand",children:ef.shortHash}),void 0!==ef.timestamp&&(0,r.jsx)("span",{children:A(ef.timestamp)}),(0,r.jsx)("span",{className:"flex-1 min-w-0 whitespace-pre-wrap break-words","data-tooltip":E(ef),children:M(ef,640,6)}),ef.truncated&&(0,r.jsx)("span",{className:"text-amber-11",children:N("diffViewer.truncated")}),ef.legacy&&(0,r.jsx)("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 dark:text-amber-400","data-tooltip":N("diffViewer.reconstructedHint"),children:N("diffViewer.reconstructed")}),(0,r.jsx)("div",{className:"ml-auto flex items-center gap-2",children:!ep?.isImage&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(x.y,{value:en,onChange:er}),(0,r.jsx)(p.q,{value:es,onChange:el})]})})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[ee&&(0,r.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:(0,r.jsx)(f.VO,{files:ex,selectedPath:X,expandedPaths:Q,onToggle:e=>Y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:e=>{!e.isDirectory&&e.file&&(G(e.file.path),window.innerWidth<768&&et(!1))},cwd:t||"",showChanges:!0,renderActions:e=>{if(e.isDirectory)return null;let t=e.file;return t?(0,r.jsxs)(r.Fragment,{children:[t.fileClass&&(0,r.jsx)(P,{cls:t.fileClass}),t.external&&(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0","data-tooltip":N("diffViewer.externalChange")})]}):null}})}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:ep?ep.isImage?(0,r.jsx)(g.K,{filePath:ep.path,oldSrc:t&&ep.oldRev?L(t,ep.oldRev,ep.path):null,newSrc:t&&ep.newRev?L(t,ep.newRev,ep.path):null}):ep.unviewable?(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:N("diffViewer.notViewable")}):"unified"===es?(0,r.jsx)(b.xU,{oldContent:ep.old_string,newContent:ep.new_string,filePath:ep.path,cwd:t,enableComments:!0,onContentSearch:C,compact:"compact"===en,onPreview:"deleted"===ep.status?void 0:(0,v.e$)(ep.path)?()=>ea(!0):(0,v.aR)(ep.path)?()=>ec(!0):ep.path.endsWith(".json")?()=>eu({content:ep.new_string,filePath:ep.path}):void 0,previewLabel:ep.path.endsWith(".json")?N("common.readable"):N("common.preview")}):(0,r.jsx)(b.xZ,{oldContent:ep.old_string,newContent:ep.new_string,filePath:ep.path,isNew:"added"===ep.status,isDeleted:"deleted"===ep.status,cwd:t,enableComments:!0,onContentSearch:C,compact:"compact"===en,onPreview:"deleted"===ep.status?void 0:(0,v.e$)(ep.path)?()=>ea(!0):(0,v.aR)(ep.path)?()=>ec(!0):ep.path.endsWith(".json")?()=>eu({content:ep.new_string,filePath:ep.path}):void 0,previewLabel:ep.path.endsWith(".json")?N("common.readable"):N("common.preview")}):(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:N("diffViewer.selectFileToView")})})]})]}):ev(N("diffViewer.selectFileToView"))})]}),eo&&ep&&(0,r.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>ea(!1),children:(0,r.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[95%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(y.M,{content:ep.new_string,filePath:ep.path,cwd:t||"",onClose:()=>ea(!1)})})}),ei&&ep&&(0,r.jsx)(w.N,{filePath:ep.path,content:ep.new_string,cwd:t,onClose:()=>ec(!1),onContentSearch:C}),ed&&(0,r.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>eu(null),children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[95%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:ed.filePath}),(0,r.jsx)("button",{onClick:()=>eu(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)(h.A,{className:"w-4 h-4"})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,v.xb)(ed.content)})})]})})]})})}function F({toolCalls:e,cwd:t,sessionId:n,runId:s,onClose:l,onContentSearch:o}){return(0,r.jsx)(d.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim",onClick:l,children:(0,r.jsx)(_,{toolCalls:e,cwd:t,sessionId:n,runId:s,onClose:l,onContentSearch:o?e=>{l(),o(e)}:void 0})})})}},46266:(e,t,n)=>{n.d(t,{M:()=>y});var r=n(95155),s=n(12115),l=n(83897),o=n(57125),a=n(55779),i=n(1058),c=n(90717),d=n(89109),u=n(7320),h=n(79114),m=n(86957),f=n(83448),x=n(62111),p=n(64428);let g=/[,,]/;function b({initialRows:e,lang:t,isCustomized:n,onSave:l,onRestoreDefault:o,onClose:a}){let{t:i}=(0,h.Bd)(),[c,d]=(0,s.useState)(()=>e.map(e=>e.join("zh"===t?",":", ")).join("\n"));(0,x.E)(a);let u=(0,s.useCallback)(()=>{l(c.split("\n").map(e=>e.split(g).map(e=>e.trim().slice(0,200)).filter(Boolean).slice(0,8)).filter(e=>e.length>0).slice(0,12)),a()},[c,l,a]),m=(0,s.useCallback)(()=>{o(),a()},[o,a]);return(0,r.jsx)(p.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim p-4",onClick:a,children:(0,r.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-lv3 w-full max-w-md flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-foreground",children:i("quickReply.editTitle")}),(0,r.jsx)("button",{onClick:a,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors","aria-label":i("quickReply.cancel"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsxs)("div",{className:"px-4 py-3 flex flex-col gap-2",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:i("quickReply.editHint")}),(0,r.jsx)("textarea",{autoFocus:!0,value:c,onChange:e=>d(e.target.value),placeholder:i("quickReply.editPlaceholder"),rows:6,spellCheck:!1,className:"w-full px-2 py-1.5 text-xs font-mono bg-background border border-border rounded text-foreground focus:outline-none focus:border-brand resize-y"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:i("quickReply.customizedFor",{lang:i("zh"===t?"quickReply.langZh":"quickReply.langEn")})})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-border",children:[(0,r.jsx)("button",{onClick:m,disabled:!n,className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:i("quickReply.restoreDefault")}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:a,className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-hover transition-colors",children:i("quickReply.cancel")}),(0,r.jsx)("button",{onClick:u,className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",children:i("quickReply.save")})]})]})]})})})}function v({value:e}){let[t,n]=(0,s.useState)(e),l=(0,s.useRef)(e),o=(0,s.useRef)(null);return(0,s.useEffect)(()=>{null!==o.current&&(cancelAnimationFrame(o.current),o.current=null);let t=l.current;if(e<=t){l.current=e,n(e);return}let r=performance.now(),s=a=>{let i=Math.min(1,Math.ceil(12*Math.min(1,(a-r)/400))/12),c=Math.round(t+(e-t)*i);l.current=c,n(c),i<1?o.current=requestAnimationFrame(s):o.current=null};return o.current=requestAnimationFrame(s),()=>{null!==o.current&&cancelAnimationFrame(o.current),o.current=null}},[e]),(0,r.jsx)("span",{className:"tabular-nums",children:t})}let y=(0,s.forwardRef)(function({messages:e,isLoading:t,cwd:n,sessionId:x,engine:p,apiRetryInfo:g,liveOutputTokens:y,runningStartedAt:w,hasMoreHistory:k,isLoadingMore:j,onLoadMore:C,onFork:N,isActive:S=!0,onContentSearch:L,onShowFileDiff:E,onOpenFileLink:M,onApprovePlan:R},T){let $,{t:I,i18n:P}=(0,h.Bd)(),A=(0,s.useRef)(null),_=(0,s.useRef)(null),F=(0,s.useRef)(null),B=(0,s.useRef)(null),[D,W]=(0,s.useState)(null),[O,V]=(0,s.useState)(!0),[z,H]=(0,s.useState)(!1),[U,q]=(0,s.useState)(!1),[K,Z]=(0,s.useState)(!1),[J,X]=(0,s.useState)(!1),[G,Q]=(0,s.useState)(0);(0,s.useEffect)(()=>{W(B.current)},[]),(0,s.useEffect)(()=>{if(!t||!w)return void Q(0);let e=()=>Q(Math.max(0,Math.floor((Date.now()-w)/1e3)));e();let n=setInterval(e,1e3);return()=>clearInterval(n)},[t,w]);let Y=(0,s.useMemo)(()=>(0,o.ch)(p)?o.H[p]:o.H.claude,[p]),ee=(0,o.ch)(p)?p:"claude",et=(0,s.useMemo)(()=>{let e=Math.floor(G/60),t=G%60;return e>0?`${e}m${t}s`:`${t}s`},[G]),{isSearchVisible:en,searchQuery:er,setSearchQuery:es,matches:el,currentMatchIndex:eo,goToNextMatch:ea,goToPrevMatch:ei,closeSearch:ec,searchInputRef:ed,handleSearchKeyDown:eu}=function(e){let[t,n]=(0,s.useState)(!1),[r,l]=(0,s.useState)(""),[o,a]=(0,s.useState)([]),[i,c]=(0,s.useState)(0),d=(0,s.useRef)(null),u=(0,s.useRef)([]),h=(0,s.useCallback)(()=>{let t=e.current;t&&(t.querySelectorAll("mark.chat-search-match, mark.chat-search-current").forEach(e=>{let t=e.parentNode;t&&(t.replaceChild(document.createTextNode(e.textContent||""),e),t.normalize())}),u.current=[])},[e]),m=(0,s.useCallback)(t=>{if(h(),!t||!e.current){a([]),c(0);return}let n=[],r=[],s=t.toLowerCase();e.current.querySelectorAll("[data-message-id]").forEach(e=>{let l,o=e.getAttribute("data-message-id")||"",a=0,i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),c=[];for(;l=i.nextNode();)c.push(l);for(let e of c){let l=(e.textContent||"").toLowerCase(),i=0,c=[];for(;;){let e=l.indexOf(s,i);if(-1===e)break;c.push({start:e,end:e+t.length}),i=e+1}if(0!==c.length)for(let t=c.length-1;t>=0;t--){let s=c[t];e.splitText(s.end);let l=e.splitText(s.start),i=document.createElement("mark");i.className="chat-search-match",i.textContent=l.textContent,l.parentNode.replaceChild(i,l),n.push({messageId:o,markIndex:a}),r.push(i),a++}}}),n.reverse(),r.reverse(),u.current=r,a(n),c(n.length>0?0:-1)},[e,h]);(0,s.useEffect)(()=>{queueMicrotask(()=>m(r))},[r,m]),(0,s.useEffect)(()=>{let e=u.current;e.forEach((e,t)=>{e.className=t===i?"chat-search-current":"chat-search-match"}),i>=0&&i<e.length&&e[i].scrollIntoView({behavior:"smooth",block:"center"})},[i,o]);let f=(0,s.useCallback)(()=>{0!==o.length&&c(e=>(e+1)%o.length)},[o.length]),x=(0,s.useCallback)(()=>{0!==o.length&&c(e=>(e-1+o.length)%o.length)},[o.length]),p=(0,s.useCallback)(()=>{n(!0),setTimeout(()=>d.current?.focus(),0)},[]),g=(0,s.useCallback)(()=>{n(!1),l(""),h(),a([]),c(0)},[h]),b=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?x():f()),"Escape"===e.key&&g()},[f,x,g]);return(0,s.useEffect)(()=>{let t=e.current;if(!t)return;let n=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),e.stopPropagation(),p())};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)},[e,p]),{isSearchVisible:t,searchQuery:r,setSearchQuery:l,matches:o,currentMatchIndex:i,goToNextMatch:f,goToPrevMatch:x,openSearch:p,closeSearch:g,searchInputRef:d,handleSearchKeyDown:b}}(B),eh=(0,l.nH)(),em=(0,s.useRef)(null),ef=(0,s.useRef)(()=>{}),{addComment:ex,refresh:ep}=(0,i._)({cwd:n||"",filePath:c.Un}),[eg,eb]=(0,s.useState)(null),[ev,ey]=(0,s.useState)(null),ew=(0,s.useCallback)(e=>{if(eg||ev)return;let t=window.getSelection();if(!t||t.isCollapsed||!t.rangeCount){em.current=null,ef.current();return}let n=t.toString().trim();if(!n){em.current=null,ef.current();return}let r=t.anchorNode instanceof HTMLElement?t.anchorNode:t.anchorNode?.parentElement;if(r?.closest('[data-role="user"]')){em.current=null,ef.current();return}em.current={x:e.clientX,y:e.clientY,range:{start:0,end:0},selectedText:n,lineSnapshot:n},ef.current()},[eg,ev]),ek=(0,s.useCallback)(e=>{let t=e.target;!(t.closest(".floating-toolbar")||t.closest('[class*="z-[200]"]'))&&em.current&&(em.current=null,ef.current())},[]),ej=(0,s.useCallback)(()=>{let e=em.current;e&&(eb({x:e.x,y:e.y,text:e.selectedText}),em.current=null,ef.current(),window.getSelection()?.removeAllRanges())},[]),eC=(0,s.useCallback)(()=>{let e=em.current;e&&(ey({x:e.x,y:e.y,text:e.selectedText}),em.current=null,ef.current(),window.getSelection()?.removeAllRanges())},[]),eN=(0,s.useCallback)(()=>{let e=em.current;e&&eh&&(em.current=null,ef.current(),window.getSelection()?.removeAllRanges(),(0,c.Ff)(eh.sendMessage,{filePath:c.Un,startLine:0,endLine:0,codeContent:e.selectedText},I("explain.selectionMessage")))},[eh,I]),eS=(0,s.useCallback)(()=>{let e=em.current;if(!e||!L)return;let t=e.selectedText.trim();em.current=null,ef.current(),window.getSelection()?.removeAllRanges(),t&&L(t)},[L]),eL=(0,s.useCallback)(async e=>{eg&&(await ex(0,0,e,eg.text),eb(null))},[eg,ex]),eE=(0,s.useCallback)(async(e,t)=>{if(eh&&n)try{let r=(await (0,c.$3)(n)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));r.push({filePath:c.Un,startLine:0,endLine:0,codeContent:e});let s=(0,c.Gw)(r,t);eh.sendMessage(s),await (0,c.RP)(n),ep()}catch(e){console.error("Failed to send to AI:",e)}},[eh,n,ep]),eM=(0,s.useCallback)((e,t)=>{let n=em.current;if(!n)return;let r=n.selectedText;em.current=null,ef.current(),window.getSelection()?.removeAllRanges(),"comment"===e?ex(0,0,t,r):eE(r,t)},[ex,eE]),eR=($=P.language,$?.toLowerCase().startsWith("zh")?"zh":"en"),[eT,e$]=(0,s.useState)(null),[eI,eP]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=!1;return m.t4.runPromiseExit((0,f.td)()).then(t=>{e||e$("Success"===t._tag?((e,t)=>{if(!e||"object"!=typeof e)return null;let n=e.quickReplies;return n&&"object"==typeof n?(e=>{if(!Array.isArray(e))return null;let t=[];for(let n of e.slice(0,12)){if(!Array.isArray(n))continue;let e=[];for(let t of n.slice(0,8)){if("string"!=typeof t)continue;let n=t.trim().slice(0,200);n&&e.push(n)}e.length&&t.push(e)}return t.length?t:null})(n[t]):null})(t.value,eR):null)}),()=>{e=!0}},[eR]);let eA=(0,s.useCallback)(e=>{m.t4.runPromiseExit((0,f.td)()).then(t=>{let n={..."Success"===t._tag?t.value.quickReplies??{}:{}};return e?n[eR]=e:delete n[eR],m.t4.runPromiseExit((0,f.em)({quickReplies:n})).then(t=>{"Success"===t._tag?e$(e):console.error("Failed to save quick replies:",t.cause)})})},[eR]),e_=(0,s.useCallback)(()=>{em.current=null,ef.current(),window.getSelection()?.removeAllRanges(),eP(!0)},[]),eF=(0,s.useMemo)(()=>eT??d.SZ.map(e=>e.map(e=>I(e))),[eT,I]),eB=(0,s.useCallback)(e=>{ev&&eE(ev.text,e)},[ev,eE]),eD=(0,s.useCallback)(e=>{eg&&eE(eg.text,e)},[eg,eE]),eW=(0,s.useMemo)(()=>{let t=new Set;return e.filter(e=>!t.has(e.id)&&(t.add(e.id),"assistant"!==e.role||!!e.isStreaming||!!e.content||!!e.images?.length||!!e.toolCalls?.length||!!e.parts?.length))},[e]),eO=(0,s.useRef)(0),eV=(0,s.useRef)(!1),ez=(0,s.useCallback)(()=>{let e=F.current;return!e||e.scrollHeight-e.scrollTop-e.clientHeight<50},[]),eH=(0,s.useCallback)(()=>{let e=F.current;return!e||e.scrollTop<50},[]),eU=(0,s.useCallback)(()=>{let e=F.current;if(!e)return;let t=e.querySelectorAll('[data-message-id][data-role="user"]'),n=t[0],r=t[t.length-1],s=e.getBoundingClientRect().top;Z(!!n&&n.getBoundingClientRect().top-s<-12),X(!!r&&r.getBoundingClientRect().top-s>12)},[]),eq=(0,s.useCallback)(()=>{let e=ez(),t=eH();if(V(e),H(!t),q(!e),eU(),t&&k&&!j&&C){let e=F.current;e&&(eO.current=e.scrollHeight,eV.current=!0),C()}},[ez,eH,eU,k,j,C]),eK=(0,s.useCallback)(()=>{_.current?.scrollIntoView({behavior:"smooth"})},[]),eZ=(0,s.useCallback)(()=>{A.current?.scrollIntoView({behavior:"smooth"})},[]),eJ=(0,s.useCallback)(e=>{let t=F.current;if(!t)return;let n=t.querySelector(`[data-message-id="${e}"]`);n&&(n.scrollIntoView({behavior:"smooth",block:"center"}),n.classList.add("ring-2","ring-brand","ring-offset-2"),setTimeout(()=>{n.classList.remove("ring-2","ring-brand","ring-offset-2")},2e3))},[]),eX=(0,s.useCallback)(e=>{let t=F.current;if(!t)return;let n=t.getBoundingClientRect().top,r=Array.from(t.querySelectorAll('[data-message-id][data-role="user"]')),s=e=>e.getBoundingClientRect().top-n,l="prev"===e?[...r].reverse().find(e=>-12>s(e)):r.find(e=>s(e)>12);l&&t.scrollTo({top:t.scrollTop+s(l)-8,behavior:"smooth"})},[]);(0,s.useImperativeHandle)(T,()=>({scrollToMessage:eJ}),[eJ]);let eG=(0,s.useRef)(!0);(0,s.useLayoutEffect)(()=>{if(eG.current||!O||eV.current)return;let e=F.current;e&&(e.scrollTop=e.scrollHeight)},[e,O]),(0,s.useLayoutEffect)(()=>{if(O&&t){let e=F.current;e&&(e.scrollTop=e.scrollHeight)}},[t,O]),(0,s.useLayoutEffect)(()=>{if(eV.current&&!j){let e=F.current;if(e){let t=e.scrollHeight-eO.current;e.scrollTop=t,eV.current=!1}}},[e,j]);let eQ=(0,s.useRef)(!1);return(0,s.useLayoutEffect)(()=>{if(S&&eQ.current&&e.length>0){eQ.current=!1;let e=F.current;e&&(e.scrollTop=e.scrollHeight)}},[S,e.length]),(0,s.useLayoutEffect)(()=>{if(eG.current&&e.length>0)if(eG.current=!1,S){let e=F.current;e&&(e.scrollTop=e.scrollHeight)}else eQ.current=!0},[e.length,S]),(0,s.useEffect)(()=>{S&&eU()},[e,S,eU]),(0,r.jsxs)("div",{ref:B,className:"relative flex-1 min-h-0 overflow-hidden flex flex-col outline-none",tabIndex:-1,onMouseUp:ew,onMouseDown:ek,children:[en&&(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,r.jsx)("input",{ref:ed,type:"text",value:er,onChange:e=>es(e.target.value),onKeyDown:eu,placeholder:I("codeViewer.searchChat"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:el.length>0?`${eo+1}/${el.length}`:I("common.noMatch")}),(0,r.jsx)("button",{onClick:ei,disabled:0===el.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:I("codeViewer.prevShiftEnter"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,r.jsx)("button",{onClick:ea,disabled:0===el.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:I("codeViewer.nextEnter"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,r.jsx)("button",{onClick:ec,className:"p-1 rounded hover:bg-hover",title:I("codeViewer.closeEsc"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{ref:F,onScroll:eq,className:"relative flex-1 min-h-0 overflow-y-auto p-4",children:0!==e.length||t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{ref:_}),k&&(0,r.jsx)("div",{className:"flex justify-center py-3",children:j?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("span",{children:I("chat.loadMoreHistory")})]}):(0,r.jsx)("button",{onClick:C,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:I("chat.scrollUpForMore")})}),eW.map(e=>(0,r.jsx)("div",{"data-message-id":e.id,"data-role":e.role,className:"transition-[box-shadow] duration-300",children:(0,r.jsx)(a.s,{message:e,cwd:n,sessionId:x,onFork:N,forkSupported:!0,onApprovePlan:R,isLoading:t,onContentSearch:L,onShowFileDiff:E,onOpenFileLink:M})},e.id)),t&&(0,r.jsx)("div",{className:"flex justify-start mb-4",children:(0,r.jsxs)("div",{className:"px-1 py-1 max-w-[90%]",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[(0,r.jsx)("span",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center","aria-hidden":"true",children:(0,r.jsx)(o.eV,{engine:ee,className:"h-4 w-4 animate-pulse"})}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground/80",children:[Y," running ",et," \xb7 processing"," ",(0,r.jsx)(v,{value:y?.outputTokens??0})]})]}),g&&(0,r.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-amber-11 border-t border-border/50 pt-2",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{children:["Retrying API call (attempt ",g.attempt,g.maxRetries>0?`/${g.maxRetries}`:"",g.delayMs>0?`, delay ${(g.delayMs/1e3).toFixed(1)}s`:"",")"]}),(g.errorStatus||g.error)&&(0,r.jsxs)("div",{className:"text-muted-foreground/80 break-words",children:[g.errorStatus?`${g.errorStatus}`:"",g.errorStatus&&g.error?" \xb7 ":"",g.error||""]})]})]})]})}),(0,r.jsx)("div",{ref:A})]}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full text-foreground-subtle",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-4xl mb-4",children:"\uD83D\uDCAC"}),(0,r.jsx)("div",{children:I("chat.startConversation")})]})})}),z&&e.length>0&&(0,r.jsx)("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 flex items-center bg-card shadow-lv2 rounded-full",children:(0,r.jsx)("button",{onClick:eK,className:"p-2 text-muted-foreground hover:text-foreground rounded-full transition-all active:scale-95",title:I("chat.jumpToStart"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})})}),U&&e.length>0&&(0,r.jsxs)("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 flex items-center bg-card shadow-lv2 rounded-full",children:[(0,r.jsx)("button",{onClick:eZ,className:"p-2 text-muted-foreground hover:text-foreground rounded-full transition-all active:scale-95",title:I("chat.jumpToLatest"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,r.jsx)("span",{className:"w-px h-4 bg-border"}),(0,r.jsx)("button",{onClick:()=>eX("prev"),disabled:!K,className:"p-2 text-muted-foreground hover:text-foreground rounded-full transition-all active:scale-95 disabled:opacity-40 disabled:hover:text-muted-foreground disabled:active:scale-100 disabled:cursor-default",title:I("chat.jumpToPrevUserMessage"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 5h14M12 19V9m-5 5l5-5 5 5"})})}),(0,r.jsx)("button",{onClick:()=>eX("next"),disabled:!J,className:"p-2 text-muted-foreground hover:text-foreground rounded-full transition-all active:scale-95 disabled:opacity-40 disabled:hover:text-muted-foreground disabled:active:scale-100 disabled:cursor-default",title:I("chat.jumpToNextUserMessage"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 19H5m7-14v10m5-5l-5 5-5-5"})})})]}),D&&(0,r.jsx)(d.fS,{floatingToolbarRef:em,bumpRef:ef,container:D,onAddComment:ej,onSendToAI:eC,onSearch:L?eS:void 0,onExplain:eh?eN:void 0,onQuickReply:eM,quickReplyRows:eF,onEditQuickReplies:e_,isChatLoading:eh?.isLoading}),eI&&(0,r.jsx)(b,{initialRows:eF,lang:eR,isCustomized:null!==eT,onSave:e=>eA(e.length?e:null),onRestoreDefault:()=>eA(null),onClose:()=>eP(!1)}),eg&&D&&(0,r.jsx)(u.t,{x:eg.x,y:eg.y,range:{start:0,end:0},lineSnapshot:eg.text,container:D,onSubmit:eL,onSendToAI:eh?eD:void 0,onClose:()=>eb(null),isChatLoading:eh?.isLoading}),ev&&D&&(0,r.jsx)(u.G,{x:ev.x,y:ev.y,range:{start:0,end:0},lineSnapshot:ev.text,container:D,onSubmit:eB,onClose:()=>ey(null),isChatLoading:eh?.isLoading})]})})},46456:(e,t,n)=>{n.d(t,{$:()=>i,BC:()=>c,Tu:()=>u,lb:()=>a,tj:()=>h,vv:()=>d});var r=n(49433),s=n(82680);let l=(e,t)=>r.tryPromise({try:async()=>{let n=await fetch(e,t);if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()},catch:n=>new s.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),o=(e,t)=>r.tryPromise({try:async()=>{let n=await fetch(e,t);if(!n.ok)throw Error(`HTTP ${n.status}`)},catch:n=>new s.uV({message:`${t.method} ${e} failed`,cause:n})}),a=(e,t)=>l(`/api/comments?cwd=${encodeURIComponent(e)}${t?`&filePath=${encodeURIComponent(t)}`:""}`),i=e=>l(`/api/comments?cwd=${encodeURIComponent(e)}&all=true`),c=e=>l("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),d=(e,t,n)=>l("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,id:t,content:n})}),u=(e,t)=>o(`/api/comments?cwd=${encodeURIComponent(e)}&id=${encodeURIComponent(t)}`,{method:"DELETE"}),h=e=>o(`/api/comments?cwd=${encodeURIComponent(e)}&all=true`,{method:"DELETE"})},47215:(e,t,n)=>{n.d(t,{C6:()=>o,C_:()=>y,Hz:()=>v,WU:()=>w,Zy:()=>b,aR:()=>g,cG:()=>a,d9:()=>i,e$:()=>p,jU:()=>l,oK:()=>k,u:()=>x,xb:()=>c,zs:()=>m});var r=n(12115),s=n(69809);function l(e){try{return JSON.parse(e),!0}catch{return!1}}function o(e){try{let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}let a={key:"hsl(var(--blue-11))",str:"hsl(var(--green-11))",num:"hsl(var(--violet-11))",bool:"hsl(var(--red-11))",punct:"hsl(var(--slate-11))",fold:"hsl(var(--slate-11))"},i=r.createContext({version:0,collapsed:!1});function c(e,t=a){try{let n=JSON.parse(e);return h(n,0,t)}catch{return e}}let d=(e,t)=>r.createElement("span",{style:{color:e}},t);function u({label:e,labelColor:t,value:n,indent:l,colors:o}){let a=r.useContext(i),[c,m]=r.useState(null),f=c&&c.version===a.version?c.collapsed:a.collapsed,[x,p]=r.useState({x:0,y:0}),g="string"==typeof n&&n.replace(/\\n/g,"\n").split("\n").length>3,b={onMouseDown:e=>{p({x:e.clientX,y:e.clientY})},onClick:e=>{let t=e.clientX-x.x,n=e.clientY-x.y;t*t+n*n>25||(e.stopPropagation(),m({version:a.version,collapsed:!f}))},style:{cursor:"pointer"}};if(g&&f&&"string"==typeof n){let l=n.replace(/\\n/g,"\n").split("\n")[0],a=n.replace(/\\n/g,"\n").split("\n").length;return r.createElement("span",b,d(t,e),d(o.punct,": "),d(o.str,l),d(o.fold,` ${s.A.t("toolCall.foldedLines",{count:a})}`))}let v=r.createElement(r.Fragment,null,d(t,e),d(o.punct,": "),h(n,l,o));return g?r.createElement("span",b,v):v}function h(e,t,n){let s=" ".repeat(t);if(null===e)return d(n.bool,"null");if(void 0===e)return d(n.bool,"undefined");if("string"==typeof e){let t=e.replace(/\\n/g,"\n").replace(/\n/g,"\n"+s);return d(n.str,t)}if("number"==typeof e)return d(n.num,String(e));if("boolean"==typeof e)return d(n.bool,String(e));if(Array.isArray(e))return 0===e.length?d(n.punct,"[]"):r.createElement(r.Fragment,null,d(n.punct,"["),"\n",...e.map((l,o)=>r.createElement("span",{key:o},s+" ",r.createElement(u,{label:`[${o}]`,labelColor:n.key,value:l,indent:t+1,colors:n}),o<e.length-1?r.createElement(r.Fragment,null,d(n.punct,","),"\n"):"\n")),s,d(n.punct,"]"));if("object"==typeof e){let l=Object.entries(e);return 0===l.length?d(n.punct,"{}"):r.createElement(r.Fragment,null,d(n.punct,"{"),"\n",...l.map(([e,o],a)=>r.createElement("span",{key:e},s+" ",r.createElement(u,{label:e,labelColor:n.key,value:o,indent:t+1,colors:n}),a<l.length-1?r.createElement(r.Fragment,null,d(n.punct,","),"\n"):"\n")),s,d(n.punct,"}"))}return String(e)}function m(e){try{let t=JSON.parse(e);if(t&&"string"==typeof t.file_path&&"string"==typeof t.old_string&&"string"==typeof t.new_string)return t}catch{}return null}let f=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function x(e){let t=e.slice(e.lastIndexOf(".")).toLowerCase();return f.has(t)}function p(e){return e.toLowerCase().endsWith(".md")}function g(e){let t=e.toLowerCase();return t.endsWith(".html")||t.endsWith(".htm")}function b(e){let t=e.toLowerCase();return t.endsWith(".csv")||t.endsWith(".tsv")}function v(e){return e.toLowerCase().endsWith(".json")}function y(e){return"skill.md"===e.slice(e.lastIndexOf("/")+1).toLowerCase()}function w(e,t){let n=t.startsWith("/")?[]:e.split("/").slice(0,-1);for(let e of t.replace(/^\//,"").split("/"))""!==e&&"."!==e&&(".."===e?n.pop():n.push(e));return n.join("/")}function k(e){try{let t=JSON.parse(e);if(t&&"string"==typeof t.file_path)return t.file_path}catch{let t=e.trim();if(t.startsWith("/")&&!t.includes("\n")&&t.length<500)return t}return null}},48347:(e,t,n)=>{n.d(t,{H:()=>o,r:()=>a});var r=n(95155),s=n(12115);let l=(0,s.createContext)(null);function o({value:e,children:t}){return(0,r.jsx)(l.Provider,{value:e,children:t})}function a(){return(0,s.useContext)(l)}},48661:(e,t,n)=>{n.d(t,{q:()=>l});var r=n(95155),s=n(79114);function l({value:e,onChange:t,className:n}){let{t:o}=(0,s.Bd)();return(0,r.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${n??""}`,children:["split","unified"].map(n=>(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),t(n)},className:`px-2 py-0.5 text-xs transition-colors ${e===n?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:o("split"===n?"diffViewer.viewSplit":"diffViewer.viewUnified")},n))})}},48764:(e,t,n)=>{n.d(t,{Bz:()=>c,Hy:()=>o,L5:()=>a,hp:()=>i});var r=n(49433),s=n(82680);let l=(e,t)=>r.tryPromise({try:async()=>{let n=await fetch(e,t);if(!n.ok){let e;try{e=(await n.json()).error}catch{}throw Error(e||`HTTP ${n.status}`)}return await n.json()},catch:n=>new s.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),o=()=>l("/api/skills"),a=e=>l("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),i=e=>l(`/api/skills/${encodeURIComponent(e)}`,{method:"DELETE"}),c=e=>l(`/api/skills/content?id=${encodeURIComponent(e)}`)},50860:(e,t,n)=>{n.d(t,{I:()=>a});var r=n(95155),s=n(12115),l=n(86957),o=n(60938);function a(e){let{refreshKey:t,className:n="h-full flex items-center justify-center p-4 bg-secondary",imgClassName:a="max-w-full max-h-full object-contain",alt:i}=e,c="absPath"in e&&"string"==typeof e.absPath,d=c?void 0:e.cwd,u=c?void 0:e.path,h=c?e.absPath:void 0,[m,f]=(0,s.useState)({kind:"loading"}),x=(0,s.useRef)(0);if((0,s.useEffect)(()=>{let e=++x.current;return f({kind:"loading"}),(async()=>{if(c){if(e!==x.current)return;f({kind:"ready",etag:null,size:0});return}let t=await l.t4.runPromiseExit((0,o.r6)(d,u));if(e!==x.current)return;if("Failure"===t._tag){let e="Fail"===t.cause._tag?t.cause.error:null,n=e?.cause;f({kind:"error",message:n instanceof Error?n.message:"Unknown error"});return}let n=t.value;if(!n.ok)return f({kind:"error",message:`stat failed (${n.status})`});let r=n.data;r&&r.exists?"too-large"===r.category?f({kind:"too-large",size:r.size??0}):"image"!==r.category?f({kind:"error",message:`Not an image (${r.category})`}):f({kind:"ready",etag:r.etag||`t-${r.mtimeMs??Date.now()}`,size:r.size??0}):f({kind:"missing"})})(),()=>{x.current++}},[c,d,u,h,t]),"loading"===m.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})});if("missing"===m.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("div",{className:"text-sm text-muted-foreground",children:"File not found"})});if("too-large"===m.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsxs)("div",{className:"text-sm text-muted-foreground",children:["Image too large to preview (",Math.round(m.size/1024/1024)," MB)"]})});if("error"===m.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("div",{className:"text-sm text-red-11",children:m.message})});let p=c?`/api/file?path=${encodeURIComponent(h)}&raw=true`:`/api/files/read?cwd=${encodeURIComponent(d)}&path=${encodeURIComponent(u)}&v=${encodeURIComponent(m.etag)}`;return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("img",{src:p,alt:i??(u||h),className:a})})}},51145:(e,t,n)=>{n.d(t,{K:()=>l});var r=n(49433),s=n(82680);let l=(e,t)=>{let n,l;return n=`/api/files/text?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,l={cache:"no-store"},r.tryPromise({try:async()=>{let e=await fetch(n,l),t=null;try{t=await e.json()}catch{}return{status:e.status,ok:e.ok,data:t}},catch:e=>new s.uV({message:`GET ${n} failed`,cause:e})})}},53377:(e,t,n)=>{n.d(t,{xU:()=>L,xZ:()=>S});var r=n(95155),s=n(12115),l=n(79114),o=n(64702),a=n(22576),i=n(34075),c=n(56978),d=n(17196);function u({lines:e,containerRef:t}){let n=(0,s.useRef)(null),[l,o]=(0,s.useState)({top:0,height:0});if((0,s.useEffect)(()=>{let e=t.current;if(!e)return;let r=()=>{let{scrollTop:t,scrollHeight:r,clientHeight:s}=e,l=n.current?.clientHeight||0;if(r<=s)o({top:0,height:l});else{let e=l/r;o({top:t*e,height:s*e})}};return r(),e.addEventListener("scroll",r),window.addEventListener("resize",r),()=>{e.removeEventListener("scroll",r),window.removeEventListener("resize",r)}},[t]),0===e.length)return null;let a=100/e.length;return(0,r.jsxs)("div",{ref:n,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:e=>{let r=t.current,s=n.current;if(!r||!s)return;let l=s.getBoundingClientRect(),o=(e.clientY-l.top)/l.height*r.scrollHeight-r.clientHeight/2;r.scrollTo({top:Math.max(0,o),behavior:"smooth"})},children:[e.map((e,t)=>"unchanged"!==e.type&&(0,r.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===e.type?"bg-red-9":"bg-green-9"}`,style:{top:`${t*a}%`,height:`${Math.max(a,.5)}%`,minHeight:"2px"}},t)),(0,r.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${l.top}px`,height:`${Math.max(l.height,10)}px`}})]})}var h=n(47650),m=n(1058),f=n(90717),x=n(69809),p=n(70188),g=n(48347),b=n(89109),v=n(7320),y=n(37614),w=n(27570);function k({cwd:e,enableComments:t=!1,filePath:n,diffLines:l,containerEl:o,onContentSearch:a}){let i=(0,p.iN)(),c=(0,g.r)(),d=t&&!!e,{comments:u,addComment:j,updateComment:C,deleteComment:N,refresh:S}=(0,m._)({cwd:e||"",filePath:n}),[L,E]=(0,s.useState)(null),{toolbarRef:M,bumpRef:R,clearToolbar:T}=(0,w.L)({enabled:d,container:o,resolveLineRange:e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,n=t?.closest("[data-new-line]");if(!n)return null;let r=parseInt(n.getAttribute("data-new-line")||"0",10);return!Number.isFinite(r)||r<=0?null:{start:r,end:r}},buildLineSnapshot:({start:e,end:t})=>{let n=[],r=0;for(let s of l)("unchanged"===s.type||"added"===s.type)&&++r>=e&&r<=t&&n.push(s.content);return n.join("\n")}}),[$,I]=(0,s.useState)(null),[P,A]=(0,s.useState)(null),[_,F]=(0,s.useState)(!1);(0,s.useEffect)(()=>{F(!0)},[]);let B=(0,s.useMemo)(()=>{let e=new Set;for(let t of u)for(let n=t.startLine;n<=t.endLine;n++)e.add(n);return e},[u]),D=(0,s.useMemo)(()=>{let e=new Map;for(let t of u){let n=t.endLine;e.has(n)||e.set(n,[]),e.get(n).push(t)}return e},[u]),W=(0,s.useCallback)((e,t)=>{t.stopPropagation(),E({comment:e,x:t.clientX,y:t.clientY}),T(),I(null),A(null)},[T]),O=(0,s.useCallback)(()=>{let e=M.current;e&&(I({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),T())},[T,M]),V=(0,s.useCallback)(()=>{let e=M.current;e&&(A({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),T())},[T,M]),z=(0,s.useCallback)(()=>{let e=M.current;e&&c&&(T(),(0,f.Ff)(c.sendMessage,{filePath:n,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot},x.A.t("explain.selectionMessage")))},[c,n,T,M]),H=(0,s.useCallback)(()=>{let e=M.current;if(!e||!a)return;let t=e.selectedText.trim();T(),t&&a(t)},[a,T,M]),U=(0,s.useCallback)(async(t,r)=>{if(c&&e)try{let s=await (0,f.$3)(e),l=[];for(let e of s)l.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});l.push({filePath:n,startLine:t.range.start,endLine:t.range.end,codeContent:t.lineSnapshot});let o=(0,f.Gw)(l,r);c.sendMessage(o),await (0,f.RP)(e),S()}catch(e){console.error("Failed to send to AI:",e)}},[c,n,e,S]),q=(0,s.useCallback)(e=>{P&&U(P,e)},[P,U]),K=(0,s.useCallback)(e=>{$&&U($,e)},[$,U]),Z=(0,s.useCallback)(async e=>{$&&(await j($.range.start,$.range.end,e,$.selectedText),I(null))},[$,j]),J=_&&i?(0,h.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(b.fS,{floatingToolbarRef:M,bumpRef:R,container:i,onAddComment:O,onSendToAI:V,onSearch:a?H:void 0,onExplain:c?z:void 0,isChatLoading:c?.isLoading??!1}),$&&(0,r.jsx)(v.t,{x:$.x,y:$.y,range:$.range,filePath:n,lineSnapshot:$.lineSnapshot,container:i,onSubmit:Z,onSendToAI:c?K:void 0,onClose:()=>I(null),isChatLoading:c?.isLoading}),P&&(0,r.jsx)(v.G,{x:P.x,y:P.y,range:P.range,filePath:n,lineSnapshot:P.lineSnapshot,container:i,onSubmit:q,onClose:()=>A(null),isChatLoading:c?.isLoading}),L&&(0,r.jsx)(y.t,{x:L.x,y:L.y,comment:L.comment,container:i,onClose:()=>E(null),onUpdateComment:C,onDeleteComment:N})]}),i):null;return{commentsEnabled:d,linesWithComments:B,commentsByEndLine:D,handleCommentBubbleClick:W,addCommentRange:$?.range??null,sendToAIRange:P?.range??null,commentPortal:J}}var j=n(96497);function C(e){return(0,s.useCallback)((t,n)=>{if(!e||n<=0)return;let r=(0,j.A)(t,t.currentTarget);r&&e(n,r.column,r.rect)},[e])}function N(e){return e.params?`${e.name}(${e.params.join(", ")})`:e.name}function S({oldContent:e,newContent:t,filePath:n,isNew:h=!1,isDeleted:m=!1,cwd:f,enableComments:x=!1,onPreview:p,previewLabel:g,onContentSearch:b,targetLine:v,compact:y=!1,symbols:w,onTokenHover:j,onTokenHoverLeave:L,onTokenHoverCancel:E}){let{t:M}=(0,l.Bd)(),R=C(j),T=g??M("common.preview"),$=(0,s.useMemo)(()=>(0,a.X)(e,t),[e,t]),I=(0,s.useRef)(null),P=(0,s.useRef)(null),A=(0,s.useRef)(null),_=(0,s.useRef)(!1),[F,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{A.current!==F&&B(A.current)});let{commentsEnabled:D,linesWithComments:W,commentsByEndLine:O,handleCommentBubbleClick:V,addCommentRange:z,sendToAIRange:H,commentPortal:U}=k({cwd:f,enableComments:x,filePath:n,diffLines:$,containerEl:F,onContentSearch:b});(0,s.useEffect)(()=>{let e=P.current,t=A.current;if(!e||!t)return;let n=(e,t)=>{_.current||(_.current=!0,t.scrollLeft=e.scrollLeft,requestAnimationFrame(()=>{_.current=!1}))},r=()=>n(e,t),s=()=>n(t,e);return e.addEventListener("scroll",r),t.addEventListener("scroll",s),()=>{e.removeEventListener("scroll",r),t.removeEventListener("scroll",s)}},[]);let{leftLines:q,rightLines:K}=(0,s.useMemo)(()=>{let e=[],t=[],n=0,r=0;for(let s=0;s<$.length;s++){let l=$[s];if("unchanged"===l.type){for(;e.length<t.length;)e.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;t.length<e.length;)t.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});n++,r++,e.push({lineNum:n,content:l.content,type:"unchanged",originalIdx:s}),t.push({lineNum:r,content:l.content,type:"unchanged",originalIdx:s})}else"removed"===l.type?(n++,e.push({lineNum:n,content:l.content,type:"removed",originalIdx:s})):"added"===l.type&&(r++,t.push({lineNum:r,content:l.content,type:"added",originalIdx:s}))}for(;e.length<t.length;)e.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;t.length<e.length;)t.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});return{leftLines:e,rightLines:t}},[$]),Z=(0,s.useMemo)(()=>$.map(e=>e.content),[$]),J=(0,c.C)(Z,n),[X,G]=(0,s.useState)(()=>new Map);(0,s.useLayoutEffect)(()=>{G(new Map),el.measure()},[q,K]);let Q=(0,s.useMemo)(()=>w??[],[w]),{rows:Y,gaps:ee}=(0,s.useMemo)(()=>y?function(e,t,n,r=[]){let s=e.length,l=n=>"unchanged"!==e[n].type||"unchanged"!==t[n].type,o=new Set;for(let e=0;e<s;e++){if(!l(e))continue;let t=Math.max(0,e-3),n=Math.min(s-1,e+3);for(let e=t;e<=n;e++)o.add(e)}let a=[];for(let e=0;e<s;e++){if(o.has(e))continue;let t=e;for(;e<s&&!o.has(e);)e++;a.push({id:a.length,startIdx:t,endIdx:e-1}),e--}for(let e of a){let t=n.get(e.id)??{topRevealed:0,bottomRevealed:0},r=e.endIdx-e.startIdx+1,s=Math.max(0,Math.min(t.topRevealed,r)),l=Math.max(0,Math.min(t.bottomRevealed,r-s));for(let t=e.startIdx;t<e.startIdx+s;t++)o.add(t);for(let t=e.endIdx-l+1;t<=e.endIdx;t++)o.add(t)}let i=[];for(let e=0;e<s;e++){let n;if(o.has(e)){i.push({kind:"diff",idx:e});continue}let l=e;for(;e<s&&!o.has(e);)e++;let c=e-1;e--;let d=a.find(e=>e.startIdx<=l&&c<=e.endIdx);if(!d)continue;let u=c-l+1,h=Math.min(20,u);if(r.length>0&&c+1<s)for(let e=c+1;e<s;e++){let s=t[e].lineNum;if(!(s<=0)){n=function(e,t){let n=null;for(let r of e)r.startLine<=t&&t<=r.endLine&&(!n||r.endLine-r.startLine<n.endLine-n.startLine)&&(n=r);return n}(r,s)??void 0;break}}i.push({kind:"gap-expand",gapId:d.id,direction:"up",revealCount:h}),i.push({kind:"gap-label",gapId:d.id,hiddenCount:u,enclosingFn:n}),i.push({kind:"gap-expand",gapId:d.id,direction:"down",revealCount:h})}return{rows:i,gaps:a}}(q,K,X,Q):{rows:q.map((e,t)=>({kind:"diff",idx:t})),gaps:[]},[y,q,q,K,X,Q]),et=(0,s.useCallback)((e,t)=>{let n=ee.find(t=>t.id===e);n&&G(r=>{let s=r.get(e)??{topRevealed:0,bottomRevealed:0},l=n.endIdx-n.startIdx+1-s.topRevealed-s.bottomRevealed;if(l<=0)return r;let o=Math.min(20,l),a="up"===t?{...s,topRevealed:s.topRevealed+o}:{...s,bottomRevealed:s.bottomRevealed+o};return new Map(r).set(e,a)})},[ee]),en=(0,s.useCallback)(e=>{for(let t of ee)if(e>=t.startIdx&&e<=t.endIdx)return t.id;return null},[ee]),er=(0,s.useCallback)(e=>Y[e]?.kind==="gap-label"?28:20,[Y]),es=(0,s.useCallback)(e=>{let t=Y[e];if(!t)return e;if("gap-label"===t.kind)return`gl:${t.gapId}`;if("gap-expand"===t.kind)return`ge:${t.gapId}:${t.direction}`;let n=q[t.idx],r=K[t.idx];return`d:${n?.lineNum??"x"}:${n?.type??"x"}:${r?.lineNum??"x"}:${r?.type??"x"}`},[Y,q,K]),el=(0,o.Te)({count:Y.length,getScrollElement:()=>I.current,estimateSize:er,getItemKey:es,overscan:20}),eo=h?"w-1/4":m?"w-3/4":"w-1/2",ea=h?"w-3/4":m?"w-1/4":"w-1/2",ei=(0,s.useMemo)(()=>Y.map(e=>{if("diff"!==e.kind)return{type:"unchanged"};let t=q[e.idx],n=K[e.idx];return"removed"===t.type?{type:"removed"}:n?.type==="added"?{type:"added"}:{type:"unchanged"}}),[Y,q,K]),ec=el.getTotalSize(),ed=el.getVirtualItems();return(0,s.useEffect)(()=>{if(!v)return;let e=("after"===v.side?K:q).findIndex(e=>e.lineNum===v.line);if(-1===e)return;let t=Y.findIndex(t=>"diff"===t.kind&&t.idx===e);if(-1===t){let t=en(e);if(null!==t){let e=ee.find(e=>e.id===t);if(!e)return;let n=e.endIdx-e.startIdx+1;G(e=>{let r=e.get(t)??{topRevealed:0,bottomRevealed:0};if(r.topRevealed+r.bottomRevealed>=n)return e;let s=new Map(e);return s.set(t,{topRevealed:n,bottomRevealed:0}),s})}return}let n=requestAnimationFrame(()=>{el.scrollToIndex(t,{align:"start"})});return()=>cancelAnimationFrame(n)},[v,q,K,Y]),(0,r.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(0,r.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,r.jsx)("div",{className:`${eo} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:h?"(New File)":m?"Deleted":"Old"}),(0,r.jsxs)("div",{className:`${ea} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,r.jsx)("span",{className:"block text-center",children:m?"(Deleted)":"New"}),(0,r.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[p&&(0,r.jsx)("button",{onClick:p,className:"text-muted-foreground hover:text-foreground transition-colors",children:T}),!m&&t&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(t),(0,i.oR)(M("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:M("common.copy")})]})]}),(0,r.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,r.jsx)("div",{ref:I,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,r.jsxs)("div",{className:"flex",style:{height:`${ec}px`},children:[(0,r.jsx)("div",{ref:P,className:`${eo} overflow-x-auto border-r border-border`,children:(0,r.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:ed.map(e=>{let t=Y[e.index];if("gap-expand"===t.kind||"gap-label"===t.kind){let n="gap-label"===t.kind;return(0,r.jsx)("div",{ref:el.measureElement,"data-index":e.index,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,er(e.index))}px`,transform:`translateY(${e.start}px)`},className:n?"bg-accent border-y border-border":""},e.key)}let n=q[t.idx];return(0,r.jsxs)("div",{ref:el.measureElement,"data-index":e.index,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,er(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${"removed"===n.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:n.lineNum||""}),(0,r.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:n.originalIdx>=0&&J[n.originalIdx]||(0,d.ZD)(n.content||" ")}})]},e.key)})})}),(0,r.jsx)("div",{ref:A,className:`${ea} overflow-x-auto`,children:(0,r.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:ed.map(e=>{let t=Y[e.index];if("gap-expand"===t.kind)return(0,r.jsx)("button",{ref:el.measureElement,"data-index":e.index,type:"button",onClick:()=>et(t.gapId,t.direction),style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,er(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center text-[11px] text-foreground/50 hover:bg-hover hover:text-brand active:bg-brand/15 transition-colors duration-100 cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-brand/60",title:M("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),"aria-label":M("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),children:(0,r.jsx)("span",{className:"select-none",children:M("diffViewer.gap.more",{count:t.revealCount})})},e.key);if("gap-label"===t.kind)return(0,r.jsxs)("div",{ref:el.measureElement,"data-index":e.index,"data-gap-id":t.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,er(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center gap-2 px-3 text-[11px] text-foreground/80 bg-accent border-y border-border min-w-0 select-none",children:[(0,r.jsx)("span",{className:"flex-shrink-0",children:M("diffViewer.gap.hidden",{count:t.hiddenCount})}),t.enclosingFn&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"opacity-50 flex-shrink-0",children:"\xb7"}),(0,r.jsx)("span",{className:"truncate min-w-0 font-medium","data-tooltip":N(t.enclosingFn),children:N(t.enclosingFn)})]})]},e.key);let n=K[t.idx],s=n?.lineNum||0,l=s>0&&W.has(s),o=O.get(s),a=o?.[0],i=z&&s>=z.start&&s<=z.end,c=H&&s>=H.start&&s<=H.end,u=i||c;return(0,r.jsxs)("div",{ref:el.measureElement,"data-index":e.index,"data-new-line":s||void 0,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,er(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${u?"bg-blue-9/20":l?"bg-amber-9/10":n?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,r.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-foreground-subtle select-none border-r border-border ${u?"bg-blue-9/30":""}`,style:{width:D?"52px":"40px"},children:[D&&s>0&&l&&a&&(0,r.jsx)("button",{onClick:e=>V(a,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:M("codeViewer.nComments",{count:o?.length}),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),D&&s>0&&!l&&(0,r.jsx)("span",{className:"w-4"}),(0,r.jsx)("span",{className:"flex-1 text-right pr-1",children:s||""})]}),(0,r.jsx)("span",{className:"whitespace-pre pl-2",onMouseOver:j?e=>R(e,s):void 0,onMouseLeave:j?L:void 0,onMouseDown:j?E:void 0,dangerouslySetInnerHTML:{__html:n?.originalIdx>=0&&J[n.originalIdx]||(0,d.ZD)(n?.content||" ")}})]},e.key)})})})]})}),(0,r.jsx)(u,{lines:ei,containerRef:I})]}),U]})}function L({oldContent:e,newContent:t,filePath:n,cwd:h,enableComments:m=!1,onPreview:f,previewLabel:x,onContentSearch:p,compact:g=!1,onTokenHover:b,onTokenHoverLeave:v,onTokenHoverCancel:y}){let{t:w}=(0,l.Bd)(),j=C(b),N=x??w("common.preview"),S=(0,s.useMemo)(()=>(0,a.X)(e,t),[e,t]),E=(0,s.useRef)(null),M=(0,s.useMemo)(()=>S.map(e=>e.content),[S]),R=(0,c.C)(M,n),[T,$]=(0,s.useState)(null);(0,s.useEffect)(()=>{E.current!==T&&$(E.current)});let{commentsEnabled:I,linesWithComments:P,commentsByEndLine:A,handleCommentBubbleClick:_,addCommentRange:F,sendToAIRange:B,commentPortal:D}=k({cwd:h,enableComments:m,filePath:n,diffLines:S,containerEl:T,onContentSearch:p}),[W,O]=(0,s.useState)(()=>new Set);(0,s.useEffect)(()=>{O(new Set)},[e,t,n]);let V=(0,s.useMemo)(()=>g?function(e,t){let n=e.length,r=Array(n).fill(!1);for(let t=0;t<n;t++){if("unchanged"===e[t].type)continue;let s=Math.max(0,t-3),l=Math.min(n-1,t+3);for(let e=s;e<=l;e++)r[e]=!0}let s=[],l=0,o=0;for(;o<n;){if(r[o]){s.push({kind:"line",line:e[o],index:o}),o++;continue}let a=o;for(;a<n&&!r[a];)a++;let i=l++;if(t.has(i))for(let t=o;t<a;t++)s.push({kind:"line",line:e[t],index:t});else s.push({kind:"gap",id:i,count:a-o});o=a}return s}(S,W):S.map((e,t)=>({kind:"line",line:e,index:t})),[g,S,W]),z=(0,s.useCallback)(e=>{let t=V[e];if(!t)return e;if("gap"===t.kind)return`gap:${t.id}`;let n=t.line;return`${n.type}:${n.oldLineNum??"x"}:${n.newLineNum??"x"}`},[V]),H=(0,o.Te)({count:V.length,getScrollElement:()=>E.current,estimateSize:()=>20,getItemKey:z,overscan:20}),U=(0,s.useMemo)(()=>V.map(e=>"gap"===e.kind?{type:"unchanged"}:{type:e.line.type}),[V]);return(0,r.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(f||t)&&(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-end gap-2 px-2 py-1 border-b border-border bg-accent text-xs",children:[f&&(0,r.jsx)("button",{onClick:f,className:"text-muted-foreground hover:text-foreground transition-colors",children:N}),t&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(t),(0,i.oR)(w("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:w("common.copy")}),(0,r.jsx)("div",{className:"w-4 flex-shrink-0"})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,r.jsx)("div",{ref:E,className:"flex-1 min-w-0 overflow-auto",children:(0,r.jsx)("div",{style:{height:`${H.getTotalSize()}px`,position:"relative"},children:H.getVirtualItems().map(e=>{let t=V[e.index];if(!t)return null;let n={position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${e.size}px`,transform:`translateY(${e.start}px)`};if("gap"===t.kind){let s=w("diffViewer.gap.hidden",{count:t.count});return(0,r.jsx)("div",{style:n,onClick:()=>O(e=>new Set(e).add(t.id)),className:"flex items-center cursor-pointer bg-slate-2 hover:bg-hover border-y border-border text-xs text-foreground-subtle select-none","data-tooltip":s,children:(0,r.jsx)("span",{className:"w-full text-center",children:s})},e.key)}let s=t.line,l="removed"!==s.type?s.newLineNum??0:0,o=l>0&&P.has(l),a=A.get(l),i=a?.[0],c=F&&l>=F.start&&l<=F.end,u=B&&l>=B.start&&l<=B.end;return(0,r.jsxs)("div",{style:n,"data-new-line":l||void 0,className:`flex ${c||u?"bg-blue-9/20":o?"bg-amber-9/10":"removed"===s.type?"bg-red-9/15 dark:bg-red-9/25":"added"===s.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[I&&(0,r.jsx)("span",{className:"w-5 flex-shrink-0 flex items-center justify-center select-none",children:l>0&&o&&i&&(0,r.jsx)("button",{onClick:e=>_(i,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:w("codeViewer.nComments",{count:a?.length}),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})})}),(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:"added"!==s.type?s.oldLineNum:""}),(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:"removed"!==s.type?s.newLineNum:""}),(0,r.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===s.type?"text-red-11":"added"===s.type?"text-green-11":"text-foreground-subtle"}`,children:"removed"===s.type?"-":"added"===s.type?"+":" "}),(0,r.jsx)("span",{className:"flex-1 whitespace-pre pl-1",onMouseOver:b?e=>j(e,l):void 0,onMouseLeave:b?v:void 0,onMouseDown:b?y:void 0,dangerouslySetInnerHTML:{__html:R[t.index]||(0,d.ZD)(s.content||" ")}})]},e.key)})})}),(0,r.jsx)(u,{lines:U,containerRef:E})]}),D]})}},55779:(e,t,n)=>{n.d(t,{s:()=>eu});var r=n(95155),s=n(12115),l=n(34075),o=n(64428),a=n(67635),i=n(54731),c=n(1709),d=n(12651),u=n(81165),h=n(16950),m=n(11019),f=n(12612),x=n(79114),p=n(86957),g=n(67589);function b({cwd:e,sessionId:t,toolCall:n,workflowRef:l,onClose:a}){let{t:i}=(0,x.Bd)(),[c,d]=(0,s.useState)(null),[u,h]=(0,s.useState)(null),[m,f]=(0,s.useState)(!1),v=(0,s.useRef)(void 0),y=l?!!l.running:!n?.result,w=(0,s.useCallback)(async()=>{let r=await p.t4.runPromiseExit((0,g.z)({cwd:e,sessionId:t,...l?{workflowId:l.runId,workflowAgentId:l.agentId}:{toolUseId:n?.id},ifFingerprint:v.current}));if(f(!0),"Success"!==r._tag||!r.value)return;let s=r.value;s.fingerprint&&(v.current=s.fingerprint),!s.notModified&&(s.messages&&d(s.messages),s.subagent&&h(s.subagent))},[e,t,n?.id,l?.runId,l?.agentId]);(0,s.useEffect)(()=>{if(w(),!y)return;let e=setInterval(w,5e3);return()=>clearInterval(e)},[y,w]);let k=(0,s.useRef)(null),j=(0,s.useRef)(!0);(0,s.useEffect)(()=>{let e=k.current;e&&j.current&&(e.scrollTop=e.scrollHeight)},[c]);let C="string"==typeof n?.input?.description?n.input.description:"",N=l?l.label||"":[u?.agentType,C].filter(Boolean).join(" \xb7 ");return(0,r.jsx)(o.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:a,children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-base",children:"\uD83E\uDD16"}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:i("chat.subagent")}),N&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":N,children:N}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[y&&(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("button",{onClick:a,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:i("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsx)("div",{ref:k,onScroll:()=>{let e=k.current;e&&(j.current=e.scrollTop+e.clientHeight>=e.scrollHeight-40)},className:"flex-1 overflow-y-auto px-4 py-3",children:null===c?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:i(m?"chat.subagentEmpty":"common.loading")}):c.map(t=>(0,r.jsx)(eu,{message:t,cwd:e},t.id))})]})})})}function v(e){return e?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):"0"}function y(e){if(!e)return"–";let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return`${n}m${t%60}s`}let w={done:"text-green-9",running:"text-brand",queued:"text-muted-foreground",error:"text-red-9",failed:"text-red-9"};function k({cwd:e,sessionId:t,runId:n,isRunning:l,onClose:a}){let{t:i}=(0,x.Bd)(),[c,d]=(0,s.useState)(null),[u,h]=(0,s.useState)(!1),[m,f]=(0,s.useState)(null),w=(0,s.useRef)(void 0),C=l||null!=c&&"completed"!==c.status&&"failed"!==c.status,N=(0,s.useCallback)(async()=>{let r=await p.t4.runPromiseExit((0,g.z)({cwd:e,sessionId:t,workflowId:n,ifFingerprint:w.current}));if(h(!0),"Success"!==r._tag||!r.value)return;let s=r.value;s.fingerprint&&(w.current=s.fingerprint),!s.notModified&&s.workflow&&d(s.workflow)},[e,t,n]);(0,s.useEffect)(()=>{if(N(),!C)return;let e=setInterval(N,5e3);return()=>clearInterval(e)},[C,N]);let S=[];if(c?.agents){let e=new Map;for(let t of c.agents){let n=t.phaseTitle||i("chat.workflowUngrouped");e.has(n)||e.set(n,[]),e.get(n).push(t)}for(let[t,n]of e)S.push({title:t,agents:n})}let L=c?[c.workflowName,c.status,`${c.agentCount??c.agents?.length??0} ${i("chat.workflowAgents")}`,`${v(c.totalTokens)} tok`,y(c.durationMs)].filter(Boolean).join(" \xb7 "):"";return(0,r.jsxs)(o.ZL,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:a,children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-base",children:"\uD83E\uDDE9"}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:i("chat.workflowRun")}),L&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":L,children:L}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[C&&(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("button",{onClick:a,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:i("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:null===c?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:i(u?"chat.workflowEmpty":"common.loading")}):(0,r.jsxs)(r.Fragment,{children:[c.summary&&(0,r.jsx)("div",{className:"mb-3 text-xs text-muted-foreground whitespace-pre-wrap",children:c.summary}),S.map(e=>(0,r.jsxs)(s.Fragment,{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-foreground/80 mt-3 mb-1 sticky top-0 bg-card py-1",children:e.title}),e.agents.map(e=>(0,r.jsx)(j,{agent:e,onOpen:()=>e.agentId&&f({runId:n,agentId:e.agentId,label:e.label,running:"done"!==e.state&&C})},`${e.index}-${e.agentId}`))]},e.title))]})})]})}),m&&(0,r.jsx)(b,{cwd:e,sessionId:t,workflowRef:m,onClose:()=>f(null)})]})}function j({agent:e,onOpen:t}){let{t:n}=(0,x.Bd)(),[l,o]=(0,s.useState)(!1),a=e.state&&w[e.state]||"text-muted-foreground",i=e.resultPreview||e.promptPreview||"";return(0,r.jsxs)("div",{className:"border border-border rounded-md mb-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,r.jsx)("button",{onClick:()=>o(e=>!e),className:"text-foreground-subtle text-xs flex-shrink-0",title:n(l?"chat.collapse":"chat.expand"),children:l?"▲":"▼"}),(0,r.jsx)("span",{className:"text-xs text-foreground truncate flex-1 min-w-0","data-tooltip":e.label||"",children:e.label||e.agentId}),(0,r.jsx)("span",{className:`text-[10px] flex-shrink-0 ${a}`,children:e.state}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[v(e.tokens)," tok \xb7 ",y(e.durationMs)]}),e.agentId&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:t,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&t()},className:"text-xs text-brand hover:text-teal-10 cursor-pointer flex-shrink-0",title:n("chat.subagentViewTitle"),children:n("chat.workflowViewAgent")})]}),l&&i&&(0,r.jsx)("pre",{className:"text-[11px] bg-secondary px-2 py-1.5 rounded-b overflow-x-auto max-h-32 overflow-y-auto text-muted-foreground whitespace-pre-wrap border-t border-border",children:i})]})}var C=n(60938),N=n(53377),S=n(38408),L=n(13219),E=n(47176),M=n(97251),R=n(34582),T=n(56045),$=n(50860),I=n(47215);function P({filePath:e}){let[t,n]=(0,s.useState)(null),[l,o]=(0,s.useState)(!0),[a,i]=(0,s.useState)(null),c=(0,s.useRef)(!1),d=(0,I.e$)(e),u=(0,I.u)(e);return((0,s.useEffect)(()=>{u?o(!1):c.current||(c.current=!0,(async()=>{o(!0),i(null);let t=await p.t4.runPromiseExit((0,C.nM)(e));if("Success"===t._tag)n(t.value.content??null);else{let e="Fail"===t.cause._tag?t.cause.error:null,n=e?.cause;i(n instanceof Error?n.message:"Failed to load file")}o(!1),c.current=!1})())},[e,u]),a)?(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("div",{className:"text-xs text-red-11",children:a})}):l?(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):(0,I.u)(e)?(0,r.jsx)($.I,{absPath:e,className:"flex items-center justify-center h-full overflow-auto",imgClassName:"max-w-full max-h-full object-contain",alt:e.split("/").pop()||"image"}):t?d?(0,r.jsx)(_,{content:t,filePath:e}):(0,r.jsx)(S.Cv,{content:t,filePath:e,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}let A=[M.W];function _({content:e,filePath:t}){let n=(0,s.useRef)(null),l=(0,s.useMemo)(()=>(0,R.J4)(t),[t]);return(0,r.jsxs)("div",{className:"h-full flex",children:[(0,r.jsx)(E.l,{content:e,containerRef:n}),(0,r.jsx)("div",{ref:n,className:"flex-1 overflow-auto p-4",children:(0,r.jsx)(L.T,{content:e,basePath:l,rehypePlugins:A})})]})}function F({title:e,content:t,toolName:n,onClose:a}){let{t:i}=(0,x.Bd)(),c=(0,I.jU)(t),d=(0,I.zs)(t),u=(0,I.oK)(t),h=!!d,m=!!u,[f,p]=(0,s.useState)(("Read"===n||"Write"===n)&&m?"file":h?"diff-unified":c?"readable":"json"),g=(0,s.useRef)(null),b=(0,T.o)(g);(0,s.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&"readable"===f&&c){e.preventDefault(),b.open();return}if("Escape"===e.key){if(b.isVisible)return void b.close();document.activeElement instanceof HTMLElement&&document.activeElement.blur(),a()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a,f,c,b]);let v=(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:a,children:(0,r.jsxs)("div",{className:"bg-card shadow-lv3 w-full max-w-[90%] h-full md:h-[90vh] rounded-none md:rounded-lg flex flex-col transition-all",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:e}),u&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(u),(0,l.oR)(i("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:i("common.copyAbsPath"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[c&&(0,r.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:()=>p("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===f?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.sideBySide"),children:"Split"}),(0,r.jsx)("button",{onClick:()=>p("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===f?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.unified"),children:"Unified"})]}),m&&(0,r.jsx)("button",{onClick:()=>p("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===f?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.previewFile"),children:"File"}),(0,r.jsx)("button",{onClick:()=>p("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===f?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:i("common.readable")}),(0,r.jsx)("button",{onClick:()=>p("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===f?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,r.jsx)("button",{onClick:a,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"file"===f&&u?(0,r.jsx)(P,{filePath:u}):"diff-unified"===f&&d?(0,r.jsx)(N.xU,{oldContent:d.old_string,newContent:d.new_string,filePath:d.file_path}):"diff-split"===f&&d?(0,r.jsx)(N.xZ,{oldContent:d.old_string,newContent:d.new_string,filePath:d.file_path}):"readable"===f&&c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(T._,{search:b}),(0,r.jsx)("pre",{ref:g,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,I.xb)(t)})]}):(0,r.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:c?(0,I.C6)(t):t})})]})});return(0,r.jsx)(o.ZL,{children:v})}let B={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",ApplyPatch:"\uD83E\uDDE9",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D",Workflow:"\uD83E\uDDE9",Skill:"\uD83D\uDEE0️"};function D(e){return"object"==typeof e&&null!==e}function W({toolCall:e,cwd:t,sessionId:n,disableOverlays:o=!1}){var a;let{t:i}=(0,x.Bd)(),[c,d]=(0,s.useState)(!1),[u,h]=(0,s.useState)(null),[m,f]=(0,s.useState)(!1),[p,g]=(0,s.useState)(!1),v=B[e.name]||"\uD83D\uDD27",y="Agent"===e.name||"Task"===e.name,w=y&&!!t&&!!n,j="Workflow"===e.name,C=j&&(a=e.result)?a.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,N=j&&!!C&&!!t&&!!n,S="Skill"===e.name,L="ApplyPatch"===e.name||y||j||S,E=e=>{if(t&&e.startsWith(t)){let n=e.slice(t.length);return n.startsWith("/")?n.slice(1):n}let n=e.split("/");return n.length>2?".../"+n.slice(-2).join("/"):e},M=(()=>{let t=e.input;if("Bash"===e.name&&t.command&&"string"==typeof t.command)return t.command;if("ApplyPatch"===e.name&&Array.isArray(t.changes)){let e=t.changes.filter(D).flatMap(e=>{let t="string"==typeof e.path?e.path:"";if(!t)return[];let n="string"==typeof e.kind&&e.kind?e.kind:"update";return`${n} ${E(t)}`});if(e.length>0)return e.join(" \xb7 ")}if(y&&t.description&&"string"==typeof t.description)return t.description;if(j){let e=["string"==typeof t.name?t.name:"","string"==typeof t.args?t.args:"string"==typeof t.resumeFromRunId?t.resumeFromRunId:""].filter(Boolean).join(" \xb7 ");if(e)return e}if(S&&"string"==typeof t.skill){let e="string"==typeof t.args?t.args:"";return[t.skill,e].filter(Boolean).join(" \xb7 ")}return"Glob"===e.name&&t.pattern&&"string"==typeof t.pattern||"Grep"===e.name&&t.pattern&&"string"==typeof t.pattern?t.pattern:"ToolSearch"===e.name&&t.query&&"string"==typeof t.query?t.query:"TaskCreate"===e.name&&t.subject&&"string"==typeof t.subject?t.subject:t.file_path&&"string"==typeof t.file_path?t.file_path:t.path&&"string"==typeof t.path?t.path:null})(),R="Glob"===e.name||"Grep"===e.name||"Bash"===e.name||"ApplyPatch"===e.name||y||j||S,T=M?R?M:E(M):null,$=t=>{let n="input"===t?i("toolCall.inputParams"):i("toolCall.resultLabel"),r="input"===t?JSON.stringify(e.input,null,2):"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2);h({title:`${e.name}${T?` ${T}`:""} - ${n}`,content:r,toolName:e.name})};return(0,r.jsxs)("div",{className:"border-b border-line-1 last:border-b-0",children:[(0,r.jsxs)("button",{onClick:()=>d(!c),className:"w-full px-3 py-1.5 flex items-center gap-2 text-left hover:bg-hover transition-colors",children:[(0,r.jsx)("span",{className:"text-sm",children:v}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:e.name}),T&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":M||"",children:T}),!L&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),M&&(navigator.clipboard.writeText(M),(0,l.oR)(i("common.copiedPath")))},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),M&&(navigator.clipboard.writeText(M),(0,l.oR)(i("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0 cursor-pointer",title:i("common.copyAbsPath"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[w&&!o&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),f(!0)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),f(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:i("chat.subagentViewTitle"),children:i("chat.subagent")}),N&&!o&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),g(!0)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),g(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:i("chat.workflowViewTitle"),children:i("chat.workflowRun")}),c&&!e.isLoading&&!o&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),$("input")},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),$("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:i("toolCall.inputParamsTitle"),children:i("toolCall.input")}),e.result&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),$("result")},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),$("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:i("toolCall.resultTitle"),children:i("toolCall.result")})]}),e.isLoading?(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,r.jsx)("span",{className:"text-foreground-subtle text-xs",children:c?"▲":"▼"})]})]}),c&&(0,r.jsxs)("div",{className:"border-t border-line-1",children:[(0,r.jsxs)("div",{className:"px-3 py-2",children:[(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[i("toolCall.inputParams"),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(e.input,null,2)})]}),e.result&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-line-1",children:[(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[i("toolCall.resultLabel"),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2)})]}),e.skillContent&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-line-1",children:[(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[i("toolCall.skillContent",{defaultValue:"Skill content"}),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-60 overflow-y-auto text-foreground whitespace-pre-wrap",children:e.skillContent})]})]}),u&&(0,r.jsx)(F,{title:u.title,content:u.content,toolName:u.toolName,onClose:()=>h(null)}),m&&t&&n&&(0,r.jsx)(b,{cwd:t,sessionId:n,toolCall:e,onClose:()=>f(!1)}),p&&t&&n&&C&&(0,r.jsx)(k,{cwd:t,sessionId:n,runId:C,isRunning:!!e.isLoading,onClose:()=>g(!1)})]})}var O=n(62111),V=n(56204),z=n(33210),H=n(58515),U=n(36201),q=n(55804),K=n(37618),Z=n(83897);function J(e){let t=e.input?.questions||[],n=e.input?.answers||{},r={};if(e.result)try{let t=JSON.parse(e.result);t?.answers&&(r=t.answers)}catch{}return{questions:t,answers:{...n,...r}}}function X(e,t){return`${e}-${t}`}function G({toolCalls:e,onClose:t}){let{t:n}=(0,x.Bd)(),i=(0,Z.nH)(),[c,d]=(0,s.useState)({}),[u,h]=(0,s.useState)({}),[m,f]=(0,s.useState)({}),[p,g]=(0,s.useState)({});(0,s.useEffect)(()=>{let t={};e.forEach((e,n)=>{let{questions:r,answers:s}=J(e);r.forEach((e,r)=>{let l=s[e.question];if(l){let s=X(n,r);t[s]=l,e.options.some(e=>e.label===l)||(h(e=>({...e,[s]:!0})),f(e=>({...e,[s]:l})))}})}),queueMicrotask(()=>d(t))},[e]),(0,O.E)(t);let b=e.reduce((e,t)=>{let{questions:n}=J(t);return e+n.length},0),v=Object.values(p).filter(Boolean).length,y=(0,s.useCallback)((e,t)=>{d(n=>({...n,[e]:t})),h(t=>({...t,[e]:!1}))},[]),w=(0,s.useCallback)(e=>{h(t=>{let n=!t[e];if(n){let t=m[e]||"";t&&d(n=>({...n,[e]:t}))}return{...t,[e]:n}})},[m]),k=(0,s.useCallback)((e,t)=>{f(n=>({...n,[e]:t})),t&&d(n=>({...n,[e]:t}))},[]),j=(0,s.useCallback)(e=>{g(t=>({...t,[e]:!t[e]}))},[]),C=(0,s.useCallback)(()=>{let t=v>0,r=[];return e.forEach((e,s)=>{let{questions:l}=J(e);l.forEach((e,l)=>{let o=X(s,l);if(t&&!p[o])return;let a=c[o];r.push(`Q: ${e.question}`),r.push(`A: ${a||n("askQuestion.notSelected")}`),r.push("")})}),r.join("\n").trim()},[e,c,p,v,n]),N=(0,s.useCallback)(()=>{navigator.clipboard.writeText(C()),(0,l.oR)(v>0?n("toast.copiedQA",{count:v}):n("toast.copiedAllQA"))},[C,v,n]),S=(0,s.useCallback)(()=>{i?(i.sendMessage(C()),(0,l.oR)(n("toast.sentQA")),t()):(0,l.oR)(n("askQuestion.sendNoChat"))},[i,C,t,n]),L=(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:t,children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:n("askQuestion.title")}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[n("askQuestion.nQuestions",{count:b}),v>0&&` \xb7 ${n("askQuestion.checkedN",{count:v})}`]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:S,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:v>0?n("askQuestion.sendChecked",{count:v}):n("askQuestion.sendAll"),children:(0,r.jsx)(V.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:N,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:v>0?n("askQuestion.copyChecked",{count:v}):n("askQuestion.copyAll"),children:(0,r.jsx)(a.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)(z.A,{className:"w-5 h-5"})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:e.map((t,s)=>{let{questions:l}=J(t);return l.map((t,o)=>{let a=X(s,o),i=c[a],d=u[a]||!1,h=p[a]||!1;return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("button",{onClick:()=>j(a),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-hover transition-colors",title:n("askQuestion.checkToCopy"),children:h?(0,r.jsx)(H.A,{className:"w-4 h-4 text-brand"}):(0,r.jsx)(U.A,{className:"w-4 h-4 text-muted-foreground"})}),t.header&&(0,r.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-brand/10 text-brand flex-shrink-0 mt-0.5",children:t.header}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:t.question})]}),(0,r.jsxs)("div",{className:"space-y-1 ml-7",children:[t.options.map((e,t)=>{let n=i===e.label&&!d;return(0,r.jsxs)("button",{onClick:()=>y(a,e.label),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-hover ${n?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,r.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:n?(0,r.jsx)(q.A,{className:"w-3.5 h-3.5 text-brand"}):(0,r.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:`text-sm ${n?"text-foreground font-medium":"text-foreground"}`,children:e.label}),e.description&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:e.description})]})]},t)}),(0,r.jsxs)("button",{onClick:()=>w(a),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-hover ${d?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,r.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:d?(0,r.jsx)(q.A,{className:"w-3.5 h-3.5 text-brand"}):(0,r.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(K.A,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:n("askQuestion.custom")})]})]}),d&&(0,r.jsx)("div",{className:"ml-6 mt-1",children:(0,r.jsx)("input",{type:"text",autoFocus:!0,value:m[a]||"",onChange:e=>k(a,e.target.value),placeholder:n("askQuestion.customPlaceholder"),className:"w-full px-3 py-1.5 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-brand text-foreground"})})]}),(s!==e.length-1||o!==l.length-1)&&(0,r.jsx)("div",{className:"border-b border-border/50 mt-3"})]},a)})})})]})});return(0,r.jsx)(o.ZL,{children:L})}var Q=n(38987),Y=n(9573),ee=n(4055),et=n(24602),en=n(32041);function er({filePath:e,content:t,onClose:n,zClassName:a="z-50"}){let{t:i}=(0,x.Bd)(),[c,d]=(0,s.useState)("table");return(0,r.jsx)(o.ZL,{children:(0,r.jsx)("div",{className:`fixed inset-0 ${a} flex items-center justify-center bg-scrim p-0 md:p-4`,onClick:n,children:(0,r.jsxs)("div",{className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("span",{className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":e,onClick:()=>{navigator.clipboard.writeText(e),(0,l.oR)(i("common.copiedPath"))},children:["‎",e]}),(0,r.jsx)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5 flex-shrink-0",children:["table","raw"].map(e=>(0,r.jsx)("button",{onClick:()=>d(e),className:`px-2 py-0.5 text-xs rounded transition-colors ${c===e?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:i(`csv.${e}`)},e))}),(0,r.jsx)("button",{onClick:n,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:"table"===c?(0,r.jsx)(en.C0,{content:t,filePath:e,className:"h-full"}):(0,r.jsx)(S.Cv,{content:t,filePath:e,showLineNumbers:!0,showSearch:!0,className:"h-full"})})]})})})}var es=n(95686),el=n(83448);async function eo(e,t){if(!navigator.clipboard?.write||"u"<typeof ClipboardItem)throw Error("Clipboard image write is unavailable");try{await navigator.clipboard.write([new ClipboardItem({[e.type]:e})]);return}catch(t){if("image/png"===e.type)throw t}let n=await new Promise((e,n)=>{let r=new Image;r.onload=()=>{let t=document.createElement("canvas");t.width=r.naturalWidth,t.height=r.naturalHeight;let s=t.getContext("2d");s?(s.drawImage(r,0,0),t.toBlob(t=>{t?e(t):n(Error("Could not encode image"))},"image/png")):n(Error("Canvas is unavailable"))},r.onerror=()=>n(Error("Could not load image")),r.src=t});await navigator.clipboard.write([new ClipboardItem({"image/png":n})])}function ea({image:e,onClose:t}){let{t:n}=(0,x.Bd)(),s=`data:${e.media_type};base64,${e.data}`,i=async t=>{t.stopPropagation();try{await eo(function(e,t){let n=atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new Blob([r],{type:t})}(e.data,e.media_type),s),(0,l.oR)(n("chat.copiedImage"),"success")}catch{(0,l.oR)(n("common.copyFailed"),"error")}},c=(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[(0,r.jsxs)("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:i,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:n("chat.copyImage"),children:(0,r.jsx)(a.A,{className:"w-5 h-5"})}),(0,r.jsx)("button",{type:"button",onClick:t,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:n("common.close"),children:(0,r.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("img",{src:s,alt:n("chat.imagePreview"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]});return(0,r.jsx)(o.ZL,{children:c})}function ei({filePath:e,onClose:t}){let{t:n}=(0,x.Bd)(),s=`/api/file?path=${encodeURIComponent(e)}&raw=true`,i=async t=>{t.stopPropagation();try{let t,r=await fetch(s);if(!r.ok)throw Error("Could not read image");let o=await r.blob(),a=o.type?o:new Blob([o],{type:(t=e.slice(e.lastIndexOf(".")).toLowerCase(),".jpg"===t||".jpeg"===t?"image/jpeg":".png"===t?"image/png":".gif"===t?"image/gif":".webp"===t?"image/webp":".svg"===t?"image/svg+xml":".bmp"===t?"image/bmp":".ico"===t?"image/x-icon":".avif"===t?"image/avif":"image/png")});await eo(a,s),(0,l.oR)(n("chat.copiedImage"),"success")}catch{(0,l.oR)(n("common.copyFailed"),"error")}};return(0,r.jsx)(o.ZL,{children:(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[(0,r.jsxs)("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:i,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:n("chat.copyImage"),children:(0,r.jsx)(a.A,{className:"w-5 h-5"})}),(0,r.jsx)("button",{type:"button",onClick:t,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:n("common.close"),children:(0,r.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("img",{src:s,alt:e.split("/").pop(),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]})})}function ec(e){let t=e.replace(/\/+$/,"");return t.startsWith("/private/")?t.slice(8):t}let ed=(0,s.memo)(function({text:e,isAside:t,isUser:n,isStreaming:o,onOpenFileLink:a,onPreviewFile:c,cwd:d}){let{t:u}=(0,x.Bd)(),h=(0,s.useMemo)(()=>{if(n||!a)return;let e=e=>{c&&((0,I.e$)(e)||(0,I.u)(e)||(0,I.Zy)(e))?c(e):(0,l.oR)(u("toast.fileOutsideProject"),"error")};return t=>{let n=function(e,t){let n;if(!e||e.startsWith("#")||/^[a-z][a-z0-9+.-]*:/i.test(e)&&!e.startsWith("file:"))return null;let r=e;try{r=decodeURIComponent(e)}catch{}r.startsWith("file://")&&(r=r.slice(7));let s=r.indexOf("#"),l=s>=0?r.slice(s+1):"",o=s>=0?r.slice(0,s):r,a=o.indexOf("?"),i=a>=0?o.slice(a+1):"";o=a>=0?o.slice(0,a):o;let c=l.match(/^L?(\d+)(?:-L?\d+)?$/i)?.[1],d=i.match(/(?:^|[&;])(?:line|L)=(\d+)(?:$|[&;])/i)?.[1],u=o.match(/:(\d+)(?::\d+)?$/),h=c||d||u?.[1];if(h&&(n=Number(h),u&&(o=o.slice(0,-u[0].length))),!(o=o.trim()))return null;let m=n&&n>0?{lineNumber:n}:{},f=t?ec(t):"";if(o.startsWith("/")){let e=ec(o);return f&&e===f?null:f&&e.startsWith(f+"/")?{rel:(0,I.WU)("",e.slice(f.length+1)),abs:null,...m}:{rel:(0,I.WU)("",e),abs:e,...m}}return o.startsWith("./")||o.startsWith("../")||o.includes("/")||/\.[A-Za-z0-9][A-Za-z0-9_-]*$/.test(o)?{rel:(0,I.WU)("",o),abs:null,...m}:null}(t,d);return!!n&&(n.abs?d?p.t4.runPromise((0,C.r6)(d,n.rel)).then(t=>{t.ok&&t.data?.exists?a({path:n.rel,...n.lineNumber?{lineNumber:n.lineNumber}:{}}):e(n.abs)}).catch(()=>e(n.abs)):e(n.abs):a({path:n.rel,...n.lineNumber?{lineNumber:n.lineNumber}:{}}),!0)}},[d,n,a,c,u]),m=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L.T,{content:e,isUser:n,isStreaming:o,enableMath:!1,onLinkClick:h}),o&&(0,r.jsx)("span",{className:"inline-block w-2 h-4 ml-1 bg-current animate-pulse"})]});return t?(0,r.jsxs)("div",{className:"flex gap-1.5 break-words opacity-65",children:[(0,r.jsx)(i.A,{className:"w-3 h-3 mt-[5px] shrink-0 text-muted-foreground","aria-hidden":!0}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:m})]}):(0,r.jsx)("div",{className:"break-words",children:m})}),eu=(0,s.memo)(function({message:e,cwd:t,sessionId:n,onFork:a,forkSupported:i=!0,onApprovePlan:g,isLoading:b,onContentSearch:v,onShowFileDiff:y,onOpenFileLink:w,disableOverlays:k=!1}){let j,C,N,S,{t:E}=(0,x.Bd)(),[M,R]=(0,s.useState)(null),[T,$]=(0,s.useState)(()=>1===(e.toolCalls?.length||0)),[P,A]=(0,s.useState)(!1),[_,F]=(0,s.useState)(!1),[B,D]=(0,s.useState)(!1),O="user"===e.role,V=e.images&&e.images.length>0,z=e.toolCalls?.length||0,H=!!n&&!!t&&!!a&&i,U=(0,s.useMemo)(()=>e.toolCalls?.some(e=>(0,ee.h)(e.name))||!1,[e.toolCalls]),q=(0,s.useMemo)(()=>{let t=e.parts;if(!t?.length)return e.content?[{text:e.content,isAside:!1}]:[];let n=-1;t.forEach((e,t)=>{"tool"===e.type&&(n=t)});let r=[];return t.forEach((e,t)=>{"text"===e.type&&r.push({text:e.text,isAside:t<n})}),r},[e.parts,e.content]),K=(0,s.useMemo)(()=>(0,Q.vP)([],e.toolCalls??[],t).length>0,[e.toolCalls,t]),[Z,J]=(0,s.useState)(!1),X=K||Z;(0,s.useEffect)(()=>{y&&e.toolCalls?.length&&y(e.id,e.toolCalls,t,n??void 0,e.runId,!0)},[y,e.id,e.toolCalls,t,n,e.runId]),(0,s.useEffect)(()=>{if(!U||K||!t)return;let r=(e.toolCalls??[]).map(e=>e.id).filter(Boolean);if(0===r.length)return;let s=(e.toolCalls??[]).filter(e=>(0,ee.h)(e.name)).map(e=>e.id),l=!1,o=null,a=0,i=()=>{p.t4.runPromiseExit((0,Y.xK)(t,r,n??void 0,e.runId)).then(e=>{if(l)return;let t="Success"===e._tag?e.value:[];if(t.length>0)return void J(!0);let n=new Set(t.map(e=>e.toolId));s.some(e=>!n.has(e))&&a<2&&(a+=1,o=setTimeout(i,2e3))})};return i(),()=>{l=!0,o&&clearTimeout(o)}},[U,K,t,n,e.toolCalls,e.runId]);let en=(0,s.useMemo)(()=>{if(!e.toolCalls)return null;for(let t=e.toolCalls.length-1;t>=0;t--)if("TodoWrite"===e.toolCalls[t].name)return e.toolCalls[t];return null},[e.toolCalls]),eo=(0,s.useMemo)(()=>e.toolCalls?e.toolCalls.filter(e=>"AskUserQuestion"===e.name):[],[e.toolCalls]),ec=(0,s.useMemo)(()=>{if(!e.toolCalls)return null;for(let t=e.toolCalls.length-1;t>=0;t--)if("ExitPlanMode"===e.toolCalls[t].name){let n=e.toolCalls[t].input?.plan;return"string"==typeof n&&n?n:null}return null},[e.toolCalls]),eu=(0,s.useMemo)(()=>e.toolCalls?.filter(e=>"ExitPlanMode"!==e.name)??[],[e.toolCalls]),eh=(0,s.useMemo)(()=>{if(!e.toolCalls)return[];let t=new Set,n=[];for(let r of e.toolCalls)if("Read"===r.name||"Edit"===r.name||"Write"===r.name){let e=r.input.file_path;e&&((0,I.e$)(e)||(0,I.aR)(e)||(0,I.u)(e)||(0,I.Zy)(e))&&!t.has(e)&&(t.add(e),n.push(e))}return n},[e.toolCalls]),em=(0,s.useMemo)(()=>{if(!e.toolCalls)return[];let t=[];for(let n of e.toolCalls){let e=n.input?.thought;if(e&&"string"==typeof e){let r=e.match(/PREVIOUS:\s*(.*?)\s*→\s*THIS:\s*(.*?)\s*→\s*EXPECT:\s*(.*)/i);r?t.push({previous:r[1].trim(),current:r[2].trim(),expect:r[3].trim(),raw:e,toolName:n.name}):t.push({previous:"",current:e,expect:"",raw:e,toolName:n.name})}}return t},[e.toolCalls]),[ef,ex]=(0,s.useState)(null),[ep,eg]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!ef||(0,I.u)(ef))return void queueMicrotask(()=>eg(null));let e=!1;return p.t4.runPromiseExit((0,el.an)(ef)).then(t=>{e||("Success"===t._tag&&void 0!==t.value.content?eg(t.value.content):((0,l.oR)(E("toast.readFileFailed"),"error"),ex(null)))}),()=>{e=!0}},[ef,E]);let eb=()=>{e.content&&(navigator.clipboard.writeText(e.content),(0,l.oR)(E("toast.copiedMessage")))},ev=()=>{H&&a(e.id,"prefix")},ey=()=>{H&&a(e.id,"single")},ew=(e=>{if(!e)return"";let t=new Date(e);if(isNaN(t.getTime()))return"";let n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0");return`${n}-${r} ${s}:${l}`})(e.timestamp);if("system"===e.role){let t=e.systemEvent,n=t?.kind==="task-notification"?"failed"===t.status?"⚠️":"stopped"===t.status?"⏹️":"\uD83D\uDD14":"ℹ️",s=t?.detail||e.content;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex justify-center my-2 px-2","data-role":"system",children:(0,r.jsxs)("button",{type:"button",onClick:()=>D(!0),className:"flex items-center gap-1.5 max-w-[85%] text-[11px] text-muted-foreground bg-secondary/40 border border-border/50 rounded-full px-3 py-1 hover:bg-secondary hover:text-foreground transition-colors cursor-pointer",title:E("chat.viewDetails",{defaultValue:"Click for details"}),children:[(0,r.jsx)("span",{className:"flex-shrink-0",children:n}),(0,r.jsx)("span",{className:"truncate",children:e.content})]})}),B&&(0,r.jsx)(o.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:()=>D(!1),children:(0,r.jsxs)("div",{className:"bg-card shadow-lv3 w-full max-w-4xl max-h-[80vh] rounded-lg flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("span",{className:"text-sm text-foreground flex items-center gap-1.5",children:[(0,r.jsx)("span",{children:n}),t?.kind==="task-notification"?E("chat.taskNotification",{defaultValue:"Task notification"}):E("chat.systemNotice",{defaultValue:"Notice"})]}),(0,r.jsx)("button",{onClick:()=>D(!1),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors",children:"✕"})]}),(0,r.jsx)("pre",{className:"flex-1 overflow-auto px-4 py-3 text-xs text-foreground whitespace-pre-wrap break-words",children:s})]})})})]})}return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:`flex flex-col ${O?"items-end":"items-start"} mb-4 group`,"data-role":e.role,children:[ew&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity mb-0.5 px-1",children:ew}),(0,r.jsxs)("div",{className:`flex items-start ${O?"justify-end":"justify-start"} w-full`,children:[O&&(0,r.jsxs)("div",{className:"self-start mt-2 mr-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.content&&(0,r.jsx)("button",{onClick:eb,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:E("chat.copyMessage"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),H&&(0,r.jsx)("button",{onClick:ev,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:E("chat.forkSession"),children:(0,r.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"18",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,r.jsx)("path",{d:"M12 12v3"})]})}),H&&(0,r.jsx)("button",{onClick:ey,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:E("chat.excerptTurn"),children:(0,r.jsx)(c.A,{className:"w-4 h-4"})})]}),(0,r.jsxs)("div",{className:`max-w-[80%] px-4 py-2 rounded-2xl bg-muted text-foreground ${O?"rounded-br-md":"rounded-bl-md"}`,children:[V&&(0,r.jsx)("div",{className:`flex flex-wrap gap-2 ${e.content?"mb-2":""}`,children:e.images.map((e,t)=>(0,r.jsx)("div",{className:`relative w-16 h-16 rounded-lg overflow-hidden border border-white/20 ${k?"":"cursor-pointer hover:opacity-90 transition-opacity"}`,onClick:k?void 0:()=>R(e),children:(0,r.jsx)("img",{src:`data:${e.media_type};base64,${e.data}`,alt:E("chat.imageN",{index:t+1}),className:"w-full h-full object-cover"})},t))}),q.length>0&&(0,r.jsx)("div",{className:"space-y-3",children:q.map((n,s)=>(0,r.jsx)(ed,{text:n.text,isAside:n.isAside,isUser:O,isStreaming:!!e.isStreaming&&s===q.length-1,onOpenFileLink:w,onPreviewFile:ex,cwd:t},s))}),en&&(N=(C=Array.isArray(j=en.input?.todos)?j:[]).filter(e=>"completed"===e.status).length,S=C.length,(0,r.jsx)("div",{className:`${e.content||V?"mt-2":""}`,children:(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden px-3 py-2 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,r.jsx)("div",{className:"flex-1 h-1 bg-secondary rounded-full overflow-hidden",children:(0,r.jsx)("div",{className:"h-full bg-green-500 rounded-full transition-all duration-300",style:{width:`${S>0?N/S*100:0}%`}})}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[N,"/",S]})]}),C.map((e,t)=>(0,r.jsxs)("div",{className:`flex items-center gap-1.5 ${"completed"===e.status?"opacity-50":""}`,children:["completed"===e.status?(0,r.jsx)(d.A,{className:"w-3 h-3 text-green-11 flex-shrink-0"}):"in_progress"===e.status?(0,r.jsx)(u.A,{className:"w-3 h-3 text-brand flex-shrink-0 animate-spin"}):(0,r.jsx)(h.A,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),(0,r.jsx)("span",{className:`text-xs truncate ${"completed"===e.status?"text-muted-foreground":"text-foreground"}`,children:"in_progress"===e.status&&e.activeForm?e.activeForm:e.content})]},t))]})})),ec&&(0,r.jsx)("div",{className:`${e.content||V||en?"mt-2":""}`,children:(0,r.jsxs)("div",{className:"border border-brand/40 rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-b border-border bg-brand/10",children:[(0,r.jsx)("span",{className:"text-sm",children:"\uD83D\uDCCB"}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:E("chat.planTitle",{defaultValue:"Plan (awaiting your review)"})})]}),(0,r.jsx)("div",{className:"px-3 py-2",children:(0,r.jsx)(L.T,{content:ec,isUser:!1,enableMath:!1})}),g&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:E("chat.planApproveHint",{defaultValue:"本环境无审批弹窗,点此退出 Plan 并执行"})}),(0,r.jsxs)("button",{onClick:()=>g(),disabled:b,className:"flex items-center gap-1.5 px-3 py-1 rounded-md bg-brand text-white text-xs font-medium hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex-shrink-0",children:[(0,r.jsx)("span",{children:"✓"}),(0,r.jsx)("span",{children:E("chat.approvePlan",{defaultValue:"批准并执行"})})]})]})]})}),eh.length>0&&(0,r.jsx)("div",{className:`${e.content||V||en?"mt-2":""}`,children:(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden px-3 py-2 space-y-0.5",children:eh.map(e=>(0,r.jsxs)("button",{disabled:k,onClick:()=>ex(e),className:"flex items-center gap-1.5 w-full text-left rounded px-1 py-0.5 group/md transition-colors enabled:hover:bg-hover disabled:cursor-default",children:[(0,I.u)(e)?(0,r.jsxs)("svg",{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v14a1 1 0 01-1 1H5a1 1 0 01-1-1V5z"}),(0,r.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4-4 3 3 4-4 5 5"})]}):(0,I.Zy)(e)?(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6a2 2 0 012-2h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm0 4h16M10 10v10"})}):(0,I.aR)(e)?(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}):(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground group-hover/md:text-foreground truncate",children:e.split("/").pop()})]},e))})}),em.length>0&&(0,r.jsx)("div",{className:`${e.content||V||en||eh.length>0?"mt-2":""}`,children:(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,r.jsxs)("table",{className:"w-full text-xs",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border text-muted-foreground",children:[(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium w-[60px]",children:"Tool"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Previous"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Action"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Expect"})]})}),(0,r.jsx)("tbody",{children:em.map((e,t)=>(0,r.jsxs)("tr",{className:t<em.length-1?"border-b border-border/50":"",children:[(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground font-mono",children:e.toolName}),(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:e.previous||"—"}),(0,r.jsx)("td",{className:"px-2 py-1 text-foreground",children:e.current}),(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:e.expect||"—"})]},t))})]})})}),eu.length>0&&(0,r.jsx)("div",{className:`${e.content||V?"mt-3":""}`,children:z>0?(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsxs)("button",{onClick:()=>$(!T),className:"flex-1 px-3 py-1.5 flex items-center gap-2 text-left hover:bg-hover transition-colors active:bg-muted",children:[(0,r.jsx)("span",{className:"text-sm",children:"\uD83D\uDD27"}),(0,r.jsx)("span",{className:"font-medium text-foreground",children:E("chat.toolCalls",{count:eu.length})}),(0,r.jsx)("span",{className:"ml-auto text-muted-foreground text-sm",children:T?E("chat.collapse"):E("chat.expand")})]}),!k&&eo.length>0&&(0,r.jsx)("button",{onClick:()=>F(!0),className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover transition-colors border-l border-line-1",title:E("chat.viewQuestions"),children:(0,r.jsx)(m.A,{className:"w-4 h-4"})}),!k&&X&&(0,r.jsx)("button",{onClick:()=>{y&&e.toolCalls?y(e.id,e.toolCalls,t,n??void 0,e.runId):A(!0)},className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover transition-colors border-l border-line-1",title:E("chat.viewAllFileChanges"),children:(0,r.jsx)(f.A,{className:"w-4 h-4"})})]}),T&&(0,r.jsx)("div",{className:"border-t border-line-1",children:eu.map((e,s)=>(0,r.jsx)(W,{toolCall:e,cwd:t,sessionId:n,disableOverlays:k},`${e.id}-${s}`))})]}):eu.map((e,s)=>(0,r.jsx)(W,{toolCall:e,cwd:t,sessionId:n,disableOverlays:k},`${e.id}-${s}`))})]}),!O&&(0,r.jsxs)("div",{className:"self-start mt-2 ml-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.content&&(0,r.jsx)("button",{onClick:eb,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:E("chat.copyMessage"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),H&&(0,r.jsx)("button",{onClick:ev,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:E("chat.forkSession"),children:(0,r.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"18",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,r.jsx)("path",{d:"M12 12v3"})]})}),H&&(0,r.jsx)("button",{onClick:ey,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:E("chat.excerptTurn"),children:(0,r.jsx)(c.A,{className:"w-4 h-4"})})]})]})]}),M&&(0,r.jsx)(ea,{image:M,onClose:()=>R(null)}),P&&e.toolCalls&&(0,r.jsx)(Q.zB,{toolCalls:e.toolCalls,cwd:t,sessionId:n??void 0,runId:e.runId,onClose:()=>A(!1),onContentSearch:v}),_&&eo.length>0&&(0,r.jsx)(G,{toolCalls:eo,onClose:()=>F(!1)}),ef&&(0,I.u)(ef)&&(0,r.jsx)(ei,{filePath:ef,onClose:()=>ex(null)}),ef&&!(0,I.u)(ef)&&null!==ep&&((0,I.aR)(ef)?(0,r.jsx)(et.N,{filePath:ef,content:ep,cwd:t,onClose:()=>ex(null),onContentSearch:v}):(0,I.Zy)(ef)?(0,r.jsx)(er,{filePath:ef,content:ep,onClose:()=>ex(null)}):(0,r.jsx)(es.x,{filePath:ef,content:ep,cwd:t||"",onClose:()=>ex(null)}))]})})},56045:(e,t,n)=>{n.d(t,{_:()=>a,o:()=>o});var r=n(12115),s=n(69809);let l="json-search-highlight-style";function o(e){let[t,n]=(0,r.useState)(!1),[s,o]=(0,r.useState)(""),[a,i]=(0,r.useState)(!1),[c,d]=(0,r.useState)(0),[u,h]=(0,r.useState)(0),m=(0,r.useRef)(null),f=(0,r.useRef)([]),x=(0,r.useCallback)(()=>{let t;CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),f.current=[];let n=e.current;if(!n||!s){d(0),h(0);return}!function(){if(document.getElementById(l))return;let e=document.createElement("style");e.id=l,e.textContent="::highlight(json-search){background:var(--highlight)}::highlight(json-search-current){background:var(--highlight-current)}",document.head.appendChild(e)}();let r=n.textContent||"",o=a?s:s.toLowerCase(),i=a?r:r.toLowerCase(),c=[],u=0;for(;u<i.length;){let e=i.indexOf(o,u);if(-1===e)break;c.push([e,e+o.length]),u=e+1}if(0===c.length){d(0),h(0);return}let m=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),x=0,p=0,g=[],b=null,v=0;for(;(t=m.nextNode())&&p<c.length;){let e=t.textContent?.length||0,n=x,r=x+e;for(;p<c.length;){let[e,s]=c[p];if(e>=r)break;if(!b)if(e>=n)(b=document.createRange()).setStart(t,e-n),v=s;else break;if(v<=r)b.setEnd(t,v-n),g.push(b),b=null,p++;else break}x=r}f.current=g,d(g.length),h(e=>g.length>0?Math.min(e,g.length-1):0),CSS.highlights&&g.length>0&&CSS.highlights.set("json-search",new Highlight(...g))},[e,s,a]),p=(0,r.useCallback)((e,t)=>{let n=e.getBoundingClientRect();(t.top<n.top||t.bottom>n.bottom)&&(e.scrollTop+=t.top-n.top-n.height/2+t.height/2)},[]),g=(0,r.useCallback)(t=>{CSS.highlights?.delete("json-search-current");let n=f.current[t];if(!n||!CSS.highlights)return;CSS.highlights.set("json-search-current",new Highlight(n));let r=n.getBoundingClientRect(),s=e.current?.parentElement;s&&p(s,r)},[e,p]);(0,r.useEffect)(()=>{queueMicrotask(()=>x())},[x]),(0,r.useEffect)(()=>{g(u)},[u,c,g]),(0,r.useEffect)(()=>{let t=e.current;if(!t||!s)return;let n=new MutationObserver(()=>x());return n.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>n.disconnect()},[e,s,x]),(0,r.useEffect)(()=>{t||(CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),f.current=[])},[t]),(0,r.useEffect)(()=>()=>{CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current")},[]);let b=(0,r.useCallback)(()=>{0!==c&&h(e=>(e+1)%c)},[c]),v=(0,r.useCallback)(()=>{0!==c&&h(e=>(e-1+c)%c)},[c]),y=(0,r.useCallback)(()=>{n(!0),setTimeout(()=>m.current?.focus(),0)},[]),w=(0,r.useCallback)(()=>{n(!1),o(""),h(0)},[]),k=(0,r.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?v():b()),"Escape"===e.key&&(e.preventDefault(),w())},[b,v,w]);return{isVisible:t,query:s,setQuery:o,caseSensitive:a,setCaseSensitive:i,matchCount:c,currentIndex:u,searchInputRef:m,open:y,close:w,goToNext:b,goToPrev:v,handleKeyDown:k}}function a({search:e}){return e.isVisible?r.createElement("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border"},r.createElement("input",{ref:e.searchInputRef,type:"text",value:e.query,onChange:t=>e.setQuery(t.target.value),onKeyDown:e.handleKeyDown,placeholder:s.A.t("codeViewer.searchPlaceholder"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),r.createElement("button",{onClick:()=>e.setCaseSensitive(e=>!e),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${e.caseSensitive?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:s.A.t("codeViewer.caseSensitive")},"Aa"),r.createElement("span",{className:"text-xs text-muted-foreground"},e.matchCount>0?`${e.currentIndex+1}/${e.matchCount}`:s.A.t("common.noMatch")),r.createElement("button",{onClick:e.goToPrev,disabled:0===e.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:s.A.t("common.previous")},r.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}))),r.createElement("button",{onClick:e.goToNext,disabled:0===e.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:s.A.t("common.next")},r.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),r.createElement("button",{onClick:e.close,className:"p-1 rounded hover:bg-accent",title:s.A.t("common.close")},r.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))):null}},56978:(e,t,n)=>{n.d(t,{C:()=>l});var r=n(12115),s=n(17196);function l(e,t){let[n,l]=(0,r.useState)(null),[o,a]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=()=>{a(document.documentElement.classList.contains("dark"))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);let i=(0,r.useMemo)(()=>e.join("\n"),[e]),c=`${i}:${t}:${o}`,d=(0,r.useMemo)(()=>n&&n.key===c?n.html:e.map(e=>(0,s.ZD)(e||" ")),[e,c,n]);return(0,r.useEffect)(()=>{if(0===e.length)return;let n=!1;return(async()=>{try{let r=await (0,s.kS)();if(n)return;let a=(0,s.sQ)(t),i=e.join("\n"),d=r.codeToTokens(i,{lang:a,theme:o?"github-dark":"github-light"}),u=[];for(let e=0;e<d.tokens.length;e++)if(u[e]=(0,s.b8)(d.tokens[e]),e%500==0&&e>0&&(await new Promise(e=>setTimeout(e,0)),n))return;l({key:c,html:u})}catch(e){console.error("Line highlight error:",e)}})(),()=>{n=!0}},[i,t,o]),d}},57125:(e,t,n)=>{n.d(t,{$T:()=>m,Aw:()=>f,CX:()=>c,Fx:()=>h,H:()=>o,XY:()=>b,ch:()=>a,eV:()=>p,hG:()=>g,pe:()=>d,yI:()=>u,ys:()=>x});var r=n(95155);n(12115);var s=n(94514),l=n(66088);let o={claude:"Claude",codex:"Codex",deepseek:"DeepSeek",kimi:"Kimi",glm:"GLM",ollama:"Ollama"};function a(e){return!!e&&e in o}let i={claude:0,codex:1,deepseek:2,glm:3,kimi:4,ollama:5},c=Object.keys(i).sort((e,t)=>i[e]-i[t]),d={claude:"text-[#c6532d] dark:text-[#D97757]",codex:"text-emerald-600 dark:text-emerald-400",deepseek:"text-sky-600 dark:text-sky-400",kimi:"text-purple-600 dark:text-purple-400",glm:"text-amber-600 dark:text-amber-400",ollama:"text-violet-600 dark:text-violet-400"},u="bg-accent font-medium text-foreground",h="focus:border-brand",m="bg-brand text-white hover:bg-brand/90",f="text-rose-600 dark:text-rose-400",x="fixed z-[9999] max-h-[70vh] overflow-y-auto rounded-lg border border-border bg-popover py-2 shadow-lv2";function p({engine:e,className:t="h-3.5 w-3.5"}){return(0,r.jsx)("img",{alt:"","aria-hidden":"true",src:`/agent-icons/${e}.svg`,className:`${t} flex-shrink-0`})}function g({selected:e}){return(0,r.jsx)("span",{className:"flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center text-foreground",children:e&&(0,r.jsx)(s.A,{className:"h-3.5 w-3.5"})})}function b({label:e,title:t,onClick:n,buttonRef:s,icon:o,labelClassName:a,labelMaxWidth:i="max-w-[160px]",testId:c}){return(0,r.jsxs)("button",{ref:s,type:"button",onClick:n,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:t,"data-testid":c,children:[o,(0,r.jsx)("span",{className:`truncate ${i} ${a??""}`,children:e}),(0,r.jsx)(l.A,{className:"h-3 w-3 flex-shrink-0"})]})}},58250:(e,t,n)=>{n.d(t,{U:()=>l,k:()=>s});let r="cockpit-skills";function s(){let e="u"<typeof BroadcastChannel?null:new BroadcastChannel(r);if(e)try{e.postMessage({type:"changed"})}finally{e.close()}}function l(e){if("u"<typeof BroadcastChannel)return()=>{};let t=new BroadcastChannel(r),n=t=>{t.data?.type==="changed"&&e()};return t.addEventListener("message",n),()=>{t.removeEventListener("message",n),t.close()}}},60938:(e,t,n)=>{n.d(t,{DZ:()=>i,Ft:()=>h,Nn:()=>v,OJ:()=>p,VK:()=>y,YW:()=>u,__:()=>b,dt:()=>g,eA:()=>x,eE:()=>m,gZ:()=>c,mP:()=>a,nM:()=>w,r6:()=>f,r9:()=>d});var r=n(49433),s=n(82680);let l=(e,t={})=>r.tryPromise({try:async()=>{let n=await fetch(e,t.init);if(t.passThroughStatuses&&t.passThroughStatuses.includes(n.status))return await n.json().catch(()=>({}));if(!n.ok){let e;try{e=(await n.json()).error}catch{}throw Error(e||`HTTP ${n.status}`)}return await n.json()},catch:t=>new s.uV({message:`GET ${e} failed`,cause:t})}),o=(e,t)=>r.tryPromise({try:async()=>{let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw Error(`HTTP ${n.status}`)},catch:t=>new s.uV({message:`POST ${e} failed`,cause:t})}),a=e=>l(`/api/files/init?cwd=${encodeURIComponent(e)}`),i=e=>l(`/api/files/index?cwd=${encodeURIComponent(e)}`),c=(e,t)=>l(`/api/files/readdir?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`),d=e=>l(`/api/files/recent?cwd=${encodeURIComponent(e)}`),u=(e,t,n)=>o("/api/files/recent",{cwd:e,file:t,...n??{}}),h=(e,t)=>o("/api/files/expanded",{cwd:e,paths:t}),m=(e,t)=>l(`/api/files/blame?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`).pipe(r.catchAll(e=>r.succeed({error:e.message}))),f=(e,t)=>{let n,l;return n=`/api/files/stat?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,l={cache:"no-store"},r.tryPromise({try:async()=>{let e=await fetch(n,l),t=null;try{t=await e.json()}catch{}return{status:e.status,ok:e.ok,data:t}},catch:e=>new s.uV({message:`GET ${n} failed`,cause:e})})},x=e=>l(`/api/files/text?${e.toString()}`),p=e=>r.tryPromise({try:async()=>{let t=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=null;try{n=await t.json()}catch{}return{status:t.status,ok:t.ok,data:n}},catch:e=>new s.uV({message:"POST /api/files/save failed",cause:e})}),g=()=>l("/api/files/clipboard"),b=e=>r.tryPromise({try:async()=>{let t=await fetch("/api/files/clipboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(`HTTP ${t.status}`)},catch:e=>new s.uV({message:"POST /api/files/clipboard failed",cause:e})}),v=e=>r.tryPromise({try:async()=>{let t=await fetch("/api/files/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`HTTP ${t.status}`);return n},catch:e=>new s.uV({message:"POST /api/files/paste failed",cause:e})}),y=e=>r.tryPromise({try:async()=>{let t=await fetch("/api/files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`HTTP ${t.status}`);return n},catch:e=>new s.uV({message:"POST /api/files/delete failed",cause:e})}),w=e=>l(`/api/file?path=${encodeURIComponent(e)}`)},62111:(e,t,n)=>{n.d(t,{E:()=>l,k:()=>s});var r=n(12115);function s(){"u">typeof document&&document.activeElement instanceof HTMLElement&&document.activeElement.blur()}function l(e,t=!0){(0,r.useEffect)(()=>{if(!t)return;let n=t=>{"Escape"===t.key&&(s(),e())};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e,t])}},63040:(e,t,n)=>{n.d(t,{m3:()=>i,mi:()=>o,ot:()=>a});var r=n(49433),s=n(82680);let l=(e,t)=>r.tryPromise({try:async()=>{let n=await fetch(e,t);if(!n.ok){let e;try{e=(await n.json()).error}catch{}throw Error(e||`HTTP ${n.status}`)}return await n.json()},catch:n=>new s.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),o=()=>l("/api/html-apps"),a=e=>l("/api/html-apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),i=e=>l(`/api/html-apps/${encodeURIComponent(e)}`,{method:"DELETE"})},63563:(e,t,n)=>{n.d(t,{N:()=>r});function r(){let e="u"<typeof BroadcastChannel?null:new BroadcastChannel("cockpit-html-apps");if(e)try{e.postMessage({type:"changed"})}finally{e.close()}}},65153:(e,t,n)=>{n.d(t,{u:()=>a});var r=n(12115),s=n(2111),l=n(19095),o=n(14594);function a(e,t,n,a,i){let c=(0,r.useRef)(null),d=(0,r.useRef)(0),u=(0,r.useRef)(0),h=(0,r.useRef)(!1),m=(0,r.useRef)(!1),f=(0,r.useRef)(!1),x=(0,r.useRef)(void 0),p=()=>{let e=`live-asst-${++d.current}`;return c.current=e,t(t=>[...t,{id:e,role:"assistant",content:"",isStreaming:!0,runId:x.current}]),e},g=e=>{let n=e=>{i?.onLiveOutputTokens?.({outputTokens:Math.max(0,Math.round(e))})},r=e=>{!h.current&&"string"==typeof e&&e&&(u.current+=(0,l.r)(e),n(u.current))};if("system"===e.type&&"init"===e.subtype){let e=m.current;f.current=!0,e||(u.current=0,h.current=!1,i?.onLiveOutputTokens?.(null),i?.onRunStartedAt?.(Date.now())),p();return}if("usage_update"===e.type){"number"==typeof e.output_tokens&&Number.isFinite(e.output_tokens)&&(h.current=!0,u.current=Math.max(u.current,Math.round(e.output_tokens)),n(u.current));return}if("stream_event"===e.type){let t=e.event;t?.type==="content_block_delta"&&t.delta?.type==="text_delta"&&r(t.delta.text)}if("system"===e.type&&"task_notification"===e.subtype){if(!f.current){let n=`live-tasknotif-${e.task_id||++d.current}`,r=`<task-notification>
11
+ `+(e.task_id?`<task-id>${e.task_id}</task-id>
12
+ `:"")+(e.status?`<status>${e.status}</status>
13
+ `:"")+(e.summary?`<summary>${e.summary}</summary>
14
+ `:"")+(e.output_file?`<output-file>${e.output_file}</output-file>
15
+ `:"")+"</task-notification>";t(t=>[...t,{id:n,role:"system",content:e.summary||"",systemEvent:{kind:"task-notification",...e.status?{status:e.status}:{},detail:r}}])}return}if("user"===e.type&&e._human){let n=e.message?.content,r="string"==typeof n?n:Array.isArray(n)?n.map(e=>e?.text||"").join(""):"",s="string"==typeof e._turnId?e._turnId:null;s&&(x.current=s);let l="number"==typeof e._ts?e._ts:null,o=s?`live-user-${s}`:`live-user-${++d.current}`;t(e=>{if(s&&e.some(e=>e.id===o))return e;for(let t=e.length-1;t>=0;t--){if("user"!==e[t].role)continue;let n=e[t].timestamp?Date.parse(e[t].timestamp):NaN;if(null===l||Number.isNaN(n)){if(e[t].content===r)return e}else if(n>=l)return e;break}return[...e,{id:o,role:"user",content:r}]});return}if("result"===e.type&&(f.current=!1,m.current=!0),"assistant"===e.type&&Array.isArray(e.message?.content))for(let t of e.message.content)t.text?r(t.text):t.name&&r(`${t.name} ${JSON.stringify(t.input??{})}`);if("user"===e.type&&Array.isArray(e.message?.content))for(let t of e.message.content)r("string"==typeof t.content?t.content:JSON.stringify(t.content??""));let s=c.current??p();t(t=>(0,o.F)(t,e,{engine:a,assistantId:s}))};(0,s.h)({url:e?`/ws/session-stream?sessionId=${encodeURIComponent(e)}`:"/ws/session-stream",enabled:n&&!!e,onMessage:e=>{if("run-snapshot"===e.type&&Array.isArray(e.events)){if("string"==typeof e.runId&&e.runId&&(x.current=e.runId),"running"!==e.status){i?.onRunningChange?.(!1),i?.onLiveOutputTokens?.(null),i?.onRunStartedAt?.(null),u.current=0,h.current=!1,m.current=!1;return}let n=e.events.find(e=>e?.type==="user"&&e?._human),r=n?.message?.content,s="string"==typeof r?r:"",l=new Set,o=new Set;for(let t of e.events){let e=t?.uuid;if("string"==typeof e&&l.add(e),t?.type==="assistant"&&Array.isArray(t.message?.content))for(let e of t.message.content)e?.name&&"string"==typeof e.id&&o.add(e.id)}let a="number"==typeof e.startedAt?e.startedAt:null;t(e=>{let t=e.filter(e=>!("string"==typeof e.id&&e.id.startsWith("live-"))),n=t[t.length-1],r=n?.timestamp?Date.parse(n.timestamp):NaN;if(null!==a&&!Number.isNaN(r)){let e=t.length;for(;e>0;){let n=t[e-1],r=n.timestamp?Date.parse(n.timestamp):NaN;if(!Number.isNaN(r)&&r>=a)e--;else break}return e<t.length?t.slice(0,e):t}if(!s)return t;let i=-1;for(let e=t.length-1;e>=0;e--)if("user"===t[e].role){t[e].content===s&&(i=e);break}return -1===i?t:t.slice(i+1).every(e=>"assistant"===e.role&&("string"==typeof e.id&&l.has(e.id)||!!e.toolCalls?.length&&e.toolCalls.every(e=>o.has(e.id))))?t.slice(0,i):t}),c.current=null,d.current=0,u.current=0,h.current=!1,m.current=!1,f.current=!1;let p="number"==typeof e.outputTokens&&Number.isFinite(e.outputTokens)?Math.max(0,Math.round(e.outputTokens)):null;for(let t of(null!==p&&(u.current=p,h.current=!0,i?.onLiveOutputTokens?.({outputTokens:p})),e.events))g(t);i?.onRunningChange?.(!0),i?.onRunStartedAt?.("number"==typeof e.startedAt?e.startedAt:Date.now())}else if("run-event"===e.type&&e.message){if("run-ended"===e.message.type){i?.onRunningChange?.(!1),i?.onLiveOutputTokens?.(null),i?.onRunStartedAt?.(null),u.current=0,h.current=!1,m.current=!1,i?.onComplete?.();return}g(e.message),i?.onRunningChange?.(!0)}else"run-idle"===e.type&&(i?.onRunningChange?.(!1),i?.onLiveOutputTokens?.(null),i?.onRunStartedAt?.(null),u.current=0,h.current=!1,m.current=!1)}})}},67589:(e,t,n)=>{n.d(t,{z:()=>a,m:()=>c});var r=n(12115),s=n(49433),l=n(86957),o=n(82680);let a=e=>s.tryPromise({try:async()=>{let t=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?await t.json():null},catch:e=>new o.uV({message:"session-by-path failed",cause:e})}),i=new Map;function c(e,t,n,{cwd:d,initialSessionId:u,onSessionId:h,onTitleChange:m,onTokenUsage:f,liveRunningRef:x}){let[p,g]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!1),[y,w]=(0,r.useState)(!1),[k,j]=(0,r.useState)(void 0),[C,N]=(0,r.useState)(0),[S,L]=(0,r.useState)(null),[E,M]=(0,r.useState)(null),R=(0,r.useRef)(m);R.current=m;let T=(0,r.useRef)(f);T.current=f;let $=(0,r.useRef)(void 0),I=(0,r.useRef)(0),P=(0,r.useCallback)(async(e,n,r=!1,s,o,c=!1)=>{if(r){let e=Date.now();if(!c&&e-I.current<5e3)return;I.current=e}let d=(e,r)=>{e.fingerprint&&($.current=e.fingerprint),void 0!==e.totalTurns&&N(e.totalTurns),void 0!==e.hasMore&&w(e.hasMore),e.messages&&e.messages.length>0&&(r?t(t=>(function(e,t){if(0===t.length)return e;let n=0;if(e.length>0&&e[0].id!==t[0].id){n=-1;for(let r=e.length-1;r>=0;r--)if(e[r].id===t[0].id){n=r;break}}if(n<0)return t;let r=e.slice(n),s=0;for(let e=0;e<Math.min(r.length,t.length)&&r[e].id===t[e].id&&r[e].content===t[e].content;e++)s=e+1;return s===r.length&&s===t.length?e:s===r.length&&s<t.length?[...e,...t.slice(s)]:[...e.slice(0,n),...r.slice(0,s),...t.slice(s)]})(t,e.messages)):x?.current||t(e.messages),L(n)),e.sessionId&&h(e.sessionId),e.engine&&M(e.engine),e.title&&R.current?.(e.title),e.usage&&T.current?.({inputTokens:e.usage.input_tokens||0,outputTokens:e.usage.output_tokens||0,cacheCreationInputTokens:e.usage.cache_creation_input_tokens||0,cacheReadInputTokens:e.usage.cache_read_input_tokens||0,totalCostUsd:0})},u=`${e}::${n}`,m=!r&&void 0===o,f=m?i.get(u):void 0;r||(f?d(f.data,!1):g(!0));try{let t={cwd:e,sessionId:n,limit:s,beforeTurnIndex:o};r&&$.current?t.ifFingerprint=$.current:f&&(t.ifFingerprint=f.fingerprint);let c=await l.t4.runPromiseExit(a(t));if("Success"===c._tag&&c.value){let e=c.value;if(e.notModified)return;if(d(e,r),m&&e.fingerprint&&e.messages&&e.messages.length>0&&(i.delete(u),i.set(u,{data:e,fingerprint:e.fingerprint}),i.size>20)){let e=i.keys().next().value;void 0!==e&&i.delete(e)}}}catch(e){console.error("Failed to load history by cwd and sessionId:",e)}finally{r||g(!1)}},[t,h]),A=(0,r.useCallback)(async()=>{if(d&&n&&!b&&y){v(!0);try{let r=void 0!==k?k:C-Math.ceil(e.filter(e=>"user"===e.role).length),s=await l.t4.runPromiseExit(a({cwd:d,sessionId:n,limit:10,beforeTurnIndex:r>0?r:void 0}));if("Success"===s._tag&&s.value){let e=s.value;if(e.messages&&e.messages.length>0){t(t=>[...e.messages,...t]);let s=e.messages.filter(e=>"user"===e.role).length;j(r-s),L(n)}void 0!==e.hasMore&&w(e.hasMore),e.fingerprint&&($.current=e.fingerprint)}else"Failure"===s._tag&&console.error("Failed to load more history:",s.cause)}finally{v(!1)}}},[d,n,b,y,k,C,e,t]),_=(0,r.useCallback)(async e=>{g(!0);let n=s.tryPromise({try:async()=>{let t=await fetch(`/api/session/${e}/history`);return t.ok?await t.json():null},catch:e=>new o.uV({message:"load session history failed",cause:e})}),r=await l.t4.runPromiseExit(n);"Success"===r._tag&&r.value?.messages&&r.value.messages.length>0?(t(r.value.messages),L(e)):"Failure"===r._tag&&console.error("Failed to load history:",r.cause),g(!1)},[t]);return(0,r.useEffect)(()=>{d&&u&&P(d,u,!1,10)},[]),{isLoadingHistory:p,isLoadingMore:b,hasMoreHistory:y,loadMoreHistory:A,loadHistory:_,loadHistoryByCwdAndSessionId:P,loadedSessionId:S,loadedEngine:E}}},70188:(e,t,n)=>{n.d(t,{Ee:()=>h,SU:()=>c,ft:()=>u,iN:()=>d});var r=n(95155),s=n(12115),l=n(79114),o=n(47650),a=n(34075);let i=(0,s.createContext)(null);function c({container:e,children:t}){return(0,r.jsx)(i.Provider,{value:e,children:t})}function d(){return(0,s.useContext)(i)}function u({x:e,y:t,path:n,cwd:c,isDirectory:d,onClose:h,onCreateFile:m,onDelete:f,onRefresh:x,onCopyFile:p,onPaste:g,onExplain:b,explainDisabled:v}){let{t:y}=(0,l.Bd)(),w=(0,s.useRef)(null),k=(0,s.useContext)(i),j=n.split("/").pop()||n,C=`${c}/${n}`,N=n.includes("/")?n.substring(0,n.lastIndexOf("/")):"",S=N?`${c}/${N}`:c,L=d?n:N,E=d?C:S;(0,s.useEffect)(()=>{let e=e=>{w.current&&!w.current.contains(e.target)&&h()},t=e=>{"Escape"===e.key&&h()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[h]);let[M,R]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(w.current&&k){let n=k.getBoundingClientRect(),r=w.current.getBoundingClientRect(),s=e-n.left,l=t-n.top;s=Math.min(s,n.width-r.width-8),l=Math.min(l,n.height-r.height-8),R({x:s=Math.max(8,s),y:l=Math.max(8,l)})}else if(w.current){let n=w.current.getBoundingClientRect();R({x:Math.max(8,Math.min(e,window.innerWidth-n.width-8)),y:Math.max(8,Math.min(t,window.innerHeight-n.height-8))})}},[e,t,k]);let T=(0,s.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(e),(0,a.oR)(y("toast.copiedName",{name:t}),"success")}catch{(0,a.oR)(y("toast.copyFailed"),"error")}h()},[h,y]),$=d?n:N,I=!!b&&!d,P=[{label:y("fileContextMenu.copyRelativePath"),value:n},{label:y("fileContextMenu.copyAbsolutePath"),value:C},{label:y("fileContextMenu.copyRelativeDirPath"),value:L||"."},{label:y("fileContextMenu.copyAbsoluteDirPath"),value:E},{label:d?y("fileContextMenu.copyFolderName"):y("fileContextMenu.copyFileName"),value:j}],A=(0,r.jsxs)("div",{ref:w,className:"absolute z-[200] bg-card border border-border rounded-lg shadow-lv2 py-1 w-fit whitespace-nowrap",style:{left:M.x,top:M.y},children:[I&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",disabled:v,title:v?y("comments.aiResponding"):void 0,onClick:()=>{h(),b(n)},children:y("explain.action")}),I&&(0,r.jsx)("div",{className:"my-1 border-t border-border"}),m&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>{h(),m($)},children:y("fileContextMenu.createFile")}),p&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>{h(),p(n)},children:d?y("fileContextMenu.copyFolder"):y("fileContextMenu.copyFile")}),g&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>{h(),g($)},children:y("fileContextMenu.pasteHere")}),f&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-destructive hover:bg-hover transition-colors",onClick:()=>{h(),f(n,d,j)},children:d?y("fileContextMenu.deleteFolder"):y("fileContextMenu.deleteFile")}),!!(m||p||g||f)&&(0,r.jsx)("div",{className:"my-1 border-t border-border"}),P.map((e,t)=>(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>T(e.value,e.label),children:e.label},t))]});return k?(0,o.createPortal)(A,k):A}function h(){let[e,t]=(0,s.useState)(null);return{contextMenu:e,showContextMenu:(0,s.useCallback)((e,n,r)=>{e.preventDefault(),e.stopPropagation(),t({x:e.clientX,y:e.clientY,path:n,isDirectory:r})},[]),hideContextMenu:(0,s.useCallback)(()=>{t(null)},[])}}},75346:(e,t,n)=>{n.d(t,{n:()=>s});var r=n(88292);let s={SessionChange:(0,r.R)("session-change"),ViewChange:(0,r.R)("view-change"),OpenNote:(0,r.R)("open-note"),LangChange:(0,r.R)("lang-change"),TabAdd:(0,r.R)("tab-add"),TabClose:(0,r.R)("tab-close"),SwitchSession:(0,r.R)("switch-session"),ProjectChange:(0,r.R)("project-change"),OpenProject:(0,r.R)("open-project"),SessionComplete:(0,r.R)("session-complete"),OpenTokenStats:(0,r.R)("open-token-stats"),PinnedSessionsChanged:(0,r.R)("pinned-sessions-changed"),ScheduledTasksChanged:(0,r.R)("scheduled-tasks-changed"),ScreenshotPrepare:(0,r.R)("screenshot-prepare"),ScreenshotDone:(0,r.R)("screenshot-done")}},77725:(e,t,n)=>{n.d(t,{Z:()=>d});var r=n(12115),s=n(10592),l=n(86359),o=n(80905),a=n(49433),i=n(80286),c=n(86957);function d(e,t){let[n,d]=(0,r.useState)({status:"loading"});return(0,r.useEffect)(()=>{d({status:"loading"});let t=c.t4.runFork(e);return t.addObserver(e=>{s.YW(e,{onSuccess:e=>d({status:"success",data:e}),onFailure:e=>{if(l.t9(e))return;let t=l.od(e);d({status:"error",error:o.Ru(t)?t.value:e})}})}),()=>{a.runFork(i.G(t))}},t),n}},82292:(e,t,n)=>{function r(e,t){for(let n of e){if(n.path===t)return n;if(n.children){let e=r(n.children,t);if(e)return e}}return null}function s(e,t){if(!e)return"";let n=r(t,e);if(n?.isDirectory)return e;let s=e.split("/");return s.pop(),s.join("/")}function l(e){let t=[];for(let n of e){let e=n.split("/"),r=t;for(let t=0;t<e.length;t++){let n=e[t],s=t===e.length-1,l=e.slice(0,t+1).join("/"),o=r.find(e=>e.name===n);o||(o={name:n,path:l,isDirectory:!s,children:s?void 0:[]},r.push(o)),!s&&o.children&&(r=o.children)}}let n=e=>{e.sort((e,t)=>e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)),e.forEach(e=>{e.children&&n(e.children)})};return n(t),t}function o(e){let t=[],n=e=>{for(let r of e)r.isDirectory&&(t.push(r.path),r.children&&n(r.children))};return n(e),t}n.d(t,{B_:()=>f,HR:()=>function e(t,n){if(0===n.length)return t;let r=new Map(n.map(e=>[e.path,e]));return t.map(t=>{let n=r.get(t.path);return n&&t.isDirectory?void 0===t.children&&void 0!==n.children?{...t,children:n.children}:void 0!==t.children&&void 0!==n.children?{...t,children:e(t.children,n.children)}:t:t})},KH:()=>d,MB:()=>r,S7:()=>s,fw:()=>u,q3:()=>c,r6:()=>h,tE:()=>m,tW:()=>o,u:()=>i,v3:()=>l});let a=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp","avif"]);function i(e){let t=e.split(".").pop()?.toLowerCase();return a.has(t||"")}function c(e,t,n=!1){let r=new Set;if(!t)return r;let s=t.toLowerCase(),l=e=>{if(r.add(e.path),e.children)for(let t of e.children)l(t)},o=(e,t)=>{let a=e.name.toLowerCase(),i=n?a===s:a.includes(s);if(i&&e.children)return l(e),t.forEach(e=>r.add(e)),!0;let c=!1;if(e.children)for(let n of e.children)o(n,[...t,e.path])&&(c=!0);return(!!i||!!c)&&(r.add(e.path),t.forEach(e=>r.add(e)),!0)};for(let t of e)o(t,[]);return r}function d(e,t,n=!1){let r=new Set;if(!t)return r;let s=t.toLowerCase();for(let t of e){let e=t.split("/");for(let t=0;t<e.length;t++){let l=e[t].toLowerCase();if(n?l===s:l.includes(s)){for(let t=0;t<=e.length-1;t++)r.add(e.slice(0,t+1).join("/"));break}}}return r}function u(e){let t=Math.floor(Math.floor((Date.now()-1e3*e)/1e3)/60),n=Math.floor(t/60),r=Math.floor(n/24),s=Math.floor(r/30),l=Math.floor(r/365);return l>0?`${l}y ago`:s>0?`${s}mo ago`:r>0?`${r}d ago`:n>0?`${n}h ago`:t>0?`${t}m ago`:"just now"}function h(e){let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0");return r?`${s}-${l} ${o}:${a}`:`${t.getFullYear()}-${s}-${l} ${o}:${a}`}let m=()=>{},f=50},83448:(e,t,n)=>{n.d(t,{Cr:()=>E,F4:()=>p,Fi:()=>m,Hw:()=>d,JC:()=>y,M5:()=>b,Ny:()=>u,QW:()=>j,XO:()=>M,Zr:()=>k,an:()=>L,dM:()=>x,dQ:()=>h,em:()=>c,he:()=>f,l1:()=>v,n_:()=>w,qD:()=>S,tY:()=>T,td:()=>i,tf:()=>R,yS:()=>g,z2:()=>C});var r=n(49433),s=n(82680);let l=(e,t)=>r.tryPromise({try:async()=>{let n=await fetch(e,t);if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()},catch:n=>new s.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),o=(e,t)=>l(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),a=(e,t)=>l(e,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=()=>l("/api/settings"),c=e=>a("/api/settings",e),d=e=>l(`/api/${e}/credentials`),u=e=>l(`/api/${e}/credentials?reveal=1`),h=(e,t)=>a(`/api/${e}/credentials`,{apiKey:t}),m=e=>l(`/api/${e}/models`),f=()=>l("/api/deepseek/balance"),x=e=>l(`/api/${e}/usage`),p=()=>l("/api/ollama/config"),g=e=>a("/api/ollama/config",e),b=()=>l("/api/commands"),v=()=>l("/api/skills"),y=e=>o("/api/bash",e),w=e=>r.tryPromise({try:async()=>{let t=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?await t.json():null},catch:e=>new s.uV({message:"POST /api/session-by-path failed",cause:e})}),k=(e,t)=>o(`/api/session/${encodeURIComponent(e)}/fork`,t),j=e=>l(`/api/sessions/projects/${encodeURIComponent(e)}`),C=()=>l("/api/global-state").pipe(r.map(e=>e.sessions??[])),N=()=>r.tryPromise({try:async()=>{let e=await fetch("/api/ollama/models");return 503===e.status?{_tag:"not-running"}:e.ok?{_tag:"ok",models:(await e.json()).models??[]}:{_tag:"error",message:"Failed to fetch models"}},catch:e=>new s.uV({message:"fetch ollama models failed",cause:e})}),S=e=>r.gen(function*(){let t=yield*N();if("not-running"!==t._tag)return t;e&&(yield*r.sync(e));let n=yield*r.tryPromise({try:async()=>{let e=await fetch("/api/ollama/start",{method:"POST"}),t=await e.json().catch(()=>({}));return 404===e.status?{_tag:"not-installed",message:t.message||"Ollama is not installed"}:e.ok?{_tag:"started"}:{_tag:"error",message:"Failed to start Ollama"}},catch:e=>new s.uV({message:"start ollama failed",cause:e})});if("not-installed"===n._tag)return{_tag:"not-installed",message:n.message};if("error"===n._tag)return{_tag:"error",message:n.message};let l=yield*N();return"not-running"===l._tag?{_tag:"error",message:"Ollama started but cannot fetch models"}:l}),L=e=>l(`/api/file?path=${encodeURIComponent(e)}`),E=()=>l("/api/claude-stats"),M=()=>l("/api/prompts/config?scope=global"),R=e=>l(`/api/prompts/config?cwd=${encodeURIComponent(e)}`),T=e=>o("/api/prompts/config",e)},83897:(e,t,n)=>{n.d(t,{k_:()=>a,nH:()=>i});var r=n(95155),s=n(12115),l=n(48347);let o=(0,s.createContext)(null);function a({children:e}){let t=(0,s.useRef)(new Map),n=(0,s.useRef)(null),[i,c]=(0,s.useState)(!1),d=(0,s.useCallback)((e,n)=>{t.current.set(n,e)},[]),u=(0,s.useCallback)(e=>{t.current.delete(e)},[]),h=(0,s.useCallback)(e=>{n.current=e},[]),m=(0,s.useCallback)(e=>{let r=n.current;if(!r)return void console.warn("No active tab to send message");let s=t.current.get(r);s?s(e):console.warn(`No chat sender registered for tab ${r}`)},[]),f=(0,s.useMemo)(()=>({sendMessage:m,isLoading:i,registerChat:d,unregisterChat:u,setActiveTab:h,setIsLoading:c}),[m,i,d,u,h]),x=(0,s.useMemo)(()=>({sendMessage:m,isLoading:i}),[m,i]);return(0,r.jsx)(o.Provider,{value:f,children:(0,r.jsx)(l.H,{value:x,children:e})})}function i(){return(0,s.useContext)(o)}},85269:(e,t,n)=>{n.d(t,{O:()=>h});var r=n(95155),s=n(12115),l=n(48347),o=n(89109),a=n(7320),i=n(34582),c=n(1058),d=n(90717),u=n(69809);function h({content:e,filePath:t,cwd:n,onContentSearch:m,reloadKey:f=0}){let x=(0,l.r)(),p=!!n,g=(0,s.useMemo)(()=>{if((0,i.qF)(t,n))return{mode:"url",url:(0,i.Xe)(t,n)};let r=e??"",s=(0,i.J4)(t,n),l="https:"===window.location.protocol?"wss:":"ws:",o=`${l}//${window.location.host}/ws/bash?cwd=${encodeURIComponent(s)}`;return{mode:"srcdoc",html:(0,i.OP)(r,{cwd:s,wsUrl:o})}},[e,t,n]),{addComment:b,refresh:v}=(0,c._)({cwd:n||"",filePath:t}),[y,w]=(0,s.useState)(null),k=(0,s.useRef)(null),j=(0,s.useRef)(null),C=(0,s.useRef)(()=>{}),[N,S]=(0,s.useState)(null),[L,E]=(0,s.useState)(null),M=(0,s.useRef)(!1);(0,s.useEffect)(()=>{M.current=!!(N||L)},[N,L]);let R=(0,s.useCallback)(()=>{j.current&&(j.current=null,C.current())},[]),T=(0,s.useCallback)(()=>{let e=k.current,t=e?.contentWindow;if(t){let e=document.documentElement.classList.contains("dark");t.postMessage({type:"THEME_CHANGE",theme:e?"dark":"light"},"*"),t.postMessage({type:"cockpit:language-change",lang:u.A.language},"*")}if(!p)return;let n=e?.contentDocument;e&&n&&(n.addEventListener("mouseup",t=>{if(M.current)return;let n=e.contentWindow?.getSelection(),r=n&&!n.isCollapsed?n.toString().trim():"";if(!r)return void R();let s=e.getBoundingClientRect();j.current={x:s.left+t.clientX,y:s.top+t.clientY,range:{start:0,end:0},selectedText:r,lineSnapshot:r},C.current()}),n.addEventListener("mousedown",()=>{R(),S(null),E(null)}),n.addEventListener("scroll",()=>R(),{capture:!0,passive:!0}))},[p,R]),$=(0,s.useCallback)(()=>{let e=j.current;e&&(S({x:e.x,y:e.y,text:e.selectedText}),R(),k.current?.contentWindow?.getSelection()?.removeAllRanges())},[R]),I=(0,s.useCallback)(()=>{let e=j.current;e&&(E({x:e.x,y:e.y,text:e.selectedText}),R(),k.current?.contentWindow?.getSelection()?.removeAllRanges())},[R]),P=(0,s.useCallback)(()=>{let e=j.current;e&&x&&(R(),k.current?.contentWindow?.getSelection()?.removeAllRanges(),(0,d.Ff)(x.sendMessage,{filePath:t,startLine:0,endLine:0,codeContent:e.selectedText},u.A.t("explain.selectionMessage")))},[x,t,R]),A=(0,s.useCallback)(()=>{let e=j.current;if(!e||!m)return;let t=e.selectedText.trim();R(),k.current?.contentWindow?.getSelection()?.removeAllRanges(),t&&m(t)},[m,R]),_=(0,s.useCallback)(async e=>{N&&(await b(0,0,e,N.text),S(null))},[N,b]),F=(0,s.useCallback)(async(e,r)=>{if(x&&n)try{let s=(await (0,d.$3)(n)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));s.push({filePath:t,startLine:0,endLine:0,codeContent:e});let l=(0,d.Gw)(s,r);x.sendMessage(l),await (0,d.RP)(n),v()}catch(e){console.error("[HtmlAppFrame] send to AI failed:",e)}},[x,n,t,v]),B=(0,s.useCallback)(e=>{L&&F(L.text,e)},[L,F]),D=(0,s.useCallback)(e=>{N&&F(N.text,e)},[N,F]);return(0,r.jsxs)("div",{ref:w,className:"relative h-full w-full bg-white",children:[(0,r.jsx)("iframe",{ref:k,..."url"===g.mode?{src:g.url}:{srcDoc:g.html},title:t,className:"h-full w-full border-0",onLoad:T},`${t}:${f}`),p&&y&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.fS,{floatingToolbarRef:j,bumpRef:C,container:y,onAddComment:$,onSendToAI:I,onSearch:m?A:void 0,onExplain:x?P:void 0,isChatLoading:x?.isLoading}),N&&(0,r.jsx)(a.t,{x:N.x,y:N.y,range:{start:0,end:0},filePath:t,lineSnapshot:N.text,container:y,onSubmit:_,onSendToAI:x?D:void 0,onClose:()=>S(null),isChatLoading:x?.isLoading}),L&&(0,r.jsx)(a.G,{x:L.x,y:L.y,range:{start:0,end:0},filePath:t,lineSnapshot:L.text,container:y,onSubmit:B,onClose:()=>E(null),isChatLoading:x?.isLoading})]})]})}},86304:(e,t,n)=>{n.d(t,{P:()=>c});var r=n(12115),s=n(79114),l=n(34075),o=n(86957),a=n(63040),i=n(63563);function c(){let{t:e}=(0,s.Bd)();return(0,r.useCallback)(async t=>{let n=await o.t4.runPromiseExit((0,a.ot)(t));if("Success"===n._tag)n.value.alreadyExists?(0,l.oR)(e("htmlApps.alreadyAdded"),"info"):((0,l.oR)(e("htmlApps.added"),"success"),(0,i.N)());else{let t="Fail"===n.cause._tag?n.cause.error:null,r=t?.cause,s=r instanceof Error?r.message:e("htmlApps.addFailed");(0,l.oR)(s,"error")}},[e])}},88780:(e,t,n)=>{n.d(t,{Do:()=>u,Sz:()=>h,VO:()=>d,wI:()=>m});var r=n(95155),s=n(12115),l=n(79114),o=n(70188),a=n(14575);function i({status:e}){let{label:t,className:n}={added:{label:"A",className:"text-green-11"},untracked:{label:"A",className:"text-green-11"},modified:{label:"M",className:"text-amber-11"},deleted:{label:"D",className:"text-red-11"},renamed:{label:"R",className:"text-brand"}}[e]||{label:"?",className:"text-muted-foreground"};return(0,r.jsx)("span",{className:`text-xs font-bold ${n}`,children:t})}let c=s.memo(function e({node:t,level:n,selectedPath:l,expandedPaths:o,onSelect:c,onToggle:d,onContextMenu:u,showChanges:h=!1,renderActions:m}){let f=l===t.path,x=o.has(t.path),p=(0,s.useCallback)(()=>{t.isDirectory?d(t.path):c(t)},[t,c,d]),g=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),u(e,t.path,t.isDirectory)},[t.path,t.isDirectory,u]);return t.isDirectory?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-hover cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*n+8}px`},onClick:p,onContextMenu:g,children:[(0,r.jsx)("span",{className:"text-foreground-subtle text-xs",children:x?"▼":"▶"}),(0,r.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":t.path,children:t.name}),m&&m(t)]}),x&&t.children.map(t=>(0,r.jsx)(e,{node:t,level:n+1,selectedPath:l,expandedPaths:o,onSelect:c,onToggle:d,onContextMenu:u,showChanges:h,renderActions:m},t.path))]}):(0,r.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${f?"bg-brand/10":"hover:bg-hover"}`,style:{paddingLeft:`${12*n+8}px`},onClick:p,onContextMenu:g,children:[(0,r.jsx)(a.o,{name:t.name,size:16,className:"flex-shrink-0"}),(0,r.jsx)("span",{className:`text-sm flex-1 truncate ${f?"text-brand":"text-foreground"}`,"data-tooltip":t.path,children:t.name}),t.status&&(0,r.jsx)(i,{status:t.status}),h&&void 0!==t.additions&&void 0!==t.deletions&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"text-xs text-green-11",children:["+",t.additions]}),(0,r.jsxs)("span",{className:"text-xs text-red-11",children:["-",t.deletions]})]}),m&&m(t)]})});function d({files:e,selectedPath:t,expandedPaths:n,onSelect:s,onToggle:a,cwd:i,showChanges:u=!1,renderActions:h,emptyMessage:m,className:f,onExplain:x,explainDisabled:p}){let{t:g}=(0,l.Bd)(),b=m??g("gitFileTree.noFiles"),{contextMenu:v,showContextMenu:y,hideContextMenu:w}=(0,o.Ee)();return 0===e.length?(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-foreground-subtle",children:b}):(0,r.jsxs)("div",{className:f||"py-1",children:[e.map(e=>(0,r.jsx)(c,{node:e,level:0,selectedPath:t,expandedPaths:n,onSelect:s,onToggle:a,onContextMenu:y,showChanges:u,renderActions:h},e.path)),v&&(0,r.jsx)(o.ft,{x:v.x,y:v.y,path:v.path,cwd:i,isDirectory:v.isDirectory,onClose:w,onExplain:x,explainDisabled:p})]})}function u(e){let t=[];for(let n of e){let e=n.path.split("/"),r=t;for(let t=0;t<e.length;t++){let s=e[t],l=t===e.length-1,o=e.slice(0,t+1).join("/"),a=r.find(e=>e.name===s);a||(a={name:s,path:o,isDirectory:!l,children:[],...l&&{status:n.status,additions:n.additions,deletions:n.deletions,oldPath:n.oldPath,file:n}},r.push(a)),l||(r=a.children)}}let n=e=>{e.sort((e,t)=>e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)),e.forEach(e=>n(e.children))};return n(t),t}function h(e){let t=[],n=e=>{for(let r of e)r.isDirectory&&(t.push(r.path),n(r.children))};return n(e),t}function m(e){let t=[],n=e=>{if(e.isDirectory)for(let t of e.children)n(t);else t.push(e)};return n(e),t}},89109:(e,t,n)=>{n.d(t,{SZ:()=>o,fS:()=>c});var r=n(95155),s=n(12115),l=n(79114);let o=[["quickReply.optionA","quickReply.optionB","quickReply.optionC","quickReply.optionD"],["quickReply.allRecommended","quickReply.thisOne","quickReply.notThis"],["quickReply.why","quickReply.elaborate","quickReply.example"],["quickReply.start","quickReply.continue","quickReply.ok","quickReply.done"]];function a({rows:e,placeAbove:t,onHeight:n,onPick:o,onEdit:i,onMouseEnter:c,onMouseLeave:d}){let{t:u}=(0,l.Bd)(),h=(0,s.useRef)(null);return(0,s.useEffect)(()=>{h.current&&n(h.current.getBoundingClientRect().height)},[n,e]),(0,r.jsxs)("div",{ref:h,className:`absolute ${t?"bottom-full mb-1":"top-full mt-1"} left-0 z-[201] flex flex-col gap-1 bg-card border border-border rounded-lg shadow-lv3 p-1.5`,onMouseEnter:c,onMouseLeave:d,children:[i&&(0,r.jsx)("button",{className:"absolute top-0.5 right-0.5 p-1 text-muted-foreground hover:text-brand transition-colors",onClick:i,title:u("quickReply.edit"),"aria-label":u("quickReply.edit"),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),e.map((e,t)=>(0,r.jsx)("div",{className:`flex items-center gap-1${i&&0===t?" pr-5":""}`,children:e.map((e,n)=>(0,r.jsx)("button",{className:"px-2 py-1 text-xs whitespace-nowrap border border-border text-foreground rounded hover:border-brand hover:bg-hover transition-colors",onClick:()=>o(e),children:e},`${t}:${n}:${e}`))},t))]})}function i({x:e,y:t,visible:n,container:c,onAddComment:d,onSendToAI:u,onSearch:h,onExplain:m,onQuickReply:f,quickReplyRows:x,onEditQuickReplies:p,isChatLoading:g}){let{t:b}=(0,l.Bd)(),v=(0,s.useRef)(null),[y,w]=(0,s.useState)({w:0,h:0}),[k,j]=(0,s.useState)(0),[C,N]=(0,s.useState)(null),S=(0,s.useRef)(null);(0,s.useLayoutEffect)(()=>{let e=v.current;if(!e)return;let{width:t,height:n}=e.getBoundingClientRect();w(e=>e.w===t&&e.h===n?e:{w:t,h:n})});let L=(0,s.useCallback)(e=>{j(t=>t===e?t:e)},[]);(0,s.useEffect)(()=>{n||N(null)},[n]);let E=(0,s.useCallback)(()=>{S.current&&(clearTimeout(S.current),S.current=null)},[]),M=(0,s.useCallback)(e=>{E(),N(e)},[E]),R=(0,s.useCallback)(()=>{E(),S.current=setTimeout(()=>N(null),150)},[E]);(0,s.useEffect)(()=>E,[E]);let T=c.getBoundingClientRect(),$=e-T.left,I=Math.max(0,t-T.top-40),P=Math.max(0,Math.min($+8,T.width-y.w-8)),A=k>0&&I+y.h+8+k>T.height,_=(0,s.useMemo)(()=>x??o.map(e=>e.map(e=>b(e))),[x,b]),F=e=>f&&C===e?(0,r.jsx)(a,{rows:_,onEdit:p,placeAbove:A,onHeight:L,onPick:t=>{N(null),f(e,t)},onMouseEnter:E,onMouseLeave:R}):null;return(0,r.jsxs)("div",{ref:v,className:"floating-toolbar absolute z-[200] flex items-center gap-1.5 bg-card border border-border rounded-lg shadow-lv3 p-1.5",style:{left:P,top:I,visibility:n?"visible":"hidden",pointerEvents:n?"auto":"none"},children:[(0,r.jsxs)("div",{className:"relative",onMouseEnter:()=>M("comment"),onMouseLeave:R,children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:d,children:b("floatingToolbar.addComment")}),F("comment")]}),(0,r.jsxs)("div",{className:"relative",onMouseEnter:()=>{g||M("ai")},onMouseLeave:R,children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:u,disabled:g,title:g?b("comments.aiResponding"):void 0,children:b("floatingToolbar.sendToAI")}),F("ai")]}),m&&(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:m,disabled:g,title:g?b("comments.aiResponding"):void 0,children:b("explain.action")}),h&&(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:h,children:b("floatingToolbar.search")})]})}let c=(0,s.memo)(function({floatingToolbarRef:e,bumpRef:t,container:n,onAddComment:l,onSendToAI:o,onSearch:a,onExplain:c,onQuickReply:d,quickReplyRows:u,onEditQuickReplies:h,isChatLoading:m}){let[f,x]=(0,s.useState)(0);(0,s.useEffect)(()=>{t.current=()=>x(e=>e+1)},[t]);let p=(0,s.useMemo)(()=>e.current,[f]);return(0,r.jsx)(i,{x:p?.x??0,y:p?.y??0,visible:!!p,container:n,onAddComment:l,onSendToAI:o,onSearch:a,onExplain:c,onQuickReply:d,quickReplyRows:u,onEditQuickReplies:h,isChatLoading:m})})},90717:(e,t,n)=>{n.d(t,{$3:()=>u,Cm:()=>d,Ff:()=>x,Gw:()=>f,RP:()=>h,Un:()=>m,zL:()=>c});var r=n(69809),s=n(49433),l=n(86957),o=n(82680),a=n(46456);let i=new Set;function c(e){return i.add(e),()=>i.delete(e)}function d(){i.forEach(e=>e())}async function u(e){let t=await l.t4.runPromiseExit((0,a.lb)(e));if("Success"!==t._tag)throw Error("Failed to fetch comments");let n=t.value.comments??[];if(0===n.length)return[];let r=new Map;for(let e of n)e.selectedText||(r.has(e.filePath)||r.set(e.filePath,[]),r.get(e.filePath).push(e));let i=new Map;await Promise.all(Array.from(r.keys()).map(async t=>{let n=await l.t4.runPromiseExit(s.tryPromise({try:async()=>{let n=await fetch(`/api/files/text?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`);return n.ok?await n.json():null},catch:e=>new o.uV({message:`read file text ${t} failed`,cause:e})}));"Success"===n._tag&&n.value&&"string"==typeof n.value.content?i.set(t,n.value.content.split("\n")):"Failure"===n._tag&&console.error(`Failed to read file ${t}:`,n.cause)}));let c=[];for(let e of n){if(e.selectedText){c.push({...e,codeContent:e.selectedText});continue}let t=i.get(e.filePath),n="";if(t){let r=Math.max(0,e.startLine-1),s=Math.min(t.length,e.endLine);n=t.slice(r,s).join("\n")}c.push({...e,codeContent:n})}return c}async function h(e){let t=await l.t4.runPromiseExit((0,a.tj)(e));return"Success"===t._tag?(d(),!0):(console.error("Failed to clear comments:",t.cause),!1)}let m="__chat__";function f(e,t){let n=e.filter(e=>e.filePath===m),s=e.filter(e=>e.filePath!==m),l=[];for(let e of(s.length>0&&(l.push(`${r.A.t("comments.codeRef")}`,""),s.forEach((e,t)=>{let n=e.startLine>0||e.endLine>0?`:${e.startLine}-${e.endLine}`:"";l.push(`[${t+1}] ${e.filePath}${n}`),l.push("```"),l.push(e.codeContent),l.push("```"),e.note&&l.push(r.A.t("comments.note",{content:e.note})),l.push("")})),n)){let t=e.codeContent.split("\n").map(e=>`> ${e}`).join("\n");l.push(t),e.note&&l.push(e.note),l.push("")}if(t.trim()){for(;l.length>0&&""===l[l.length-1];)l.pop();l.push(t.trim())}return l.join("\n").trim()}function x(e,t,n){e(f([t],n))}},95045:(e,t,n)=>{n.d(t,{F:()=>o});var r=n(49433),s=n(88292),l=n(86957);let o=(e,t)=>{l.t4.runFork(r.flatMap(s.d,n=>n.publish(e,t)))}},95686:(e,t,n)=>{n.d(t,{x:()=>i});var r=n(95155),s=n(12115),l=n(64428),o=n(70188),a=n(5135);function i({filePath:e,content:t,cwd:n,onClose:c,zClassName:d="z-50"}){let[u,h]=(0,s.useState)(null);return(0,r.jsx)(l.ZL,{children:(0,r.jsx)("div",{className:`fixed inset-0 ${d} flex items-center justify-center bg-scrim p-0 md:p-4`,onClick:c,children:(0,r.jsx)("div",{ref:h,className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(o.SU,{container:u,children:(0,r.jsx)(a.M,{content:t,filePath:e,cwd:n,onClose:c})})})})})}},96497:(e,t,n)=>{function r(e,t){let n,r=document.caretRangeFromPoint(e.clientX,e.clientY);if(!r||!t.contains(r.startContainer))return 1;let s=r.startContainer,l=r.startOffset,o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),a=1;for(;n=o.nextNode();){if(n===s){a+=l;break}a+=n.textContent?.length||0}return a}function s(e,t){if(0!==e.buttons)return null;let n=window.getSelection();if(n&&!n.isCollapsed)return null;let s=e.target;if("SPAN"!==s.tagName||!s.style.color)return null;let l=s.getBoundingClientRect();return{column:r(e,t),rect:{x:l.left,y:l.bottom+4}}}n.d(t,{A:()=>s,j:()=>r})}}]);