@surething/cockpit 1.0.204 → 1.0.206

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 (325) hide show
  1. package/.next-prod/BUILD_ID +1 -1
  2. package/.next-prod/app-path-routes-manifest.json +23 -23
  3. package/.next-prod/build-manifest.json +3 -3
  4. package/.next-prod/prerender-manifest.json +3 -3
  5. package/.next-prod/react-loadable-manifest.json +3 -3
  6. package/.next-prod/required-server-files.js +14 -1
  7. package/.next-prod/required-server-files.json +14 -1
  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/_global-error.segment.rsc +1 -1
  15. package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +1 -1
  16. package/.next-prod/server/app/_global-error.segments/_index.segment.rsc +1 -1
  17. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  18. package/.next-prod/server/app/_not-found/page.js +2 -2
  19. package/.next-prod/server/app/_not-found/page.js.nft.json +1 -1
  20. package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
  21. package/.next-prod/server/app/_not-found.html +2 -2
  22. package/.next-prod/server/app/_not-found.rsc +4 -3
  23. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +4 -3
  24. package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +1 -1
  25. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +4 -3
  26. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  27. package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  28. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +3 -2
  29. package/.next-prod/server/app/api/bash/route.js +1 -1
  30. package/.next-prod/server/app/api/bash/route.js.nft.json +1 -1
  31. package/.next-prod/server/app/api/chat/codex/route.js +3 -3
  32. package/.next-prod/server/app/api/chat/codex/route.js.nft.json +1 -1
  33. package/.next-prod/server/app/api/chat/deepseek/route.js +6 -6
  34. package/.next-prod/server/app/api/chat/deepseek/route.js.nft.json +1 -1
  35. package/.next-prod/server/app/api/chat/kimi/route.js +3 -3
  36. package/.next-prod/server/app/api/chat/kimi/route.js.nft.json +1 -1
  37. package/.next-prod/server/app/api/chat/ollama/route.js +18 -18
  38. package/.next-prod/server/app/api/chat/ollama/route.js.nft.json +1 -1
  39. package/.next-prod/server/app/api/chat/route.js +3 -3
  40. package/.next-prod/server/app/api/chat/route.js.nft.json +1 -1
  41. package/.next-prod/server/app/api/claude-stats/route.js +1 -1
  42. package/.next-prod/server/app/api/claude-stats/route.js.nft.json +1 -1
  43. package/.next-prod/server/app/api/commands/route.js +1 -1
  44. package/.next-prod/server/app/api/commands/route.js.nft.json +1 -1
  45. package/.next-prod/server/app/api/comments/route.js +1 -1
  46. package/.next-prod/server/app/api/comments/route.js.nft.json +1 -1
  47. package/.next-prod/server/app/api/db/columns/route.js +4 -4
  48. package/.next-prod/server/app/api/db/columns/route.js.nft.json +1 -1
  49. package/.next-prod/server/app/api/db/connect/route.js +1 -1
  50. package/.next-prod/server/app/api/db/connect/route.js.nft.json +1 -1
  51. package/.next-prod/server/app/api/db/disconnect/route.js +1 -1
  52. package/.next-prod/server/app/api/db/disconnect/route.js.nft.json +1 -1
  53. package/.next-prod/server/app/api/db/export/route.js +1 -1
  54. package/.next-prod/server/app/api/db/export/route.js.nft.json +1 -1
  55. package/.next-prod/server/app/api/db/query/route.js +1 -1
  56. package/.next-prod/server/app/api/db/query/route.js.nft.json +1 -1
  57. package/.next-prod/server/app/api/db/schemas/route.js +2 -2
  58. package/.next-prod/server/app/api/db/schemas/route.js.nft.json +1 -1
  59. package/.next-prod/server/app/api/extension/version/route.js +1 -1
  60. package/.next-prod/server/app/api/extension/version/route.js.nft.json +1 -1
  61. package/.next-prod/server/app/api/file/route.js +1 -1
  62. package/.next-prod/server/app/api/file/route.js.nft.json +1 -1
  63. package/.next-prod/server/app/api/files/blame/route.js +1 -1
  64. package/.next-prod/server/app/api/files/blame/route.js.nft.json +1 -1
  65. package/.next-prod/server/app/api/files/clipboard/route.js +1 -1
  66. package/.next-prod/server/app/api/files/clipboard/route.js.nft.json +1 -1
  67. package/.next-prod/server/app/api/files/copy/route.js +1 -1
  68. package/.next-prod/server/app/api/files/copy/route.js.nft.json +1 -1
  69. package/.next-prod/server/app/api/files/delete/route.js +1 -1
  70. package/.next-prod/server/app/api/files/delete/route.js.nft.json +1 -1
  71. package/.next-prod/server/app/api/files/expanded/route.js +1 -1
  72. package/.next-prod/server/app/api/files/expanded/route.js.nft.json +1 -1
  73. package/.next-prod/server/app/api/files/index/route.js +1 -1
  74. package/.next-prod/server/app/api/files/index/route.js.nft.json +1 -1
  75. package/.next-prod/server/app/api/files/init/route.js +1 -1
  76. package/.next-prod/server/app/api/files/init/route.js.nft.json +1 -1
  77. package/.next-prod/server/app/api/files/paste/route.js +1 -1
  78. package/.next-prod/server/app/api/files/paste/route.js.nft.json +1 -1
  79. package/.next-prod/server/app/api/files/read/route.js +1 -1
  80. package/.next-prod/server/app/api/files/read/route.js.nft.json +1 -1
  81. package/.next-prod/server/app/api/files/readdir/route.js +1 -1
  82. package/.next-prod/server/app/api/files/readdir/route.js.nft.json +1 -1
  83. package/.next-prod/server/app/api/files/recent/route.js +1 -1
  84. package/.next-prod/server/app/api/files/recent/route.js.nft.json +1 -1
  85. package/.next-prod/server/app/api/files/save/route.js +1 -1
  86. package/.next-prod/server/app/api/files/save/route.js.nft.json +1 -1
  87. package/.next-prod/server/app/api/files/search/route.js +1 -1
  88. package/.next-prod/server/app/api/files/search/route.js.nft.json +1 -1
  89. package/.next-prod/server/app/api/files/stat/route.js +1 -1
  90. package/.next-prod/server/app/api/files/stat/route.js.nft.json +1 -1
  91. package/.next-prod/server/app/api/files/text/route.js +1 -1
  92. package/.next-prod/server/app/api/files/text/route.js.nft.json +1 -1
  93. package/.next-prod/server/app/api/git/branch-diff/route.js +1 -1
  94. package/.next-prod/server/app/api/git/branch-diff/route.js.nft.json +1 -1
  95. package/.next-prod/server/app/api/git/branches/route.js +1 -1
  96. package/.next-prod/server/app/api/git/branches/route.js.nft.json +1 -1
  97. package/.next-prod/server/app/api/git/commit-diff/route.js +1 -1
  98. package/.next-prod/server/app/api/git/commit-diff/route.js.nft.json +1 -1
  99. package/.next-prod/server/app/api/git/commits/route.js +1 -1
  100. package/.next-prod/server/app/api/git/commits/route.js.nft.json +1 -1
  101. package/.next-prod/server/app/api/git/diff/route.js +1 -1
  102. package/.next-prod/server/app/api/git/diff/route.js.nft.json +1 -1
  103. package/.next-prod/server/app/api/git/discard/route.js +1 -1
  104. package/.next-prod/server/app/api/git/discard/route.js.nft.json +1 -1
  105. package/.next-prod/server/app/api/git/stage/route.js +1 -1
  106. package/.next-prod/server/app/api/git/stage/route.js.nft.json +1 -1
  107. package/.next-prod/server/app/api/git/status/route.js +1 -1
  108. package/.next-prod/server/app/api/git/status/route.js.nft.json +1 -1
  109. package/.next-prod/server/app/api/git/unstage/route.js +1 -1
  110. package/.next-prod/server/app/api/git/unstage/route.js.nft.json +1 -1
  111. package/.next-prod/server/app/api/git/worktree/route.js +1 -1
  112. package/.next-prod/server/app/api/git/worktree/route.js.nft.json +1 -1
  113. package/.next-prod/server/app/api/global-state/route.js +1 -1
  114. package/.next-prod/server/app/api/global-state/route.js.nft.json +1 -1
  115. package/.next-prod/server/app/api/jupyter/load/route.js +1 -1
  116. package/.next-prod/server/app/api/jupyter/load/route.js.nft.json +1 -1
  117. package/.next-prod/server/app/api/jupyter/save/route.js +1 -1
  118. package/.next-prod/server/app/api/jupyter/save/route.js.nft.json +1 -1
  119. package/.next-prod/server/app/api/jupyter/shutdown/route.js +1 -1
  120. package/.next-prod/server/app/api/jupyter/shutdown/route.js.nft.json +1 -1
  121. package/.next-prod/server/app/api/lsp/definition/route.js +1 -1
  122. package/.next-prod/server/app/api/lsp/definition/route.js.nft.json +1 -1
  123. package/.next-prod/server/app/api/lsp/hover/route.js +1 -1
  124. package/.next-prod/server/app/api/lsp/hover/route.js.nft.json +1 -1
  125. package/.next-prod/server/app/api/lsp/references/route.js +1 -1
  126. package/.next-prod/server/app/api/lsp/references/route.js.nft.json +1 -1
  127. package/.next-prod/server/app/api/lsp/status/route.js +1 -1
  128. package/.next-prod/server/app/api/lsp/status/route.js.nft.json +1 -1
  129. package/.next-prod/server/app/api/lsp/warmup/route.js +1 -1
  130. package/.next-prod/server/app/api/lsp/warmup/route.js.nft.json +1 -1
  131. package/.next-prod/server/app/api/mysql/columns/route.js +4 -4
  132. package/.next-prod/server/app/api/mysql/columns/route.js.nft.json +1 -1
  133. package/.next-prod/server/app/api/mysql/connect/route.js +1 -1
  134. package/.next-prod/server/app/api/mysql/connect/route.js.nft.json +1 -1
  135. package/.next-prod/server/app/api/mysql/disconnect/route.js +1 -1
  136. package/.next-prod/server/app/api/mysql/disconnect/route.js.nft.json +1 -1
  137. package/.next-prod/server/app/api/mysql/export/route.js +1 -1
  138. package/.next-prod/server/app/api/mysql/export/route.js.nft.json +1 -1
  139. package/.next-prod/server/app/api/mysql/query/route.js +1 -1
  140. package/.next-prod/server/app/api/mysql/query/route.js.nft.json +1 -1
  141. package/.next-prod/server/app/api/mysql/schemas/route.js +2 -2
  142. package/.next-prod/server/app/api/mysql/schemas/route.js.nft.json +1 -1
  143. package/.next-prod/server/app/api/neo4j/connect/route.js +1 -1
  144. package/.next-prod/server/app/api/neo4j/connect/route.js.nft.json +1 -1
  145. package/.next-prod/server/app/api/neo4j/disconnect/route.js +1 -1
  146. package/.next-prod/server/app/api/neo4j/disconnect/route.js.nft.json +1 -1
  147. package/.next-prod/server/app/api/neo4j/query/route.js +1 -1
  148. package/.next-prod/server/app/api/neo4j/query/route.js.nft.json +1 -1
  149. package/.next-prod/server/app/api/neo4j/schema/route.js +1 -1
  150. package/.next-prod/server/app/api/neo4j/schema/route.js.nft.json +1 -1
  151. package/.next-prod/server/app/api/note/route.js +1 -1
  152. package/.next-prod/server/app/api/note/route.js.nft.json +1 -1
  153. package/.next-prod/server/app/api/ollama/models/route.js +1 -1
  154. package/.next-prod/server/app/api/ollama/models/route.js.nft.json +1 -1
  155. package/.next-prod/server/app/api/ollama/start/route.js +1 -1
  156. package/.next-prod/server/app/api/ollama/start/route.js.nft.json +1 -1
  157. package/.next-prod/server/app/api/open-cursor/route.js +1 -1
  158. package/.next-prod/server/app/api/open-cursor/route.js.nft.json +1 -1
  159. package/.next-prod/server/app/api/open-vscode/route.js +1 -1
  160. package/.next-prod/server/app/api/open-vscode/route.js.nft.json +1 -1
  161. package/.next-prod/server/app/api/pick-folder/route.js +1 -1
  162. package/.next-prod/server/app/api/pick-folder/route.js.nft.json +1 -1
  163. package/.next-prod/server/app/api/pinned-sessions/route.js +1 -1
  164. package/.next-prod/server/app/api/pinned-sessions/route.js.nft.json +1 -1
  165. package/.next-prod/server/app/api/project-settings/route.js +1 -1
  166. package/.next-prod/server/app/api/project-settings/route.js.nft.json +1 -1
  167. package/.next-prod/server/app/api/project-state/route.js +1 -1
  168. package/.next-prod/server/app/api/project-state/route.js.nft.json +1 -1
  169. package/.next-prod/server/app/api/projectGraph/file/route.js +1 -1
  170. package/.next-prod/server/app/api/projectGraph/file/route.js.nft.json +1 -1
  171. package/.next-prod/server/app/api/projectGraph/file-functions/route.js +1 -1
  172. package/.next-prod/server/app/api/projectGraph/file-functions/route.js.nft.json +1 -1
  173. package/.next-prod/server/app/api/projectGraph/search/route.js +1 -1
  174. package/.next-prod/server/app/api/projectGraph/search/route.js.nft.json +1 -1
  175. package/.next-prod/server/app/api/projects/route.js +1 -1
  176. package/.next-prod/server/app/api/projects/route.js.nft.json +1 -1
  177. package/.next-prod/server/app/api/redis/command/route.js +1 -1
  178. package/.next-prod/server/app/api/redis/command/route.js.nft.json +1 -1
  179. package/.next-prod/server/app/api/redis/connect/route.js +1 -1
  180. package/.next-prod/server/app/api/redis/connect/route.js.nft.json +1 -1
  181. package/.next-prod/server/app/api/redis/delete/route.js +1 -1
  182. package/.next-prod/server/app/api/redis/delete/route.js.nft.json +1 -1
  183. package/.next-prod/server/app/api/redis/disconnect/route.js +1 -1
  184. package/.next-prod/server/app/api/redis/disconnect/route.js.nft.json +1 -1
  185. package/.next-prod/server/app/api/redis/get/route.js +1 -1
  186. package/.next-prod/server/app/api/redis/get/route.js.nft.json +1 -1
  187. package/.next-prod/server/app/api/redis/keys/route.js +1 -1
  188. package/.next-prod/server/app/api/redis/keys/route.js.nft.json +1 -1
  189. package/.next-prod/server/app/api/redis/set/route.js +1 -1
  190. package/.next-prod/server/app/api/redis/set/route.js.nft.json +1 -1
  191. package/.next-prod/server/app/api/review/[id]/comments/route.js +1 -1
  192. package/.next-prod/server/app/api/review/[id]/comments/route.js.nft.json +1 -1
  193. package/.next-prod/server/app/api/review/[id]/replies/route.js +1 -1
  194. package/.next-prod/server/app/api/review/[id]/replies/route.js.nft.json +1 -1
  195. package/.next-prod/server/app/api/review/[id]/route.js +1 -1
  196. package/.next-prod/server/app/api/review/[id]/route.js.nft.json +1 -1
  197. package/.next-prod/server/app/api/review/identify/route.js +1 -1
  198. package/.next-prod/server/app/api/review/identify/route.js.nft.json +1 -1
  199. package/.next-prod/server/app/api/review/order/route.js +1 -1
  200. package/.next-prod/server/app/api/review/order/route.js.nft.json +1 -1
  201. package/.next-prod/server/app/api/review/route.js +1 -1
  202. package/.next-prod/server/app/api/review/route.js.nft.json +1 -1
  203. package/.next-prod/server/app/api/review/share-info/route.js +1 -1
  204. package/.next-prod/server/app/api/review/share-info/route.js.nft.json +1 -1
  205. package/.next-prod/server/app/api/review/users/route.js +1 -1
  206. package/.next-prod/server/app/api/review/users/route.js.nft.json +1 -1
  207. package/.next-prod/server/app/api/scheduled-tasks/route.js +1 -1
  208. package/.next-prod/server/app/api/scheduled-tasks/route.js.nft.json +1 -1
  209. package/.next-prod/server/app/api/services/config/route.js +1 -1
  210. package/.next-prod/server/app/api/services/config/route.js.nft.json +1 -1
  211. package/.next-prod/server/app/api/services/scripts/route.js +1 -1
  212. package/.next-prod/server/app/api/services/scripts/route.js.nft.json +1 -1
  213. package/.next-prod/server/app/api/session/[sessionId]/fork/route.js +1 -1
  214. package/.next-prod/server/app/api/session/[sessionId]/fork/route.js.nft.json +1 -1
  215. package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -1
  216. package/.next-prod/server/app/api/session/[sessionId]/history/route.js.nft.json +1 -1
  217. package/.next-prod/server/app/api/session-by-path/route.js +1 -1
  218. package/.next-prod/server/app/api/session-by-path/route.js.nft.json +1 -1
  219. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js +1 -1
  220. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js.nft.json +1 -1
  221. package/.next-prod/server/app/api/sessions/projects/route.js +1 -1
  222. package/.next-prod/server/app/api/sessions/projects/route.js.nft.json +1 -1
  223. package/.next-prod/server/app/api/sessions/route.js +1 -1
  224. package/.next-prod/server/app/api/sessions/route.js.nft.json +1 -1
  225. package/.next-prod/server/app/api/settings/route.js +1 -1
  226. package/.next-prod/server/app/api/settings/route.js.nft.json +1 -1
  227. package/.next-prod/server/app/api/skills/[id]/route.js +1 -1
  228. package/.next-prod/server/app/api/skills/[id]/route.js.nft.json +1 -1
  229. package/.next-prod/server/app/api/skills/content/route.js +1 -1
  230. package/.next-prod/server/app/api/skills/content/route.js.nft.json +1 -1
  231. package/.next-prod/server/app/api/skills/route.js +1 -1
  232. package/.next-prod/server/app/api/skills/route.js.nft.json +1 -1
  233. package/.next-prod/server/app/api/terminal/aliases/route.js +1 -1
  234. package/.next-prod/server/app/api/terminal/aliases/route.js.nft.json +1 -1
  235. package/.next-prod/server/app/api/terminal/autocomplete/route.js +1 -1
  236. package/.next-prod/server/app/api/terminal/autocomplete/route.js.nft.json +1 -1
  237. package/.next-prod/server/app/api/terminal/bubble-order/route.js +1 -1
  238. package/.next-prod/server/app/api/terminal/bubble-order/route.js.nft.json +1 -1
  239. package/.next-prod/server/app/api/terminal/env/route.js +1 -1
  240. package/.next-prod/server/app/api/terminal/env/route.js.nft.json +1 -1
  241. package/.next-prod/server/app/api/terminal/history/route.js +1 -1
  242. package/.next-prod/server/app/api/terminal/history/route.js.nft.json +1 -1
  243. package/.next-prod/server/app/api/version/route.js +1 -1
  244. package/.next-prod/server/app/api/version/route.js.nft.json +1 -1
  245. package/.next-prod/server/app/favicon.ico/route.js.nft.json +1 -1
  246. package/.next-prod/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  247. package/.next-prod/server/app/page.js +2 -99
  248. package/.next-prod/server/app/page.js.nft.json +1 -1
  249. package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
  250. package/.next-prod/server/app/project/page.js +2 -30
  251. package/.next-prod/server/app/project/page.js.nft.json +1 -1
  252. package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
  253. package/.next-prod/server/app/review/[id]/page.js +2 -2
  254. package/.next-prod/server/app/review/[id]/page.js.nft.json +1 -1
  255. package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
  256. package/.next-prod/server/app-paths-manifest.json +23 -23
  257. package/.next-prod/server/chunks/240.js +1 -0
  258. package/.next-prod/server/chunks/5466.js +1 -0
  259. package/.next-prod/server/chunks/554.js +101 -0
  260. package/.next-prod/server/chunks/{4272.js → 6007.js} +2 -2
  261. package/.next-prod/server/chunks/7264.js +5 -0
  262. package/.next-prod/server/chunks/8750.js +1 -0
  263. package/.next-prod/server/chunks/{4490.js → 8764.js} +1 -1
  264. package/.next-prod/server/chunks/900.js +1 -0
  265. package/.next-prod/server/chunks/9255.js +1 -0
  266. package/.next-prod/server/chunks/9658.js +59 -0
  267. package/.next-prod/server/chunks/987.js +139 -0
  268. package/.next-prod/server/functions-config-manifest.json +1 -26
  269. package/.next-prod/server/middleware-build-manifest.js +1 -1
  270. package/.next-prod/server/middleware-react-loadable-manifest.js +1 -1
  271. package/.next-prod/server/pages/404.html +2 -2
  272. package/.next-prod/server/pages/500.html +1 -1
  273. package/.next-prod/server/server-reference-manifest.json +1 -1
  274. package/.next-prod/static/chunks/{700.8d53bb1a328c3f97.js → 1959.b9473117faf354bf.js} +1 -1
  275. package/.next-prod/static/chunks/5204-c8293184aa55cdd5.js +23 -0
  276. package/.next-prod/static/chunks/5660-9ffe0abe675caac1.js +29 -0
  277. package/.next-prod/static/chunks/6028-1d6ced1439a3f01f.js +1 -0
  278. package/.next-prod/static/chunks/6345-6b34b0528ff833a1.js +14 -0
  279. package/.next-prod/static/chunks/app/layout-421143dba2c69478.js +1 -0
  280. package/.next-prod/static/chunks/app/page-db32ebfdf1ac9174.js +1 -0
  281. package/.next-prod/static/chunks/app/project/page-db32ebfdf1ac9174.js +1 -0
  282. package/.next-prod/static/chunks/app/review/[id]/page-05cd4cb51babd64c.js +1 -0
  283. package/.next-prod/static/chunks/webpack-bb0c02e3a9602d78.js +1 -0
  284. package/.next-prod/static/css/a7974d62fe853925.css +1 -0
  285. package/.next-prod/trace +12 -12
  286. package/.next-prod/trace-build +1 -1
  287. package/dist/{chunk-5NL2LMKP.mjs → chunk-HIRLDMCH.mjs} +24 -140
  288. package/dist/chunk-RSHKDWJM.mjs +136 -0
  289. package/dist/chunk-VCZEGP64.mjs +984 -0
  290. package/dist/scheduledTasks.mjs +6 -4
  291. package/dist/server-K6XWP7DX.mjs +69 -0
  292. package/dist/wsServer.mjs +60 -482
  293. package/next.config.mjs +21 -0
  294. package/package.json +15 -17
  295. package/server.mjs +1 -1
  296. package/.next-prod/server/chunks/2338.js +0 -1
  297. package/.next-prod/server/chunks/3353.js +0 -1
  298. package/.next-prod/server/chunks/3863.js +0 -1
  299. package/.next-prod/server/chunks/4098.js +0 -1
  300. package/.next-prod/server/chunks/4732.js +0 -1
  301. package/.next-prod/server/chunks/4793.js +0 -1
  302. package/.next-prod/server/chunks/5147.js +0 -1
  303. package/.next-prod/server/chunks/5394.js +0 -1
  304. package/.next-prod/server/chunks/6043.js +0 -4
  305. package/.next-prod/server/chunks/7051.js +0 -1
  306. package/.next-prod/server/chunks/7514.js +0 -31
  307. package/.next-prod/server/chunks/8491.js +0 -5
  308. package/.next-prod/server/chunks/9298.js +0 -139
  309. package/.next-prod/static/chunks/1705-906aa28943dbc391.js +0 -4
  310. package/.next-prod/static/chunks/3530-5b5e2c59811ae478.js +0 -14
  311. package/.next-prod/static/chunks/3579-51f0ad7204c67e22.js +0 -1
  312. package/.next-prod/static/chunks/3643-fe2ac2f1accd0649.js +0 -1
  313. package/.next-prod/static/chunks/3743-1f5d8cfd9d92ad97.js +0 -4
  314. package/.next-prod/static/chunks/4186-2bbbcdf03b3c15f5.js +0 -17
  315. package/.next-prod/static/chunks/9062-8d92cbc176f388a0.js +0 -1
  316. package/.next-prod/static/chunks/9114-0d2717c9c2752d0f.js +0 -1
  317. package/.next-prod/static/chunks/app/layout-e091cf70aaec617b.js +0 -1
  318. package/.next-prod/static/chunks/app/page-c9a30c88afc0a0c5.js +0 -1
  319. package/.next-prod/static/chunks/app/project/page-4881270bf8e49c61.js +0 -29
  320. package/.next-prod/static/chunks/app/review/[id]/page-f8bb4748e9a94a0f.js +0 -1
  321. package/.next-prod/static/chunks/webpack-c6cffb10a569677a.js +0 -1
  322. package/.next-prod/static/css/874f987341759310.css +0 -1
  323. package/dist/JupyterKernelManager-VBKKSRVJ.mjs +0 -269
  324. /package/.next-prod/static/{8uae4HftphIngPubLspsR → VAwjvIwxO_lfKwd6A4ptI}/_buildManifest.js +0 -0
  325. /package/.next-prod/static/{8uae4HftphIngPubLspsR → VAwjvIwxO_lfKwd6A4ptI}/_ssgManifest.js +0 -0
@@ -1,30 +1,2 @@
1
- (()=>{var a={};a.id=6500,a.ids=[6500],a.modules={243:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>p});var e=c(48249),f=c(67484),g=c(84705),h=c(99117),i=c(77937),j=c(45214),k=c(77033),l=c(47033),m=c(23434),n=c(44384),o=a([g]);g=(o.then?(await o)():o)[0];let p=(0,f.forwardRef)(function({messages:a,isLoading:b,cwd:c,sessionId:d,engine:o,apiRetryInfo:p,hasMoreHistory:q,isLoadingMore:r,onLoadMore:s,onFork:t,isActive:u=!0,onContentSearch:v},w){let{t:x}=(0,n.Bd)(),y=(0,f.useRef)(null),z=(0,f.useRef)(null),A=(0,f.useRef)(null),B=(0,f.useRef)(null),[C,D]=(0,f.useState)(null),[E,F]=(0,f.useState)(!0),[G,H]=(0,f.useState)(!1),[I,J]=(0,f.useState)(!1);(0,f.useEffect)(()=>{D(B.current)},[]);let{isSearchVisible:K,searchQuery:L,setSearchQuery:M,matches:N,currentMatchIndex:O,goToNextMatch:P,goToPrevMatch:Q,closeSearch:R,searchInputRef:S,handleSearchKeyDown:T}=(0,h.a)(B),U=(0,k.nH)(),V=(0,f.useRef)(null),W=(0,f.useRef)(()=>{}),{addComment:X,refresh:Y}=(0,l._)({cwd:c||"",filePath:m.Un}),[Z,$]=(0,f.useState)(null),[_,aa]=(0,f.useState)(null),ab=(0,f.useCallback)(a=>{if(Z||_)return;let b=window.getSelection();if(!b||b.isCollapsed||!b.rangeCount){V.current=null,W.current();return}let c=b.toString().trim();if(!c){V.current=null,W.current();return}let d=b.anchorNode instanceof HTMLElement?b.anchorNode:b.anchorNode?.parentElement;if(d?.closest('[data-role="user"]')){V.current=null,W.current();return}V.current={x:a.clientX,y:a.clientY,range:{start:0,end:0},selectedText:c},W.current()},[Z,_]),ac=(0,f.useCallback)(a=>{let b=a.target;!(b.closest(".floating-toolbar")||b.closest('[class*="z-[200]"]'))&&V.current&&(V.current=null,W.current())},[]),ad=(0,f.useCallback)(()=>{let a=V.current;a&&($({x:a.x,y:a.y,text:a.selectedText}),V.current=null,W.current(),window.getSelection()?.removeAllRanges())},[]),ae=(0,f.useCallback)(()=>{let a=V.current;a&&(aa({x:a.x,y:a.y,text:a.selectedText}),V.current=null,W.current(),window.getSelection()?.removeAllRanges())},[]),af=(0,f.useCallback)(()=>{let a=V.current;if(!a||!v)return;let b=a.selectedText.trim();V.current=null,W.current(),window.getSelection()?.removeAllRanges(),b&&v(b)},[v]),ag=(0,f.useCallback)(async a=>{Z&&(await X(0,0,a,Z.text),$(null))},[Z,X]),ah=(0,f.useCallback)(async a=>{if(_&&U&&c)try{let b=(await (0,m.$3)(c)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0}));b.push({filePath:m.Un,startLine:0,endLine:0,codeContent:_.text});let d=(0,m.Gw)(b,a);U.sendMessage(d),await (0,m.RP)(c),Y(),aa(null)}catch(a){console.error("Failed to send to AI:",a)}},[_,U,c,Y]),ai=(0,f.useMemo)(()=>{let b=new Set;return a.filter(a=>!b.has(a.id)&&(b.add(a.id),!0))},[a]),aj=(0,f.useRef)(0),ak=(0,f.useRef)(!1),al=(0,f.useCallback)(()=>{let a=A.current;return!a||a.scrollHeight-a.scrollTop-a.clientHeight<50},[]),am=(0,f.useCallback)(()=>{let a=A.current;return!a||a.scrollTop<50},[]),an=(0,f.useCallback)(()=>{let a=al(),b=am();if(F(a),H(!b),J(!a),b&&q&&!r&&s){let a=A.current;a&&(aj.current=a.scrollHeight,ak.current=!0),s()}},[al,am,q,r,s]),ao=(0,f.useCallback)(()=>{z.current?.scrollIntoView({behavior:"smooth"})},[]),ap=(0,f.useCallback)(()=>{y.current?.scrollIntoView({behavior:"smooth"})},[]),aq=(0,f.useCallback)(a=>{let b=A.current;if(!b)return;let c=b.querySelector(`[data-message-id="${a}"]`);c&&(c.scrollIntoView({behavior:"smooth",block:"center"}),c.classList.add("ring-2","ring-brand","ring-offset-2"),setTimeout(()=>{c.classList.remove("ring-2","ring-brand","ring-offset-2")},2e3))},[]);(0,f.useImperativeHandle)(w,()=>({scrollToMessage:aq}),[aq]);let ar=(0,f.useRef)(0),as=(0,f.useRef)(!0);(0,f.useEffect)(()=>{let b=ar.current,c=a.length;ar.current=c,!as.current&&E&&c>b&&y.current?.scrollIntoView({behavior:"smooth"})},[a,E]),(0,f.useEffect)(()=>{E&&b&&y.current?.scrollIntoView({behavior:"smooth"})},[b,E]),(0,f.useEffect)(()=>{if(ak.current&&!r){let a=A.current;if(a){let b=a.scrollHeight-aj.current;a.scrollTop=b,ak.current=!1}}},[a,r]);let at=(0,f.useRef)(!1);return(0,f.useEffect)(()=>{u&&at.current&&a.length>0&&(at.current=!1,y.current?.scrollIntoView({behavior:"instant"}))},[u,a.length]),(0,f.useEffect)(()=>{as.current&&a.length>0&&(as.current=!1,u?y.current?.scrollIntoView({behavior:"instant"}):at.current=!0)},[a.length,u]),(0,e.jsxs)("div",{ref:B,className:"relative flex-1 min-h-0 overflow-hidden flex flex-col outline-none",tabIndex:-1,onMouseUp:ab,onMouseDown:ac,children:[K&&(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border",children:[(0,e.jsx)("input",{ref:S,type:"text",value:L,onChange:a=>M(a.target.value),onKeyDown:T,placeholder:x("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,e.jsx)("span",{className:"text-xs text-muted-foreground",children:N.length>0?`${O+1}/${N.length}`:x("common.noMatch")}),(0,e.jsx)("button",{onClick:Q,disabled:0===N.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:x("codeViewer.prevShiftEnter"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,e.jsx)("button",{onClick:P,disabled:0===N.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:x("codeViewer.nextEnter"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,e.jsx)("button",{onClick:R,className:"p-1 rounded hover:bg-accent",title:x("codeViewer.closeEsc"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{ref:A,onScroll:an,className:"relative flex-1 min-h-0 overflow-y-auto p-4",children:0!==a.length||b?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{ref:z}),q&&(0,e.jsx)("div",{className:"flex justify-center py-3",children:r?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,e.jsx)("span",{children:x("chat.loadMoreHistory")})]}):(0,e.jsx)("button",{onClick:s,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:x("chat.scrollUpForMore")})}),ai.map(a=>(0,e.jsx)("div",{"data-message-id":a.id,className:"transition-[box-shadow] duration-300",children:(0,e.jsx)(g.s,{message:a,cwd:c,sessionId:d,onFork:t})},a.id)),b&&(0,e.jsx)("div",{className:"flex justify-start mb-4",children:(0,e.jsxs)("div",{className:"bg-accent rounded-2xl rounded-bl-md px-4 py-3 max-w-[90%]",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,e.jsx)("span",{className:"inline-block w-5 h-5 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,e.jsx)("span",{className:"text-sm",children:"claude2"===o?"Claude 2 is thinking...":"codex"===o?"Codex is thinking...":"kimi"===o?"Kimi is thinking...":"ollama"===o?"Ollama is thinking...":"deepseek"===o?"Deepseek is thinking...":x("chat.claudeThinking")})]}),p&&(0,e.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-amber-400 border-t border-border/50 pt-2",children:[(0,e.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,e.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,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{children:["Retrying API call (attempt ",p.attempt,p.maxRetries>0?`/${p.maxRetries}`:"",p.delayMs>0?`, delay ${(p.delayMs/1e3).toFixed(1)}s`:"",")"]}),(p.errorStatus||p.error)&&(0,e.jsxs)("div",{className:"text-muted-foreground/80 break-words",children:[p.errorStatus?`${p.errorStatus}`:"",p.errorStatus&&p.error?" \xb7 ":"",p.error||""]})]})]})]})}),(0,e.jsx)("div",{ref:y})]}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-slate-9",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"text-4xl mb-4",children:"\uD83D\uDCAC"}),(0,e.jsx)("div",{children:x("chat.startConversation")})]})})}),G&&a.length>0&&(0,e.jsx)("button",{onClick:ao,className:"absolute top-2 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-md rounded-full transition-all hover:shadow-lg active:scale-95",title:x("chat.jumpToStart"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),I&&a.length>0&&(0,e.jsx)("button",{onClick:ap,className:"absolute bottom-2 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-md rounded-full transition-all hover:shadow-lg active:scale-95",title:x("chat.jumpToLatest"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),C&&(0,e.jsx)(i.f,{floatingToolbarRef:V,bumpRef:W,container:C,onAddComment:ad,onSendToAI:ae,onSearch:v?af:void 0,isChatLoading:U?.isLoading}),Z&&C&&(0,e.jsx)(j.t,{x:Z.x,y:Z.y,range:{start:0,end:0},codeContent:Z.text,container:C,onSubmit:ag,onClose:()=>$(null)}),_&&C&&(0,e.jsx)(j.G,{x:_.x,y:_.y,range:{start:0,end:0},codeContent:_.text,container:C,onSubmit:ah,onClose:()=>aa(null),isChatLoading:U?.isLoading})]})});d()}catch(a){d(a)}})},261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1906:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{D:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(46674),i=c(5811),j=a([i]);function k({references:a,loading:b,onSelect:c,onClose:d}){let{t:i}=(0,g.Bd)(),j=function(){let[a,b]=(0,f.useState)(new Map),[c,d]=(0,f.useState)(!1);return(0,f.useRef)(0),a}(),l=[],m=new Map;for(let b=0;b<a.length;b++){let c=a[b],d=m.get(c.file);void 0===d&&(d=l.length,m.set(c.file,d),l.push({file:c.file,items:[]})),l[d].items.push({ref:c,idx:b})}return(0,e.jsxs)("div",{className:"border-t border-border bg-secondary flex flex-col",style:{height:"300px"},children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[i("references.title")," ",!b&&`(${a.length})`]}),(0,e.jsx)("button",{onClick:d,className:"p-0.5 rounded hover:bg-accent text-muted-foreground",children:(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("references.searching")}):0===a.length?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("references.notFound")}):l.map(({file:a,items:b})=>(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card/30 sticky top-0",children:a}),b.map(({ref:a,idx:b})=>(0,e.jsxs)("button",{onClick:()=>c(a),className:"w-full text-left px-3 py-0.5 hover:bg-accent/50 flex items-baseline gap-2 group",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:a.line}),j.has(b)?(0,e.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:j.get(b)}}):(0,e.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:a.lineText||""})]},`${a.line}-${a.column}-${b}`))]},a))})]})}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},2531:(a,b,c)=>{"use strict";c.d(b,{V:()=>h});var d=c(67484);let e=new Map,f=new Map;async function g(a,b,c=!1){let d=`${a}::${b}`;if(c)!function(a){if(!a){e.clear(),f.clear();return}let b=`${a}::`;for(let a of e.keys())a.startsWith(b)&&e.delete(a);for(let a of f.keys())a.startsWith(b)&&f.delete(a)}(a);else{let a=e.get(d);if(a)return a;let b=f.get(d);if(b)return b}let h=(async()=>{let f=new URLSearchParams({cwd:a,path:b});c&&f.set("refresh","1");let g=await fetch(`/api/projectGraph/file-functions?${f}`);if(404===g.status)return"not-found";if(!g.ok)throw Error((await g.json().catch(()=>({error:`HTTP ${g.status}`}))).error||`HTTP ${g.status}`);let h=await g.json();return e.set(d,h),h})().finally(()=>f.delete(d));return f.set(d,h),h}function h(a,b){let[c,e]=(0,d.useState)({state:"idle"}),f=(0,d.useRef)(!0),h=(0,d.useCallback)((a,b,c)=>{e({state:"loading"}),g(a,b,c).then(a=>{f.current&&("not-found"===a?e({state:"notFound"}):e({state:"ready",data:a}))}).catch(a=>{f.current&&e({state:"error",message:a.message})})},[]);return{state:c,refresh:(0,d.useCallback)(()=>{a&&b&&h(a,b,!0)},[a,b,h])}}},2868:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{n:()=>m});var e=c(48249),f=c(67484),g=c(44384),h=c(86402),i=c(95836),j=c(56929),k=c(36645),l=a([h]);function m({isOpen:a,onClose:b,commit:c,cwd:d,embedded:l=!1,initialFilePath:n,onContentSearch:o}){let{t:p}=(0,g.Bd)(),[q,r]=(0,f.useState)([]),[s,t]=(0,f.useState)([]),[u,v]=(0,f.useState)(new Set),[w,x]=(0,f.useState)(null),[y,z]=(0,f.useState)(null),[A,B]=(0,f.useState)(!1),[C,D]=(0,f.useState)(!1),[E,F]=(0,f.useState)(null),G=(0,f.useRef)(null),H=(0,k.o)(G),I=(0,f.useCallback)(a=>{c&&(x(a),D(!0),fetch(`/api/git/commit-diff?cwd=${encodeURIComponent(d)}&hash=${c.hash}&file=${encodeURIComponent(a.path)}`).then(a=>a.json()).then(a=>z(a)).catch(console.error).finally(()=>D(!1)))},[d,c]),J=(0,f.useCallback)(a=>{v(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),K=(0,f.useMemo)(()=>{if(!c)return"";if(c.date){var a;let b,d,e,f,g,h,i;return a=c.date,b=new Date(a),d=new Date,e=b.getFullYear()===d.getFullYear(),f=String(b.getMonth()+1).padStart(2,"0"),g=String(b.getDate()).padStart(2,"0"),h=String(b.getHours()).padStart(2,"0"),i=String(b.getMinutes()).padStart(2,"0"),e?`${f}-${g} ${h}:${i}`:`${b.getFullYear()}-${f}-${g} ${h}:${i}`}return c.time?new Date(1e3*c.time).toLocaleString():""},[c]);if(!a||!c)return null;let L=(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"px-4 py-3 border-b border-border bg-secondary flex-shrink-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground mb-2",children:c.subject}),c.body&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground whitespace-pre-wrap mb-3 max-h-32 overflow-y-auto border-l-2 border-border pl-3",children:c.body}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-4 text-xs text-muted-foreground",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-slate-9",children:p("commitDetail.hash")}),(0,e.jsx)("span",{className:"font-mono bg-accent px-1.5 py-0.5 rounded",children:c.hash})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-slate-9",children:p("commitDetail.author")}),(0,e.jsx)("span",{children:c.author}),(0,e.jsxs)("span",{className:"text-slate-9",children:["<",c.authorEmail,">"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-slate-9",children:p("commitDetail.date")}),(0,e.jsx)("span",{children:K}),c.relativeDate&&(0,e.jsxs)("span",{className:"text-slate-9",children:["(",c.relativeDate,")"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-slate-9",children:p("commitDetail.files")}),(0,e.jsx)("span",{children:p("commitDetail.nChanges",{count:q.length})})]})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:A?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:p("commitDetail.loadingFiles")}):(0,e.jsx)(i.VO,{files:s,selectedPath:w?.path||null,expandedPaths:u,onSelect:a=>a.file&&I(a.file),onToggle:J,cwd:d,showChanges:!0,emptyMessage:p("commitDetail.noFileChanges"),className:"py-1"})}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:C?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:p("commitDetail.loadingDiff")}):y?(0,e.jsx)(h.xZ,{oldContent:y.oldContent,newContent:y.newContent,filePath:y.filePath,isNew:y.isNew,isDeleted:y.isDeleted,cwd:d,enableComments:!0,onPreview:!y.isDeleted&&y.filePath.endsWith(".json")?()=>F({content:y.newContent,filePath:y.filePath}):void 0,previewLabel:p("common.readable"),onContentSearch:o}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:p("commitDetail.selectFileToView")})})]})]}),M=E&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>F(null),children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90%] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:E.filePath}),(0,e.jsx)("button",{onClick:()=>F(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)(k._,{search:H}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,e.jsx)("pre",{ref:G,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,j.xb)(E.content)})})]})});return l?(0,e.jsxs)("div",{className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsx)("button",{onClick:b,className:"absolute top-2 right-2 z-10 p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",title:p("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),L,M]}):(0,e.jsx)("div",{className:"fixed inset-0 z-[60] bg-black/50",onClick:b,children:(0,e.jsxs)("div",{className:"bg-card w-full h-full flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:p("commitDetail.title")}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),L,M]})})}h=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4219:(a,b,c)=>{"use strict";c.d(b,{o:()=>g});var d=c(48249);c(67484);let e={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"},f={"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 g({name:a,className:b="",size:c=16}){let h,i=f[h=a.toLowerCase()]?f[h]:e[a.split(".").pop()?.toLowerCase()||""]||e.default,j=a.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.jsx)("path",{d:"M7 10h10M12 10v8",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):["js","jsx","mjs","cjs"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.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"===j||"tsx"===j&&a.includes("component")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(60 12 12)"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(120 12 12)"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"2",fill:"#61dafb"})]}):"json"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.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,d.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,d.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:i})]}):["md","mdx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.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(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.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,d.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,d.jsx)("circle",{cx:"9",cy:"7",r:"1",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"17",r:"1",fill:"white"})]}):"go"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6",fill:i}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"0.7",fill:"#333"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"0.7",fill:"#333"})]}):"rs"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:i,strokeWidth:"2",fill:"none"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:i}),(0,d.jsx)("path",{d:"M12 3v3M12 18v3M3 12h3M18 12h3",stroke:i,strokeWidth:"2",strokeLinecap:"round"})]}):["png","jpg","jpeg","gif","webp","ico","bmp"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"9",r:"2",fill:i}),(0,d.jsx)("path",{d:"M3 16l5-5 3 3 4-4 6 6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"svg"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 12 Q12 6 17 12 Q12 18 7 12",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"html"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.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(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.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(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 8l3 4v5M17 8l-3 4v5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["sh","bash","zsh","fish"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",fill:"#1e1e1e",stroke:"#555",strokeWidth:"1"}),(0,d.jsx)("path",{d:"M6 9l3 3-3 3M12 15h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"gitignore"===j||".gitignore"===a.toLowerCase()?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:i}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"white"}),(0,d.jsx)("path",{d:"M12 6v3M12 15v3M6 12h3M15 12h3",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):"dockerfile"===j||"dockerfile"===a.toLowerCase()||a.toLowerCase().startsWith("dockerfile")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M3 12h3v3H3zM7 12h3v3H7zM11 12h3v3h-3zM7 8h3v3H7zM11 8h3v3h-3zM11 4h3v3h-3zM15 12h3v3h-3z",fill:i}),(0,d.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"===j||a.startsWith(".env")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:i}),(0,d.jsx)("path",{d:"M12 8h6M8 12h8M8 16h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round"})]}):"sql"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"7",rx:"8",ry:"3",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"vue"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M2 4h4l6 10 6-10h4L12 22 2 4z",fill:i}),(0,d.jsx)("path",{d:"M6 4h4l2 4 2-4h4l-6 10L6 4z",fill:"#35495e"})]}):(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M6 3h8l5 5v13H6V3z",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M14 3v5h5",stroke:i,strokeWidth:"1.5",fill:"none"})]})}},4667:(a,b,c)=>{"use strict";c.d(b,{Q:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({isOpen:a,onClose:b,cwd:c,onSelectSession:h}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)([]),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(""),r=(0,e.useRef)(null);(0,e.useCallback)(async()=>{if(c){m(!0),o(null);try{let a=c.replace(/\//g,"-"),b=await fetch(`/api/sessions/projects/${encodeURIComponent(a)}`);if(!b.ok)throw Error("Failed to load sessions");let d=await b.json();k(d)}catch(a){o(a instanceof Error?a.message:"Unknown error")}finally{m(!1)}}},[c]);let s=j.filter(a=>{if(!p)return!0;let b=p.toLowerCase();return a.title.toLowerCase().includes(b)||a.firstMessages.some(a=>a.toLowerCase().includes(b))||a.lastMessages.some(a=>a.toLowerCase().includes(b))});return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:b}),(0,d.jsxs)("div",{className:"relative w-full max-w-6xl h-[90vh] mx-4 bg-card rounded-lg shadow-xl flex flex-col overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:i("sessions.sessionList")}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:c,children:c})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsx)("input",{ref:r,type:"text",placeholder:i("sessions.searchSessions"),value:p,onChange:a=>q(a.target.value),className:"px-2 py-1 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[l&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:i("sessions.loadingSessions")})]})}),n&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:n})}),!l&&!n&&0===s.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:i(p?"sessions.noMatchingSessions":"sessions.noSessionsYet")})}),!l&&!n&&s.length>0&&(0,d.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:s.map(a=>(0,d.jsxs)("div",{onClick:()=>{let d;return d=(a.path.split("/").pop()||"").replace(".jsonl",""),void(h?(h(d,a.title),b()):window.parent.postMessage({type:"OPEN_PROJECT",cwd:c,sessionId:d},"*"))},className:"p-3 bg-secondary rounded border border-border hover:border-brand hover:shadow-md cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[a.engine&&"claude"!==a.engine&&(0,d.jsx)("span",{className:`shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded ${"claude2"===a.engine?"bg-orange-500/15 text-orange-11":"ollama"===a.engine?"bg-blue-500/15 text-blue-11":"codex"===a.engine?"bg-green-500/15 text-green-11":"kimi"===a.engine?"bg-purple-500/15 text-purple-11":"bg-muted text-muted-foreground"}`,children:a.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate",title:a.title,children:a.title})]}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(a.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[a.firstMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`first-${b}`)),a.lastMessages.length>0&&(0,d.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),a.lastMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`last-${b}`))]})]},a.path))})]})]})]}):null}},5098:(a,b,c)=>{"use strict";c.d(b,{r:()=>h});var d=c(48249),e=c(67484),f=c(31172);let g=[{value:"deepseek-v4-flash",label:"deepseek-v4-flash"},{value:"deepseek-v4-pro",label:"deepseek-v4-pro"}];function h({currentModel:a,onModelChange:b}){let[c,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)(""),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(null),v=(0,e.useRef)(null),w=(0,e.useRef)(null),x=(0,e.useRef)(null),[y,z]=(0,e.useState)({top:0,left:0}),A=(0,f.F2)(),B=(0,e.useCallback)(async()=>{q(!0),u(null);try{let c=await fetch("/api/settings");if(!c.ok)return void u("Failed to load settings");let d=await c.json(),e=d?.engines?.deepseek?.apiKey||"";k(e),m(""),o(!1);let f=d?.engines?.deepseek?.model;!a&&f&&g.some(a=>a.value===f)&&b(f)}catch{u("Connection error")}finally{q(!1)}},[a,b]),C=(0,e.useCallback)(async a=>{let b=(await fetch("/api/settings").then(a=>a.ok?a.json():{}).catch(()=>({}))).engines||{},c={...b,deepseek:{...b.deepseek||{},...a}};if(!(await fetch("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({engines:c})})).ok)throw Error("Failed to save settings")},[]),D=async()=>{let a=l.trim();if(a){s(!0),u(null);try{await C({apiKey:a}),k(a),m(""),o(!1)}catch(a){u(a instanceof Error?a.message:"Save failed")}finally{s(!1)}}},E=async()=>{s(!0),u(null);try{await C({apiKey:""}),k(""),m(""),o(!1)}catch(a){u(a instanceof Error?a.message:"Clear failed")}finally{s(!1)}},F=async a=>{b(a);try{await C({model:a})}catch{}},G=!!j,H=G?a||"deepseek-v4-flash":"Set API key",I=G?"text-sky-400":"text-amber-400",J=c?(0,d.jsx)(f.ZL,{children:(0,d.jsx)("div",{ref:w,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lg py-2 min-w-[280px]",style:{top:y.top,left:y.left},children:p?(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Loading..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"API Key"}),G&&!n?(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"flex-1 min-w-0 truncate text-xs px-2 py-1 rounded bg-secondary text-foreground font-mono",children:j?j.length<=8?j.replace(/./g,"•"):`${j.slice(0,3)}${"•".repeat(Math.max(4,j.length-7))}${j.slice(-4)}`:""}),(0,d.jsx)("button",{onClick:()=>{o(!0),m(""),setTimeout(()=>x.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",disabled:r,children:"Edit"}),(0,d.jsx)("button",{onClick:E,className:"text-[11px] px-2 py-1 rounded text-red-400 hover:bg-red-500/10 transition-colors",disabled:r,children:"Clear"})]}):(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{ref:x,type:"password",value:l,onChange:a=>m(a.target.value),onKeyDown:a=>{"Enter"===a.key&&D()},placeholder:"sk-...",className:"flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:border-sky-500 focus:outline-none font-mono",autoFocus:!0}),(0,d.jsx)("button",{onClick:D,disabled:r||!l.trim(),className:"text-[11px] px-2 py-1 rounded bg-sky-500/20 hover:bg-sky-500/30 text-sky-300 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:r?"Saving...":"Save"}),G&&(0,d.jsx)("button",{onClick:()=>{o(!1),m("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),t&&(0,d.jsx)("div",{className:"mt-1 text-[11px] text-red-400",children:t})]}),(0,d.jsx)("div",{className:"my-1 border-t border-border"}),(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Model"}),(0,d.jsx)("div",{className:"flex flex-col gap-0.5",children:g.map(b=>{let c=(a||"deepseek-v4-flash")===b.value;return(0,d.jsxs)("button",{onClick:()=>F(b.value),className:`flex items-center gap-2 px-2 py-1 text-xs rounded transition-colors ${c?"bg-sky-500/15 text-sky-300":"text-foreground hover:bg-accent"}`,children:[(0,d.jsx)("span",{className:`w-3 h-3 rounded-full border-2 flex items-center justify-center ${c?"border-sky-400":"border-muted-foreground"}`,children:c&&(0,d.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-sky-400"})}),(0,d.jsx)("span",{children:b.label})]},b.value)})})]})]})})}):null;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("button",{ref:v,onClick:()=>{if(!c){if(v.current){let a=v.current.getBoundingClientRect(),b=A?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;z({top:a.bottom+4-d,left:a.left-c})}B()}i(a=>!a)},className:"flex items-center gap-1 px-2 py-0.5 text-[11px] rounded bg-sky-500/15 hover:bg-sky-500/25 transition-colors",title:"Configure Deepseek",children:[(0,d.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-sky-500 flex-shrink-0"}),(0,d.jsx)("span",{className:`truncate max-w-[160px] ${I}`,children:H}),(0,d.jsx)("svg",{className:"w-3 h-3 flex-shrink-0 text-sky-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),J]})}},6088:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});let d=new Set(["function","class","method"]);function e(a){return d.has(a.kind)}},6154:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484);function f(a,b){for(let c=0;c<a.blocks.length;c++){let d=a.blocks[c];if(b>=d.startLine&&b<=d.endLine)return a.prefix[c]+(b-d.startLine)}return null}function g({addedLines:a,blockRanges:b,viewportRange:c,onJumpToLine:h}){let i,j=(0,e.useRef)(null),k=(0,e.useMemo)(()=>(function(a){let b=[...a].sort((a,b)=>a.startLine-b.startLine),c=[0];for(let a of b){let b=Math.max(0,a.endLine-a.startLine+1);c.push(c[c.length-1]+b)}return{blocks:b,prefix:c,total:c[c.length-1]}})(b),[b]),l=(0,e.useMemo)(()=>{if(k.total<=0||0===a.size)return[];let b=[];for(let c of a){let a=k.blocks.find(a=>c>=a.startLine&&c<=a.endLine);a&&b.push({line:c,qname:a.qname})}b.sort((a,b)=>a.line-b.line);let c=[],d=null;for(let a of b)d&&a.line===d.end+1&&a.qname===d.qname?d.end=a.line:(d&&c.push(d),d={start:a.line,end:a.line,qname:a.qname});return d&&c.push(d),c},[a,k]);if(k.total<=0)return null;let m=(a,b)=>{let c=f(k,a),d=f(k,b);return null===c||null===d?null:{top:c/k.total*100,heightPct:(d-c+1)/k.total*100}};return(0,d.jsxs)("div",{ref:j,onClick:a=>{let b=j.current;if(!b)return;let c=b.getBoundingClientRect();if(c.height<=0)return;let d=function(a,b){if(a.total<=0)return null;let c=Math.max(0,Math.min(a.total-1,b));for(let b=0;b<a.blocks.length;b++){let d=a.prefix[b],e=a.prefix[b+1];if(c>=d&&c<e){let e=a.blocks[b];return{qname:e.qname,line:e.startLine+Math.round(c-d)}}}return null}(k,(a.clientY-c.top)/c.height*k.total);if(!d)return;let e=d.line,g=l.find(a=>a.qname===d.qname&&e>=a.start&&e<=a.end);if(g)return void h(g.qname,e);if(l.length>0){let a=Math.max(2,Math.round(.05*k.total)),b=f(k,e);if(null!==b){let c=null,d=1/0;for(let a of l){let e=f(k,a.start),g=f(k,a.end);if(null===e||null===g)continue;let h=b<e?e-b:b>g?b-g:0;h<d&&(c=a,d=h)}if(c&&d<=a){let a=e<c.start?c.start:e>c.end?c.end:e;h(c.qname,a);return}}}let i=k.blocks.find(a=>a.qname===d.qname);i&&h(i.qname,i.startLine)},className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",title:"Diff minimap — click to jump",children:[l.map(a=>{let b=m(a.start,a.end);return b?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-green-9 pointer-events-none",style:{top:`${b.top}%`,height:`${b.heightPct}%`,minHeight:"2px"}},`run:${a.qname}:${a.start}-${a.end}`):null}),c&&c.end>=c.start&&((i=m(c.start,c.end))?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border pointer-events-none",style:{top:`${i.top}%`,height:`${Math.max(1.2,i.heightPct)}%`}}):null)]})}},6440:(a,b,c)=>{"use strict";c.d(b,{F:()=>e});var d=c(67484);function e(){let[a,b]=(0,d.useState)(()=>"u"<typeof document||"visible"===document.visibilityState);return a}},7084:(a,b,c)=>{"use strict";c.d(b,{y:()=>m});var d=c(48249),e=c(80600),f=c(47408);let g=(0,f.A)("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]),h=(0,f.A)("heading-1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]),i=(0,f.A)("square-function",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3",key:"m1af9g"}],["path",{d:"M9 11.2h5.7",key:"3zgcl2"}]]),j=(0,f.A)("box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]),k=(0,f.A)("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]),l=(0,f.A)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);function m({kind:a,qname:b,className:c}){let f=`${(function(a,b){if("__file__"===b||"__preamble__"===b||b&&b.startsWith("__heading_"))return"text-muted-foreground/60";switch(a){case"function":case"method":return"text-violet-11";case"class":return"text-amber-11";case"interface":return"text-blue-11";default:return"text-muted-foreground/60"}})(a,b)} ${c??""}`.trim();if("__file__"===b)return(0,d.jsx)(e.A,{className:f});if("__preamble__"===b)return(0,d.jsx)(g,{className:f});if(b&&b.startsWith("__heading_"))return(0,d.jsx)(h,{className:f});switch(a){case"function":case"method":return(0,d.jsx)(i,{className:f});case"class":return(0,d.jsx)(j,{className:f});case"interface":return(0,d.jsx)(k,{className:f});default:return(0,d.jsx)(l,{className:f})}}},7418:(a,b,c)=>{"use strict";c.d(b,{r:()=>e});var d=c(67484);function e({enabled:a,container:b,bodyScope:c}){let[f,g]=(0,d.useState)(null);return{toolbar:f,clearToolbar:()=>g(null)}}},8472:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>h,dynamic:()=>f,generateMetadata:()=>g});var d=c(5735),e=c(38476);let f="force-dynamic";async function g({searchParams:a}){let b=(await a).cwd,c=b?.split("/").filter(Boolean).pop();return{title:c?`Cockpit - ${c}`:"Cockpit"}}async function h({searchParams:a}){let{cwd:b,sessionId:c}=await a;return(0,d.jsx)(e.TabManager,{initialCwd:b,initialSessionId:c})}},10164:(a,b,c)=>{"use strict";c.d(b,{M:()=>u});var d=c(48249),e=c(67484),f=c(44384),g=c(74429),h=c(26068),i=c(77937),j=c(45214),k=c(68502),l=c(47033),m=c(77033),n=c(23434),o=c(49280),p=c(90500),q=c(30068),r=c(81749);function s({content:a,sourceFile:b}){let c,g,h,i,j,{t:k}=(0,f.Bd)(),[l,m]=(0,e.useState)(null),[n,o]=(0,e.useState)(!0),[p,q]=(0,e.useState)(!1),t=l?.active===!0,u=(0,e.useCallback)(async()=>{q(!0);try{let c=b.split("/").pop()||b,d=await fetch("/api/review",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:c,content:a,sourceFile:b})});if(!d.ok)throw Error("Failed");let e=(await d.json()).review;m({id:e.id,active:!0,updatedAt:e.updatedAt||e.createdAt});try{let a=await fetch("/api/review/share-info"),b=await a.json(),c=b.shareBase?`${b.shareBase}/review/${e.id}`:`${window.location.origin}/review/${e.id}`;await navigator.clipboard.writeText(c)}catch{}(0,r.oR)(e.existing?k("toast.reviewUpdated"):k("toast.reviewCreated"),"success")}catch{(0,r.oR)(k("toast.reviewCreateFailed"),"error")}finally{q(!1)}},[a,b]),v=(0,e.useCallback)(async()=>{if(l){q(!0);try{if(!(await fetch(`/api/review/${l.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({active:!1})})).ok)throw Error("Failed");m(a=>a?{...a,active:!1}:null),(0,r.oR)(k("toast.sharingClosed"),"success")}catch{(0,r.oR)(k("toast.sharingCloseFailed"),"error")}finally{q(!1)}}},[l]),w=(0,e.useCallback)(()=>{p||(t?v():u())},[p,t,u,v]),x=(0,e.useCallback)(()=>{l&&window.open(`${window.location.origin}/review/${l.id}`,"_blank")},[l]);return n?null:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:w,disabled:p,className:`relative inline-flex h-4 w-7 items-center rounded-full transition-colors ${p?"opacity-50 cursor-wait":"cursor-pointer"} ${t?"bg-green-500":"bg-muted-foreground/30"}`,title:t?k("review.closeSharing"):k("review.enableSharing"),children:(0,d.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white transition-transform ${t?"translate-x-3.5":"translate-x-0.5"}`})}),(0,d.jsx)("span",{className:`text-[11px] ${t?"text-green-600 dark:text-green-400":"text-muted-foreground"}`,children:t?k("review.sharing"):k("review.notShared")}),l&&l.updatedAt&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(g=String((c=new Date(l.updatedAt)).getMonth()+1).padStart(2,"0"),h=String(c.getDate()).padStart(2,"0"),i=String(c.getHours()).padStart(2,"0"),j=String(c.getMinutes()).padStart(2,"0"),`${g}-${h} ${i}:${j}`)}),(0,d.jsx)("button",{onClick:x,className:"text-[11px] text-brand hover:underline",children:k("review.view")})]})]})}let t=[p.W];function u({content:a,filePath:b,cwd:c,onClose:p,sourceFile:r}){let v=r||(c&&b.startsWith(c)?b.slice(c.endsWith("/")?c.length:c.length+1):b),{t:w}=(0,f.Bd)(),x=(0,e.useRef)(null),y=(0,e.useRef)(null),z=(0,e.useRef)(()=>{}),A=(0,h.iN)(),B=(0,m.nH)(),{comments:C,addComment:D,updateComment:E,deleteComment:F,refresh:G}=(0,l._)({cwd:c,filePath:b}),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)(null),[L,M]=(0,e.useState)(null),[N,O]=(0,e.useState)(null),P=(0,e.useMemo)(()=>a.split("\n"),[a]),Q=(0,e.useCallback)(()=>{let a=y.current;a&&(K({x:a.x,y:a.y,range:a.range,codeContent:a.selectedText}),y.current=null,z.current())},[]),R=(0,e.useCallback)(()=>{let a=y.current;a&&(M({x:a.x,y:a.y,range:a.range,codeContent:a.selectedText}),y.current=null,z.current())},[]),S=(0,e.useCallback)(async a=>{J&&(await D(J.range.start,J.range.end,a),K(null))},[J,D]),T=(0,e.useCallback)(async a=>{if(L&&B)try{let d=await (0,n.$3)(c),e=[];for(let a of d)e.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});let f=Math.max(0,L.range.start-1),g=Math.min(P.length,L.range.end),h=P.slice(f,g).join("\n");e.push({filePath:b,startLine:L.range.start,endLine:L.range.end,codeContent:h});let i=(0,n.Gw)(e,a);B.sendMessage(i),await (0,n.RP)(c),G(),M(null)}catch(a){console.error("Failed to send to AI:",a)}},[L,B,b,c,P,G]);(0,e.useMemo)(()=>{if(0===C.length)return[];let a=new Map;for(let b of C){let c=`${b.startLine}-${b.endLine}`;a.has(c)||a.set(c,[]),a.get(c).push(b)}return Array.from(a.entries()).map(([a,b])=>({key:a,startLine:b[0].startLine,endLine:b[0].endLine,comments:b}))},[C]);let[U,V]=(0,e.useState)([]);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between flex-shrink-0",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:b}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)(s,{content:a,sourceFile:v}),(0,d.jsx)("button",{onClick:p,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:w("common.close"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,d.jsx)(q.l,{content:a,containerRef:x}),(0,d.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:x,children:[(0,d.jsx)("div",{className:"p-6",children:(0,d.jsx)(o.T,{content:a,rehypePlugins:t})}),U.map(({key:a,top:b,comments:c})=>(0,d.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:b},onClick:a=>{a.stopPropagation(),O({comment:c[0],x:a.clientX,y:a.clientY})},children:(0,d.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-sm hover:bg-amber-500 transition-colors",children:c.length})},a))]})]}),H&&A&&(0,g.createPortal)((0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i.f,{floatingToolbarRef:y,bumpRef:z,container:A,onAddComment:Q,onSendToAI:R,isChatLoading:B?.isLoading}),J&&(0,d.jsx)(j.t,{x:J.x,y:J.y,range:J.range,codeContent:J.codeContent,container:A,onSubmit:S,onClose:()=>K(null)}),L&&(0,d.jsx)(j.G,{x:L.x,y:L.y,range:L.range,filePath:b,codeContent:L.codeContent,container:A,onSubmit:T,onClose:()=>M(null),isChatLoading:B?.isLoading}),N&&(0,d.jsx)(k.t,{x:N.x,y:N.y,comment:N.comment,container:A,onClose:()=>O(null),onUpdateComment:E,onDeleteComment:F})]}),A)]})}},10316:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]])},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12629:a=>{"use strict";a.exports=import("web-tree-sitter")},15273:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},17891:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/get-segment-param")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},19794:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},21735:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]])},23290:(a,b,c)=>{"use strict";c.d(b,{I:()=>f});var d=c(48249),e=c(67484);function f(a){let{refreshKey:b,className:c="h-full flex items-center justify-center p-4 bg-secondary",imgClassName:f="max-w-full max-h-full object-contain",alt:g}=a,h="absPath"in a&&"string"==typeof a.absPath,i=h?void 0:a.cwd,j=h?void 0:a.path,k=h?a.absPath:void 0,[l,m]=(0,e.useState)({kind:"loading"});if((0,e.useRef)(0),"loading"===l.kind)return(0,d.jsx)("div",{className:c,children:(0,d.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})});if("missing"===l.kind)return(0,d.jsx)("div",{className:c,children:(0,d.jsx)("div",{className:"text-sm text-muted-foreground",children:"File not found"})});if("too-large"===l.kind)return(0,d.jsx)("div",{className:c,children:(0,d.jsxs)("div",{className:"text-sm text-muted-foreground",children:["Image too large to preview (",Math.round(l.size/1024/1024)," MB)"]})});if("error"===l.kind)return(0,d.jsx)("div",{className:c,children:(0,d.jsx)("div",{className:"text-sm text-red-11",children:l.message})});let n=h?`/api/file?path=${encodeURIComponent(k)}&raw=true`:`/api/files/read?cwd=${encodeURIComponent(i)}&path=${encodeURIComponent(j)}&v=${encodeURIComponent(l.etag)}`;return(0,d.jsx)("div",{className:c,children:(0,d.jsx)("img",{src:n,alt:g??(j||k),className:f})})}},24266:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{r:()=>v});var e=c(48249),f=c(67484),g=c(243),h=c(83634),i=c(64874),j=c(4667),k=c(60306),l=c(42911),m=c(99374),n=c(77033),o=c(61969),p=c(56111),q=c(99543),r=c(44384),s=c(63161),t=c(5098),u=a([g]);function v({tabId:a,initialCwd:b,initialSessionId:c,engine:d,ollamaModel:u,onOllamaModelChange:w,deepseekModel:x,onDeepseekModelChange:y,hideHeader:z,hideSidebar:A,isActive:B=!0,onLoadingChange:C,onSessionIdChange:D,onTitleChange:E,onShowGitStatus:F,onOpenNote:G,onCreateScheduledTask:H,onOpenSession:I,onContentSearch:J}){let{t:K}=(0,r.Bd)();(0,n.nH)();let[L,M]=(0,f.useState)([]),[N,O]=(0,f.useState)(null),[P,Q]=(0,f.useState)(!1),[R,S]=(0,f.useState)(!1),[T,U]=(0,f.useState)(!1),[V,W]=(0,f.useState)(!1),[X,Y]=(0,f.useState)(!1),[Z,$]=(0,f.useState)(!1),[_,aa]=(0,f.useState)(null),ab=(0,f.useRef)(null);(0,f.useRef)(null);let ac=(0,f.useCallback)(async a=>{if(b)try{let c=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,sessionId:a})});if(c.ok){let a=await c.json();a.title&&E?.(a.title)}}catch(a){console.error("Failed to fetch session title:",a)}},[b,E]),{isLoading:ad,tokenUsage:ae,rateLimitInfo:af,apiRetryInfo:ag,handleSend:ah,handleStop:ai}=(0,p.e)(L,M,{sessionId:N,cwd:b,engine:d,ollamaModel:u,deepseekModel:x,onSessionId:O,onFetchTitle:ac}),aj=(0,f.useCallback)(async(a,c)=>{let d=a.split("\n")[0];if(d.startsWith("!")&&d.length>1){let e=d.slice(1).trim();if(!e)return void ah(a,c);let f=a.split("\n").slice(1).join("\n").trim();try{let a=await fetch("/api/bash",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e,cwd:b})}),d=await a.json(),g=[d.stdout,d.stderr].filter(Boolean).join("\n")||"(no output)",h=d.exitCode?` (exit code: ${d.exitCode})`:"",i=K("chat.executedCommand",{command:e,exitInfo:h,output:g});f&&(i+=`
2
-
3
- ${f}`),ah(i,c)}catch(a){ah(K("chat.executedCommandFailed",{command:e,error:a}),c)}return}ah(a,c)},[ah,b,K]),{isLoadingHistory:ak,isLoadingMore:al,hasMoreHistory:am,loadMoreHistory:an,loadHistoryByCwdAndSessionId:ao}=(0,q.m)(L,M,N,{cwd:b,initialSessionId:c,onSessionId:O,onTitleChange:E,onTokenUsage:aa});(0,f.useRef)(B);let ap=ae||_;(0,f.useRef)(!1);let aq=(0,f.useCallback)(async a=>{if(b&&N)try{let c=await fetch(`/api/session/${N}/fork`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,fromMessageUuid:a})});if(c.ok){let a=await c.json();I?I(a.newSessionId,"Fork"):window.parent.postMessage({type:"OPEN_PROJECT",cwd:b,sessionId:a.newSessionId},"*")}else console.error("Fork failed:",await c.text())}catch(a){console.error("Fork error:",a)}},[b,N,I]),ar=(0,f.useCallback)(()=>{Y(!0)},[]),as=(0,f.useCallback)(()=>{$(!0)},[]),at=(0,f.useMemo)(()=>{if(H&&b&&a&&N)return c=>{H({...c,cwd:b,tabId:a,sessionId:N})}},[H,b,a,N]);return(0,e.jsxs)("div",{className:`flex ${z&&A?"h-full":"h-screen"} bg-card`,children:[(0,e.jsxs)("div",{id:"chat-screen",className:"flex-1 flex flex-col min-w-0 relative",onMouseEnter:()=>Q(!0),onMouseLeave:()=>Q(!1),children:[!z&&(0,e.jsx)(o.e,{cwd:b,sessionId:N,onOpenProjectSessions:()=>U(!0),onOpenSessionBrowser:()=>S(!0),onOpenSettings:()=>W(!0)}),"ollama"===d&&w&&(0,e.jsx)("div",{className:"flex items-center px-3 py-1.5 border-b border-border bg-card/50",children:(0,e.jsx)(s.m,{currentModel:u,onModelChange:w})}),"deepseek"===d&&y&&(0,e.jsx)("div",{className:"flex items-center px-3 py-1.5 border-b border-border bg-card/50",children:(0,e.jsx)(t.r,{currentModel:x,onModelChange:y})}),ak?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"text-muted-foreground",children:K("sessions.loadingHistory")})}):(0,e.jsx)(g.M,{ref:ab,messages:L,isLoading:ad,cwd:b,sessionId:N,engine:d,apiRetryInfo:ag,hasMoreHistory:am,isLoadingMore:al,onLoadMore:an,onFork:aq,isActive:B,onContentSearch:J}),ap&&(0,e.jsx)(o.g,{tokenUsage:ap,rateLimitInfo:af}),(0,e.jsx)(h.V,{onSend:aj,disabled:ad,cwd:b,engine:d,onShowGitStatus:F,onShowComments:b?ar:void 0,onShowUserMessages:as,onOpenNote:G,onCreateScheduledTask:at})]}),!z&&(0,e.jsx)(i.r,{isOpen:R,onClose:()=>S(!1)}),!z&&b&&(0,e.jsx)(j.Q,{isOpen:T,onClose:()=>U(!1),cwd:b}),!z&&(0,e.jsx)(k.b,{isOpen:V,onClose:()=>W(!1)}),b&&(0,e.jsx)(l.i,{isOpen:X,onClose:()=>Y(!1),cwd:b}),(0,e.jsx)(m.f,{isOpen:Z,onClose:()=>$(!1),messages:L,onSelectMessage:a=>{ab.current?.scrollToMessage(a)}})]})}g=(u.then?(await u)():u)[0],d()}catch(a){d(a)}})},24463:(a,b,c)=>{"use strict";c.d(b,{s:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g(a){return a.replace(/^\([^)]+\)\s*/,"")}let h=(0,e.forwardRef)(function({displayString:a,documentation:b,x:c,y:h,container:i,onMouseEnter:j,onMouseLeave:k,onFindReferences:l,onSearch:m},n){let{t:o}=(0,f.Bd)(),p=(0,e.useRef)(null);(0,e.useImperativeHandle)(n,()=>p.current,[]);let q=i.getBoundingClientRect(),r=c-q.left,s=h-q.top,t=(0,e.useMemo)(()=>g(a),[a]),u=(0,e.useMemo)(()=>(function(a){let b,c=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b/g,e=[],f=0,g=0,h=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b|"[^"]*"|'[^']*'|\b\d+\b/g;for(;null!==(b=h.exec(a));){b.index>f&&e.push((0,d.jsx)("span",{className:"text-foreground",children:a.slice(f,b.index)},g++));let h=b[0];/^["']/.test(h)?e.push((0,d.jsx)("span",{className:"text-green-400",children:h},g++)):/^\d+$/.test(h)?e.push((0,d.jsx)("span",{className:"text-orange-300",children:h},g++)):c.test(h)?(c.lastIndex=0,e.push((0,d.jsx)("span",{className:"text-pink-400",children:h},g++))):e.push((0,d.jsx)("span",{className:"text-foreground",children:h},g++)),f=b.index+h.length}return f<a.length&&e.push((0,d.jsx)("span",{className:"text-foreground",children:a.slice(f)},g++)),e})(t),[t]);return(0,e.useEffect)(()=>{if(!p.current)return;let a=p.current,b=i.getBoundingClientRect(),d=a.getBoundingClientRect(),e=c-b.left,f=h-b.top;e+d.width>b.width-8&&(e=b.width-d.width-8),e<8&&(e=8),f+d.height>b.height-8&&(f=f-d.height-24),a.style.left=`${e}px`,a.style.top=`${f}px`},[c,h,i]),(0,d.jsxs)("div",{ref:p,className:"absolute z-[200] max-w-lg bg-card border border-border rounded-lg shadow-xl px-3 py-2 pointer-events-none",style:{left:r,top:s},children:[(0,d.jsx)("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all leading-relaxed",children:u}),b&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"border-t border-border my-1"}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:b})]}),(l||m)&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"border-t border-border my-1.5"}),(0,d.jsxs)("div",{className:"flex items-center gap-3 pointer-events-auto",onMouseEnter:j,onMouseLeave:k,children:[l&&(0,d.jsx)("button",{onClick:l,className:"text-[11px] text-brand hover:underline cursor-pointer",children:o("hoverTooltip.findReferences")}),m&&(0,d.jsx)("button",{onClick:()=>m(function(a){let b=g(a),c=b.match(/^(?:function|const|let|var|class|interface|type|enum|async function)\s+([a-zA-Z_$][\w$]*)/);if(c)return c[1];let d=a.match(/\([^)]+\)\s+(?:[\w$]+\.)*([a-zA-Z_$][\w$]*)/);if(d)return d[1];let e=b.match(/([a-zA-Z_$][\w$]*)/);return e?e[1]:b.split(/[(\s:]/)[0]}(a)),className:"text-[11px] text-brand hover:underline cursor-pointer",children:o("hoverTooltip.search")})]})]})]})})},24520:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},24591:(a,b,c)=>{"use strict";function d(a){let b=0xdeadbeef,c=0x41c6ce57;for(let d=0;d<a.length;d++){let e=a.charCodeAt(d);b=Math.imul(b^e,0x9e3779b1),c=Math.imul(c^e,0x5f356495)}return b=Math.imul(b^b>>>16,0x85ebca6b)^Math.imul(c^c>>>13,0xc2b2ae35),(0x100000000*(2097151&(c=Math.imul(c^c>>>16,0x85ebca6b)^Math.imul(b^b>>>13,0xc2b2ae35)))+(b>>>0)>>>0).toString(16)}function e(a){return a.replace(/\s+/g," ").trim()}function f(a,b){return a?`${a}>${b}`:b}function g(a){let b=a.childForFieldName("name");if(b)return b.text;for(let b=0;b<a.namedChildCount;b++){let c=a.namedChild(b);if(c&&("identifier"===c.type||"type_identifier"===c.type||"property_identifier"===c.type))return c.text}return"<anonymous>"}function h(a,b,c,g,i=[],j){return{qualifiedName:f(g,b),name:b,kind:c,startLine:a.startPosition.row+1,endLine:a.endPosition.row+1,contentHash:d(e(a.text)),children:i,params:j}}function i(a){let b=a.childForFieldName("parameter");if(b)return[b.text];let c=a.childForFieldName("parameters");if(!c)return;let d=[];for(let a=0;a<c.namedChildCount;a++){let b=c.namedChild(a);b&&d.push(function a(b){switch(b.type){case"required_parameter":case"optional_parameter":{let c=b.childForFieldName("pattern");return c?a(c):b.text}case"assignment_pattern":{let c=b.childForFieldName("left");return c?a(c):b.text}case"default_parameter":case"typed_default_parameter":{let a=b.childForFieldName("name");return a?a.text:b.text}case"typed_parameter":for(let a=0;a<b.namedChildCount;a++){let c=b.namedChild(a);if(c?.type==="identifier")return c.text}return b.text;default:return b.text}}(b))}return d}function j(a){let b=[],c=function(a){let b=[],c=-1,f=-1;for(let d=0;d<a.namedChildCount;d++){let e=a.namedChild(d);if(e){if("import_statement"===e.type||"export_statement"===e.type&&null!==e.childForFieldName("source")||"import_from_statement"===e.type||"future_import_statement"===e.type)b.push(e),c<0&&(c=e.startPosition.row+1),f=e.endPosition.row+1;else if(c>=0)break}}return c<0?null:{qualifiedName:"__imports__",name:"imports",kind:"unknown",startLine:c,endLine:f,contentHash:d(e(b.map(a=>a.text).join("\n"))),children:[]}}(a);c&&b.push(c);for(let c=0;c<a.namedChildCount;c++){let j=a.namedChild(c);j&&b.push(...function a(b,c,j=!1){switch(b.type){case"export_statement":case"export_default_declaration":{let d=[];for(let e=0;e<b.namedChildCount;e++){let f=b.namedChild(e);f&&d.push(...a(f,c,!0))}return d}case"function_declaration":case"generator_function_declaration":case"function_definition":return[h(b,g(b),"function",c,[],i(b))];case"class_declaration":case"abstract_class_declaration":{let a=g(b),d=f(c,a),e=function(a,b){if(!a)return[];let c=[];for(let d=0;d<a.namedChildCount;d++){let e=a.namedChild(d);if(e){if("method_definition"===e.type)c.push(h(e,g(e),"method",b,[],i(e)));else if("public_field_definition"===e.type){let a=e.childForFieldName("value");a&&("arrow_function"===a.type||"function_expression"===a.type)&&c.push(h(e,g(e),"method",b,[],i(a)))}}}return c}(b.childForFieldName("body"),d);return[h(b,a,"class",c,e)]}case"interface_declaration":return[h(b,g(b),"interface",c)];case"type_alias_declaration":return[h(b,g(b),"type",c)];case"enum_declaration":return[h(b,g(b),"enum",c)];case"lexical_declaration":case"variable_declaration":return function(a,b){let c=[];for(let d=0;d<a.namedChildCount;d++){let e=a.namedChild(d);if(!e||"variable_declarator"!==e.type)continue;let f=e.childForFieldName("name"),j=e.childForFieldName("value");if(!f)continue;let k=f.text,l=j&&("arrow_function"===j.type||"function_expression"===j.type),m=l&&j?i(j):void 0;if(c.push(h(a,k,l?"function":"const",b,[],m)),j&&"object"===j.type&&!l){let a=b?`${b}>${k}`:k;for(let b=0;b<j.namedChildCount;b++){let d=j.namedChild(b);if(d){if("pair"===d.type){let b=d.childForFieldName("key"),e=d.childForFieldName("value");if(!b||!e||"property_identifier"!==b.type&&"identifier"!==b.type||"arrow_function"!==e.type&&"function_expression"!==e.type)continue;c.push(h(d,b.text,"method",a,[],i(e)))}else if("method_definition"===d.type){let b=g(d);b&&c.push(h(d,b,"method",a,[],i(d)))}}}}}return c}(b,c);case"class_definition":{let a=g(b),j=f(c,a),k=function a(b,c){if(!b)return[];let j=[];for(let k=0;k<b.namedChildCount;k++){let l=b.namedChild(k);if(l){if("function_definition"===l.type)j.push(h(l,g(l),"method",c,[],i(l)));else if("decorated_definition"===l.type){let b=l.childForFieldName("definition");if(b?.type==="function_definition")j.push({...h(b,g(b),"method",c,[],i(b)),startLine:l.startPosition.row+1,contentHash:d(e(l.text))});else if(b?.type==="class_definition"){let i=g(b),k=f(c,i),m=a(b.childForFieldName("body"),k);j.push({...h(b,i,"class",c,m),startLine:l.startPosition.row+1,contentHash:d(e(l.text))})}}else if("class_definition"===l.type){let b=g(l),d=f(c,b),e=a(l.childForFieldName("body"),d);j.push(h(l,b,"class",c,e))}}}return j}(b.childForFieldName("body"),j);return[h(b,a,"class",c,k)]}case"decorated_definition":{let f=b.childForFieldName("definition");if(!f)return[];return a(f,c,!1).map(a=>({...a,startLine:b.startPosition.row+1,contentHash:d(e(b.text))}))}case"expression_statement":{let a=[];for(let g=0;g<b.namedChildCount;g++){let h=b.namedChild(g);if(h?.type==="assignment"){let g=function(a,b,c){let g=b.childForFieldName("left");if(!g||"identifier"!==g.type)return null;let h=g.text;return{qualifiedName:f(c,h),name:h,kind:"const",startLine:a.startPosition.row+1,endLine:a.endPosition.row+1,contentHash:d(e(a.text)),children:[]}}(b,h,c);g&&a.push(g)}}return a.push(...function(a,b){let c=null;for(let b=0;b<a.namedChildCount;b++){let d=a.namedChild(b);if(d){if("call_expression"===d.type){c=d;break}if("await_expression"===d.type){for(let a=0;a<d.namedChildCount;a++){let b=d.namedChild(a);if(b?.type==="call_expression"){c=b;break}}break}}}if(!c)return[];let d=c.childForFieldName("function"),e=c.childForFieldName("arguments");if(!d||!e)return[];let f=null,g=[];for(let a=0;a<e.namedChildCount;a++){let b=e.namedChild(a);if(b){if(null===f&&("string"===b.type||"template_string"===b.type)){let a=b.text;f=a.length>=2&&/^["'`]/.test(a)?a.slice(1,-1):a}("arrow_function"===b.type||"function_expression"===b.type)&&g.push(b)}}if(0===g.length||!f)return[];let j=function a(b){if("identifier"===b.type)return b.text;if("member_expression"===b.type){let a=b.childForFieldName("property");return a?.text??""}if("call_expression"===b.type){let c=b.childForFieldName("function");return c?a(c):""}return""}(d),k=j?`${j} ${f}`:f;return g.map((a,c)=>h(a,g.length>1?`${k} #${c+1}`:k,"function",b,[],i(a)))}(b,c)),a}default:return[]}}(j,void 0,!1))}return b.push(...function(a,b){let c=a.text.split("\n"),f=c.length;if(0===f)return[];let g=new Uint8Array(f+2);for(let a of b){let b=Math.max(1,a.startLine),c=Math.min(f,a.endLine);for(let a=b;a<=c;a++)g[a]=1}let h=[],i=(a,b)=>{let f=!1;for(let d=a;d<=b;d++){let a=c[d-1];if(a&&a.trim().length>0){f=!0;break}}if(!f)return;let g=c.slice(a-1,b).join("\n");h.push({qualifiedName:`__code_${a}_${b}__`,name:"code",kind:"unknown",startLine:a,endLine:b,contentHash:d(e(g)),children:[]})},j=-1;for(let a=1;a<=f;a++)g[a]?j>=0&&(i(j,a-1),j=-1):j<0&&(j=a);return j>=0&&i(j,f),h}(a,b)),b}c.d(b,{Hs:()=>j})},26130:(a,b,c)=>{"use strict";c.d(b,{x:()=>h});var d=c(48249),e=c(67484),f=c(44384),g=c(81749);function h({isOpen:a,onClose:b,cwd:c}){let i,{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)([]),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(""),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)([]),[E,F]=(0,e.useState)(""),[G,H]=(0,e.useState)(!1),I=(0,e.useCallback)(async()=>{r(!0);try{let a=await fetch(`/api/git/worktree?cwd=${encodeURIComponent(c)}`);if(a.ok){let b=await a.json();l(b.worktrees),n(b.nextPath),p(b.nextRandomWord),b.gitUserName&&z(b.gitUserName)}}catch(a){console.error("Failed to load worktrees:",a),(0,g.oR)(j("toast.worktreeLoadFailed"),"error")}finally{r(!1)}},[c]),J=(0,e.useCallback)(a=>{let{local:b,remote:c}=a;return c.includes("origin/main")?"origin/main":c.includes("origin/master")?"origin/master":b.includes("main")?"main":b.includes("master")?"master":c.length>0?c[0]:b.length>0?b[0]:"main"},[]),K=async()=>{if(!m)return;let a="origin/main";try{let b=await fetch(`/api/git/branches?cwd=${encodeURIComponent(c)}`);if(b.ok){let c=await b.json();a=J(c)}}catch{}let b=o||function(){let a="bcdfghjklmnprstvwz",b=["a","e","i","o","u","ai","au","ea","ee","ia","io","oa","oo","ou","ui"],c="";for(let d=0;d<2;d++)c+=a[Math.floor(Math.random()*a.length)],c+=b[Math.floor(Math.random()*b.length)];return c}(),d=y?`${y}/${b}`:b;t(!0);try{let b=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"add",cwd:c,path:m,newBranch:d,baseBranch:a})});if(b.ok)(0,g.oR)(j("toast.worktreeCreateSuccess",{name:d}),"success"),I();else{let a=await b.json();(0,g.oR)(a.error||j("toast.worktreeCreateFailed"),"error")}}catch(a){console.error("Failed to create worktree:",a),(0,g.oR)(j("toast.worktreeCreateFailed"),"error")}finally{t(!1)}},L=async()=>{H(!0),F(""),B(!0);try{let a=await fetch(`/api/git/branches?cwd=${encodeURIComponent(c)}`);if(a.ok){let b=await a.json(),c=new Set(k.map(a=>a.branch).filter(Boolean)),d=[...b.local.filter(a=>!c.has(a)),...b.remote.filter(a=>!c.has(a)&&!b.local.includes(a.replace(/^origin\//,"")))];D(d)}}catch{(0,g.oR)(j("toast.loadBranchFailed"),"error")}finally{H(!1)}},M=async a=>{if(m){B(!1),t(!0);try{let b=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"add",cwd:c,path:m,branch:a})});if(b.ok)(0,g.oR)(j("toast.worktreeCreateSuccess",{name:a}),"success"),I();else{let a=await b.json();(0,g.oR)(a.error||j("toast.worktreeCreateFailed"),"error")}}catch(a){console.error("Failed to create worktree:",a),(0,g.oR)(j("toast.worktreeCreateFailed"),"error")}finally{t(!1)}}},N=async()=>{if(u){x(!0);try{let a=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"remove",cwd:c,path:u.path})});if(a.ok)(0,g.oR)(j("toast.worktreeDeleted"),"success"),v(null),I();else{let b=await a.json();(0,g.oR)(b.error||j("toast.worktreeDeleteFailed"),"error")}}catch(a){console.error("Failed to delete worktree:",a),(0,g.oR)(j("toast.worktreeDeleteFailed"),"error")}finally{x(!1)}}},O=async a=>{let b=a.isLocked?"unlock":"lock";try{let d=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:b,cwd:c,path:a.path})});if(d.ok)(0,g.oR)(a.isLocked?j("toast.worktreeUnlocked"):j("toast.worktreeLocked"),"success"),I();else{let a=await d.json();(0,g.oR)(a.error||j("toast.operationFailed"),"error")}}catch(a){console.error("Failed to toggle lock:",a),(0,g.oR)(j("toast.operationFailed"),"error")}};return a?(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:b,children:(0,d.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-[480px] max-h-[80vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between flex-shrink-0",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Git Worktrees"}),(0,d.jsx)("button",{onClick:b,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:j("common.close"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 p-4 overflow-y-auto",children:q?(0,d.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,d.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):(0,d.jsx)("div",{className:"space-y-2",children:k.map(a=>{let e=a.path===c;return(0,d.jsxs)("div",{className:`group p-3 rounded-lg border transition-colors ${e?"border-brand bg-brand/5":"border-border hover:bg-accent cursor-pointer"}`,onClick:()=>{a.path!==c&&(window.parent.postMessage({type:"OPEN_PROJECT",cwd:a.path},"*"),b())},children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${e?"bg-brand":"bg-muted-foreground/30"}`}),(0,d.jsx)("span",{className:"font-medium text-foreground truncate",children:a.branch||(a.isDetached?"detached":"unknown")}),a.isLocked&&(0,d.jsx)("span",{className:"text-amber-11",title:j("git.worktree.locked"),children:"\uD83D\uDD12"}),e&&(0,d.jsxs)("span",{className:"text-xs text-brand",children:["(",j("common.current"),")"]})]}),(0,d.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:!e&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),O(a)},className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-secondary rounded transition-colors",title:a.isLocked?j("git.worktree.unlock"):j("git.worktree.lock"),children:a.isLocked?(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z"})}):(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),v(a)},className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-secondary rounded transition-colors",title:j("common.delete"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})})]})})]}),(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate pl-4",children:a.path}),a.isDetached&&(0,d.jsx)("div",{className:"mt-1 text-xs text-amber-11 pl-4",children:"(detached HEAD)"})]},a.path)})})}),A&&(0,d.jsxs)("div",{className:"border-t border-border px-4 py-3 flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,d.jsx)("input",{value:E,onChange:a=>F(a.target.value),placeholder:j("git.worktree.searchBranch"),className:"flex-1 bg-secondary text-sm text-foreground rounded px-2.5 py-1.5 outline-none placeholder:text-muted-foreground",autoFocus:!0,autoComplete:"off",spellCheck:"false"}),(0,d.jsx)("button",{onClick:()=>B(!1),className:"text-xs text-muted-foreground hover:text-foreground px-2 py-1.5",children:j("common.cancel")})]}),(0,d.jsx)("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:G?(0,d.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:j("common.loading")}):0===(i=C.filter(a=>a.toLowerCase().includes(E.toLowerCase()))).length?(0,d.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:j("git.worktree.noBranches")}):i.map(a=>(0,d.jsx)("button",{onClick:()=>M(a),className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-accent transition-colors truncate",children:(0,d.jsx)("span",{className:`${a.startsWith("origin/")?"text-muted-foreground":"text-foreground"}`,children:a})},a))})]}),(0,d.jsxs)("div",{className:"px-4 py-3 border-t border-border flex items-center justify-between flex-shrink-0",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:j("git.worktree.count",{count:k.length})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:L,disabled:!m||s,className:`px-3 py-1.5 text-sm rounded transition-colors ${m&&!s?"bg-secondary text-foreground hover:bg-accent":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:j("git.worktree.selectBranch")}),(0,d.jsx)("button",{onClick:K,disabled:!m||s,className:`px-3 py-1.5 text-sm rounded transition-colors ${m&&!s?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:s?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):j("git.worktree.addWorktree")})]})]}),u&&(0,d.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-black/50 rounded-lg",onClick:()=>v(null),children:(0,d.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-[360px] p-4",onClick:a=>a.stopPropagation(),children:[(0,d.jsx)("div",{className:"text-sm font-medium text-foreground mb-3",children:j("git.worktree.confirmDelete")}),(0,d.jsxs)("div",{className:"text-sm text-muted-foreground mb-4",children:[(0,d.jsx)("p",{className:"mb-2",children:j("git.worktree.confirmDeleteMsg")}),(0,d.jsxs)("p",{className:"text-xs",children:[(0,d.jsx)("span",{className:"text-muted-foreground",children:j("git.worktree.path")}),(0,d.jsx)("span",{className:"text-foreground",children:u.path})]}),(0,d.jsxs)("p",{className:"text-xs",children:[(0,d.jsx)("span",{className:"text-muted-foreground",children:j("git.worktree.branch")}),(0,d.jsx)("span",{className:"text-foreground",children:u.branch||"detached"})]})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)("button",{onClick:()=>v(null),className:"px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:j("common.cancel")}),(0,d.jsx)("button",{onClick:N,disabled:w,className:"px-3 py-1.5 text-sm bg-red-9 text-white rounded hover:bg-red-10 transition-colors disabled:opacity-50",children:w?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):j("common.delete")})]})]})})]})}):null}},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},28354:a=>{"use strict";a.exports=require("util")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},31893:(a,b,c)=>{"use strict";c.d(b,{$:()=>q});var d=c(48249),e=c(67484),f=c(44384),g=c(31172),h=c(15273),i=c(46674),j=c(47408);let k=(0,j.A)("square-check-big",[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),l=(0,j.A)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),m=(0,j.A)("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]),n=(0,j.A)("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);var o=c(81749);function p(a){let b=a.input?.questions||[],c=a.input?.answers||{},d={};if(a.result)try{let b=JSON.parse(a.result);b?.answers&&(d=b.answers)}catch{}return{questions:b,answers:{...c,...d}}}function q({toolCalls:a,onClose:b}){let{t:c}=(0,f.Bd)(),[j,r]=(0,e.useState)({}),[s,t]=(0,e.useState)({}),[u,v]=(0,e.useState)({}),[w,x]=(0,e.useState)({}),y=a.reduce((a,b)=>{let{questions:c}=p(b);return a+c.length},0),z=Object.values(w).filter(Boolean).length,A=(0,e.useCallback)((a,b)=>{r(c=>({...c,[a]:b})),t(b=>({...b,[a]:!1}))},[]),B=(0,e.useCallback)(a=>{t(b=>{let c=!b[a];if(c){let b=u[a]||"";b&&r(c=>({...c,[a]:b}))}return{...b,[a]:c}})},[u]),C=(0,e.useCallback)((a,b)=>{v(c=>({...c,[a]:b})),b&&r(c=>({...c,[a]:b}))},[]),D=(0,e.useCallback)(a=>{x(b=>({...b,[a]:!b[a]}))},[]),E=(0,e.useCallback)(()=>{let b=z>0,d=[];a.forEach((a,e)=>{let{questions:f}=p(a);f.forEach((a,f)=>{let g=`${e}-${f}`;if(b&&!w[g])return;let h=j[g];d.push(`Q: ${a.question}`),d.push(`A: ${h||c("askQuestion.notSelected")}`),d.push("")})}),navigator.clipboard.writeText(d.join("\n").trim()),(0,o.oR)(b?c("toast.copiedQA",{count:z}):c("toast.copiedAllQA"))},[a,j,w,z,c]),F=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,d.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground",children:c("askQuestion.title")}),(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[c("askQuestion.nQuestions",{count:y}),z>0&&` \xb7 ${c("askQuestion.checkedN",{count:z})}`]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:E,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:z>0?c("askQuestion.copyChecked",{count:z}):c("askQuestion.copyAll"),children:(0,d.jsx)(h.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)(i.A,{className:"w-5 h-5"})})]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:a.map((b,e)=>{let{questions:f}=p(b);return f.map((b,g)=>{let h=`${e}-${g}`,i=j[h],o=s[h]||!1,p=w[h]||!1;return(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("button",{onClick:()=>D(h),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-accent transition-colors",title:c("askQuestion.checkToCopy"),children:p?(0,d.jsx)(k,{className:"w-4 h-4 text-brand"}):(0,d.jsx)(l,{className:"w-4 h-4 text-muted-foreground"})}),b.header&&(0,d.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:b.header}),(0,d.jsx)("span",{className:"text-sm font-medium text-foreground",children:b.question})]}),(0,d.jsxs)("div",{className:"space-y-1 ml-7",children:[b.options.map((a,b)=>{let c=i===a.label&&!o;return(0,d.jsxs)("button",{onClick:()=>A(h,a.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-accent/50 ${c?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,d.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:c?(0,d.jsx)(m,{className:"w-3.5 h-3.5 text-brand"}):(0,d.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("div",{className:`text-sm ${c?"text-foreground font-medium":"text-foreground"}`,children:a.label}),a.description&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]})]},b)}),(0,d.jsxs)("button",{onClick:()=>B(h),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${o?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,d.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:o?(0,d.jsx)(m,{className:"w-3.5 h-3.5 text-brand"}):(0,d.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)(n,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,d.jsx)("span",{className:"text-sm text-muted-foreground",children:c("askQuestion.custom")})]})]}),o&&(0,d.jsx)("div",{className:"ml-6 mt-1",children:(0,d.jsx)("input",{type:"text",autoFocus:!0,value:u[h]||"",onChange:a=>C(h,a.target.value),placeholder:c("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 placeholder:text-muted-foreground"})})]}),(e!==a.length-1||g!==f.length-1)&&(0,d.jsx)("div",{className:"border-b border-border/50 mt-3"})]},h)})})})]})});return(0,d.jsx)(g.ZL,{children:F})}},32616:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("file-diff",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]])},33500:(a,b,c)=>{"use strict";c.d(b,{YO:()=>d,pU:()=>e});let d=20;function e(a,b,c,d=[]){let f=a.length,g=c=>"unchanged"!==a[c].type||"unchanged"!==b[c].type,h=new Set;for(let a=0;a<f;a++){if(!g(a))continue;let b=Math.max(0,a-3),c=Math.min(f-1,a+3);for(let a=b;a<=c;a++)h.add(a)}let i=[];for(let a=0;a<f;a++){if(h.has(a))continue;let b=a;for(;a<f&&!h.has(a);)a++;i.push({id:i.length,startIdx:b,endIdx:a-1}),a--}for(let a of i){let b=c.get(a.id)??{topRevealed:0,bottomRevealed:0},d=a.endIdx-a.startIdx+1,e=Math.max(0,Math.min(b.topRevealed,d)),f=Math.max(0,Math.min(b.bottomRevealed,d-e));for(let b=a.startIdx;b<a.startIdx+e;b++)h.add(b);for(let b=a.endIdx-f+1;b<=a.endIdx;b++)h.add(b)}let j=[];for(let a=0;a<f;a++){let e;if(h.has(a)){j.push({kind:"diff",idx:a});continue}let g=a;for(;a<f&&!h.has(a);)a++;let k=a-1;a--;let l=i.find(a=>a.startIdx<=g&&k<=a.endIdx);if(!l)continue;let m=c.get(l.id)??{topRevealed:0,bottomRevealed:0},n=l.endIdx-l.startIdx+1;if(d.length>0&&k+1<f)for(let a=k+1;a<f;a++){let c=b[a].lineNum;if(!(c<=0)){e=function(a,b){let c=null;for(let d of a)d.startLine<=b&&b<=d.endLine&&(!c||d.endLine-d.startLine<c.endLine-c.startLine)&&(c=d);return c}(d,c)??void 0;break}}j.push({kind:"gap",gapId:l.id,hiddenCount:k-g+1,canExpandUp:m.topRevealed<n,canExpandDown:m.bottomRevealed<n-m.topRevealed,enclosingFn:e})}return{rows:j,gaps:i}}},33740:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]])},33873:a=>{"use strict";a.exports=require("path")},34371:(a,b,c)=>{"use strict";c.d(b,{y:()=>h});var d=c(67484),e=c(95836),f=c(94882),g=c(41564);function h({cwd:a,addToRecentFiles:b}){let[c,i]=(0,d.useState)(null),[j,k]=(0,d.useState)(""),[l,m]=(0,d.useState)([]),[n,o]=(0,d.useState)(null),[p,q]=(0,d.useState)([]),[r,s]=(0,d.useState)([]),[t,u]=(0,d.useState)(new Set),[v,w]=(0,d.useState)(null),[x,y]=(0,d.useState)(null),[z,A]=(0,d.useState)(!1),[B,C]=(0,d.useState)(!1),[D,E]=(0,d.useState)(!1),[F,G]=(0,d.useState)(!0),[H,I]=(0,d.useState)(!1),[J,K]=(0,d.useState)(!1),[L,M]=(0,d.useState)(null),N=(0,d.useRef)(null),[O,P]=(0,d.useState)(null),[Q,R]=(0,d.useState)(!1),[S,T]=(0,d.useState)(""),[U,V]=(0,d.useState)(""),[W,X]=(0,d.useState)([]),[Y,Z]=(0,d.useState)([]),[$,_]=(0,d.useState)(new Set),[aa,ab]=(0,d.useState)(null),[ac,ad]=(0,d.useState)(null),[ae,af]=(0,d.useState)(!1),[ag,ah]=(0,d.useState)(!1),ai=(0,d.useCallback)(()=>{A(!0),M(null),fetch(`/api/git/branches?cwd=${encodeURIComponent(a)}`).then(a=>a.json()).then(a=>{a.error?(M("Failed to get branches"===a.error?g.A.t("git.notGitRepo"):a.error),i(null)):a.local&&a.current?(i(a),k(a.current),a.upstream&&T(a.upstream)):(M(g.A.t("git.cannotGetBranches")),i(null))}).catch(a=>{console.error(a),M(g.A.t("git.getBranchesFailed")),i(null)}).finally(()=>A(!1))},[a]),aj=(0,d.useCallback)(b=>{C(!0),o(null),q([]),s([]),w(null),y(null),G(!0),fetch(`/api/git/commits?cwd=${encodeURIComponent(a)}&branch=${encodeURIComponent(b)}&limit=${f.B_}`).then(a=>a.json()).then(a=>{let b=a.commits||[];m(b),G(b.length>=f.B_)}).catch(console.error).finally(()=>C(!1))},[a]),ak=(0,d.useCallback)(()=>{if(D||!F||!j)return;E(!0);let b=l.length;fetch(`/api/git/commits?cwd=${encodeURIComponent(a)}&branch=${encodeURIComponent(j)}&limit=${f.B_}&offset=${b}`).then(a=>a.json()).then(a=>{let b=a.commits||[];b.length>0&&m(a=>[...a,...b]),G(b.length>=f.B_)}).catch(console.error).finally(()=>E(!1))},[a,j,l.length,D,F]),al=(0,d.useCallback)(a=>{let{scrollTop:b,scrollHeight:c,clientHeight:d}=a.target;c-b-d<100&&ak()},[ak]),am=(0,d.useCallback)(b=>{o(b),w(null),y(null),I(!0),fetch(`/api/git/commit-diff?cwd=${encodeURIComponent(a)}&hash=${b.hash}`).then(a=>a.json()).then(a=>{let b=a.files||[];q(b);let c=(0,e.Do)(b);s(c),u(new Set((0,e.Sz)(c)))}).catch(console.error).finally(()=>I(!1))},[a]),an=(0,d.useCallback)(c=>{n&&(w(c),b(c.path),K(!0),fetch(`/api/git/commit-diff?cwd=${encodeURIComponent(a)}&hash=${n.hash}&file=${encodeURIComponent(c.path)}`).then(a=>a.json()).then(a=>y(a)).catch(console.error).finally(()=>K(!1)))},[a,n,b]),ao=(0,d.useCallback)(a=>{u(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),ap=(0,d.useCallback)(b=>{af(!0),ab(null),ad(null),fetch(`/api/git/branch-diff?cwd=${encodeURIComponent(a)}&base=${encodeURIComponent(b)}`).then(a=>a.json()).then(a=>{let b=a.files||[];X(b);let c=(0,e.Do)(b);Z(c),_(new Set((0,e.Sz)(c)))}).catch(console.error).finally(()=>af(!1))},[a]),aq=(0,d.useCallback)(c=>{ab(c),b(c.path),ah(!0),fetch(`/api/git/branch-diff?cwd=${encodeURIComponent(a)}&base=${encodeURIComponent(U)}&file=${encodeURIComponent(c.path)}`).then(a=>a.json()).then(a=>ad(a)).catch(console.error).finally(()=>ah(!1))},[a,U,b]),ar=(0,d.useCallback)(a=>{_(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),as=(0,d.useCallback)(a=>{if(R(a),a){let a="origin/main";V(a),ap(a)}else X([]),Z([]),ab(null),ad(null),V("")},[S,ap]);return{branches:c,selectedBranch:j,setSelectedBranch:k,commits:l,setCommits:m,selectedCommit:n,setSelectedCommit:o,historyFiles:p,historyFileTree:r,historyExpandedPaths:t,historySelectedFile:v,historyFileDiff:x,isLoadingBranches:z,isLoadingCommits:B,isLoadingMore:D,hasMoreCommits:F,setHasMoreCommits:G,isLoadingHistoryFiles:H,isLoadingHistoryDiff:J,historyError:L,commitListRef:N,tooltipPos:O,loadBranches:ai,loadCommits:aj,loadMoreCommits:ak,handleCommitListScroll:al,handleSelectCommit:am,handleSelectHistoryFile:an,handleHistoryToggle:ao,handleCommitInfoMouseMove:(0,d.useCallback)(a=>{P({x:a.clientX,y:a.clientY})},[]),handleCommitInfoMouseLeave:(0,d.useCallback)(()=>{P(null)},[]),compareMode:Q,toggleCompareMode:as,compareBaseBranch:U,setCompareBaseBranch:V,upstreamBranch:S,compareFiles:W,compareFileTree:Y,compareExpandedPaths:$,compareSelectedFile:aa,compareFileDiff:ac,isLoadingCompareFiles:ae,isLoadingCompareDiff:ag,handleSelectCompareFile:aq,handleCompareToggle:ar,loadCompareFiles:ap}}},36645:(a,b,c)=>{"use strict";c.d(b,{_:()=>i,o:()=>h});var d=c(67484),e=c.n(d),f=c(41564);let g="json-search-highlight-style";function h(a){let[b,c]=(0,d.useState)(!1),[e,f]=(0,d.useState)(""),[h,i]=(0,d.useState)(!1),[j,k]=(0,d.useState)(0),[l,m]=(0,d.useState)(0),n=(0,d.useRef)(null),o=(0,d.useRef)([]);(0,d.useCallback)(()=>{let b;CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),o.current=[];let c=a.current;if(!c||!e){k(0),m(0);return}!function(){if(document.getElementById(g))return;let a=document.createElement("style");a.id=g,a.textContent="::highlight(json-search){background:rgba(217,119,6,.3)}::highlight(json-search-current){background:rgba(217,119,6,.5)}",document.head.appendChild(a)}();let d=c.textContent||"",f=h?e:e.toLowerCase(),i=h?d:d.toLowerCase(),j=[],l=0;for(;l<i.length;){let a=i.indexOf(f,l);if(-1===a)break;j.push([a,a+f.length]),l=a+1}if(0===j.length){k(0),m(0);return}let n=document.createTreeWalker(c,NodeFilter.SHOW_TEXT),p=0,q=0,r=[],s=null,t=0;for(;(b=n.nextNode())&&q<j.length;){let a=b.textContent?.length||0,c=p,d=p+a;for(;q<j.length;){let[a,e]=j[q];if(a>=d)break;if(!s)if(a>=c)(s=document.createRange()).setStart(b,a-c),t=e;else break;if(t<=d)s.setEnd(b,t-c),r.push(s),s=null,q++;else break}p=d}o.current=r,k(r.length),m(a=>r.length>0?Math.min(a,r.length-1):0),CSS.highlights&&r.length>0&&CSS.highlights.set("json-search",new Highlight(...r))},[a,e,h]);let p=(0,d.useCallback)((a,b)=>{let c=a.getBoundingClientRect();(b.top<c.top||b.bottom>c.bottom)&&(a.scrollTop+=b.top-c.top-c.height/2+b.height/2)},[]);(0,d.useCallback)(b=>{CSS.highlights?.delete("json-search-current");let c=o.current[b];if(!c||!CSS.highlights)return;CSS.highlights.set("json-search-current",new Highlight(c));let d=c.getBoundingClientRect(),e=a.current?.parentElement;e&&p(e,d)},[a,p]);let q=(0,d.useCallback)(()=>{0!==j&&m(a=>(a+1)%j)},[j]),r=(0,d.useCallback)(()=>{0!==j&&m(a=>(a-1+j)%j)},[j]),s=(0,d.useCallback)(()=>{c(!0),setTimeout(()=>n.current?.focus(),0)},[]),t=(0,d.useCallback)(()=>{c(!1),f(""),m(0)},[]),u=(0,d.useCallback)(a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?r():q()),"Escape"===a.key&&(a.preventDefault(),t())},[q,r,t]);return{isVisible:b,query:e,setQuery:f,caseSensitive:h,setCaseSensitive:i,matchCount:j,currentIndex:l,searchInputRef:n,open:s,close:t,goToNext:q,goToPrev:r,handleKeyDown:u}}function i({search:a}){return a.isVisible?e().createElement("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border"},e().createElement("input",{ref:a.searchInputRef,type:"text",value:a.query,onChange:b=>a.setQuery(b.target.value),onKeyDown:a.handleKeyDown,placeholder:f.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"}),e().createElement("button",{onClick:()=>a.setCaseSensitive(a=>!a),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${a.caseSensitive?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:f.A.t("codeViewer.caseSensitive")},"Aa"),e().createElement("span",{className:"text-xs text-muted-foreground"},a.matchCount>0?`${a.currentIndex+1}/${a.matchCount}`:f.A.t("common.noMatch")),e().createElement("button",{onClick:a.goToPrev,disabled:0===a.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:f.A.t("common.previous")},e().createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}))),e().createElement("button",{onClick:a.goToNext,disabled:0===a.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:f.A.t("common.next")},e().createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),e().createElement("button",{onClick:a.close,className:"p-1 rounded hover:bg-accent",title:f.A.t("common.close")},e().createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))):null}},37957:(a,b,c)=>{Promise.resolve().then(c.bind(c,38476))},38476:(a,b,c)=>{"use strict";c.d(b,{TabManager:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call TabManager() from the server but TabManager is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/project/TabManager.tsx","TabManager")},40516:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{m:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(81749),i=c(86402),j=c(10164),k=c(56929),l=c(36645),m=c(69005),n=c(2531),o=c(6088),p=c(89261),q=c(23290),r=c(94882),s=a([i,p]);function t({cwd:a,selected:b,diff:c,showMarkdownPreview:d,setShowMarkdownPreview:s,changedFiles:u,fileGitStatusMap:v,onContentSearch:w,locateInTree:x,jsonPreview:y,setJsonPreview:z,jsonPreviewSearch:A,jsonPreviewPreRef:B}){let{t:C}=(0,g.Bd)(),[D,E]=(0,f.useState)("file"),[F,G]=(0,f.useState)("compact"),H=b.file.path,I=(0,r.u)(H),{state:J}=(0,n.V)(a,H),K=(0,f.useMemo)(()=>{if("ready"===J.state)return J.data.functions.filter(o._).map(a=>({name:a.name,startLine:a.startLine,endLine:a.endLine,params:a.params}))},[J]);return(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[I||"map"!==D?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:H}),(0,e.jsx)(m.m,{content:C("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),navigator.clipboard.writeText(`${a}/${H}`),(0,h.oR)(C("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)(m.m,{content:C("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),x(H)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),(0,e.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${"staged"===b.type?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===b.type?C("fileBrowser.staged"):C("fileBrowser.unstaged")}),(0,e.jsx)("div",{className:"flex-1"}),!I&&"file"===D&&(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["compact","full"].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),G(a)},className:`px-2 py-0.5 text-xs transition-colors ${F===a?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:C("compact"===a?"diffViewer.compact":"diffViewer.full")},a))}),!I&&(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),E(a)},className:`px-2 py-0.5 text-xs transition-colors ${D===a?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:C("file"===a?"common.file":"common.codeMap")},a))})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:I?(0,e.jsx)(q.I,{cwd:a,path:H,className:"p-4 flex items-center justify-center",imgClassName:"max-w-full max-h-[60vh] object-contain",alt:H}):(0,e.jsx)(i.xZ,{oldContent:c.oldContent,newContent:c.newContent,filePath:c.filePath,isNew:c.isNew,isDeleted:c.isDeleted,cwd:a,enableComments:!0,compact:"compact"===F,symbols:K,onPreview:!c.isDeleted&&(0,k.e$)(H)?()=>s(!0):!c.isDeleted&&H.endsWith(".json")?()=>z({content:c.newContent,filePath:c.filePath}):void 0,previewLabel:H.endsWith(".json")?C("common.readable"):C("common.preview"),onContentSearch:w})})]}):(0,e.jsx)(p.r,{cwd:a,filePath:c.filePath,oldContent:c.oldContent,newContent:c.newContent,isNew:c.isNew,isDeleted:c.isDeleted,changedFiles:u,fileGitStatusMap:v,enableComments:!0,onContentSearch:w,headerExtraLeft:({focalFile:b})=>{if(!b)return null;let c=v.get(b);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(m.m,{content:C("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${a}/${b}`),(0,h.oR)(C("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)(m.m,{content:C("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),x(b)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,e.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),c&&(0,e.jsx)("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${"staged"===c?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===c?C("fileBrowser.staged"):C("fileBrowser.unstaged")})]})},headerExtraRight:()=>(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),E(a)},className:`px-2 py-0.5 text-[11px] transition-colors ${D===a?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:C("file"===a?"common.file":"common.codeMap")},a))})}),d&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>s(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(j.M,{content:c.newContent,filePath:c.filePath,cwd:a,onClose:()=>s(!1)})})}),y&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>z(null),children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90%] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:y.filePath}),(0,e.jsx)("button",{onClick:()=>z(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)(l._,{search:A}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,e.jsx)("pre",{ref:B,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,k.xb)(y.content)})})]})})]})}[i,p]=s.then?(await s)():s,d()}catch(a){d(a)}})},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},41938:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$:()=>g});var e=c(12629),f=a([e]);e=(f.then?(await f)():f)[0];let h="/tree-sitter",i=null,j=new Map;async function g(a){let b,c=await (!(b=j.get(a))&&(b=(async()=>(await (!i&&(i=e.Parser.init({locateFile:a=>`${h}/${a}`})),i),e.Language.load(`${h}/tree-sitter-${a}.wasm`)))(),j.set(a,b)),b),d=new e.Parser;return d.setLanguage(c),d}d()}catch(a){d(a)}})},42911:(a,b,c)=>{"use strict";c.d(b,{i:()=>l});var d=c(48249),e=c(67484),f=c(44384),g=c(41564),h=c(23434),i=c(31172),j=c(81749);function k(a){if(0===a.length)return"";let b=[g.A.t("comments.codeRef"),""],c=a.filter(a=>a.filePath===h.Un),d=a.filter(a=>a.filePath!==h.Un);for(let a of(d.length>0&&d.forEach((a,c)=>{b.push(`[${c+1}] ${a.filePath}:${a.startLine}-${a.endLine}`),b.push("```"),b.push(a.codeContent),b.push("```"),a.content&&b.push(g.A.t("comments.note",{content:a.content})),b.push("")}),c)){let c=a.codeContent.split("\n").map(a=>`> ${a}`).join("\n");b.push(c),a.content&&b.push(a.content),b.push("")}return b.join("\n").trim()}function l({isOpen:a,onClose:b,cwd:c,onNavigateToComment:g}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)([]),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(null),[t,u]=(0,e.useState)(!1);(0,e.useCallback)(async()=>{if(c){q(!0);try{let a=await fetch(`/api/comments?cwd=${encodeURIComponent(c)}&all=true`);if(a.ok){let b=await a.json();o(b.comments||[])}}catch(a){console.error("Failed to load comments:",a)}finally{q(!1)}}},[c]);let v=async a=>{try{(await fetch(`/api/comments?cwd=${encodeURIComponent(c)}&id=${encodeURIComponent(a)}`,{method:"DELETE"})).ok&&(o(b=>b.filter(b=>b.id!==a)),(0,h.Cm)())}catch(a){console.error("Failed to delete comment:",a)}},w=async a=>{s(a.id);try{let b="";if(a.selectedText)b=a.selectedText;else{let d=await fetch(`/api/files/text?cwd=${encodeURIComponent(c)}&path=${encodeURIComponent(a.filePath)}`);if(!d.ok)throw Error("Failed to read file");b=((await d.json()).content||"").split("\n").slice(a.startLine-1,a.endLine).join("\n")}let d={filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,content:a.content,codeContent:b},e=k([d]);await navigator.clipboard.writeText(e),(0,j.oR)(m("toast.copiedComment"))}catch(a){console.error("Failed to copy comment:",a)}finally{s(null)}},x=async()=>{if(0!==n.length){u(!0);try{let a=await (0,h.$3)(c),b=k(a);await navigator.clipboard.writeText(b),(0,j.oR)(m("toast.copiedAllComments"))}catch(a){console.error("Failed to copy all comments:",a)}finally{u(!1)}}},y=n.reduce((a,b)=>(a[b.filePath]||(a[b.filePath]=[]),a[b.filePath].push(b),a),{});if(!a)return null;let z=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,d.jsxs)("div",{className:"w-full max-w-2xl max-h-[80vh] bg-card border border-border rounded-lg shadow-xl flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-secondary",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:m("comments.allComments")}),n.length>0&&(0,d.jsx)("button",{onClick:x,disabled:t,className:"p-1 rounded hover:bg-accent text-muted-foreground disabled:opacity-50",title:m("comments.copyAllComments"),children:t?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:b,className:"p-1 rounded hover:bg-accent text-muted-foreground",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:p?(0,d.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:m("common.loading")}):0===n.length?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,d.jsx)("svg",{className:"w-12 h-12 mb-3 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsx)("span",{children:m("comments.noComments")})]}):(0,d.jsx)("div",{className:"space-y-4",children:Object.entries(y).map(([a,b])=>(0,d.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,d.jsxs)("div",{className:"px-3 py-2 bg-secondary border-b border-border",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-foreground font-mono",children:a===h.Un?m("comments.aiReply"):a}),(0,d.jsxs)("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",m("comments.nComments",{count:b.length}),")"]})]}),(0,d.jsx)("div",{className:"divide-y divide-border",children:b.map(a=>{var b;return(0,d.jsx)("div",{className:"px-3 py-2 hover:bg-accent/50 cursor-pointer group",onClick:()=>g?.(a),children:(0,d.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.startLine>0||a.endLine>0?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"text-xs text-brand font-mono",children:[m("common.line")," ",a.startLine===a.endLine?a.startLine:`${a.startLine}-${a.endLine}`]}),(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",m("comments.linesCount",{count:a.endLine-a.startLine+1}),")"]})]}):a.selectedText?(0,d.jsxs)("span",{className:"text-xs text-muted-foreground italic truncate max-w-[200px]",children:["“",a.selectedText.slice(0,50),a.selectedText.length>50?"...":"","”"]}):null,(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:(b=a.updatedAt||a.createdAt)?new Date(b).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):""})]}),(0,d.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.content||(0,d.jsx)("span",{className:"text-muted-foreground italic",children:m("comments.noContent")})})]}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),w(a)},disabled:r===a.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-accent text-muted-foreground transition-opacity disabled:opacity-50",title:m("common.copy"),children:r===a.id?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:b=>{b.stopPropagation(),v(a.id)},className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-accent text-muted-foreground hover:text-red-9 transition-opacity",title:m("common.delete"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})})]})},a.id)})})]},a))})}),(0,d.jsxs)("div",{className:"px-4 py-3 border-t border-border bg-secondary flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground",children:m("comments.totalComments",{count:n.length})}),(0,d.jsx)("button",{onClick:async()=>{0===n.length||await (0,h.RP)(c)&&o([])},disabled:0===n.length,className:"px-3 py-1.5 text-sm bg-red-9 text-white rounded hover:bg-red-10 disabled:opacity-50 disabled:cursor-not-allowed",children:m("comments.clearAll")})]})]})});return(0,d.jsx)(i.ZL,{children:z})}},43609:(a,b,c)=>{"use strict";c.d(b,{W:()=>f});var d=c(67484),e=c(94882);function f({cwd:a}){let[b,c]=(0,d.useState)([]),[g,h]=(0,d.useState)(null),[i,j]=(0,d.useState)(new Set),[k,l]=(0,d.useState)([]),[m,n]=(0,d.useState)(null),[o,p]=(0,d.useState)(null),[q,r]=(0,d.useState)(new Set),[s,t]=(0,d.useState)(null),[u,v]=(0,d.useState)(""),[w,x]=(0,d.useState)(!1),[y,z]=(0,d.useState)(null),[A,B]=(0,d.useState)(!1),[C,D]=(0,d.useState)(!1),[E,F]=(0,d.useState)(null),G=(0,d.useRef)(null),[H,I]=(0,d.useState)(!1),[J,K]=(0,d.useState)(null),[L,M]=(0,d.useState)("center"),[N,O]=(0,d.useState)(null),[P,Q]=(0,d.useState)(null),[R,S]=(0,d.useState)(!1),[T,U]=(0,d.useState)([]),[V,W]=(0,d.useState)(!1),[X,Y]=(0,d.useState)(null),[Z,$]=(0,d.useState)(null),[_,aa]=(0,d.useState)(!1),[ab,ac]=(0,d.useState)(!1),ad=(0,d.useMemo)(()=>k.map(a=>a.path).filter(Boolean),[k]),ae=(0,d.useMemo)(()=>(0,e.v3)(ad),[ad]),af=(0,d.useMemo)(()=>new Set((0,e.tW)(ae)),[ae]),ag=(0,d.useMemo)(()=>u?g?(0,e.KH)(g,u,w):(0,e.q3)(b,u,w):null,[b,g,u,w]),ah=s??q,ai=(0,d.useRef)(null),aj=(0,d.useCallback)(b=>{ai.current&&clearTimeout(ai.current),ai.current=setTimeout(async()=>{try{await fetch("/api/files/expanded",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,paths:Array.from(b)})})}catch(a){console.error("Error saving expanded paths:",a)}},500)},[a]),ak=(0,d.useCallback)(async()=>{B(!0),F(null);try{let b=await fetch(`/api/files/init?cwd=${encodeURIComponent(a)}`),d=await b.json();d.error?F(d.error):(c(d.files||[]),d.expandedPaths&&Array.isArray(d.expandedPaths)&&r(new Set(d.expandedPaths)))}catch(a){console.error("Error loading files:",a),F("Failed to load files")}finally{B(!1)}},[a]),al=(0,d.useCallback)(async()=>{try{let b=await fetch(`/api/files/index?cwd=${encodeURIComponent(a)}`),c=await b.json();c.paths&&h(c.paths)}catch(a){console.error("Error loading file index:",a)}},[a]),am=(0,d.useCallback)(async b=>{j(a=>new Set([...a,b]));try{let d=await fetch(`/api/files/readdir?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`),f=await d.json();f.children&&c(a=>{if(!b){let b=new Map(a.map(a=>[a.path,a]));return f.children.map(a=>{let c=b.get(a.path);return c?.children&&a.isDirectory?{...a,children:c.children}:a})}let c=structuredClone(a),d=(0,e.MB)(c,b);return d&&(d.children=f.children),c})}catch(a){console.error("Error loading directory:",a)}finally{j(a=>{let c=new Set(a);return c.delete(b),c})}},[a]);(0,d.useRef)(i).current=i;let an=(0,d.useCallback)(async()=>{try{let b=await fetch(`/api/files/recent?cwd=${encodeURIComponent(a)}`),c=await b.json();l(c.files||[])}catch(a){console.error("Error loading recent files:",a)}},[a]),ao=(0,d.useCallback)(async b=>{l(a=>{let c=a.filter(a=>a.path!==b);return[{path:b},...c].slice(0,15)});try{await fetch("/api/files/recent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,file:b})})}catch(a){console.error("Error adding to recent files:",a)}},[a]),ap=(0,d.useCallback)((b,c,d,e)=>{l(a=>a.map(a=>a.path===b?{...a,scrollLine:c,cursorLine:d,cursorCol:e}:a)),fetch("/api/files/recent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,file:b,scrollLine:c,cursorLine:d,cursorCol:e})}).catch(()=>{})},[a]),aq=(0,d.useCallback)(a=>k.find(b=>b.path===a),[k]),ar=(0,d.useCallback)(async b=>{let c=b||m;if(c){W(!0),Y(null);try{let b=await fetch(`/api/files/blame?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(c)}`),d=await b.json();d.error?Y(d.error):U(d.blame||[])}catch(a){console.error("Error loading blame:",a),Y("Failed to load blame info")}finally{W(!1)}}},[a,m]),as=(0,d.useCallback)(async b=>{D(!0),p(null),S(!1),U([]),Y(null),$(null);try{let c=await fetch(`/api/files/stat?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`,{cache:"no-store"}),d=await c.json();if(!c.ok)return void p({type:"error",message:d?.error||"Failed to stat file"});if(!d.exists)return void p({type:"error",message:"File not found"});if("dir"===d.kind)return void p({type:"error",message:"Path is a directory"});switch(d.category){case"image":p({type:"image",size:d.size,mtime:d.mtimeMs,...d.isSymlink?{isSymlink:!0,symlinkTarget:d.symlinkTarget}:{}});break;case"binary":p({type:"binary",message:"Cannot preview binary file",size:d.size,mtime:d.mtimeMs});break;case"too-large":p({type:"error",message:"File too large to preview",size:d.size,mtime:d.mtimeMs});break;default:{let c=await fetch(`/api/files/text?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`,{cache:"no-store"});if(409===c.status){let a=await c.json().catch(()=>({}));p({type:"binary",message:a?.error||"Cannot preview binary file",size:d.size,mtime:d.mtimeMs});break}if(!c.ok){let a=await c.json().catch(()=>({}));p({type:"error",message:a?.error||"Failed to load file"});break}let e=await c.json();p({type:"text",content:e.content,size:e.size,mtime:e.mtimeMs,...e.isSymlink?{isSymlink:!0,symlinkTarget:e.symlinkTarget}:{}})}}ao(b),ar(b)}catch(a){console.error("Error loading file content:",a),p({type:"error",message:"Failed to load file"})}finally{D(!1)}},[a,ao,ar]),at=(0,d.useCallback)(()=>{R?S(!1):(S(!0),0===T.length&&ar())},[R,T.length,ar]),au=(0,d.useCallback)((a,b)=>{if(!a)return;if(n(a),K(b??null),null==b){let b=k.find(b=>b.path===a);b?.scrollLine?(K(b.scrollLine),M("start"),O(b.cursorLine??null),Q(b.cursorCol??null)):(M("center"),O(null),Q(null))}else M("center"),O(null),Q(null);as(a);let c=a.split("/");if(c.length>1){let a=[];for(let b=1;b<c.length;b++)a.push(c.slice(0,b).join("/"));r(b=>{let c=new Set(b),d=!1;for(let b of a)c.has(b)||(c.add(b),d=!0);return d&&aj(c),d?c:b})}},[as,aj,k]),av=(0,d.useCallback)(a=>{if(s)t(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c});else{let c=!q.has(a);if(r(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),aj(c),c}),c){let c=(0,e.MB)(b,a);c&&c.isDirectory&&!c.children&&am(a)}}},[s,aj,q,b,am]);return{files:b,setFiles:c,fileIndex:g,setFileIndex:h,loadingDirs:i,expandedPaths:q,setExpandedPaths:r,searchTreeExpandedPaths:s,setSearchTreeExpandedPaths:t,effectiveExpandedPaths:ah,searchQuery:u,setSearchQuery:v,searchExactMatch:w,setSearchDirExact:x,matchedPaths:ag,creatingItem:y,setCreatingItem:z,isLoadingFiles:A,fileError:E,searchInputRef:G,shouldScrollToSelected:H,setShouldScrollToSelected:I,targetLineNumber:J,setTargetLineNumber:K,targetScrollAlign:L,setTargetScrollAlign:M,initialCursorLine:N,initialCursorCol:P,setInitialCursorLine:O,setInitialCursorCol:Q,selectedPath:m,setSelectedPath:n,fileContent:o,setFileContent:p,isLoadingContent:C,recentFiles:k,recentFilePaths:ad,setRecentFiles:l,recentFilesTree:ae,recentTreeDirPaths:af,showBlame:R,setShowBlame:S,blameLines:T,isLoadingBlame:V,blameError:X,blameSelectedCommit:Z,setBlameSelectedCommit:$,showMarkdownPreview:_,setShowMarkdownPreview:aa,showEditor:ab,setShowEditor:ac,saveExpandedPaths:aj,loadFiles:ak,loadFileIndex:al,loadDirectory:am,loadRecentFiles:an,addToRecentFiles:ao,updateRecentFilePosition:ap,getRecentFilePosition:aq,loadFileContent:as,loadBlame:ar,handleToggleBlame:at,handleSelectFile:au,handleToggle:av}}},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},44218:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},45050:(a,b,c)=>{"use strict";function d(a,b){let c=a.split("\n"),d=b.split("\n"),e=[],f=c.length,g=d.length,h=Array(f+1).fill(null).map(()=>Array(g+1).fill(0));for(let a=1;a<=f;a++)for(let b=1;b<=g;b++)c[a-1]===d[b-1]?h[a][b]=h[a-1][b-1]+1:h[a][b]=Math.max(h[a-1][b],h[a][b-1]);let i=f,j=g,k=[];for(;i>0||j>0;)i>0&&j>0&&c[i-1]===d[j-1]?(k.push({type:"unchanged",content:c[i-1],oldLineNum:i,newLineNum:j}),i--,j--):j>0&&(0===i||h[i][j-1]>=h[i-1][j])?(k.push({type:"added",content:d[j-1],newLineNum:j}),j--):(k.push({type:"removed",content:c[i-1],oldLineNum:i}),i--);for(;k.length>0;)e.push(k.pop());return e}c.d(b,{X:()=>d})},45832:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{D:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(46674),i=c(5811),j=a([i]);function k({results:a,loading:b,totalMatches:c,onSelect:d,onClose:i}){let{t:j}=(0,g.Bd)(),l=function(){let[a,b]=(0,f.useState)(new Map),[c,d]=(0,f.useState)(!1);return(0,f.useRef)(0),a}();return(0,e.jsxs)("div",{className:"border-t border-border bg-secondary flex flex-col",style:{height:"300px"},children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[j("searchResults.title")," ",!b&&j("searchResults.nMatches",{count:c})]}),(0,e.jsx)("button",{onClick:i,className:"p-0.5 rounded hover:bg-accent text-muted-foreground",children:(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:j("searchResults.searching")}):0===a.length?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:j("searchResults.noResults")}):a.map(a=>(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card/30 sticky top-0",children:a.path}),a.matches.map((b,c)=>{let f=`${a.path}:${b.lineNumber}`,g=l.get(f);return(0,e.jsxs)("button",{onClick:()=>d(a.path,b.lineNumber),className:"w-full text-left px-3 py-0.5 hover:bg-accent/50 flex items-baseline gap-2 group",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:b.lineNumber}),g?(0,e.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:g}}):(0,e.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:b.content||""})]},`${b.lineNumber}-${c}`)})]},a.path))})]})}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},46674:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},47237:(a,b,c)=>{"use strict";c.d(b,{Q:()=>e});var d=c(67484);function e(){let a=(0,d.useRef)([]),b=(0,d.useRef)([]),c=(0,d.useCallback)(c=>{a.current.push(c),a.current.length>50&&(a.current=a.current.slice(-50)),b.current=[]},[]),e=(0,d.useCallback)(c=>{if(0===a.current.length)return null;let d=a.current.pop();return b.current.push(c),b.current.length>50&&(b.current=b.current.slice(-50)),d},[]),f=(0,d.useCallback)(c=>{if(0===b.current.length)return null;let d=b.current.pop();return a.current.push(c),a.current.length>50&&(a.current=a.current.slice(-50)),d},[]);return{push:c,goBack:e,goForward:f,canGoBack:(0,d.useCallback)(()=>a.current.length>0,[]),canGoForward:(0,d.useCallback)(()=>b.current.length>0,[])}}},47408:(a,b,c)=>{"use strict";c.d(b,{A:()=>i});var d=c(67484);let e=(...a)=>a.filter((a,b,c)=>!!a&&""!==a.trim()&&c.indexOf(a)===b).join(" ").trim(),f=a=>{let b=a.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,b,c)=>c?c.toUpperCase():b.toLowerCase());return b.charAt(0).toUpperCase()+b.slice(1)};var g={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let h=(0,d.forwardRef)(({color:a="currentColor",size:b=24,strokeWidth:c=2,absoluteStrokeWidth:f,className:h="",children:i,iconNode:j,...k},l)=>(0,d.createElement)("svg",{ref:l,...g,width:b,height:b,stroke:a,strokeWidth:f?24*Number(c)/Number(b):c,className:e("lucide",h),...!i&&!(a=>{for(let b in a)if(b.startsWith("aria-")||"role"===b||"title"===b)return!0;return!1})(k)&&{"aria-hidden":"true"},...k},[...j.map(([a,b])=>(0,d.createElement)(a,b)),...Array.isArray(i)?i:[i]])),i=(a,b)=>{let c=(0,d.forwardRef)(({className:c,...g},i)=>(0,d.createElement)(h,{ref:i,iconNode:b,className:e(`lucide-${f(a).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${a}`,c),...g}));return c.displayName=f(a),c}},47993:(a,b,c)=>{"use strict";c.r(b),c.d(b,{__next_app__:()=>M,handler:()=>O,routeModule:()=>N});var d=c(7553),e=c(84006),f=c(67798),g=c(34775),h=c(99373),i=c(73461),j=c(1020),k=c(26349),l=c(54365),m=c(16023),n=c(63747),o=c(24235),p=c(23938),q=c(261),r=c(66758),s=c(77243),t=c(26713),u=c(37527),v=c(22820),w=c(88216),x=c(47929),y=c(79551),z=c(71797),A=c(89125),B=c(86439),C=c(77068),D=c(27269),E=c(61287),F=c(81494),G=c(70722),H=c(70753),I=c(43954),J=c(17891),K={};for(let a in E)0>["default","__next_app__","routeModule","handler"].indexOf(a)&&(K[a]=()=>E[a]);c.d(b,K);let L={children:["",{children:["project",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,8472)),"/home/runner/work/cockpit/cockpit/src/app/project/page.tsx"]}]},{"global-error":[()=>Promise.resolve().then(c.bind(c,81227)),"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}},[]]},{layout:[()=>Promise.resolve().then(c.bind(c,76537)),"/home/runner/work/cockpit/cockpit/src/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.bind(c,81227)),"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,55091,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,45270,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,28193,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}},[]]}.children,M={require:c,loadChunk:()=>Promise.resolve()},N=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/project/page",pathname:"/project",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:L},distDir:".next-prod",relativeProjectDir:""});async function O(a,b,d){var K,P,Q,R,S;d.requestMeta&&(0,h.setRequestMeta)(a,d.requestMeta),N.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let T=!!(0,h.getRequestMeta)(a,"minimalMode"),U="/project/page";"/index"===U&&(U="/");let V=await N.prepare(a,b,{srcPage:U,multiZoneDraftMode:!1});if(!V)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:W,query:X,params:Y,pageIsDynamic:Z,buildManifest:$,nextFontManifest:_,reactLoadableManifest:aa,serverActionsManifest:ab,clientReferenceManifest:ac,subresourceIntegrityManifest:ad,prerenderManifest:ae,isDraftMode:af,resolvedPathname:ag,revalidateOnlyGenerated:ah,routerServerContext:ai,nextConfig:aj,parsedUrl:ak,interceptionRoutePatterns:al,deploymentId:am,clientAssetToken:an}=V,ao=(0,q.normalizeAppPath)(U),{isOnDemandRevalidate:ap}=V,aq=aj.experimental.ppr&&!aj.cacheComponents&&(0,I.isInterceptionRouteAppPath)(ag)?null:N.match(ag,ae),ar=(null==aq?void 0:aq.route)??null,as=!!ae.routes[ag],at=a.headers["user-agent"]||"",au=(0,t.getBotType)(at),av=(0,p.isHtmlBotRequest)(a),aw=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[s.NEXT_ROUTER_PREFETCH_HEADER],ax=(0,h.getRequestMeta)(a,"isRSCRequest")??!!a.headers[s.RSC_HEADER],ay=(0,r.getIsPossibleServerAction)(a),az=(0,m.checkIsAppPPREnabled)(aj.experimental.ppr),aA=a.headers[x.NEXT_RESUME_STATE_LENGTH_HEADER];if(!(0,h.getRequestMeta)(a,"postponed")&&T&&az&&ay&&aA&&"string"==typeof aA){let e=parseInt(aA,10),{maxPostponedStateSize:f,maxPostponedStateSizeBytes:g}=(0,D.getMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize);if(!isNaN(e)&&e>0){if(e>g)return b.statusCode=413,b.end((0,D.getPostponedStateExceededErrorMessage)(f)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let i="1 MB",j=(null==(S=aj.experimental.serverActions)?void 0:S.bodySizeLimit)??i,k=e+(j!==i?c(95726).parse(j):1048576),l=await (0,D.readBodyWithSizeLimit)(a,k);if(null===l)return b.statusCode=413,b.end("Request body exceeded limit. To configure the body size limit for Server Actions, see: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;if(l.length>=e){let b=l.subarray(0,e).toString("utf8");(0,h.addRequestMeta)(a,"postponed",b);let c=l.subarray(e);(0,h.addRequestMeta)(a,"actionBody",c)}else throw Object.defineProperty(Error(`invariant: expected ${e} bytes of postponed state but only received ${l.length} bytes`),"__NEXT_ERROR_CODE",{value:"E979",enumerable:!1,configurable:!0})}}if(!(0,h.getRequestMeta)(a,"postponed")&&az&&"1"===a.headers[x.NEXT_RESUME_HEADER]&&"POST"===a.method){let{maxPostponedStateSize:c,maxPostponedStateSizeBytes:e}=(0,D.getMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize),f=await (0,D.readBodyWithSizeLimit)(a,e);if(null===f)return b.statusCode=413,b.end((0,D.getPostponedStateExceededErrorMessage)(c)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let g=f.toString("utf8");(0,h.addRequestMeta)(a,"postponed",g)}let aB=!0===N.isDev||!0===aj.experimental.exposeTestingApiInProductionBuild,aC=aB&&("1"===a.headers[s.NEXT_INSTANT_PREFETCH_HEADER]||void 0===a.headers[s.RSC_HEADER]&&"string"==typeof a.headers.cookie&&a.headers.cookie.includes(s.NEXT_INSTANT_TEST_COOKIE+"=")),aD=(az||aC)&&((null==(K=ae.routes[ao]??ae.dynamicRoutes[ao])?void 0:K.renderingMode)==="PARTIALLY_STATIC"||aC&&(aB||(null==ai?void 0:ai.experimentalTestProxy)===!0)),aE=aC&&aD,aF=aE&&!0===N.isDev,aG=!1,aH=aD?(0,h.getRequestMeta)(a,"postponed"):void 0,aI=null==(P=ae.routes[ag])?void 0:P.prefetchDataRoute,aJ=aD&&ax&&!aw&&!aI;T&&(aJ=aJ&&!!aH);let aK=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),aL=(!au||!aD)&&(!at||(0,p.shouldServeStreamingMetadata)(at,aj.htmlLimitedBots)),aM=!!((ar||as||ae.routes[ao])&&!(au&&aD)),aN=aD&&!0===aj.cacheComponents,aO=!0===N.isDev||!aM||"string"==typeof aH||(aN&&(0,h.getRequestMeta)(a,"onCacheEntryV2")?aJ&&!T:aJ),aP=!!au&&aD,aQ=(null==ar?void 0:ar.remainingPrerenderableParams)??[],aR=(null==ar?void 0:ar.fallback)===null&&((null==(Q=ar.fallbackRootParams)?void 0:Q.length)??0)>0,aS=null;if(!af&&aM&&!aO&&!ay&&!aH&&!aJ){let a=aq?"string"==typeof(null==ar?void 0:ar.fallback)?ar.fallback:aq.source:null;if(!0===aj.experimental.partialFallbacks&&a&&(null==ar?void 0:ar.fallbackRouteParams)&&!aR){if(aQ.length>0){let b,c=(b=new Map(aQ.map(a=>[a.paramName,a])),a.split("/").map(a=>{let c=(0,J.getSegmentParam)(a);if(!c)return a;let d=b.get(c.paramName);if(!d)return a;let e=null==Y?void 0:Y[d.paramName];if(!e)return a;let f=Array.isArray(e)?e.map(a=>encodeURIComponent(a)).join("/"):encodeURIComponent(e);return a.replace(function(a){let{repeat:b,optional:c}=(0,J.getParamProperties)(a.paramType);return c?`[[...${a.paramName}]]`:b?`[...${a.paramName}]`:`[${a.paramName}]`}(d),f)}).join("/")||"/");aS=c!==a?c:null}}else aS=ag}let aT=aS;!aT&&(N.isDev||aM&&Z&&(null==ar?void 0:ar.fallbackRouteParams)&&!ay)&&(aT=ag),N.isDev||af||!aM||!ax||aJ||(0,k.d)(a.headers);let aU={...E,tree:L,handler:O,routeModule:N,__next_app__:M};ab&&ac&&(0,o.setManifestsSingleton)({page:U,clientReferenceManifest:ac,serverActionsManifest:ab});let aV=a.method||"GET",aW=(0,g.getTracer)(),aX=aW.getActiveScopeSpan(),aY=!!(null==ai?void 0:ai.isWrappedByNextServer),aZ=!0===aj.experimental.partialFallbacks&&aQ.length>0?(null==ar||null==(R=ar.fallbackRouteParams)?void 0:R.filter(a=>!aQ.some(b=>b.paramName===a.paramName)))??[]:[],a$=async()=>((null==ai?void 0:ai.render404)?await ai.render404(a,b,ak,!1):b.end("This page could not be found"),null);try{let k,m=N.getVaryHeader(ag,al);b.setHeader("Vary",m);let o=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return N.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let a=aW.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let d=a.get("next.route");if(d){let a=`${aV} ${d}`;c.setAttributes({"next.route":d,"http.route":d,"next.span_name":a}),c.updateName(a),k&&k!==c&&(k.setAttribute("http.route",d),k.updateName(a))}else c.updateName(`${aV} ${U}`)})},p=(0,h.getRequestMeta)(a,"incrementalCache")||await N.getIncrementalCache(a,aj,ae,T);null==p||p.resetRequestCache(),globalThis.__incrementalCache=p;let q=async({span:e,postponed:f,fallbackRouteParams:g,forceStaticRender:i})=>{let k={query:X,params:Y,page:ao,sharedContext:{buildId:W,deploymentId:am,clientAssetToken:an},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aU,Component:(0,j.T)(aU),params:Y,routeModule:N,page:U,postponed:f,shouldWaitOnAllReady:aP,serveStreamingMetadata:aL,supportsDynamicResponse:"string"==typeof f||aO,buildManifest:$,nextFontManifest:_,reactLoadableManifest:aa,subresourceIntegrityManifest:ad,setCacheStatus:null==ai?void 0:ai.setCacheStatus,setIsrStatus:null==ai?void 0:ai.setIsrStatus,setReactDebugChannel:null==ai?void 0:ai.setReactDebugChannel,sendErrorsToBrowser:null==ai?void 0:ai.sendErrorsToBrowser,dir:c(33873).join(process.cwd(),N.relativeProjectDir),isDraftMode:af,botType:au,isOnDemandRevalidate:ap,isPossibleServerAction:ay,assetPrefix:aj.assetPrefix,nextConfigOutput:aj.output,crossOrigin:aj.crossOrigin,trailingSlash:aj.trailingSlash,images:aj.images,previewProps:ae.preview,enableTainting:aj.experimental.taint,htmlLimitedBots:aj.htmlLimitedBots,reactMaxHeadersLength:aj.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:p,cacheLifeProfiles:aj.cacheLife,basePath:aj.basePath,serverActions:aj.experimental.serverActions,logServerFunctions:"object"==typeof aj.logging&&!!aj.logging.serverFunctions,...aE||aF||aG?{isBuildTimePrerendering:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isDebugDynamicAccesses:aF}:{},cacheComponents:!!aj.cacheComponents,experimental:{isRoutePPREnabled:aD,expireTime:aj.expireTime,staleTimes:aj.experimental.staleTimes,dynamicOnHover:!!aj.experimental.dynamicOnHover,optimisticRouting:!!aj.experimental.optimisticRouting,inlineCss:!!aj.experimental.inlineCss,prefetchInlining:aj.experimental.prefetchInlining??!1,authInterrupts:!!aj.experimental.authInterrupts,cachedNavigations:!!aj.experimental.cachedNavigations,clientTraceMetadata:aj.experimental.clientTraceMetadata||[],clientParamParsingOrigins:aj.experimental.clientParamParsingOrigins,maxPostponedStateSizeBytes:(0,C.parseMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize)},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d,e)=>N.onRequestError(a,b,d,e,ai),err:(0,h.getRequestMeta)(a,"invokeError")}};i&&(k.renderOpts.supportsDynamicResponse=!1);let l=await o(e,k),{metadata:m}=l,{cacheControl:n,headers:q={},fetchTags:r,fetchMetrics:s}=m;if(r&&(q[x.NEXT_CACHE_TAGS_HEADER]=r),a.fetchMetrics=s,aM&&(null==n?void 0:n.revalidate)===0&&!N.isDev&&!aD){let a=m.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${ag}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
4
- see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:u.CachedRouteKind.APP_PAGE,html:l,headers:q,rscData:m.flightData,postponed:m.postponed,status:m.statusCode,segmentData:m.segmentData},cacheControl:n}},r=async({hasResolved:c,previousCacheEntry:g,isRevalidating:i,span:j,forceStaticRender:k=!1})=>{let l=!1===N.isDev,m=c||b.writableEnded;try{let f;if(ap&&ah&&!g&&!T)return(null==ai?void 0:ai.render404)?await ai.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(ar&&(f=(0,v.parseFallbackField)(ar.fallback)),!0===aj.experimental.partialFallbacks&&(null==ar?void 0:ar.fallback)===null&&!aR&&aQ.length>0&&(f=v.FallbackMode.PRERENDER),f===v.FallbackMode.PRERENDER&&(0,t.isBot)(at)&&(!aD||av)&&(f=v.FallbackMode.BLOCKING_STATIC_RENDER),(null==g?void 0:g.isStale)===-1&&(ap=!0),ap&&(f!==v.FallbackMode.NOT_FOUND||g)&&(f=v.FallbackMode.BLOCKING_STATIC_RENDER),!T&&f!==v.FallbackMode.BLOCKING_STATIC_RENDER&&aT&&!m&&!af&&Z&&(l||!as)){if((l||ar)&&f===v.FallbackMode.NOT_FOUND){if(aj.adapterPath)return await a$();throw new B.NoFallbackError}if(aD&&(aj.cacheComponents?!aJ:!ax)){let b=l&&"string"==typeof(null==ar?void 0:ar.fallback)?ar.fallback:ao,f=(l||aE)&&(null==ar?void 0:ar.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams):aG?(0,n.getFallbackRouteParams)(ao,N):null;aE&&f&&(0,h.addRequestMeta)(a,"fallbackParams",f);let g=await N.handleResponse({cacheKey:b,req:a,nextConfig:aj,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:ae,isRoutePPREnabled:aD,responseGenerator:async()=>q({span:j,postponed:void 0,fallbackRouteParams:f,forceStaticRender:!0}),waitUntil:d.waitUntil,isMinimalMode:T});if(null===g)return null;if(g)return T||!aD||!(aQ.length>0)||!0!==aj.experimental.partialFallbacks||!aS||!p||ap||aG||aB||aC||aw||(0,H.scheduleOnNextTick)(async()=>{let b=N.getResponseCache(a);try{await b.revalidate(aS,p,aD,!1,a=>q({span:a.span,postponed:void 0,fallbackRouteParams:aZ.length>0?(0,n.createOpaqueFallbackRouteParams)(aZ):null,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}),delete g.cacheControl,g}}let o=ap||i||!aH?void 0:aH;if(aN&&!T&&p&&(aJ||ay)&&!k){let b=await p.get(ag,{kind:u.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===u.CachedRouteKind.APP_PAGE&&(o=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,H.scheduleOnNextTick)(async()=>{let b=N.getResponseCache(a);try{await b.revalidate(ag,p,aD,!1,a=>r({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if((aE||aF)&&void 0!==o)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:u.CachedRouteKind.PAGES,html:w.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let s=(l&&(0,h.getRequestMeta)(a,"renderFallbackShell")||aE&&!as)&&(null==ar?void 0:ar.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams):aG?(0,n.getFallbackRouteParams)(ao,N):null;if((l||aE)&&aj.cacheComponents&&!as&&(null==ar?void 0:ar.fallbackRouteParams)){let b=(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams);b&&(0,h.addRequestMeta)(a,"fallbackParams",b)}return q({span:j,postponed:o,fallbackRouteParams:s,forceStaticRender:k})}catch(b){throw(null==g?void 0:g.isStale)&&await N.onRequestError(a,b,{routerKind:"App Router",routePath:U,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aM,isOnDemandRevalidate:ap})},!1,ai),b}},D=async c=>{var f,g,i,j,k;let l,m=await N.handleResponse({cacheKey:aS,responseGenerator:a=>r({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ap,isRoutePPREnabled:aD,req:a,nextConfig:aj,prerenderManifest:ae,waitUntil:d.waitUntil,isMinimalMode:T});if(af&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),N.isDev&&b.setHeader("Cache-Control","no-cache, must-revalidate"),!m){if(aS)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=m.value)?void 0:f.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=m.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let n="string"==typeof m.value.postponed;ax&&!ay&&am&&b.setHeader(x.NEXT_NAV_DEPLOYMENT_ID_HEADER,am),aM&&!aJ&&(!n||aw)&&(T||b.setHeader("x-nextjs-cache",ap?"REVALIDATED":m.isMiss?"MISS":m.isStale?"STALE":"HIT"),b.setHeader(s.NEXT_IS_PRERENDER_HEADER,"1"));let{value:o}=m;if(aH)l={revalidate:0,expire:void 0};else if(aJ)l={revalidate:0,expire:void 0};else if(!N.isDev)if(af)l={revalidate:0,expire:void 0};else if(aM){if(m.cacheControl)if("number"==typeof m.cacheControl.revalidate){if(m.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${m.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:m.cacheControl.revalidate,expire:(null==(j=m.cacheControl)?void 0:j.expire)??aj.expireTime}}else l={revalidate:x.CACHE_ONE_YEAR_SECONDS,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(m.cacheControl=l,"string"==typeof aK&&(null==o?void 0:o.kind)===u.CachedRouteKind.APP_PAGE&&o.segmentData){b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=o.headers)?void 0:k[x.NEXT_CACHE_TAGS_HEADER];T&&aM&&c&&"string"==typeof c&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,c);let d=o.segmentData.get(aK);return void 0!==d?(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.fromStatic(d,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl}):(b.statusCode=204,(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl}))}let p=aN?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(p&&await p(m,{url:(0,h.getRequestMeta)(a,"initURL")??a.url}))return null;if(o.headers){let a={...o.headers};for(let[c,d]of(T&&aM||delete a[x.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let t=null==(g=o.headers)?void 0:g[x.NEXT_CACHE_TAGS_HEADER];if(T&&aM&&t&&"string"==typeof t&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,t),!o.status||ax&&aD||(b.statusCode=o.status),!T&&o.status&&F.RedirectStatusCode[o.status]&&ax&&(b.statusCode=200),n&&!aJ&&b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"1"),ax&&!af){if(void 0===o.rscData){if(o.html.contentType!==s.RSC_CONTENT_TYPE_HEADER)if(aj.cacheComponents)return b.statusCode=404,(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl});else throw Object.defineProperty(new G.InvariantError(`Expected RSC response, got ${o.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:o.html,cacheControl:m.cacheControl})}return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.fromStatic(o.rscData,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl})}let v=o.html;if(aC&&aE){let c=!0===N.isDev?crypto.randomUUID():null;return v.pipeThrough((0,z.createInstantTestScriptInsertionTransformStream)(c)),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})}if(!n||T||ax)return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:m.cacheControl});if(aE||aF)return v.push(new ReadableStream({start(a){a.enqueue(y.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}});let B=new TransformStream;return v.push(B.readable),q({span:c,postponed:o.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(B.writable)}).catch(a=>{B.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})};if(!aY||!aX)return k=aW.getActiveScopeSpan(),await aW.withPropagatedContext(a.headers,()=>aW.trace(i.BaseServerSpan.handleRequest,{spanName:`${aV} ${U}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aV,"http.target":a.url}},D),void 0,!aY);await D(aX)}catch(b){throw b instanceof B.NoFallbackError||await N.onRequestError(a,b,{routerKind:"App Router",routePath:U,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aM,isOnDemandRevalidate:ap})},!1,ai),b}}},48464:(a,b,c)=>{"use strict";c.d(b,{V:()=>k});var d=c(48249),e=c(67484),f=c(69005),g=c(31172),h=c(44384);function i({number:a,isActive:b}){return(0,d.jsxs)("svg",{className:`w-5 h-5 flex-shrink-0 ${b?"text-brand":"text-muted-foreground"}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,d.jsx)("text",{x:"12",y:"16",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"12",fontWeight:"500",children:a})]})}function j({onNewTab:a,onNewClaude2Tab:b,onNewCodexTab:c,onNewKimiTab:f,onNewOllamaTab:h,onNewDeepseekTab:i}){let[k,l]=(0,e.useState)(!1),m=(0,e.useRef)(null),n=(0,e.useRef)(null),[o,p]=(0,e.useState)({top:0,right:0}),q=(0,g.F2)(),r=d=>{l(!1),"claude2"===d?b?.():"codex"===d?c?.():"kimi"===d?f?.():"ollama"===d?h?.():"deepseek"===d?i?.():a()};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{ref:m,onClick:()=>{if(!k&&m.current){let a=m.current.getBoundingClientRect(),b=q?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0,e=b?.width??window.innerWidth;p({top:a.bottom+4-d,right:e-(a.right-c)})}l(a=>!a)},className:"flex-shrink-0 p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:"New tab",children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),k&&(0,d.jsx)(g.ZL,{children:(0,d.jsxs)("div",{ref:n,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lg py-1 min-w-[140px]",style:{top:o.top,right:o.right},children:[(0,d.jsxs)("button",{onClick:()=>r("claude"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}),"Claude Code"]}),(0,d.jsxs)("button",{onClick:()=>r("claude2"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-orange-500 flex-shrink-0"}),"Claude 2"]}),(0,d.jsxs)("button",{onClick:()=>r("codex"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),"OpenAI Codex"]}),(0,d.jsxs)("button",{onClick:()=>r("deepseek"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),"Deepseek"]}),(0,d.jsxs)("button",{onClick:()=>r("kimi"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-blue-500 flex-shrink-0"}),"Kimi"]}),(0,d.jsxs)("button",{onClick:()=>r("ollama"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-violet-500 flex-shrink-0"}),"Ollama"]})]})})]})}function k({tabs:a,activeTabId:b,unreadTabs:c,dragTabIndex:e,dragOverTabIndex:g,isPinned:l,onTogglePin:m,onSwitchTab:n,onCloseTab:o,onNewTab:p,onNewClaude2Tab:q,onNewCodexTab:r,onNewKimiTab:s,onNewOllamaTab:t,onNewDeepseekTab:u,onDragStart:v,onDragOver:w,onDrop:x,onDragEnd:y}){let{t:z}=(0,h.Bd)();return(0,d.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,d.jsxs)("div",{className:"flex items-center px-2 gap-1 overflow-x-auto",children:[a.map((h,j)=>(0,d.jsx)(f.m,{content:h.title,delay:200,className:"flex-1 min-w-16 max-w-32",children:(0,d.jsxs)("div",{draggable:!0,onDragStart:()=>v(j),onDragOver:a=>w(a,j),onDrop:()=>x(j),onDragEnd:y,className:`group flex items-center gap-1 px-3 py-1.5 text-sm cursor-pointer rounded-t-lg transition-colors ${h.id===b?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary"} ${e===j?"opacity-50":""} ${g===j?"border-l-2 border-brand":""}`,onClick:()=>n(h.id),children:[(0,d.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,d.jsx)(i,{number:j+1,isActive:h.id===b}),h.isLoading&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"}),!h.isLoading&&c.has(h.id)&&h.id!==b&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),m&&l?.(h.id)&&!h.isLoading&&!(c.has(h.id)&&h.id!==b)&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),m(h.id)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center rounded-full bg-card text-amber-500 hover:text-destructive transition-colors",title:z("tabBar.unpin"),children:(0,d.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M16 4h-2V2h-4v2H8c-.55 0-1 .45-1 1v4l-2 3v2h5.97v7l1 1 1-1v-7H19v-2l-2-3V5c0-.55-.45-1-1-1z"})})}),m&&!l?.(h.id)&&!h.isLoading&&!(c.has(h.id)&&h.id!==b)&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),m(h.id)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center rounded-full bg-card text-muted-foreground opacity-0 group-hover:opacity-60 hover:!opacity-100 hover:!text-brand transition-all",title:z("tabBar.pin"),children:(0,d.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,children:(0,d.jsx)("path",{d:"M16 4h-2V2h-4v2H8c-.55 0-1 .45-1 1v4l-2 3v2h5.97v7l1 1 1-1v-7H19v-2l-2-3V5c0-.55-.45-1-1-1z"})})})]}),(0,d.jsx)("span",{className:"flex-1 min-w-0 truncate",children:h.title}),"claude2"===h.engine&&(0,d.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-orange-500/15 text-orange-400 font-medium leading-relaxed",children:"C2"}),"codex"===h.engine&&(0,d.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-emerald-500/15 text-emerald-400 font-medium leading-relaxed",children:"CX"}),"kimi"===h.engine&&(0,d.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-blue-500/15 text-blue-400 font-medium leading-relaxed",children:"KM"}),"ollama"===h.engine&&(0,d.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-violet-500/15 text-violet-400 font-medium leading-relaxed",children:"OL"}),"deepseek"===h.engine&&(0,d.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-sky-500/15 text-sky-400 font-medium leading-relaxed",children:"DS"}),a.length>1&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),o(h.id)},className:"ml-1 p-0.5 rounded hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:z("tabBar.closeTab"),children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},h.id)),(0,d.jsx)(j,{onNewTab:p,onNewClaude2Tab:q,onNewCodexTab:r,onNewKimiTab:s,onNewOllamaTab:t,onNewDeepseekTab:u})]})})}},49681:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},50099:(a,b,c)=>{"use strict";c.d(b,{J:()=>bf});var d,e,f,g,h,i=c(48249),j=c(67484),k=c(44384),l=c(46674),m=c(15273),n=c(47408);let o=(0,n.A)("clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]),p=(0,n.A)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);var q=c(10316),r=c(72419),s=c(44218),t=c(81749),u=function(a,b){return Object.defineProperty?Object.defineProperty(a,"raw",{value:b}):a.raw=b,a};(d=e||(e={}))[d.EOS=0]="EOS",d[d.Text=1]="Text",d[d.Incomplete=2]="Incomplete",d[d.ESC=3]="ESC",d[d.Unknown=4]="Unknown",d[d.SGR=5]="SGR",d[d.OSCURL=6]="OSCURL";class v{constructor(){this.VERSION="6.0.6",this.setup_palettes(),this._use_classes=!1,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1,this.fg=this.bg=null,this._buffer="",this._url_allowlist={http:1,https:1},this._escape_html=!0,this.boldStyle="font-weight:bold",this.faintStyle="opacity:0.7",this.italicStyle="font-style:italic",this.underlineStyle="text-decoration:underline"}set use_classes(a){this._use_classes=a}get use_classes(){return this._use_classes}set url_allowlist(a){this._url_allowlist=a}get url_allowlist(){return this._url_allowlist}set escape_html(a){this._escape_html=a}get escape_html(){return this._escape_html}set boldStyle(a){this._boldStyle=a}get boldStyle(){return this._boldStyle}set faintStyle(a){this._faintStyle=a}get faintStyle(){return this._faintStyle}set italicStyle(a){this._italicStyle=a}get italicStyle(){return this._italicStyle}set underlineStyle(a){this._underlineStyle=a}get underlineStyle(){return this._underlineStyle}setup_palettes(){this.ansi_colors=[[{rgb:[0,0,0],class_name:"ansi-black"},{rgb:[187,0,0],class_name:"ansi-red"},{rgb:[0,187,0],class_name:"ansi-green"},{rgb:[187,187,0],class_name:"ansi-yellow"},{rgb:[0,0,187],class_name:"ansi-blue"},{rgb:[187,0,187],class_name:"ansi-magenta"},{rgb:[0,187,187],class_name:"ansi-cyan"},{rgb:[255,255,255],class_name:"ansi-white"}],[{rgb:[85,85,85],class_name:"ansi-bright-black"},{rgb:[255,85,85],class_name:"ansi-bright-red"},{rgb:[0,255,0],class_name:"ansi-bright-green"},{rgb:[255,255,85],class_name:"ansi-bright-yellow"},{rgb:[85,85,255],class_name:"ansi-bright-blue"},{rgb:[255,85,255],class_name:"ansi-bright-magenta"},{rgb:[85,255,255],class_name:"ansi-bright-cyan"},{rgb:[255,255,255],class_name:"ansi-bright-white"}]],this.palette_256=[],this.ansi_colors.forEach(a=>{a.forEach(a=>{this.palette_256.push(a)})});let a=[0,95,135,175,215,255];for(let b=0;b<6;++b)for(let c=0;c<6;++c)for(let d=0;d<6;++d){let e={rgb:[a[b],a[c],a[d]],class_name:"truecolor"};this.palette_256.push(e)}let b=8;for(let a=0;a<24;++a,b+=10){let a={rgb:[b,b,b],class_name:"truecolor"};this.palette_256.push(a)}}escape_txt_for_html(a){return this._escape_html?a.replace(/[&<>"']/gm,a=>"&"===a?"&amp;":"<"===a?"&lt;":">"===a?"&gt;":'"'===a?"&quot;":"'"===a?"&#x27;":void 0):a}append_buffer(a){var b=this._buffer+a;this._buffer=b}get_next_packet(){var a={kind:e.EOS,text:"",url:""},b=this._buffer.length;if(0==b)return a;var c=this._buffer.indexOf("\x1b");if(-1==c)return a.kind=e.Text,a.text=this._buffer,this._buffer="",a;if(c>0)return a.kind=e.Text,a.text=this._buffer.slice(0,c),this._buffer=this._buffer.slice(c),a;if(0==c){if(b<3)return a.kind=e.Incomplete,a;var d=this._buffer.charAt(1);if("["!=d&&"]"!=d&&"("!=d)return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a;if("["==d){this._csi_regex||(this._csi_regex=w(f||(f=u(["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \x1b[ # CSI\n ([<-?]?) # private-mode char\n ([d;]*) # any digits or semicolons\n ([ -/]? # an intermediate modifier\n [@-~]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \x1b[ # CSI\n [ -~]* # anything legal\n ([\0-\x1f:]) # anything illegal\n )\n "],["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \\x1b\\[ # CSI\n ([\\x3c-\\x3f]?) # private-mode char\n ([\\d;]*) # any digits or semicolons\n ([\\x20-\\x2f]? # an intermediate modifier\n [\\x40-\\x7e]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \\x1b\\[ # CSI\n [\\x20-\\x7e]* # anything legal\n ([\\x00-\\x1f:]) # anything illegal\n )\n "]))));let b=this._buffer.match(this._csi_regex);if(null===b)return a.kind=e.Incomplete,a;if(b[4])return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a;""!=b[1]||"m"!=b[3]?a.kind=e.Unknown:a.kind=e.SGR,a.text=b[2];var i=b[0].length;return this._buffer=this._buffer.slice(i),a}if("]"==d){if(b<4)return a.kind=e.Incomplete,a;if("8"!=this._buffer.charAt(2)||";"!=this._buffer.charAt(3))return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a;this._osc_st||(this._osc_st=RegExp((g||(g=u(["\n (?: # legal sequence\n (\x1b\\) # ESC | # alternate\n (\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\0-\x06] # anything illegal\n | # alternate\n [\b-\x1a] # anything illegal\n | # alternate\n [\x1c-\x1f] # anything illegal\n )\n "],["\n (?: # legal sequence\n (\\x1b\\\\) # ESC \\\n | # alternate\n (\\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\\x00-\\x06] # anything illegal\n | # alternate\n [\\x08-\\x1a] # anything illegal\n | # alternate\n [\\x1c-\\x1f] # anything illegal\n )\n "]))).raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,""),"g")),this._osc_st.lastIndex=0;{let b=this._osc_st.exec(this._buffer);if(null===b)return a.kind=e.Incomplete,a;if(b[3])return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a}{let b=this._osc_st.exec(this._buffer);if(null===b)return a.kind=e.Incomplete,a;if(b[3])return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a}this._osc_regex||(this._osc_regex=w(h||(h=u(["\n ^ # beginning of line\n #\n \x1b]8; # OSC Hyperlink\n [ -:<-~]* # params (excluding ;)\n ; # end of params\n ([!-~]{0,512}) # URL capture\n (?: # ST\n (?:\x1b\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n ([ -~]+) # TEXT capture\n \x1b]8;; # OSC Hyperlink End\n (?: # ST\n (?:\x1b\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n "],["\n ^ # beginning of line\n #\n \\x1b\\]8; # OSC Hyperlink\n [\\x20-\\x3a\\x3c-\\x7e]* # params (excluding ;)\n ; # end of params\n ([\\x21-\\x7e]{0,512}) # URL capture\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n ([\\x20-\\x7e]+) # TEXT capture\n \\x1b\\]8;; # OSC Hyperlink End\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n "]))));let c=this._buffer.match(this._osc_regex);if(null===c)return a.kind=e.ESC,a.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),a;a.kind=e.OSCURL,a.url=c[1],a.text=c[2];var i=c[0].length;return this._buffer=this._buffer.slice(i),a}if("("==d)return a.kind=e.Unknown,this._buffer=this._buffer.slice(3),a}}ansi_to_html(a){this.append_buffer(a);for(var b=[];;){var c=this.get_next_packet();if(c.kind==e.EOS||c.kind==e.Incomplete)break;c.kind!=e.ESC&&c.kind!=e.Unknown&&(c.kind==e.Text?b.push(this.transform_to_html(this.with_state(c))):c.kind==e.SGR?this.process_ansi(c):c.kind==e.OSCURL&&b.push(this.process_hyperlink(c)))}return b.join("")}with_state(a){return{bold:this.bold,faint:this.faint,italic:this.italic,underline:this.underline,fg:this.fg,bg:this.bg,text:a.text}}process_ansi(a){let b=a.text.split(";");for(;b.length>0;){let a=parseInt(b.shift(),10);if(isNaN(a)||0===a)this.fg=null,this.bg=null,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1;else if(1===a)this.bold=!0;else if(2===a)this.faint=!0;else if(3===a)this.italic=!0;else if(4===a)this.underline=!0;else if(21===a)this.bold=!1;else if(22===a)this.faint=!1,this.bold=!1;else if(23===a)this.italic=!1;else if(24===a)this.underline=!1;else if(39===a)this.fg=null;else if(49===a)this.bg=null;else if(a>=30&&a<38)this.fg=this.ansi_colors[0][a-30];else if(a>=40&&a<48)this.bg=this.ansi_colors[0][a-40];else if(a>=90&&a<98)this.fg=this.ansi_colors[1][a-90];else if(a>=100&&a<108)this.bg=this.ansi_colors[1][a-100];else if((38===a||48===a)&&b.length>0){let c=38===a,d=b.shift();if("5"===d&&b.length>0){let a=parseInt(b.shift(),10);a>=0&&a<=255&&(c?this.fg=this.palette_256[a]:this.bg=this.palette_256[a])}if("2"===d&&b.length>2){let a=parseInt(b.shift(),10),d=parseInt(b.shift(),10),e=parseInt(b.shift(),10);if(a>=0&&a<=255&&d>=0&&d<=255&&e>=0&&e<=255){let b={rgb:[a,d,e],class_name:"truecolor"};c?this.fg=b:this.bg=b}}}}}transform_to_html(a){let b=a.text;if(0===b.length||(b=this.escape_txt_for_html(b),!a.bold&&!a.italic&&!a.faint&&!a.underline&&null===a.fg&&null===a.bg))return b;let c=[],d=[],e=a.fg,f=a.bg;a.bold&&c.push(this._boldStyle),a.faint&&c.push(this._faintStyle),a.italic&&c.push(this._italicStyle),a.underline&&c.push(this._underlineStyle),this._use_classes?(e&&("truecolor"!==e.class_name?d.push(`${e.class_name}-fg`):c.push(`color:rgb(${e.rgb.join(",")})`)),f&&("truecolor"!==f.class_name?d.push(`${f.class_name}-bg`):c.push(`background-color:rgb(${f.rgb.join(",")})`))):(e&&c.push(`color:rgb(${e.rgb.join(",")})`),f&&c.push(`background-color:rgb(${f.rgb})`));let g="",h="";return d.length&&(g=` class="${d.join(" ")}"`),c.length&&(h=` style="${c.join(";")}"`),`<span${h}${g}>${b}</span>`}process_hyperlink(a){let b=a.url.split(":");return b.length<1||!this._url_allowlist[b[0]]?"":`<a href="${this.escape_txt_for_html(a.url)}">${this.escape_txt_for_html(a.text)}</a>`}}function w(a){return new RegExp(a.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,""))}function x(a){let b=function(a){let b=0xffffffff;for(let c=0;c<a.length;c++){b^=a.charCodeAt(c);for(let a=0;a<8;a++)b=b>>>1^(1&b?0xedb88320:0)}return(0xffffffff^b)>>>0}(a),c="",d=b;for(let a=0;a<4;a++)c+=String.fromCharCode(97+d%26),d=Math.floor(d/26);return c}let y=(0,j.memo)(function({shortId:a,type:b,onRegister:c,onUnregister:d}){let{t:e}=(0,k.Bd)(),[f,g]=(0,j.useState)(!1),h=(0,j.useCallback)(async h=>{if(h.stopPropagation(),f)await d(),g(!1),(0,t.oR)(e("toast.disconnected",{id:a}));else{await c(),g(!0);let d=`cock ${b} ${a}`;navigator.clipboard.writeText(d),(0,t.oR)(e("toast.copiedCommand",{command:d}))}},[f,a,b,c,d,e]);return(0,i.jsxs)("button",{onClick:h,className:"inline-flex items-center gap-1 text-[10px] font-mono leading-none px-1.5 py-0.5 rounded flex-shrink-0 transition-colors bg-muted/60 hover:bg-muted text-muted-foreground",title:f?e("shortIdBadge.clickToDisconnect"):e("shortIdBadge.clickToRegister"),children:[(0,i.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${f?"bg-green-500":"bg-muted-foreground/40"}`}),a]})});var z=c(30976);let A=(0,j.lazy)(()=>c.e(4490).then(c.bind(c,54490)).then(a=>({default:a.XtermRenderer}))),B={c:"\x03",d:"\x04",z:"\x1a",l:"\f",a:"\x01",e:"\x05",u:"\x15",w:"\x17"},C=/\x1b\[[0-9;]*m/g;function D({output:a,query:b,mode:c,currentIdx:d,matchListRef:e}){let f=(0,j.useRef)(null);f.current||(f.current=new v,f.current.use_classes=!0);let g=a.split("\n"),h=b.toLowerCase(),k=0;return e.current=[],(0,i.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap break-words select-text",children:g.map((a,b)=>{let g=a.replace(C,""),j=g.toLowerCase().includes(h);if("filter"===c&&!j)return null;if(!j){let c=f.current.ansi_to_html(a);return(0,i.jsx)("div",{dangerouslySetInnerHTML:{__html:c}},b)}let l=[],m=0,n=g.toLowerCase(),o=0;for(;o<n.length;){let a=n.indexOf(h,o);if(-1===a)break;a>m&&l.push((0,i.jsx)("span",{children:g.slice(m,a)},`t${m}`));let b=k++,c=b===d;l.push((0,i.jsx)("mark",{ref:a=>{e.current[b]=a},className:c?"bg-brand/40 text-foreground":"bg-yellow-300/40 text-foreground",children:g.slice(a,a+h.length)},`m${a}`)),o=m=a+h.length}return m<g.length&&l.push((0,i.jsx)("span",{children:g.slice(m)},`t${m}`)),(0,i.jsx)("div",{children:l},b)})})}let E=(0,j.memo)(function({commandId:a,tabId:b,projectCwd:c,command:d,output:e,exitCode:f,isRunning:g,selected:h,onSelect:n,onInterrupt:u,onStdin:w,onDelete:C,onRerun:E,timestamp:F,usePty:G,subscribePtyOutput:H,subscribePtyReset:I,onPtyResize:J,onToggleMaximize:K,maximized:L,expandedHeight:M,bubbleContentHeight:N,onTitleMouseDown:O}){let{t:P}=(0,k.Bd)(),Q=(0,j.useRef)(null),R=(0,j.useRef)(null),S=(0,j.useRef)(!0),T=(0,j.useRef)(null),U=(0,j.useRef)(null),V=(a=>{if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`})(F),W=a&&b?x(b+a):void 0,[X,Y]=(0,j.useState)(!1),[Z,$]=(0,j.useState)(""),_=(0,j.useRef)(null),aa=(0,j.useRef)(null);(0,j.useEffect)(()=>{if(!H||!a)return;let b=()=>_.current?H(a,_.current.write):null,c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[H,a]),(0,j.useEffect)(()=>{if(!I||!a)return;let b=()=>_.current?I(a,_.current.reset):null,c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[I,a]);let[ab,ac]=(0,j.useState)(!1),[ad,ae]=(0,j.useState)(""),[af,ag]=(0,j.useState)("search"),[ah,ai]=(0,j.useState)(0),aj=(0,j.useRef)([]),ak=(0,j.useRef)(null),al=(0,j.useRef)(0);(0,j.useEffect)(()=>{ak.current||(ak.current=new v,ak.current.use_classes=!0)},[]),(0,j.useLayoutEffect)(()=>{let a=R.current;if(a&&ak.current){if(e.length<al.current&&(ak.current=new v,ak.current.use_classes=!0,al.current=0,a.innerHTML=""),e.length>al.current){let b=e.slice(al.current),c=ak.current.ansi_to_html(b);al.current=e.length,a.insertAdjacentHTML("beforeend",c)}if(Q.current){let a=Q.current.scrollHeight>Q.current.clientHeight;Y(a),a&&(Q.current.scrollTop=Q.current.scrollHeight)}}},[e]),(0,j.useEffect)(()=>(g&&S.current&&Q.current&&(null!==T.current&&cancelAnimationFrame(T.current),T.current=requestAnimationFrame(()=>{Q.current&&(Q.current.scrollTop=Q.current.scrollHeight),T.current=null})),()=>{null!==T.current&&cancelAnimationFrame(T.current)}),[e,g]),(0,j.useEffect)(()=>{if(!L)return;let a=a=>{"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),K?.())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[L,K]);let am=e?e.split("\n").length:0,an=(0,j.useCallback)(()=>{ac(!0),requestAnimationFrame(()=>aa.current?.focus())},[]),ao=(0,j.useCallback)(()=>{ac(!1),ae(""),ai(0),_.current?.clearSearch()},[]),ap=(0,j.useCallback)(a=>{a.trim()&&(G?_.current?.findNext(a):ai(a=>{let b=a+1,c=aj.current[b];return c?(c.scrollIntoView({block:"nearest"}),b):(aj.current[0]?.scrollIntoView({block:"nearest"}),0)}))},[G]),aq=(0,j.useCallback)(a=>{a.trim()&&(G?_.current?.findPrevious(a):ai(a=>{let b=a-1;if(b>=0)return aj.current[b]?.scrollIntoView({block:"nearest"}),b;let c=aj.current.length-1;return c>=0&&aj.current[c]?.scrollIntoView({block:"nearest"}),Math.max(c,0)}))},[G]);(0,j.useEffect)(()=>{if(!h)return;let a=a=>{if((a.metaKey||a.ctrlKey)&&"f"===a.key){a.preventDefault(),a.stopPropagation(),an();return}if("Escape"===a.key&&ab){a.preventDefault(),a.stopPropagation(),ao();return}};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[h,ab,an,ao]);let ar=L&&M?M-41:N??360;return(0,i.jsx)("div",{className:"flex flex-col items-start",children:(0,i.jsxs)("div",{className:`w-full bg-accent text-foreground dark:text-slate-11 relative overflow-hidden border transition-colors cursor-pointer ${L?"rounded-none border-0":"rounded-2xl rounded-bl-md rounded-br-md"} ${L?"":h?"border-brand":"border-brand/30"}`,onClick:n,children:[L?(0,i.jsxs)("div",{onDoubleClick:()=>K?.(),className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41,flexShrink:0},children:[(0,i.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded bg-muted text-muted-foreground",children:">_"}),(0,i.jsx)("span",{className:"flex-1 text-xs text-muted-foreground truncate font-mono",children:d}),g&&(0,i.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,i.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse"}),P("console.runningText")]}),g&&u&&(0,i.jsx)("button",{onClick:u,className:"text-xs px-3 py-1 rounded-md font-medium bg-destructive text-destructive-foreground transition-all duration-150 hover:bg-destructive/80 hover:shadow-md active:scale-95 active:bg-destructive/70 cursor-pointer select-none",children:"Ctrl+C"}),(0,i.jsx)("button",{onClick:()=>K?.(),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:P("console.restoreTooltip",{modKey:(0,z.Mu)()}),children:(0,i.jsx)(l.A,{className:"w-4 h-4"})})]}):(0,i.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>O?.(),onDoubleClick:a=>{a.stopPropagation(),K?.()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing ${h?"border-brand":"border-brand/30"}`,children:[(0,i.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:">_"}),W&&a&&b&&(0,i.jsx)(y,{shortId:W,type:"terminal",onRegister:()=>{fetch("/api/terminal/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tabId:b,commandId:a,command:d,projectCwd:c})}).catch(()=>{})},onUnregister:()=>{fetch("/api/terminal/unregister",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandId:a})}).catch(()=>{})}}),(0,i.jsx)("span",{className:"font-mono text-foreground truncate",children:d}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(d),(0,t.oR)(P("toast.copiedCmd"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:P("console.copyCommand"),children:(0,i.jsx)(m.A,{className:"w-3.5 h-3.5"})}),(0,i.jsx)("span",{className:"flex-1"}),X&&!g&&(0,i.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:P("console.totalLines",{count:am})}),e&&(0,i.jsx)("button",{onClick:a=>{let b;a.stopPropagation(),b=e.replace(/\x1b\[[0-9;]*m/g,""),navigator.clipboard.writeText(b),(0,t.oR)(P("toast.copiedOutput"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:P("console.copyOutput"),children:(0,i.jsx)(o,{className:"w-3.5 h-3.5"})}),E&&(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),E()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:P("console.rerun"),children:(0,i.jsx)(p,{className:"w-3.5 h-3.5"})}),C&&(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),C()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:P("console.deleteRecord"),children:(0,i.jsx)(l.A,{className:"w-3.5 h-3.5"})})]}),ab&&(0,i.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card",style:{flexShrink:0},children:[(0,i.jsx)(q.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),(0,i.jsx)("input",{ref:aa,value:ad,onChange:a=>{let b=a.target.value;ae(b),ai(0),G&&(b.trim()?_.current?.findNext(b):_.current?.clearSearch())},onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?aq(ad):ap(ad))},placeholder:P("console.searchPlaceholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}),!G&&(0,i.jsxs)("div",{className:"flex items-center gap-0.5 text-xs flex-shrink-0",children:[(0,i.jsx)("button",{onClick:()=>ag("search"),className:`px-1.5 py-0.5 rounded transition-colors ${"search"===af?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:P("console.searchMode")}),(0,i.jsx)("button",{onClick:()=>ag("filter"),className:`px-1.5 py-0.5 rounded transition-colors ${"filter"===af?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:P("console.filterMode")})]}),(0,i.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,i.jsx)("button",{onClick:()=>aq(ad),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:P("console.prevShiftEnter"),children:(0,i.jsx)(r.A,{className:"w-3.5 h-3.5"})}),(0,i.jsx)("button",{onClick:()=>ap(ad),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:P("console.nextEnter"),children:(0,i.jsx)(s.A,{className:"w-3.5 h-3.5"})})]}),(0,i.jsx)("button",{onClick:ao,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",children:(0,i.jsx)(l.A,{className:"w-3.5 h-3.5"})})]}),G?(0,i.jsx)("div",{style:{height:ar,overflow:"hidden"},children:(0,i.jsx)(j.Suspense,{fallback:(0,i.jsx)("div",{className:"px-4 py-2 text-xs text-muted-foreground",style:{height:ar},children:P("console.loadingTerminal")}),children:(0,i.jsx)(A,{ref:_,output:e,isRunning:g,onInput:w,onResize:J,maximized:L,height:ar,directWrite:!!H})})}):(0,i.jsx)("div",{ref:Q,className:"overflow-auto px-4 py-2",style:{height:ar},onScroll:()=>{if(Q.current){let{scrollTop:a,scrollHeight:b,clientHeight:c}=Q.current;S.current=b-a-c<50}},children:ab&&ad.trim()?(0,i.jsx)(D,{output:e,query:ad,mode:af,currentIdx:ah,matchListRef:aj}):(0,i.jsx)("pre",{ref:R,className:"text-sm font-mono whitespace-pre-wrap break-words select-text"})}),g&&!L&&(0,i.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2",onClick:a=>a.stopPropagation(),children:[(0,i.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse flex-shrink-0"}),G?(0,i.jsx)("span",{className:"text-xs text-muted-foreground flex-1",children:P("console.clickToInput")}):w?(0,i.jsx)("input",{ref:U,value:Z,onChange:a=>$(a.target.value),onKeyDown:a=>{if(a.ctrlKey&&!a.metaKey&&!a.altKey){let b=B[a.key.toLowerCase()];if(b){a.preventDefault(),a.stopPropagation(),w(b);return}}"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),w(Z+"\n"),$("")),"Tab"===a.key&&(a.preventDefault(),w(" "))},placeholder:P("console.stdinPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs font-mono text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}):(0,i.jsx)("span",{className:"text-xs text-muted-foreground",children:P("console.runningText")}),u&&(0,i.jsx)("button",{onClick:u,className:"flex-shrink-0 text-xs text-destructive hover:brightness-125 transition-colors cursor-pointer select-none",children:"Ctrl+C"}),V&&(0,i.jsx)("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:V})]}),!g&&void 0!==f&&!L&&(0,i.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,i.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${0===f?"bg-green-500":"bg-red-500"}`}),(0,i.jsx)("span",{children:P("console.exitCode",{code:f})}),(0,i.jsx)("span",{className:"flex-1"}),V&&(0,i.jsx)("span",{className:"text-[11px] flex-shrink-0",children:V})]})]})})});var F=c(59347),G=c(24520);function H({cwd:a,tabId:b,onClose:c,onSave:d}){let{t:e}=(0,k.Bd)(),[f,g]=(0,j.useState)({}),[h,m]=(0,j.useState)(""),[n,o]=(0,j.useState)(""),[p,q]=(0,j.useState)(!0);(0,j.useCallback)(async()=>{q(!0);try{let c=new URLSearchParams({cwd:a});b&&c.set("tabId",b);let d=await fetch(`/api/terminal/env?${c}`);if(d.ok){let a=await d.json();g(a.env||{})}}catch(a){console.error("Failed to load env:",a)}finally{q(!1)}},[a,b]);let r=()=>{h.trim()&&(g(a=>({...a,[h.trim()]:n})),m(""),o(""))},s=async()=>{try{(await fetch("/api/terminal/env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,tabId:b,env:f})})).ok&&(d(f),c())}catch(a){console.error("Failed to save env:",a)}};return(0,i.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,i.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{className:"text-lg font-semibold",children:e("envManager.title")}),(0,i.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b?e("envManager.tabScope"):e("envManager.globalScope")})]}),(0,i.jsx)("button",{onClick:c,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,i.jsx)(l.A,{className:"w-5 h-5"})})]}),(0,i.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:p?(0,i.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:e("common.loading")}):(0,i.jsxs)("div",{className:"space-y-3",children:[Object.entries(f).map(([a,b])=>(0,i.jsxs)("div",{className:"flex items-start gap-2",children:[(0,i.jsx)("input",{type:"text",value:a,disabled:!0,className:"flex-1 px-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"}),(0,i.jsx)("input",{type:"text",value:b,onChange:b=>{var c;return c=b.target.value,void g(b=>({...b,[a]:c}))},placeholder:e("envManager.valuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"}),(0,i.jsx)("button",{onClick:()=>{g(b=>{let c={...b};return delete c[a],c})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors",children:(0,i.jsx)(F.A,{className:"w-4 h-4"})})]},a)),(0,i.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,i.jsx)("input",{type:"text",value:h,onChange:a=>m(a.target.value),placeholder:e("envManager.varNamePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),r())}}),(0,i.jsx)("input",{type:"text",value:n,onChange:a=>o(a.target.value),placeholder:e("envManager.varValuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),r())}}),(0,i.jsx)("button",{onClick:r,disabled:!h.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,i.jsx)(G.A,{className:"w-4 h-4"})})]}),0===Object.keys(f).length&&(0,i.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:e("envManager.noVars")})]})}),(0,i.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,i.jsx)("button",{onClick:c,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:e("common.cancel")}),(0,i.jsx)("button",{onClick:s,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:e("common.save")})]})]})})}var I=c(94924);let J=(0,n.A)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),K=(0,n.A)("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),L=(0,n.A)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),M=(0,n.A)("variable",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]),N=(0,n.A)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);var O=c(69005);let P=null,Q="",R=0,S=null,T=!1,U=new Map,V=null,W=null;function X(a){let b;try{b=JSON.parse(a.data)}catch{return}let c=b.type;if("ping"===c)return;if("running"===c){V&&(V(b.commands),V=null);return}let d=b.commandId;if(!d)return;let e=U.get(d);if(e){if("error"===c)e.onError(b.error);else{let{commandId:a,type:d,...f}=b;e.onData(c,f)}("exit"===c||"error"===c)&&U.delete(d)}}function Y(a){P?.readyState===WebSocket.OPEN&&P.send(JSON.stringify(a))}function Z(a){let b,c=(b="https:"===window.location.protocol?"wss:":"ws:",`${b}//${window.location.host}/ws/terminal?projectCwd=${encodeURIComponent(a)}`);Q===c&&P||(function(){if(T=!0,S&&(clearTimeout(S),S=null),P){let a=P;P=null,a.close()}U.clear(),V&&(V([]),V=null),W=null,Q="",R=0}(),T=!1,Q=c,function a(){if(T||!Q)return;let b=new WebSocket(Q);P=b,b.onopen=()=>{for(let a of(R=0,U.keys()))b.send(JSON.stringify({type:"attach",commandId:a}))},b.onmessage=X,b.onclose=()=>{if(P!==b||(P=null,T))return;S&&clearTimeout(S);let c=Math.min(1e3*Math.pow(1.5,R),1e4);R++,S=setTimeout(a,c)},b.onerror=()=>{}}())}function $(){return new Promise((a,b)=>{if(P?.readyState===WebSocket.OPEN)return void a();let c=setInterval(()=>{P?.readyState===WebSocket.OPEN&&(clearInterval(c),clearTimeout(d),a())},50),d=setTimeout(()=>{clearInterval(c),b(Error("WebSocket connection timeout"))},5e3)})}async function _(a){let{cwd:b,command:c,commandId:d,tabId:e,projectCwd:f,env:g,usePty:h,cols:i,rows:j,onData:k,onError:l}=a;Z(f);try{await $()}catch{l("WebSocket connection failed");return}U.delete(d),U.set(d,{onData:k,onError:l}),Y({type:"exec",commandId:d,command:c,cwd:b,tabId:e,env:g,...h?{usePty:!0}:{},...i?{cols:i,rows:j}:{}})}async function aa(a){let{commandId:b,projectCwd:c,onData:d,onError:e}=a;Z(c);try{await $()}catch{e("WebSocket connection failed");return}U.set(b,{onData:d,onError:e}),Y({type:"attach",commandId:b})}function ab(a,b){Y({type:"stdin",commandId:a,data:b})}function ac(a,b,c){Y({type:"resize",commandId:a,cols:b,rows:c})}function ad(a){Y({type:"interrupt",pid:a})}async function ae(a){try{Z(a);try{await $()}catch{return[]}return await new Promise(a=>{V=b=>{a(b)},Y({type:"running"}),setTimeout(()=>{V&&(V=null,a([]))},3e3)})}finally{W=null}}let af=new Map;function ag(a){af.set(a.type,a)}function ah(a){return af.get(a)}function ai(a){for(let b of af.values())if(b.match(a))return b;return null}var aj=c(74955);async function ak(a){let b=(0,aj.f)()?.id??null;return!!b&&new Promise(c=>{try{let d=globalThis.chrome?.runtime;if(!d?.sendMessage)return void c(!1);let e=setTimeout(()=>c(!1),2e3);d.sendMessage(b,{type:"prepare-iframe",url:a},a=>{clearTimeout(e),c(a?.ok??!1)})}catch{c(!1)}})}function al({url:a,id:b,selected:c,maximized:d,expandedHeight:e,bubbleContentHeight:f,onSelect:g,onClose:h,onToggleMaximize:l,onNewTab:m,timestamp:n,onTitleMouseDown:o,initialSleeping:p,onSleep:q,onWake:r}){let{t:s}=(0,k.Bd)(),[u,v]=(0,j.useState)(!1),[w,A]=(0,j.useState)(null),[B,C]=(0,j.useState)(a),[D,E]=(0,j.useState)(null),[F,G]=(0,j.useState)(p??!1),H=(0,j.useRef)(null),I=(0,j.useRef)(null),J=(0,j.useRef)(null);(0,j.useRef)(!0),(0,j.useCallback)(()=>{F||(G(!0),E(null),q?.(b))},[F,b,q]),(0,j.useCallback)(()=>{H.current&&(clearTimeout(H.current),H.current=null)},[]);let{shortId:K,connected:L,connect:M,disconnect:N}=function(a,b,c){let d=(0,j.useMemo)(()=>x(a),[a]),[e,f]=(0,j.useState)(!1),g=(0,j.useRef)(null);(0,j.useRef)([]),(0,j.useRef)(null),(0,j.useRef)(!1),(0,j.useRef)(c);let h=(0,j.useRef)([]);(0,j.useCallback)(a=>{let c=b.current;if(!c?.contentWindow){let b=g.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"browser:cmd-result",reqId:a.reqId,ok:!1,error:"iframe not available (page may be sleeping)"}));return}c.contentWindow.postMessage({type:"cockpit:cmd",reqId:a.reqId,action:a.action,params:a.params},"*")},[b]);let i=(0,j.useCallback)(()=>e&&g.current?.readyState===WebSocket.OPEN?Promise.resolve():new Promise(a=>{h.current.push(a),e||f(!0)}),[e]);return{shortId:d,connected:e,connect:i,disconnect:(0,j.useCallback)(()=>{f(!1)},[])}}(b,J,!!D&&!F&&!u);(0,j.useRef)(L).current=L;let O=(0,j.useCallback)(()=>{G(!1),r?.(b);let c=function(a){if(!a)return a;try{let b=new URL(a);return b.searchParams.set("_cockpit","1"),b.toString()}catch{let b=a.includes("?")?"&":"?";return`${a}${b}_cockpit=1`}}(a);!function(a){try{let b=new URL(a).hostname;return"localhost"===b||"127.0.0.1"===b}catch{return!1}}(a)?ak(a).then(()=>E(c)):E(c)},[a,b,r]),P=(0,j.useCallback)(()=>v(!1),[]),Q=(0,j.useCallback)(()=>{v(!1),A(s("browser.pageLoadFailed"))},[]),R=(0,j.useCallback)(()=>{if(F)return void O();let a=I.current?.querySelector("iframe");if(a&&D){v(!0),A(null);let b=a.src;a.src="",setTimeout(()=>{a.src=b},0)}},[F,O,D]),S=(0,j.useCallback)(()=>{B&&window.open(B,"_blank")},[B]),T=function(a){if(!a)return"";try{let b=new URL(a);return b.port?`${b.hostname}:${b.port}`:b.hostname}catch{return a}}(B);return(0,i.jsx)("div",{className:"flex flex-col items-start",children:(0,i.jsxs)("div",{className:`w-full bg-accent text-foreground
5
- relative transition-colors cursor-pointer
6
- ${d?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
7
- ${d?"":c?"border-brand":"border-brand/30"}`,onClick:d?void 0:g,children:[d?(0,i.jsxs)("div",{onDoubleClick:l,className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41},children:[(0,i.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:(0,i.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})})}),K&&(0,i.jsx)(y,{shortId:K,type:"browser",onRegister:()=>M(),onUnregister:async()=>{N(),await fetch("/api/browser/unregister",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:K})}).catch(()=>{})}}),(0,i.jsx)("span",{className:"text-xs text-muted-foreground truncate font-mono",children:B||s("browser.blankPage")}),B&&(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(B),(0,t.oR)(s("toast.copiedUrl"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:s("browser.copyUrl"),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.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,i.jsx)("span",{className:"flex-1"}),u&&(0,i.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),(0,i.jsx)("button",{onClick:R,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:s("common.refresh"),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.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,i.jsx)("button",{onClick:S,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:s("browser.openInNewWindow"),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}),(0,i.jsx)("button",{onClick:l,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:s("browser.exitMaximize",{modKey:(0,z.Mu)()}),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})})})]}):(0,i.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>o?.(),onDoubleClick:a=>{a.stopPropagation(),l()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing
8
- ${c?"border-brand":"border-brand/30"}`,children:[(0,i.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:(0,i.jsx)("svg",{className:"w-3 h-3 inline-block",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})})}),K&&(0,i.jsx)(y,{shortId:K,type:"browser",onRegister:()=>M(),onUnregister:async()=>{N(),await fetch("/api/browser/unregister",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:K})}).catch(()=>{})}}),(0,i.jsx)("span",{className:"font-mono text-foreground truncate",children:B||s("browser.blankPage")}),B&&(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(B),(0,t.oR)(s("toast.copiedUrl"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:s("browser.copyUrl"),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.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,i.jsx)("span",{className:"flex-1"}),u&&(0,i.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),S()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:s("browser.openInNewWindow"),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),R()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:s("common.refresh"),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.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,i.jsx)("button",{onClick:a=>{a.stopPropagation(),h()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:s("common.close"),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,i.jsx)("div",{ref:I,className:"w-full",style:{height:d&&e?e-41:f??360},children:F?(0,i.jsxs)("div",{className:"relative overflow-hidden cursor-pointer group h-full",onClick:a=>{a.stopPropagation(),R()},children:[(0,i.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-muted/30",children:[(0,i.jsx)("svg",{className:"w-10 h-10 mb-2 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}),(0,i.jsx)("p",{className:"text-xs text-muted-foreground/60",children:T})]}),(0,i.jsx)("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:(0,i.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-black/60 text-white text-xs",children:[(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.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"})}),s("browser.clickToWake")]})})]}):a?w?(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center text-muted-foreground p-6 h-full",children:[(0,i.jsx)("svg",{className:"w-10 h-10 mb-3 text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,i.jsx)("p",{className:"text-xs",children:w}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),R()},className:"mt-2 px-3 py-1 text-xs bg-secondary text-foreground rounded hover:bg-accent transition-colors",children:s("common.retry")})]}):(0,i.jsxs)("div",{className:"relative overflow-hidden h-full",style:{contain:"strict"},children:[u&&(0,i.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-white/80 dark:bg-slate-900/80 z-10",children:(0,i.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),D?(0,i.jsx)("iframe",{ref:J,src:D,className:"border-0",allow:"clipboard-write; clipboard-read",style:d?{width:"100%",height:"100%"}:{position:"absolute",top:0,left:0,width:"200%",height:"200%",transform:"scale(0.5)",transformOrigin:"top left"},onLoad:P,onError:Q,title:`Browser: ${T}`,"data-browser-id":b}):(0,i.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,i.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})})]}):(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center text-muted-foreground h-full",children:[(0,i.jsx)("svg",{className:"w-10 h-10 mb-2 text-slate-300 dark:text-slate-700",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}),(0,i.jsx)("p",{className:"text-xs",children:s("browser.blankPage")})]})}),!d&&a&&(0,i.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,i.jsx)("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${F?"bg-yellow-500":u?"bg-brand animate-pulse":w?"bg-red-500":"bg-green-500"}`}),(0,i.jsx)("span",{className:"truncate",children:F?s("browser.sleeping"):u?s("browser.loadingPage"):w?s("browser.loadFailed"):T}),(0,i.jsx)("span",{className:"flex-1"}),n&&(0,i.jsx)("span",{className:"text-[11px] flex-shrink-0",children:function(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}(n)})]})]})})}ag({type:"browser",idPrefix:"browser",match(a){let b=a.trim().toLowerCase();return b.startsWith("http://")||b.startsWith("https://")},parse:a=>({url:a.trim()}),fromHistory:a=>({url:a.url}),toHistory:a=>({url:a.url}),Component:function({item:a,selected:b,maximized:c,expandedHeight:d,bubbleContentHeight:e,timestamp:f,onSelect:g,onClose:h,onToggleMaximize:j,onTitleMouseDown:k,extra:l}){return(0,i.jsx)(al,{id:a.id,url:a.url,selected:b,maximized:c,expandedHeight:d,bubbleContentHeight:e,timestamp:f,onSelect:g,onClose:h,onToggleMaximize:j,onTitleMouseDown:k,onNewTab:l?.addBrowserItem,initialSleeping:l?.initialSleeping,onSleep:l?.onSleep,onWake:l?.onWake})}});var am=c(31172);let an=[{value:"=",label:"="},{value:"!=",label:"≠"},{value:">",label:">"},{value:"<",label:"<"},{value:">=",label:"≥"},{value:"<=",label:"≤"},{value:"LIKE",label:"LIKE"},{value:"NOT LIKE",label:"NOT LIKE"},{value:"IN",label:"IN"},{value:"IS NULL",label:"IS NULL"},{value:"IS NOT NULL",label:"IS NOT NULL"}];function ao(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}function ap(a){return`"${a.replace(/"/g,'""')}"`}function aq(a){return null==a?"":"object"==typeof a?JSON.stringify(a):String(a)}function ar({text:a}){let[b,c]=(0,j.useState)(!1),[d,e]=(0,j.useState)({x:0,y:0,maxW:600,maxH:300,above:!0}),f=(0,j.useRef)(null),g=(0,j.useRef)(null),h=(0,j.useRef)(!1),k=(0,am.F2)(),l=(0,j.useCallback)(()=>{g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{h.current||c(!1)},80)},[]),m=(0,j.useCallback)(()=>{g.current&&clearTimeout(g.current),h.current=!1,g.current=setTimeout(()=>{let a=f.current;if(!a||a.scrollWidth<=a.clientWidth)return;let b=a.getBoundingClientRect(),d=k?.getBoundingClientRect(),g=d?.left??0,h=d?.top??0,i=d?.width??window.innerWidth,j=d?.height??window.innerHeight,l=b.left-g,m=b.top-h,n=b.bottom-h,o=Math.min(600,i-l-8),p=m-8,q=j-n-8,r=p>q&&p>80;e({x:o<200?Math.max(8,i-600-8):l,y:r?m-4:n+4,maxW:o<200?Math.min(600,i-16):o,maxH:Math.max(60,r?p-4:q-4),above:r}),c(!0)},350)},[k]),n=(0,j.useCallback)(()=>{l()},[l]),o=(0,j.useCallback)(()=>{h.current=!0,g.current&&clearTimeout(g.current)},[]),p=(0,j.useCallback)(()=>{h.current=!1,l()},[l]);return(0,i.jsxs)("span",{ref:f,className:"block truncate",onMouseEnter:m,onMouseLeave:n,children:[a,b&&(0,i.jsx)(am.ZL,{children:(0,i.jsx)("div",{className:"fixed z-[9999] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lg whitespace-pre-wrap break-all select-text cursor-text",style:{left:d.x,top:d.y,maxWidth:d.maxW,maxHeight:d.maxH,transform:d.above?"translateY(-100%)":void 0},onMouseEnter:o,onMouseLeave:p,children:function(a){try{let b=JSON.parse(a);if("object"==typeof b&&null!==b)return JSON.stringify(b,null,2)}catch{}return a}(a)})})]})}async function as(a,b){let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(!c.ok)throw Error(d.error||`HTTP ${c.status}`);return d}async function at(a,b){let c=new URLSearchParams(b),d=await fetch(`${a}?${c}`),e=await d.json();if(!d.ok)throw Error(e.error||`HTTP ${d.status}`);return e}function au({id:a,connectionString:b,displayName:c,selected:d,maximized:e,expandedHeight:f,bubbleContentHeight:g,onSelect:h,onClose:l,onToggleMaximize:m,timestamp:n,onTitleMouseDown:o}){let{t:p}=(0,k.Bd)(),{showToast:q}=(0,t.dj)(),[r,s]=(0,j.useState)("connecting"),[u,v]=(0,j.useState)(""),[w,x]=(0,j.useState)([]),[y,A]=(0,j.useState)("public"),[B,C]=(0,j.useState)([]),[D,E]=(0,j.useState)(null),[F,G]=(0,j.useState)("table"),[H,I]=(0,j.useState)("data"),[J,K]=(0,j.useState)([]),[L,M]=(0,j.useState)([]),[N,O]=(0,j.useState)([]),[P,Q]=(0,j.useState)([]),[R,S]=(0,j.useState)(null),[T,U]=(0,j.useState)(0),[V,W]=(0,j.useState)(!1),[X,Y]=(0,j.useState)(0),[Z,$]=(0,j.useState)(new Set),[_,aa]=(0,j.useState)(!1),[ab,ac]=(0,j.useState)(null),[ad,ae]=(0,j.useState)({}),[af,ag]=(0,j.useState)(!1),[ah,ai]=(0,j.useState)({}),[aj,ak]=(0,j.useState)({}),[al,am]=(0,j.useState)(null),[an,aw]=(0,j.useState)(""),[az,aA]=(0,j.useState)(null),[aB,aC]=(0,j.useState)(""),[aD,aE]=(0,j.useState)(!1),aF=(0,j.useRef)(null),aG=(0,j.useCallback)(async()=>{s("connecting"),v("");try{let c=await as("/api/db/connect",{id:a,connectionString:b});x(c.schemas||[]),c.schemas?.length>0&&!c.schemas.includes("public")&&A(c.schemas[0]),s("connected")}catch(a){v(a instanceof Error?a.message:String(a)),s("error")}},[a,b]),aH=(0,j.useCallback)(async()=>{if("connected"===r)try{let c=await at("/api/db/schemas",{id:a,connectionString:b,schema:y});C(c.tables||[])}catch{}},[a,b,y,r]),aI=(0,j.useCallback)(async(c,d,e,f)=>{W(!0);let g=e??aj,h=void 0!==f?f:al;try{let e=`${ap(y)}.${ap(c)}`,{where:f,params:i}=function(a){let b=[],c=[],d=1;for(let[e,f]of Object.entries(a)){if(!f.enabled)continue;let a=ap(e);if("IS NULL"===f.op)b.push(`${a} IS NULL`);else if("IS NOT NULL"===f.op)b.push(`${a} IS NOT NULL`);else if("IN"===f.op){let e=f.value.split(",").map(a=>a.trim()).filter(Boolean);if(0===e.length)continue;let g=e.map(a=>(c.push(a),`$${d++}`));b.push(`${a}::text IN (${g.join(", ")})`)}else"LIKE"===f.op||f.op,b.push(`${a}::text ${f.op} $${d++}`),c.push(f.value)}return{where:b.length>0?` WHERE ${b.join(" AND ")}`:"",params:c}}(g),j=h?` ORDER BY ${ap(h.column)} ${h.dir}`:"",k=`SELECT * FROM ${e}${f}${j} LIMIT 50 OFFSET ${50*d}`,l=await as("/api/db/query",{id:a,connectionString:b,sql:k,params:i});S(l);let m=`SELECT count(*)::int AS cnt FROM ${e}${f}`,n=await as("/api/db/query",{id:a,connectionString:b,sql:m,params:i});Y(n.rows?.[0]?.cnt??0)}catch{}W(!1)},[a,b,y,aj,al]),aJ=(0,j.useCallback)(async c=>{E(c),U(0),ac(null),ag(!1),$(new Set),aa(!1),ak({}),am(null);try{let d=await at("/api/db/columns",{id:a,connectionString:b,schema:y,table:c});K(d.columns||[]),M(d.primaryKeys||[]),O(d.foreignKeys||[]),Q(d.indexes||[])}catch{}aI(c,0,{},null)},[a,b,y,aI]),aK=(0,j.useCallback)(async()=>{if(an.trim()){aE(!0),aC(""),aA(null);try{let c=await as("/api/db/query",{id:a,connectionString:b,sql:an});aA(c)}catch(a){aC(a instanceof Error?a.message:String(a))}aE(!1)}},[a,b,an]),aL=(0,j.useCallback)(async()=>{if(null===ab||!R||!D)return;let c=R.rows[ab],d=[],e=[],f=1;for(let a of J)void 0!==ad[a.name]&&ad[a.name]!==aq(c[a.name]??"")&&(d.push(`${ap(a.name)} = $${f}`),e.push(""===ad[a.name]&&a.nullable?null:ad[a.name]),f++);if(0===d.length)return void ac(null);let g=L.length>0?L:J.map(a=>a.name),h=[];for(let a of g)null===c[a]||void 0===c[a]?h.push(`${ap(a)} IS NULL`):(h.push(`${ap(a)} = $${f}`),e.push(c[a]),f++);let i=`UPDATE ${ap(y)}.${ap(D)} SET ${d.join(", ")} WHERE ${h.join(" AND ")}`;try{await as("/api/db/query",{id:a,connectionString:b,sql:i,params:e}),ac(null),aI(D,T,aj,al)}catch(a){alert(`Update failed: ${a instanceof Error?a.message:String(a)}`)}},[ab,R,D,J,L,ad,a,b,y,aI,T,aj,al]),aM=(0,j.useCallback)(async()=>{if(!D)return;let c=[],d=[],e=[],f=1;for(let a of J)void 0!==ah[a.name]&&""!==ah[a.name]&&(c.push(ap(a.name)),d.push(ah[a.name]),e.push(`$${f}`),f++);if(0===c.length)return;let g=`INSERT INTO ${ap(y)}.${ap(D)} (${c.join(", ")}) VALUES (${e.join(", ")})`;try{await as("/api/db/query",{id:a,connectionString:b,sql:g,params:d}),ag(!1),ai({}),aI(D,T,aj,al)}catch(a){alert(`Insert failed: ${a instanceof Error?a.message:String(a)}`)}},[D,J,ah,a,b,y,aI,T,aj,al]),aN=(0,j.useCallback)(async()=>{if(0===Z.size||!R||!D)return;let c=L.length>0?L:J.map(a=>a.name),d=0;for(let e of Array.from(Z).sort((a,b)=>b-a)){let f=R.rows[e];if(!f)continue;let g=[],h=[],i=1;for(let a of c)null===f[a]||void 0===f[a]?g.push(`${ap(a)} IS NULL`):(g.push(`${ap(a)} = $${i}`),h.push(f[a]),i++);let j=`DELETE FROM ${ap(y)}.${ap(D)} WHERE ctid = (SELECT ctid FROM ${ap(y)}.${ap(D)} WHERE ${g.join(" AND ")} LIMIT 1)`;try{await as("/api/db/query",{id:a,connectionString:b,sql:j,params:h})}catch{d++}}$(new Set),aa(!1),aI(D,T,aj,al),d>0&&alert(p("database.deleteRowsFailed",{count:d}))},[Z,R,D,L,J,a,b,y,aI,T,aj,al]),aO=(0,j.useCallback)(async c=>{if(!D)return;if(Z.size>0&&R){let a,b=R.fields.map(a=>a.name),d=Array.from(Z).sort((a,b)=>a-b).map(a=>R.rows[a]).filter(Boolean);if("json"===c)a=JSON.stringify(d,null,2);else{let c=[b.join(",")];for(let a of d)c.push(b.map(b=>{let c=a[b];if(null==c)return"";let d="object"==typeof c?JSON.stringify(c):String(c);return d.includes(",")||d.includes('"')||d.includes("\n")?`"${d.replace(/"/g,'""')}"`:d}).join(","));a=c.join("\n")}navigator.clipboard.writeText(a);return}let d=`SELECT * FROM ${ap(y)}.${ap(D)}`;try{let e=await fetch("/api/db/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a,connectionString:b,sql:d,format:c})});if(!e.ok)throw Error("Export failed");let f=await e.blob(),g=URL.createObjectURL(f),h=document.createElement("a");h.href=g,h.download=`${D}.${c}`,h.click(),URL.revokeObjectURL(g)}catch(a){alert(`Export failed: ${a instanceof Error?a.message:String(a)}`)}},[D,a,b,y,Z,R]),aP=(0,j.useCallback)(a=>{(a.metaKey||a.ctrlKey)&&"Enter"===a.key&&(a.preventDefault(),aK())},[aK]),aQ=Math.max(1,Math.ceil(X/50)),aR=(0,j.useCallback)(a=>{D&&(U(a),aI(D,a,aj,al))},[D,aI,aj,al]),aS=(0,j.useCallback)((a,b)=>{let c={...aj};b?c[a]=b:delete c[a],ak(c),U(0),$(new Set),D&&aI(D,0,c,al)},[aj,al,D,aI]),aT=(0,j.useCallback)(()=>{ak({}),U(0),$(new Set),D&&aI(D,0,{},al)},[al,D,aI]),aU=(0,j.useCallback)(a=>{am(a),U(0),$(new Set),D&&aI(D,0,aj,a)},[aj,D,aI]);return(0,i.jsx)("div",{className:"flex flex-col items-start",children:(0,i.jsxs)("div",{className:`w-full bg-accent text-foreground
9
- relative transition-colors cursor-pointer
10
- ${e?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
11
- ${e?"":d?"border-brand":"border-brand/30"}`,onClick:e?void 0:h,children:[(0,i.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:m,onMouseDown:o,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${e?"bg-card":"bg-card/50"}`,style:e?{height:41}:void 0,children:[(0,i.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDC18"}),(0,i.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),"connecting"===r&&(0,i.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"error"===r&&(0,i.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:p("database.connectionFailed")}),"connected"===r&&(0,i.jsx)("span",{className:"text-[10px] text-emerald-500 flex-shrink-0",children:p("database.connected")}),(0,i.jsx)("span",{className:"flex-1"}),n&&(0,i.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:ao(n)}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),m()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:e?p("browser.exitMaximize",{modKey:(0,z.Mu)()}):p("browser.maximize",{modKey:(0,z.Mu)()}),children:e?(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),l()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:p("common.close"),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,i.jsxs)("div",{style:{height:e&&f?f-41:g??360},className:"flex overflow-hidden",children:["connecting"===r&&(0,i.jsxs)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:[(0,i.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin mr-2"}),p("database.connecting")]}),"error"===r&&(0,i.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,i.jsx)("span",{className:"text-sm text-destructive text-center break-all",children:u}),(0,i.jsx)("button",{onClick:aG,className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:p("common.retry")})]}),"connected"===r&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"w-52 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,i.jsxs)("div",{className:"p-1.5 border-b border-border flex items-center gap-1",children:[w.length>1?(0,i.jsx)("select",{value:y,onChange:a=>{A(a.target.value),E(null)},className:"flex-1 min-w-0 text-xs bg-background border border-input rounded px-1.5 py-1",children:w.map(a=>(0,i.jsx)("option",{value:a,children:a},a))}):(0,i.jsx)("span",{className:"flex-1 min-w-0 text-xs text-muted-foreground truncate",children:y}),(0,i.jsx)("button",{onClick:aH,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent active:bg-accent/50 transition-colors",title:p("database.refreshTableList"),children:(0,i.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M1 1v5h5"}),(0,i.jsx)("path",{d:"M15 15v-5h-5"}),(0,i.jsx)("path",{d:"M13.5 6A6 6 0 0 0 3.2 3.2L1 6"}),(0,i.jsx)("path",{d:"M2.5 10a6 6 0 0 0 10.3 2.8L15 10"})]})})]}),(0,i.jsx)("div",{className:"flex items-center border-b border-border",children:["table","view"].map(a=>(0,i.jsx)("button",{onClick:()=>G(a),className:`flex-1 py-1 text-[10px] font-medium transition-colors ${F===a?"text-brand border-b border-brand":"text-muted-foreground hover:text-foreground"}`,children:{table:p("database.filterTable"),view:p("database.filterView")}[a]},a))}),(0,i.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[B.filter(a=>"table"===F?"view"!==a.type:"view"===a.type).map(a=>(0,i.jsxs)("div",{onClick:()=>aJ(a.name),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer truncate transition-colors ${D===a.name?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,i.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground",children:"view"===a.type?"V":"T"}),(0,i.jsx)("span",{className:"truncate min-w-0 flex-1",children:(0,i.jsx)(ar,{text:a.name})}),(0,i.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.rowEstimate>0?`~${a.rowEstimate}`:""})]},a.name)),0===B.length&&(0,i.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:p("database.noTables")})]})]}),(0,i.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,i.jsxs)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:[["structure","data","sql"].map(a=>(0,i.jsx)("button",{onClick:()=>I(a),className:`px-3 py-1.5 text-xs transition-colors ${H===a?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{structure:p("database.tabStructure"),data:p("database.tabData"),sql:"SQL"}[a]},a)),D&&"data"===H&&(0,i.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[Object.values(aj).some(a=>a.enabled)&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"text-[10px] text-brand",children:p("database.filterActive",{count:Object.values(aj).filter(a=>a.enabled).length})}),(0,i.jsx)("button",{onClick:aT,className:"px-1 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",title:p("database.clearAllFilters"),children:"✕"}),(0,i.jsx)("span",{className:"text-border",children:"|"})]}),Z.size>0&&!_&&(0,i.jsx)("button",{onClick:()=>aa(!0),className:"px-1.5 py-0.5 text-[10px] text-destructive hover:text-destructive/80 bg-destructive/10 rounded transition-colors",children:p("database.deleteNRows",{count:Z.size})}),_&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"text-[10px] text-destructive",children:p("database.confirmDeleteRows")}),(0,i.jsx)("button",{onClick:aN,className:"px-1.5 py-0.5 text-[10px] text-white bg-destructive rounded transition-colors hover:bg-destructive/80",children:p("common.confirm")}),(0,i.jsx)("button",{onClick:()=>aa(!1),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:p("common.cancel")})]}),(0,i.jsx)("button",{onClick:()=>aO("csv"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:Z.size>0?p("database.copyCsvSelected"):p("database.copyCsvAll"),children:Z.size>0?p("database.copyCSV"):p("database.CSV")}),(0,i.jsx)("button",{onClick:()=>aO("json"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:Z.size>0?p("database.copyJsonSelected"):p("database.copyJsonAll"),children:Z.size>0?p("database.copyJSON"):p("database.JSON")})]})]}),(0,i.jsx)("div",{className:"flex-1 overflow-auto",children:D||"sql"===H?"structure"===H?(0,i.jsx)(av,{columns:J,primaryKeys:L,foreignKeys:N,indexes:P}):"data"===H?(0,i.jsx)(ax,{result:R,loading:V,columns:J,page:T,totalPages:aQ,totalRows:X,onPageChange:aR,filters:aj,sort:al,onFilterChange:aS,onSortChange:aU,selectedRows:Z,onSelectedRowsChange:a=>{$(a),aa(!1)},editingRowIdx:ab,editValues:ad,onStartEdit:a=>{if(!R)return;let b=R.rows[a],c={};for(let a of J)c[a.name]=null==b[a.name]?"":aq(b[a.name]);ae(c),ac(a)},onEditChange:(a,b)=>ae(c=>({...c,[a]:b})),onSaveEdit:aL,onCancelEdit:()=>ac(null),isAddingRow:af,newRowValues:ah,onStartAdd:()=>{ag(!0),ai({})},onNewRowChange:(a,b)=>ai(c=>({...c,[a]:b})),onSaveNewRow:aM,onCancelAdd:()=>{ag(!1),ai({})},onCellCopy:a=>{navigator.clipboard.writeText(a),q(p("common.copied"))}}):(0,i.jsx)(ay,{sqlInput:an,onSqlChange:aw,onExecute:aK,onKeyDown:aP,result:az,error:aB,loading:aD,sqlRef:aF,onCellCopy:a=>{navigator.clipboard.writeText(a),q(p("common.copied"))}}):(0,i.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:p("database.selectTable")})})]})]})]}),!e&&(0,i.jsxs)("div",{className:"border-t border-border px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,i.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${"connected"===r?"bg-green-500":"error"===r?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,i.jsx)("span",{children:{connecting:p("common.connecting"),connected:p("common.connected"),error:p("common.connectionFailed")}[r]}),"connected"===r&&D&&(0,i.jsx)("span",{className:"text-muted-foreground/70",children:D}),(0,i.jsx)("span",{className:"flex-1"}),n&&(0,i.jsx)("span",{className:"text-[11px] flex-shrink-0",children:ao(n)})]})]})})}function av({columns:a,primaryKeys:b,foreignKeys:c,indexes:d}){let{t:e}=(0,k.Bd)();return 0===a.length?(0,i.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:e("database.selectTableToView")}):(0,i.jsxs)("div",{className:"p-2 space-y-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:e("database.columns")}),(0,i.jsxs)("table",{className:"w-full text-xs",children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border",children:[(0,i.jsx)("th",{className:"px-1.5 py-1 font-medium",children:e("database.colName")}),(0,i.jsx)("th",{className:"px-1.5 py-1 font-medium",children:e("database.colType")}),(0,i.jsx)("th",{className:"px-1.5 py-1 font-medium",children:e("database.colNullable")}),(0,i.jsx)("th",{className:"px-1.5 py-1 font-medium",children:e("database.colDefault")})]})}),(0,i.jsx)("tbody",{children:a.map(a=>(0,i.jsxs)("tr",{className:"border-b border-border/50 hover:bg-accent/50",children:[(0,i.jsxs)("td",{className:"px-1.5 py-1 font-mono",children:[a.isPrimaryKey&&(0,i.jsx)("span",{className:"text-amber-500 mr-1",title:e("database.primaryKey"),children:"\uD83D\uDD11"}),a.name]}),(0,i.jsxs)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono",children:[a.type,a.maxLength?`(${a.maxLength})`:""]}),(0,i.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground",children:a.nullable?"YES":"NO"}),(0,i.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono truncate max-w-[120px]",children:a.default||""})]},a.name))})]})]}),c.length>0&&(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:e("database.foreignKeys")}),(0,i.jsx)("div",{className:"space-y-0.5",children:c.map((a,b)=>(0,i.jsxs)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground",children:[a.column," → ",a.refSchema,".",a.refTable,".",a.refColumn]},b))})]}),d.length>0&&(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:e("database.indexes")}),(0,i.jsx)("div",{className:"space-y-0.5",children:d.map(a=>(0,i.jsx)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground truncate",title:a.definition,children:a.name},a.name))})]})]})}function aw({filter:a,onApply:b,onClear:c,onToggle:d,onClose:e,colName:f,anchorRect:g}){let{t:h}=(0,k.Bd)(),[l,m]=(0,j.useState)(a?.op||"="),[n,o]=(0,j.useState)(a?.value||""),p=(0,j.useRef)(null),q=(0,am.F2)(),r="IS NULL"!==l&&"IS NOT NULL"!==l,s=()=>{(!r||n.trim())&&b({op:l,value:n.trim(),enabled:!0})},t=q?.getBoundingClientRect(),u=t?.left??0,v=t?.top??0,w=t?.width??1e3,x=g.left-u;x+220>w-8&&(x=w-220-8),x<8&&(x=8);let y=g.bottom+2-v;return(0,i.jsx)(am.ZL,{children:(0,i.jsxs)("div",{ref:p,className:"fixed z-[9998] w-[220px] bg-popover border border-border rounded-md shadow-lg p-2 space-y-2",style:{left:x,top:y},onClick:a=>a.stopPropagation(),children:[a&&(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground cursor-pointer",children:[(0,i.jsx)("input",{type:"checkbox",checked:a.enabled,onChange:a=>d(a.target.checked),className:"w-3 h-3 accent-brand"}),h("database.enable")]}),(0,i.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono truncate max-w-[120px]",children:f})]}),(0,i.jsx)("select",{value:l,onChange:a=>m(a.target.value),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-ring",children:an.map(a=>(0,i.jsx)("option",{value:a.value,children:a.label},a.value))}),r&&(0,i.jsx)("input",{type:"text",value:n,onChange:a=>o(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),s())},placeholder:h("IN"===l?"database.commaValues":"LIKE"===l?"database.likePattern":"database.valuePlaceholder"),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 font-mono focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0}),(0,i.jsxs)("div",{className:"flex items-center gap-1",children:[(0,i.jsx)("button",{onClick:s,disabled:r&&!n.trim(),className:"flex-1 px-2 py-1 text-[10px] bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-40 transition-colors",children:h("database.apply")}),a&&(0,i.jsx)("button",{onClick:c,className:"flex-1 px-2 py-1 text-[10px] text-muted-foreground bg-muted rounded hover:text-foreground transition-colors",children:h("database.clearFilter")})]})]})})}function ax({result:a,loading:b,columns:c,page:d,totalPages:e,totalRows:f,onPageChange:g,filters:h,sort:l,onFilterChange:m,onSortChange:n,selectedRows:o,onSelectedRowsChange:p,editingRowIdx:q,editValues:r,onStartEdit:s,onEditChange:t,onSaveEdit:u,onCancelEdit:v,isAddingRow:w,newRowValues:x,onStartAdd:y,onNewRowChange:z,onSaveNewRow:A,onCancelAdd:B,onCellCopy:C}){let{t:D}=(0,k.Bd)(),[E,F]=(0,j.useState)(null),[G,H]=(0,j.useState)({left:0,bottom:0});if(!a&&!b)return(0,i.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:D("database.selectTableForData")});let I=a?.fields||[],J=a?.rows||[],K={};for(let a of c)K[a.name]=a.type+(a.maxLength?`(${a.maxLength})`:"");let L=J.length>0&&o.size===J.length,M=o.size>0&&!L;return(0,i.jsxs)("div",{className:"flex flex-col h-full",children:[(0,i.jsxs)("div",{className:"flex-1 overflow-auto relative",children:[b&&(0,i.jsx)("div",{className:"absolute inset-0 bg-background/50 flex items-center justify-center z-10",children:(0,i.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),(0,i.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,i.jsx)("thead",{className:"sticky top-0 bg-card z-[2]",children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{className:"px-1 py-1 border-b border-border w-8 text-center",children:(0,i.jsx)("input",{type:"checkbox",checked:L,ref:a=>{a&&(a.indeterminate=M)},onChange:()=>{L?p(new Set):p(new Set(J.map((a,b)=>b)))},className:"w-3 h-3 accent-brand cursor-pointer"})}),I.map(a=>{let b=l?.column===a.name?l.dir:null,c=h[a.name],d=c?.enabled;return(0,i.jsxs)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono relative",children:[(0,i.jsxs)("span",{className:"cursor-pointer select-none hover:text-foreground transition-colors",onClick:()=>{var b;return b=a.name,void(l?.column===b?"ASC"===l.dir?n({column:b,dir:"DESC"}):n(null):n({column:b,dir:"ASC"}))},children:[a.name,K[a.name]&&(0,i.jsx)("span",{className:"ml-1 text-[9px] text-muted-foreground/60 font-normal",children:K[a.name]}),"ASC"===b&&(0,i.jsx)("span",{className:"ml-0.5 text-brand",children:"↑"}),"DESC"===b&&(0,i.jsx)("span",{className:"ml-0.5 text-brand",children:"↓"})]}),(0,i.jsx)("button",{onClick:b=>{if(b.stopPropagation(),E===a.name)return void F(null);let c=b.currentTarget.closest("th").getBoundingClientRect();H({left:c.left,bottom:c.bottom}),F(a.name)},className:`ml-1 inline-flex items-center transition-colors ${d?"text-brand":"text-muted-foreground/40 hover:text-muted-foreground"}`,children:(0,i.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,i.jsx)("path",{d:"M1 2h14l-5.5 6.5V14l-3-2v-3.5z"})})}),E===a.name&&(0,i.jsx)(aw,{filter:c||null,onApply:b=>{m(a.name,b),F(null)},onClear:()=>{m(a.name,null),F(null)},onToggle:b=>{c&&m(a.name,{...c,enabled:b})},onClose:()=>F(null),colName:a.name,anchorRect:G})]},a.name)})]})}),(0,i.jsxs)("tbody",{children:[w&&(0,i.jsxs)("tr",{className:"bg-emerald-500/5",children:[(0,i.jsx)("td",{className:"px-1 py-0.5 border-b border-border text-center",children:(0,i.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,i.jsx)("button",{onClick:A,className:"text-[10px] text-emerald-500 hover:text-emerald-400",title:D("common.save"),children:"✓"}),(0,i.jsx)("button",{onClick:B,className:"text-[10px] text-muted-foreground hover:text-foreground",title:D("common.cancel"),children:"✕"})]})}),I.map(a=>(0,i.jsx)("td",{className:"px-0.5 py-0.5 border-b border-border",children:(0,i.jsx)("input",{type:"text",value:x[a.name]??"",onChange:b=>z(a.name,b.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]",placeholder:"NULL"})},a.name))]}),J.map((a,b)=>(0,i.jsxs)("tr",{className:`hover:bg-accent/50 ${o.has(b)?"bg-brand/5":""} ${q===b?"bg-blue-500/5":""}`,children:[(0,i.jsx)("td",{className:"px-1 py-0.5 border-b border-border/50 text-center",children:q===b?(0,i.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,i.jsx)("button",{onClick:u,className:"text-[10px] text-emerald-500 hover:text-emerald-400",title:D("common.save"),children:"✓"}),(0,i.jsx)("button",{onClick:v,className:"text-[10px] text-muted-foreground hover:text-foreground",title:D("common.cancel"),children:"✕"})]}):(0,i.jsx)("input",{type:"checkbox",checked:o.has(b),onChange:()=>{let a;(a=new Set(o)).has(b)?a.delete(b):a.add(b),p(a)},className:"w-3 h-3 accent-brand cursor-pointer"})}),I.map(c=>(0,i.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onDoubleClick:()=>{null===q&&s(b)},onContextMenu:b=>{b.preventDefault(),C(aq(a[c.name]))},children:q===b?(0,i.jsx)("input",{type:"text",value:r[c.name]??"",onChange:a=>t(c.name,a.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]"}):null===a[c.name]||void 0===a[c.name]?(0,i.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,i.jsx)(ar,{text:aq(a[c.name])})},c.name))]},b))]})]}),0===J.length&&!b&&(0,i.jsx)("div",{className:"p-4 text-xs text-muted-foreground text-center",children:D("common.noData")})]}),(0,i.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 border-t border-border text-[10px] text-muted-foreground bg-card/30 flex-shrink-0",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("button",{onClick:y,disabled:w,className:"px-1.5 py-0.5 text-[10px] text-emerald-500 hover:text-emerald-400 disabled:opacity-30",children:D("database.addRow")}),(0,i.jsx)("span",{children:D("database.totalRows",{count:f})}),a?.duration!==void 0&&(0,i.jsxs)("span",{children:[a.duration,"ms"]})]}),(0,i.jsxs)("div",{className:"flex items-center gap-1",children:[(0,i.jsx)("button",{onClick:()=>g(d-1),disabled:0===d,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"◀"}),(0,i.jsxs)("span",{children:[d+1," / ",e]}),(0,i.jsx)("button",{onClick:()=>g(d+1),disabled:d>=e-1,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"▶"})]})]})]})}function ay({sqlInput:a,onSqlChange:b,onExecute:c,onKeyDown:d,result:e,error:f,loading:g,sqlRef:h,onCellCopy:j}){let{t:l}=(0,k.Bd)();return(0,i.jsxs)("div",{className:"flex flex-col h-full",children:[(0,i.jsxs)("div",{className:"flex-shrink-0 p-2 border-b border-border",children:[(0,i.jsx)("textarea",{ref:h,value:a,onChange:a=>b(a.target.value),onKeyDown:d,placeholder:l("database.sqlPlaceholder",{modKey:(0,z.Mu)()}),className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,i.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,i.jsx)("button",{onClick:c,disabled:g||!a.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:l(g?"database.executing":"database.execute")}),e?.duration!==void 0&&(0,i.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[e.command&&!e.fields?l("database.rowsAffected",{command:e.command,count:e.rowCount,duration:e.duration}):l("database.queryRows",{count:e.rows?.length??0,duration:e.duration}),e.truncated&&` ${l("database.resultTruncated")}`]})]})]}),f&&(0,i.jsx)("div",{className:"px-3 py-2 text-xs text-destructive bg-destructive/5 border-b border-border break-all",children:f}),e?.fields&&e.rows&&(0,i.jsx)("div",{className:"flex-1 overflow-auto",children:(0,i.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,i.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,i.jsx)("tr",{children:e.fields.map(a=>(0,i.jsx)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono",children:a.name},a.name))})}),(0,i.jsx)("tbody",{children:e.rows.map((a,b)=>(0,i.jsx)("tr",{className:"hover:bg-accent/50",children:e.fields.map(b=>(0,i.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onContextMenu:c=>{c.preventDefault(),j(aq(a[b.name]))},children:null===a[b.name]||void 0===a[b.name]?(0,i.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,i.jsx)(ar,{text:aq(a[b.name])})},b.name))},b))})]})})]})}ag({type:"database",idPrefix:"db",match(a){let b=a.trim().toLowerCase();return b.startsWith("postgresql://")||b.startsWith("postgres://")},parse(a){let b=a.trim(),c=b;try{let a=new URL(b),d=a.pathname.replace(/^\//,"")||"postgres";c=`${d}@${a.hostname}${a.port?":"+a.port:""}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:d,bubbleContentHeight:e,timestamp:f,onSelect:g,onClose:h,onToggleMaximize:j,onTitleMouseDown:k}){return(0,i.jsx)(au,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:d,bubbleContentHeight:e,timestamp:f,onSelect:g,onClose:h,onToggleMaximize:j,onTitleMouseDown:k})},async onClose(a){try{await fetch("/api/db/disconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a.id})})}catch{}}});var az=c(50757),aA=c(27454),aB=c(37752),aC=c(49280),aD=c(3532);let aE=new v;function aF(a){return a?Array.isArray(a)?a.join(""):a:""}function aG(a,b){return a&&a[b]?aF(a[b]):""}aE.use_classes=!0;let aH=(0,j.memo)(function({output:a}){if("stream"===a.output_type){let b=aF(a.text);if(!b)return null;let c=aE.ansi_to_html(b);return(0,i.jsx)("pre",{className:`text-xs leading-relaxed whitespace-pre-wrap break-all px-3 py-1 ${"stderr"===a.name?"text-amber-500":"text-foreground"}`,dangerouslySetInnerHTML:{__html:c}})}if("error"===a.output_type){let b=(a.traceback||[]).join("\n"),c=aE.ansi_to_html(b);return(0,i.jsx)("pre",{className:"text-xs leading-relaxed whitespace-pre-wrap break-all px-3 py-1 text-red-400 bg-red-500/5 rounded",dangerouslySetInnerHTML:{__html:c}})}if("execute_result"===a.output_type||"display_data"===a.output_type||"update_display_data"===a.output_type){let b=a.data;if(!b)return null;let c=aG(b,"image/png"),d=aG(b,"image/jpeg"),e=aG(b,"image/svg+xml"),f=aG(b,"text/html"),g=aG(b,"text/markdown"),h=aG(b,"text/latex"),j=aG(b,"text/plain");if(c)return(0,i.jsx)("div",{className:"px-3 py-1",children:(0,i.jsx)("img",{src:`data:image/png;base64,${c}`,alt:"output",className:"max-w-full"})});if(d)return(0,i.jsx)("div",{className:"px-3 py-1",children:(0,i.jsx)("img",{src:`data:image/jpeg;base64,${d}`,alt:"output",className:"max-w-full"})});if(e)return(0,i.jsx)("div",{className:"px-3 py-1",dangerouslySetInnerHTML:{__html:e}});if(f)return(0,i.jsx)("div",{className:"px-3 py-1 overflow-x-auto notebook-html-output",dangerouslySetInnerHTML:{__html:f}});if(g)return(0,i.jsx)("div",{className:"px-3 py-1",children:(0,i.jsx)(aC.T,{content:g})});if(h)return(0,i.jsx)("div",{className:"px-3 py-1",children:(0,i.jsx)(aC.T,{content:`$$${h}$$`})});if(j)return(0,i.jsx)("pre",{className:"text-xs leading-relaxed whitespace-pre-wrap break-all px-3 py-1 text-foreground",children:j})}return null}),aI=(0,j.memo)(function({cell:a,isActive:b,isEditing:c,onSelect:d,onEdit:e,onStopEdit:f,onSourceChange:g,onRun:h,onDelete:k,onMoveUp:l,onMoveDown:m,onToggleType:n,isFirst:o,isLast:p}){let{resolvedTheme:q}=(0,aD.D)(),r=(0,j.useRef)(null),[s,t]=(0,j.useState)(a.source),u=(0,j.useCallback)(()=>{t(a.source),e()},[a.source,e]);(0,j.useEffect)(()=>{if(c&&r.current){r.current.focus();let a=r.current.value.length;r.current.setSelectionRange(a,a)}},[c]);let v=(0,j.useCallback)(()=>{let a=r.current;a&&(a.style.height="auto",a.style.height=a.scrollHeight+"px")},[]);(0,j.useEffect)(()=>{c&&v()},[c,s,v]);let w=(0,j.useCallback)(a=>{t(a.target.value),v()},[v]),x=(0,j.useCallback)(()=>{s!==a.source&&g(s),f()},[s,a.source,g,f]),y=(0,j.useCallback)(b=>{if("Enter"===b.key&&b.shiftKey)b.preventDefault(),s!==a.source&&g(s),h();else if("Enter"===b.key&&(b.metaKey||b.ctrlKey))b.preventDefault(),s!==a.source&&g(s),h();else if("Escape"===b.key)b.preventDefault(),x();else if("Tab"===b.key){b.preventDefault();let a=r.current;if(a){let b=a.selectionStart,c=a.selectionEnd;t(s.substring(0,b)+" "+s.substring(c)),requestAnimationFrame(()=>{a.selectionStart=a.selectionEnd=b+4})}}},[s,a.source,g,h,x]),z=a.isExecuting?"*":a.execution_count??" ",A="code"===a.cell_type?"Code":"markdown"===a.cell_type?"Md":"Raw";return(0,i.jsxs)("div",{className:`group relative border rounded-lg transition-colors ${b?"border-brand/50 bg-brand/5":"border-border/50 hover:border-border"}`,onClick:d,children:[(0,i.jsxs)("div",{className:`absolute -top-3 left-2 flex items-center gap-0.5 text-[10px] z-10 bg-surface-secondary rounded px-1 py-0.5 border border-border/50 transition-opacity ${b?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:[(0,i.jsx)("button",{onClick:h,className:"px-1 hover:text-brand",title:"Run (Shift+Enter)",children:a.isExecuting?"⬛":"▶"}),(0,i.jsx)("button",{onClick:n,className:"px-1 hover:text-brand",title:"Toggle type",children:A}),!o&&(0,i.jsx)("button",{onClick:l,className:"px-1 hover:text-brand",title:"Move up",children:"↑"}),!p&&(0,i.jsx)("button",{onClick:m,className:"px-1 hover:text-brand",title:"Move down",children:"↓"}),(0,i.jsx)("button",{onClick:k,className:"px-1 hover:text-red-400",title:"Delete",children:"\xd7"})]}),(0,i.jsxs)("div",{className:"flex",children:[(0,i.jsx)("div",{className:"flex-shrink-0 w-10 text-center py-2 text-[10px] text-muted-foreground select-none cursor-pointer border-r border-border/30",onClick:a=>{a.stopPropagation(),h()},title:"code"===a.cell_type?"Click to run":void 0,children:"code"===a.cell_type?(0,i.jsxs)("span",{className:a.isExecuting?"text-brand animate-pulse":"",children:["[",z,"]"]}):(0,i.jsx)("span",{className:"text-muted-foreground/50",children:A})}),(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsx)("div",{className:"cursor-text",onDoubleClick:a=>{a.stopPropagation(),u()},children:c?(0,i.jsx)("textarea",{ref:r,value:s,onChange:w,onBlur:x,onKeyDown:y,className:"w-full bg-transparent text-xs font-mono leading-relaxed px-3 py-2 resize-none outline-none text-foreground",spellCheck:!1,style:{minHeight:"1.5rem"}}):"code"===a.cell_type?(0,i.jsx)("div",{className:"text-xs [&_pre]:!m-0 [&_pre]:!p-2 [&_pre]:!bg-transparent [&_code]:!bg-transparent",children:(0,i.jsx)(az.A,{language:"python",style:"dark"===q?aA.A:aB.A,customStyle:{margin:0,padding:"8px 12px",background:"transparent",fontSize:"12px"},wrapLongLines:!0,children:a.source||" "})}):"markdown"===a.cell_type?a.source.trim()?(0,i.jsx)("div",{className:"px-3 py-2 text-sm prose prose-sm dark:prose-invert max-w-none",children:(0,i.jsx)(aC.T,{content:a.source})}):(0,i.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground italic",children:"Empty markdown cell"}):(0,i.jsx)("pre",{className:"text-xs font-mono px-3 py-2 text-muted-foreground whitespace-pre-wrap",children:a.source||" "})}),a.outputs.length>0&&(0,i.jsx)("div",{className:"border-t border-border/30",children:a.outputs.map((a,b)=>(0,i.jsx)(aH,{output:a},b))})]})]})]})});function aJ({id:a,filePath:b,displayName:c,cwd:d,selected:e,maximized:f,expandedHeight:g,bubbleContentHeight:h,timestamp:k,onSelect:l,onClose:m,onToggleMaximize:n,onTitleMouseDown:o}){let{showToast:p}=(0,t.dj)(),[q,r]=(0,j.useState)([]),[s,u]=(0,j.useState)(!0),[v,w]=(0,j.useState)(null),[x,y]=(0,j.useState)(!1),[A,B]=(0,j.useState)(!1),[C,D]=(0,j.useState)(null),[E,F]=(0,j.useState)(null),[G,H]=(0,j.useState)("disconnected"),[I,J]=(0,j.useState)(null),K=(0,j.useRef)(null),L=(0,j.useRef)(new Map),M=(0,j.useRef)(null),N=(0,j.useRef)(q);N.current=q;let O=(0,j.useCallback)(async()=>{u(!0),w(null);try{let a=await fetch("/api/jupyter/load",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:b,cwd:d})}),c=await a.json();if(!a.ok)throw Error(c.error||"Failed to load notebook");r(c.cells.map((a,b)=>({...a,index:b,isExecuting:!1}))),y(!1)}catch(a){w(a.message)}finally{u(!1)}},[b,d]),P=(0,j.useCallback)(async()=>{if(!A){B(!0);try{let a=await fetch("/api/jupyter/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:b,cwd:d,cells:q.map(a=>({cell_type:a.cell_type,source:a.source,outputs:a.outputs,execution_count:a.execution_count,metadata:a.metadata}))})}),c=await a.json();if(!a.ok)throw Error(c.error||"Failed to save");y(!1),p("Saved","success")}catch(a){p(a.message,"error")}finally{B(!1)}}},[b,d,q,A,p]),Q=(0,j.useCallback)(()=>{if(K.current&&K.current.readyState<=1)return;H("starting"),J(null);let b="https:"===window.location.protocol?"wss:":"ws:",c=new WebSocket(`${b}//${window.location.host}/ws/jupyter?bubbleId=${encodeURIComponent(a)}&cwd=${encodeURIComponent(d)}`);K.current=c,c.onopen=()=>{},c.onmessage=a=>{let b;try{b=JSON.parse(a.data)}catch{return}let c=b.type;if("ready"===c)H("idle"),J(null);else if("status"===c){let a=b.execution_state;"idle"===a?H("idle"):"busy"===a&&H("busy")}else if("output"===c){let a=b.msg_id,c=b.msg_type,d=b.content,e=L.current.get(a);if(void 0===e)return;r(a=>a.map((a,b)=>{if(b!==e)return a;let f={output_type:"execute_result"===c?"execute_result":"display_data"===c?"display_data":"update_display_data"===c?"update_display_data":"stream"===c?"stream":"error"===c?"error":"display_data"};return"stream"===c?(f.name=d.name,f.text=d.text):"error"===c?(f.ename=d.ename,f.evalue=d.evalue,f.traceback=d.traceback):(f.data=d.data,f.metadata=d.metadata,"execute_result"===c&&(f.execution_count=d.execution_count)),{...a,outputs:[...a.outputs,f]}}))}else if("kernel_error"===c)H("error"),J(b.message);else if("kernel_died"===c){for(let[,a]of(H("dead"),J("Kernel died"),L.current))r(b=>b.map((b,c)=>c===a?{...b,isExecuting:!1}:b));L.current.clear()}},c.onclose=()=>{"error"!==G&&"dead"!==G&&H("disconnected")},c.onerror=()=>{H("error")}},[a,d,G]),R=(0,j.useRef)(null),S=(0,j.useCallback)(a=>{let b=N.current[a];if(!b||"code"!==b.cell_type)return;if(!K.current||K.current.readyState!==WebSocket.OPEN){Q();let b=setInterval(()=>{K.current?.readyState===WebSocket.OPEN&&(clearInterval(b),R.current?.(a))},200);setTimeout(()=>clearInterval(b),15e3);return}let c=`cell-${a}-${Date.now()}`;L.current.set(c,a),r(b=>b.map((b,c)=>c===a?{...b,outputs:[],isExecuting:!0,execution_count:null}:b)),K.current.send(JSON.stringify({type:"execute",msg_id:c,code:b.source})),setTimeout(()=>{L.current.has(c)&&(L.current.delete(c),r(b=>b.map((b,c)=>c===a?{...b,isExecuting:!1}:b)))},3e5)},[Q]);R.current=S;let T=(0,j.useCallback)(()=>{let a=[...q.map((a,b)=>({cell:a,index:b})).filter(a=>"code"===a.cell.cell_type)],b=()=>{if(0===a.length)return;let{index:c}=a.shift();S(c);let d=setInterval(()=>{let a=N.current[c];a&&!a.isExecuting&&(clearInterval(d),b())},200)};b()},[q,S]),U=(0,j.useCallback)(()=>{K.current?.send(JSON.stringify({type:"interrupt"}))},[]),V=(0,j.useCallback)((a,b)=>{r(c=>c.map((c,d)=>d===a?{...c,source:b}:c)),y(!0)},[]),W=(0,j.useCallback)(a=>{r(b=>b.filter((b,c)=>c!==a)),y(!0),C===a&&D(null)},[C]),X=(0,j.useCallback)((a,b)=>{r(c=>{let d=[...c],e="up"===b?a-1:a+1;return e<0||e>=d.length?c:([d[a],d[e]]=[d[e],d[a]],d)}),y(!0),D("up"===b?a-1:a+1)},[]),Y=(0,j.useCallback)(a=>{r(b=>b.map((b,c)=>{if(c!==a)return b;let d="code"===b.cell_type?"markdown":"markdown"===b.cell_type?"raw":"code";return{...b,cell_type:d,outputs:"code"===d?b.outputs:[]}})),y(!0)},[]),Z=(0,j.useCallback)((a,b)=>{let c={index:0,cell_type:a,source:"",outputs:[],execution_count:null,metadata:{},isExecuting:!1};r(a=>{let d=[...a],e=void 0!==b?b+1:d.length;return d.splice(e,0,c),d}),y(!0);let d=void 0!==b?b+1:q.length;D(d),F(d)},[q.length]),$=(0,j.useMemo)(()=>{switch(G){case"idle":return(0,i.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500 inline-block",title:"Kernel idle"});case"busy":return(0,i.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse inline-block",title:"Kernel busy"});case"starting":return(0,i.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin inline-block",title:"Starting kernel"});case"error":return(0,i.jsx)("span",{className:"w-2 h-2 rounded-full bg-red-500 inline-block",title:I||"Kernel error"});case"dead":return(0,i.jsx)("span",{className:"w-2 h-2 rounded-full bg-red-500 inline-block",title:"Kernel died"});default:return(0,i.jsx)("span",{className:"w-2 h-2 rounded-full bg-gray-500 inline-block",title:"Disconnected"})}},[G,I]);return(0,i.jsxs)("div",{className:`w-full bg-accent text-foreground
12
- relative transition-colors cursor-pointer
13
- ${f?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
14
- ${f?"":e?"border-brand":"border-brand/30"}`,onClick:f?void 0:l,children:[(0,i.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:n,onMouseDown:o,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${f?"bg-card":"bg-card/50"}`,style:f?{height:41}:void 0,children:[(0,i.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDCD3"}),(0,i.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),$,x&&(0,i.jsx)("span",{className:"text-[10px] text-amber-500 flex-shrink-0",children:"unsaved"}),(0,i.jsx)("span",{className:"flex-1"}),k&&(0,i.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:function(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}(k)}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),n()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:f?`Exit maximize (${(0,z.Mu)()}+M)`:`Maximize (${(0,z.Mu)()}+M)`,children:f?(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),m()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:"Close",children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,i.jsxs)("div",{className:"flex items-center gap-1 px-3 py-1 border-b border-border/50 bg-surface-secondary/50 text-[11px]",children:[(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),T()},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Run All",children:"▶ All"}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),U()},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Interrupt",disabled:"busy"!==G,children:"⬛ Stop"}),(0,i.jsx)("div",{className:"w-px h-3 bg-border/50 mx-1"}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),Z("code",C??q.length-1)},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Add code cell",children:"+ Code"}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),Z("markdown",C??q.length-1)},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Add markdown cell",children:"+ Md"}),(0,i.jsx)("div",{className:"w-px h-3 bg-border/50 mx-1"}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),P()},className:`px-1.5 py-0.5 rounded hover:bg-accent transition-colors ${x?"text-brand":"text-muted-foreground hover:text-foreground"}`,title:`Save (${(0,z.Mu)()}+S)`,disabled:A,children:A?"Saving...":"Save"}),(0,i.jsx)("span",{className:"flex-1"}),I&&(0,i.jsx)("span",{className:"text-[10px] text-red-400 truncate max-w-[50%]",title:I,children:I}),"dead"===G&&(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),Q()},className:"px-1.5 py-0.5 rounded text-brand hover:bg-accent transition-colors",children:"Restart"})]}),(0,i.jsx)("div",{ref:M,className:"overflow-y-auto",style:{height:(f&&g?g-41:h??360)-30},children:s?(0,i.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground text-sm",children:"Loading notebook..."}):v?(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center h-32 gap-2",children:[(0,i.jsx)("span",{className:"text-red-400 text-sm",children:v}),(0,i.jsx)("button",{onClick:O,className:"text-xs text-brand hover:underline",children:"Retry"})]}):0===q.length?(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center h-32 gap-2 text-muted-foreground text-sm",children:[(0,i.jsx)("span",{children:"Empty notebook"}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)("button",{onClick:()=>Z("code"),className:"text-xs text-brand hover:underline",children:"+ Code cell"}),(0,i.jsx)("button",{onClick:()=>Z("markdown"),className:"text-xs text-brand hover:underline",children:"+ Markdown cell"})]})]}):(0,i.jsxs)("div",{className:"flex flex-col gap-1 p-2",children:[q.map((a,b)=>(0,i.jsx)(aI,{cell:a,isActive:C===b,isEditing:E===b,onSelect:()=>D(b),onEdit:()=>{D(b),F(b)},onStopEdit:()=>F(null),onSourceChange:a=>V(b,a),onRun:()=>{"code"===a.cell_type&&S(b),b<q.length-1&&D(b+1)},onDelete:()=>W(b),onMoveUp:()=>X(b,"up"),onMoveDown:()=>X(b,"down"),onToggleType:()=>Y(b),isFirst:0===b,isLast:b===q.length-1},`${b}-${a.cell_type}`)),(0,i.jsxs)("div",{className:"flex justify-center gap-2 py-2 opacity-0 hover:opacity-100 transition-opacity",children:[(0,i.jsx)("button",{onClick:()=>Z("code",q.length-1),className:"text-[10px] text-muted-foreground hover:text-foreground px-2 py-0.5 rounded border border-border/50 hover:border-border transition-colors",children:"+ Code"}),(0,i.jsx)("button",{onClick:()=>Z("markdown",q.length-1),className:"text-[10px] text-muted-foreground hover:text-foreground px-2 py-0.5 rounded border border-border/50 hover:border-border transition-colors",children:"+ Markdown"})]})]})})]})}ag({type:"jupyter",idPrefix:"nb",match:a=>a.trim().endsWith(".ipynb"),parse(a){let b=a.trim(),c=b.split("/"),d=c[c.length-1]||b;return{filePath:b,displayName:d,cwd:""}},fromHistory:a=>({filePath:a.filePath,displayName:a.displayName||"",cwd:a.cwd||""}),toHistory:a=>({filePath:a.filePath,displayName:a.displayName,cwd:a.cwd}),Component:function({item:a,selected:b,maximized:c,expandedHeight:d,bubbleContentHeight:e,timestamp:f,onSelect:g,onClose:h,onToggleMaximize:j,onTitleMouseDown:k}){return(0,i.jsx)(aJ,{id:a.id,filePath:a.filePath,displayName:a.displayName,cwd:a.cwd,selected:b,maximized:c,expandedHeight:d,bubbleContentHeight:e,timestamp:f,onSelect:g,onClose:h,onToggleMaximize:j,onTitleMouseDown:k})},async onClose(a){try{await fetch("/api/jupyter/shutdown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bubbleId:a.id})})}catch{}}});let aK=[{value:"=",label:"="},{value:"!=",label:"!="},{value:">",label:">"},{value:"<",label:"<"},{value:">=",label:">="},{value:"<=",label:"<="},{value:"LIKE",label:"LIKE"},{value:"NOT LIKE",label:"NOT LIKE"},{value:"IN",label:"IN"},{value:"IS NULL",label:"IS NULL"},{value:"IS NOT NULL",label:"IS NOT NULL"}];function aL(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}function aM(a){return`\`${a.replace(/`/g,"``")}\``}function aN(a){try{let b=a.match(/\/\/[^/]+\/([^?]+)/);if(b)return b[1]}catch{}return""}function aO(a){return null==a?"":"object"==typeof a?JSON.stringify(a):String(a)}function aP({text:a}){let[b,c]=(0,j.useState)(!1),[d,e]=(0,j.useState)({x:0,y:0,maxW:600,maxH:300,above:!0}),f=(0,j.useRef)(null),g=(0,j.useRef)(null),h=(0,j.useRef)(!1),k=(0,am.F2)(),l=(0,j.useCallback)(()=>{g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{h.current||c(!1)},80)},[]),m=(0,j.useCallback)(()=>{g.current&&clearTimeout(g.current),h.current=!1,g.current=setTimeout(()=>{let a=f.current;if(!a||a.scrollWidth<=a.clientWidth)return;let b=a.getBoundingClientRect(),d=k?.getBoundingClientRect(),g=d?.left??0,h=d?.top??0,i=d?.width??window.innerWidth,j=d?.height??window.innerHeight,l=b.left-g,m=b.top-h,n=b.bottom-h,o=Math.min(600,i-l-8),p=m-8,q=j-n-8,r=p>q&&p>80;e({x:o<200?Math.max(8,i-600-8):l,y:r?m-4:n+4,maxW:o<200?Math.min(600,i-16):o,maxH:Math.max(60,r?p-4:q-4),above:r}),c(!0)},350)},[k]),n=(0,j.useCallback)(()=>{l()},[l]),o=(0,j.useCallback)(()=>{h.current=!0,g.current&&clearTimeout(g.current)},[]),p=(0,j.useCallback)(()=>{h.current=!1,l()},[l]);return(0,i.jsxs)("span",{ref:f,className:"block truncate",onMouseEnter:m,onMouseLeave:n,children:[a,b&&(0,i.jsx)(am.ZL,{children:(0,i.jsx)("div",{className:"fixed z-[9999] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lg whitespace-pre-wrap break-all select-text cursor-text",style:{left:d.x,top:d.y,maxWidth:d.maxW,maxHeight:d.maxH,transform:d.above?"translateY(-100%)":void 0},onMouseEnter:o,onMouseLeave:p,children:function(a){try{let b=JSON.parse(a);if("object"==typeof b&&null!==b)return JSON.stringify(b,null,2)}catch{}return a}(a)})})]})}async function aQ(a,b){let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(!c.ok)throw Error(d.error||`HTTP ${c.status}`);return d}async function aR(a,b){let c=new URLSearchParams(b),d=await fetch(`${a}?${c}`),e=await d.json();if(!d.ok)throw Error(e.error||`HTTP ${d.status}`);return e}function aS({id:a,connectionString:b,displayName:c,selected:d,maximized:e,expandedHeight:f,bubbleContentHeight:g,onSelect:h,onClose:l,onToggleMaximize:m,timestamp:n,onTitleMouseDown:o}){let{t:p}=(0,k.Bd)(),{showToast:q}=(0,t.dj)(),[r,s]=(0,j.useState)("connecting"),[u,v]=(0,j.useState)(""),[w,x]=(0,j.useState)([]),[y,A]=(0,j.useState)(()=>aN(b)),[B,C]=(0,j.useState)([]),[D,E]=(0,j.useState)(null),[F,G]=(0,j.useState)("table"),[H,I]=(0,j.useState)("data"),[J,K]=(0,j.useState)([]),[L,M]=(0,j.useState)([]),[N,O]=(0,j.useState)([]),[P,Q]=(0,j.useState)([]),[R,S]=(0,j.useState)(null),[T,U]=(0,j.useState)(0),[V,W]=(0,j.useState)(!1),[X,Y]=(0,j.useState)(0),[Z,$]=(0,j.useState)(new Set),[_,aa]=(0,j.useState)(!1),[ab,ac]=(0,j.useState)(null),[ad,ae]=(0,j.useState)({}),[af,ag]=(0,j.useState)(!1),[ah,ai]=(0,j.useState)({}),[aj,ak]=(0,j.useState)({}),[al,am]=(0,j.useState)(null),[an,ao]=(0,j.useState)(""),[ap,aq]=(0,j.useState)(null),[ar,as]=(0,j.useState)(""),[at,au]=(0,j.useState)(!1),av=(0,j.useRef)(null),aw=(0,j.useCallback)(async()=>{s("connecting"),v("");try{let c=await aQ("/api/mysql/connect",{id:a,connectionString:b});x(c.schemas||[]);let d=aN(b);c.schemas?.length>0&&d&&c.schemas.includes(d)?A(d):c.schemas?.length>0&&A(c.schemas[0]),s("connected")}catch(a){v(a instanceof Error?a.message:String(a)),s("error")}},[a,b]),ax=(0,j.useCallback)(async()=>{if("connected"===r)try{let c=await aR("/api/mysql/schemas",{id:a,connectionString:b,schema:y});C(c.tables||[])}catch{}},[a,b,y,r]),ay=(0,j.useCallback)(async(c,d,e,f)=>{W(!0);let g=e??aj,h=void 0!==f?f:al;try{let e=`${aM(y)}.${aM(c)}`,{where:f,params:i}=function(a){let b=[],c=[];for(let[d,e]of Object.entries(a)){if(!e.enabled)continue;let a=aM(d);if("IS NULL"===e.op)b.push(`${a} IS NULL`);else if("IS NOT NULL"===e.op)b.push(`${a} IS NOT NULL`);else if("IN"===e.op){let d=e.value.split(",").map(a=>a.trim()).filter(Boolean);if(0===d.length)continue;let f=d.map(a=>(c.push(a),"?"));b.push(`${a} IN (${f.join(", ")})`)}else"LIKE"===e.op||e.op,b.push(`${a} ${e.op} ?`),c.push(e.value)}return{where:b.length>0?` WHERE ${b.join(" AND ")}`:"",params:c}}(g),j=h?` ORDER BY ${aM(h.column)} ${h.dir}`:"",k=`SELECT * FROM ${e}${f}${j} LIMIT 50 OFFSET ${50*d}`,l=await aQ("/api/mysql/query",{id:a,connectionString:b,sql:k,params:i});S(l);let m=`SELECT count(*) AS cnt FROM ${e}${f}`,n=await aQ("/api/mysql/query",{id:a,connectionString:b,sql:m,params:i});Y(n.rows?.[0]?.cnt??0)}catch{}W(!1)},[a,b,y,aj,al]),az=(0,j.useCallback)(async c=>{E(c),U(0),ac(null),ag(!1),$(new Set),aa(!1),ak({}),am(null);try{let d=await aR("/api/mysql/columns",{id:a,connectionString:b,schema:y,table:c});K(d.columns||[]),M(d.primaryKeys||[]),O(d.foreignKeys||[]),Q(d.indexes||[])}catch{}ay(c,0,{},null)},[a,b,y,ay]),aA=(0,j.useCallback)(async()=>{if(an.trim()){au(!0),as(""),aq(null);try{let c=await aQ("/api/mysql/query",{id:a,connectionString:b,sql:an});aq(c)}catch(a){as(a instanceof Error?a.message:String(a))}au(!1)}},[a,b,an]),aB=(0,j.useCallback)(async()=>{if(null===ab||!R||!D)return;let c=R.rows[ab],d=[],e=[];for(let a of J)void 0!==ad[a.name]&&ad[a.name]!==aO(c[a.name]??"")&&(d.push(`${aM(a.name)} = ?`),e.push(""===ad[a.name]&&a.nullable?null:ad[a.name]));if(0===d.length)return void ac(null);let f=L.length>0?L:J.map(a=>a.name),g=[];for(let a of f)null===c[a]||void 0===c[a]?g.push(`${aM(a)} IS NULL`):(g.push(`${aM(a)} = ?`),e.push(c[a]));let h=`UPDATE ${aM(y)}.${aM(D)} SET ${d.join(", ")} WHERE ${g.join(" AND ")}`;try{await aQ("/api/mysql/query",{id:a,connectionString:b,sql:h,params:e}),ac(null),ay(D,T,aj,al)}catch(a){alert(`Update failed: ${a instanceof Error?a.message:String(a)}`)}},[ab,R,D,J,L,ad,a,b,y,ay,T,aj,al]),aC=(0,j.useCallback)(async()=>{if(!D)return;let c=[],d=[],e=[];for(let a of J)void 0!==ah[a.name]&&""!==ah[a.name]&&(c.push(aM(a.name)),d.push(ah[a.name]),e.push("?"));if(0===c.length)return;let f=`INSERT INTO ${aM(y)}.${aM(D)} (${c.join(", ")}) VALUES (${e.join(", ")})`;try{await aQ("/api/mysql/query",{id:a,connectionString:b,sql:f,params:d}),ag(!1),ai({}),ay(D,T,aj,al)}catch(a){alert(`Insert failed: ${a instanceof Error?a.message:String(a)}`)}},[D,J,ah,a,b,y,ay,T,aj,al]),aD=(0,j.useCallback)(async()=>{if(0===Z.size||!R||!D)return;let c=L.length>0?L:J.map(a=>a.name),d=0;for(let e of Array.from(Z).sort((a,b)=>b-a)){let f=R.rows[e];if(!f)continue;let g=[],h=[];for(let a of c)null===f[a]||void 0===f[a]?g.push(`${aM(a)} IS NULL`):(g.push(`${aM(a)} = ?`),h.push(f[a]));let i=`DELETE FROM ${aM(y)}.${aM(D)} WHERE ${g.join(" AND ")} LIMIT 1`;try{await aQ("/api/mysql/query",{id:a,connectionString:b,sql:i,params:h})}catch{d++}}$(new Set),aa(!1),ay(D,T,aj,al),d>0&&alert(p("mysql.deleteRowsFailed",{count:d}))},[Z,R,D,L,J,a,b,y,ay,T,aj,al]),aE=(0,j.useCallback)(async c=>{if(!D)return;if(Z.size>0&&R){let a,b=R.fields.map(a=>a.name),d=Array.from(Z).sort((a,b)=>a-b).map(a=>R.rows[a]).filter(Boolean);if("json"===c)a=JSON.stringify(d,null,2);else{let c=[b.join(",")];for(let a of d)c.push(b.map(b=>{let c=a[b];if(null==c)return"";let d="object"==typeof c?JSON.stringify(c):String(c);return d.includes(",")||d.includes('"')||d.includes("\n")?`"${d.replace(/"/g,'""')}"`:d}).join(","));a=c.join("\n")}navigator.clipboard.writeText(a);return}let d=`SELECT * FROM ${aM(y)}.${aM(D)}`;try{let e=await fetch("/api/mysql/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a,connectionString:b,sql:d,format:c})});if(!e.ok)throw Error("Export failed");let f=await e.blob(),g=URL.createObjectURL(f),h=document.createElement("a");h.href=g,h.download=`${D}.${c}`,h.click(),URL.revokeObjectURL(g)}catch(a){alert(`Export failed: ${a instanceof Error?a.message:String(a)}`)}},[D,a,b,y,Z,R]),aF=(0,j.useCallback)(a=>{(a.metaKey||a.ctrlKey)&&"Enter"===a.key&&(a.preventDefault(),aA())},[aA]),aG=Math.max(1,Math.ceil(X/50)),aH=(0,j.useCallback)(a=>{D&&(U(a),ay(D,a,aj,al))},[D,ay,aj,al]),aI=(0,j.useCallback)((a,b)=>{let c={...aj};b?c[a]=b:delete c[a],ak(c),U(0),$(new Set),D&&ay(D,0,c,al)},[aj,al,D,ay]),aJ=(0,j.useCallback)(()=>{ak({}),U(0),$(new Set),D&&ay(D,0,{},al)},[al,D,ay]),aK=(0,j.useCallback)(a=>{am(a),U(0),$(new Set),D&&ay(D,0,aj,a)},[aj,D,ay]);return(0,i.jsx)("div",{className:"flex flex-col items-start",children:(0,i.jsxs)("div",{className:`w-full bg-accent text-foreground
15
- relative transition-colors cursor-pointer
16
- ${e?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
17
- ${e?"":d?"border-brand":"border-brand/30"}`,onClick:e?void 0:h,children:[(0,i.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:m,onMouseDown:o,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${e?"bg-card":"bg-card/50"}`,style:e?{height:41}:void 0,children:[(0,i.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDC2C"}),(0,i.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),"connecting"===r&&(0,i.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"error"===r&&(0,i.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:p("mysql.connectionFailed")}),"connected"===r&&(0,i.jsx)("span",{className:"text-[10px] text-emerald-500 flex-shrink-0",children:p("mysql.connected")}),(0,i.jsx)("span",{className:"flex-1"}),n&&(0,i.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:aL(n)}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),m()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:e?p("browser.exitMaximize",{modKey:(0,z.Mu)()}):p("browser.maximize",{modKey:(0,z.Mu)()}),children:e?(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),l()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:p("common.close"),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,i.jsxs)("div",{style:{height:e&&f?f-41:g??360},className:"flex overflow-hidden",children:["connecting"===r&&(0,i.jsxs)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:[(0,i.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin mr-2"}),p("mysql.connecting")]}),"error"===r&&(0,i.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,i.jsx)("span",{className:"text-sm text-destructive text-center break-all",children:u}),(0,i.jsx)("button",{onClick:aw,className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:p("common.retry")})]}),"connected"===r&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"w-52 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,i.jsxs)("div",{className:"p-1.5 border-b border-border flex items-center gap-1",children:[w.length>1?(0,i.jsx)("select",{value:y,onChange:a=>{A(a.target.value),E(null)},className:"flex-1 min-w-0 text-xs bg-background border border-input rounded px-1.5 py-1",children:w.map(a=>(0,i.jsx)("option",{value:a,children:a},a))}):(0,i.jsx)("span",{className:"flex-1 min-w-0 text-xs text-muted-foreground truncate",children:y}),(0,i.jsx)("button",{onClick:ax,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent active:bg-accent/50 transition-colors",title:p("mysql.refreshTableList"),children:(0,i.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M1 1v5h5"}),(0,i.jsx)("path",{d:"M15 15v-5h-5"}),(0,i.jsx)("path",{d:"M13.5 6A6 6 0 0 0 3.2 3.2L1 6"}),(0,i.jsx)("path",{d:"M2.5 10a6 6 0 0 0 10.3 2.8L15 10"})]})})]}),(0,i.jsx)("div",{className:"flex items-center border-b border-border",children:["table","view"].map(a=>(0,i.jsx)("button",{onClick:()=>G(a),className:`flex-1 py-1 text-[10px] font-medium transition-colors ${F===a?"text-brand border-b border-brand":"text-muted-foreground hover:text-foreground"}`,children:{table:p("mysql.filterTable"),view:p("mysql.filterView")}[a]},a))}),(0,i.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[B.filter(a=>"table"===F?"view"!==a.type:"view"===a.type).map(a=>(0,i.jsxs)("div",{onClick:()=>az(a.name),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer truncate transition-colors ${D===a.name?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,i.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground",children:"view"===a.type?"V":"T"}),(0,i.jsx)("span",{className:"truncate min-w-0 flex-1",children:(0,i.jsx)(aP,{text:a.name})}),(0,i.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.rowEstimate>0?`~${a.rowEstimate}`:""})]},a.name)),0===B.length&&(0,i.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:p("mysql.noTables")})]})]}),(0,i.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,i.jsxs)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:[["structure","data","sql"].map(a=>(0,i.jsx)("button",{onClick:()=>I(a),className:`px-3 py-1.5 text-xs transition-colors ${H===a?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{structure:p("mysql.tabStructure"),data:p("mysql.tabData"),sql:"SQL"}[a]},a)),D&&"data"===H&&(0,i.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[Object.values(aj).some(a=>a.enabled)&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"text-[10px] text-brand",children:p("mysql.filterActive",{count:Object.values(aj).filter(a=>a.enabled).length})}),(0,i.jsx)("button",{onClick:aJ,className:"px-1 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",title:p("mysql.clearAllFilters"),children:"✕"}),(0,i.jsx)("span",{className:"text-border",children:"|"})]}),Z.size>0&&!_&&(0,i.jsx)("button",{onClick:()=>aa(!0),className:"px-1.5 py-0.5 text-[10px] text-destructive hover:text-destructive/80 bg-destructive/10 rounded transition-colors",children:p("mysql.deleteNRows",{count:Z.size})}),_&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"text-[10px] text-destructive",children:p("mysql.confirmDeleteRows")}),(0,i.jsx)("button",{onClick:aD,className:"px-1.5 py-0.5 text-[10px] text-white bg-destructive rounded transition-colors hover:bg-destructive/80",children:p("common.confirm")}),(0,i.jsx)("button",{onClick:()=>aa(!1),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:p("common.cancel")})]}),(0,i.jsx)("button",{onClick:()=>aE("csv"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:Z.size>0?p("mysql.copyCsvSelected"):p("mysql.copyCsvAll"),children:Z.size>0?p("mysql.copyCSV"):p("mysql.CSV")}),(0,i.jsx)("button",{onClick:()=>aE("json"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:Z.size>0?p("mysql.copyJsonSelected"):p("mysql.copyJsonAll"),children:Z.size>0?p("mysql.copyJSON"):p("mysql.JSON")})]})]}),(0,i.jsx)("div",{className:"flex-1 overflow-auto",children:D||"sql"===H?"structure"===H?(0,i.jsx)(aT,{columns:J,primaryKeys:L,foreignKeys:N,indexes:P}):"data"===H?(0,i.jsx)(aV,{result:R,loading:V,columns:J,page:T,totalPages:aG,totalRows:X,onPageChange:aH,filters:aj,sort:al,onFilterChange:aI,onSortChange:aK,selectedRows:Z,onSelectedRowsChange:a=>{$(a),aa(!1)},editingRowIdx:ab,editValues:ad,onStartEdit:a=>{if(!R)return;let b=R.rows[a],c={};for(let a of J)c[a.name]=null==b[a.name]?"":aO(b[a.name]);ae(c),ac(a)},onEditChange:(a,b)=>ae(c=>({...c,[a]:b})),onSaveEdit:aB,onCancelEdit:()=>ac(null),isAddingRow:af,newRowValues:ah,onStartAdd:()=>{ag(!0),ai({})},onNewRowChange:(a,b)=>ai(c=>({...c,[a]:b})),onSaveNewRow:aC,onCancelAdd:()=>{ag(!1),ai({})},onCellCopy:a=>{navigator.clipboard.writeText(a),q(p("common.copied"))}}):(0,i.jsx)(aW,{sqlInput:an,onSqlChange:ao,onExecute:aA,onKeyDown:aF,result:ap,error:ar,loading:at,sqlRef:av,onCellCopy:a=>{navigator.clipboard.writeText(a),q(p("common.copied"))}}):(0,i.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:p("mysql.selectTable")})})]})]})]}),!e&&(0,i.jsxs)("div",{className:"border-t border-border px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,i.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${"connected"===r?"bg-green-500":"error"===r?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,i.jsx)("span",{children:{connecting:p("common.connecting"),connected:p("common.connected"),error:p("common.connectionFailed")}[r]}),"connected"===r&&D&&(0,i.jsx)("span",{className:"text-muted-foreground/70",children:D}),(0,i.jsx)("span",{className:"flex-1"}),n&&(0,i.jsx)("span",{className:"text-[11px] flex-shrink-0",children:aL(n)})]})]})})}function aT({columns:a,primaryKeys:b,foreignKeys:c,indexes:d}){let{t:e}=(0,k.Bd)();return 0===a.length?(0,i.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:e("mysql.selectTableToView")}):(0,i.jsxs)("div",{className:"p-2 space-y-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:e("mysql.columns")}),(0,i.jsxs)("table",{className:"w-full text-xs",children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border",children:[(0,i.jsx)("th",{className:"px-1.5 py-1 font-medium",children:e("mysql.colName")}),(0,i.jsx)("th",{className:"px-1.5 py-1 font-medium",children:e("mysql.colType")}),(0,i.jsx)("th",{className:"px-1.5 py-1 font-medium",children:e("mysql.colNullable")}),(0,i.jsx)("th",{className:"px-1.5 py-1 font-medium",children:e("mysql.colDefault")})]})}),(0,i.jsx)("tbody",{children:a.map(a=>(0,i.jsxs)("tr",{className:"border-b border-border/50 hover:bg-accent/50",children:[(0,i.jsxs)("td",{className:"px-1.5 py-1 font-mono",children:[a.isPrimaryKey&&(0,i.jsx)("span",{className:"text-amber-500 mr-1",title:e("mysql.primaryKey"),children:"\uD83D\uDD11"}),a.name]}),(0,i.jsxs)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono",children:[a.type,a.maxLength?`(${a.maxLength})`:""]}),(0,i.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground",children:a.nullable?"YES":"NO"}),(0,i.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono truncate max-w-[120px]",children:a.default||""})]},a.name))})]})]}),c.length>0&&(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:e("mysql.foreignKeys")}),(0,i.jsx)("div",{className:"space-y-0.5",children:c.map((a,b)=>(0,i.jsxs)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground",children:[a.column," → ",a.refSchema,".",a.refTable,".",a.refColumn]},b))})]}),d.length>0&&(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:e("mysql.indexes")}),(0,i.jsx)("div",{className:"space-y-0.5",children:d.map(a=>(0,i.jsx)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground truncate",title:a.definition,children:a.name},a.name))})]})]})}function aU({filter:a,onApply:b,onClear:c,onToggle:d,onClose:e,colName:f,anchorRect:g}){let{t:h}=(0,k.Bd)(),[l,m]=(0,j.useState)(a?.op||"="),[n,o]=(0,j.useState)(a?.value||""),p=(0,j.useRef)(null),q=(0,am.F2)(),r="IS NULL"!==l&&"IS NOT NULL"!==l,s=()=>{(!r||n.trim())&&b({op:l,value:n.trim(),enabled:!0})},t=q?.getBoundingClientRect(),u=t?.left??0,v=t?.top??0,w=t?.width??1e3,x=g.left-u;x+220>w-8&&(x=w-220-8),x<8&&(x=8);let y=g.bottom+2-v;return(0,i.jsx)(am.ZL,{children:(0,i.jsxs)("div",{ref:p,className:"fixed z-[9998] w-[220px] bg-popover border border-border rounded-md shadow-lg p-2 space-y-2",style:{left:x,top:y},onClick:a=>a.stopPropagation(),children:[a&&(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground cursor-pointer",children:[(0,i.jsx)("input",{type:"checkbox",checked:a.enabled,onChange:a=>d(a.target.checked),className:"w-3 h-3 accent-brand"}),h("mysql.enable")]}),(0,i.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono truncate max-w-[120px]",children:f})]}),(0,i.jsx)("select",{value:l,onChange:a=>m(a.target.value),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-ring",children:aK.map(a=>(0,i.jsx)("option",{value:a.value,children:a.label},a.value))}),r&&(0,i.jsx)("input",{type:"text",value:n,onChange:a=>o(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),s())},placeholder:h("IN"===l?"mysql.commaValues":"LIKE"===l?"mysql.likePattern":"mysql.valuePlaceholder"),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 font-mono focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0}),(0,i.jsxs)("div",{className:"flex items-center gap-1",children:[(0,i.jsx)("button",{onClick:s,disabled:r&&!n.trim(),className:"flex-1 px-2 py-1 text-[10px] bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-40 transition-colors",children:h("mysql.apply")}),a&&(0,i.jsx)("button",{onClick:c,className:"flex-1 px-2 py-1 text-[10px] text-muted-foreground bg-muted rounded hover:text-foreground transition-colors",children:h("mysql.clearFilter")})]})]})})}function aV({result:a,loading:b,columns:c,page:d,totalPages:e,totalRows:f,onPageChange:g,filters:h,sort:l,onFilterChange:m,onSortChange:n,selectedRows:o,onSelectedRowsChange:p,editingRowIdx:q,editValues:r,onStartEdit:s,onEditChange:t,onSaveEdit:u,onCancelEdit:v,isAddingRow:w,newRowValues:x,onStartAdd:y,onNewRowChange:z,onSaveNewRow:A,onCancelAdd:B,onCellCopy:C}){let{t:D}=(0,k.Bd)(),[E,F]=(0,j.useState)(null),[G,H]=(0,j.useState)({left:0,bottom:0});if(!a&&!b)return(0,i.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:D("mysql.selectTableForData")});let I=a?.fields||[],J=a?.rows||[],K={};for(let a of c)K[a.name]=a.type+(a.maxLength?`(${a.maxLength})`:"");let L=J.length>0&&o.size===J.length,M=o.size>0&&!L;return(0,i.jsxs)("div",{className:"flex flex-col h-full",children:[(0,i.jsxs)("div",{className:"flex-1 overflow-auto relative",children:[b&&(0,i.jsx)("div",{className:"absolute inset-0 bg-background/50 flex items-center justify-center z-10",children:(0,i.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),(0,i.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,i.jsx)("thead",{className:"sticky top-0 bg-card z-[2]",children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{className:"px-1 py-1 border-b border-border w-8 text-center",children:(0,i.jsx)("input",{type:"checkbox",checked:L,ref:a=>{a&&(a.indeterminate=M)},onChange:()=>{L?p(new Set):p(new Set(J.map((a,b)=>b)))},className:"w-3 h-3 accent-brand cursor-pointer"})}),I.map(a=>{let b=l?.column===a.name?l.dir:null,c=h[a.name],d=c?.enabled;return(0,i.jsxs)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono relative",children:[(0,i.jsxs)("span",{className:"cursor-pointer select-none hover:text-foreground transition-colors",onClick:()=>{var b;return b=a.name,void(l?.column===b?"ASC"===l.dir?n({column:b,dir:"DESC"}):n(null):n({column:b,dir:"ASC"}))},children:[a.name,K[a.name]&&(0,i.jsx)("span",{className:"ml-1 text-[9px] text-muted-foreground/60 font-normal",children:K[a.name]}),"ASC"===b&&(0,i.jsx)("span",{className:"ml-0.5 text-brand",children:"↑"}),"DESC"===b&&(0,i.jsx)("span",{className:"ml-0.5 text-brand",children:"↓"})]}),(0,i.jsx)("button",{onClick:b=>{if(b.stopPropagation(),E===a.name)return void F(null);let c=b.currentTarget.closest("th").getBoundingClientRect();H({left:c.left,bottom:c.bottom}),F(a.name)},className:`ml-1 inline-flex items-center transition-colors ${d?"text-brand":"text-muted-foreground/40 hover:text-muted-foreground"}`,children:(0,i.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,i.jsx)("path",{d:"M1 2h14l-5.5 6.5V14l-3-2v-3.5z"})})}),E===a.name&&(0,i.jsx)(aU,{filter:c||null,onApply:b=>{m(a.name,b),F(null)},onClear:()=>{m(a.name,null),F(null)},onToggle:b=>{c&&m(a.name,{...c,enabled:b})},onClose:()=>F(null),colName:a.name,anchorRect:G})]},a.name)})]})}),(0,i.jsxs)("tbody",{children:[w&&(0,i.jsxs)("tr",{className:"bg-emerald-500/5",children:[(0,i.jsx)("td",{className:"px-1 py-0.5 border-b border-border text-center",children:(0,i.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,i.jsx)("button",{onClick:A,className:"text-[10px] text-emerald-500 hover:text-emerald-400",title:D("common.save"),children:"✓"}),(0,i.jsx)("button",{onClick:B,className:"text-[10px] text-muted-foreground hover:text-foreground",title:D("common.cancel"),children:"✕"})]})}),I.map(a=>(0,i.jsx)("td",{className:"px-0.5 py-0.5 border-b border-border",children:(0,i.jsx)("input",{type:"text",value:x[a.name]??"",onChange:b=>z(a.name,b.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]",placeholder:"NULL"})},a.name))]}),J.map((a,b)=>(0,i.jsxs)("tr",{className:`hover:bg-accent/50 ${o.has(b)?"bg-brand/5":""} ${q===b?"bg-blue-500/5":""}`,children:[(0,i.jsx)("td",{className:"px-1 py-0.5 border-b border-border/50 text-center",children:q===b?(0,i.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,i.jsx)("button",{onClick:u,className:"text-[10px] text-emerald-500 hover:text-emerald-400",title:D("common.save"),children:"✓"}),(0,i.jsx)("button",{onClick:v,className:"text-[10px] text-muted-foreground hover:text-foreground",title:D("common.cancel"),children:"✕"})]}):(0,i.jsx)("input",{type:"checkbox",checked:o.has(b),onChange:()=>{let a;(a=new Set(o)).has(b)?a.delete(b):a.add(b),p(a)},className:"w-3 h-3 accent-brand cursor-pointer"})}),I.map(c=>(0,i.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onDoubleClick:()=>{null===q&&s(b)},onContextMenu:b=>{b.preventDefault(),C(aO(a[c.name]))},children:q===b?(0,i.jsx)("input",{type:"text",value:r[c.name]??"",onChange:a=>t(c.name,a.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]"}):null===a[c.name]||void 0===a[c.name]?(0,i.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,i.jsx)(aP,{text:aO(a[c.name])})},c.name))]},b))]})]}),0===J.length&&!b&&(0,i.jsx)("div",{className:"p-4 text-xs text-muted-foreground text-center",children:D("common.noData")})]}),(0,i.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 border-t border-border text-[10px] text-muted-foreground bg-card/30 flex-shrink-0",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("button",{onClick:y,disabled:w,className:"px-1.5 py-0.5 text-[10px] text-emerald-500 hover:text-emerald-400 disabled:opacity-30",children:D("mysql.addRow")}),(0,i.jsx)("span",{children:D("mysql.totalRows",{count:f})}),a?.duration!==void 0&&(0,i.jsxs)("span",{children:[a.duration,"ms"]})]}),(0,i.jsxs)("div",{className:"flex items-center gap-1",children:[(0,i.jsx)("button",{onClick:()=>g(d-1),disabled:0===d,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"◀"}),(0,i.jsxs)("span",{children:[d+1," / ",e]}),(0,i.jsx)("button",{onClick:()=>g(d+1),disabled:d>=e-1,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"▶"})]})]})]})}function aW({sqlInput:a,onSqlChange:b,onExecute:c,onKeyDown:d,result:e,error:f,loading:g,sqlRef:h,onCellCopy:j}){let{t:l}=(0,k.Bd)();return(0,i.jsxs)("div",{className:"flex flex-col h-full",children:[(0,i.jsxs)("div",{className:"flex-shrink-0 p-2 border-b border-border",children:[(0,i.jsx)("textarea",{ref:h,value:a,onChange:a=>b(a.target.value),onKeyDown:d,placeholder:l("mysql.sqlPlaceholder",{modKey:(0,z.Mu)()}),className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,i.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,i.jsx)("button",{onClick:c,disabled:g||!a.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:l(g?"mysql.executing":"mysql.execute")}),e?.duration!==void 0&&(0,i.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[e.command&&!e.fields?l("mysql.rowsAffected",{command:e.command,count:e.rowCount,duration:e.duration}):l("mysql.queryRows",{count:e.rows?.length??0,duration:e.duration}),e.truncated&&` ${l("mysql.resultTruncated")}`]})]})]}),f&&(0,i.jsx)("div",{className:"px-3 py-2 text-xs text-destructive bg-destructive/5 border-b border-border break-all",children:f}),e?.fields&&e.rows&&(0,i.jsx)("div",{className:"flex-1 overflow-auto",children:(0,i.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,i.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,i.jsx)("tr",{children:e.fields.map(a=>(0,i.jsx)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono",children:a.name},a.name))})}),(0,i.jsx)("tbody",{children:e.rows.map((a,b)=>(0,i.jsx)("tr",{className:"hover:bg-accent/50",children:e.fields.map(b=>(0,i.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onContextMenu:c=>{c.preventDefault(),j(aO(a[b.name]))},children:null===a[b.name]||void 0===a[b.name]?(0,i.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,i.jsx)(aP,{text:aO(a[b.name])})},b.name))},b))})]})})]})}async function aX(a,b){let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(!c.ok)throw Error(d.error||`HTTP ${c.status}`);return d}ag({type:"mysql",idPrefix:"mysql",match:a=>a.trim().toLowerCase().startsWith("mysql://"),parse(a){let b=a.trim(),c=b;try{let a=new URL(b),d=a.pathname.replace(/^\//,"")||"mysql";c=`${d}@${a.hostname}${a.port?":"+a.port:""}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:d,bubbleContentHeight:e,timestamp:f,onSelect:g,onClose:h,onToggleMaximize:j,onTitleMouseDown:k}){return(0,i.jsx)(aS,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:d,bubbleContentHeight:e,timestamp:f,onSelect:g,onClose:h,onToggleMaximize:j,onTitleMouseDown:k})},async onClose(a){try{await fetch("/api/mysql/disconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a.id})})}catch{}}});let aY={string:{label:"S",color:"text-emerald-500 bg-emerald-500/10"},hash:{label:"H",color:"text-blue-500 bg-blue-500/10"},list:{label:"L",color:"text-orange-500 bg-orange-500/10"},set:{label:"SET",color:"text-teal-500 bg-teal-500/10"},zset:{label:"Z",color:"text-purple-500 bg-purple-500/10"},stream:{label:"STR",color:"text-pink-500 bg-pink-500/10"}};function aZ({type:a}){let b=aY[a]||{label:"?",color:"text-muted-foreground bg-muted"};return(0,i.jsx)("span",{className:`inline-block text-[9px] font-mono font-bold leading-none px-1 py-0.5 rounded flex-shrink-0 ${b.color}`,children:b.label})}function a$({text:a}){let[b,c]=(0,j.useState)(!1),[d,e]=(0,j.useState)({x:0,y:0,above:!0}),f=(0,j.useRef)(null),g=(0,j.useRef)(null),h=(0,am.F2)(),k=(0,j.useCallback)(()=>{g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{let a=f.current;if(!a||a.scrollWidth<=a.clientWidth)return;let b=a.getBoundingClientRect(),d=h?.getBoundingClientRect(),g=d?.left??0,i=d?.top??0,j=d?.height??window.innerHeight,k=b.top-i,l=b.bottom-i,m=k>j/2;e({x:b.left-g,y:m?k-4:l+4,above:m}),c(!0)},350)},[h]),l=(0,j.useCallback)(()=>{g.current&&clearTimeout(g.current),c(!1)},[]);return(0,i.jsxs)("span",{ref:f,className:"block truncate",onMouseEnter:k,onMouseLeave:l,children:[a,b&&(0,i.jsx)(am.ZL,{children:(0,i.jsx)("div",{className:"fixed z-[9999] max-w-[500px] max-h-[200px] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lg whitespace-pre-wrap break-all select-text",style:{left:d.x,top:d.y,transform:d.above?"translateY(-100%)":void 0},children:a})})]})}function a_({id:a,connectionString:b,displayName:c,selected:d,maximized:e,expandedHeight:f,bubbleContentHeight:g,onSelect:h,onClose:l,onToggleMaximize:m,timestamp:n,onTitleMouseDown:o}){var p;let{t:q}=(0,k.Bd)(),{showToast:r}=(0,t.dj)(),[s,u]=(0,j.useState)("connecting"),[v,w]=(0,j.useState)(""),[x,y]=(0,j.useState)(null),[A,B]=(0,j.useState)([]),[C,D]=(0,j.useState)("0"),[E,F]=(0,j.useState)(!1),[G,H]=(0,j.useState)("*"),[I,J]=(0,j.useState)(!1),[K,L]=(0,j.useState)(null),[M,N]=(0,j.useState)(null),[O,P]=(0,j.useState)(!1),[Q,R]=(0,j.useState)(null),[S,T]=(0,j.useState)(!1),[U,V]=(0,j.useState)("data"),[W,X]=(0,j.useState)(""),[Y,Z]=(0,j.useState)(""),[$,_]=(0,j.useState)([]),[aa,ab]=(0,j.useState)(!1),ac=(0,j.useRef)(null),ad=(0,j.useRef)(null),ae=(0,j.useCallback)(async()=>{u("connecting"),w("");try{let c=await aX("/api/redis/connect",{id:a,connectionString:b});y(c),u("connected")}catch(a){w(a instanceof Error?a.message:String(a)),u("error")}},[a,b]),af=(0,j.useCallback)(async(c,d,e)=>{J(!0);try{let f=await aX("/api/redis/keys",{id:a,connectionString:b,pattern:c,cursor:d,count:200});B(a=>e?[...a,...f.keys]:f.keys),D(f.cursor),F(f.hasMore)}catch{}J(!1)},[a,b]),ag=(0,j.useCallback)(()=>{L(null),N(null),af(G,"0",!1)},[G,af]),ah=(0,j.useCallback)(async c=>{L(c),P(!0),R(null),T(!1);try{let d=await aX("/api/redis/get",{id:a,connectionString:b,key:c});N(d)}catch(a){N(null),r(a instanceof Error?a.message:q("redis.loadFailed"))}P(!1)},[a,b,r]),ai=(0,j.useCallback)(async()=>{if(K)try{await aX("/api/redis/delete",{id:a,connectionString:b,keys:[K]}),L(null),N(null),T(!1),af(G,"0",!1)}catch(a){r(a instanceof Error?a.message:q("redis.deleteFailed"))}},[K,a,b,G,af,r]),aj=(0,j.useCallback)(async()=>{if(K&&null!==Q)try{await aX("/api/redis/set",{id:a,connectionString:b,key:K,value:Q,type:"string"}),R(null),ah(K),r(q("common.saved"))}catch(a){r(a instanceof Error?a.message:q("redis.saveFailed"))}},[K,Q,a,b,ah,r]),ak=(0,j.useCallback)(async()=>{try{let c=await aX("/api/redis/command",{id:a,connectionString:b,command:"INFO"});X("string"==typeof c.result?c.result:String(c.result))}catch{}},[a,b]),al=(0,j.useCallback)(async()=>{let c,d=Y.trim();if(!d)return;ab(!0),Z("");let e=[],f=/(?:"([^"]*)")|(?:'([^']*)')|(\S+)/g;for(;null!==(c=f.exec(d));)e.push(c[1]??c[2]??c[3]);let g=e[0]||"",h=e.slice(1);try{let c=await aX("/api/redis/command",{id:a,connectionString:b,command:g,args:h});_(a=>[...a,{command:d,result:c.result,duration:c.duration,isError:!1}])}catch(a){_(b=>[...b,{command:d,result:a instanceof Error?a.message:String(a),duration:0,isError:!0}])}ab(!1)},[Y,a,b]);return(0,i.jsx)("div",{className:"flex flex-col items-start",children:(0,i.jsxs)("div",{className:`w-full bg-accent text-foreground
18
- relative transition-colors cursor-pointer
19
- ${e?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
20
- ${e?"":d?"border-brand":"border-brand/30"}`,onClick:e?void 0:h,children:[(0,i.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:m,onMouseDown:o,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${e?"bg-card":"bg-card/50"}`,style:e?{height:41}:void 0,children:[(0,i.jsx)("span",{className:"text-sm flex-shrink-0",children:"♦"}),(0,i.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),"connecting"===s&&(0,i.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"error"===s&&(0,i.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:q("common.connectionFailed")}),"connected"===s&&x&&(0,i.jsxs)("span",{className:"text-[10px] text-red-500 flex-shrink-0",children:["v",x.version," \xb7 ",x.dbSize," keys \xb7 ",x.memory]}),(0,i.jsx)("span",{className:"flex-1"}),n&&(0,i.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:function(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}(n)}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),m()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:e?q("browser.exitMaximize",{modKey:(0,z.Mu)()}):q("browser.maximize",{modKey:(0,z.Mu)()}),children:e?(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),l()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:q("common.close"),children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,i.jsxs)("div",{style:{height:e&&f?f-41:g??360},className:"flex overflow-hidden",children:["connecting"===s&&(0,i.jsxs)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:[(0,i.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin mr-2"}),q("common.connecting"),"..."]}),"error"===s&&(0,i.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,i.jsx)("span",{className:"text-sm text-destructive text-center break-all",children:v}),(0,i.jsx)("button",{onClick:ae,className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:q("common.retry")})]}),"connected"===s&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"w-52 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,i.jsxs)("div",{className:"p-1.5 border-b border-border flex items-center gap-1",children:[(0,i.jsx)("input",{type:"text",value:G,onChange:a=>H(a.target.value),onKeyDown:a=>{"Enter"===a.key&&ag()},placeholder:q("redis.scanPlaceholder"),className:"flex-1 min-w-0 text-xs bg-background border border-input rounded px-1.5 py-1 font-mono focus:outline-none focus:ring-1 focus:ring-ring"}),(0,i.jsx)("button",{onClick:ag,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent active:bg-accent/50 transition-colors",title:q("redis.scanSearch"),children:(0,i.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"6.5",cy:"6.5",r:"4.5"}),(0,i.jsx)("path",{d:"M10 10l4 4"})]})}),(0,i.jsx)("button",{onClick:()=>af(G,"0",!1),className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent active:bg-accent/50 transition-colors",title:q("common.refresh"),children:(0,i.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M1 1v5h5"}),(0,i.jsx)("path",{d:"M15 15v-5h-5"}),(0,i.jsx)("path",{d:"M13.5 6A6 6 0 0 0 3.2 3.2L1 6"}),(0,i.jsx)("path",{d:"M2.5 10a6 6 0 0 0 10.3 2.8L15 10"})]})})]}),(0,i.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[A.map(a=>(0,i.jsxs)("div",{onClick:()=>ah(a.key),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer transition-colors ${K===a.key?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,i.jsx)(aZ,{type:a.type}),(0,i.jsx)("span",{className:"truncate min-w-0 flex-1 font-mono",children:(0,i.jsx)(a$,{text:a.key})})]},a.key)),0===A.length&&!I&&(0,i.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:q("redis.noKeys")}),I&&(0,i.jsx)("div",{className:"p-2 flex items-center justify-center",children:(0,i.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"})}),E&&!I&&(0,i.jsx)("button",{onClick:()=>af(G,C,!0),className:"w-full py-1.5 text-[10px] text-brand hover:text-brand/80 transition-colors",children:q("redis.loadMore")})]}),(0,i.jsxs)("div",{className:"px-2 py-1 border-t border-border text-[10px] text-muted-foreground",children:[A.length," keys",E?"+":"",x?` / ${x.dbSize} total`:""]})]}),(0,i.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,i.jsxs)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:[["data","info","cli"].map(a=>(0,i.jsx)("button",{onClick:()=>V(a),className:`px-3 py-1.5 text-xs transition-colors ${U===a?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{data:q("redis.tabData"),info:q("redis.tabInfo"),cli:"CLI"}[a]},a)),K&&"data"===U&&(0,i.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[M&&(0,i.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:["TTL: ",function(a,b){if(-1===a)return b("redis.neverExpires");if(-2===a)return b("redis.expired");if(a<60)return`${a}s`;if(a<3600)return`${Math.floor(a/60)}m${a%60>0?` ${a%60}s`:""}`;let c=Math.floor(a/3600),d=Math.floor(a%3600/60);return`${c}h${d>0?` ${d}m`:""}`}(M.ttl,q),null!==M.size?` \xb7 ${null==(p=M.size)?"":p<1024?`${p} B`:p<1048576?`${(p/1024).toFixed(1)} KB`:`${(p/1048576).toFixed(1)} MB`}`:""]}),S?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("span",{className:"text-[10px] text-destructive",children:[q("common.confirm"),"?"]}),(0,i.jsx)("button",{onClick:ai,className:"px-1.5 py-0.5 text-[10px] text-white bg-destructive rounded transition-colors hover:bg-destructive/80",children:q("common.confirm")}),(0,i.jsx)("button",{onClick:()=>T(!1),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:q("common.cancel")})]}):(0,i.jsx)("button",{onClick:()=>T(!0),className:"px-1.5 py-0.5 text-[10px] text-destructive hover:text-destructive/80 bg-destructive/10 rounded transition-colors",children:q("common.delete")})]})]}),(0,i.jsx)("div",{className:"flex-1 overflow-auto",children:"data"===U?(0,i.jsx)(a0,{selectedKey:K,keyValue:M,keyLoading:O,editingValue:Q,onStartEdit:a=>R(a),onEditChange:R,onSaveEdit:aj,onCancelEdit:()=>R(null),onCellCopy:a=>{navigator.clipboard.writeText(a),r(q("common.copied"))}}):"info"===U?(0,i.jsx)(a1,{infoText:W,onRefresh:ak}):(0,i.jsx)(a2,{cliInput:Y,onInputChange:Z,onExecute:al,history:$,loading:aa,endRef:ac,inputRef:ad})})]})]})]})]})})}function a0({selectedKey:a,keyValue:b,keyLoading:c,editingValue:d,onStartEdit:e,onEditChange:f,onSaveEdit:g,onCancelEdit:h,onCellCopy:j}){let{t:l}=(0,k.Bd)();if(!a)return(0,i.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:l("redis.selectKey")});if(c)return(0,i.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,i.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})});if(!b)return(0,i.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:l("redis.keyNotExist")});let{type:m,value:n}=b;if("string"===m){let b=String(n??""),c=null!==d;return(0,i.jsxs)("div",{className:"p-3 h-full flex flex-col",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,i.jsx)(aZ,{type:"string"}),(0,i.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a}),(0,i.jsx)("span",{className:"flex-1"}),c?(0,i.jsxs)("div",{className:"flex gap-1",children:[(0,i.jsx)("button",{onClick:g,className:"px-2 py-0.5 text-[10px] text-white bg-brand rounded hover:bg-brand/90",children:l("common.save")}),(0,i.jsx)("button",{onClick:h,className:"px-2 py-0.5 text-[10px] text-muted-foreground bg-muted rounded hover:text-foreground",children:l("common.cancel")})]}):(0,i.jsx)("button",{onClick:()=>e(b),className:"px-2 py-0.5 text-[10px] text-brand hover:text-brand/80 bg-brand/10 rounded transition-colors",children:l("common.edit")})]}),c?(0,i.jsx)("textarea",{value:d,onChange:a=>f(a.target.value),className:"flex-1 w-full px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-none focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}):(0,i.jsx)("pre",{className:"flex-1 overflow-auto text-xs font-mono bg-muted/30 rounded p-2 whitespace-pre-wrap break-all select-text cursor-text",onContextMenu:a=>{a.preventDefault(),j(b)},children:b})]})}if("hash"===m){let b=Object.entries(n||{});return(0,i.jsxs)("div",{className:"h-full flex flex-col",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,i.jsx)(aZ,{type:"hash"}),(0,i.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a}),(0,i.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[b.length," fields"]})]}),(0,i.jsx)("div",{className:"flex-1 overflow-auto",children:(0,i.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,i.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border w-1/3",children:"Field"}),(0,i.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Value"})]})}),(0,i.jsx)("tbody",{children:b.map(([a,b])=>(0,i.jsxs)("tr",{className:"hover:bg-accent/50",children:[(0,i.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[150px]",onContextMenu:b=>{b.preventDefault(),j(a)},children:(0,i.jsx)(a$,{text:a})}),(0,i.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[300px]",onContextMenu:a=>{a.preventDefault(),j(b)},children:(0,i.jsx)(a$,{text:b})})]},a))})]})})]})}if("list"===m){let b=n?.items||[],c=n?.total||0;return(0,i.jsxs)("div",{className:"h-full flex flex-col",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,i.jsx)(aZ,{type:"list"}),(0,i.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a}),(0,i.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[l("redis.nItems",{total:c}),b.length<c?` (${l("redis.showingN",{count:b.length})})`:""]})]}),(0,i.jsx)("div",{className:"flex-1 overflow-auto",children:(0,i.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,i.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border w-16",children:"#"}),(0,i.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Value"})]})}),(0,i.jsx)("tbody",{children:b.map((a,b)=>(0,i.jsxs)("tr",{className:"hover:bg-accent/50",children:[(0,i.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 text-muted-foreground",children:b}),(0,i.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[300px]",onContextMenu:b=>{b.preventDefault(),j(a)},children:(0,i.jsx)(a$,{text:a})})]},b))})]})})]})}if("set"===m){let b=n?.items||[],c=n?.total||0;return(0,i.jsxs)("div",{className:"h-full flex flex-col",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,i.jsx)(aZ,{type:"set"}),(0,i.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a}),(0,i.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[l("redis.nMembers",{total:c}),b.length<c?` (${l("redis.showingN",{count:b.length})})`:""]})]}),(0,i.jsx)("div",{className:"flex-1 overflow-auto",children:(0,i.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,i.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,i.jsx)("tr",{children:(0,i.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Member"})})}),(0,i.jsx)("tbody",{children:b.map((a,b)=>(0,i.jsx)("tr",{className:"hover:bg-accent/50",children:(0,i.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[400px]",onContextMenu:b=>{b.preventDefault(),j(a)},children:(0,i.jsx)(a$,{text:a})})},b))})]})})]})}if("zset"===m){let b=n?.items||[],c=n?.total||0;return(0,i.jsxs)("div",{className:"h-full flex flex-col",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,i.jsx)(aZ,{type:"zset"}),(0,i.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a}),(0,i.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[l("redis.nMembers",{total:c}),b.length<c?` (${l("redis.showingN",{count:b.length})})`:""]})]}),(0,i.jsx)("div",{className:"flex-1 overflow-auto",children:(0,i.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,i.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Member"}),(0,i.jsx)("th",{className:"px-2 py-1 text-right text-muted-foreground font-medium border-b border-border w-28",children:"Score"})]})}),(0,i.jsx)("tbody",{children:b.map((a,b)=>(0,i.jsxs)("tr",{className:"hover:bg-accent/50",children:[(0,i.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[300px]",onContextMenu:b=>{b.preventDefault(),j(a.member)},children:(0,i.jsx)(a$,{text:a.member})}),(0,i.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono text-right text-muted-foreground",children:a.score})]},b))})]})})]})}if("stream"===m){let b=n?.entries||[],c=n?.total||0;return(0,i.jsxs)("div",{className:"h-full flex flex-col",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,i.jsx)(aZ,{type:"stream"}),(0,i.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a}),(0,i.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[l("redis.nEntries",{total:c}),b.length<c?` (${l("redis.showingN",{count:b.length})})`:""]})]}),(0,i.jsx)("div",{className:"flex-1 overflow-auto",children:(0,i.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,i.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border w-40",children:"ID"}),(0,i.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Fields"})]})}),(0,i.jsx)("tbody",{children:b.map(([a,b])=>{let c=[];for(let a=0;a<b.length;a+=2)c.push(`${b[a]}: ${b[a+1]}`);return(0,i.jsxs)("tr",{className:"hover:bg-accent/50",children:[(0,i.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono text-muted-foreground",children:a}),(0,i.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[300px]",children:(0,i.jsx)(a$,{text:c.join(", ")})})]},a)})})]})})]})}return(0,i.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:l("redis.unsupportedType",{type:m})})}function a1({infoText:a,onRefresh:b}){let{t:c}=(0,k.Bd)();if(!a)return(0,i.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,i.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})});let d=[],e=null;for(let b of a.split("\n")){let a=b.trim();if(a){if(a.startsWith("#"))e={title:a.replace(/^#\s*/,""),items:[]},d.push(e);else if(e&&a.includes(":")){let b=a.indexOf(":");e.items.push({key:a.slice(0,b),value:a.slice(b+1)})}}}return(0,i.jsxs)("div",{className:"p-2 space-y-3 overflow-auto h-full",children:[(0,i.jsx)("div",{className:"flex justify-end",children:(0,i.jsx)("button",{onClick:b,className:"px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:c("common.refresh")})}),d.map(a=>(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1 font-medium",children:a.title}),(0,i.jsx)("div",{className:"space-y-0",children:a.items.map(({key:a,value:b})=>(0,i.jsxs)("div",{className:"flex items-start gap-2 px-1.5 py-0.5 text-xs hover:bg-accent/50 rounded",children:[(0,i.jsx)("span",{className:"text-muted-foreground font-mono flex-shrink-0 w-48 truncate",children:a}),(0,i.jsx)("span",{className:"font-mono text-foreground break-all",children:b})]},a))})]},a.title))]})}function a2({cliInput:a,onInputChange:b,onExecute:c,history:d,loading:e,endRef:f,inputRef:g}){let{t:h}=(0,k.Bd)();return(0,i.jsxs)("div",{className:"flex flex-col h-full",children:[(0,i.jsxs)("div",{className:"flex-1 overflow-auto p-2 font-mono text-xs space-y-2",onClick:()=>g.current?.focus(),children:[0===d.length&&(0,i.jsx)("div",{className:"text-muted-foreground text-center py-4",children:h("redis.cliHint")}),d.map((a,b)=>(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"text-brand",children:[(0,i.jsx)("span",{className:"text-muted-foreground mr-1",children:">"}),a.command,a.duration>0&&(0,i.jsxs)("span",{className:"text-muted-foreground/50 ml-2",children:["(",a.duration,"ms)"]})]}),(0,i.jsx)("pre",{className:`whitespace-pre-wrap break-all mt-0.5 ${a.isError?"text-destructive":"text-foreground"}`,children:a.isError?`(error) ${a.result}`:function a(b,c=0){let d=" ".repeat(c);return null===b?`${d}(nil)`:"number"==typeof b?`${d}(integer) ${b}`:"string"==typeof b?`${d}"${b}"`:Array.isArray(b)?0===b.length?`${d}(empty array)`:b.map((b,c)=>`${d}${c+1}) ${a(b,0)}`).join("\n"):`${d}${String(b)}`}(a.result)})]},b)),(0,i.jsx)("div",{ref:f})]}),(0,i.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 border-t border-border bg-card/30 flex-shrink-0",children:[(0,i.jsx)("span",{className:"text-xs text-brand font-mono flex-shrink-0",children:">"}),(0,i.jsx)("input",{ref:g,type:"text",value:a,onChange:a=>b(a.target.value),onKeyDown:a=>{"Enter"!==a.key||e||c()},placeholder:h("redis.cliPlaceholder"),className:"flex-1 min-w-0 text-xs font-mono bg-transparent border-0 focus:outline-none",autoComplete:"off",spellCheck:!1,disabled:e}),e&&(0,i.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"})]})]})}ag({type:"redis",idPrefix:"redis",match(a){let b=a.trim().toLowerCase();return b.startsWith("redis://")||b.startsWith("rediss://")},parse(a){let b=a.trim(),c=b;try{let a=new URL(b),d=a.pathname.replace(/^\//,"")||"0";c=`db${d}@${a.hostname}${a.port?":"+a.port:":6379"}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:d,bubbleContentHeight:e,timestamp:f,onSelect:g,onClose:h,onToggleMaximize:j,onTitleMouseDown:k}){return(0,i.jsx)(a_,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:d,bubbleContentHeight:e,timestamp:f,onSelect:g,onClose:h,onToggleMaximize:j,onTitleMouseDown:k})},async onClose(a){try{await fetch("/api/redis/disconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a.id})})}catch{}}});let a3=["#4C8BF5","#E74C3C","#2ECC71","#F39C12","#9B59B6","#1ABC9C","#E67E22","#3498DB","#E91E63","#00BCD4"];async function a4(a,b){let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(!c.ok)throw Error(d.error||`HTTP ${c.status}`);return d}function a5(a){if(!a)return"";let b=new Date(a);return isNaN(b.getTime())?"":`${String(b.getMonth()+1).padStart(2,"0")}-${String(b.getDate()).padStart(2,"0")} ${String(b.getHours()).padStart(2,"0")}:${String(b.getMinutes()).padStart(2,"0")}`}function a6({nodes:a,rels:b,allLabels:c}){let d=(0,j.useRef)(null),e=(0,j.useRef)(null),f=(0,j.useRef)([]);(0,j.useRef)(0);let g=(0,j.useRef)(null);(0,j.useRef)({w:0,h:0}),(0,j.useRef)(new Map);let[h,k]=(0,j.useState)(null),l=(0,j.useRef)(null),m=(0,j.useCallback)(a=>{let b=e.current?.getBoundingClientRect();if(!b)return null;let c=a.clientX-b.left,d=a.clientY-b.top;return f.current.find(a=>{let b=(a.x||0)-c,e=(a.y||0)-d;return b*b+e*e<400})||null},[]);return(0,i.jsxs)("div",{ref:d,className:"relative w-full h-full",children:[(0,i.jsx)("canvas",{ref:e,className:"cursor-grab active:cursor-grabbing absolute inset-0",onMouseDown:a=>{let b=m(a);if(b){let c=e.current.getBoundingClientRect();g.current={nodeId:b.id,offsetX:a.clientX-c.left-(b.x||0),offsetY:a.clientY-c.top-(b.y||0)}}},onMouseMove:a=>{if(g.current){let b=e.current.getBoundingClientRect(),c=f.current.find(a=>a.id===g.current.nodeId);c&&(c.x=a.clientX-b.left-g.current.offsetX,c.y=a.clientY-b.top-g.current.offsetY,c.vx=0,c.vy=0)}else{let b=m(a);l.current=b,k(b)}},onMouseUp:()=>{g.current=null},onMouseLeave:()=>{g.current=null,l.current=null,k(null)}}),h&&!g.current&&(0,i.jsxs)("div",{className:"absolute top-2 left-2 bg-popover text-popover-foreground border border-border rounded px-2 py-1 text-xs max-w-[300px] pointer-events-none",children:[(0,i.jsxs)("div",{className:"font-medium",children:[h.labels.join(", ")," #",String(h.id)]}),Object.entries(h.properties).slice(0,8).map(([a,b])=>(0,i.jsxs)("div",{className:"truncate",children:[(0,i.jsxs)("span",{className:"text-muted-foreground",children:[a,":"]})," ",String(b)]},a))]})]})}function a7({id:a,connectionString:b,displayName:c,selected:d,maximized:e,expandedHeight:f,bubbleContentHeight:g,onSelect:h,onClose:k,onToggleMaximize:l,timestamp:m,onTitleMouseDown:n}){let[o,p]=(0,j.useState)("connecting"),[q,r]=(0,j.useState)(""),[s,t]=(0,j.useState)(null),[u,v]=(0,j.useState)(null),[w,x]=(0,j.useState)(!1),[y,A]=(0,j.useState)("labels"),[B,C]=(0,j.useState)(""),[D,E]=(0,j.useState)(null),[F,G]=(0,j.useState)(!1),[H,I]=(0,j.useState)(""),J=(0,j.useRef)(null),[K,L]=(0,j.useState)([]),[M,N]=(0,j.useState)([]),[O,P]=(0,j.useState)("schema"),Q=(0,j.useCallback)(async()=>{p("connecting");try{let c=await a4("/api/neo4j/connect",{id:a,connectionString:b});t(c),p("connected")}catch(a){r(a instanceof Error?a.message:String(a)),p("error")}},[a,b]),R=(0,j.useCallback)(async()=>{x(!0);try{let c=await a4("/api/neo4j/schema",{id:a,connectionString:b});v(c)}catch{}x(!1)},[a,b]),S=(0,j.useCallback)(async c=>{let d=c||B.trim();if(d){G(!0),I("");try{var e;let c,f,g=await a4("/api/neo4j/query",{id:a,connectionString:b,cypher:d});E(g);let{nodes:h,rels:i}=(e=g.records,c=new Map,f=[],e.forEach(a=>Object.values(a).forEach(function a(b){if(b&&"object"==typeof b)if("node"===b._type){let a=b._id;c.has(a)||c.set(a,{id:a,labels:b._labels||[],properties:Object.fromEntries(Object.entries(b).filter(([a])=>!a.startsWith("_")))})}else if("relationship"===b._type)f.push({id:b._id,type:b._relType,startId:b._start,endId:b._end,properties:Object.fromEntries(Object.entries(b).filter(([a])=>!a.startsWith("_")))});else if("path"===b._type){let c=b.segments;c?.forEach(b=>{a(b.start),a(b.relationship),a(b.end)})}else Array.isArray(b)&&b.forEach(a)})),{nodes:Array.from(c.values()),rels:f});h.length>0&&(L(h),N(i))}catch(a){I(a instanceof Error?a.message:String(a))}G(!1)}},[a,b,B]),T=(0,j.useCallback)(a=>{let b=`MATCH (n:\`${a}\`) RETURN n LIMIT 25`;C(b),P("cypher"),S(b)},[S]),U=(0,j.useCallback)(a=>{let b=`MATCH (a)-[r:\`${a}\`]->(b) RETURN a, r, b LIMIT 25`;C(b),P("graph"),S(b)},[S]);return(0,i.jsx)("div",{className:"flex flex-col items-start",onClick:h,children:(0,i.jsxs)("div",{className:`w-full bg-accent text-foreground relative transition-colors ${d?"ring-1 ring-ring":""} rounded-lg overflow-hidden`,children:[(0,i.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:l,onMouseDown:n,className:"flex items-center gap-2 px-4 py-1.5 border-b border-border cursor-grab active:cursor-grabbing select-none",children:[(0,i.jsx)("span",{className:"text-sm flex-shrink-0",children:"⬡"}),(0,i.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),"connecting"===o&&(0,i.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"connected"===o&&(0,i.jsx)("span",{className:"text-[10px] text-emerald-500 flex-shrink-0",children:"Connected"}),"error"===o&&(0,i.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:"Error"}),m&&(0,i.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:a5(m)}),"connected"===o&&s&&(0,i.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:["v",s.version," \xb7 ",s.nodeCount.toLocaleString(),"n \xb7 ",s.relationshipCount.toLocaleString(),"r"]}),(0,i.jsx)("span",{className:"flex-1"}),"connected"===o&&(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),R(),Q()},disabled:w,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0 disabled:opacity-40",title:"Refresh",children:(0,i.jsx)("svg",{className:`w-3.5 h-3.5 ${w?"animate-spin":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.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,i.jsx)("button",{onClick:a=>{a.stopPropagation(),l()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e?(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"}):(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"})})}),(0,i.jsx)("button",{onClick:a=>{a.stopPropagation(),k()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",children:(0,i.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,i.jsxs)("div",{style:{height:e&&f?f-41:g??360},className:"flex flex-col overflow-hidden",children:["connecting"===o&&(0,i.jsxs)("div",{className:"flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[(0,i.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Connecting..."]}),"error"===o&&(0,i.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-xs p-4 gap-2",children:[(0,i.jsx)("p",{className:"text-destructive",children:q}),(0,i.jsx)("button",{onClick:Q,className:"px-3 py-1 rounded text-xs bg-brand text-white hover:bg-brand/90 transition-colors",children:"Retry"})]}),"connected"===o&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:["schema","cypher","graph"].map(a=>(0,i.jsx)("button",{onClick:()=>P(a),className:`px-3 py-1.5 text-xs transition-colors ${O===a?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{schema:"Schema",cypher:"Cypher",graph:"Graph"}[a]},a))}),(0,i.jsxs)("div",{className:"flex-1 overflow-hidden flex",children:["schema"===O&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"w-40 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:(0,i.jsx)("div",{className:"flex-1 overflow-y-auto text-xs",children:[{key:"labels",label:"Labels",count:u?.labels.length},{key:"relationships",label:"Relationships",count:u?.relationshipTypes.length},{key:"properties",label:"Properties",count:u?.propertyKeys.length},{key:"indexes",label:"Indexes",count:u?.indexes.length},{key:"constraints",label:"Constraints",count:u?.constraints.length}].map(a=>(0,i.jsxs)("div",{onClick:()=>A(a.key),className:`flex items-center gap-1.5 px-2 py-1.5 cursor-pointer truncate transition-colors ${y===a.key?"bg-brand/10 text-brand":"hover:bg-white/10 text-foreground"}`,children:[(0,i.jsx)("span",{className:"truncate min-w-0 flex-1",children:a.label}),(0,i.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.count??0})]},a.key))})}),(0,i.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[w&&(0,i.jsxs)("div",{className:"flex items-center justify-center p-4 gap-2 text-muted-foreground",children:[(0,i.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"})," Loading..."]}),!w&&"labels"===y&&u?.labels.map(a=>{var b;return(0,i.jsxs)("div",{onClick:()=>T(a.name),className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer hover:bg-brand/10 transition-colors",children:[(0,i.jsx)("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:(b=a.name,a3[u.labels.map(a=>a.name).indexOf(b)%a3.length])}}),(0,i.jsx)("span",{className:"truncate min-w-0 flex-1 font-mono",children:a.name}),(0,i.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.count.toLocaleString()})]},a.name)}),!w&&"relationships"===y&&u?.relationshipTypes.map(a=>(0,i.jsxs)("div",{onClick:()=>U(a.name),className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer hover:bg-brand/10 transition-colors",children:[(0,i.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:"→"}),(0,i.jsx)("span",{className:"truncate min-w-0 flex-1 font-mono",children:a.name}),(0,i.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.count.toLocaleString()})]},a.name)),!w&&"properties"===y&&u?.propertyKeys.map(a=>(0,i.jsx)("div",{className:"px-2 py-1 font-mono text-muted-foreground hover:bg-brand/10 transition-colors",children:a},a)),!w&&"indexes"===y&&u?.indexes.map(a=>(0,i.jsxs)("div",{className:"px-2 py-1 border-b border-border/50 hover:bg-brand/10 transition-colors",children:[(0,i.jsx)("div",{className:"font-mono text-foreground",children:a.name}),(0,i.jsxs)("div",{className:"text-muted-foreground",children:[a.type," \xb7 ",a.labelsOrTypes?.join(", ")," \xb7 (",a.properties?.join(", "),") \xb7 ",a.state]})]},a.name)),!w&&"constraints"===y&&u?.constraints.map(a=>(0,i.jsxs)("div",{className:"px-2 py-1 border-b border-border/50 hover:bg-brand/10 transition-colors",children:[(0,i.jsx)("div",{className:"font-mono text-foreground",children:a.name}),(0,i.jsxs)("div",{className:"text-muted-foreground",children:[a.type," \xb7 ",a.labelsOrTypes?.join(", ")," \xb7 (",a.properties?.join(", "),")"]})]},a.name))]})]}),"cypher"===O&&(0,i.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,i.jsxs)("div",{className:"p-2 border-b border-border flex-shrink-0",children:[(0,i.jsx)("textarea",{ref:J,value:B,onChange:a=>C(a.target.value),onKeyDown:a=>{(a.metaKey||a.ctrlKey)&&"Enter"===a.key&&(a.preventDefault(),S())},placeholder:`Enter Cypher query (${(0,z.Mu)()}+Enter to run)`,className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,i.jsxs)("div",{className:"flex items-center justify-between mt-1",children:[(0,i.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[(0,z.Mu)(),"+Enter to execute"]}),(0,i.jsx)("button",{onClick:()=>S(),disabled:F||!B.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:F?"Running...":"Execute"})]})]}),(0,i.jsxs)("div",{className:"flex-1 overflow-auto",children:[H&&(0,i.jsx)("div",{className:"p-2 text-xs text-destructive",children:H}),D&&!H&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"px-2 py-1 text-[10px] text-muted-foreground border-b border-border flex items-center gap-2",children:[(0,i.jsxs)("span",{children:[D.records.length," rows"]}),(0,i.jsxs)("span",{children:[D.duration,"ms"]}),Object.entries(D.counters).filter(([,a])=>a>0).map(([a,b])=>(0,i.jsxs)("span",{children:[a,": ",b]},a))]}),D.records.length>0&&(0,i.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,i.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,i.jsx)("tr",{children:D.keys.map(a=>(0,i.jsx)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono",children:a},a))})}),(0,i.jsx)("tbody",{children:D.records.map((a,b)=>(0,i.jsx)("tr",{className:"hover:bg-accent/50",children:D.keys.map(b=>(0,i.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",children:null===a[b]?(0,i.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):function(a){if(null==a)return"null";if("object"==typeof a){if("node"===a._type){let b=a._labels?.[0]||"",c=a.name||a.title||a.id||"";return`(${b}${c?": "+c:""})`}return"relationship"===a._type?`[${a._relType}]`:JSON.stringify(a)}return String(a)}(a[b])},b))},b))})]})]})]})]}),"graph"===O&&(0,i.jsx)("div",{className:"flex-1 relative",children:0===K.length?(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-xs text-muted-foreground gap-2",children:[(0,i.jsx)("p",{children:"Run a Cypher query that returns nodes to visualize"}),(0,i.jsx)("button",{onClick:()=>{let a="MATCH (a)-[r]->(b) RETURN a, r, b LIMIT 50";C(a),S(a)},className:"px-3 py-1 rounded text-xs bg-brand text-white hover:bg-brand/90 transition-colors",children:"Load sample graph"})]}):(0,i.jsx)(a6,{nodes:K,rels:M,allLabels:u?.labels.map(a=>a.name)||[]})})]})]})]}),!e&&(0,i.jsxs)("div",{className:"border-t border-border px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,i.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${"connected"===o?"bg-green-500":"error"===o?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,i.jsx)("span",{children:{connecting:"Connecting",connected:"Connected",error:"Error"}[o]}),"connected"===o&&s&&(0,i.jsx)("span",{className:"text-muted-foreground/70",children:s.edition}),(0,i.jsx)("span",{className:"flex-1"}),m&&(0,i.jsx)("span",{className:"text-[11px] flex-shrink-0",children:a5(m)})]})]})})}function a8(){return`cmd-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}ag({type:"neo4j",idPrefix:"neo4j",match(a){let b=a.trim().toLowerCase();return b.startsWith("neo4j://")||b.startsWith("neo4j+s://")||b.startsWith("bolt://")||b.startsWith("bolt+s://")},parse(a){let b=a.trim(),c=b;try{let a=new URL(b);c=`${a.hostname}${a.port?":"+a.port:":7687"}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:d,bubbleContentHeight:e,timestamp:f,onSelect:g,onClose:h,onToggleMaximize:j,onTitleMouseDown:k}){return(0,i.jsx)(a7,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:d,bubbleContentHeight:e,timestamp:f,onSelect:g,onClose:h,onToggleMaximize:j,onTitleMouseDown:k})},async onClose(a){try{await fetch("/api/neo4j/disconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a.id})})}catch{}}});let a9=new Set(["zsh","bash","sh","fish","nu","python","python3","node","irb","lua","vim","nvim","vi","nano","emacs","top","htop","less","man"]);function ba({onAdd:a,onCancel:b}){let{t:c}=(0,k.Bd)(),[d,e]=(0,j.useState)(""),[f,g]=(0,j.useState)("");return(0,i.jsxs)("div",{className:"flex gap-1 mb-1",children:[(0,i.jsx)("input",{type:"text",value:d,onChange:a=>e(a.target.value),placeholder:c("console.namePlaceholder"),className:"w-24 flex-shrink-0 px-2 py-1 text-xs rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0,onKeyDown:a=>{"Escape"===a.key&&b()}}),(0,i.jsx)("input",{type:"text",value:f,onChange:a=>g(a.target.value),placeholder:c("console.commandPlaceholder"),className:"flex-1 min-w-0 px-2 py-1 text-xs font-mono rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring",onKeyDown:c=>{"Enter"!==c.key||c.nativeEvent.isComposing?"Escape"===c.key&&b():(c.preventDefault(),c.stopPropagation(),d.trim()&&f.trim()&&a(d.trim(),f.trim()))}})]})}function bb({label:a,commands:b,isAdding:c,onStartAdd:d,onAdd:e,onCancelAdd:f,onDelete:g,onExecute:h}){let{t:j}=(0,k.Bd)();return(0,i.jsxs)("div",{className:"p-2",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,i.jsx)("span",{className:"text-xs font-medium text-muted-foreground px-1",children:a}),(0,i.jsx)("button",{type:"button",onClick:d,className:"p-0.5 text-muted-foreground hover:text-foreground rounded",children:(0,i.jsx)(G.A,{className:"w-3.5 h-3.5"})})]}),c&&(0,i.jsx)(ba,{onAdd:(a,b)=>e(a,b),onCancel:f}),0===b.length&&!c&&(0,i.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:j("console.noCustomCommands")}),b.map((a,b)=>(0,i.jsx)(O.m,{content:a.command,children:(0,i.jsxs)("div",{className:"flex items-center group min-w-0",children:[(0,i.jsxs)("button",{type:"button",onClick:()=>h(a.command),className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1.5 text-left text-sm rounded hover:bg-accent transition-colors",children:[(0,i.jsx)(N,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,i.jsx)("span",{className:"truncate",children:a.name})]}),(0,i.jsx)("button",{type:"button",onClick:()=>g(b),className:"p-1 text-muted-foreground hover:text-destructive rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:(0,i.jsx)(l.A,{className:"w-3 h-3"})})]})},b))]})}function bc({cwd:a,show:b,onClose:c,onExecute:d,onAddPluginItem:e}){let{t:f}=(0,k.Bd)(),[g,h]=(0,j.useState)([]),[l,m]=(0,j.useState)([]),[n,o]=(0,j.useState)(null),p=(0,j.useRef)(null);(0,j.useCallback)(async()=>{try{let[b,c]=await Promise.all([fetch("/api/services/config?scope=global"),fetch(`/api/services/config?cwd=${encodeURIComponent(a)}`)]);if(b.ok){let a=await b.json();h(a.customCommands||[])}if(c.ok){let a=await c.json();m(a.customCommands||[])}}catch(a){console.error("Failed to load commands:",a)}},[a]);let q=(0,j.useCallback)(async a=>{h(a);try{await fetch("/api/services/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:"global",customCommands:a})})}catch(a){console.error("Failed to save global commands:",a)}},[]),r=(0,j.useCallback)(async b=>{m(b);try{await fetch("/api/services/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,customCommands:b})})}catch(a){console.error("Failed to save project commands:",a)}},[a]),s=(0,j.useCallback)(a=>{c();let b=ai(a);b?e?.(b.type,a.trim()):d(a)},[c,d,e]);return b?(0,i.jsxs)("div",{ref:p,className:"absolute bottom-full left-0 mb-2 w-72 bg-popover border border-border rounded-lg shadow-lg z-50 max-h-[70vh] overflow-y-auto",children:[(0,i.jsx)(bb,{label:f("console.globalCommands"),commands:g,isAdding:"global"===n,onStartAdd:()=>o("global"),onAdd:(a,b)=>{q([...g,{name:a,command:b}]),o(null)},onCancelAdd:()=>o(null),onDelete:a=>q(g.filter((b,c)=>c!==a)),onExecute:s}),(0,i.jsx)("div",{className:"border-t border-border"}),(0,i.jsx)(bb,{label:f("console.projectCommands"),commands:l,isAdding:"project"===n,onStartAdd:()=>o("project"),onAdd:(a,b)=>{r([...l,{name:a,command:b}]),o(null)},onCancelAdd:()=>o(null),onDelete:a=>r(l.filter((b,c)=>c!==a)),onExecute:s})]}):null}function bd({cwd:a,currentCwd:b,commandHistoryRef:c,gridLayout:d,onGridLayoutChange:e,onExecute:f,onAddPluginItem:g,onShowEnvManager:h,onOpenZsh:l,onOpenNote:m}){let{t:n}=(0,k.Bd)(),[o,p]=(0,j.useState)(""),[q,r]=(0,j.useState)(-1),[s,t]=(0,j.useState)(""),[u,v]=(0,j.useState)([]),[w,x]=(0,j.useState)(0),[y,z]=(0,j.useState)(!1),[A,B]=(0,j.useState)(!1),[C,D]=(0,j.useState)([]),[E,F]=(0,j.useState)(!1),[G,H]=(0,j.useState)(0),I=(0,j.useRef)(null),N=(0,j.useRef)(null),O=(0,j.useRef)(!1),{projectCommands:P,globalCommands:Q,expandCustomCommand:R,loadQuickCommands:S}=function(a){let[b,c]=(0,j.useState)([]),[d,e]=(0,j.useState)([]),f=(0,j.useCallback)(async()=>{try{let[b,d]=await Promise.all([fetch(`/api/services/config?cwd=${encodeURIComponent(a)}`),fetch("/api/services/config?scope=global")]);if(b.ok){let a=await b.json();c(a.customCommands||[])}if(d.ok){let a=await d.json();e(a.customCommands||[])}}catch{}},[a]),g=[...b,...d],h=(0,j.useCallback)(a=>{let c=a.trim().split(/\s+/),e=c[0];if(!e.startsWith("/")||e.length<=1)return null;let f=e.slice(1),g=b.find(a=>a.name===f)??d.find(a=>a.name===f);return g?g.command+(c.length>1?" "+c.slice(1).join(" "):""):null},[b,d]);return{quickCustomCommands:g,projectCommands:b,globalCommands:d,expandCustomCommand:h,loadQuickCommands:f}}(a),T=(0,j.useCallback)(a=>{F(!1);let b=a.command,c=ai(b);c?g?.(c.type,b.trim()):f(b),p("")},[f,g]),U=(0,j.useCallback)(a=>{if(a.preventDefault(),O.current||!o.trim())return;let b=R(o)??o,c=ai(b);c?g?.(c.type,b.trim()):f(b),p(""),r(-1),t("")},[o,f,g,R]),V=(0,j.useCallback)(async()=>{if(!I.current)return;let a=I.current.selectionStart||0;try{let c=await fetch("/api/terminal/autocomplete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,input:o,cursorPosition:a})});if(c.ok){let a=await c.json();if(a.suggestions&&a.suggestions.length>0&&(v(a.suggestions),x(0),z(!0),1===a.suggestions.length)){let b=o.substring(0,a.replaceStart),c=o.substring(a.replaceEnd),d=b+a.suggestions[0]+c;p(d),z(!1),setTimeout(()=>{if(I.current){let b=a.replaceStart+a.suggestions[0].length;I.current.setSelectionRange(b,b)}},0)}}}catch(a){console.error("Autocomplete error:",a)}},[b,o]),W=(0,j.useCallback)(a=>{if(!I.current)return;let b=I.current.selectionStart||0,c=o.substring(0,b),d=o.substring(b),e=c.split(/\s+/),f=b-(e[e.length-1]||"").length;p(o.substring(0,f)+a+d),z(!1),setTimeout(()=>{if(I.current){let b=f+a.length;I.current.setSelectionRange(b,b)}},0)},[o]),X=(0,j.useCallback)(a=>{if(a.nativeEvent.isComposing)return;if(E&&C.length>0){if("ArrowUp"===a.key){a.preventDefault(),H(a=>(a-1+C.length)%C.length);return}if("ArrowDown"===a.key){a.preventDefault(),H(a=>(a+1)%C.length);return}if("Tab"===a.key||"Enter"===a.key){a.preventDefault(),T(C[G]);return}if("Escape"===a.key){a.preventDefault(),F(!1);return}}if("Tab"===a.key){if(a.preventDefault(),y&&u.length>0){let a=(w+1)%u.length;x(a),W(u[a])}else V();return}if("Escape"===a.key&&y){a.preventDefault(),z(!1);return}let b=c.current;if(b&&0!==b.length){if("ArrowUp"===a.key){a.preventDefault(),-1===q&&t(o);let c=-1===q?b.length-1:Math.max(0,q-1);r(c),p(b[c])}else if("ArrowDown"===a.key){if(a.preventDefault(),-1===q)return;let c=q+1;c>=b.length?(r(-1),p(s)):(r(c),p(b[c]))}}},[q,o,s,y,u,w,V,W,E,C,G,T,c]);return(0,i.jsx)("div",{className:"border-t border-border p-4",children:(0,i.jsxs)("form",{onSubmit:U,className:"relative flex gap-2 items-center",children:[(0,i.jsxs)("div",{className:"relative",children:[(0,i.jsx)("button",{type:"button",onClick:()=>{A||S(),B(!A)},className:`p-2 rounded-lg transition-all ${A?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95"}`,title:n("console.quickCommands"),children:(0,i.jsx)(J,{className:"w-4 h-4"})}),(0,i.jsx)(bc,{cwd:a,show:A,onClose:()=>B(!1),onExecute:f,onAddPluginItem:g})]}),m&&(0,i.jsx)("button",{type:"button",onClick:m,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:n("chat.projectNotes"),children:(0,i.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.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,i.jsx)("button",{type:"button",onClick:()=>e(!d),className:`p-2 rounded-lg transition-all ${d?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95"}`,title:d?n("console.singleColumn"):n("console.dualColumn"),children:d?(0,i.jsx)(K,{className:"w-4 h-4"}):(0,i.jsx)(L,{className:"w-4 h-4"})}),(0,i.jsx)("button",{type:"button",onClick:h,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:n("console.envVars"),children:(0,i.jsx)(M,{className:"w-4 h-4"})}),(0,i.jsx)("button",{type:"button",onClick:l,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:n("console.launchZsh"),children:(0,i.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,i.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}),(0,i.jsx)("input",{ref:I,type:"text",value:o,onChange:a=>{p(a.target.value),-1!==q&&(r(-1),t("")),z(!1)},onKeyDown:X,onCompositionStart:()=>{O.current=!0},onCompositionEnd:()=>{O.current=!1},placeholder:n("console.inputPlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring font-mono"}),E&&C.length>0&&(0,i.jsx)("div",{ref:N,className:"absolute bottom-full left-0 right-0 mb-1 max-h-64 overflow-y-auto bg-popover border border-border rounded-lg shadow-lg z-50",children:C.map((a,b)=>(0,i.jsxs)("div",{onClick:()=>T(a),className:`flex items-center gap-3 px-3 py-1.5 cursor-pointer text-sm ${b===G?"bg-brand/10":"hover:bg-accent"}`,children:[(0,i.jsxs)("span",{className:"font-mono font-medium text-foreground",children:["/",a.name]}),(0,i.jsx)("span",{className:"flex-1 text-muted-foreground truncate",children:a.command}),(0,i.jsx)("span",{className:"text-[10px] text-muted-foreground/60 flex-shrink-0",children:"project"===a.scope?n("console.scopeProject"):n("console.scopeGlobal")})]},`${a.scope}-${a.name}`))}),y&&u.length>1&&(0,i.jsxs)("div",{className:"absolute bottom-full left-0 mb-1 bg-popover border border-border rounded-lg shadow-lg max-h-48 overflow-y-auto z-50",children:[(0,i.jsx)("div",{className:"py-1",children:u.map((a,b)=>(0,i.jsx)("button",{type:"button",onClick:()=>W(a),className:`w-full px-3 py-1.5 text-left text-sm font-mono hover:bg-accent transition-colors ${b===w?"bg-accent":""}`,children:a},b))}),(0,i.jsx)("div",{className:"border-t border-border px-3 py-1 text-xs text-muted-foreground",children:n("console.tabSwitchEscClose")})]})]})})}function be({showTop:a,showBottom:b,onScrollTop:c,onScrollBottom:d}){let{t:e}=(0,k.Bd)();return(0,i.jsxs)(i.Fragment,{children:[a&&(0,i.jsx)("button",{onClick:c,className:"absolute top-2 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-md rounded-full transition-all hover:shadow-lg active:scale-95 z-10",title:e("chat.jumpToStart"),children:(0,i.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),b&&(0,i.jsx)("button",{onClick:d,className:"absolute bottom-20 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-md rounded-full transition-all hover:shadow-lg active:scale-95 z-10",title:e("chat.jumpToLatest"),children:(0,i.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})}function bf({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:d,onOpenNote:e}){let{t:f}=(0,k.Bd)(),{consoleItems:g,scrollRef:h,selectedCommandId:l,setSelectedCommandId:m,interruptCommand:n,sendStdin:o,deleteCommand:p,rerunCommand:q,ptySizeRef:r,resizePty:s,executeCommand:t,addPluginItem:u,closePluginItem:v,sleepingBubbles:w,handleBubbleSleep:x,handleBubbleWake:y,scrollToBottom:z,currentCwd:A,commandHistoryRef:B,setCustomEnv:C,setAliases:D,saveBubbleOrder:F,hasMoreHistory:G,loadHistory:J,currentPage:K,isLoadingHistory:L,subscribePtyOutput:M,subscribePtyReset:N}=function({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:d}){let[e,f]=(0,j.useState)([]),[g,h]=(0,j.useState)([]),[i,k]=(0,j.useState)(new Set),[l,m]=(0,j.useState)(b||a),[n,o]=(0,j.useState)(!1),[p,q]=(0,j.useState)(!1),[r,s]=(0,j.useState)(0),[t,u]=(0,j.useState)(null),[v,w]=(0,j.useState)({}),[x,y]=(0,j.useState)({}),[z,A]=(0,j.useState)(null),B=(0,j.useRef)(null),C=(0,j.useRef)(new Map),D=(0,j.useRef)(new Map),E=(0,j.useRef)(new Set),F=(0,j.useRef)([]),G=(0,j.useRef)(new Map),H=(0,j.useRef)(new Map),I=(0,j.useRef)(new Map),J=(0,j.useRef)(null),K=(0,j.useRef)(null),L=(0,j.useRef)([]),M=(0,j.useRef)(null),N=(0,j.useCallback)(()=>{if(C.current.size>0){let a=new Map(C.current);C.current.clear(),f(b=>b.map(b=>{let c=a.get(b.id);return void 0!==c?{...b,output:c}:b}))}B.current=null},[]),O=(0,j.useCallback)((a,b)=>{if(E.current.has(a)){let c=H.current.get(a);if(c&&c.size>0)for(let a of c)a(b);else I.current.has(a)||I.current.set(a,[]),I.current.get(a).push(b);return}let c=(D.current.get(a)||"")+b;if(c.length>2097152){let b=function(a){let b=a.slice(-2097152),c=0;if(b.length>0){let a=b.charCodeAt(0);a>=56320&&a<=57343&&(c=1)}let d=Math.min(b.length,64);for(let a=c;a<d;a++){let d=b.charCodeAt(a);if(27===d){c=a;break}if((!(d>=48)||!(d<=63))&&59!==d&&63!==d&&32!==d){d>=64&&d<=126&&(c=a+1);break}}return c>0?b.slice(c):b}(c);D.current.set(a,b),C.current.set(a,b)}else D.current.set(a,c),C.current.set(a,c);null===B.current&&(B.current=requestAnimationFrame(N))},[N]),P=(0,j.useCallback)((a,b=!1)=>{D.current.delete(a),E.current.delete(a),C.current.delete(a),I.current.delete(a),b||(H.current.delete(a),R.current.delete(a))},[]),Q=(0,j.useCallback)((a,b)=>{H.current.has(a)||H.current.set(a,new Set),H.current.get(a).add(b);let c=I.current.get(a);if(c&&c.length>0){for(let a of c)b(a);I.current.delete(a)}return()=>{H.current.get(a)?.delete(b)}},[]),R=(0,j.useRef)(new Map),S=(0,j.useCallback)((a,b)=>(R.current.has(a)||R.current.set(a,new Set),R.current.get(a).add(b),()=>{R.current.get(a)?.delete(b)}),[]),T=(0,j.useCallback)(a=>(null!==B.current&&(cancelAnimationFrame(B.current),B.current=null),N(),D.current.get(a)||""),[N]),U=(0,j.useCallback)(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[]),V=(0,j.useCallback)(async(b=0)=>{if(c){o(!0);try{let d=await fetch(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(c)}&page=${b}&pageSize=100`);if(d.ok){let a=await d.json(),c=[],e=[],g=new Set;for(let b of a.entries){let a=ah(b.type);if(a){let c=a.fromHistory(b);e.push({id:b.id,_type:b.type,timestamp:b.timestamp,...c}),b.sleeping&&g.add(b.id)}else{if(b.running)continue;c.push({id:b.id.includes("-")&&3===b.id.split("-").length?b.id:a8(),command:b.command,output:b.output,exitCode:b.exitCode,isRunning:!1,timestamp:b.timestamp,cwd:b.cwd,usePty:b.usePty})}}0===b?(f(c),h(e),g.size>0&&k(g)):(f(a=>{let b=new Set(a.map(a=>a.id)),d=c.filter(a=>!b.has(a.id));return[...a,...d]}),h(a=>{let b=new Set(a.map(a=>a.id)),c=e.filter(a=>!b.has(a.id));return[...a,...c]})),q(a.hasMore),s(b)}}catch(a){console.error("Failed to load history:",a)}finally{o(!1)}}},[a,c]),X=(0,j.useCallback)(async b=>{if(c)try{await fetch("/api/terminal/history",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,tabId:c,entry:{id:b.id,command:b.command,output:b.output,exitCode:b.exitCode,timestamp:b.timestamp,cwd:l}})})}catch(a){console.error("Failed to save cd history:",a)}},[a,c,l]);(0,j.useCallback)(async b=>{try{let d=await (W||(W=ae(a)));if(b.current)return;for(let e of d){if(c&&e.tabId!==c)continue;if(b.current)break;let d=e.commandId;f(a=>a.find(a=>a.id===d)?a.map(a=>a.id===d?{...a,isRunning:!0,exitCode:void 0,pid:e.pid,...e.usePty?{usePty:!0}:{}}:a):[...a,{id:d,command:e.command,output:"",isRunning:!0,pid:e.pid,timestamp:e.timestamp,cwd:e.cwd,...e.usePty?{usePty:!0}:{}}]),D.current.set(d,""),e.usePty&&E.current.add(d),await aa({commandId:d,projectCwd:a,onData:(a,b)=>{if("pid"===a);else if("stdout"===a||"stderr"===a)O(d,b.data);else if("exit"===a){let a=T(d);P(d),f(c=>c.map(c=>c.id===d?{...c,output:a,exitCode:b.code,isRunning:!1,pid:void 0}:c))}},onError:()=>{f(a=>a.map(a=>a.id===d&&a.isRunning?{...a,isRunning:!1}:a))}})}}catch{}},[a,c,O,T,P]);let Y=(0,j.useCallback)(async b=>{let e,g=b.trim().split(/\s+/),h=g[0],i=b;x[h]&&(i=x[h]+(g.length>1?" "+g.slice(1).join(" "):""));let j=ai(i);if(j)return void K.current?.(j.type,i.trim());let k=a8(),n=new Date().toISOString(),o=(e=i.trim().split(/\s+/)[0],a9.has(e)),p={id:k,command:b,output:i!==b?`→ ${i}
21
- `:"",isRunning:!0,timestamp:n,cwd:l,...o?{usePty:!0}:{}};if(f(a=>a.some(a=>a.id===k)?a:[...a,p]),u(k),D.current.set(k,p.output),o&&E.current.add(k),setTimeout(U,100),i.trim().startsWith("cd ")){let a=i.trim().substring(3).trim(),b=l;a.startsWith("/")?b=a:".."===a?b=l.split("/").slice(0,-1).join("/")||"/":"."!==a&&(b=`${l}/${a}`.replace(/\/+/g,"/")),m(b),d?.(b),f(a=>a.map(a=>{if(a.id===k){let c={...a,output:`Changed directory to: ${b}`,exitCode:0,isRunning:!1};return X(c),c}return a}));return}try{await _({cwd:l,command:i,commandId:k,tabId:c||"",projectCwd:a,env:v,usePty:o,onData:(a,b)=>{if("pid"===a)f(a=>a.map(a=>a.id===k?{...a,pid:b.pid}:a));else if("stdout"===a||"stderr"===a)O(k,b.data);else if("exit"===a){let a=T(k);P(k),f(c=>c.map(c=>c.id===k?{...c,output:a,exitCode:b.code,isRunning:!1,pid:void 0}:c))}},onError:a=>{let b=T(k);P(k),f(c=>c.map(c=>c.id===k?{...c,output:b+`
22
- Error: ${a}`,exitCode:1,isRunning:!1,pid:void 0}:c))}})}catch(b){let a=T(k);P(k),f(c=>c.map(c=>c.id===k?{...c,output:a+`
23
- Error: ${b.message}`,exitCode:1,isRunning:!1,pid:void 0}:c))}},[x,l,v,c,a,O,T,P,U,d,X]),Z=(0,j.useCallback)(a=>{let b=e.find(b=>b.id===a);b?.isRunning&&b.pid&&ad(b.pid)},[e]),$=(0,j.useCallback)(async b=>{let d=e.find(a=>a.id===b);if(!d)return;d.isRunning&&d.pid&&(ad(d.pid),await new Promise(a=>setTimeout(a,200)));let g=d.command.trim().split(/\s+/),h=g[0],i=d.command;x[h]&&(i=x[h]+(g.length>1?" "+g.slice(1).join(" "):""));let j=d.usePty||!1;if(j){let a=R.current.get(b);if(a)for(let b of a)b()}P(b,j);let k=i!==d.command?`→ ${i}
24
- `:"";j||D.current.set(b,k),j&&E.current.add(b),f(a=>a.map(a=>a.id===b?{...a,output:j?"":k,exitCode:void 0,isRunning:!0,pid:void 0}:a));let m=G.current.get(b);try{await _({cwd:d.cwd||l,command:i,commandId:b,tabId:c||"",projectCwd:a,env:v,usePty:j,...j&&m?{cols:m.cols,rows:m.rows}:{},onData:(a,c)=>{if("pid"===a)f(a=>a.map(a=>a.id===b?{...a,pid:c.pid}:a));else if("stdout"===a||"stderr"===a)O(b,c.data);else if("exit"===a){let a=T(b);P(b),f(d=>d.map(d=>d.id===b?{...d,output:a,exitCode:c.code,isRunning:!1,pid:void 0}:d))}},onError:a=>{let c=T(b);P(b),f(d=>d.map(d=>d.id===b?{...d,output:c+`
25
- Error: ${a}`,exitCode:1,isRunning:!1,pid:void 0}:d))}})}catch(c){let a=T(b);P(b),f(d=>d.map(d=>d.id===b?{...d,output:a+`
26
- Error: ${c.message}`,exitCode:1,isRunning:!1,pid:void 0}:d))}},[e,x,l,v,c,a,O,T,P]),af=(0,j.useCallback)(async b=>{if(f(a=>a.filter(a=>a.id!==b)),P(b),c)try{await fetch(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(c)}&commandId=${encodeURIComponent(b)}`,{method:"DELETE"})}catch(a){console.error("Failed to delete command:",a)}},[a,c,P]),ag=(0,j.useCallback)((b,d,e)=>{var f;let g=ah(b);if(!g)return;let i=g.parse(d);"cwd"in i&&!i.cwd&&(i.cwd=l);let j={id:(f=g.idPrefix,`${f}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`),_type:b,timestamp:new Date().toISOString(),...i};if(h(a=>[...a,j]),u(j.id),setTimeout(U,100),e){let b=z&&z.length>0?[...z]:L.current.map(a=>a.data.id),d=b.indexOf(e);-1!==d?b.splice(d+1,0,j.id):b.push(j.id),A(b),c&&fetch("/api/terminal/bubble-order",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,tabId:c,order:b})}).catch(()=>{})}if(c){let d=g.toHistory(j);fetch("/api/terminal/history",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,tabId:c,entry:{type:b,id:j.id,timestamp:j.timestamp,...d}})}).catch(a=>console.error(`Failed to save ${b} item:`,a))}},[U,a,c,z]),aj=(0,j.useCallback)(async b=>{let d=g.find(a=>a.id===b);if(h(a=>a.filter(a=>a.id!==b)),u(a=>a===b?null:a),k(a=>{let c=new Set(a);return c.delete(b),c}),d){let a=ah(d._type);a?.onClose?.(d)}c&&fetch(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(c)}&commandId=${encodeURIComponent(b)}`,{method:"DELETE"}).catch(a=>console.error("Failed to delete plugin item:",a))},[g,a,c]);K.current=ag,J.current=Y;let ak=(0,j.useCallback)((b,d)=>{c&&fetch("/api/terminal/history",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,tabId:c,id:b,fields:{sleeping:d}})}).catch(()=>{})},[a,c]),al=(0,j.useCallback)(a=>{k(b=>new Set(b).add(a)),ak(a,!0)},[ak]),am=(0,j.useCallback)(a=>{k(b=>{let c=new Set(b);return c.delete(a),c}),ak(a,!1)},[ak]),an=(0,j.useCallback)(async b=>{if(A(b),c)try{await fetch("/api/terminal/bubble-order",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,tabId:c,order:b})})}catch{}},[a,c]),ao=(0,j.useMemo)(()=>{let a=[...e.map(a=>({type:"command",data:a})),...g.map(a=>({type:a._type,data:a}))];if(!z||0===z.length)return a.sort((a,b)=>new Date(a.data.timestamp).getTime()-new Date(b.data.timestamp).getTime());let b=new Map(z.map((a,b)=>[a,b])),c=[],d=[];for(let e of a)b.has(e.data.id)?c.push(e):d.push(e);return c.sort((a,c)=>b.get(a.data.id)-b.get(c.data.id)),d.sort((a,b)=>new Date(a.data.timestamp).getTime()-new Date(b.data.timestamp).getTime()),[...c,...d]},[e,g,z]);return L.current=ao,{commands:e,pluginItems:g,sleepingBubbles:i,consoleItems:ao,currentCwd:l,selectedCommandId:t,setSelectedCommandId:u,customEnv:v,setCustomEnv:w,aliases:x,setAliases:y,isLoadingHistory:n,hasMoreHistory:p,currentPage:r,scrollRef:M,commandHistoryRef:F,ptySizeRef:G,executeCommandRef:J,executeCommand:Y,interruptCommand:Z,rerunCommand:$,deleteCommand:af,addPluginItem:ag,closePluginItem:aj,handleBubbleSleep:al,handleBubbleWake:am,loadHistory:V,scrollToBottom:U,saveBubbleOrder:an,sendStdin:ab,resizePty:ac,subscribePtyOutput:Q,subscribePtyReset:S}}({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:d}),[O,P]=(0,j.useState)(null),[Q,R]=(0,j.useState)(0),[S,T]=(0,j.useState)(0),[U,V]=(0,j.useState)(!0),[X,Y]=(0,j.useState)(!1),[Z,$]=(0,j.useState)(!1),[af,ag]=(0,j.useState)(!1),[aj,ak]=(0,j.useState)(!1),al=(0,j.useRef)(null),am=(0,j.useRef)(null),an=(0,j.useRef)(null),ao=(0,j.useRef)(!1),ap=(0,j.useRef)(null),aq=(0,j.useRef)(null),ar=(0,j.useRef)([]),as=(0,j.useCallback)(()=>{let a=h.current;return!a||a.scrollHeight-a.scrollTop-a.clientHeight<50},[h]),at=(0,j.useCallback)(()=>{let a=h.current;return!a||a.scrollTop<50},[h]),au=(0,j.useCallback)(()=>{ag(!at()),ak(!as())},[as,at]),av=(0,j.useCallback)(()=>{am.current?.scrollIntoView({behavior:"smooth"})},[]),aw=async b=>{try{await fetch("/api/project-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,settings:b})})}catch(a){console.error("Failed to save project settings:",a)}},ax=(0,j.useCallback)(()=>{ao.current=!0},[]),ay=(0,j.useCallback)((a,b)=>{if(!ao.current)return void a.preventDefault();ao.current=!1,ap.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b),a.currentTarget.style.opacity="0.4";let c=a.currentTarget.querySelector("[data-drag-handle]");if(c){let b=c.cloneNode(!0);b.style.cssText="position:fixed;top:-9999px;left:-9999px;width:"+c.offsetWidth+"px;background:var(--card);border-radius:8px;padding:4px 12px;opacity:0.9;",document.body.appendChild(b),a.dataTransfer.setDragImage(b,20,16),requestAnimationFrame(()=>document.body.removeChild(b))}},[]),az=(0,j.useCallback)((a,b)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",aq.current=b},[]),aA=(0,j.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.add("ring-2","ring-brand")},[]),aB=(0,j.useCallback)(a=>{a.currentTarget.classList.remove("ring-2","ring-brand")},[]),aC=(0,j.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.remove("ring-2","ring-brand")},[]),aD=(0,j.useCallback)(a=>{a.currentTarget.style.opacity="1";let b=ap.current,c=aq.current;if(ap.current=null,aq.current=null,!b||!c||b===c)return;let d=ar.current.map(a=>a.data.id),e=d.indexOf(b),f=d.indexOf(c);if(-1===e||-1===f)return;let g=[...d];g[e]=c,g[f]=b,F(g)},[F]),aE=(0,j.useCallback)(a=>{P(b=>b===a?null:a)},[]),aF=S>0?Math.floor((S-32-12)/2-41):void 0;return(0,i.jsxs)("div",{ref:al,className:"h-full flex flex-col bg-background relative",children:[(0,i.jsx)("div",{ref:h,onScroll:au,className:`flex-1 overflow-y-auto ${O?"":"py-4 px-4"}`,children:0===g.length?(0,i.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:f("console.enterCommandOrUrl")}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{ref:am}),G&&(0,i.jsx)("div",{className:"flex justify-center mb-4",children:(0,i.jsx)("button",{onClick:()=>J(K+1),disabled:L,className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-50",children:f(L?"console.loadingMore":"console.loadMoreHistory")})}),(0,i.jsx)("div",{className:O?"flex flex-col gap-3":U?"grid grid-cols-2 gap-3":"flex flex-col gap-3",children:g.map(b=>{let d={draggable:!0,onDragStart:a=>ay(a,b.data.id),onDragOver:a=>az(a,b.data.id),onDragEnter:aA,onDragLeave:aB,onDrop:aC,onDragEnd:aD};if("command"===b.type){let e=b.data;return(0,i.jsx)("div",{"data-bubble-id":e.id,className:"group/cmd rounded-lg transition-shadow",...d,children:(0,i.jsx)(E,{commandId:e.id,tabId:c,projectCwd:a,command:e.command,output:e.output,exitCode:e.exitCode,isRunning:e.isRunning,selected:l===e.id,onSelect:()=>{m(e.id)},onInterrupt:e.isRunning?()=>n(e.id):void 0,onStdin:e.isRunning?a=>o(e.id,a):void 0,onDelete:()=>{e.isRunning&&e.pid&&ad(e.pid),p(e.id)},onRerun:()=>q(e.id),timestamp:e.timestamp,usePty:e.usePty,subscribePtyOutput:e.usePty?M:void 0,subscribePtyReset:e.usePty?N:void 0,onPtyResize:(a,b)=>{r.current.set(e.id,{cols:a,rows:b}),s(e.id,a,b)},onToggleMaximize:()=>aE(e.id),maximized:O===e.id,expandedHeight:Q,bubbleContentHeight:aF,onTitleMouseDown:ax})},e.id)}let e=ah(b.type);if(!e)return null;let f=e.Component,g=b.data;return(0,i.jsx)("div",{"data-bubble-id":g.id,className:"rounded-lg transition-shadow",...d,children:(0,i.jsx)(f,{item:g,selected:l===g.id,maximized:O===g.id,expandedHeight:Q,bubbleContentHeight:aF,timestamp:g.timestamp,onSelect:()=>{m(g.id)},onClose:()=>v(g.id),onToggleMaximize:()=>aE(g.id),onTitleMouseDown:ax,extra:{addBrowserItem:(a,b)=>u("browser",a,b),initialSleeping:w.has(g.id),onSleep:x,onWake:y}})},g.id)})}),(0,i.jsx)("div",{ref:an})]})}),!O&&g.length>0&&(0,i.jsx)(be,{showTop:af,showBottom:aj,onScrollTop:av,onScrollBottom:z}),(0,i.jsx)(bd,{cwd:a,currentCwd:A,commandHistoryRef:B,gridLayout:U,onGridLayoutChange:a=>{V(a),aw({gridLayout:a})},onExecute:t,onAddPluginItem:u,onShowEnvManager:()=>Y(!0),onOpenZsh:()=>t("zsh"),onOpenNote:e}),X&&(0,i.jsx)(H,{cwd:a,tabId:c,onClose:()=>Y(!1),onSave:a=>C(a)}),Z&&(0,i.jsx)(I.Y,{onClose:()=>$(!1),onSave:a=>D(a)})]})}},52620:(a,b,c)=>{"use strict";c.d(b,{JL:()=>h,Sn:()=>e,Xm:()=>f,po:()=>g});var d=c(67484);function e(a){let[b,c]=(0,d.useState)(!1);return{goToDefinition:(0,d.useCallback)(async(b,d,e)=>{c(!0);try{let c=await fetch("/api/lsp/definition",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,filePath:b,line:d,column:e})});return(await c.json()).definitions||[]}catch(a){return console.error("[useLSP] definition error:",a),[]}finally{c(!1)}},[a]),loading:b}}function f(a){let[b,c]=(0,d.useState)(null),e=(0,d.useRef)(null),f=(0,d.useRef)(null),g=(0,d.useRef)(0),h=(0,d.useRef)(!1),i=(0,d.useRef)(null),j=(0,d.useRef)({x:0,y:0}),k=(0,d.useCallback)(a=>{i.current=a},[]),l=(0,d.useRef)(!1),m=(0,d.useRef)(null),n=(0,d.useCallback)(()=>{let a=i.current;a&&l.current&&(a.style.pointerEvents="none"),l.current=!1,m.current&&(i.current?.removeEventListener("mouseleave",m.current),m.current=null)},[]),o=(0,d.useCallback)(()=>{let a=i.current;if(!a||l.current)return;l.current=!0,h.current=!0,a.style.pointerEvents="auto";let b=()=>{h.current=!1,n(),g.current++,c(null)};m.current=b,a.addEventListener("mouseleave",b)},[n]),p=(0,d.useCallback)((b,d,h,i)=>{e.current&&clearTimeout(e.current),f.current&&clearTimeout(f.current);let j=++g.current;e.current=setTimeout(async()=>{try{let e=await fetch("/api/lsp/hover",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,filePath:b,line:d,column:h})}),f=await e.json();if(j!==g.current)return;f.hover&&f.hover.displayString&&c({...f.hover,x:i.x,y:i.y,filePath:b,line:d,column:h})}catch{}},300)},[a]),q=(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),g.current++,f.current=setTimeout(function(){if(h.current)return;let a=i.current;if(a){let b=a.getBoundingClientRect(),{x:c,y:d}=j.current;if(c>=b.left&&c<=b.right&&d>=b.top&&d<=b.bottom)return void o()}c(null)},150)},[o]),r=(0,d.useCallback)(()=>{h.current=!0,f.current&&clearTimeout(f.current)},[]);return{hoverInfo:b,onTokenMouseEnter:p,onTokenMouseLeave:q,onCardMouseEnter:r,onCardMouseLeave:(0,d.useCallback)(()=>{h.current=!1,g.current++,c(null)},[]),clearHover:(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),f.current&&clearTimeout(f.current),h.current=!1,n(),g.current++,c(null)},[n]),setTooltipEl:k}}function g(a){let[b,c]=(0,d.useState)([]),[e,f]=(0,d.useState)(!1),[g,h]=(0,d.useState)(!1);return{references:b,loading:e,visible:g,findReferences:(0,d.useCallback)(async(b,d,e)=>{f(!0),h(!0);try{let f=await fetch("/api/lsp/references",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,filePath:b,line:d,column:e})}),g=await f.json();c(g.references||[])}catch(a){console.error("[useLSP] references error:",a),c([])}finally{f(!1)}},[a]),closeReferences:(0,d.useCallback)(()=>{h(!1),c([])},[])}}function h(a,b){(0,d.useRef)(null)}c(62862)},54017:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>N});var e=c(48249),f=c(67484),g=c(74429),h=c(31172),i=c(2868),j=c(86402),k=c(81749),l=c(66254),m=c(95836),n=c(26068),o=c(79029),p=c(56929),q=c(94882),r=c(10164),s=c(66185),t=c(13928),u=c(6440),v=c(92188),w=c(40516),x=c(99470),y=c(23290),z=c(43609),A=c(96666),B=c(86753),C=c(34371),D=c(52620),E=c(47237),F=c(44384),G=c(36645),H=c(62862),I=c(24463),J=c(1906),K=c(45832),L=c(92154),M=a([i,j,o,v,w,J,K]);function N({onClose:a,cwd:b,initialTab:c="tree",tabSwitchTrigger:d,initialSearchQuery:M,searchQueryTrigger:O}){let{t:P}=(0,F.Bd)(),{activeView:Q}=(0,L.R8)(),[R,S]=(0,f.useState)(c),[T,U]=(0,f.useState)("code"),V=(0,f.useRef)(null),W=(0,f.useRef)(!1),[X,Y]=(0,f.useState)(null),[Z,$]=(0,f.useState)(null),[_,aa]=(0,f.useState)(!1),ab=(0,f.useRef)(1),ac=(0,f.useRef)(null),[ad,ae]=(0,f.useState)(null),af=(0,f.useRef)(null),[ag,ah]=(0,f.useState)({isDirty:!1,isSaving:!1}),[ai,aj]=(0,f.useState)(!1),[ak,al]=(0,f.useState)(!1),[am,an]=(0,f.useState)(null),ao=(0,f.useRef)(null),ap=(0,G.o)(ao),aq=(0,f.useRef)(null),ar=(0,G.o)(aq),as=(0,D.Sn)(b),at=(0,D.Xm)(b),au=(0,D.po)(b),av=(0,E.Q)(),aw=(0,u.F)(),ax=(0,z.W)({cwd:b});(0,D.JL)(b,ax.selectedPath);let ay=(0,A.p)({cwd:b,onSearchComplete:()=>aj(!0)}),az=(0,B.e)({cwd:b,addToRecentFiles:ax.addToRecentFiles}),aA=(0,f.useMemo)(()=>{let a=new Set;if(az.status){for(let b of az.status.staged)a.add(b.path);for(let b of az.status.unstaged)a.add(b.path)}return a},[az.status]),aB=(0,f.useMemo)(()=>{let a=new Map;if(az.status){for(let b of az.status.staged)a.set(b.path,"staged");for(let b of az.status.unstaged)a.set(b.path,"unstaged")}return a},[az.status]),aC=(0,C.y)({cwd:b,addToRecentFiles:ax.addToRecentFiles}),aD=(0,f.useCallback)(a=>{ax.setFileContent(b=>b?.type==="text"?{...b,content:a}:b)},[ax]),aE=(0,f.useCallback)(a=>{ax.setShowEditor(!0)},[ax]),aF=(0,f.useCallback)(async()=>{if(ax.fileContent&&"text"===ax.fileContent.type&&ax.fileContent.content)try{let a=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,path:ax.selectedPath,content:ax.fileContent.content})});if(!a.ok)throw Error("Failed to save file");let c=await a.json();c.mtime&&ax.setFileContent(a=>a?.type==="text"?{...a,mtime:c.mtime}:a),(0,k.oR)(P("toast.savedSuccess"),"success")}catch{(0,k.oR)(P("toast.saveFailed"),"error")}},[b,ax]),aG=(0,f.useCallback)(()=>{if(!ax.selectedPath)return;let a=ab.current,b=ac.current;a>0&&ax.updateRecentFilePosition(ax.selectedPath,a,b?b.cursorLine+1:a,b?b.cursorCol+1:1)},[ax]),aH=(0,f.useCallback)((a,b)=>{a!==ax.selectedPath&&aG(),ax.handleSelectFile(a,b)},[ax,aG]),aI=(0,f.useMemo)(()=>{let a=ay.contentSearchResults;if(0===a.length)return{files:[],expandDirs:new Set,matchMap:new Map};let b=new Map,c=[];for(let d of a)b.set(d.path,d),c.push(d.path);let d=(0,q.v3)(c),e=new Set((0,q.tW)(d));return{files:d,expandDirs:e,matchMap:b}},[ay.contentSearchResults]),[aJ,aK]=(0,f.useState)(new Set),aL=(0,f.useCallback)(a=>{aK(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),aM=(0,f.useCallback)(a=>{if(a.isDirectory)return null;let b=aI.matchMap.get(a.path);return b?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:b.matches.length}):null},[aI.matchMap]),aN=ai&&ay.contentSearchResults.length>0,aO=!!ax.selectedPath&&null!==(0,H.c)(ax.selectedPath),aP=(0,f.useCallback)(async(a,c)=>{if(!ax.selectedPath||!aO)return;let d=await as.goToDefinition(ax.selectedPath,a,c);if(0===d.length)return;let e=d[0],f=b.endsWith("/")?b:b+"/",g=e.file.startsWith(f)?e.file.slice(f.length):e.file;av.push({filePath:ax.selectedPath,lineNumber:ab.current}),g===ax.selectedPath?ax.setTargetLineNumber(e.line):aH(g,e.line)},[ax,b,aO,as,av]),aQ=(0,f.useCallback)((a,b,c)=>{ax.selectedPath&&aO&&at.onTokenMouseEnter(ax.selectedPath,a,b,c)},[ax.selectedPath,aO,at]),aR=(0,f.useCallback)(a=>{let c=b.endsWith("/")?b:b+"/",d=a.file.startsWith(c)?a.file.slice(c.length):a.file;ax.selectedPath&&av.push({filePath:ax.selectedPath,lineNumber:ab.current}),d===ax.selectedPath?ax.setTargetLineNumber(a.line):aH(d,a.line)},[ax,b,av]),aS=(0,f.useMemo)(()=>{if(!az.status)return null;let a=new Map,b=a=>{switch(a){case"modified":default:return"M";case"added":return"A";case"deleted":return"D";case"renamed":return"R";case"untracked":return"?"}};for(let c of az.status.staged)a.set(c.path,b(c.status));for(let c of az.status.unstaged)a.set(c.path,b(c.status));return a},[az.status]),aT=(0,f.useCallback)(a=>{S(a),ax.setBlameSelectedCommit(null),"history"===a&&aC.selectedBranch&&aC.loadCommits(aC.selectedBranch)},[ax,aC.selectedBranch,aC.loadCommits]);(0,f.useCallback)(()=>{if(!ax.selectedPath)return;let a={filePath:ax.selectedPath,lineNumber:ab.current},b=av.goBack(a);b&&(b.filePath===ax.selectedPath?ax.setTargetLineNumber(b.lineNumber):aH(b.filePath,b.lineNumber))},[ax,av]),(0,f.useCallback)(()=>{if(!ax.selectedPath)return;let a={filePath:ax.selectedPath,lineNumber:ab.current},b=av.goForward(a);b&&(b.filePath===ax.selectedPath?ax.setTargetLineNumber(b.lineNumber):aH(b.filePath,b.lineNumber))},[ax,av]);let aU=(0,f.useCallback)(async a=>{let c=a.split("/").pop()||a;try{await fetch("/api/files/clipboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,path:a})}),(0,k.oR)(P("toast.copiedName",{name:c}),"success")}catch{(0,k.oR)(P("toast.copyFailed"),"error")}},[b]),aV=(0,f.useCallback)(async a=>{try{let c=await fetch("/api/files/clipboard"),d=await c.json();if(!d.path)return void(0,k.oR)(P("toast.noFileToPaste"),"info");let e=await fetch("/api/files/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,targetDir:a,sourceAbsPath:d.path})}),f=await e.json();e.ok?((0,k.oR)(P("toast.pastedFile",{name:f.newName}),"success"),ax.loadDirectory(a),ax.loadFileIndex()):(0,k.oR)(f.error||P("toast.pasteFailed"),"error")}catch{(0,k.oR)(P("toast.pasteFailed"),"error")}},[b,ax]);(0,f.useRef)(0),(0,f.useRef)(aw),(0,f.useRef)(R);let aW=(0,f.useRef)(aC.selectedBranch);aW.current=aC.selectedBranch;let aX=(0,f.useRef)(ax.selectedPath);aX.current=ax.selectedPath;let aY=(0,f.useRef)(ax.fileContent?.type);aY.current=ax.fileContent?.type;let aZ=(0,f.useCallback)(async a=>{try{let{data:c}=a;if(!c)return;let d=c.some(a=>"git"===a.type),e=c.some(a=>"file"===a.type),f=[];if((e||d)&&(f.push(fetch(`/api/files/init?cwd=${encodeURIComponent(b)}`).then(a=>a.json()).then(a=>{a.error||ax.setFiles(a.files||[])})),f.push(fetch(`/api/files/index?cwd=${encodeURIComponent(b)}`).then(a=>a.json()).then(a=>{a.paths&&ax.setFileIndex(a.paths)})),f.push(fetch(`/api/files/recent?cwd=${encodeURIComponent(b)}`).then(a=>a.json()).then(a=>{ax.setRecentFiles(a.files||[])}))),d||e){f.push(fetch(`/api/git/status?cwd=${encodeURIComponent(b)}`).then(a=>{if(a.ok)return a.json().then(a=>{az.setStatus(a);let b=(0,m.Do)(a.staged),c=(0,m.Do)(a.unstaged);az.setStagedTree(b),az.setUnstagedTree(c)})})),az.refreshDiff(),d&&aC.loadBranches();let a=aW.current;a&&f.push(fetch(`/api/git/commits?cwd=${encodeURIComponent(b)}&branch=${encodeURIComponent(a)}&limit=${q.B_}`).then(a=>a.json()).then(a=>{let b=a.commits||[];aC.setCommits(b),aC.setHasMoreCommits(b.length>=q.B_)}))}let g=aX.current,h=aY.current;g&&"text"===h&&f.push(fetch(`/api/files/text?cwd=${encodeURIComponent(b)}&path=${encodeURIComponent(g)}`).then(a=>a.ok?a.json():null).then(a=>{a&&"string"==typeof a.content&&ax.setFileContent({type:"text",content:a.content,size:a.size,mtime:a.mtimeMs,...a.isSymlink?{isSymlink:!0,symlinkTarget:a.symlinkTarget}:{}})})),await Promise.all(f)}catch(a){console.error("File watch handler error:",a)}},[b]);(0,t.h)({url:`/ws/watch?cwd=${encodeURIComponent(b)}`,onMessage:aZ,enabled:aw});let a$=(0,f.useCallback)(a=>{let b=a.split("/");if(b.length>1){let a=[];for(let c=1;c<b.length;c++)a.push(b.slice(0,c).join("/"));ax.setExpandedPaths(b=>{let c=new Set(b);for(let b of a)c.add(b);return ax.saveExpandedPaths(c),c})}ax.setSelectedPath(a),ax.setShouldScrollToSelected(!0),S("tree")},[ax]);return(0,e.jsxs)(n.SU,{container:X,children:[(0,e.jsxs)("div",{ref:V,className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsxs)("div",{className:"w-80 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex border-b border-border",children:[(0,e.jsx)("button",{onClick:()=>aT("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===R?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:P("fileBrowser.directoryTree")}),(0,e.jsx)("button",{onClick:()=>aT("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===R?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:P("fileBrowser.searchTab")}),(0,e.jsx)("button",{onClick:()=>aT("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===R?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:P("fileBrowser.recentTab")}),(0,e.jsx)("button",{onClick:()=>aT("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===R?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:P("fileBrowser.changesTab")}),(0,e.jsx)("button",{onClick:()=>aT("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===R?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:P("fileBrowser.historyTab")})]}),"tree"===R&&(0,e.jsxs)("div",{className:"p-2 border-b border-border flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:ax.searchInputRef,type:"text",value:ax.searchQuery,onChange:a=>ax.setSearchQuery(a.target.value),placeholder:P("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),ax.searchQuery&&(0,e.jsx)("button",{onClick:()=>ax.setSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:P("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>ax.setSearchDirExact(a=>!a),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${ax.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:ax.searchExactMatch?P("fileBrowser.exactMatchOn"):P("fileBrowser.exactMatchOff"),children:"ab"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>ax.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:P("fileBrowser.refreshTree"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:()=>ax.searchTreeExpandedPaths?ax.setSearchTreeExpandedPaths(new Set):ax.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:P("fileBrowser.collapseAll"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})]})]}),"search"===R&&(0,e.jsxs)("div",{className:"p-2 border-b border-border space-y-2",children:[(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:ay.contentSearchInputRef,type:"text",value:ay.contentSearchQuery,onChange:a=>ay.setContentSearchQuery(a.target.value),onKeyDown:a=>{"Enter"===a.key&&ay.performContentSearch(ay.contentSearchQuery)},placeholder:P("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),ay.contentSearchQuery&&(0,e.jsx)("button",{onClick:()=>ay.setContentSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:P("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>ay.performContentSearch(ay.contentSearchQuery),disabled:ay.isSearching||!ay.contentSearchQuery.trim(),className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",children:ay.isSearching?"...":P("common.search")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:ay.searchOptions.caseSensitive,onChange:a=>ay.setSearchOptions(b=>({...b,caseSensitive:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:P("fileBrowser.caseSensitive")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:ay.searchOptions.wholeWord,onChange:a=>ay.setSearchOptions(b=>({...b,wholeWord:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:P("fileBrowser.wholeWord")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:ay.searchOptions.regex,onChange:a=>ay.setSearchOptions(b=>({...b,regex:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:P("fileBrowser.regex")})]}),(0,e.jsx)("input",{type:"text",value:ay.searchOptions.fileType,onChange:a=>ay.setSearchOptions(b=>({...b,fileType:a.target.value})),placeholder:P("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9"})]})]}),"history"===R&&(0,e.jsx)("div",{className:"p-3 border-b border-border",children:aC.compareMode?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-border rounded bg-secondary text-foreground flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),(0,e.jsx)("span",{className:"truncate",children:aC.branches?.current||"HEAD"}),(0,e.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:"HEAD"})]}),(0,e.jsx)("button",{onClick:()=>aC.toggleCompareMode(!1),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors bg-brand text-white",title:P("fileBrowser.compareModeOff"),children:P("fileBrowser.compareMode")})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0 pl-1",children:"vs"}),(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(x.e,{branches:aC.branches,selectedBranch:aC.compareBaseBranch,onSelect:a=>{aC.setCompareBaseBranch(a),aC.loadCompareFiles(a)},isLoading:aC.isLoadingBranches,pinnedBranches:["origin/main",...aC.upstreamBranch&&"origin/main"!==aC.upstreamBranch?[aC.upstreamBranch]:[]]})})]})]}):(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(x.e,{branches:aC.branches,selectedBranch:aC.selectedBranch,onSelect:a=>{aC.setSelectedBranch(a)},isLoading:aC.isLoadingBranches,pinnedBranches:["origin/main",...aC.upstreamBranch&&"origin/main"!==aC.upstreamBranch?[aC.upstreamBranch]:[]]})}),(0,e.jsx)("button",{onClick:()=>aC.toggleCompareMode(!0),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors text-muted-foreground hover:text-foreground hover:bg-accent border border-border",title:P("fileBrowser.compareModeOn"),children:P("fileBrowser.compareMode")})]})}),(0,e.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,e.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 ${"tree"===R?"":"hidden"}`,children:[ax.creatingItem&&(0,e.jsxs)("div",{className:"px-2 py-1.5 border-b border-border bg-secondary flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:ax.creatingItem.parentPath?P("fileBrowser.createFileIn",{path:ax.creatingItem.parentPath}):P("fileBrowser.createFile")}),(0,e.jsx)("input",{type:"text",autoFocus:!0,placeholder:P("fileBrowser.fileName"),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring",onCompositionStart:()=>{W.current=!0},onCompositionEnd:()=>{W.current=!1},onKeyDown:async a=>{if("Enter"===a.key){if(W.current)return;let c=a.target.value.trim();if(!c)return;let d=ax.creatingItem.parentPath,e=d?`${d}/${c}`:c;try{let a=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,path:e,content:""})});if(a.ok)(0,k.oR)(P("toast.createdFile",{name:c}),"success"),ax.setCreatingItem(null),ax.loadDirectory(d),ax.loadFileIndex(),d&&ax.setExpandedPaths(a=>new Set([...a,d])),aH(e);else{let b=await a.json();(0,k.oR)(b.error||P("toast.createFailed"),"error")}}catch(a){(0,k.oR)(P("toast.createFailed"),"error")}}else"Escape"===a.key&&ax.setCreatingItem(null)},onBlur:()=>ax.setCreatingItem(null)})]}),ax.isLoadingFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:P("common.loading")}):ax.fileError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:ax.fileError}):(0,e.jsx)(l.h,{files:ax.files,selectedPath:ax.selectedPath,expandedPaths:ax.effectiveExpandedPaths,matchedPaths:ax.matchedPaths,gitStatusMap:aS,loadingDirs:ax.loadingDirs,onSelect:a=>{ax.setShouldScrollToSelected(!1),aH(a)},onToggle:ax.handleToggle,cwd:b,shouldScrollToSelected:ax.shouldScrollToSelected,onScrolledToSelected:()=>ax.setShouldScrollToSelected(!1),onCreateFile:a=>ax.setCreatingItem({type:"file",parentPath:a}),onDelete:(a,b,c)=>$({path:a,isDirectory:b,name:c}),onRefresh:()=>ax.loadFiles(),onCopyFile:aU,onPaste:aV})]}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===R?"":"hidden"}`,children:ay.isSearching?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):ay.searchError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:ay.searchError}):0===ay.contentSearchResults.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ay.contentSearchQuery?P("fileBrowser.noContentSearchResults"):P("fileBrowser.enterKeywordToSearch")}):(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[ay.searchStats&&(0,e.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-secondary border-b border-border flex-shrink-0",children:[P("fileBrowser.nFilesNMatches",{files:ay.searchStats.totalFiles,matches:ay.searchStats.totalMatches}),ay.searchStats.truncated&&(0,e.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",P("fileBrowser.resultsTruncated"),")"]})]}),(0,e.jsx)(l.h,{files:aI.files,selectedPath:ax.selectedPath,expandedPaths:aJ,onSelect:a=>{let b=aI.matchMap.get(a);aH(a,b?.matches[0]?.lineNumber),ai||aj(!0)},onToggle:aL,cwd:b,renderActions:aM,className:"flex-1 overflow-y-auto py-1 min-w-max"})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"recent"===R?"":"hidden"}`,children:0===ax.recentFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:P("fileBrowser.noRecentFiles")}):(0,e.jsx)(l.h,{files:ax.recentFilesTree,selectedPath:ax.selectedPath,expandedPaths:ax.recentTreeDirPaths,onSelect:aH,onToggle:q.tE,cwd:b})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===R?"":"hidden"}`,children:az.statusLoading?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):az.statusError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,e.jsx)("span",{className:"text-red-11 text-sm",children:az.statusError})}):(0,e.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[(0,e.jsxs)("div",{className:"border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:P("fileBrowser.stagingArea",{count:az.status?.staged.length||0})}),(0,e.jsx)("button",{onClick:()=>az.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:P("fileBrowser.refreshChanges"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})})]}),(az.status?.staged.length||0)>0&&(0,e.jsx)("button",{onClick:az.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:P("fileBrowser.unstageAll")})]}),(0,e.jsx)(m.VO,{files:az.stagedTree,selectedPath:az.statusSelectedFile?.type==="staged"?az.statusSelectedFile.file.path:null,expandedPaths:az.statusExpandedPaths,onSelect:a=>a.file&&az.handleStatusFileSelect(a.file,"staged"),onToggle:az.handleStatusToggle,cwd:b,emptyMessage:P("fileBrowser.noStagedFiles"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,m.wI)(a);return 0===b.length?null:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),az.handleUnstageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:P("fileBrowser.unstageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}return(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),az.handleUnstage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:P("fileBrowser.unstageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:P("fileBrowser.workspace",{count:az.status?.unstaged.length||0})}),(az.status?.unstaged.length||0)>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:az.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:P("fileBrowser.discardAll")}),(0,e.jsx)("button",{onClick:az.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:P("fileBrowser.stageAll")})]})]}),(0,e.jsx)(m.VO,{files:az.unstagedTree,selectedPath:az.statusSelectedFile?.type==="unstaged"?az.statusSelectedFile.file.path:null,expandedPaths:az.statusExpandedPaths,onSelect:a=>a.file&&az.handleStatusFileSelect(a.file,"unstaged"),onToggle:az.handleStatusToggle,cwd:b,emptyMessage:P("fileBrowser.noUnstagedChanges"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,m.wI)(a);if(0===b.length)return null;let c=b.map(a=>a.file).filter(Boolean);return(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),az.handleDiscardFiles(c)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:P("fileBrowser.discardNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),az.handleStageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:P("fileBrowser.stageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return a.file?(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),az.handleDiscardFile(a.file)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:P("fileBrowser.discardChanges"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),az.handleStage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:P("fileBrowser.stageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):null}})]})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"history"===R?"":"hidden"}`,children:aC.historyError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,e.jsx)("p",{className:"text-muted-foreground",children:aC.historyError})]})}):aC.compareMode?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:aC.isLoadingCompareFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:P("fileBrowser.loadingDiff")}):0===aC.compareFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:P("fileBrowser.noDiffFiles")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:P("fileBrowser.nFilesChanged",{count:aC.compareFiles.length,branch:aC.compareBaseBranch})})}),(0,e.jsx)(m.VO,{files:aC.compareFileTree,expandedPaths:aC.compareExpandedPaths,onToggle:aC.handleCompareToggle,selectedPath:aC.compareSelectedFile?.path||null,onSelect:a=>{a.file&&aC.handleSelectCompareFile(a.file)},cwd:b,showChanges:!0})]})}):(0,e.jsx)("div",{ref:aC.commitListRef,className:"flex-1 overflow-y-auto",onScroll:aC.handleCommitListScroll,children:aC.isLoadingCommits?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:P("fileBrowser.loadingCommits")}):0===aC.commits.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:P("fileBrowser.noCommits")}):(0,e.jsxs)(e.Fragment,{children:[aC.commits.map(a=>(0,e.jsxs)("div",{onClick:()=>aC.handleSelectCommit(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-accent ${aC.selectedCommit?.hash===a.hash?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),(0,e.jsxs)("span",{className:"text-xs text-slate-9",title:a.date,children:[a.relativeDate," \xb7 ",(0,q.r6)(a.date)]})]}),(0,e.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":a.subject,children:a.subject}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.author})]},a.hash)),aC.isLoadingMore&&(0,e.jsx)("div",{className:"p-3 text-center",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),!aC.hasMoreCommits&&aC.commits.length>0&&(0,e.jsx)("div",{className:"p-3 text-center text-xs text-slate-9",children:P("fileBrowser.allLoaded",{count:aC.commits.length})})]})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[("tree"===R||"search"===R||"recent"===R)&&(ax.blameSelectedCommit?(0,e.jsx)(i.n,{isOpen:!0,onClose:()=>ax.setBlameSelectedCommit(null),commit:ax.blameSelectedCommit,cwd:b,embedded:!0,initialFilePath:ax.selectedPath||void 0,onContentSearch:a=>{S("search"),ay.setContentSearchQuery(a),ay.performContentSearch(a)}}):"map"===T?(0,e.jsx)(v.O,{cwd:b,highlightedFilePath:ax.selectedPath,changedFiles:aA,onSwitchToCode:()=>U("code"),enableComments:!0,onContentSearch:a=>{S("search"),ay.setContentSearchQuery(a),ay.performContentSearch(a)},headerExtraLeft:({focalFile:a})=>a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${b}/${a}`),(0,k.oR)(P("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:P("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:b=>{b.stopPropagation(),a$(a)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:P("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]})}):ax.selectedPath?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex-shrink-0 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground truncate",children:ax.selectedPath}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${ax.selectedPath}`),(0,k.oR)(P("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:P("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:a=>{a.stopPropagation(),a$(ax.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:P("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:ax.showEditor?(0,e.jsxs)(e.Fragment,{children:[ag.isDirty&&(0,e.jsx)("span",{className:"text-xs text-amber-11",children:P("fileBrowser.unsaved")}),(0,e.jsx)("button",{onClick:()=>af.current?.save(),disabled:!ag.isDirty||ag.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${ag.isDirty&&!ag.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:ag.isSaving?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):P("common.save")}),(0,e.jsx)("button",{onClick:()=>af.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:P("fileBrowser.closeEdit"),children:P("fileBrowser.closeBtn")})]}):(0,e.jsxs)(e.Fragment,{children:[ax.fileContent?.type==="text"&&ax.fileContent.content&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(ax.fileContent.content),(0,k.oR)(P("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:P("fileBrowser.copyFileContent"),children:P("common.copy")}),ax.selectedPath?.endsWith(".json")&&ax.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>al(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${ak?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,title:P("fileBrowser.toggleJsonReadable"),children:P("common.readable")}),ax.fileContent?.type==="text"&&(0,p.e$)(ax.selectedPath)&&(0,e.jsx)("button",{onClick:()=>ax.setShowMarkdownPreview(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:P("fileBrowser.previewMarkdown"),children:P("common.preview")}),ax.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:ax.handleToggleBlame,disabled:ax.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${ax.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-accent"} disabled:opacity-50`,title:P("fileBrowser.viewBlame"),children:ax.isLoadingBlame?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),ax.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>U("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:P("blockViewer.viewerToggle.toBlock"),children:P("common.codeMap")}),ax.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>ax.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:P("fileBrowser.editFile"),children:P("common.edit")})]})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:ax.isLoadingContent?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):ax.fileContent?"text"===ax.fileContent.type&&"string"==typeof ax.fileContent.content?ax.showBlame&&ax.blameError?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{className:"text-red-11",children:ax.blameError}),(0,e.jsx)("button",{onClick:()=>ax.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:P("fileBrowser.backToPreview")})]})}):ax.showBlame&&0===ax.blameLines.length&&ax.isLoadingBlame?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):ak&&ax.selectedPath?.endsWith(".json")?(0,e.jsxs)("div",{className:"h-full flex flex-col bg-[#0d1117]",children:[(0,e.jsx)(G._,{search:ap}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,e.jsx)("pre",{ref:ao,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,p.xb)(ax.fileContent.content)})})]}):(0,e.jsx)(o.Cv,{ref:af,content:ax.fileContent.content,filePath:ax.selectedPath,cwd:b,enableComments:!0,scrollToLine:ad??ax.targetLineNumber,scrollToLineAlign:null!=ad?"start":ax.targetScrollAlign,onScrollToLineComplete:()=>{ae(null),ax.setTargetLineNumber(null)},highlightKeyword:"search"===R?ay.contentSearchQuery:null,visibleLineRef:ab,viStateRef:ac,initialCursorLine:ax.initialCursorLine,initialCursorCol:ax.initialCursorCol,onInitialCursorSet:()=>{ax.setInitialCursorLine(null),ax.setInitialCursorCol(null)},onCmdClick:aO?aP:void 0,onTokenHover:aO?aQ:void 0,onTokenHoverLeave:aO?at.onTokenMouseLeave:void 0,onTokenHoverCancel:aO?at.clearHover:void 0,blameLines:ax.showBlame&&ax.blameLines.length>0?ax.blameLines:void 0,inlineBlameLines:ax.blameLines.length>0?ax.blameLines:void 0,onSelectCommit:ax.setBlameSelectedCommit,editable:ax.showEditor,initialMtime:ax.fileContent.mtime,onEditorClose:a=>{ax.setShowEditor(!1),ae(a)},onSaved:()=>{let a=ab.current??1;ax.loadFileContent(ax.selectedPath),ax.setShowEditor(!1),ae(a)},onEditorStateChange:ah,viMode:!0,onContentMutate:aD,onEnterInsertMode:aE,onViSave:aF,onContentSearch:a=>{S("search"),ay.setContentSearchQuery(a),ay.performContentSearch(a)}}):"image"===ax.fileContent.type&&ax.selectedPath?(0,e.jsx)(y.I,{cwd:b,path:ax.selectedPath,refreshKey:ax.fileContent.mtime,alt:ax.selectedPath}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,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,e.jsx)("p",{children:ax.fileContent.message||P("fileBrowser.cannotPreview")})]})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:P("fileBrowser.selectFileToPreview")})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,e.jsx)("p",{children:P("fileBrowser.selectFileToPreview")})]})})),"status"===R&&(az.statusSelectedFile&&az.statusDiff?(0,e.jsx)(w.m,{cwd:b,selected:az.statusSelectedFile,diff:az.statusDiff,showMarkdownPreview:az.showStatusDiffPreview,setShowMarkdownPreview:az.setShowStatusDiffPreview,changedFiles:aA,fileGitStatusMap:aB,onContentSearch:a=>{S("search"),ay.setContentSearchQuery(a),ay.performContentSearch(a)},locateInTree:a$,jsonPreview:am,setJsonPreview:an,jsonPreviewSearch:ar,jsonPreviewPreRef:aq}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:P("fileBrowser.selectFileToViewDiff")})})),"history"===R&&!aC.historyError&&(aC.compareMode?aC.isLoadingCompareDiff?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:P("fileBrowser.loadingDiffContent")}):aC.compareFileDiff?(0,e.jsx)(j.xZ,{oldContent:aC.compareFileDiff.oldContent,newContent:aC.compareFileDiff.newContent,filePath:aC.compareFileDiff.filePath,isNew:aC.compareFileDiff.isNew,isDeleted:aC.compareFileDiff.isDeleted,cwd:b,enableComments:!0,onPreview:!aC.compareFileDiff.isDeleted&&aC.compareFileDiff.filePath.endsWith(".json")?()=>an({content:aC.compareFileDiff.newContent,filePath:aC.compareFileDiff.filePath}):void 0,previewLabel:P("common.readable"),onContentSearch:a=>{S("search"),ay.setContentSearchQuery(a),ay.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:aC.compareFiles.length>0?P("fileBrowser.selectFileToViewDiff"):P("fileBrowser.clickCompareToLoad")})}):aC.selectedCommit?(0,e.jsx)(i.n,{isOpen:!0,onClose:()=>aC.setSelectedCommit(null),commit:aC.selectedCommit,cwd:b,embedded:!0,onContentSearch:a=>{S("search"),ay.setContentSearchQuery(a),ay.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:P("fileBrowser.selectCommitToView")})}))]})]}),ax.showMarkdownPreview&&ax.fileContent?.type==="text"&&ax.selectedPath&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>ax.setShowMarkdownPreview(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(r.M,{content:ax.fileContent.content||"",filePath:ax.selectedPath,cwd:b,onClose:()=>ax.setShowMarkdownPreview(!1)})})}),_&&(0,e.jsx)(s.c,{files:ax.files,fileIndex:ax.fileIndex,recentFiles:ax.recentFilePaths,onSelectFile:a=>{aH(a),ax.setShouldScrollToSelected(!0),S("tree")},onClose:()=>aa(!1)}),(aN||au.visible)&&(0,e.jsxs)("div",{className:`flex ${au.visible&&aN?"":"flex-col"}`,children:[aN&&(0,e.jsx)("div",{className:au.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,e.jsx)(K.D,{results:ay.contentSearchResults,loading:ay.isSearching,totalMatches:ay.searchStats?.totalMatches??0,onSelect:(a,b)=>{ax.selectedPath&&av.push({filePath:ax.selectedPath,lineNumber:ab.current}),aH(a,b)},onClose:()=>aj(!1)})}),au.visible&&(0,e.jsx)("div",{className:aN?"flex-1 min-w-0":"",children:(0,e.jsx)(J.D,{references:au.references,loading:au.loading,onSelect:aR,onClose:au.closeReferences})})]})]}),Z&&(0,e.jsx)(h.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-black/50",onClick:()=>$(null),children:(0,e.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-2",children:P("fileBrowser.confirmDelete")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:P("fileBrowser.confirmDeleteMessage",{name:Z.name}).split(/<\/?file>/g).map((a,b)=>1===b?(0,e.jsx)("span",{className:"font-mono text-foreground",children:a},b):a)}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)("button",{onClick:()=>$(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-accent transition-colors",children:P("common.cancel")}),(0,e.jsx)("button",{onClick:async()=>{let{path:a,name:c}=Z;$(null);try{let d=await fetch("/api/files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b,path:a})});if(d.ok){(0,k.oR)(P("toast.movedToTrash",{name:c}),"success");let b=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"";ax.loadDirectory(b),ax.loadFileIndex(),ax.selectedPath===a&&aH("")}else{let a=await d.json();(0,k.oR)(a.error||P("toast.deleteFailed"),"error")}}catch{(0,k.oR)(P("toast.deleteFailed"),"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:P("common.delete")})]})]})})}),at.hoverInfo&&X&&(0,g.createPortal)((0,e.jsx)(I.s,{ref:at.setTooltipEl,displayString:at.hoverInfo.displayString,documentation:at.hoverInfo.documentation,x:at.hoverInfo.x,y:at.hoverInfo.y,container:X,onMouseEnter:at.onCardMouseEnter,onMouseLeave:at.onCardMouseLeave,onFindReferences:()=>{let{filePath:a,line:b,column:c}=at.hoverInfo;at.clearHover(),au.findReferences(a,b,c)},onSearch:a=>{at.clearHover(),S("search"),ay.setContentSearchQuery(a),ay.performContentSearch(a)}}),X)]})}[i,j,o,v,w,J,K]=M.then?(await M)():M,d()}catch(a){d(a)}})},54338:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabManager:()=>x});var e=c(48249),f=c(67484),g=c(44384),h=c(4667),i=c(54017),j=c(26130),k=c(50099),l=c(94924),m=c(77033),n=c(92154),o=c(31172),p=c(93053),q=c(81190),r=c(48464),s=c(92050),t=c(13928),u=c(132),v=c(21108),w=a([i,s]);function x({initialCwd:a,initialSessionId:b}){let{t:c}=(0,g.Bd)(),[d,w]=(0,f.useState)("agent"),{tabs:y,activeTabId:z,activeTab:A,unreadTabs:B,dragTabIndex:C,dragOverTabIndex:D,closeTab:E,switchTab:F,handleSelectSession:G,handleNewTab:H,handleNewClaude2Tab:I,handleNewCodexTab:J,handleNewKimiTab:K,handleNewOllamaTab:L,handleNewDeepseekTab:M,handleOpenSession:N,updateTabState:O,updateTabOllamaModel:P,updateTabDeepseekModel:Q,handleTabDragStart:R,handleTabDragOver:S,handleTabDrop:T,handleTabDragEnd:U}=(0,p.i)({initialCwd:a,initialSessionId:b,activeView:d}),{isPinned:V,pinSession:W,unpinSession:X}=(0,u.P)(),{createTask:Y}=(0,v.n)(),Z=(0,f.useCallback)(a=>{let b=y.find(b=>b.id===a);return!!b?.sessionId&&V(b.sessionId)},[y,V]),$=(0,f.useCallback)(b=>{let c=y.find(a=>a.id===b);c?.sessionId&&(V(c.sessionId)?X(c.sessionId):W(c.sessionId,c.cwd||a||"",c.title))},[y,V,W,X,a]),[_,aa]=(0,f.useState)(!1),[ab,ac]=(0,f.useState)(!1),[ad,ae]=(0,f.useState)(!1),[af,ag]=(0,f.useState)(null),[ah,ai]=(0,f.useState)(!1),[aj,ak]=(0,f.useState)("tree"),[al,am]=(0,f.useState)(0),[an,ao]=(0,f.useState)(null),[ap,aq]=(0,f.useState)(0),[ar,as]=(0,f.useState)(!1);(0,f.useRef)(null);let at=(0,f.useCallback)(b=>{w(b),a&&(fetch("/api/project-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,settings:{activeView:b}})}).catch(()=>{}),window.parent.postMessage({type:"VIEW_CHANGE",cwd:a,view:b},"*"))},[a]),au=(0,f.useCallback)(async()=>{if(a)try{let b=await fetch(`/api/git/worktree?cwd=${encodeURIComponent(a)}`);if(b.ok){let c=await b.json();if(ai(c.isGitRepo),c.isGitRepo&&c.worktrees.length>0){let b=c.worktrees.find(b=>b.path===a);b&&ag(b.branch)}}}catch(a){console.error("Failed to load git info:",a)}},[a]),av=(0,f.useCallback)(a=>{let{data:b}=a;b?.some(a=>"git"===a.type)&&au()},[au]);(0,t.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"")}`,onMessage:av,enabled:!!a});let aw=(0,f.useCallback)(()=>{ak("status"),am(a=>a+1),at("explorer")},[at]),ax=(0,f.useCallback)(a=>{ao(a),aq(a=>a+1),at("explorer")},[at]),ay=(0,f.useCallback)(()=>{a&&window.parent.postMessage({type:"OPEN_NOTE",cwd:a},"*")},[a]);return(0,e.jsx)(m.k_,{children:(0,e.jsx)(n.fY,{activeView:d,onViewChange:at,children:(0,e.jsxs)("div",{className:"flex h-screen bg-card",children:[(0,e.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,e.jsx)(q.B,{initialCwd:a,activeTab:A,isGitRepo:ah,currentBranch:af,onOpenWorktree:()=>ac(!0),onOpenProjectSessions:()=>aa(!0),onOpenAliasManager:()=>ae(!0),onBranchSwitched:au}),ar&&(0,e.jsxs)("div",{className:"flex items-center justify-center gap-2 py-1 bg-brand/15 text-brand text-xs font-medium border-b border-brand/20",children:[(0,e.jsx)("span",{className:"animate-pulse",children:"●"}),c("console.screenshotting")]}),a?(0,e.jsxs)(n.c0,{children:[(0,e.jsx)("div",{className:"w-1/3 h-full flex flex-col overflow-hidden",children:(0,e.jsx)(o.a9,{children:(0,e.jsxs)("div",{className:"w-full h-full flex flex-col",children:[(0,e.jsx)(r.V,{tabs:y,activeTabId:z,unreadTabs:B,dragTabIndex:C,dragOverTabIndex:D,isPinned:Z,onTogglePin:$,onSwitchTab:F,onCloseTab:E,onNewTab:H,onNewClaude2Tab:I,onNewCodexTab:J,onNewKimiTab:K,onNewOllamaTab:L,onNewDeepseekTab:M,onDragStart:R,onDragOver:S,onDrop:T,onDragEnd:U}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:y.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===z?"block":"hidden"}`,children:(0,e.jsx)(s.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,ollamaModel:a.ollamaModel,onOllamaModelChange:P,deepseekModel:a.deepseekModel,onDeepseekModelChange:Q,isActive:a.id===z&&"agent"===d,onStateChange:O,onShowGitStatus:aw,onContentSearch:ax,onOpenNote:ay,onCreateScheduledTask:Y,onOpenSession:N})},a.id))})]})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(o.a9,{children:(0,e.jsx)(i.g,{onClose:()=>at("agent"),cwd:a,initialTab:aj,tabSwitchTrigger:al,initialSearchQuery:an,searchQueryTrigger:ap})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(o.a9,{children:(0,e.jsx)(k.J,{cwd:a,tabId:"default",onOpenNote:ay})})})]}):(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsx)(r.V,{tabs:y,activeTabId:z,unreadTabs:B,dragTabIndex:C,dragOverTabIndex:D,isPinned:Z,onTogglePin:$,onSwitchTab:F,onCloseTab:E,onNewTab:H,onNewClaude2Tab:I,onNewCodexTab:J,onNewKimiTab:K,onNewDeepseekTab:M,onDragStart:R,onDragOver:S,onDrop:T,onDragEnd:U}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:y.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===z?"block":"hidden"}`,children:(0,e.jsx)(s.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,ollamaModel:a.ollamaModel,onOllamaModelChange:P,deepseekModel:a.deepseekModel,onDeepseekModelChange:Q,isActive:a.id===z,onStateChange:O,onCreateScheduledTask:Y,onOpenSession:N})},a.id))})]})]}),a&&(0,e.jsx)(h.Q,{isOpen:_,onClose:()=>aa(!1),cwd:a,onSelectSession:G}),a&&ah&&(0,e.jsx)(j.x,{isOpen:ab,onClose:()=>ac(!1),cwd:a}),ad&&(0,e.jsx)(l.Y,{onClose:()=>ae(!1),onSave:()=>ae(!1)})]})})})}[i,s]=w.then?(await w)():w,d()}catch(a){d(a)}})},55313:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("message-circle-question-mark",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},56111:(a,b,c)=>{"use strict";c.d(b,{e:()=>f});var d=c(67484),e=c(41564);function f(a,b,{sessionId:c,cwd:g,engine:h,ollamaModel:i,deepseekModel:j,onSessionId:k,onFetchTitle:l}){let[m,n]=(0,d.useState)(!1),[o,p]=(0,d.useState)(null),[q,r]=(0,d.useState)(null),[s,t]=(0,d.useState)(null),u=(0,d.useRef)(null),v=(0,d.useRef)(c);v.current=c;let w=(0,d.useRef)(null),x=(0,d.useRef)(null),y=(0,d.useCallback)(()=>{let a=w.current;if(a&&a.text){let{messageId:c,text:d}=a;b(a=>a.map(a=>a.id===c?{...a,content:(a.content||"")+d}:a)),w.current={messageId:c,text:""}}x.current=null},[b]),z=(0,d.useCallback)(()=>{u.current&&(u.current.abort(),u.current=null)},[]),A=(0,d.useCallback)((a,c)=>{let d=a.type;if("system"===d&&"init"===a.subtype){let b=a.session_id;k(b),v.current=b,t(null);return}if("system"===d&&"api_retry"===a.subtype)return void t({attempt:a.attempt??0,maxRetries:a.max_retries??0,delayMs:a.retry_delay_ms??0,errorStatus:a.error_status,error:a.error});if("rate_limit_event"===d){let b=a.rate_limit_info;b&&r({status:b.status||"allowed",resetsAt:b.resetsAt,rateLimitType:b.rateLimitType,utilization:b.utilization,overageStatus:b.overageStatus,overageDisabledReason:b.overageDisabledReason,isUsingOverage:b.isUsingOverage,surpassedThreshold:b.surpassedThreshold});return}if("stream_event"===d){t(a=>a?null:a);let b=a.event;if(b?.type==="content_block_delta"&&b.delta?.type==="text_delta"){let a=b.delta.text||"";w.current&&w.current.messageId===c?w.current.text+=a:w.current={messageId:c,text:a},x.current||(x.current=setTimeout(y,50))}return}if("assistant"===d){let d=a.message;if(d?.content){if("codex"===h||"kimi"===h||"ollama"===h){let a=d.content.filter(a=>"text"===a.type&&a.text).map(a=>a.text);if(a.length>0){let d=a.join("");b(a=>a.map(a=>a.id===c?{...a,content:(a.content||"")+d}:a))}}for(let a of d.content)if("name"in a&&a.name){let d={id:a.id||`tool-${Date.now()}`,name:a.name,input:a.input||{},isLoading:!0};b(a=>a.map(a=>a.id!==c||a.toolCalls?.some(a=>a.id===d.id)?a:{...a,toolCalls:[...a.toolCalls||[],d]}))}}}if("user"===d){let d=a.message;if(d?.content){for(let a of d.content)if("tool_use_id"in a&&a.tool_use_id){let d=a.tool_use_id,e="string"==typeof a.content?a.content:JSON.stringify(a.content);b(a=>a.map(a=>a.id===c?{...a,toolCalls:a.toolCalls?.map(a=>a.id===d?{...a,result:e,isLoading:!1}:a)}:a))}}}if("result"===d){t(null),x.current&&(clearTimeout(x.current),x.current=null),y();let d=v.current;d&&g&&b(a=>(2===a.length&&l(d),a));let e=a.usage,f=a.total_cost_usd;e&&p({inputTokens:e.input_tokens||0,outputTokens:e.output_tokens||0,cacheCreationInputTokens:e.cache_creation_input_tokens||0,cacheReadInputTokens:e.cache_read_input_tokens||0,totalCostUsd:f||0}),b(a=>a.map(a=>a.id===c?{...a,isStreaming:!1,toolCalls:a.toolCalls?.map(a=>({...a,isLoading:!1}))}:a))}},[b,y,k,l,g,h]),B=(0,d.useCallback)(async(a,c)=>{let d=c?.map(a=>({type:"base64",media_type:a.media_type,data:a.data})),f={id:`user-${Date.now()}`,role:"user",content:a,images:d};b(a=>[...a,f]),n(!0),t(null);let k=`assistant-${Date.now()}`,l={id:k,role:"assistant",content:"",toolCalls:[],isStreaming:!0};b(a=>[...a,l]),u.current=new AbortController;try{if("ollama"===h&&!i)throw Error("Please select an Ollama model first (click the model picker above)");let b="codex"===h?"/api/chat/codex":"kimi"===h?"/api/chat/kimi":"ollama"===h?"/api/chat/ollama":"deepseek"===h?"/api/chat/deepseek":"/api/chat",c=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:a,sessionId:v.current,images:d,cwd:g,language:e.A.language,..."ollama"===h&&i&&{model:i},..."deepseek"===h&&j&&{model:j},..."claude2"===h&&{engine:"claude2"}}),signal:u.current.signal});if(400===c.status&&"deepseek"===h){let a=await c.json().catch(()=>null);throw Error(a?.error||"Deepseek request failed")}if(!c.ok)throw Error(e.A.t("chat.requestFailed"));let f=c.body?.getReader();if(!f)throw Error(e.A.t("chat.cannotReadStream"));let l=new TextDecoder,m="";for(;;){let{done:a,value:b}=await f.read();if(a)break;let c=(m+=l.decode(b,{stream:!0})).split("\n");for(let a of(m=c.pop()||"",c))if(a.startsWith("data: ")){let b=a.slice(6);if("[DONE]"===b)continue;try{let a=JSON.parse(b);A(a,k)}catch{}}}}catch(a){if(a instanceof Error&&"AbortError"===a.name);else{console.error("Chat error:",a);let c=a instanceof Error?a.message:e.A.t("chat.errorRetry");b(a=>a.map(a=>a.id===k?{...a,content:c,isStreaming:!1}:a))}}finally{u.current=null,n(!1),b(a=>a.map(a=>a.id===k?{...a,isStreaming:!1}:a))}},[g,h,i,j,b,A]);return{isLoading:m,tokenUsage:o,rateLimitInfo:q,apiRetryInfo:s,handleSend:B,handleStop:z,abortControllerRef:u}}},56929:(a,b,c)=>{"use strict";c.d(b,{C6:()=>h,e$:()=>t,jU:()=>g,oK:()=>u,u:()=>s,xb:()=>i,zs:()=>q});var d=c(67484),e=c.n(d),f=c(41564);function g(a){try{return JSON.parse(a),!0}catch{return!1}}function h(a){try{let b=JSON.parse(a);return JSON.stringify(b,null,2)}catch{return a}}function i(a){try{let b=JSON.parse(a);return p(b,0)}catch{return a}}let j="#79c0ff",k="#a5d6ff",l="#ff7b72",m="#8b949e",n=(a,b)=>e().createElement("span",{style:{color:a}},b);function o({label:a,labelColor:b,value:c,indent:d}){let[g,h]=e().useState(!1),[i,j]=e().useState({x:0,y:0}),l="string"==typeof c&&c.replace(/\\n/g,"\n").split("\n").length>3,q={onMouseDown:a=>{j({x:a.clientX,y:a.clientY})},onClick:a=>{let b=a.clientX-i.x,c=a.clientY-i.y;b*b+c*c>25||(a.stopPropagation(),h(a=>!a))},style:{cursor:"pointer"}};if(l&&g&&"string"==typeof c){let d=c.replace(/\\n/g,"\n").split("\n")[0],g=c.replace(/\\n/g,"\n").split("\n").length;return e().createElement("span",q,n(b,a),n(m,": "),n(k,d),n("#6e7681",` ${f.A.t("toolCall.foldedLines",{count:g})}`))}let r=e().createElement(e().Fragment,null,n(b,a),n(m,": "),p(c,d));return l?e().createElement("span",q,r):r}function p(a,b){let c=" ".repeat(b);if(null===a)return n(l,"null");if(void 0===a)return n(l,"undefined");if("string"==typeof a)return n(k,a.replace(/\\n/g,"\n").replace(/\n/g,"\n"+c));if("number"==typeof a)return n("#79c0ff",String(a));if("boolean"==typeof a)return n(l,String(a));if(Array.isArray(a))return 0===a.length?n(m,"[]"):e().createElement(e().Fragment,null,n(m,"["),"\n",...a.map((d,f)=>e().createElement("span",{key:f},c+" ",e().createElement(o,{label:`[${f}]`,labelColor:j,value:d,indent:b+1}),f<a.length-1?e().createElement(e().Fragment,null,n(m,","),"\n"):"\n")),c,n(m,"]"));if("object"==typeof a){let d=Object.entries(a);return 0===d.length?n(m,"{}"):e().createElement(e().Fragment,null,n(m,"{"),"\n",...d.map(([a,f],g)=>e().createElement("span",{key:a},c+" ",e().createElement(o,{label:a,labelColor:j,value:f,indent:b+1}),g<d.length-1?e().createElement(e().Fragment,null,n(m,","),"\n"):"\n")),c,n(m,"}"))}return String(a)}function q(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path&&"string"==typeof b.old_string&&"string"==typeof b.new_string)return b}catch{}return null}let r=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function s(a){let b=a.slice(a.lastIndexOf(".")).toLowerCase();return r.has(b)}function t(a){return a.toLowerCase().endsWith(".md")}function u(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path)return b.file_path}catch{let b=a.trim();if(b.startsWith("/")&&!b.includes("\n")&&b.length<500)return b}return null}},59347:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]])},61969:(a,b,c)=>{"use strict";c.d(b,{e:()=>g,g:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({cwd:a,sessionId:b,onOpenProjectSessions:c,onOpenSessionBrowser:h,onOpenSettings:i}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1);return(0,d.jsx)("div",{className:"border-b border-border px-4 py-3 bg-card",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6"}),(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,d.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"One seat. One AI. Everything under control."})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[a&&(0,d.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help",title:`CWD: ${a}`,children:a}),!a&&b&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Session: ",b.slice(0,8),"..."]}),a&&(0,d.jsx)("button",{onClick:c,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("sessions.projectSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:h,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("sessions.browseAllSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),b&&(0,d.jsx)("button",{onClick:()=>{let a=`claude -r ${b}`;navigator.clipboard.writeText(a).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},className:`p-2 rounded-lg transition-colors ${k?"text-green-500 bg-green-500/10":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:k?j("chat.copiedCommandTooltip"):j("chat.copyCommandTooltip",{sessionId:b}),children:k?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),(0,d.jsx)("button",{onClick:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("settings.title"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})]})})}function h({tokenUsage:a,rateLimitInfo:b}){let{t:c}=(0,f.Bd)(),[g,i]=(0,e.useState)(()=>Date.now()),j=b?.status==="rejected"?"text-red-500":b?.status==="allowed_warning"?"text-yellow-500":"text-muted-foreground",k=b?.status==="rejected"?c("chat.rateLimitRejected","Rate Limited"):b?.status==="allowed_warning"?c("chat.rateLimitWarning","Approaching Limit"):null,l=a=>{if(!a)return"";let b=(a<1e12?1e3*a:a)-g;if(b<=0)return"";let c=Math.ceil(b/6e4);if(c<60)return`${c}m`;let d=Math.floor(c/60),e=c%60;return e>0?`${d}h${e}m`:`${d}h`},m=a=>a?a.replace(/_/g," "):"";return(0,d.jsx)("div",{className:"px-4 py-1.5 border-t border-border bg-secondary",children:(0,d.jsxs)("div",{className:"flex items-center justify-end gap-4 text-xs text-muted-foreground",children:[b&&k&&(0,d.jsxs)("span",{className:`flex items-center gap-1 ${j}`,title:[b.rateLimitType&&`Type: ${m(b.rateLimitType)}`,null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&`Resets in: ${l(b.resetsAt)}`,b.isUsingOverage&&"Using overage"].filter(Boolean).join(" \xb7 "),children:["rejected"===b.status?(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:[(0,d.jsx)("strong",{children:k}),null!=b.utilization&&` ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&` \xb7 ${l(b.resetsAt)}`]})]}),b&&!k&&b.resetsAt&&(0,d.jsxs)("span",{className:"flex items-center gap-1.5",title:[b.rateLimitType&&m(b.rateLimitType),null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,`Resets in: ${l(b.resetsAt)}`].filter(Boolean).join(" \xb7 "),children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),null!=b.utilization?(0,d.jsxs)("span",{children:[(100*b.utilization).toFixed(0),"%"]}):(0,d.jsx)("span",{children:l(b.resetsAt)})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsxs)("span",{children:[c("chat.context"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens).toLocaleString()})]})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),(0,d.jsxs)("span",{children:[c("chat.output"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:a.outputTokens.toLocaleString()})]})]}),(a.cacheReadInputTokens>0||a.cacheCreationInputTokens>0)&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-brand",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4"})}),(0,d.jsxs)("span",{children:["Cache: ",(a.cacheReadInputTokens/(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens)*100).toFixed(0),"%"]})]}),a.totalCostUsd>0&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-green-11",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:["$",a.totalCostUsd.toFixed(4)]})]})]})})}},62862:(a,b,c)=>{"use strict";function d(a){let b=a.split(".").pop()?.toLowerCase();return b?["ts","tsx","js","jsx","mjs","cjs"].includes(b)?"typescript":["py","pyi"].includes(b)?"python":null:null}c.d(b,{c:()=>d})},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},63161:(a,b,c)=>{"use strict";c.d(b,{m:()=>g});var d=c(48249),e=c(67484),f=c(31172);function g({currentModel:a,onModelChange:b}){let[c,h]=(0,e.useState)(!1),[i,j]=(0,e.useState)([]),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(!1),q=(0,e.useRef)(null),r=(0,e.useRef)(null),[s,t]=(0,e.useState)({top:0,left:0}),u=(0,f.F2)(),v=(0,e.useCallback)(async()=>{l(!0),n(null);try{let a=await fetch("/api/ollama/models");if(503===a.status){p(!0);let a=await fetch("/api/ollama/start",{method:"POST"}),b=await a.json();if(404===a.status){n(b.message||"Ollama is not installed"),p(!1);return}if(!a.ok){n("Failed to start Ollama"),p(!1);return}p(!1);let c=await fetch("/api/ollama/models");if(!c.ok)return void n("Ollama started but cannot fetch models");let d=await c.json();j(d.models||[])}else if(a.ok){let b=await a.json();j(b.models||[])}else n("Failed to fetch models")}catch{n("Connection error")}finally{l(!1)}},[]),w=a?a.replace(/:latest$/,""):"Select model",x=c?(0,d.jsx)(f.ZL,{children:(0,d.jsx)("div",{ref:r,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lg py-1 min-w-[200px] max-h-[300px] overflow-y-auto",style:{top:s.top,left:s.left},children:k||o?(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),o?"Starting Ollama...":"Loading models..."]}):m?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-red-400",children:m}):0===i.length?(0,d.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No models found. Run ",(0,d.jsx)("code",{className:"bg-secondary px-1 rounded",children:"ollama pull <model>"})]}):i.map(c=>{var e;return(0,d.jsxs)("button",{onClick:()=>{b(c.name),h(!1)},className:`w-full flex items-center justify-between gap-2 px-3 py-1.5 text-xs hover:bg-brand/10 transition-colors ${c.name===a?"text-brand":"text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate",children:c.name.replace(/:latest$/,"")}),(0,d.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:c.parameter_size||((e=c.size)<1e9?`${(e/1e6).toFixed(0)}M`:`${(e/1e9).toFixed(1)}G`)})]},c.name)})})}):null;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("button",{ref:q,onClick:()=>{if(!c){if(q.current){let a=q.current.getBoundingClientRect(),b=u?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;t({top:a.bottom+4-d,left:a.left-c})}v()}h(a=>!a)},className:"flex items-center gap-1 px-2 py-0.5 text-[11px] rounded bg-violet-500/15 text-violet-400 hover:bg-violet-500/25 transition-colors",title:"Switch Ollama model",children:[(0,d.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-violet-500 flex-shrink-0"}),(0,d.jsx)("span",{className:"truncate max-w-[120px]",children:w}),(0,d.jsx)("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),x]})}},66185:(a,b,c)=>{"use strict";c.d(b,{c:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(4219),h=c(31172);function i({path:a,matchedIndices:b}){let c=(0,e.useMemo)(()=>new Set(b),[b]),f=a.lastIndexOf("/"),g=f>=0?a.slice(0,f+1):"",h=f>=0?a.slice(f+1):a,j=(a,b,e)=>{let f=[],g="",h=!1;for(let e=0;e<a.length;e++){let i=b+e,j=c.has(i);j!==h&&g&&(f.push(h?(0,d.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-${e}`):(0,d.jsx)("span",{children:g},`${b}-${e}`)),g=""),h=j,g+=a[e]}return g&&f.push(h?(0,d.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-end`):(0,d.jsx)("span",{children:g},`${b}-end`)),(0,d.jsx)("span",{className:e,children:f})};return(0,d.jsxs)("span",{className:"truncate",children:[g&&j(g,0,"text-muted-foreground"),j(h,g.length,"text-foreground")]})}function j({files:a,fileIndex:b,recentFiles:c,onSelectFile:k,onClose:l}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)(0),r=(0,e.useRef)(null),s=(0,e.useRef)(null),t=(0,e.useMemo)(()=>{let c,d;return b??(c=[],(d=a=>{for(let b of a)b.isDirectory&&b.children?d(b.children):b.isDirectory||c.push(b.path)})(a),c)},[b,a]),u=(0,e.useMemo)(()=>{if(!n.trim()){let a=new Set(c);return[...c.map(a=>({path:a,score:0,matchedIndices:[]})),...t.filter(b=>!a.has(b)).slice(0,50).map(a=>({path:a,score:0,matchedIndices:[]}))]}let a=[];for(let b of t){let d=function(a,b){let c=a.toLowerCase(),d=b.toLowerCase(),e=[],f=0,g=0,h=-1;for(let i=0;i<c.length&&f<d.length;i++)c[i]===d[f]&&(e.push(i),h===i-1&&(g+=5),(0===i||"/"===a[i-1]||"."===a[i-1]||"-"===a[i-1]||"_"===a[i-1])&&(g+=10),i>a.lastIndexOf("/")&&(g+=3),a[i]===b[f]&&(g+=1),h=i,f++);return f<d.length?null:(g-=.1*a.length,{path:a,score:g,matchedIndices:e})}(b,n.trim());d&&(c.includes(b)&&(d.score+=20),a.push(d))}return a.sort((a,b)=>b.score-a.score),a.slice(0,50)},[n,t,c]),v=(0,e.useCallback)(a=>{o(a),q(0)},[]),w=(0,e.useCallback)(a=>{k(a),l()},[k,l]),x=(0,e.useCallback)(a=>{if(!a.nativeEvent.isComposing)switch(a.key){case"ArrowDown":a.preventDefault(),q(a=>Math.min(a+1,u.length-1));break;case"ArrowUp":a.preventDefault(),q(a=>Math.max(a-1,0));break;case"Enter":a.preventDefault(),u[p]&&w(u[p].path);break;case"Escape":a.preventDefault(),l()}},[u,p,w,l]);return(0,d.jsx)(h.ZL,{children:(0,d.jsx)("div",{className:"fixed inset-0 z-[300] flex items-start justify-center pt-[15vh]",onClick:l,children:(0,d.jsxs)("div",{className:"w-[680px] max-h-[60vh] bg-card border border-border rounded-lg shadow-2xl overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,d.jsx)("input",{ref:r,value:n,onChange:a=>v(a.target.value),onKeyDown:x,placeholder:m("quickFileOpen.placeholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",autoCorrect:"off",spellCheck:"false"}),(0,d.jsx)("kbd",{className:"text-[10px] text-muted-foreground px-1.5 py-0.5 rounded border border-border bg-secondary",children:"ESC"})]}),(0,d.jsx)("div",{ref:s,className:"flex-1 overflow-y-auto py-1",children:0===u.length?(0,d.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:m("quickFileOpen.noMatch")}):u.map((a,b)=>(0,d.jsxs)("div",{className:`px-3 py-1.5 flex items-center gap-2 cursor-pointer transition-colors ${b===p?"bg-brand/15 text-foreground":"hover:bg-accent text-foreground"}`,"data-tooltip":a.path,onClick:()=>w(a.path),children:[(0,d.jsx)(g.o,{name:a.path.split("/").pop()||"",className:"w-4 h-4 flex-shrink-0"}),(0,d.jsx)(i,{path:a.path,matchedIndices:a.matchedIndices}),!n.trim()&&c.includes(a.path)&&(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground px-1.5 py-0.5 rounded bg-secondary flex-shrink-0",children:m("quickFileOpen.recent")})]},a.path))}),(0,d.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex items-center gap-3 text-[10px] text-muted-foreground",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"↑↓"})," ",m("quickFileOpen.selectHint")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Enter"})," ",m("quickFileOpen.openHint")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Esc"})," ",m("quickFileOpen.closeHint")]})]})]})})})}},66254:(a,b,c)=>{"use strict";c.d(b,{h:()=>l});var d=c(48249),e=c(67484),f=c.n(e),g=c(36043),h=c(26068),i=c(4219);let j={M:{text:"text-amber-11",bg:"bg-amber-9/20"},A:{text:"text-green-11",bg:"bg-green-9/20"},D:{text:"text-red-11",bg:"bg-red-9/20"},"?":{text:"text-slate-9",bg:"bg-slate-9/20"},R:{text:"text-blue-11",bg:"bg-blue-9/20"}},k=f().memo(function({item:a,isSelected:b,isExpanded:c,isLoading:f,onSelect:g,onToggle:h,onContextMenu:k,renderActions:l}){let{node:m,level:n,gitStatus:o,hasChangedChildren:p}=a,q=o?j[o]:null,r=(0,e.useCallback)(()=>{m.isDirectory?h(m.path):g(m.path)},[m.isDirectory,m.path,g,h]),s=(0,e.useCallback)(a=>{k(a,m.path,m.isDirectory)},[m.path,m.isDirectory,k]),t=!m.isDirectory&&(".env"===m.name||m.name.startsWith(".env.")),u=o?q.text:p?"text-amber-11":t?"text-yellow-600 dark:text-yellow-500":b&&!m.isDirectory?"text-brand":"text-foreground";return(0,d.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 cursor-pointer hover:bg-accent ${b?"bg-brand/10":""}`,style:{paddingLeft:`${12*n+8}px`},onClick:r,onContextMenu:s,children:[m.isDirectory?f?(0,d.jsxs)("svg",{className:"w-4 h-4 flex-shrink-0 text-muted-foreground animate-spin",viewBox:"0 0 16 16",fill:"none",children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.3"}),(0,d.jsx)("path",{d:"M14 8a6 6 0 0 0-6-6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):(0,d.jsx)("svg",{className:`w-4 h-4 flex-shrink-0 text-muted-foreground transition-transform ${c?"rotate-90":""}`,viewBox:"0 0 16 16",fill:"none",children:(0,d.jsx)("path",{d:"M6 4 L10 8 L6 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}):(0,d.jsx)(i.o,{name:m.name,size:16,className:"flex-shrink-0 ml-4"}),(0,d.jsx)("span",{className:`text-sm truncate flex-1 ${u}`,"data-tooltip":m.isSymlink&&m.symlinkTarget?`${m.path} → ${m.symlinkTarget}`:m.path,children:m.name}),m.isSymlink&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:"→"}),o&&(0,d.jsx)("span",{className:`text-xs font-mono px-1 rounded ${q.text} ${q.bg} flex-shrink-0`,children:o}),m.isDirectory&&p&&(0,d.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-9 flex-shrink-0"}),l?.(m)]})});function l({files:a,selectedPath:b,expandedPaths:c,matchedPaths:f=null,gitStatusMap:i=null,loadingDirs:j,onSelect:m,onToggle:n,cwd:o,shouldScrollToSelected:p=!1,onScrolledToSelected:q,className:r,renderActions:s,onCreateFile:t,onDelete:u,onRefresh:v,onCopyFile:w,onPaste:x}){let y=(0,e.useRef)(null),{contextMenu:z,showContextMenu:A,hideContextMenu:B}=(0,h.Ee)(),C=(0,e.useMemo)(()=>(function a(b,c,d,e=null,f=0){let g=[];for(let h of b){if(null!==d&&!d.has(h.path))continue;let b=e?.get(h.path),i=h.isDirectory?function(a,b){if(!b)return!1;let c=a+"/";for(let a of b.keys())if(a.startsWith(c))return!0;return!1}(h.path,e):void 0;g.push({node:h,level:f,gitStatus:b,hasChangedChildren:i}),h.isDirectory&&h.children&&c.has(h.path)&&g.push(...a(h.children,c,d,e,f+1))}return g})(a,c,f,i),[a,c,f,i]),D=(0,g.Te)({count:C.length,getScrollElement:()=>y.current,estimateSize:()=>26,overscan:10});return((0,e.useRef)(q).current=q,0===C.length)?(0,d.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No files"}):(0,d.jsxs)("div",{ref:y,className:r||"h-full overflow-y-auto",style:{willChange:"transform"},children:[(0,d.jsx)("div",{style:{height:`${D.getTotalSize()}px`,width:"100%",position:"relative"},children:D.getVirtualItems().map(a=>{let e=C[a.index];return(0,d.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${a.size}px`,transform:`translateY(${a.start}px)`},children:(0,d.jsx)(k,{item:e,isSelected:b===e.node.path,isExpanded:c.has(e.node.path),isLoading:j?.has(e.node.path),onSelect:m,onToggle:n,onContextMenu:A,renderActions:s})},e.node.path)})}),z&&(0,d.jsx)(h.ft,{x:z.x,y:z.y,path:z.path,cwd:o,isDirectory:z.isDirectory,onClose:B,onCreateFile:t,onDelete:u,onRefresh:v,onCopyFile:w,onPaste:x})]})}},67093:(a,b,c)=>{"use strict";c.d(b,{_:()=>g});var d=c(48249);let e=(0,c(47408).A)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);var f=c(69005);function g({comments:a,startLine:b,endLine:c,lineHeight:h,bodyTopOffset:i,onCommentClick:j}){let k=new Map;for(let d of a){if(d.endLine<b||d.endLine>c)continue;let a=k.get(d.endLine);a?a.push(d):k.set(d.endLine,[d])}return 0===k.size?null:(0,d.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-6 pointer-events-none",children:Array.from(k.entries()).map(([a,c])=>{let g=i+(a-b)*h,k=c[0],l=c.length-1;return(0,d.jsx)(f.m,{content:1===c.length?k.content:`${c.length} comments — click to view`,children:(0,d.jsxs)("button",{onClick:a=>j(k,a),className:"pointer-events-auto absolute right-1 w-4 h-4 rounded-full bg-amber-9/70 hover:bg-amber-11 text-white flex items-center justify-center shadow-sm transition-colors",style:{top:`${g+h/2-8}px`},children:[(0,d.jsx)(e,{className:"w-2.5 h-2.5"}),l>0&&(0,d.jsx)("span",{className:"absolute -top-1 -right-1 bg-amber-11 text-white rounded-full text-[8px] leading-none w-3 h-3 flex items-center justify-center",children:l+1})]})},a)})})}},69648:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{z:()=>q});var e=c(48249),f=c(67484),g=c(44384),h=c(31172),i=c(80600),j=c(44218),k=c(19794),l=c(46674),m=c(86402),n=a([m]);function o(a,b){if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}return a}function p({node:a,selectedUid:b,onSelect:c,depth:d=0}){let[g,h]=(0,f.useState)(!0);if(a.isFile&&a.change){let f=b===a.change.uid;return(0,e.jsxs)("button",{onClick:()=>c(a.change),className:`w-full flex items-center gap-1.5 px-2 py-1 text-xs text-left rounded transition-colors ${f?"bg-brand/15 text-brand":"text-foreground hover:bg-accent"}`,style:{paddingLeft:`${12*d+8}px`},"data-tooltip":a.fullPath,children:[(0,e.jsx)(i.A,{className:"w-3.5 h-3.5 flex-shrink-0 opacity-60"}),(0,e.jsx)("span",{className:"truncate",children:a.name}),(0,e.jsx)("span",{className:`ml-auto text-[10px] flex-shrink-0 ${"write"===a.change.type?"text-green-500":"text-yellow-500"}`,children:"write"===a.change.type?"new":"edit"})]})}return(0,e.jsxs)("div",{children:[(0,e.jsxs)("button",{onClick:()=>h(!g),className:"w-full flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors",style:{paddingLeft:`${12*d+8}px`},children:[g?(0,e.jsx)(j.A,{className:"w-3 h-3"}):(0,e.jsx)(k.A,{className:"w-3 h-3"}),(0,e.jsx)("span",{className:"truncate",children:a.name})]}),g&&a.children.map((a,f)=>(0,e.jsx)(p,{node:a,selectedUid:b,onSelect:c,depth:d+1},a.isFile&&a.change?a.change.uid:`${a.fullPath}-${f}`))]})}function q({toolCalls:a,cwd:b,onClose:c}){let{t:d}=(0,g.Bd)(),i=(0,f.useMemo)(()=>(function(a,b){let c=[],d=0;for(let e of a)if("Edit"===e.name){let a=e.input;a.file_path&&"string"==typeof a.old_string&&"string"==typeof a.new_string&&c.push({filePath:o(a.file_path,b),uid:`change-${d++}`,type:"edit",old_string:a.old_string,new_string:a.new_string})}else if("Write"===e.name){let a=e.input;a.file_path&&"string"==typeof a.content&&c.push({filePath:o(a.file_path,b),uid:`change-${d++}`,type:"write",old_string:"",new_string:a.content})}return c})(a,b),[a,b]),j=(0,f.useMemo)(()=>(function a(b){return b.map(b=>{if(!b.isFile&&1===b.children.length&&!b.children[0].isFile){let c=b.children[0];return{...c,name:b.name+"/"+c.name,children:a(c.children)}}return{...b,children:a(b.children)}})})(function(a){let b=[];for(let c of a){let a=c.filePath.split("/").filter(Boolean),d=b;for(let b=0;b<a.length;b++){let e=a[b],f=b===a.length-1,g=a.slice(0,b+1).join("/");if(f){let a={name:e,fullPath:g,isFile:!0,children:[],change:c};d.push(a)}else{let a=d.find(a=>a.name===e&&!a.isFile);a||(a={name:e,fullPath:g,isFile:!1,children:[]},d.push(a)),d=a.children}}}return b}(i)),[i]),[k,n]=(0,f.useState)(i[0]||null),[r,s]=(0,f.useState)("unified"),t=(0,f.useRef)(null);if(0===i.length)return null;let u=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:c,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col transition-all",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsx)("div",{className:"flex items-center gap-2",children:(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:d("diffViewer.fileChanges",{count:i.length})})}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[(0,e.jsx)("button",{onClick:()=>s("unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"unified"===r?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Unified"}),(0,e.jsx)("button",{onClick:()=>s("split"),className:`px-2 py-1 text-xs rounded transition-colors ${"split"===r?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Split"})]}),(0,e.jsx)("button",{onClick:c,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)(l.A,{className:"w-5 h-5"})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)("div",{ref:t,className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto py-2",children:j.map((a,b)=>(0,e.jsx)(p,{node:a,selectedUid:k?.uid||"",onSelect:n},a.isFile&&a.change?a.change.uid:`${a.fullPath}-${b}`))}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:k?"unified"===r?(0,e.jsx)(m.xU,{oldContent:k.old_string,newContent:k.new_string,filePath:k.filePath}):(0,e.jsx)(m.xZ,{oldContent:k.old_string,newContent:k.new_string,filePath:k.filePath,isNew:"write"===k.type}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:d("diffViewer.selectFileToView")})})]})]})});return(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(h.ZL,{children:u})})}m=(n.then?(await n)():n)[0],d()}catch(a){d(a)}})},69924:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},72419:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},73136:a=>{"use strict";a.exports=require("node:url")},74405:(a,b,c)=>{Promise.resolve().then(c.bind(c,54338))},75648:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{i:()=>m});var e=c(45050),f=c(24591),g=c(78341),h=c(41938),i=a([h]);function j(a){return a.qualifiedName.startsWith("__code_")||a.qualifiedName.startsWith("__heading_")}function k(a){return!j(a)&&"__file__"!==a.qualifiedName}async function l(a,b){if(!a)return[];let c=(0,g.k)(b);if(!c)return null;let d=(await (0,h.$)(c)).parse(a);if(!d)return null;try{return(0,f.Hs)(d.rootNode)}finally{d.delete()}}async function m(a,b,c,d,f){let h=new Set;if(a!==b)for(let c of(0,e.X)(d?"":a,f?"":b))"added"===c.type&&void 0!==c.newLineNum&&h.add(c.newLineNum);if(!(0,g.k)(c))return{addedLines:h};let[i,m]=await Promise.all([l(d?"":a,c),l(f?"":b,c)]),n=m??[],o=function(a,b){let c=new Map;for(let b of a)c.set(b.qualifiedName,b);let d=new Map;for(let a of b)d.set(a.qualifiedName,a);let e=[];for(let a of b){let b=c.get(a.qualifiedName);b?b.contentHash!==a.contentHash&&e.push({id:`mod:${a.qualifiedName}`,changeKind:"modified",qname:a.qualifiedName}):e.push({id:`add:${a.qualifiedName}`,changeKind:"added",qname:a.qualifiedName})}for(let b of a)d.has(b.qualifiedName)||e.push({id:`del:${b.qualifiedName}`,changeKind:"deleted",qname:b.qualifiedName});return e}((i??[]).filter(k),n.filter(k)),p=new Set;for(let a of o)"deleted"!==a.changeKind&&p.add(a.qname);for(let a of function(a,b){if(0===b.size)return[];let c=[];for(let d of a)if(j(d)){for(let a of b)if(a>=d.startLine&&a<=d.endLine){c.push(d.qualifiedName);break}}return c}(n,h))p.add(a);return{changedQnames:p,addedLines:h}}h=(i.then?(await i)():i)[0],d()}catch(a){d(a)}})},76760:a=>{"use strict";a.exports=require("node:path")},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},78341:(a,b,c)=>{"use strict";function d(a){let b=a.split("/").pop()?.toLowerCase()??"";switch(b.includes(".")?b.split(".").pop():""){case"ts":return"typescript";case"tsx":case"jsx":return"tsx";case"js":case"mjs":case"cjs":return"javascript";case"py":case"pyi":return"python";case"go":return"go";case"rs":return"rust";default:return null}}c.d(b,{k:()=>d})},78908:a=>{"use strict";a.exports=import("shiki")},79327:a=>{"use strict";a.exports=require("node:process")},80600:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(47408).A)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},81190:(a,b,c)=>{"use strict";c.d(b,{B:()=>p});var d=c(48249),e=c(67484),f=c(92154),g=c(44384),h=c(13928),i=c(15622);let j="review-last-viewed";function k(){try{return JSON.parse(localStorage.getItem(j)||"{}")}catch{return{}}}function l(a,b){if(!a.lastCommentAt)return!1;let c=b[a.id];return!c||a.lastCommentAt>c}function m({cwd:a}){let{t:b}=(0,g.Bd)(),[c,f]=(0,e.useState)(!1),[n,o]=(0,e.useState)([]),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(null),[t,u]=(0,e.useState)({}),[v,w]=(0,e.useState)({open:!1,comments:[],title:"",userNameMap:{}}),x=(0,e.useRef)(null),y=(0,e.useRef)(null),[z,A]=(0,e.useState)(null),B=(0,e.useCallback)(async()=>{q(!0);try{let a=await fetch("/api/review");if(a.ok){let b=await a.json();o(b.reviews||[])}}catch{}q(!1)},[]),C=(0,e.useCallback)(a=>{let{data:b}=a;b?.some(a=>"review"===a.type)&&B()},[B]);(0,h.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"/")}`,onMessage:C,enabled:!!a});let D=(0,e.useMemo)(()=>n.filter(a=>a.active),[n]),E=(0,e.useMemo)(()=>D.some(a=>l(a,t)),[D,t]),F=(0,e.useCallback)(a=>{let b;(b=k())[a]=Date.now(),localStorage.setItem(j,JSON.stringify(b)),u(k()),window.open(`${window.location.origin}/review/${a}`,"_blank")},[]),G=(0,e.useCallback)(async(a,b)=>{a.stopPropagation();try{let[a,c]=await Promise.all([fetch(`/api/review/${b}`),fetch("/api/review/users")]);if(!a.ok)return;let{review:d}=await a.json(),e={};if(c.ok){let{users:a}=await c.json();for(let[b,c]of Object.entries(a))e[b]=c.name}w({open:!0,comments:d.comments||[],title:d.title,userNameMap:e})}catch{}},[]),H=(0,e.useCallback)((a,b)=>{y.current=b,a.dataTransfer.effectAllowed="move";let c=a.currentTarget;requestAnimationFrame(()=>c.classList.add("opacity-30"))},[]),I=(0,e.useCallback)(a=>{y.current=null,A(null),a.currentTarget instanceof HTMLElement&&a.currentTarget.classList.remove("opacity-30")},[]),J=(0,e.useCallback)((a,b)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",y.current&&y.current!==b&&A(b)},[]),K=(0,e.useCallback)((a,b)=>{a.preventDefault(),A(null);let c=y.current;y.current=null,c&&c!==b&&o(a=>{let d=[...a],e=d.findIndex(a=>a.id===c),f=d.findIndex(a=>a.id===b);if(-1===e||-1===f)return a;let[g]=d.splice(e,1);return d.splice(f,0,g),fetch("/api/review/order",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:d.map(a=>a.id)})}).catch(()=>{}),d})},[]);return(0,d.jsxs)("div",{ref:x,className:"relative",children:[(0,d.jsxs)("button",{onClick:()=>f(a=>!a),className:`relative p-2 rounded-lg transition-colors ${c?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:b("review.reviewManagement"),children:[(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),E&&(0,d.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 bg-red-500 rounded-full"})]}),c&&(0,d.jsxs)("div",{className:"absolute right-0 top-full mt-1 w-64 bg-popover border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:b("review.allReviews")}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground/60 ml-1.5",children:D.length})]}),(0,d.jsx)("button",{onClick:B,className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",title:b("common.refresh"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("div",{className:"max-h-80 overflow-y-auto",children:p&&0===n.length?(0,d.jsx)("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center",children:b("common.loading")}):0===D.length?(0,d.jsx)("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center",children:b("review.noOpenReviews")}):D.map(a=>{let c,e,f,g,h,i=l(a,t);return(0,d.jsxs)("div",{draggable:!0,onDragStart:b=>H(b,a.id),onDragEnd:I,onDragOver:b=>J(b,a.id),onDrop:b=>K(b,a.id),onMouseEnter:b=>{let c=b.currentTarget.getBoundingClientRect();s({id:a.id,text:a.title,top:c.top+c.height/2,left:c.left})},onMouseLeave:()=>s(b=>b?.id===a.id?null:b),onClick:()=>F(a.id),className:`group px-3 py-2 cursor-pointer border-b transition-colors ${z===a.id?"border-b-brand border-t border-t-transparent":"border-b-border/50"} hover:bg-accent/30`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${i?"bg-red-500":"bg-green-500"}`}),(0,d.jsx)("span",{className:`text-xs truncate flex-1 ${i?"font-medium text-foreground":""}`,children:a.title}),a.commentCount>0&&(0,d.jsx)("button",{onClick:b=>G(b,a.id),className:"flex-shrink-0 p-0.5 rounded text-muted-foreground/0 group-hover:text-muted-foreground/60 hover:!text-brand hover:!bg-brand/10 transition-colors",title:b("review.viewComments"),children:(0,d.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground/50 mt-0.5 pl-3",children:[(0,d.jsx)("span",{children:(e=String((c=new Date(a.updatedAt||a.createdAt)).getMonth()+1).padStart(2,"0"),f=String(c.getDate()).padStart(2,"0"),g=String(c.getHours()).padStart(2,"0"),h=String(c.getMinutes()).padStart(2,"0"),`${e}-${f} ${g}:${h}`)}),a.commentCount>0&&(0,d.jsx)("span",{children:b("review.nComments",{count:a.commentCount})})]})]},a.id)})})]}),r&&c&&(0,d.jsx)("div",{className:"fixed z-[60] px-2 py-1 text-xs bg-popover text-popover-foreground border border-border rounded shadow-md whitespace-nowrap pointer-events-none",style:{top:r.top,left:r.left-8,transform:"translate(-100%, -50%)"},children:r.text}),(0,d.jsx)(i._,{isOpen:v.open,onClose:()=>w(a=>({...a,open:!1})),comments:v.comments,reviewTitle:v.title,userNameMap:v.userNameMap})]})}var n=c(81749);function o({cwd:a,currentBranch:b,onSwitched:c}){let{t:f}=(0,g.Bd)(),[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)([]),[l,m]=(0,e.useState)(!1),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(""),t=(0,e.useRef)(null),u=(0,e.useRef)(null),v=(0,e.useCallback)(async()=>{m(!0);try{let b=await fetch(`/api/git/branches?cwd=${encodeURIComponent(a)}`);if(b.ok){let a=await b.json(),c=[...a.local||[],...(a.remote||[]).filter(b=>!a.local.includes(b.replace(/^origin\//,"")))];k(c)}}catch{(0,n.oR)(f("toast.loadBranchFailed"),"error")}finally{m(!1)}},[a]),w=(0,e.useCallback)(()=>{i(!0),s(""),v()},[v]),x=(0,e.useCallback)(()=>{i(!1)},[]),y=async b=>{q(!0);try{let d=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"checkout",cwd:a,path:a,branch:b})});if(d.ok){let a=b.replace(/^origin\//,"");(0,n.oR)(f("toast.switchedToBranch",{branch:a}),"success"),x(),c()}else{let a=await d.json();(0,n.oR)(a.error||f("toast.switchBranchFailed"),"error")}}catch{(0,n.oR)(f("toast.switchBranchFailed"),"error")}finally{q(!1)}},z=j.filter(a=>a!==b&&a.toLowerCase().includes(r.toLowerCase()));return(0,d.jsxs)("div",{className:"relative",ref:t,children:[(0,d.jsx)("button",{onClick:h?x:w,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:f("git.switchBranch"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})})}),h&&(0,d.jsxs)("div",{className:"absolute top-full left-0 mt-1 w-64 bg-popover border border-border rounded-lg shadow-lg z-50 overflow-hidden",children:[(0,d.jsx)("div",{className:"p-2 border-b border-border",children:(0,d.jsx)("input",{ref:u,type:"text",value:r,onChange:a=>s(a.target.value),placeholder:f("git.searchBranch"),className:"w-full px-2.5 py-1.5 text-sm bg-muted rounded border-none outline-none placeholder:text-muted-foreground",onKeyDown:a=>{"Escape"===a.key&&x()}})}),(0,d.jsx)("div",{className:"max-h-60 overflow-y-auto p-1",children:l?(0,d.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:f("common.loading")}):0===z.length?(0,d.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:r?f("git.noMatchingBranches"):f("git.noBranches")}):z.map(a=>(0,d.jsx)("button",{onClick:()=>y(a),disabled:p,className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-accent transition-colors truncate disabled:opacity-50",children:(0,d.jsx)("span",{className:a.startsWith("origin/")?"text-muted-foreground":"text-foreground",children:a})},a))})]})]})}function p({initialCwd:a,activeTab:b,isGitRepo:c,currentBranch:e,onOpenWorktree:h,onOpenProjectSessions:i,onOpenAliasManager:j,onBranchSwitched:k}){let{t:l}=(0,g.Bd)();return(0,d.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 relative",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6 cursor-pointer",title:l("tabManagerTopBar.copyPageUrl"),onClick:()=>{navigator.clipboard.writeText(window.location.href).then(()=>{(0,n.oR)(l("toast.copiedPageUrl"),"success")})}}),a?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help",title:`CWD: ${a}`,children:a}),(0,d.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(a),(0,n.oR)(l("toast.copiedDirPath"))},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:l("tabManagerTopBar.copyDirPath"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"})]}),c&&a&&(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsxs)("button",{onClick:h,className:"flex items-center gap-1.5 px-2 py-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:"Git Worktrees",children:[(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 17h8m0 0l-4-4m4 4l-4 4M3 7v6a4 4 0 004 4h5"})}),(0,d.jsx)("span",{className:"text-sm",children:e||"main"})]}),(0,d.jsx)(o,{cwd:a,currentBranch:e,onSwitched:()=>k?.()})]})]}),(0,d.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2",children:(0,d.jsx)(f.gT,{})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(m,{cwd:a}),(0,d.jsx)("button",{onClick:()=>window.location.reload(),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.refreshProject"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})}),a&&(0,d.jsx)("button",{onClick:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("sessions.projectSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:async()=>{if(b?.cwd)try{await fetch("/api/open-vscode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b.cwd})})}catch{}},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.openInVSCode"),children:(0,d.jsx)("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M17.583 2.213L12 7.393 6.417 2.213 1 6.17v11.66l5.417 3.957L12 16.607l5.583 5.18L23 17.83V6.17l-5.417-3.957zM6.417 17.83L3 15.33V8.67l3.417-2.5v11.66zm11.166 0V6.17L21 8.67v6.66l-3.417 2.5z"})})}),(0,d.jsx)("button",{onClick:async()=>{if(b?.cwd)try{await fetch("/api/open-cursor",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:b.cwd})})}catch{}},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.openInCursor"),children:(0,d.jsx)("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M4.5 2L20.5 12L4.5 22V2Z"})})}),b?.sessionId&&(0,d.jsx)("button",{onClick:()=>{let a=`claude -r ${b.sessionId}`;navigator.clipboard.writeText(a).then(()=>{(0,n.oR)(l("toast.copiedCommand",{command:a}),"success")})},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("chat.copyCommandTooltip",{sessionId:b.sessionId}),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:j,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.aliasesGlobal"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 12h-6m-4 0a8 8 0 1116 0 8 8 0 01-16 0zm4 0h.01"})})}),(0,d.jsx)("button",{onClick:()=>window.parent.postMessage({type:"OPEN_TOKEN_STATS"},"*"),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.tokenStats"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),(0,d.jsx)("button",{onClick:()=>window.open("https://surething.io?from=cockpit","_blank"),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:l("tabManagerTopBar.openSurething"),children:(0,d.jsx)("img",{src:"https://surething.io/logo.png?from=cockpit",alt:"Surething",className:"w-5 h-5 rounded-sm"})})]})]})})}},83634:(a,b,c)=>{"use strict";c.d(b,{V:()=>m});var d=c(48249),e=c(67484),f=c(44384),g=c(31172);function h({image:a,onClose:b}){let{t:c}=(0,f.Bd)(),e=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:b,children:(0,d.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,d.jsx)("img",{src:a.preview,alt:c("imagePreview.previewImage"),className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:a=>a.stopPropagation()}),(0,d.jsx)("button",{onClick:b,className:"absolute -top-3 -right-3 w-8 h-8 bg-card text-foreground hover:text-foreground rounded-full shadow-lg flex items-center justify-center transition-colors",title:c("common.close"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})});return(0,d.jsx)(g.ZL,{children:e})}function i({images:a,onRemove:b,disabled:c}){let{t:g}=(0,f.Bd)(),[j,k]=(0,e.useState)(null);return 0===a.length?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"flex flex-wrap gap-2 p-2 bg-secondary border-b border-border",children:a.map(a=>(0,d.jsxs)("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-border cursor-pointer",onClick:()=>k(a),children:[(0,d.jsx)("img",{src:a.preview,alt:g("imagePreview.previewImage"),className:"w-full h-full object-cover hover:opacity-90 transition-opacity"}),(0,d.jsx)("button",{onClick:c=>{c.stopPropagation(),b(a.id)},className:"absolute top-0 right-0 w-5 h-5 bg-black/60 hover:bg-black/80 text-white text-xs flex items-center justify-center rounded-bl-lg opacity-0 group-hover:opacity-100 transition-opacity",title:g("imagePreview.deleteImage"),children:"✕"})]},a.id))}),j&&(0,d.jsx)(h,{image:j,onClose:()=>k(null)})]})}var j=c(81749),k=c(31037),l=c(61858);let m=(0,e.memo)(function({onSend:a,disabled:b,cwd:c,engine:g,onShowGitStatus:h,onShowComments:m,onShowUserMessages:n,onOpenNote:o,onCreateScheduledTask:p}){let{t:q}=(0,f.Bd)(),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)([]),[v,w]=(0,e.useState)([]),[x,y]=(0,e.useState)([]),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)(0),[D,E]=(0,e.useState)(!1),F=(0,e.useRef)(null),G=(0,e.useRef)(null),H=(0,e.useCallback)(()=>{let a=F.current;if(!a)return;a.style.height="auto";let b=Math.max(38,Math.min(a.scrollHeight,200));a.style.height=`${b}px`},[]);(0,e.useLayoutEffect)(()=>{H()},[r,H]),(0,e.useEffect)(()=>{(async()=>{try{let a=c?`/api/commands?cwd=${encodeURIComponent(c)}`:"/api/commands",b=await fetch(a);if(b.ok){let a=await b.json();w(a)}}catch(a){console.error("Failed to load commands:",a)}})()},[c]);let I=(0,e.useCallback)(async()=>{try{let a=await fetch("/api/skills");if(a.ok){let b=(await a.json()).filter(a=>a.valid&&!!a.name).map(a=>({name:`/${a.name}`,description:a.description||"",source:"skill",skillPath:a.path,argumentHint:a.argumentHint}));y(b)}}catch(a){console.error("Failed to load skills:",a)}},[]);(0,e.useEffect)(()=>(I(),(0,l.U)(I)),[I]);let J=(0,e.useMemo)(()=>{if(!r.startsWith("/"))return[];let a=r.toLowerCase(),b=b=>b.name.toLowerCase().startsWith(a);return[...v.filter(b),...x.filter(b)]},[r,v,x]),K=!D&&r.startsWith("/")&&J.length>0,L=(0,e.useRef)(r);(0,e.useLayoutEffect)(()=>{L.current!==r&&(queueMicrotask(()=>C(0)),D&&queueMicrotask(()=>E(!1)),L.current=r)},[r,D]),(0,e.useLayoutEffect)(()=>{if(K&&G.current){let a=G.current.children[B];a&&a.scrollIntoView({block:"nearest"})}},[B,K]);let M=(0,e.useCallback)(()=>{let c=r.trim();if((c||t.length>0)&&!b){let b=c;if(c.startsWith("/")&&x.length>0)for(let a of[...x].sort((a,b)=>b.name.length-a.name.length)){if(!a.skillPath)continue;if(c===a.name){b=`${q("chat.skillExpansionPrompt")}
27
- ${a.skillPath}`;break}let d=`${a.name} `;if(c.startsWith(d)){let e=c.slice(d.length).trimStart();b=`${q("chat.skillExpansionPrompt")}
28
- ${a.skillPath}
29
-
30
- ${e}`;break}}a(b,t.length>0?t:void 0),s(""),u([]),F.current&&(F.current.style.height="auto")}},[r,t,b,a,x,q]),N=(0,e.useCallback)(a=>{s(a.name+" "),F.current?.focus()},[]),O=(0,e.useCallback)(a=>{if(!a.nativeEvent.isComposing){if(K&&J.length>0){if("ArrowDown"===a.key){a.preventDefault(),C(a=>(a+1)%J.length);return}if("ArrowUp"===a.key){a.preventDefault(),C(a=>(a-1+J.length)%J.length);return}if("Enter"===a.key){a.preventDefault(),N(J[B]);return}if("Escape"===a.key){a.preventDefault(),E(!0);return}if("Tab"===a.key){a.preventDefault(),N(J[B]);return}}"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),M())}},[K,J,B,N,M]),P=(0,e.useCallback)(a=>{let b=a.clipboardData?.items;if(!b)return;let c=["image/png","image/jpeg","image/webp","image/gif"];for(let d of Array.from(b)){let b=c.find(a=>d.type===a);if(b){a.preventDefault();let c=d.getAsFile();if(!c)continue;if(c.size>5242880){alert(q("chat.imageSizeLimit",{size:(c.size/1024/1024).toFixed(2)}));continue}let e=new FileReader;e.onload=a=>{let c=a.target?.result;if(!c)return;let d=c.replace(/^data:image\/\w+;base64,/,""),e={id:`img-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,data:d,preview:c,media_type:b};u(a=>[...a,e])},e.readAsDataURL(c)}}},[q]),Q=(0,e.useCallback)(a=>{u(b=>b.filter(b=>b.id!==a))},[]);return(0,d.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,d.jsx)(i,{images:t,onRemove:Q,disabled:b}),K&&J.length>0&&(0,d.jsx)("div",{ref:G,className:"absolute bottom-full left-0 right-0 mx-4 mb-2 max-h-64 overflow-y-auto bg-card border border-border rounded-lg shadow-lg",children:J.map((a,b)=>{let c=b>0?J[b-1]:null,e="skill"===a.source&&(!c||"skill"!==c.source),f="skill"!==a.source&&0===b;return(0,d.jsxs)("div",{children:[f&&(0,d.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Commands"}),e&&(0,d.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Skills"}),(0,d.jsxs)("div",{onClick:()=>N(a),className:`px-4 py-2 cursor-pointer ${b===B?"bg-brand/10":"hover:bg-accent"}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("span",{className:"font-mono text-sm font-medium text-foreground",children:a.name}),(0,d.jsx)("span",{className:"flex-1 text-sm text-muted-foreground truncate",children:a.description}),(0,d.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${(a=>{switch(a){case"builtin":return"bg-brand/15 text-brand dark:bg-brand/25 dark:text-teal-11";case"global":return"bg-green-9/15 text-green-11 dark:bg-green-9/25 dark:text-green-11";case"project":return"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25 dark:text-amber-11";case"skill":return"bg-purple-9/15 text-purple-11 dark:bg-purple-9/25 dark:text-purple-11"}})(a.source)}`,children:(a=>{switch(a){case"builtin":return q("common.builtin");case"global":return q("common.global");case"project":return q("common.project");case"skill":return"Skill"}})(a.source)})]}),"skill"===a.source&&a.argumentHint&&(0,d.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-0.5 pl-0 truncate",children:a.argumentHint})]})]},a.name)})}),(0,d.jsxs)("div",{className:"flex gap-2 items-end p-4",children:[(0,d.jsx)("button",{onClick:async()=>{try{(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:c,files:["."]})})).ok?((0,j.oR)(q("toast.stagedAllFiles"),"success"),window.dispatchEvent(new CustomEvent("git-status-changed"))):(0,j.oR)(q("toast.stageFailed"),"error")}catch(a){console.error("Error staging files:",a),(0,j.oR)(q("toast.stageFailed"),"error")}},className:"p-2 text-green-11 hover:text-green-10 hover:bg-green-9/10 active:bg-green-9/20 active:scale-95 rounded-lg transition-all",title:q("chat.stageAll"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),h&&(0,d.jsx)("button",{onClick:h,className:"p-2 text-brand hover:text-teal-10 hover:bg-brand/10 active:bg-brand/20 active:scale-95 rounded-lg transition-all",title:q("chat.viewGitChanges"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"6",cy:"6",r:"2",strokeWidth:2}),(0,d.jsx)("circle",{cx:"18",cy:"6",r:"2",strokeWidth:2}),(0,d.jsx)("circle",{cx:"6",cy:"18",r:"2",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 8v10M18 8v4c0 2-2 4-6 4"})]})}),m&&(0,d.jsx)("button",{onClick:m,className:"p-2 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95 rounded-lg transition-all",title:q("chat.viewAllComments"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),n&&(0,d.jsx)("button",{onClick:n,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:q("chat.userMessages"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),o&&(0,d.jsx)("button",{onClick:o,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:q("chat.projectNotes"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})}),p&&(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("button",{onClick:()=>A(!z),className:`p-2 rounded-lg transition-all ${z?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95"}`,title:q("chat.scheduledTasks"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]})}),z&&(0,d.jsx)(k.E,{onClose:()=>A(!1),onCreate:p})]}),(0,d.jsx)("textarea",{ref:F,value:r,onChange:a=>s(a.target.value),onKeyDown:O,onPaste:P,placeholder:b?q("chat.placeholderDisabled"):q("chat.placeholder"),rows:1,className:"flex-1 resize-none px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-ring bg-card text-foreground placeholder-slate-9"})]})]})})},84705:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{s:()=>x});var e=c(48249),f=c(67484),g=c(31172),h=c(49681),i=c(21735),j=c(33740),k=c(55313),l=c(32616),m=c(86791),n=c(69648),o=c(31893),p=c(10164),q=c(26068),r=c(49280),s=c(81749),t=c(44384),u=a([m,n]);function v({image:a,onClose:b}){let{t:c}=(0,t.Bd)(),d=(0,e.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:b,children:[(0,e.jsx)("button",{onClick:b,className:"absolute top-4 right-4 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",children:(0,e.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),(0,e.jsx)("img",{src:`data:${a.media_type};base64,${a.data}`,alt:c("chat.imagePreview"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:a=>a.stopPropagation()})]});return(0,e.jsx)(g.ZL,{children:d})}function w({filePath:a,content:b,cwd:c,onClose:d}){let[h,i]=(0,f.useState)(null);return(0,e.jsx)(g.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:d,children:(0,e.jsx)("div",{ref:i,className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col relative",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(q.SU,{container:h,children:(0,e.jsx)(p.M,{content:b,filePath:a,cwd:c,onClose:d})})})})})}[m,n]=u.then?(await u)():u;let x=(0,f.memo)(function({message:a,cwd:b,sessionId:c,onFork:d}){let g,p,q,u,{t:x}=(0,t.Bd)(),[y,z]=(0,f.useState)(null),[A,B]=(0,f.useState)(!1),[C,D]=(0,f.useState)(!1),[E,F]=(0,f.useState)(!1),G="user"===a.role,H=a.images&&a.images.length>0,I=a.toolCalls?.length||0,J=I>1,K=!!c&&!!b&&!!d,L=(0,f.useMemo)(()=>a.toolCalls?.some(a=>"Edit"===a.name||"Write"===a.name)||!1,[a.toolCalls]),M=(0,f.useMemo)(()=>{if(!a.toolCalls)return null;for(let b=a.toolCalls.length-1;b>=0;b--)if("TodoWrite"===a.toolCalls[b].name)return a.toolCalls[b];return null},[a.toolCalls]),N=(0,f.useMemo)(()=>a.toolCalls?a.toolCalls.filter(a=>"AskUserQuestion"===a.name):[],[a.toolCalls]),O=(0,f.useMemo)(()=>{if(!a.toolCalls)return[];let b=new Set,c=[];for(let d of a.toolCalls)if("Read"===d.name||"Edit"===d.name||"Write"===d.name){let a=d.input.file_path;a&&a.toLowerCase().endsWith(".md")&&!b.has(a)&&(b.add(a),c.push(a))}return c},[a.toolCalls]),P=(0,f.useMemo)(()=>{if(!a.toolCalls)return[];let b=[];for(let c of a.toolCalls){let a=c.input?.thought;if(a&&"string"==typeof a){let d=a.match(/PREVIOUS:\s*(.*?)\s*→\s*THIS:\s*(.*?)\s*→\s*EXPECT:\s*(.*)/i);d?b.push({previous:d[1].trim(),current:d[2].trim(),expect:d[3].trim(),raw:a,toolName:c.name}):b.push({previous:"",current:a,expect:"",raw:a,toolName:c.name})}}return b},[a.toolCalls]),[Q,R]=(0,f.useState)(null),[S,T]=(0,f.useState)(null);(0,f.useEffect)(()=>{if(!Q)return void queueMicrotask(()=>T(null));let a=!1;return fetch(`/api/file?path=${encodeURIComponent(Q)}`).then(a=>a.ok?a.json():Promise.reject()).then(b=>{a||T(b.content)}).catch(()=>{a||((0,s.oR)(x("toast.readFileFailed"),"error"),R(null))}),()=>{a=!0}},[Q]);let U=()=>{a.content&&(navigator.clipboard.writeText(a.content),(0,s.oR)(x("toast.copiedMessage")))},V=()=>{K&&d(a.id)},W=(a=>{if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`})(a.timestamp);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:`flex flex-col ${G?"items-end":"items-start"} mb-4 group`,"data-role":a.role,children:[W&&(0,e.jsx)("span",{className:"text-[11px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity mb-0.5 px-1",children:W}),(0,e.jsxs)("div",{className:`flex ${G?"justify-end":"justify-start"} w-full`,children:[G&&(0,e.jsxs)("div",{className:"self-start mt-2 mr-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.content&&(0,e.jsx)("button",{onClick:U,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:x("chat.copyMessage"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})}),K&&(0,e.jsx)("button",{onClick:V,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:x("chat.forkSession"),children:(0,e.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("circle",{cx:"12",cy:"18",r:"3"}),(0,e.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,e.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,e.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,e.jsx)("path",{d:"M12 12v3"})]})})]}),(0,e.jsxs)("div",{className:`max-w-[80%] ${G?"bg-accent text-foreground border border-brand rounded-2xl rounded-br-md":"bg-accent text-foreground dark:text-slate-11 rounded-2xl rounded-bl-md"} px-4 py-2`,children:[H&&(0,e.jsx)("div",{className:`flex flex-wrap gap-2 ${a.content?"mb-2":""}`,children:a.images.map((a,b)=>(0,e.jsx)("div",{className:"relative w-16 h-16 rounded-lg overflow-hidden border border-white/20 cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>z(a),children:(0,e.jsx)("img",{src:`data:${a.media_type};base64,${a.data}`,alt:x("chat.imageN",{index:b+1}),className:"w-full h-full object-cover"})},b))}),a.content&&(0,e.jsxs)("div",{className:"break-words",children:[(0,e.jsx)(r.T,{content:a.content,isUser:G,isStreaming:a.isStreaming,enableMath:!1}),a.isStreaming&&(0,e.jsx)("span",{className:"inline-block w-2 h-4 ml-1 bg-current animate-pulse"})]}),M&&(g=M.input?.todos,q=(p=Array.isArray(g)?g:[]).filter(a=>"completed"===a.status).length,u=p.length,(0,e.jsx)("div",{className:`${a.content||H?"mt-2":""}`,children:(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50 px-3 py-2 space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,e.jsx)("div",{className:"flex-1 h-1 bg-secondary rounded-full overflow-hidden",children:(0,e.jsx)("div",{className:"h-full bg-green-500 rounded-full transition-all duration-300",style:{width:`${u>0?q/u*100:0}%`}})}),(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[q,"/",u]})]}),p.map((a,b)=>(0,e.jsxs)("div",{className:`flex items-center gap-1.5 ${"completed"===a.status?"opacity-50":""}`,children:["completed"===a.status?(0,e.jsx)(h.A,{className:"w-3 h-3 text-green-500 flex-shrink-0"}):"in_progress"===a.status?(0,e.jsx)(i.A,{className:"w-3 h-3 text-brand flex-shrink-0 animate-spin"}):(0,e.jsx)(j.A,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),(0,e.jsx)("span",{className:`text-xs truncate ${"completed"===a.status?"text-muted-foreground":"text-foreground"}`,children:"in_progress"===a.status&&a.activeForm?a.activeForm:a.content})]},b))]})})),O.length>0&&(0,e.jsx)("div",{className:`${a.content||H||M?"mt-2":""}`,children:(0,e.jsx)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50 px-3 py-2 space-y-0.5",children:O.map(a=>(0,e.jsxs)("button",{onClick:()=>R(a),className:"flex items-center gap-1.5 w-full text-left hover:bg-accent rounded px-1 py-0.5 transition-colors group/md",children:[(0,e.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,e.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,e.jsx)("span",{className:"text-xs text-muted-foreground group-hover/md:text-foreground truncate",children:a.split("/").pop()})]},a))})}),P.length>0&&(0,e.jsx)("div",{className:`${a.content||H||M||O.length>0?"mt-2":""}`,children:(0,e.jsx)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50",children:(0,e.jsxs)("table",{className:"w-full text-xs",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-border text-muted-foreground",children:[(0,e.jsx)("th",{className:"px-2 py-1.5 text-left font-medium w-[60px]",children:"Tool"}),(0,e.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Previous"}),(0,e.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Action"}),(0,e.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Expect"})]})}),(0,e.jsx)("tbody",{children:P.map((a,b)=>(0,e.jsxs)("tr",{className:b<P.length-1?"border-b border-border/50":"",children:[(0,e.jsx)("td",{className:"px-2 py-1 text-muted-foreground font-mono",children:a.toolName}),(0,e.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:a.previous||"—"}),(0,e.jsx)("td",{className:"px-2 py-1 text-foreground",children:a.current}),(0,e.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:a.expect||"—"})]},b))})]})})}),a.toolCalls&&a.toolCalls.length>0&&(0,e.jsx)("div",{className:`${a.content||H?"mt-2":""}`,children:J?(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center",children:[(0,e.jsxs)("button",{onClick:()=>B(!A),className:"flex-1 px-3 py-2 flex items-center gap-2 text-left hover:bg-accent transition-colors active:bg-muted",children:[(0,e.jsx)("span",{className:"text-lg",children:"\uD83D\uDD27"}),(0,e.jsx)("span",{className:"font-medium text-foreground",children:x("chat.toolCalls",{count:I})}),(0,e.jsx)("span",{className:"ml-auto text-muted-foreground text-sm",children:A?x("chat.collapse"):x("chat.expand")})]}),N.length>0&&(0,e.jsx)("button",{onClick:()=>F(!0),className:"px-3 py-2 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors border-l border-border",title:x("chat.viewQuestions"),children:(0,e.jsx)(k.A,{className:"w-4 h-4"})}),L&&(0,e.jsx)("button",{onClick:()=>D(!0),className:"px-3 py-2 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors border-l border-border",title:x("chat.viewAllFileChanges"),children:(0,e.jsx)(l.A,{className:"w-4 h-4"})})]}),A&&(0,e.jsx)("div",{className:"border-t border-border p-2 space-y-1",children:a.toolCalls.map((a,c)=>(0,e.jsx)(m.K,{toolCall:a,cwd:b},`${a.id}-${c}`))})]}):a.toolCalls.map((a,c)=>(0,e.jsx)(m.K,{toolCall:a,cwd:b},`${a.id}-${c}`))})]}),!G&&(0,e.jsxs)("div",{className:"self-start mt-2 ml-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.content&&(0,e.jsx)("button",{onClick:U,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:x("chat.copyMessage"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})}),K&&(0,e.jsx)("button",{onClick:V,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:x("chat.forkSession"),children:(0,e.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("circle",{cx:"12",cy:"18",r:"3"}),(0,e.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,e.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,e.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,e.jsx)("path",{d:"M12 12v3"})]})})]})]})]}),y&&(0,e.jsx)(v,{image:y,onClose:()=>z(null)}),C&&a.toolCalls&&(0,e.jsx)(n.z,{toolCalls:a.toolCalls,cwd:b,onClose:()=>D(!1)}),E&&N.length>0&&(0,e.jsx)(o.$,{toolCalls:N,onClose:()=>F(!1)}),Q&&null!==S&&(0,e.jsx)(w,{filePath:Q,content:S,cwd:b||"",onClose:()=>R(null)})]})});d()}catch(a){d(a)}})},86402:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{xU:()=>B,xZ:()=>A});var e=c(48249),f=c(67484),g=c(74429),h=c(44384),i=c(36043),j=c(72419),k=c(44218),l=c(47033),m=c(23434),n=c(26068),o=c(77033),p=c(45214),q=c(45050),r=c(33500),s=c(81749),t=c(90173),u=c(5811),v=c(89976),w=c(77937),x=c(68502),y=a([t,u]);function z(a){return a.params?`${a.name}(${a.params.join(", ")})`:a.name}[t,u]=y.then?(await y)():y;let C=(0,f.memo)(function({floatingToolbarRef:a,bumpRef:b,container:c,onAddComment:d,onSendToAI:g,onSearch:h,isChatLoading:i}){let[j,k]=(0,f.useState)(0),l=(0,f.useMemo)(()=>a.current,[j]);return(0,e.jsx)(w.w,{x:l?.x??0,y:l?.y??0,visible:!!l,container:c,onAddComment:d,onSendToAI:g,onSearch:h,isChatLoading:i})});function A({oldContent:a,newContent:b,filePath:c,isNew:d=!1,isDeleted:w=!1,cwd:y,enableComments:B=!1,onPreview:D,previewLabel:E,onContentSearch:F,targetLine:G,compact:H=!1,symbols:I}){let{t:J}=(0,h.Bd)(),K=E??J("common.preview"),L=(0,f.useMemo)(()=>(0,q.X)(a,b),[a,b]),M=(0,f.useRef)(null),N=(0,f.useRef)(null),O=(0,f.useRef)(null);(0,f.useRef)(!1);let[P,Q]=(0,f.useState)(!1),R=(0,n.iN)(),S=(0,o.nH)(),T=B&&!!y,{comments:U,addComment:V,updateComment:W,deleteComment:X,refresh:Y}=(0,l._)({cwd:y||"",filePath:c}),[Z,$]=(0,f.useState)(null),_=(0,f.useRef)(null),aa=(0,f.useRef)(()=>{}),[ab,ac]=(0,f.useState)(null),[ad,ae]=(0,f.useState)(null),af=(0,f.useMemo)(()=>{let a=new Set;for(let b of U)for(let c=b.startLine;c<=b.endLine;c++)a.add(c);return a},[U]),ag=(0,f.useMemo)(()=>{let a=new Map;for(let b of U){let c=b.endLine;a.has(c)||a.set(c,[]),a.get(c).push(b)}return a},[U]),ah=(0,f.useCallback)((a,b)=>{b.stopPropagation(),$({comment:a,x:b.clientX,y:b.clientY}),_.current=null,aa.current(),ac(null),ae(null)},[]),ai=(0,f.useCallback)(()=>{let a=_.current;a&&(ac({x:a.x,y:a.y,range:a.range,codeContent:a.codeContent}),_.current=null,aa.current())},[]),aj=(0,f.useCallback)(()=>{let a=_.current;a&&(ae({x:a.x,y:a.y,range:a.range,codeContent:a.codeContent}),_.current=null,aa.current())},[]),ak=(0,f.useCallback)(()=>{let a=_.current;if(!a||!F)return;let b=a.codeContent.trim();_.current=null,aa.current(),b&&F(b)},[F]),al=(0,f.useCallback)(async a=>{if(ad&&S&&y)try{let b=await (0,m.$3)(y),d=[];for(let a of b)d.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});d.push({filePath:c,startLine:ad.range.start,endLine:ad.range.end,codeContent:ad.codeContent});let e=(0,m.Gw)(d,a);S.sendMessage(e),await (0,m.RP)(y),Y(),ae(null)}catch(a){console.error("Failed to send to AI:",a)}},[ad,S,c,y,Y]),am=(0,f.useCallback)(async a=>{ab&&(await V(ab.range.start,ab.range.end,a),ac(null))},[ab,V]),{leftLines:an,rightLines:ao}=(0,f.useMemo)(()=>{let a=[],b=[],c=0,d=0;for(let e=0;e<L.length;e++){let f=L[e];if("unchanged"===f.type){for(;a.length<b.length;)a.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;b.length<a.length;)b.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});c++,d++,a.push({lineNum:c,content:f.content,type:"unchanged",originalIdx:e}),b.push({lineNum:d,content:f.content,type:"unchanged",originalIdx:e})}else"removed"===f.type?(c++,a.push({lineNum:c,content:f.content,type:"removed",originalIdx:e})):"added"===f.type&&(d++,b.push({lineNum:d,content:f.content,type:"added",originalIdx:e}))}for(;a.length<b.length;)a.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;b.length<a.length;)b.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});return{leftLines:a,rightLines:b}},[L]),ap=(0,f.useMemo)(()=>L.map(a=>a.content),[L]),aq=(0,t.C)(ap,c),[ar,as]=(0,f.useState)(()=>new Map),at=(0,f.useMemo)(()=>I??[],[I]),{rows:au,gaps:av}=(0,f.useMemo)(()=>H?(0,r.pU)(an,ao,ar,at):{rows:an.map((a,b)=>({kind:"diff",idx:b})),gaps:[]},[H,an,an,ao,ar,at]),aw=(0,f.useRef)(null),ax=(0,f.useCallback)((a,b)=>{let c=M.current,d=c?.querySelector(`[data-gap-id="${a}"]`),e=d?.getBoundingClientRect().top??null,f=av.find(b=>b.id===a),g=f?f.endIdx+1:-1,h=g>=0?c?.querySelector(`[data-row-idx="${g}"]`):null,i=h?.getBoundingClientRect().top??null,j=!1;as(c=>{if(!f)return c;let d=c.get(a)??{topRevealed:0,bottomRevealed:0},e=f.endIdx-f.startIdx+1-d.topRevealed-d.bottomRevealed;if(e<=0)return c;let g=Math.min(r.YO,e),h="up"===b?{...d,topRevealed:d.topRevealed+g}:{...d,bottomRevealed:d.bottomRevealed+g};return j=!0,new Map(c).set(a,h)}),j&&null!==e&&(aw.current={gapId:a,oldViewportY:e,fallbackVisualIdx:g,fallbackOldViewportY:i})},[av]);(0,f.useCallback)(a=>{for(let b of av)if(a>=b.startIdx&&a<=b.endIdx)return b.id;return null},[av]);let ay=(0,f.useCallback)(a=>au[a]?.kind==="gap"?28:20,[au]),az=(0,i.Te)({count:au.length,getScrollElement:()=>M.current,estimateSize:ay,overscan:20}),aA=d?"w-1/4":w?"w-3/4":"w-1/2",aB=d?"w-3/4":w?"w-1/4":"w-1/2",aC=(0,f.useMemo)(()=>au.map(a=>{if("gap"===a.kind)return{type:"unchanged"};let b=an[a.idx],c=ao[a.idx];return"removed"===b.type?{type:"removed"}:c?.type==="added"?{type:"added"}:{type:"unchanged"}}),[au,an,ao]),aD=az.getTotalSize(),aE=az.getVirtualItems();return(0,e.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(0,e.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,e.jsx)("div",{className:`${aA} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:d?"(New File)":w?"Deleted":"Old"}),(0,e.jsxs)("div",{className:`${aB} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,e.jsx)("span",{className:"block text-center",children:w?"(Deleted)":"New"}),(0,e.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[D&&(0,e.jsx)("button",{onClick:D,className:"text-muted-foreground hover:text-foreground transition-colors",children:K}),!w&&b&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(b),(0,s.oR)(J("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:J("common.copy")})]})]}),(0,e.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,e.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,e.jsx)("div",{ref:M,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,e.jsxs)("div",{className:"flex",style:{height:`${aD}px`},children:[(0,e.jsx)("div",{ref:N,className:`${aA} overflow-x-auto border-r border-border`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:aE.map(a=>{let b=au[a.index];if("gap"===b.kind)return(0,e.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${a.size}px`,transform:`translateY(${a.start}px)`},className:"bg-accent border-y border-border"},a.key);let c=an[b.idx];return(0,e.jsxs)("div",{"data-row-idx":b.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${a.size}px`,transform:`translateY(${a.start}px)`},className:`flex ${"removed"===c.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:c.lineNum||""}),(0,e.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:c.originalIdx>=0&&aq[c.originalIdx]||(0,u.ZD)(c.content||" ")}})]},a.key)})})}),(0,e.jsx)("div",{ref:O,className:`${aB} overflow-x-auto`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:aE.map(a=>{let b=au[a.index];if("gap"===b.kind)return(0,e.jsxs)("div",{"data-gap-id":b.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${a.size}px`,transform:`translateY(${a.start}px)`},className:"flex items-center justify-center gap-3 text-[11px] text-muted-foreground bg-accent border-y border-border min-w-0",children:[(0,e.jsx)("button",{type:"button",disabled:!b.canExpandUp,onClick:()=>ax(b.gapId,"up"),className:"flex-shrink-0 flex items-center justify-center w-7 h-5 rounded text-foreground/80 hover:bg-secondary hover:text-brand active:bg-brand/15 active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:text-foreground/80 disabled:active:scale-100 disabled:active:bg-transparent transition-all",title:J("diffViewer.gap.expandUp",{count:r.YO}),"aria-label":J("diffViewer.gap.expandUp",{count:r.YO}),children:(0,e.jsx)(j.A,{className:"w-4 h-4"})}),(0,e.jsx)("span",{className:"opacity-80 select-none flex-shrink-0",children:J("diffViewer.gap.hidden",{count:b.hiddenCount})}),b.enclosingFn&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"opacity-50 select-none flex-shrink-0",children:"\xb7"}),(0,e.jsx)("span",{className:"opacity-90 truncate min-w-0 font-medium",title:z(b.enclosingFn),children:z(b.enclosingFn)})]}),(0,e.jsx)("button",{type:"button",disabled:!b.canExpandDown,onClick:()=>ax(b.gapId,"down"),className:"flex-shrink-0 flex items-center justify-center w-7 h-5 rounded text-foreground/80 hover:bg-secondary hover:text-brand active:bg-brand/15 active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:text-foreground/80 disabled:active:scale-100 disabled:active:bg-transparent transition-all",title:J("diffViewer.gap.expandDown",{count:r.YO}),"aria-label":J("diffViewer.gap.expandDown",{count:r.YO}),children:(0,e.jsx)(k.A,{className:"w-4 h-4"})})]},a.key);let c=ao[b.idx],d=c?.lineNum||0,f=d>0&&af.has(d),g=ag.get(d),h=g?.[0],i=ab&&d>=ab.range.start&&d<=ab.range.end,l=ad&&d>=ad.range.start&&d<=ad.range.end,m=i||l;return(0,e.jsxs)("div",{"data-new-line":d||void 0,"data-row-idx":b.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${a.size}px`,transform:`translateY(${a.start}px)`},className:`flex ${m?"bg-blue-9/20":f?"bg-amber-9/10":c?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,e.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-slate-9 select-none border-r border-border ${m?"bg-blue-9/30":""}`,style:{width:T?"52px":"40px"},children:[T&&d>0&&f&&h&&(0,e.jsx)("button",{onClick:a=>ah(h,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:J("codeViewer.nComments",{count:g?.length}),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.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"})})}),T&&d>0&&!f&&(0,e.jsx)("span",{className:"w-4"}),(0,e.jsx)("span",{className:"flex-1 text-right pr-1",children:d||""})]}),(0,e.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:c?.originalIdx>=0&&aq[c.originalIdx]||(0,u.ZD)(c?.content||" ")}})]},a.key)})})})]})}),(0,e.jsx)(v.b,{lines:aC,containerRef:M})]}),P&&R&&(0,g.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(C,{floatingToolbarRef:_,bumpRef:aa,container:R,onAddComment:ai,onSendToAI:aj,onSearch:F?ak:void 0,isChatLoading:S?.isLoading??!1}),ab&&(0,e.jsx)(p.t,{x:ab.x,y:ab.y,range:ab.range,codeContent:ab.codeContent,container:R,onSubmit:am,onClose:()=>ac(null)}),ad&&(0,e.jsx)(p.G,{x:ad.x,y:ad.y,range:ad.range,container:R,onSubmit:al,onClose:()=>ae(null)}),Z&&(0,e.jsx)(x.t,{x:Z.x,y:Z.y,comment:Z.comment,container:R,onClose:()=>$(null),onUpdateComment:W,onDeleteComment:X})]}),R)]})}function B({oldContent:a,newContent:b,filePath:c}){let d=(0,f.useMemo)(()=>(0,q.X)(a,b),[a,b]),g=(0,f.useRef)(null),h=(0,f.useMemo)(()=>d.map(a=>a.content),[d]),j=(0,t.C)(h,c),k=(0,i.Te)({count:d.length,getScrollElement:()=>g.current,estimateSize:()=>20,overscan:20});return(0,e.jsx)("div",{ref:g,className:"font-mono text-sm overflow-auto h-full",children:(0,e.jsx)("div",{style:{height:`${k.getTotalSize()}px`,position:"relative"},children:k.getVirtualItems().map(a=>{let b=d[a.index];return(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${a.size}px`,transform:`translateY(${a.start}px)`},className:`flex ${"removed"===b.type?"bg-red-9/15 dark:bg-red-9/25":"added"===b.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"added"!==b.type?b.oldLineNum:""}),(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"removed"!==b.type?b.newLineNum:""}),(0,e.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===b.type?"text-red-11":"added"===b.type?"text-green-11":"text-slate-9"}`,children:"removed"===b.type?"-":"added"===b.type?"+":" "}),(0,e.jsx)("span",{className:"flex-1 whitespace-pre pl-1",dangerouslySetInnerHTML:{__html:j[a.index]||(0,u.ZD)(b.content||" ")}})]},a.key)})})})}d()}catch(a){d(a)}})},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},86753:(a,b,c)=>{"use strict";c.d(b,{e:()=>h});var d=c(67484),e=c(95836),f=c(81749),g=c(41564);function h({cwd:a,addToRecentFiles:b}){let[c,i]=(0,d.useState)(null),[j,k]=(0,d.useState)(!1),[l,m]=(0,d.useState)(null),[n,o]=(0,d.useState)(null),[p,q]=(0,d.useState)(null),[r,s]=(0,d.useState)(!1),[t,u]=(0,d.useState)(new Set),[v,w]=(0,d.useState)([]),[x,y]=(0,d.useState)([]),z=(0,d.useMemo)(()=>{let a=new Set([...(0,e.Sz)(v),...(0,e.Sz)(x)]);for(let b of t)a.delete(b);return a},[v,x,t]),[A,B]=(0,d.useState)(!1),[C,D]=(0,d.useState)(0),E=(0,d.useCallback)(async()=>{k(!0),m(null);try{let b=`/api/git/status?cwd=${encodeURIComponent(a)}`,c=await fetch(b);if(!c.ok){let a=await c.json();throw Error(a.error||"Failed to fetch git status")}let d=await c.json();i(d);let f=(0,e.Do)(d.staged),g=(0,e.Do)(d.unstaged);w(f),y(g)}catch(a){m(a instanceof Error?a.message:"Unknown error")}finally{k(!1)}},[a]),F=(0,d.useCallback)(a=>{u(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),G=(0,d.useCallback)((a,c)=>{o({file:a,type:c}),b(a.path)},[b]),H=(0,d.useCallback)(async b=>{try{if(!(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:[b]})})).ok)throw Error("Failed to stage file");await E(),(0,f.oR)(g.A.t("toast.staged"),"success")}catch(a){console.error("Error staging file:",a),(0,f.oR)(g.A.t("toast.stageFailed"),"error")}},[a,E]),I=(0,d.useCallback)(async b=>{try{if(!(await fetch("/api/git/unstage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:[b]})})).ok)throw Error("Failed to unstage file");await E(),(0,f.oR)(g.A.t("toast.unstaged"),"success")}catch(a){console.error("Error unstaging file:",a),(0,f.oR)(g.A.t("toast.unstageFailed"),"error")}},[a,E]),J=(0,d.useCallback)(async b=>{if(0!==b.length)try{if(!(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:b})})).ok)throw Error("Failed to stage files");await E(),(0,f.oR)(g.A.t("toast.stagedNFiles",{count:b.length}),"success")}catch(a){console.error("Error staging files:",a),(0,f.oR)(g.A.t("toast.stageFailed"),"error")}},[a,E]),K=(0,d.useCallback)(async b=>{if(0!==b.length)try{if(!(await fetch("/api/git/unstage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:b})})).ok)throw Error("Failed to unstage files");await E(),(0,f.oR)(g.A.t("toast.unstagedNFiles",{count:b.length}),"success")}catch(a){console.error("Error unstaging files:",a),(0,f.oR)(g.A.t("toast.unstageFailed"),"error")}},[a,E]),L=(0,d.useCallback)(async b=>{if(0!==b.length)try{let c=b.filter(a=>"untracked"===a.status).map(a=>a.path),d=b.filter(a=>"untracked"!==a.status).map(a=>a.path);if(c.length>0&&!(await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:c,isUntracked:!0})})).ok)throw Error("Failed to discard untracked files");if(d.length>0&&!(await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:d,isUntracked:!1})})).ok)throw Error("Failed to discard tracked files");await E(),(0,f.oR)(g.A.t("toast.discardedNFiles",{count:b.length}),"success")}catch(a){console.error("Error discarding files:",a),(0,f.oR)(g.A.t("toast.discardFailed"),"error")}},[a,E]),M=(0,d.useCallback)(async()=>{if(c?.unstaged.length)try{if(!(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:c.unstaged.map(a=>a.path)})})).ok)throw Error("Failed to stage all files");await E(),(0,f.oR)(g.A.t("toast.stagedNFiles",{count:c.unstaged.length}),"success")}catch(a){console.error("Error staging all files:",a),(0,f.oR)(g.A.t("toast.stageFailed"),"error")}},[a,c,E]),N=(0,d.useCallback)(async()=>{if(c?.staged.length)try{if(!(await fetch("/api/git/unstage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:c.staged.map(a=>a.path)})})).ok)throw Error("Failed to unstage all files");await E(),(0,f.oR)(g.A.t("toast.unstagedNFiles",{count:c.staged.length}),"success")}catch(a){console.error("Error unstaging all files:",a),(0,f.oR)(g.A.t("toast.unstageFailed"),"error")}},[a,c,E]),O=(0,d.useCallback)(async b=>{try{let c="untracked"===b.status;if(!(await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:[b.path],isUntracked:c})})).ok)throw Error("Failed to discard file");await E(),(0,f.oR)(c?g.A.t("toast.deletedFile"):g.A.t("toast.discardedChanges"),"success")}catch(a){console.error("Error discarding file:",a),(0,f.oR)(g.A.t("toast.discardFailed"),"error")}},[a,E]),P=(0,d.useCallback)(async()=>{if(c?.unstaged.length&&await (0,f.lJ)(g.A.t("git.discardAllConfirm",{count:c.unstaged.length}),{danger:!0}))try{let b=c.unstaged.filter(a=>"untracked"===a.status).map(a=>a.path),d=c.unstaged.filter(a=>"untracked"!==a.status).map(a=>a.path);d.length>0&&await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:d,isUntracked:!1})}),b.length>0&&await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,files:b,isUntracked:!0})}),await E(),(0,f.oR)(g.A.t("toast.discardedNFiles",{count:c.unstaged.length}),"success")}catch(a){console.error("Error discarding all:",a),(0,f.oR)(g.A.t("toast.discardFailed"),"error")}},[a,c,E]);return{status:c,setStatus:i,statusLoading:j,statusError:l,statusSelectedFile:n,statusDiff:p,statusDiffLoading:r,statusExpandedPaths:z,stagedTree:v,setStagedTree:w,unstagedTree:x,setUnstagedTree:y,showStatusDiffPreview:A,setShowStatusDiffPreview:B,fetchStatus:E,handleStatusToggle:F,handleStatusFileSelect:G,handleStage:H,handleUnstage:I,handleStageFiles:J,handleUnstageFiles:K,handleDiscardFiles:L,handleStageAll:M,handleUnstageAll:N,handleDiscardFile:O,handleDiscardAll:P,refreshDiff:(0,d.useCallback)(()=>D(a=>a+1),[])}}},86791:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(92951),i=c(81749),j=a([h]);h=(j.then?(await j)():j)[0];let l={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D"};function k({toolCall:a,cwd:b}){let c,{t:d}=(0,g.Bd)(),[j,m]=(0,f.useState)(!1),[n,o]=(0,f.useState)(null),p=l[a.name]||"\uD83D\uDD27",q=(c=a.input,"Bash"===a.name&&c.command&&"string"==typeof c.command?c.command:"Glob"===a.name&&c.pattern&&"string"==typeof c.pattern||"Grep"===a.name&&c.pattern&&"string"==typeof c.pattern?c.pattern:c.file_path&&"string"==typeof c.file_path?c.file_path:c.path&&"string"==typeof c.path?c.path:null),r="Glob"===a.name||"Grep"===a.name||"Bash"===a.name,s=q?r?q:(a=>{if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}let c=a.split("/");return c.length>2?".../"+c.slice(-2).join("/"):a})(q):null,t=b=>{let c="input"===b?d("toolCall.inputParams"):d("toolCall.resultLabel"),e="input"===b?JSON.stringify(a.input,null,2):"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2);o({title:`${a.name}${s?` ${s}`:""} - ${c}`,content:e,toolName:a.name})};return(0,e.jsxs)("div",{className:"my-2 border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,e.jsxs)("button",{onClick:()=>m(!j),className:"w-full px-3 py-2 flex items-center gap-2 text-left hover:bg-accent transition-colors",children:[(0,e.jsx)("span",{className:"text-base",children:p}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:a.name}),s&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:q||"",children:s}),(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),q&&(navigator.clipboard.writeText(q),(0,i.oR)(d("common.copiedPath")))},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),q&&(navigator.clipboard.writeText(q),(0,i.oR)(d("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0 cursor-pointer",title:d("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[j&&!a.isLoading&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),t("input")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),t("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:d("toolCall.inputParamsTitle"),children:d("toolCall.input")}),a.result&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),t("result")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),t("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:d("toolCall.resultTitle"),children:d("toolCall.result")})]}),a.isLoading?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("span",{className:"text-slate-9 text-xs",children:j?"▲":"▼"})]})]}),j&&(0,e.jsxs)("div",{className:"border-t border-border",children:[(0,e.jsxs)("div",{className:"px-3 py-2",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d("toolCall.inputParams"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(a.input,null,2)})]}),a.result&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-border",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d("toolCall.resultLabel"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2)})]})]}),n&&(0,e.jsx)(h.M,{title:n.title,content:n.content,toolName:n.toolName,onClose:()=>o(null)})]})}d()}catch(a){d(a)}})},87099:(a,b,c)=>{"use strict";c.d(b,{mp:()=>j,nb:()=>k});var d=c(48249),e=c(44384);let f=(0,c(47408).A)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);var g=c(46674),h=c(69005),i=c(7084);function j({entries:a,onSelect:b,onClear:c}){let{t:k}=(0,e.Bd)();return(0,d.jsxs)("div",{className:"w-56 flex-shrink-0 bg-card border-l border-border flex flex-col","data-testid":"function-history-drawer",children:[(0,d.jsxs)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border flex items-center justify-between gap-1",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground font-mono min-w-0",children:[(0,d.jsx)(f,{className:"w-3 h-3 flex-shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:0===a.length?k("blockViewer.history.title"):`${k("blockViewer.history.title")} \xb7 ${a.length}/15`})]}),a.length>0&&(0,d.jsx)(h.m,{content:k("blockViewer.history.clear"),children:(0,d.jsx)("button",{onClick:c,className:"flex-shrink-0 text-muted-foreground hover:text-foreground p-0.5 rounded hover:bg-secondary",children:(0,d.jsx)(g.A,{className:"w-3 h-3"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===a.length?(0,d.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:k("blockViewer.history.empty")}):a.map((a,c)=>{var e;let f;return(0,d.jsx)(h.m,{content:`${a.qname} \xb7 ${a.filePath}`,children:(0,d.jsxs)("button",{onClick:()=>b(a),className:"w-full text-left px-2 py-1.5 border-b border-border/50 hover:bg-secondary/60 transition-colors group flex items-start gap-1.5",children:[(0,d.jsx)(i.y,{kind:a.kind??"unknown",qname:a.qname,className:"w-3 h-3 mt-0.5 flex-shrink-0"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-xs font-mono font-medium truncate",children:a.name}),(0,d.jsxs)("div",{className:"text-[10px] text-muted-foreground/70 truncate",children:[(f=(e=a.filePath).lastIndexOf("/"))>=0?e.slice(f+1):e,a.kind&&(0,d.jsxs)("span",{className:"ml-1 opacity-60",children:["\xb7 ",a.kind]})]})]})]})},`${a.filePath}::${a.qname}::${c}`)})})]})}function k(a,b){let c=a.filter(a=>a.filePath!==b.filePath||a.qname!==b.qname),d=[b,...c];return d.length>15?d.slice(0,15):d}},89261:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{r:()=>j});var e=c(48249),f=c(67484),g=c(92188),h=c(75648),i=a([g,h]);function j({cwd:a,filePath:b,oldContent:c,newContent:d,isNew:h=!1,isDeleted:i=!1,changedFiles:k,fileGitStatusMap:l,enableComments:m=!1,onContentSearch:n,headerExtraLeft:o,headerExtraRight:p}){let[q,r]=(0,f.useState)(b),[s,t]=(0,f.useState)(null);return(0,e.jsx)(g.O,{cwd:a,highlightedFilePath:b,changedFiles:k,enableComments:m,qnameFilter:s?.changedQnames,qnameFilterFile:q,accentQnames:s?.changedQnames,accentFile:q,addedLines:s?.addedLines,addedLinesFile:q,onFocalChange:a=>a&&r(a),onContentSearch:n,headerExtraLeft:o,headerExtraRight:p})}[g,h]=i.then?(await i)():i,d()}catch(a){d(a)}})},89976:(a,b,c)=>{"use strict";c.d(b,{b:()=>f});var d=c(48249),e=c(67484);function f({lines:a,containerRef:b}){let c=(0,e.useRef)(null),[g,h]=(0,e.useState)({top:0,height:0});if(0===a.length)return null;let i=100/a.length;return(0,d.jsxs)("div",{ref:c,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:a=>{let d=b.current,e=c.current;if(!d||!e)return;let f=e.getBoundingClientRect(),g=(a.clientY-f.top)/f.height*d.scrollHeight-d.clientHeight/2;d.scrollTo({top:Math.max(0,g),behavior:"smooth"})},children:[a.map((a,b)=>"unchanged"!==a.type&&(0,d.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===a.type?"bg-red-9":"bg-green-9"}`,style:{top:`${b*i}%`,height:`${Math.max(i,.5)}%`,minHeight:"2px"}},b)),(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${g.top}px`,height:`${Math.max(g.height,10)}px`}})]})}},92050:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{X:()=>i});var e=c(48249),f=c(67484),g=c(24266),h=a([g]);function i({tabId:a,cwd:b,sessionId:c,engine:d,ollamaModel:h,onOllamaModelChange:j,deepseekModel:k,onDeepseekModelChange:l,isActive:m,onStateChange:n,onShowGitStatus:o,onOpenNote:p,onCreateScheduledTask:q,onOpenSession:r,onContentSearch:s}){let t=(0,f.useCallback)(b=>{n(a,{isLoading:b})},[a,n]),u=(0,f.useCallback)(b=>{n(a,{sessionId:b})},[a,n]),v=(0,f.useCallback)(b=>{n(a,{title:b})},[a,n]),w=(0,f.useCallback)(b=>{j?.(a,b)},[a,j]),x=(0,f.useCallback)(b=>{l?.(a,b)},[a,l]);return(0,e.jsx)(g.r,{tabId:a,initialCwd:b,initialSessionId:c,engine:d,ollamaModel:h,onOllamaModelChange:w,deepseekModel:k,onDeepseekModelChange:x,hideHeader:!0,hideSidebar:!0,isActive:m,onLoadingChange:t,onSessionIdChange:u,onTitleChange:v,onShowGitStatus:o,onOpenNote:p,onCreateScheduledTask:q,onOpenSession:r,onContentSearch:s})}g=(h.then?(await h)():h)[0],d()}catch(a){d(a)}})},92154:(a,b,c)=>{"use strict";c.d(b,{R8:()=>i,c0:()=>k,fY:()=>j,gT:()=>l});var d=c(48249),e=c(67484);let f=["agent","explorer","console"],g={agent:"AGENT",explorer:"EXPLORER",console:"CONSOLE"},h=(0,e.createContext)(null);function i(){let a=(0,e.useContext)(h);if(!a)throw Error("useSwipeContext must be used within SwipeableViewContainer");return a}function j({activeView:a,onViewChange:b,children:c}){(0,e.useRef)(null),(0,e.useRef)(!1),(0,e.useRef)(0);let[g,i]=(0,e.useState)(0),[k,l]=(0,e.useState)(!1);f.indexOf(a),f.length;let[m,n]=(0,e.useState)(!1),o={activeView:a,onViewChange:b,dragOffset:(()=>{if(!m)return 0;let a=window.innerWidth;return a?g/a:0})(),isDragging:m&&k};return(0,d.jsx)(h.Provider,{value:o,children:c})}function k({children:a}){let b,c,{activeView:g,dragOffset:h,isDragging:j}=i(),l=(0,e.useRef)(null),m=(0,e.useRef)(null),n=f.indexOf(g),o=f.length;return(0,d.jsx)("div",{ref:l,className:"flex-1 overflow-hidden relative",style:{overscrollBehaviorX:"none"},children:(0,d.jsx)("div",{ref:m,className:j?"flex":"flex transition-transform duration-100 ease-out",style:{position:"absolute",top:"0px",bottom:"0px",left:"0px",width:`${100*f.length}%`,transform:(b=h/o*100,c=-(100/o*n)+(Number.isFinite(b)?b:0),`translateX(${c}%)`)},children:a})})}function l(){let{activeView:a,onViewChange:b,dragOffset:c,isDragging:h}=i(),j=(0,e.useRef)(null),k=(0,e.useRef)([]),[l,m]=(0,e.useState)({left:0,width:0}),n=f.indexOf(a),o=Number.isFinite(c)?c:0,p=Math.round(Math.max(0,Math.min(f.length-1,n-o)));return(0,d.jsxs)("div",{ref:j,className:"relative flex gap-4",children:[f.map((a,c)=>(0,d.jsx)("button",{ref:a=>{k.current[c]=a},onClick:()=>b(a),className:`px-4 py-1 text-sm font-medium transition-colors ${p===c?"text-brand":"text-muted-foreground hover:text-foreground"}`,children:g[a]},a)),(0,d.jsx)("div",{className:`absolute bottom-0 h-0.5 bg-brand ${h?"":"transition-all duration-100 ease-out"}`,style:{left:l.left,width:l.width}})]})}},92188:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{O:()=>K});var e=c(48249),f=c(67484),g=c(44384),h=c(10316),i=c(46674),j=c(80600),k=c(69924),l=c(7084),m=c(2531),n=c(77033),o=c(47033),p=c(23434),q=c(3532),r=c(5811),s=c(87099),t=c(96732),u=c(7418),v=c(67093),w=c(6154),x=c(77937),y=c(45214),z=c(68502),A=a([r]);function B(a){let b=a.lastIndexOf("/");return b>=0?a.slice(b+1):a}function C({symbol:a,fileSource:b,hasChange:c,onHighlighted:d,comments:g,onCommentClick:h,addedLines:i}){let{resolvedTheme:j}=(0,q.D)();(0,f.useMemo)(()=>(0,r.sQ)(a.filePath),[a.filePath]);let[k,m]=(0,f.useState)(null),[n,o]=(0,f.useState)(null);return(0,e.jsxs)("div",{className:"flex-1 min-w-0 bg-card border border-border rounded overflow-hidden relative",children:[(0,e.jsxs)("div",{"data-block-header":!0,className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-border bg-secondary/40 text-xs",children:[(0,e.jsx)(l.y,{kind:a.kind,qname:a.qualifiedName,className:"w-3.5 h-3.5 flex-shrink-0"}),(0,e.jsxs)("span",{className:"font-mono truncate min-w-0",children:[(0,e.jsx)("span",{className:"font-medium",children:a.name}),void 0!==a.params&&(0,e.jsxs)("span",{className:"text-muted-foreground/80",children:["(",a.params.join(", "),")"]})]}),(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 flex-shrink-0",children:[a.kind," \xb7 L",a.startLine,"-",a.endLine]}),(0,e.jsx)("span",{className:"flex-1"}),c&&(0,e.jsx)("span",{className:"flex-shrink-0 w-2 h-2 rounded-full bg-amber-11","data-tooltip":"File has uncommitted change"})]}),(0,e.jsxs)("div",{"data-block-body":!0,className:"text-[11px] font-mono px-2 py-2 overflow-auto",style:{lineHeight:`${N}px`},children:[!b&&(0,e.jsx)("span",{className:"text-muted-foreground",children:"Loading…"}),n&&(0,e.jsx)("span",{className:"text-red-11",children:n}),k&&(0,e.jsx)("div",{dangerouslySetInnerHTML:{__html:k}})]}),g&&g.length>0&&h&&(0,e.jsx)(v._,{comments:g,startLine:a.startLine,endLine:a.endLine,lineHeight:N,bodyTopOffset:O+P,onCommentClick:h})]})}function D({side:a,pin:b,accent:c,onClick:d}){let f,g,h,i,j,k,l,m=b.lines.length;"ext"===b.kind?(f="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",g="ext",h="text-muted-foreground/60",i=b.name,j=b.packageSpec,k="external",l=b.packageSpec):"method"===b.kind?(f="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",g="method",h="text-muted-foreground/60",i=`${b.receiverName}.${b.methodName}`,j=null,k="method (unresolved)",l=m>0?`at line${m>1?"s":""} ${b.lines.join(", ")}`:""):"self"===b.kind?(f="bg-secondary/40 border-border hover:border-muted-foreground",g="self",h="text-muted-foreground/70",i=b.external.name,j=null,k="same-file",l=m>0?`at line${m>1?"s":""} ${b.lines.join(", ")}`:""):(f="in"===a?"bg-amber-9/15 border-amber-9/40 hover:border-amber-11":"bg-green-9/15 border-green-9/40 hover:border-green-11",g=a,h="in"===a?"text-amber-11":"text-green-11",i=b.external.name,j=B(b.external.filePath),k="in"===a?"caller":"callee",l=b.external.filePath);let n=c&&"ext"!==b.kind&&"method"!==b.kind?" ring-1 ring-amber-9/70 ring-offset-0":"";return(0,e.jsxs)("button",{onClick:a=>{a.stopPropagation(),d()},className:`${f}${n} w-full text-left border rounded px-1.5 py-0.5 text-[10px] font-mono cursor-pointer transition-colors flex items-center gap-1.5`,"data-tooltip":`${k}${l?" \xb7 "+l:""}`,children:[(0,e.jsx)("span",{className:`${h} text-[9px] uppercase tracking-wider font-semibold flex-shrink-0`,children:g}),(0,e.jsxs)("span",{className:"truncate flex-1 min-w-0",children:[(0,e.jsx)("span",{className:"font-medium",children:i}),j&&(0,e.jsx)("span",{className:"text-muted-foreground/70 ml-1",children:j}),m>1&&(0,e.jsxs)("span",{className:"text-muted-foreground/60 ml-1",children:["\xb7",m,"\xd7"]})]})]})}r=(A.then?(await A)():A)[0];let N=18,O=29,P=8;function E(a,b){switch(b.kind){case"cross":return`${a}:x:${b.external.filePath}::${b.external.qualifiedName}`;case"self":return`${a}:s:${b.external.filePath}::${b.external.qualifiedName}`;case"ext":return`${a}:e:${b.packageSpec}::${b.name}`;case"method":return`${a}:m:${b.receiverName}::${b.methodName}`}}function F(a,b){return"ext"!==a.kind&&"method"!==a.kind&&(b?.has(a.external.qualifiedName)??!1)}function G(a){return{filePath:a.filePath,qname:a.qualifiedName,name:a.name,kind:a.kind}}function H({symbol:a,fileSource:b,hasChange:c,upstream:d,downstream:f,onPinClick:g,onHighlighted:h,comments:i,onCommentClick:j,accentQnames:k,addedLines:l}){let m=function(a,b){if(0===a.length)return[];let c=a.map((a,c)=>{var d,e,f;return{i:c,line:(d=a.lines[0]??b.startLine,e=b.startLine,f=b.endLine,Math.max(e,Math.min(f,d)))}});c.sort((a,b)=>a.line-b.line||a.i-b.i);let d=Array(a.length).fill(0),e=-1/0;for(let{i:a,line:f}of c){let c=O+P+(f-b.startLine)*N,g=Math.max(c,e);d[a]=g,e=g+22}return d}(f,a);return(0,e.jsxs)("div",{"data-block-qname":a.qualifiedName,"data-start-line":a.startLine,"data-end-line":a.endLine,className:"flex gap-2 items-stretch scroll-mt-2",children:[(0,e.jsx)("div",{className:"w-44 flex-shrink-0 flex flex-col gap-1 pt-1",children:0===d.length?(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5",children:"no callers"}):d.map(b=>(0,e.jsx)(D,{side:"in",pin:b,accent:F(b,k),onClick:()=>g(b,a)},E("in",b)))}),(0,e.jsx)(C,{symbol:a,fileSource:b,hasChange:c,onHighlighted:h,comments:i,onCommentClick:j,addedLines:l}),(0,e.jsx)("div",{className:"w-44 flex-shrink-0 relative",children:0===f.length?(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5 pt-1",children:"no callees"}):f.map((b,c)=>(0,e.jsx)("div",{className:"absolute left-0 right-0",style:{top:`${m[c]}px`},children:(0,e.jsx)(D,{side:"out",pin:b,accent:F(b,k),onClick:()=>g(b,a)})},E("out",b)))})]})}function I({cwd:a,onSelect:b,onClose:c}){let{t:d}=(0,g.Bd)(),[j,k]=(0,f.useState)(""),[l,m]=(0,f.useState)({files:[],symbols:[]}),[n,o]=(0,f.useState)(0),[p,q]=(0,f.useState)(!1),r=(0,f.useMemo)(()=>[...l.files,...l.symbols],[l]),s=(0,f.useCallback)(a=>{if("Escape"===a.key)return void c();if(0!==r.length){if("ArrowDown"===a.key)a.preventDefault(),o(a=>Math.min(a+1,r.length-1));else if("ArrowUp"===a.key)a.preventDefault(),o(a=>Math.max(a-1,0));else if("Enter"===a.key){a.preventDefault();let c=r[n];c&&b(c)}}},[r,n,c,b]);return(0,e.jsx)("div",{className:"absolute inset-0 bg-background/40 z-20 flex items-start justify-center pt-24",onClick:c,children:(0,e.jsxs)("div",{className:"w-[480px] max-w-[80%] bg-card border border-border rounded shadow-2xl overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,e.jsx)(h.A,{className:"w-4 h-4 text-muted-foreground"}),(0,e.jsx)("input",{autoFocus:!0,value:j,onChange:a=>k(a.target.value),onKeyDown:s,placeholder:d("blockViewer.search.hint","Start typing to search"),className:"flex-1 bg-transparent border-0 outline-none text-sm"}),p&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"…"}),(0,e.jsx)("button",{onClick:c,className:"text-muted-foreground hover:text-foreground",children:(0,e.jsx)(i.A,{className:"w-3.5 h-3.5"})})]}),(0,e.jsxs)("div",{className:"max-h-96 overflow-y-auto",children:[0===r.length&&j&&!p&&(0,e.jsx)("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:d("blockViewer.search.noResults","No matches")}),(0,e.jsx)(J,{label:d("blockViewer.search.files","Files"),hits:l.files,startIdx:0,activeIdx:n,onSelect:b,setActive:o}),(0,e.jsx)(J,{label:d("blockViewer.search.symbols","Symbols"),hits:l.symbols,startIdx:l.files.length,activeIdx:n,onSelect:b,setActive:o})]})]})})}function J({label:a,hits:b,startIdx:c,activeIdx:d,onSelect:f,setActive:g}){return 0===b.length?null:(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-secondary/40",children:a}),b.map((a,b)=>{let h=c+b,i=h===d;return(0,e.jsxs)("button",{onMouseEnter:()=>g(h),onClick:()=>f(a),className:`w-full text-left px-3 py-1.5 text-xs flex items-start gap-2 ${i?"bg-secondary":"hover:bg-secondary/60"}`,children:["file"===a.target.kind?(0,e.jsx)(j.A,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-muted-foreground"}):(0,e.jsx)(l.y,{kind:a.target.symbolKind,qname:a.target.qualifiedName,className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),(0,e.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,e.jsx)("span",{className:"font-mono truncate",children:a.label}),a.hint&&(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground truncate",children:a.hint})]})]},`${a.type}:${a.label}:${b}`)})]})}function K({cwd:a,highlightedFilePath:b,changedFiles:c,onSwitchToCode:d,enableComments:h=!1,onContentSearch:i,onFocalChange:j,qnameFilter:k,qnameFilterFile:l,accentQnames:q,accentFile:r,addedLines:v,addedLinesFile:A,headerExtraLeft:C,headerExtraRight:D}){let{t:E}=(0,g.Bd)(),[F,J]=(0,f.useState)(null),N=F??b??null,{state:O,refresh:P}=(0,m.V)(a,N),[Q,R]=(0,f.useState)(null);(0,f.useRef)(null);let[S,T]=(0,f.useState)([]),[U,V]=(0,f.useState)(!1),[W,X]=(0,f.useState)(null),Y=(0,f.useRef)(0);(0,f.useRef)(0);let[Z,$]=(0,f.useState)(()=>new Set);"ready"===O.state&&O.data.filePath;let _=(0,f.useCallback)(a=>{$(b=>{if(b.has(a))return b;let c=new Set(b);return c.add(a),c})},[]),aa=(0,f.useCallback)((a,b)=>{if("ext"===a.kind||"method"===a.kind){let a=b.filePath;if(!a)return;Y.current+=1,X({filePath:a,qname:"__imports__",nonce:Y.current});return}let c=G(b),d=G(a.external);T(a=>(0,s.nb)((0,s.nb)(a,c),d)),J(d.filePath),Y.current+=1,X({filePath:d.filePath,qname:d.qname,nonce:Y.current})},[]),ab=(0,f.useCallback)(a=>{J(a.filePath),Y.current+=1,X({filePath:a.filePath,qname:a.qname,nonce:Y.current})},[]),ac=(0,f.useCallback)(a=>{V(!1),J(a.target.filePath),"symbol"===a.target.kind&&(Y.current+=1,X({filePath:a.target.filePath,qname:a.target.qualifiedName,line:a.target.line,nonce:Y.current}))},[]),ad=(0,f.useCallback)((a,b)=>{N&&(Y.current+=1,X({filePath:N,qname:a,line:b,nonce:Y.current}))},[N]),[ae,af]=(0,f.useState)(null),[ag,ah]=(0,f.useState)(null),ai=(0,f.useMemo)(()=>{if("ready"!==O.state||!ag)return null;let a=O.data.functions;if(0===a.length)return null;let b=(ag.start+ag.end)/2;for(let c of a)if(c.startLine<=b&&b<=c.endLine)return c.qualifiedName;let c=null;for(let b of a)b.startLine<=ag.start&&(!c||b.startLine>c.startLine)&&(c=b);return c?.qualifiedName??null},[O,ag]),aj=h&&!!a&&!!N,ak=(0,n.nH)(),{comments:al,addComment:am,updateComment:an,deleteComment:ao,refresh:ap}=(0,o._)({cwd:a,filePath:N??""}),[aq,ar]=(0,f.useState)(null),{toolbar:as,clearToolbar:at}=(0,u.r)({enabled:aj,container:aq}),[au,av]=(0,f.useState)(null),[aw,ax]=(0,f.useState)(null),[ay,az]=(0,f.useState)(null),aA=(0,f.useCallback)(()=>{as&&(av({x:as.x,y:as.y,range:as.range,codeContent:as.selectedText}),at())},[as,at]),aB=(0,f.useCallback)(()=>{as&&(ax({x:as.x,y:as.y,range:as.range,codeContent:as.selectedText}),at())},[as,at]),aC=(0,f.useCallback)(()=>{if(!as||!i)return;let a=as.selectedText.trim();at(),a&&i(a)},[as,i,at]),aD=(0,f.useCallback)(async a=>{au&&(await am(au.range.start,au.range.end,a,au.codeContent),av(null))},[au,am]),aE=(0,f.useCallback)(async b=>{if(aw&&ak&&a&&N)try{let c=(await (0,p.$3)(a)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0}));c.push({filePath:N,startLine:aw.range.start,endLine:aw.range.end,codeContent:aw.codeContent});let d=(0,p.Gw)(c,b);ak.sendMessage(d),await (0,p.RP)(a),ap(),ax(null)}catch(a){console.error("[BlockViewer] send to AI failed:",a)}},[aw,ak,a,N,ap]),aF=(0,f.useCallback)((a,b)=>{b.stopPropagation(),az({comment:a,x:b.clientX,y:b.clientY}),at(),av(null),ax(null)},[at]);if(!N)return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(M,{focalFile:null,fileCount:null,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,refreshDisabled:!0,extraLeft:C,extraRight:D}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-sm text-muted-foreground gap-2 px-4 text-center",children:[(0,e.jsx)("span",{children:E("blockViewer.empty.body","Select a file in the left tree to see its function call graph.")}),(0,e.jsx)("span",{className:"text-xs",children:E("blockViewer.empty.hint","or press ⌘K to search.")})]}),U&&(0,e.jsx)(I,{cwd:a,onSelect:ac,onClose:()=>V(!1)})]});if("idle"===O.state||"loading"===O.state)return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(M,{focalFile:N,fileCount:null,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,refreshDisabled:!0,extraLeft:C,extraRight:D}),(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:E("blockViewer.fileMode.loading","Loading…")})]});if("notFound"===O.state)return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(M,{focalFile:N,fileCount:null,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,extraLeft:C,extraRight:D}),(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground px-4 text-center",children:E("blockViewer.fileMode.notFound","This file is not indexed (unsupported language or beyond the file cap).")}),U&&(0,e.jsx)(I,{cwd:a,onSelect:ac,onClose:()=>V(!1)})]});if("error"===O.state)return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(M,{focalFile:N,fileCount:null,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,extraLeft:C,extraRight:D}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-sm",children:[(0,e.jsx)("span",{className:"text-red-11",children:O.message}),(0,e.jsx)("button",{onClick:P,className:"px-3 py-1 rounded bg-secondary hover:bg-secondary/80",children:E("blockViewer.retry","Retry")})]})]});let aG=O.data,aH=aG.functions;if(0===aH.length&&Q){let a=Math.max(1,Q.content.split("\n").length);aH=[{filePath:aG.filePath,qualifiedName:"__file__",name:B(aG.filePath),kind:"unknown",startLine:1,endLine:a}]}let aI=l&&l===aG.filePath,aJ=r&&r===aG.filePath,aK=A&&A===aG.filePath;aI&&k&&(aH=aH.filter(a=>k.has(a.qualifiedName)));let aL=aJ?q:void 0,aM=aK?v:void 0,aN=L(aG.upstreamCalls),aO=L(aG.downstreamCalls),aP=new Map(aH.map(a=>[a.qualifiedName,a])),aQ=new Map,aR=new Map;for(let a of aG.intraCalls){let b=aP.get(a.to),c=aP.get(a.from);if(b){let c=aQ.get(a.from),d={kind:"self",external:b,lines:a.lines};c?c.push(d):aQ.set(a.from,[d])}if(c){let b=aR.get(a.to),d={kind:"self",external:c,lines:a.lines};b?b.push(d):aR.set(a.to,[d])}}let aS=new Map;for(let a of aG.externalCalls??[]){let b=aS.get(a.focalQname),c={kind:"ext",name:a.external.name,packageSpec:a.external.packageSpec,lines:a.lines};b?b.push(c):aS.set(a.focalQname,[c])}let aT=new Map;for(let a of aG.methodCalls??[]){let b=aT.get(a.focalQname),c={kind:"method",receiverName:a.receiverName,methodName:a.methodName,lines:a.lines};b?b.push(c):aT.set(a.focalQname,[c])}let aU=c.has(aG.filePath);return(0,e.jsxs)("div",{className:"h-full flex flex-col relative",children:[(0,e.jsx)(M,{focalFile:N,fileCount:aG.fileCount,functionCount:aG.functions.length,upstreamCount:aG.upstreamCalls.length,downstreamCount:aG.downstreamCalls.length,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,extraLeft:C,extraRight:D}),(0,e.jsxs)("div",{ref:ar,className:"flex-1 relative min-h-0 flex",children:[(0,e.jsx)(t.g,{functions:aH,currentQname:ai,onSelect:ad}),(0,e.jsx)("div",{ref:af,className:"flex-1 min-w-0 overflow-auto",children:(0,e.jsx)("div",{className:"flex flex-col gap-3 p-3",children:aH.map(a=>{let b,c,d,f,g,h;return(0,e.jsx)(H,{symbol:a,fileSource:Q?.content??null,hasChange:aU,upstream:(b=aN.get(a.qualifiedName),c=aR.get(a.qualifiedName),[...(b??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...c??[]]),downstream:(d=aO.get(a.qualifiedName),f=aQ.get(a.qualifiedName),g=aT.get(a.qualifiedName),h=aS.get(a.qualifiedName),[...(d??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...f??[],...g??[],...h??[]]),onPinClick:aa,onHighlighted:_,comments:aj?al:void 0,onCommentClick:aj?aF:void 0,accentQnames:aL,addedLines:aM},a.qualifiedName)})})}),aj&&as&&aq&&(0,e.jsx)(x.w,{x:as.x,y:as.y,visible:!0,container:aq,onAddComment:aA,onSendToAI:aB,onSearch:i?aC:void 0,isChatLoading:ak?.isLoading}),aj&&au&&(0,e.jsx)(y.t,{x:au.x,y:au.y,range:au.range,codeContent:au.codeContent,container:aq,onSubmit:aD,onClose:()=>av(null)}),aj&&aw&&N&&(0,e.jsx)(y.G,{x:aw.x,y:aw.y,range:aw.range,filePath:N,codeContent:aw.codeContent,container:aq,onSubmit:aE,onClose:()=>ax(null),isChatLoading:ak?.isLoading}),aj&&ay&&(0,e.jsx)(z.t,{x:ay.x,y:ay.y,comment:ay.comment,container:aq,onClose:()=>az(null),onUpdateComment:an,onDeleteComment:ao}),aM&&aM.size>0&&aH.length>0&&(0,e.jsx)(w.e,{addedLines:aM,blockRanges:aH.map(a=>({qname:a.qualifiedName,startLine:a.startLine,endLine:a.endLine})),viewportRange:ag,onJumpToLine:ad}),(0,e.jsx)(s.mp,{entries:S,onSelect:ab,onClear:()=>T([])}),U&&(0,e.jsx)(I,{cwd:a,onSelect:ac,onClose:()=>V(!1)})]})]})}function L(a){let b=new Map;for(let c of a){let a=b.get(c.focalQname);if(!a){b.set(c.focalQname,[c]);continue}a.some(a=>a.external.filePath===c.external.filePath&&a.external.qualifiedName===c.external.qualifiedName)||a.push(c)}return b}function M({focalFile:a,fileCount:b,functionCount:c,upstreamCount:d,downstreamCount:f,onSwitchToCode:i,onSearch:j,onRefresh:l,refreshDisabled:m,extraLeft:n,extraRight:o}){let{t:p}=(0,g.Bd)(),q={focalFile:a,blockCount:c??0,upstreamCount:d??0,downstreamCount:f??0};return(0,e.jsxs)("div",{className:"flex-shrink-0 px-3 py-2 border-b border-border flex items-center justify-between bg-secondary/30 gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0 text-xs text-muted-foreground font-mono",children:[(0,e.jsx)("span",{className:"truncate min-w-0",children:a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-foreground",children:a}),"number"==typeof c&&(0,e.jsxs)("span",{className:"ml-2",children:["\xb7 ",c," blocks"]}),"number"==typeof d&&"number"==typeof f&&(0,e.jsxs)("span",{className:"ml-2",children:["\xb7 ",d," in \xb7 ",f," out"]})]}):(0,e.jsx)("span",{children:null!==b?`${b} files`:"…"})}),n&&(0,e.jsx)("span",{className:"flex items-center gap-1 flex-shrink-0",children:n(q)})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o&&(0,e.jsx)("span",{className:"flex items-center gap-1",children:o(q)}),(0,e.jsxs)("button",{onClick:j,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground flex items-center gap-1","data-tooltip":p("blockViewer.search.tooltip","Search (⌘K)"),children:[(0,e.jsx)(h.A,{className:"w-3 h-3"})," ⌘K"]}),(0,e.jsx)("button",{onClick:l,disabled:m,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:hover:bg-transparent","data-tooltip":p("blockViewer.refresh","Rebuild project graph"),children:(0,e.jsx)(k.A,{className:"w-3 h-3"})}),i&&(0,e.jsx)("button",{onClick:i,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground",children:"Code"})]})]})}d()}catch(a){d(a)}})},92951:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>u});var e=c(48249),f=c(67484),g=c(44384),h=c(31172),i=c(86402),j=c(79029),k=c(49280),l=c(30068),m=c(90500),n=c(81749),o=c(36645),p=c(23290),q=c(56929),r=a([i,j]);function s({filePath:a}){let[b,c]=(0,f.useState)(null),[d,g]=(0,f.useState)(!0),[h,i]=(0,f.useState)(null);(0,f.useRef)(!1);let k=(0,q.e$)(a);return((0,q.u)(a),h)?(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("div",{className:"text-xs text-red-11",children:h})}):d?(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):(0,q.u)(a)?(0,e.jsx)(p.I,{absPath:a,className:"flex items-center justify-center h-full overflow-auto",imgClassName:"max-w-full max-h-full object-contain",alt:a.split("/").pop()||"image"}):b?k?(0,e.jsx)(t,{content:b}):(0,e.jsx)(j.Cv,{content:b,filePath:a,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}[i,j]=r.then?(await r)():r;let v=[m.W];function t({content:a}){let b=(0,f.useRef)(null);return(0,e.jsxs)("div",{className:"h-full flex",children:[(0,e.jsx)(l.l,{content:a,containerRef:b}),(0,e.jsx)("div",{ref:b,className:"flex-1 overflow-auto p-4",children:(0,e.jsx)(k.T,{content:a,rehypePlugins:v})})]})}function u({title:a,content:b,toolName:c,onClose:d}){let{t:j}=(0,g.Bd)(),k=(0,q.jU)(b),l=(0,q.zs)(b),m=(0,q.oK)(b),p=!!l,r=!!m,[t,v]=(0,f.useState)(("Read"===c||"Write"===c)&&r?"file":p?"diff-unified":k?"readable":"json"),w=(0,f.useRef)(null),x=(0,o.o)(w),y=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:d,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col transition-all",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a}),m&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(m),(0,n.oR)(j("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:j("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsxs)("div",{className:"flex items-center gap-3",children:[k&&(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[p&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>v("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.sideBySide"),children:"Split"}),(0,e.jsx)("button",{onClick:()=>v("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.unified"),children:"Unified"})]}),r&&(0,e.jsx)("button",{onClick:()=>v("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.previewFile"),children:"File"}),(0,e.jsx)("button",{onClick:()=>v("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:j("common.readable")}),(0,e.jsx)("button",{onClick:()=>v("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,e.jsx)("button",{onClick:d,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"file"===t&&m?(0,e.jsx)(s,{filePath:m}):"diff-unified"===t&&l?(0,e.jsx)(i.xU,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"diff-split"===t&&l?(0,e.jsx)(i.xZ,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"readable"===t&&k?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o._,{search:x}),(0,e.jsx)("pre",{ref:w,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,q.xb)(b)})]}):(0,e.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:k?(0,q.C6)(b):b})})]})});return(0,e.jsx)(h.ZL,{children:y})}d()}catch(a){d(a)}})},93053:(a,b,c)=>{"use strict";c.d(b,{i:()=>f});var d=c(67484),e=c(6440);function f({initialCwd:a,initialSessionId:b,activeView:c}){(0,d.useRef)(!1),(0,d.useRef)(!0);let g=(0,d.useRef)(c),h=(0,e.F)(),i=(0,d.useRef)(h),[j,k]=(0,d.useState)(()=>[{id:`tab-${Date.now()}`,cwd:a,title:"New Chat"}]),[l,m]=(0,d.useState)(j[0].id),[n,o]=(0,d.useState)(new Set),p=(0,d.useRef)(j),q=(0,d.useCallback)((b,c)=>{a&&b&&fetch("/api/global-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,sessionId:b,status:c})}).catch(()=>{})},[a]),[r,s]=(0,d.useState)(null),[t,u]=(0,d.useState)(null),v=(0,d.useCallback)((a,b,c,d,e,f)=>{let g={id:`tab-${Date.now()}`,cwd:a,sessionId:b,title:c||(b?`Session ${b.slice(0,6)}...`:"New Chat"),engine:d,ollamaModel:e,deepseekModel:f};k(a=>{let b=a.findIndex(a=>a.id===l);if(-1===b)return[...a,g];let c=[...a];return c.splice(b+1,0,g),c}),m(g.id)},[l]),w=(0,d.useCallback)(b=>{k(c=>{let d=c.filter(a=>a.id!==b);if(b===l&&d.length>0&&m(d[d.length-1].id),0===d.length){let b={id:`tab-${Date.now()}`,cwd:a,title:"New Chat"};return m(b.id),[b]}return d})},[l,a]),x=(0,d.useCallback)((b,c)=>{let d=j.find(a=>a.sessionId===b);d?m(d.id):v(a,b,c)},[j,a,v]),y=(0,d.useCallback)(()=>{v(a)},[a,v]),z=(0,d.useCallback)(()=>{v(a,void 0,"New Claude 2 Chat","claude2")},[a,v]),A=(0,d.useCallback)(()=>{v(a,void 0,"New Codex Chat","codex")},[a,v]),B=(0,d.useCallback)(()=>{v(a,void 0,"New Kimi Chat","kimi")},[a,v]),C=(0,d.useCallback)(b=>{v(a,void 0,b?`New Ollama (${b})`:"New Ollama Chat","ollama",b)},[a,v]),D=(0,d.useCallback)((a,b)=>{k(c=>c.map(c=>c.id===a?{...c,ollamaModel:b}:c))},[]),E=(0,d.useCallback)(()=>{v(a,void 0,"New Deepseek Chat","deepseek",void 0,"deepseek-v4-flash")},[a,v]),F=(0,d.useCallback)((a,b)=>{k(c=>c.map(c=>c.id===a?{...c,deepseekModel:b}:c))},[]),G=(0,d.useCallback)((b,c)=>{v(a,b,c)},[a,v]),H=(0,d.useCallback)((a,b)=>{k(c=>{let d=c.find(b=>b.id===a);if(d?.isLoading&&!1===b.isLoading){let c=!g.current||"agent"===g.current;if(a===l&&c&&i.current){let a=d.sessionId||b.sessionId;a&&q(a,"normal")}else o(b=>new Set(b).add(a))}return c.map(c=>c.id===a?{...c,...b}:c)})},[l,q]),I=(0,d.useCallback)(a=>{m(a),o(b=>{if(!b.has(a))return b;let c=new Set(b);c.delete(a);let d=p.current.find(b=>b.id===a);return d?.sessionId&&(q(d.sessionId,"normal"),fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"markReadBySessionId",fields:{sessionId:d.sessionId}})}).catch(()=>{})),c})},[q]),J=(0,d.useCallback)(a=>{s(a)},[]),K=(0,d.useCallback)((a,b)=>{a.preventDefault(),null!==r&&r!==b&&u(b)},[r]),L=(0,d.useCallback)(a=>{null!==r&&r!==a&&k(b=>{let c=[...b],[d]=c.splice(r,1);return c.splice(a,0,d),c}),s(null),u(null)},[r]),M=(0,d.useCallback)(()=>{s(null),u(null)},[]),N=j.find(a=>a.id===l);return{tabs:j,activeTabId:l,activeTab:N,unreadTabs:n,dragTabIndex:r,dragOverTabIndex:t,addTab:v,closeTab:w,switchTab:I,handleSelectSession:x,handleNewTab:y,handleNewClaude2Tab:z,handleNewCodexTab:A,handleNewKimiTab:B,handleNewOllamaTab:C,handleNewDeepseekTab:E,handleOpenSession:G,updateTabState:H,updateTabOllamaModel:D,updateTabDeepseekModel:F,handleTabDragStart:J,handleTabDragOver:K,handleTabDrop:L,handleTabDragEnd:M}}},94924:(a,b,c)=>{"use strict";c.d(b,{Y:()=>k});var d=c(48249),e=c(67484),f=c(44384);let g=(0,c(47408).A)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);var h=c(46674),i=c(59347),j=c(24520);function k({onClose:a,onSave:b}){let{t:c}=(0,f.Bd)(),[l,m]=(0,e.useState)({}),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(!0);(0,e.useCallback)(async()=>{s(!0);try{let a=await fetch("/api/terminal/aliases");if(a.ok){let b=await a.json();m(b.aliases||{})}}catch(a){console.error("Failed to load aliases:",a)}finally{s(!1)}},[]);let t=()=>{n.trim()&&p.trim()&&(m(a=>({...a,[n.trim()]:p.trim()})),o(""),q(""))},u=async()=>{try{(await fetch("/api/terminal/aliases",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({aliases:l})})).ok&&(b(l),a())}catch(a){console.error("Failed to save aliases:",a)}};return(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,d.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,d.jsx)(g,{className:"w-5 h-5"}),c("aliasManager.title")]}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:c("aliasManager.description")})]}),(0,d.jsx)("button",{onClick:a,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,d.jsx)(h.A,{className:"w-5 h-5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:r?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:c("common.loading")}):(0,d.jsxs)("div",{className:"space-y-3",children:[Object.entries(l).map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-start gap-2 group",children:[(0,d.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,d.jsx)("input",{type:"text",value:a,disabled:!0,className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"})]}),(0,d.jsx)("input",{type:"text",value:b,onChange:b=>{var c;return c=b.target.value,void m(b=>({...b,[a]:c}))},placeholder:c("aliasManager.fullCommandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"})]}),(0,d.jsx)("button",{onClick:()=>{m(b=>{let c={...b};return delete c[a],c})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors opacity-0 group-hover:opacity-100",children:(0,d.jsx)(i.A,{className:"w-4 h-4"})})]},a)),(0,d.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,d.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,d.jsx)("input",{type:"text",value:n,onChange:a=>o(a.target.value),placeholder:c("aliasManager.aliasPlaceholder"),className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),t())}})]}),(0,d.jsx)("input",{type:"text",value:p,onChange:a=>q(a.target.value),placeholder:c("aliasManager.commandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),t())}})]}),(0,d.jsx)("button",{onClick:t,disabled:!n.trim()||!p.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,d.jsx)(j.A,{className:"w-4 h-4"})})]}),(0,d.jsxs)("div",{className:"mt-4 p-3 bg-accent rounded-lg",children:[(0,d.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(0,d.jsx)("strong",{children:c("aliasManager.usage")}),c("aliasManager.usageDesc")]}),(0,d.jsxs)("div",{className:"mt-2 space-y-1 text-xs text-muted-foreground",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ ll"}),(0,d.jsx)("span",{children:"→"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"ls -la"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ gs"}),(0,d.jsx)("span",{children:"→"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"git status"})]})]})]}),0===Object.keys(l).length&&(0,d.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:c("aliasManager.noAliases")})]})}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,d.jsx)("button",{onClick:a,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:c("common.cancel")}),(0,d.jsx)("button",{onClick:u,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:c("common.save")})]})]})})}},95836:(a,b,c)=>{"use strict";c.d(b,{Do:()=>m,Sz:()=>n,VO:()=>l,wI:()=>o});var d=c(48249),e=c(67484),f=c.n(e),g=c(44384),h=c(26068),i=c(4219);function j({status:a}){let{label:b,className:c}={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"}}[a]||{label:"?",className:"text-muted-foreground"};return(0,d.jsx)("span",{className:`text-xs font-bold ${c}`,children:b})}let k=f().memo(function a({node:b,level:c,selectedPath:f,expandedPaths:g,onSelect:h,onToggle:k,onContextMenu:l,showChanges:m=!1,renderActions:n}){let o=f===b.path,p=g.has(b.path),q=(0,e.useCallback)(()=>{b.isDirectory?k(b.path):h(b)},[b,h,k]),r=(0,e.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),l(a,b.path,b.isDirectory)},[b.path,b.isDirectory,l]);return b.isDirectory?(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-accent cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,d.jsx)("span",{className:"text-slate-9 text-xs",children:p?"▼":"▶"}),(0,d.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":b.path,children:b.name}),n&&n(b)]}),p&&b.children.map(b=>(0,d.jsx)(a,{node:b,level:c+1,selectedPath:f,expandedPaths:g,onSelect:h,onToggle:k,onContextMenu:l,showChanges:m,renderActions:n},b.path))]}):(0,d.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${o?"bg-brand/10":"hover:bg-accent"}`,style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,d.jsx)(i.o,{name:b.name,size:16,className:"flex-shrink-0"}),(0,d.jsx)("span",{className:`text-sm flex-1 truncate ${o?"text-brand":"text-foreground"}`,"data-tooltip":b.path,children:b.name}),b.status&&(0,d.jsx)(j,{status:b.status}),m&&void 0!==b.additions&&void 0!==b.deletions&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["+",b.additions]}),(0,d.jsxs)("span",{className:"text-xs text-red-11",children:["-",b.deletions]})]}),n&&n(b)]})});function l({files:a,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,cwd:i,showChanges:j=!1,renderActions:m,emptyMessage:n,className:o}){let{t:p}=(0,g.Bd)(),q=n??p("gitFileTree.noFiles"),{contextMenu:r,showContextMenu:s,hideContextMenu:t}=(0,h.Ee)();return 0===a.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-slate-9",children:q}):(0,d.jsxs)("div",{className:o||"py-1",children:[a.map(a=>(0,d.jsx)(k,{node:a,level:0,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,onContextMenu:s,showChanges:j,renderActions:m},a.path)),r&&(0,d.jsx)(h.ft,{x:r.x,y:r.y,path:r.path,cwd:i,isDirectory:r.isDirectory,onClose:t})]})}function m(a){let b=[];for(let c of a){let a=c.path.split("/"),d=b;for(let b=0;b<a.length;b++){let e=a[b],f=b===a.length-1,g=a.slice(0,b+1).join("/"),h=d.find(a=>a.name===e);h||(h={name:e,path:g,isDirectory:!f,children:[],...f&&{status:c.status,additions:c.additions,deletions:c.deletions,oldPath:c.oldPath,file:c}},d.push(h)),f||(d=h.children)}}let c=a=>{a.sort((a,b)=>a.isDirectory&&!b.isDirectory?-1:!a.isDirectory&&b.isDirectory?1:a.name.localeCompare(b.name)),a.forEach(a=>c(a.children))};return c(b),b}function n(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),c(d.children))};return c(a),b}function o(a){let b=[],c=a=>{if(a.isDirectory)for(let b of a.children)c(b);else b.push(a)};return c(a),b}},96666:(a,b,c)=>{"use strict";c.d(b,{p:()=>f});var d=c(67484),e=c(41564);function f({cwd:a,onSearchComplete:b}){let[c,g]=(0,d.useState)(""),[h,i]=(0,d.useState)([]),[j,k]=(0,d.useState)(!1),[l,m]=(0,d.useState)(null),[n,o]=(0,d.useState)(new Set),[p,q]=(0,d.useState)({caseSensitive:!1,wholeWord:!1,regex:!1,fileType:""}),[r,s]=(0,d.useState)(null),t=(0,d.useRef)(null),u=(0,d.useCallback)(async c=>{let d=c.trim();if(!d){i([]),s(null);return}if(d.length<2)return void m(e.A.t("fileBrowser.searchMinChars"));k(!0),m(null);try{let d=new URLSearchParams({cwd:a,q:c,caseSensitive:String(p.caseSensitive),wholeWord:String(p.wholeWord),regex:String(p.regex),fileType:p.fileType}),e=await fetch(`/api/files/search?${d}`),f=await e.json();if(f.error)throw Error(f.error);i(f.results),s({totalFiles:f.totalFiles,totalMatches:f.totalMatches,truncated:f.truncated});let g=new Set(f.results.map(a=>a.path));o(g),f.results.length>0&&b?.()}catch(a){m(a instanceof Error?a.message:"Search failed"),i([])}finally{k(!1)}},[a,p,b]);return{contentSearchQuery:c,setContentSearchQuery:g,contentSearchResults:h,isSearching:j,searchError:l,searchExpandedPaths:n,searchOptions:p,setSearchOptions:q,searchStats:r,contentSearchInputRef:t,performContentSearch:u,handleSearchToggle:(0,d.useCallback)(a=>{o(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[])}}},96732:(a,b,c)=>{"use strict";c.d(b,{g:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(6088),h=c(69005),i=c(7084);function j({functions:a,currentQname:b,onSelect:c}){let{t:k}=(0,f.Bd)(),l=(0,e.useMemo)(()=>a.filter(g._),[a]);return(0,d.jsxs)("div",{className:"w-56 flex-shrink-0 bg-card border-r border-border flex flex-col","data-testid":"file-toc-section",children:[(0,d.jsx)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border text-xs text-muted-foreground font-mono truncate",children:0===l.length?k("blockViewer.toc.title"):`${k("blockViewer.toc.title")} \xb7 ${l.length}`}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===l.length?(0,d.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:k("blockViewer.toc.empty")}):l.map(a=>{let e=b===a.qualifiedName;return(0,d.jsx)(h.m,{content:`${a.qualifiedName} \xb7 L${a.startLine}`,children:(0,d.jsxs)("button",{onClick:()=>c(a.qualifiedName,a.startLine),className:`w-full text-left px-2 py-1 transition-colors flex items-center gap-1.5 min-w-0 ${e?"bg-brand/15 hover:bg-brand/20":"hover:bg-secondary/60"}`,children:[(0,d.jsx)(i.y,{kind:a.kind,qname:a.qualifiedName,className:"w-3 h-3 flex-shrink-0"}),(0,d.jsx)("span",{className:`text-xs font-mono truncate ${e?"font-semibold text-brand":""}`,children:a.name})]})},a.qualifiedName)})})]})}},99117:(a,b,c)=>{"use strict";c.d(b,{a:()=>e});var d=c(67484);function e(a){let[b,c]=(0,d.useState)(!1),[e,f]=(0,d.useState)(""),[g,h]=(0,d.useState)([]),[i,j]=(0,d.useState)(0),k=(0,d.useRef)(null),l=(0,d.useRef)([]),m=(0,d.useCallback)(()=>{let b=a.current;b&&(b.querySelectorAll("mark.chat-search-match, mark.chat-search-current").forEach(a=>{let b=a.parentNode;b&&(b.replaceChild(document.createTextNode(a.textContent||""),a),b.normalize())}),l.current=[])},[a]);(0,d.useCallback)(b=>{if(m(),!b||!a.current){h([]),j(0);return}let c=[],d=[],e=b.toLowerCase();a.current.querySelectorAll("[data-message-id]").forEach(a=>{let f,g=a.getAttribute("data-message-id")||"",h=0,i=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null),j=[];for(;f=i.nextNode();)j.push(f);for(let a of j){let f=(a.textContent||"").toLowerCase(),i=0,j=[];for(;;){let a=f.indexOf(e,i);if(-1===a)break;j.push({start:a,end:a+b.length}),i=a+1}if(0!==j.length)for(let b=j.length-1;b>=0;b--){let e=j[b];a.splitText(e.end);let f=a.splitText(e.start),i=document.createElement("mark");i.className="chat-search-match",i.textContent=f.textContent,f.parentNode.replaceChild(i,f),c.push({messageId:g,markIndex:h}),d.push(i),h++}}}),c.reverse(),d.reverse(),l.current=d,h(c),j(c.length>0?0:-1)},[a,m]);let n=(0,d.useCallback)(()=>{0!==g.length&&j(a=>(a+1)%g.length)},[g.length]),o=(0,d.useCallback)(()=>{0!==g.length&&j(a=>(a-1+g.length)%g.length)},[g.length]),p=(0,d.useCallback)(()=>{c(!0),setTimeout(()=>k.current?.focus(),0)},[]),q=(0,d.useCallback)(()=>{c(!1),f(""),m(),h([]),j(0)},[m]),r=(0,d.useCallback)(a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?o():n()),"Escape"===a.key&&q()},[n,o,q]);return{isSearchVisible:b,searchQuery:e,setSearchQuery:f,matches:g,currentMatchIndex:i,goToNextMatch:n,goToPrevMatch:o,openSearch:p,closeSearch:q,searchInputRef:k,handleSearchKeyDown:r}}},99374:(a,b,c)=>{"use strict";c.d(b,{f:()=>g});var d=c(48249);c(67484);var e=c(44384),f=c(31172);function g({isOpen:a,onClose:b,messages:c,onSelectMessage:h}){let{t:i}=(0,e.Bd)();if(!a)return null;let j=c.filter(a=>"user"===a.role),k=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,d.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-lg max-h-[70vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground",children:i("userMessages.title")}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===j.length?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:i("userMessages.noMessages")}):(0,d.jsx)("div",{className:"divide-y divide-border",children:j.map((a,c)=>{let e,f,g,i=(e=a.id.match(/^user-(\d+)/))?parseInt(e[1],10):null,j=i?(f=new Date(i),g=new Date,f.toDateString()===g.toDateString()?f.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):f.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})):"";return(0,d.jsx)("button",{onClick:()=>{h(a.id),b()},className:"w-full px-4 py-3 text-left hover:bg-accent transition-colors",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsxs)("span",{className:"text-xs text-muted-foreground font-mono w-6 shrink-0 pt-0.5",children:[c+1,"."]}),(0,d.jsx)("div",{className:"flex-1 min-w-0",children:(0,d.jsx)("p",{className:"text-sm text-foreground break-words",children:function(a,b=50){let c=a.replace(/\s+/g," ").trim();return c.length<=b?c:c.slice(0,b)+"..."}(a.content)})}),j&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground shrink-0 pt-0.5",children:j})]})},a.id)})})})]})});return(0,d.jsx)(f.ZL,{children:k})}},99470:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({branches:a,selectedBranch:b,onSelect:c,isLoading:h,pinnedBranches:i=[]}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),o=(0,e.useRef)(null),p=(0,e.useRef)(null),q=m.toLowerCase(),r=new Set([...a?.local||[],...a?.remote||[]]),s=i.filter(a=>r.has(a)&&a.toLowerCase().includes(q)),t=new Set(s),u=a?.local.filter(a=>!t.has(a)&&a.toLowerCase().includes(q))||[],v=a?.remote.filter(a=>!t.has(a)&&a.toLowerCase().includes(q))||[],w=a=>{c(a),l(!1),n("")};return(0,d.jsxs)("div",{className:"relative",ref:o,children:[(0,d.jsxs)("button",{onClick:()=>l(!k),disabled:h,className:"w-full px-3 py-1.5 text-sm border border-border rounded bg-card text-foreground text-left flex items-center justify-between hover:border-slate-6 dark:hover:border-slate-6 transition-colors",children:[(0,d.jsxs)("span",{className:"truncate flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),b||j("git.selectBranch"),a?.current===b&&(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["(",j("git.currentBranch"),")"]})]}),(0,d.jsx)("svg",{className:`w-4 h-4 text-slate-9 transition-transform ${k?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),k&&(0,d.jsxs)("div",{className:"absolute z-50 mt-1 w-full bg-card border border-border rounded-lg shadow-lg max-h-80 flex flex-col",children:[(0,d.jsx)("div",{className:"p-2 border-b border-border",children:(0,d.jsx)("input",{ref:p,type:"text",value:m,onChange:a=>n(a.target.value),placeholder:j("git.searchBranch"),className:"w-full px-2 py-1 text-sm border border-border rounded bg-secondary text-foreground placeholder-slate-9"})}),(0,d.jsxs)("div",{className:"overflow-y-auto flex-1",children:[s.length>0&&s.map(c=>(0,d.jsxs)("div",{onClick:()=>w(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:j("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},`pinned-${c}`)),u.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:j("git.localBranches")}),u.map(c=>(0,d.jsxs)("div",{onClick:()=>w(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:j("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},c))]}),v.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:j("git.remoteBranches")}),v.map(a=>(0,d.jsxs)("div",{onClick:()=>w(a),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${a===b?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:a}),a===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},a))]}),0===s.length&&0===u.length&&0===v.length&&(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:j("git.noMatchingBranches")})]})]})]})}},99543:(a,b,c)=>{"use strict";c.d(b,{m:()=>e});var d=c(67484);function e(a,b,c,{cwd:f,initialSessionId:g,onSessionId:h,onTitleChange:i,onTokenUsage:j}){let[k,l]=(0,d.useState)(!1),[m,n]=(0,d.useState)(!1),[o,p]=(0,d.useState)(!1),[q,r]=(0,d.useState)(void 0),[s,t]=(0,d.useState)(0),u=(0,d.useRef)(i);u.current=i;let v=(0,d.useRef)(j);v.current=j;let w=(0,d.useRef)(void 0),x=(0,d.useRef)(0),y=(0,d.useCallback)(async(a,c,d=!1,e,f)=>{if(d){let a=Date.now();if(a-x.current<5e3)return;x.current=a}d||l(!0);try{let g={cwd:a,sessionId:c,limit:e,beforeTurnIndex:f};d&&w.current&&(g.ifFingerprint=w.current);let i=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(i.ok){let a=await i.json();if(a.notModified)return;a.fingerprint&&(w.current=a.fingerprint),void 0!==a.totalTurns&&t(a.totalTurns),void 0!==a.hasMore&&p(a.hasMore),a.messages&&a.messages.length>0&&(d?b(b=>{let c=a.messages;if(b.length===c.length&&b.length>0&&b[b.length-1].content===c[c.length-1].content)return b;let d=0;for(let a=0;a<Math.min(b.length,c.length)&&b[a].id===c[a].id&&b[a].content===c[a].content;a++)d=a+1;return d===b.length&&d<c.length?[...b,...c.slice(d)]:c}):b(a.messages)),a.sessionId&&h(a.sessionId),a.title&&u.current?.(a.title),a.usage&&v.current?.({inputTokens:a.usage.input_tokens||0,outputTokens:a.usage.output_tokens||0,cacheCreationInputTokens:a.usage.cache_creation_input_tokens||0,cacheReadInputTokens:a.usage.cache_read_input_tokens||0,totalCostUsd:0})}}catch(a){console.error("Failed to load history by cwd and sessionId:",a)}finally{d||l(!1)}},[b,h]),z=(0,d.useCallback)(async()=>{if(f&&c&&!m&&o){n(!0);try{let d=void 0!==q?q:s-Math.ceil(a.filter(a=>"user"===a.role).length),e=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:f,sessionId:c,limit:10,beforeTurnIndex:d>0?d:void 0})});if(e.ok){let a=await e.json();if(a.messages&&a.messages.length>0){b(b=>[...a.messages,...b]);let c=a.messages.filter(a=>"user"===a.role).length;r(d-c)}void 0!==a.hasMore&&p(a.hasMore),a.fingerprint&&(w.current=a.fingerprint)}}catch(a){console.error("Failed to load more history:",a)}finally{n(!1)}}},[f,c,m,o,q,s,a,b]);return{isLoadingHistory:k,isLoadingMore:m,hasMoreHistory:o,loadMoreHistory:z,loadHistory:(0,d.useCallback)(async a=>{l(!0);try{let c=await fetch(`/api/session/${a}/history`);if(c.ok){let a=await c.json();a.messages&&a.messages.length>0&&b(a.messages)}}catch(a){console.error("Failed to load history:",a)}finally{l(!1)}},[b]),loadHistoryByCwdAndSessionId:y}}}};var b=require("../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,8465,4793,3353,6043,7514,4732,2338],()=>b(b.s=47993));module.exports=c})();
1
+ (()=>{var a={};a.id=6500,a.ids=[6500],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1708:a=>{"use strict";a.exports=require("node:process")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8472:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>h,dynamic:()=>f,generateMetadata:()=>g});var d=c(5735),e=c(6612);let f="force-dynamic";async function g({searchParams:a}){let b=(await a).cwd,c=b?.split("/").filter(Boolean).pop();return{title:c?`Cockpit - ${c}`:"Cockpit"}}async function h({searchParams:a}){let{cwd:b,sessionId:c}=await a;return(0,d.jsx)(e.TabManager,{initialCwd:b,initialSessionId:c})}},9297:(a,b,c)=>{Promise.resolve().then(c.bind(c,55632)),Promise.resolve().then(c.bind(c,99829)),Promise.resolve().then(c.bind(c,24943)),Promise.resolve().then(c.bind(c,74837)),Promise.resolve().then(c.bind(c,85906)),Promise.resolve().then(c.bind(c,72399)),Promise.resolve().then(c.bind(c,25702)),Promise.resolve().then(c.bind(c,47938)),Promise.resolve().then(c.bind(c,19562)),Promise.resolve().then(c.bind(c,83022)),Promise.resolve().then(c.bind(c,6612)),Promise.resolve().then(c.bind(c,93448)),Promise.resolve().then(c.bind(c,65395)),Promise.resolve().then(c.bind(c,84747))},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12629:a=>{"use strict";a.exports=import("web-tree-sitter")},17891:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/get-segment-param")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},28354:a=>{"use strict";a.exports=require("util")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},47993:(a,b,c)=>{"use strict";c.r(b),c.d(b,{__next_app__:()=>M,handler:()=>O,routeModule:()=>N});var d=c(7553),e=c(84006),f=c(67798),g=c(34775),h=c(99373),i=c(73461),j=c(1020),k=c(26349),l=c(54365),m=c(16023),n=c(63747),o=c(24235),p=c(23938),q=c(261),r=c(66758),s=c(77243),t=c(26713),u=c(37527),v=c(22820),w=c(88216),x=c(47929),y=c(79551),z=c(71797),A=c(89125),B=c(86439),C=c(77068),D=c(27269),E=c(61287),F=c(81494),G=c(70722),H=c(70753),I=c(43954),J=c(17891),K={};for(let a in E)0>["default","__next_app__","routeModule","handler"].indexOf(a)&&(K[a]=()=>E[a]);c.d(b,K);let L={children:["",{children:["project",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,8472)),"/home/runner/work/cockpit/cockpit/src/app/project/page.tsx"]}]},{"global-error":[()=>Promise.resolve().then(c.bind(c,81227)),"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}},[]]},{layout:[()=>Promise.resolve().then(c.bind(c,76537)),"/home/runner/work/cockpit/cockpit/src/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.bind(c,81227)),"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,55091,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,45270,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,28193,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}},[]]}.children,M={require:c,loadChunk:()=>Promise.resolve()},N=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/project/page",pathname:"/project",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:L},distDir:".next-prod",relativeProjectDir:""});async function O(a,b,d){var K,P,Q,R,S;d.requestMeta&&(0,h.setRequestMeta)(a,d.requestMeta),N.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let T=!!(0,h.getRequestMeta)(a,"minimalMode"),U="/project/page";"/index"===U&&(U="/");let V=await N.prepare(a,b,{srcPage:U,multiZoneDraftMode:!1});if(!V)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:W,query:X,params:Y,pageIsDynamic:Z,buildManifest:$,nextFontManifest:_,reactLoadableManifest:aa,serverActionsManifest:ab,clientReferenceManifest:ac,subresourceIntegrityManifest:ad,prerenderManifest:ae,isDraftMode:af,resolvedPathname:ag,revalidateOnlyGenerated:ah,routerServerContext:ai,nextConfig:aj,parsedUrl:ak,interceptionRoutePatterns:al,deploymentId:am,clientAssetToken:an}=V,ao=(0,q.normalizeAppPath)(U),{isOnDemandRevalidate:ap}=V,aq=aj.experimental.ppr&&!aj.cacheComponents&&(0,I.isInterceptionRouteAppPath)(ag)?null:N.match(ag,ae),ar=(null==aq?void 0:aq.route)??null,as=!!ae.routes[ag],at=a.headers["user-agent"]||"",au=(0,t.getBotType)(at),av=(0,p.isHtmlBotRequest)(a),aw=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[s.NEXT_ROUTER_PREFETCH_HEADER],ax=(0,h.getRequestMeta)(a,"isRSCRequest")??!!a.headers[s.RSC_HEADER],ay=(0,r.getIsPossibleServerAction)(a),az=(0,m.checkIsAppPPREnabled)(aj.experimental.ppr),aA=a.headers[x.NEXT_RESUME_STATE_LENGTH_HEADER];if(!(0,h.getRequestMeta)(a,"postponed")&&T&&az&&ay&&aA&&"string"==typeof aA){let e=parseInt(aA,10),{maxPostponedStateSize:f,maxPostponedStateSizeBytes:g}=(0,D.getMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize);if(!isNaN(e)&&e>0){if(e>g)return b.statusCode=413,b.end((0,D.getPostponedStateExceededErrorMessage)(f)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let i="1 MB",j=(null==(S=aj.experimental.serverActions)?void 0:S.bodySizeLimit)??i,k=e+(j!==i?c(95726).parse(j):1048576),l=await (0,D.readBodyWithSizeLimit)(a,k);if(null===l)return b.statusCode=413,b.end("Request body exceeded limit. To configure the body size limit for Server Actions, see: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;if(l.length>=e){let b=l.subarray(0,e).toString("utf8");(0,h.addRequestMeta)(a,"postponed",b);let c=l.subarray(e);(0,h.addRequestMeta)(a,"actionBody",c)}else throw Object.defineProperty(Error(`invariant: expected ${e} bytes of postponed state but only received ${l.length} bytes`),"__NEXT_ERROR_CODE",{value:"E979",enumerable:!1,configurable:!0})}}if(!(0,h.getRequestMeta)(a,"postponed")&&az&&"1"===a.headers[x.NEXT_RESUME_HEADER]&&"POST"===a.method){let{maxPostponedStateSize:c,maxPostponedStateSizeBytes:e}=(0,D.getMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize),f=await (0,D.readBodyWithSizeLimit)(a,e);if(null===f)return b.statusCode=413,b.end((0,D.getPostponedStateExceededErrorMessage)(c)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let g=f.toString("utf8");(0,h.addRequestMeta)(a,"postponed",g)}let aB=!0===N.isDev||!0===aj.experimental.exposeTestingApiInProductionBuild,aC=aB&&("1"===a.headers[s.NEXT_INSTANT_PREFETCH_HEADER]||void 0===a.headers[s.RSC_HEADER]&&"string"==typeof a.headers.cookie&&a.headers.cookie.includes(s.NEXT_INSTANT_TEST_COOKIE+"=")),aD=(az||aC)&&((null==(K=ae.routes[ao]??ae.dynamicRoutes[ao])?void 0:K.renderingMode)==="PARTIALLY_STATIC"||aC&&(aB||(null==ai?void 0:ai.experimentalTestProxy)===!0)),aE=aC&&aD,aF=aE&&!0===N.isDev,aG=!1,aH=aD?(0,h.getRequestMeta)(a,"postponed"):void 0,aI=null==(P=ae.routes[ag])?void 0:P.prefetchDataRoute,aJ=aD&&ax&&!aw&&!aI;T&&(aJ=aJ&&!!aH);let aK=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),aL=(!au||!aD)&&(!at||(0,p.shouldServeStreamingMetadata)(at,aj.htmlLimitedBots)),aM=!!((ar||as||ae.routes[ao])&&!(au&&aD)),aN=aD&&!0===aj.cacheComponents,aO=!0===N.isDev||!aM||"string"==typeof aH||(aN&&(0,h.getRequestMeta)(a,"onCacheEntryV2")?aJ&&!T:aJ),aP=!!au&&aD,aQ=(null==ar?void 0:ar.remainingPrerenderableParams)??[],aR=(null==ar?void 0:ar.fallback)===null&&((null==(Q=ar.fallbackRootParams)?void 0:Q.length)??0)>0,aS=null;if(!af&&aM&&!aO&&!ay&&!aH&&!aJ){let a=aq?"string"==typeof(null==ar?void 0:ar.fallback)?ar.fallback:aq.source:null;if(!0===aj.experimental.partialFallbacks&&a&&(null==ar?void 0:ar.fallbackRouteParams)&&!aR){if(aQ.length>0){let b,c=(b=new Map(aQ.map(a=>[a.paramName,a])),a.split("/").map(a=>{let c=(0,J.getSegmentParam)(a);if(!c)return a;let d=b.get(c.paramName);if(!d)return a;let e=null==Y?void 0:Y[d.paramName];if(!e)return a;let f=Array.isArray(e)?e.map(a=>encodeURIComponent(a)).join("/"):encodeURIComponent(e);return a.replace(function(a){let{repeat:b,optional:c}=(0,J.getParamProperties)(a.paramType);return c?`[[...${a.paramName}]]`:b?`[...${a.paramName}]`:`[${a.paramName}]`}(d),f)}).join("/")||"/");aS=c!==a?c:null}}else aS=ag}let aT=aS;!aT&&(N.isDev||aM&&Z&&(null==ar?void 0:ar.fallbackRouteParams)&&!ay)&&(aT=ag),N.isDev||af||!aM||!ax||aJ||(0,k.d)(a.headers);let aU={...E,tree:L,handler:O,routeModule:N,__next_app__:M};ab&&ac&&(0,o.setManifestsSingleton)({page:U,clientReferenceManifest:ac,serverActionsManifest:ab});let aV=a.method||"GET",aW=(0,g.getTracer)(),aX=aW.getActiveScopeSpan(),aY=!!(null==ai?void 0:ai.isWrappedByNextServer),aZ=!0===aj.experimental.partialFallbacks&&aQ.length>0?(null==ar||null==(R=ar.fallbackRouteParams)?void 0:R.filter(a=>!aQ.some(b=>b.paramName===a.paramName)))??[]:[],a$=async()=>((null==ai?void 0:ai.render404)?await ai.render404(a,b,ak,!1):b.end("This page could not be found"),null);try{let k,m=N.getVaryHeader(ag,al);b.setHeader("Vary",m);let o=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return N.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let a=aW.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let d=a.get("next.route");if(d){let a=`${aV} ${d}`;c.setAttributes({"next.route":d,"http.route":d,"next.span_name":a}),c.updateName(a),k&&k!==c&&(k.setAttribute("http.route",d),k.updateName(a))}else c.updateName(`${aV} ${U}`)})},p=(0,h.getRequestMeta)(a,"incrementalCache")||await N.getIncrementalCache(a,aj,ae,T);null==p||p.resetRequestCache(),globalThis.__incrementalCache=p;let q=async({span:e,postponed:f,fallbackRouteParams:g,forceStaticRender:i})=>{let k={query:X,params:Y,page:ao,sharedContext:{buildId:W,deploymentId:am,clientAssetToken:an},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aU,Component:(0,j.T)(aU),params:Y,routeModule:N,page:U,postponed:f,shouldWaitOnAllReady:aP,serveStreamingMetadata:aL,supportsDynamicResponse:"string"==typeof f||aO,buildManifest:$,nextFontManifest:_,reactLoadableManifest:aa,subresourceIntegrityManifest:ad,setCacheStatus:null==ai?void 0:ai.setCacheStatus,setIsrStatus:null==ai?void 0:ai.setIsrStatus,setReactDebugChannel:null==ai?void 0:ai.setReactDebugChannel,sendErrorsToBrowser:null==ai?void 0:ai.sendErrorsToBrowser,dir:c(33873).join(process.cwd(),N.relativeProjectDir),isDraftMode:af,botType:au,isOnDemandRevalidate:ap,isPossibleServerAction:ay,assetPrefix:aj.assetPrefix,nextConfigOutput:aj.output,crossOrigin:aj.crossOrigin,trailingSlash:aj.trailingSlash,images:aj.images,previewProps:ae.preview,enableTainting:aj.experimental.taint,htmlLimitedBots:aj.htmlLimitedBots,reactMaxHeadersLength:aj.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:p,cacheLifeProfiles:aj.cacheLife,basePath:aj.basePath,serverActions:aj.experimental.serverActions,logServerFunctions:"object"==typeof aj.logging&&!!aj.logging.serverFunctions,...aE||aF||aG?{isBuildTimePrerendering:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isDebugDynamicAccesses:aF}:{},cacheComponents:!!aj.cacheComponents,experimental:{isRoutePPREnabled:aD,expireTime:aj.expireTime,staleTimes:aj.experimental.staleTimes,dynamicOnHover:!!aj.experimental.dynamicOnHover,optimisticRouting:!!aj.experimental.optimisticRouting,inlineCss:!!aj.experimental.inlineCss,prefetchInlining:aj.experimental.prefetchInlining??!1,authInterrupts:!!aj.experimental.authInterrupts,cachedNavigations:!!aj.experimental.cachedNavigations,clientTraceMetadata:aj.experimental.clientTraceMetadata||[],clientParamParsingOrigins:aj.experimental.clientParamParsingOrigins,maxPostponedStateSizeBytes:(0,C.parseMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize)},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d,e)=>N.onRequestError(a,b,d,e,ai),err:(0,h.getRequestMeta)(a,"invokeError")}};i&&(k.renderOpts.supportsDynamicResponse=!1);let l=await o(e,k),{metadata:m}=l,{cacheControl:n,headers:q={},fetchTags:r,fetchMetrics:s}=m;if(r&&(q[x.NEXT_CACHE_TAGS_HEADER]=r),a.fetchMetrics=s,aM&&(null==n?void 0:n.revalidate)===0&&!N.isDev&&!aD){let a=m.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${ag}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
2
+ see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:u.CachedRouteKind.APP_PAGE,html:l,headers:q,rscData:m.flightData,postponed:m.postponed,status:m.statusCode,segmentData:m.segmentData},cacheControl:n}},r=async({hasResolved:c,previousCacheEntry:g,isRevalidating:i,span:j,forceStaticRender:k=!1})=>{let l=!1===N.isDev,m=c||b.writableEnded;try{let f;if(ap&&ah&&!g&&!T)return(null==ai?void 0:ai.render404)?await ai.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(ar&&(f=(0,v.parseFallbackField)(ar.fallback)),!0===aj.experimental.partialFallbacks&&(null==ar?void 0:ar.fallback)===null&&!aR&&aQ.length>0&&(f=v.FallbackMode.PRERENDER),f===v.FallbackMode.PRERENDER&&(0,t.isBot)(at)&&(!aD||av)&&(f=v.FallbackMode.BLOCKING_STATIC_RENDER),(null==g?void 0:g.isStale)===-1&&(ap=!0),ap&&(f!==v.FallbackMode.NOT_FOUND||g)&&(f=v.FallbackMode.BLOCKING_STATIC_RENDER),!T&&f!==v.FallbackMode.BLOCKING_STATIC_RENDER&&aT&&!m&&!af&&Z&&(l||!as)){if((l||ar)&&f===v.FallbackMode.NOT_FOUND){if(aj.adapterPath)return await a$();throw new B.NoFallbackError}if(aD&&(aj.cacheComponents?!aJ:!ax)){let b=l&&"string"==typeof(null==ar?void 0:ar.fallback)?ar.fallback:ao,f=(l||aE)&&(null==ar?void 0:ar.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams):aG?(0,n.getFallbackRouteParams)(ao,N):null;aE&&f&&(0,h.addRequestMeta)(a,"fallbackParams",f);let g=await N.handleResponse({cacheKey:b,req:a,nextConfig:aj,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:ae,isRoutePPREnabled:aD,responseGenerator:async()=>q({span:j,postponed:void 0,fallbackRouteParams:f,forceStaticRender:!0}),waitUntil:d.waitUntil,isMinimalMode:T});if(null===g)return null;if(g)return T||!aD||!(aQ.length>0)||!0!==aj.experimental.partialFallbacks||!aS||!p||ap||aG||aB||aC||aw||(0,H.scheduleOnNextTick)(async()=>{let b=N.getResponseCache(a);try{await b.revalidate(aS,p,aD,!1,a=>q({span:a.span,postponed:void 0,fallbackRouteParams:aZ.length>0?(0,n.createOpaqueFallbackRouteParams)(aZ):null,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}),delete g.cacheControl,g}}let o=ap||i||!aH?void 0:aH;if(aN&&!T&&p&&(aJ||ay)&&!k){let b=await p.get(ag,{kind:u.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===u.CachedRouteKind.APP_PAGE&&(o=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,H.scheduleOnNextTick)(async()=>{let b=N.getResponseCache(a);try{await b.revalidate(ag,p,aD,!1,a=>r({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if((aE||aF)&&void 0!==o)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:u.CachedRouteKind.PAGES,html:w.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let s=(l&&(0,h.getRequestMeta)(a,"renderFallbackShell")||aE&&!as)&&(null==ar?void 0:ar.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams):aG?(0,n.getFallbackRouteParams)(ao,N):null;if((l||aE)&&aj.cacheComponents&&!as&&(null==ar?void 0:ar.fallbackRouteParams)){let b=(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams);b&&(0,h.addRequestMeta)(a,"fallbackParams",b)}return q({span:j,postponed:o,fallbackRouteParams:s,forceStaticRender:k})}catch(b){throw(null==g?void 0:g.isStale)&&await N.onRequestError(a,b,{routerKind:"App Router",routePath:U,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aM,isOnDemandRevalidate:ap})},!1,ai),b}},D=async c=>{var f,g,i,j,k;let l,m=await N.handleResponse({cacheKey:aS,responseGenerator:a=>r({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ap,isRoutePPREnabled:aD,req:a,nextConfig:aj,prerenderManifest:ae,waitUntil:d.waitUntil,isMinimalMode:T});if(af&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),N.isDev&&b.setHeader("Cache-Control","no-cache, must-revalidate"),!m){if(aS)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=m.value)?void 0:f.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=m.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let n="string"==typeof m.value.postponed;ax&&!ay&&am&&b.setHeader(x.NEXT_NAV_DEPLOYMENT_ID_HEADER,am),aM&&!aJ&&(!n||aw)&&(T||b.setHeader("x-nextjs-cache",ap?"REVALIDATED":m.isMiss?"MISS":m.isStale?"STALE":"HIT"),b.setHeader(s.NEXT_IS_PRERENDER_HEADER,"1"));let{value:o}=m;if(aH)l={revalidate:0,expire:void 0};else if(aJ)l={revalidate:0,expire:void 0};else if(!N.isDev)if(af)l={revalidate:0,expire:void 0};else if(aM){if(m.cacheControl)if("number"==typeof m.cacheControl.revalidate){if(m.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${m.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:m.cacheControl.revalidate,expire:(null==(j=m.cacheControl)?void 0:j.expire)??aj.expireTime}}else l={revalidate:x.CACHE_ONE_YEAR_SECONDS,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(m.cacheControl=l,"string"==typeof aK&&(null==o?void 0:o.kind)===u.CachedRouteKind.APP_PAGE&&o.segmentData){b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=o.headers)?void 0:k[x.NEXT_CACHE_TAGS_HEADER];T&&aM&&c&&"string"==typeof c&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,c);let d=o.segmentData.get(aK);return void 0!==d?(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.fromStatic(d,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl}):(b.statusCode=204,(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl}))}let p=aN?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(p&&await p(m,{url:(0,h.getRequestMeta)(a,"initURL")??a.url}))return null;if(o.headers){let a={...o.headers};for(let[c,d]of(T&&aM||delete a[x.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let t=null==(g=o.headers)?void 0:g[x.NEXT_CACHE_TAGS_HEADER];if(T&&aM&&t&&"string"==typeof t&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,t),!o.status||ax&&aD||(b.statusCode=o.status),!T&&o.status&&F.RedirectStatusCode[o.status]&&ax&&(b.statusCode=200),n&&!aJ&&b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"1"),ax&&!af){if(void 0===o.rscData){if(o.html.contentType!==s.RSC_CONTENT_TYPE_HEADER)if(aj.cacheComponents)return b.statusCode=404,(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl});else throw Object.defineProperty(new G.InvariantError(`Expected RSC response, got ${o.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:o.html,cacheControl:m.cacheControl})}return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.fromStatic(o.rscData,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl})}let v=o.html;if(aC&&aE){let c=!0===N.isDev?crypto.randomUUID():null;return v.pipeThrough((0,z.createInstantTestScriptInsertionTransformStream)(c)),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})}if(!n||T||ax)return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:m.cacheControl});if(aE||aF)return v.push(new ReadableStream({start(a){a.enqueue(y.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}});let B=new TransformStream;return v.push(B.readable),q({span:c,postponed:o.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(B.writable)}).catch(a=>{B.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})};if(!aY||!aX)return k=aW.getActiveScopeSpan(),await aW.withPropagatedContext(a.headers,()=>aW.trace(i.BaseServerSpan.handleRequest,{spanName:`${aV} ${U}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aV,"http.target":a.url}},D),void 0,!aY);await D(aX)}catch(b){throw b instanceof B.NoFallbackError||await N.onRequestError(a,b,{routerKind:"App Router",routePath:U,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aM,isOnDemandRevalidate:ap})},!1,ai),b}}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},73136:a=>{"use strict";a.exports=require("node:url")},76760:a=>{"use strict";a.exports=require("node:path")},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},78908:a=>{"use strict";a.exports=import("shiki")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},99569:(a,b,c)=>{Promise.resolve().then(c.bind(c,4462)),Promise.resolve().then(c.bind(c,29491)),Promise.resolve().then(c.bind(c,34001)),Promise.resolve().then(c.bind(c,83179)),Promise.resolve().then(c.bind(c,25608)),Promise.resolve().then(c.bind(c,8077)),Promise.resolve().then(c.bind(c,76552)),Promise.resolve().then(c.bind(c,77120)),Promise.resolve().then(c.bind(c,77220)),Promise.resolve().then(c.bind(c,3588)),Promise.resolve().then(c.bind(c,77462)),Promise.resolve().then(c.bind(c,38878)),Promise.resolve().then(c.bind(c,37129)),Promise.resolve().then(c.bind(c,99033))}};var b=require("../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,8465,554,9658],()=>b(b.s=47993));module.exports=c})();