commandmate 0.16.0 → 0.17.0

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 (616) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +286 -216
  3. package/.next/app-path-routes-manifest.json +37 -27
  4. package/.next/build-manifest.json +2 -2
  5. package/.next/prerender-manifest.json +9 -9
  6. package/.next/required-server-files.json +1 -1
  7. package/.next/routes-manifest.json +57 -0
  8. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  9. package/.next/server/app/api/app/update/route_client-reference-manifest.js +1 -1
  10. package/.next/server/app/api/app/update-check/route.js +1 -1
  11. package/.next/server/app/api/app/update-check/route_client-reference-manifest.js +1 -1
  12. package/.next/server/app/api/assistant/conversation/route.js +1 -1
  13. package/.next/server/app/api/assistant/conversation/route.js.nft.json +1 -1
  14. package/.next/server/app/api/assistant/conversation/route_client-reference-manifest.js +1 -1
  15. package/.next/server/app/api/assistant/current-output/route.js +1 -1
  16. package/.next/server/app/api/assistant/current-output/route.js.nft.json +1 -1
  17. package/.next/server/app/api/assistant/current-output/route_client-reference-manifest.js +1 -1
  18. package/.next/server/app/api/assistant/messages/route.js +1 -1
  19. package/.next/server/app/api/assistant/messages/route.js.nft.json +1 -1
  20. package/.next/server/app/api/assistant/messages/route_client-reference-manifest.js +1 -1
  21. package/.next/server/app/api/assistant/session/route.js +1 -1
  22. package/.next/server/app/api/assistant/session/route.js.nft.json +1 -1
  23. package/.next/server/app/api/assistant/session/route_client-reference-manifest.js +1 -1
  24. package/.next/server/app/api/assistant/start/route.js +1 -1
  25. package/.next/server/app/api/assistant/start/route.js.nft.json +1 -1
  26. package/.next/server/app/api/assistant/start/route_client-reference-manifest.js +1 -1
  27. package/.next/server/app/api/assistant/terminal/route.js +3 -3
  28. package/.next/server/app/api/assistant/terminal/route.js.nft.json +1 -1
  29. package/.next/server/app/api/assistant/terminal/route_client-reference-manifest.js +1 -1
  30. package/.next/server/app/api/assistant/tools/route.js +1 -1
  31. package/.next/server/app/api/assistant/tools/route.js.nft.json +1 -1
  32. package/.next/server/app/api/assistant/tools/route_client-reference-manifest.js +1 -1
  33. package/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  34. package/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  35. package/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  36. package/.next/server/app/api/daily-summary/route_client-reference-manifest.js +1 -1
  37. package/.next/server/app/api/daily-summary/status/route_client-reference-manifest.js +1 -1
  38. package/.next/server/app/api/external-apps/[id]/health/route_client-reference-manifest.js +1 -1
  39. package/.next/server/app/api/external-apps/[id]/route_client-reference-manifest.js +1 -1
  40. package/.next/server/app/api/external-apps/route_client-reference-manifest.js +1 -1
  41. package/.next/server/app/api/fs/browse/route_client-reference-manifest.js +1 -1
  42. package/.next/server/app/api/fs/recent-paths/route.js +1 -1
  43. package/.next/server/app/api/fs/recent-paths/route_client-reference-manifest.js +1 -1
  44. package/.next/server/app/api/hooks/agent-event/route.js +1 -0
  45. package/.next/server/app/api/hooks/agent-event/route.js.nft.json +1 -0
  46. package/.next/server/app/api/hooks/agent-event/route_client-reference-manifest.js +1 -0
  47. package/.next/server/app/api/hooks/claude-done/route.js +1 -1
  48. package/.next/server/app/api/hooks/claude-done/route.js.nft.json +1 -1
  49. package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
  50. package/.next/server/app/api/metrics/vibe/route.js +37 -0
  51. package/.next/server/app/api/metrics/vibe/route.js.nft.json +1 -0
  52. package/.next/server/app/api/metrics/vibe/route_client-reference-manifest.js +1 -0
  53. package/.next/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
  54. package/.next/server/app/api/push/subscriptions/route.js +1 -1
  55. package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
  56. package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
  57. package/.next/server/app/api/repositories/[id]/route_client-reference-manifest.js +1 -1
  58. package/.next/server/app/api/repositories/[id]/todos/[todoId]/route.js +1 -1
  59. package/.next/server/app/api/repositories/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  60. package/.next/server/app/api/repositories/[id]/todos/route.js +1 -1
  61. package/.next/server/app/api/repositories/[id]/todos/route_client-reference-manifest.js +1 -1
  62. package/.next/server/app/api/repositories/clone/[jobId]/route.js +1 -1
  63. package/.next/server/app/api/repositories/clone/[jobId]/route.js.nft.json +1 -1
  64. package/.next/server/app/api/repositories/clone/[jobId]/route_client-reference-manifest.js +1 -1
  65. package/.next/server/app/api/repositories/clone/route.js +1 -1
  66. package/.next/server/app/api/repositories/clone/route.js.nft.json +1 -1
  67. package/.next/server/app/api/repositories/clone/route_client-reference-manifest.js +1 -1
  68. package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
  69. package/.next/server/app/api/repositories/restore/route.js +1 -1
  70. package/.next/server/app/api/repositories/restore/route.js.nft.json +1 -1
  71. package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
  72. package/.next/server/app/api/repositories/route.js +1 -1
  73. package/.next/server/app/api/repositories/route.js.nft.json +1 -1
  74. package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
  75. package/.next/server/app/api/repositories/scan/route.js +1 -1
  76. package/.next/server/app/api/repositories/scan/route.js.nft.json +1 -1
  77. package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +1 -1
  78. package/.next/server/app/api/repositories/sync/route.js +1 -1
  79. package/.next/server/app/api/repositories/sync/route.js.nft.json +1 -1
  80. package/.next/server/app/api/repositories/sync/route_client-reference-manifest.js +1 -1
  81. package/.next/server/app/api/repositories/validate-path/route_client-reference-manifest.js +1 -1
  82. package/.next/server/app/api/sidebar/group-order/route_client-reference-manifest.js +1 -1
  83. package/.next/server/app/api/skills/[id]/route_client-reference-manifest.js +1 -1
  84. package/.next/server/app/api/skills/installations/route_client-reference-manifest.js +1 -1
  85. package/.next/server/app/api/skills/operations/route_client-reference-manifest.js +1 -1
  86. package/.next/server/app/api/skills/reindex/route_client-reference-manifest.js +1 -1
  87. package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
  88. package/.next/server/app/api/slash-commands/route_client-reference-manifest.js +1 -1
  89. package/.next/server/app/api/tasks/[taskId]/cancel/route.js +4 -0
  90. package/.next/server/app/api/tasks/[taskId]/cancel/route.js.nft.json +1 -0
  91. package/.next/server/app/api/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -0
  92. package/.next/server/app/api/tasks/[taskId]/route.js +4 -0
  93. package/.next/server/app/api/tasks/[taskId]/route.js.nft.json +1 -0
  94. package/.next/server/app/api/tasks/[taskId]/route_client-reference-manifest.js +1 -0
  95. package/.next/server/app/api/templates/[id]/route.js +1 -1
  96. package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
  97. package/.next/server/app/api/templates/route.js +1 -1
  98. package/.next/server/app/api/templates/route_client-reference-manifest.js +1 -1
  99. package/.next/server/app/api/todos/route.js +1 -1
  100. package/.next/server/app/api/todos/route_client-reference-manifest.js +1 -1
  101. package/.next/server/app/api/verification/runs/[runId]/route.js +1 -0
  102. package/.next/server/app/api/verification/runs/[runId]/route.js.nft.json +1 -0
  103. package/.next/server/app/api/verification/runs/[runId]/route_client-reference-manifest.js +1 -0
  104. package/.next/server/app/api/verification/runs/route.js +1 -0
  105. package/.next/server/app/api/verification/runs/route.js.nft.json +1 -0
  106. package/.next/server/app/api/verification/runs/route_client-reference-manifest.js +1 -0
  107. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js +1 -1
  108. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js.nft.json +1 -1
  109. package/.next/server/app/api/worktrees/[id]/auto-yes/route_client-reference-manifest.js +1 -1
  110. package/.next/server/app/api/worktrees/[id]/capture/route.js +1 -1
  111. package/.next/server/app/api/worktrees/[id]/capture/route.js.nft.json +1 -1
  112. package/.next/server/app/api/worktrees/[id]/capture/route_client-reference-manifest.js +1 -1
  113. package/.next/server/app/api/worktrees/[id]/cli-tool/route.js +1 -1
  114. package/.next/server/app/api/worktrees/[id]/cli-tool/route_client-reference-manifest.js +1 -1
  115. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route.js +1 -1
  116. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route_client-reference-manifest.js +1 -1
  117. package/.next/server/app/api/worktrees/[id]/current-output/route.js +1 -1
  118. package/.next/server/app/api/worktrees/[id]/current-output/route.js.nft.json +1 -1
  119. package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
  120. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route.js +1 -1
  121. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route_client-reference-manifest.js +1 -1
  122. package/.next/server/app/api/worktrees/[id]/execution-logs/route.js +2 -2
  123. package/.next/server/app/api/worktrees/[id]/execution-logs/route_client-reference-manifest.js +1 -1
  124. package/.next/server/app/api/worktrees/[id]/files/[...path]/route.js +1 -1
  125. package/.next/server/app/api/worktrees/[id]/files/[...path]/route_client-reference-manifest.js +1 -1
  126. package/.next/server/app/api/worktrees/[id]/git/branch/create/route.js +1 -1
  127. package/.next/server/app/api/worktrees/[id]/git/branch/create/route_client-reference-manifest.js +1 -1
  128. package/.next/server/app/api/worktrees/[id]/git/branch/delete/route.js +1 -1
  129. package/.next/server/app/api/worktrees/[id]/git/branch/delete/route_client-reference-manifest.js +1 -1
  130. package/.next/server/app/api/worktrees/[id]/git/branches/route.js +1 -1
  131. package/.next/server/app/api/worktrees/[id]/git/branches/route_client-reference-manifest.js +1 -1
  132. package/.next/server/app/api/worktrees/[id]/git/checkout/route.js +1 -1
  133. package/.next/server/app/api/worktrees/[id]/git/checkout/route_client-reference-manifest.js +1 -1
  134. package/.next/server/app/api/worktrees/[id]/git/commit/route.js +1 -1
  135. package/.next/server/app/api/worktrees/[id]/git/commit/route_client-reference-manifest.js +1 -1
  136. package/.next/server/app/api/worktrees/[id]/git/diff/route.js +1 -1
  137. package/.next/server/app/api/worktrees/[id]/git/diff/route_client-reference-manifest.js +1 -1
  138. package/.next/server/app/api/worktrees/[id]/git/fetch/route.js +1 -1
  139. package/.next/server/app/api/worktrees/[id]/git/fetch/route_client-reference-manifest.js +1 -1
  140. package/.next/server/app/api/worktrees/[id]/git/log/route.js +1 -1
  141. package/.next/server/app/api/worktrees/[id]/git/log/route_client-reference-manifest.js +1 -1
  142. package/.next/server/app/api/worktrees/[id]/git/pull/route.js +1 -1
  143. package/.next/server/app/api/worktrees/[id]/git/pull/route_client-reference-manifest.js +1 -1
  144. package/.next/server/app/api/worktrees/[id]/git/push/route.js +1 -1
  145. package/.next/server/app/api/worktrees/[id]/git/push/route_client-reference-manifest.js +1 -1
  146. package/.next/server/app/api/worktrees/[id]/git/reset/route.js +1 -1
  147. package/.next/server/app/api/worktrees/[id]/git/reset/route_client-reference-manifest.js +1 -1
  148. package/.next/server/app/api/worktrees/[id]/git/revert/route.js +1 -1
  149. package/.next/server/app/api/worktrees/[id]/git/revert/route_client-reference-manifest.js +1 -1
  150. package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route.js +1 -1
  151. package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route_client-reference-manifest.js +1 -1
  152. package/.next/server/app/api/worktrees/[id]/git/stage/route.js +1 -1
  153. package/.next/server/app/api/worktrees/[id]/git/stage/route_client-reference-manifest.js +1 -1
  154. package/.next/server/app/api/worktrees/[id]/git/staged/route.js +1 -1
  155. package/.next/server/app/api/worktrees/[id]/git/staged/route_client-reference-manifest.js +1 -1
  156. package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route.js +1 -1
  157. package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route_client-reference-manifest.js +1 -1
  158. package/.next/server/app/api/worktrees/[id]/git/stash/apply/route.js +1 -1
  159. package/.next/server/app/api/worktrees/[id]/git/stash/apply/route_client-reference-manifest.js +1 -1
  160. package/.next/server/app/api/worktrees/[id]/git/stash/pop/route.js +1 -1
  161. package/.next/server/app/api/worktrees/[id]/git/stash/pop/route_client-reference-manifest.js +1 -1
  162. package/.next/server/app/api/worktrees/[id]/git/stash/push/route.js +1 -1
  163. package/.next/server/app/api/worktrees/[id]/git/stash/push/route_client-reference-manifest.js +1 -1
  164. package/.next/server/app/api/worktrees/[id]/git/stash/route.js +1 -1
  165. package/.next/server/app/api/worktrees/[id]/git/stash/route_client-reference-manifest.js +1 -1
  166. package/.next/server/app/api/worktrees/[id]/git/status/route.js +1 -1
  167. package/.next/server/app/api/worktrees/[id]/git/status/route_client-reference-manifest.js +1 -1
  168. package/.next/server/app/api/worktrees/[id]/git/unstage/route.js +1 -1
  169. package/.next/server/app/api/worktrees/[id]/git/unstage/route_client-reference-manifest.js +1 -1
  170. package/.next/server/app/api/worktrees/[id]/git/working-diff/route.js +1 -1
  171. package/.next/server/app/api/worktrees/[id]/git/working-diff/route_client-reference-manifest.js +1 -1
  172. package/.next/server/app/api/worktrees/[id]/interrupt/route.js +1 -1
  173. package/.next/server/app/api/worktrees/[id]/interrupt/route.js.nft.json +1 -1
  174. package/.next/server/app/api/worktrees/[id]/interrupt/route_client-reference-manifest.js +1 -1
  175. package/.next/server/app/api/worktrees/[id]/kill-session/route.js +1 -1
  176. package/.next/server/app/api/worktrees/[id]/kill-session/route.js.nft.json +1 -1
  177. package/.next/server/app/api/worktrees/[id]/kill-session/route_client-reference-manifest.js +1 -1
  178. package/.next/server/app/api/worktrees/[id]/logs/[filename]/route.js +1 -1
  179. package/.next/server/app/api/worktrees/[id]/logs/[filename]/route_client-reference-manifest.js +1 -1
  180. package/.next/server/app/api/worktrees/[id]/logs/route.js +1 -1
  181. package/.next/server/app/api/worktrees/[id]/logs/route_client-reference-manifest.js +1 -1
  182. package/.next/server/app/api/worktrees/[id]/marp-render/route.js +1 -1
  183. package/.next/server/app/api/worktrees/[id]/marp-render/route_client-reference-manifest.js +1 -1
  184. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route.js +1 -1
  185. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route_client-reference-manifest.js +1 -1
  186. package/.next/server/app/api/worktrees/[id]/memos/route.js +1 -1
  187. package/.next/server/app/api/worktrees/[id]/memos/route_client-reference-manifest.js +1 -1
  188. package/.next/server/app/api/worktrees/[id]/messages/route.js +1 -1
  189. package/.next/server/app/api/worktrees/[id]/messages/route_client-reference-manifest.js +1 -1
  190. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js +1 -1
  191. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js.nft.json +1 -1
  192. package/.next/server/app/api/worktrees/[id]/prompt-response/route_client-reference-manifest.js +1 -1
  193. package/.next/server/app/api/worktrees/[id]/respond/route.js +1 -1
  194. package/.next/server/app/api/worktrees/[id]/respond/route.js.nft.json +1 -1
  195. package/.next/server/app/api/worktrees/[id]/respond/route_client-reference-manifest.js +1 -1
  196. package/.next/server/app/api/worktrees/[id]/route.js +1 -1
  197. package/.next/server/app/api/worktrees/[id]/route.js.nft.json +1 -1
  198. package/.next/server/app/api/worktrees/[id]/route_client-reference-manifest.js +1 -1
  199. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js +1 -1
  200. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route_client-reference-manifest.js +1 -1
  201. package/.next/server/app/api/worktrees/[id]/schedules/active/route.js +1 -1
  202. package/.next/server/app/api/worktrees/[id]/schedules/active/route_client-reference-manifest.js +1 -1
  203. package/.next/server/app/api/worktrees/[id]/schedules/route.js +2 -2
  204. package/.next/server/app/api/worktrees/[id]/schedules/route_client-reference-manifest.js +1 -1
  205. package/.next/server/app/api/worktrees/[id]/search/route.js +1 -1
  206. package/.next/server/app/api/worktrees/[id]/search/route_client-reference-manifest.js +1 -1
  207. package/.next/server/app/api/worktrees/[id]/send/route.js +1 -1
  208. package/.next/server/app/api/worktrees/[id]/send/route.js.nft.json +1 -1
  209. package/.next/server/app/api/worktrees/[id]/send/route_client-reference-manifest.js +1 -1
  210. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route.js +1 -1
  211. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route.js.nft.json +1 -1
  212. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route_client-reference-manifest.js +1 -1
  213. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route_client-reference-manifest.js +1 -1
  214. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route_client-reference-manifest.js +1 -1
  215. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route_client-reference-manifest.js +1 -1
  216. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route_client-reference-manifest.js +1 -1
  217. package/.next/server/app/api/worktrees/[id]/skills/route.js +2 -2
  218. package/.next/server/app/api/worktrees/[id]/skills/route_client-reference-manifest.js +1 -1
  219. package/.next/server/app/api/worktrees/[id]/slash-commands/route.js +1 -1
  220. package/.next/server/app/api/worktrees/[id]/slash-commands/route_client-reference-manifest.js +1 -1
  221. package/.next/server/app/api/worktrees/[id]/special-keys/route.js +1 -1
  222. package/.next/server/app/api/worktrees/[id]/special-keys/route.js.nft.json +1 -1
  223. package/.next/server/app/api/worktrees/[id]/special-keys/route_client-reference-manifest.js +1 -1
  224. package/.next/server/app/api/worktrees/[id]/start-polling/route.js +1 -1
  225. package/.next/server/app/api/worktrees/[id]/start-polling/route.js.nft.json +1 -1
  226. package/.next/server/app/api/worktrees/[id]/start-polling/route_client-reference-manifest.js +1 -1
  227. package/.next/server/app/api/worktrees/[id]/tasks/route.js +6 -0
  228. package/.next/server/app/api/worktrees/[id]/tasks/route.js.nft.json +1 -0
  229. package/.next/server/app/api/worktrees/[id]/tasks/route_client-reference-manifest.js +1 -0
  230. package/.next/server/app/api/worktrees/[id]/terminal/route.js +1 -1
  231. package/.next/server/app/api/worktrees/[id]/terminal/route.js.nft.json +1 -1
  232. package/.next/server/app/api/worktrees/[id]/terminal/route_client-reference-manifest.js +1 -1
  233. package/.next/server/app/api/worktrees/[id]/timers/history/route.js +1 -1
  234. package/.next/server/app/api/worktrees/[id]/timers/history/route_client-reference-manifest.js +1 -1
  235. package/.next/server/app/api/worktrees/[id]/timers/route.js +1 -1
  236. package/.next/server/app/api/worktrees/[id]/timers/route.js.nft.json +1 -1
  237. package/.next/server/app/api/worktrees/[id]/timers/route_client-reference-manifest.js +1 -1
  238. package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route.js +1 -1
  239. package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  240. package/.next/server/app/api/worktrees/[id]/todos/route.js +1 -1
  241. package/.next/server/app/api/worktrees/[id]/todos/route_client-reference-manifest.js +1 -1
  242. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route.js +1 -1
  243. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route_client-reference-manifest.js +1 -1
  244. package/.next/server/app/api/worktrees/[id]/tree/route.js +1 -1
  245. package/.next/server/app/api/worktrees/[id]/tree/route_client-reference-manifest.js +1 -1
  246. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route.js +1 -1
  247. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route_client-reference-manifest.js +1 -1
  248. package/.next/server/app/api/worktrees/[id]/verify/route.js +4 -0
  249. package/.next/server/app/api/worktrees/[id]/verify/route.js.nft.json +1 -0
  250. package/.next/server/app/api/worktrees/[id]/verify/route_client-reference-manifest.js +1 -0
  251. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route.js +1 -0
  252. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route.js.nft.json +1 -0
  253. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route_client-reference-manifest.js +1 -0
  254. package/.next/server/app/api/worktrees/[id]/verify/runs/route.js +1 -0
  255. package/.next/server/app/api/worktrees/[id]/verify/runs/route.js.nft.json +1 -0
  256. package/.next/server/app/api/worktrees/[id]/verify/runs/route_client-reference-manifest.js +1 -0
  257. package/.next/server/app/api/worktrees/[id]/viewed/route.js +1 -1
  258. package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
  259. package/.next/server/app/api/worktrees/route.js +1 -1
  260. package/.next/server/app/api/worktrees/route.js.nft.json +1 -1
  261. package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
  262. package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  263. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  264. package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
  265. package/.next/server/app/more/page_client-reference-manifest.js +1 -1
  266. package/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  267. package/.next/server/app/page_client-reference-manifest.js +1 -1
  268. package/.next/server/app/proxy/[...path]/route_client-reference-manifest.js +1 -1
  269. package/.next/server/app/repositories/page.js +1 -1
  270. package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
  271. package/.next/server/app/review/page.js +1 -1
  272. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  273. package/.next/server/app/sessions/page.js +1 -1
  274. package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  275. package/.next/server/app/skills/[skillId]/page_client-reference-manifest.js +1 -1
  276. package/.next/server/app/skills/installed/page_client-reference-manifest.js +1 -1
  277. package/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  278. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
  279. package/.next/server/app/worktrees/[id]/page.js +2 -2
  280. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
  281. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
  282. package/.next/server/app-paths-manifest.json +37 -27
  283. package/.next/server/chunks/1068.js +1 -1
  284. package/.next/server/chunks/1117.js +1 -1
  285. package/.next/server/chunks/1503.js +2 -0
  286. package/.next/server/chunks/2366.js +1 -0
  287. package/.next/server/chunks/3042.js +1 -1
  288. package/.next/server/chunks/3736.js +1 -1
  289. package/.next/server/chunks/4444.js +1 -1
  290. package/.next/server/chunks/4689.js +25 -0
  291. package/.next/server/chunks/5381.js +50 -10
  292. package/.next/server/chunks/5959.js +3 -3
  293. package/.next/server/chunks/6130.js +1 -1
  294. package/.next/server/chunks/6274.js +13 -0
  295. package/.next/server/chunks/646.js +1 -1
  296. package/.next/server/chunks/8681.js +1 -1
  297. package/.next/server/chunks/8807.js +192 -51
  298. package/.next/server/chunks/8856.js +4 -0
  299. package/.next/server/chunks/9687.js +2 -2
  300. package/.next/server/middleware-manifest.json +5 -5
  301. package/.next/server/pages/500.html +1 -1
  302. package/.next/server/server-reference-manifest.json +1 -1
  303. package/.next/static/chunks/{4560-8ffb0bb19f2ba998.js → 4560-0917ae2e6a0e5400.js} +1 -1
  304. package/.next/static/chunks/{6488-c2a968ec806975c2.js → 6488-f4e447464c9e0e22.js} +1 -1
  305. package/.next/static/chunks/app/api/app/update/route-8440b6c72bed83a1.js +1 -0
  306. package/.next/static/chunks/app/api/app/update-check/route-8440b6c72bed83a1.js +1 -0
  307. package/.next/static/chunks/app/api/assistant/conversation/route-8440b6c72bed83a1.js +1 -0
  308. package/.next/static/chunks/app/api/assistant/current-output/route-8440b6c72bed83a1.js +1 -0
  309. package/.next/static/chunks/app/api/assistant/messages/route-8440b6c72bed83a1.js +1 -0
  310. package/.next/static/chunks/app/api/assistant/session/route-8440b6c72bed83a1.js +1 -0
  311. package/.next/static/chunks/app/api/assistant/start/route-8440b6c72bed83a1.js +1 -0
  312. package/.next/static/chunks/app/api/assistant/terminal/route-8440b6c72bed83a1.js +1 -0
  313. package/.next/static/chunks/app/api/assistant/tools/route-8440b6c72bed83a1.js +1 -0
  314. package/.next/static/chunks/app/api/auth/login/route-8440b6c72bed83a1.js +1 -0
  315. package/.next/static/chunks/app/api/auth/logout/route-8440b6c72bed83a1.js +1 -0
  316. package/.next/static/chunks/app/api/auth/status/route-8440b6c72bed83a1.js +1 -0
  317. package/.next/static/chunks/app/api/daily-summary/route-8440b6c72bed83a1.js +1 -0
  318. package/.next/static/chunks/app/api/daily-summary/status/route-8440b6c72bed83a1.js +1 -0
  319. package/.next/static/chunks/app/api/external-apps/[id]/health/route-8440b6c72bed83a1.js +1 -0
  320. package/.next/static/chunks/app/api/external-apps/[id]/route-8440b6c72bed83a1.js +1 -0
  321. package/.next/static/chunks/app/api/external-apps/route-8440b6c72bed83a1.js +1 -0
  322. package/.next/static/chunks/app/api/fs/browse/route-8440b6c72bed83a1.js +1 -0
  323. package/.next/static/chunks/app/api/fs/recent-paths/route-8440b6c72bed83a1.js +1 -0
  324. package/.next/static/chunks/app/api/hooks/agent-event/route-8440b6c72bed83a1.js +1 -0
  325. package/.next/static/chunks/app/api/hooks/claude-done/route-8440b6c72bed83a1.js +1 -0
  326. package/.next/static/chunks/app/api/metrics/vibe/route-8440b6c72bed83a1.js +1 -0
  327. package/.next/static/chunks/app/api/ollama/models/route-8440b6c72bed83a1.js +1 -0
  328. package/.next/static/chunks/app/api/push/subscriptions/route-8440b6c72bed83a1.js +1 -0
  329. package/.next/static/chunks/app/api/push/vapid/route-8440b6c72bed83a1.js +1 -0
  330. package/.next/static/chunks/app/api/repositories/[id]/route-8440b6c72bed83a1.js +1 -0
  331. package/.next/static/chunks/app/api/repositories/[id]/todos/[todoId]/route-8440b6c72bed83a1.js +1 -0
  332. package/.next/static/chunks/app/api/repositories/[id]/todos/route-8440b6c72bed83a1.js +1 -0
  333. package/.next/static/chunks/app/api/repositories/clone/[jobId]/route-8440b6c72bed83a1.js +1 -0
  334. package/.next/static/chunks/app/api/repositories/clone/route-8440b6c72bed83a1.js +1 -0
  335. package/.next/static/chunks/app/api/repositories/excluded/route-8440b6c72bed83a1.js +1 -0
  336. package/.next/static/chunks/app/api/repositories/restore/route-8440b6c72bed83a1.js +1 -0
  337. package/.next/static/chunks/app/api/repositories/route-8440b6c72bed83a1.js +1 -0
  338. package/.next/static/chunks/app/api/repositories/scan/route-8440b6c72bed83a1.js +1 -0
  339. package/.next/static/chunks/app/api/repositories/sync/route-8440b6c72bed83a1.js +1 -0
  340. package/.next/static/chunks/app/api/repositories/validate-path/route-8440b6c72bed83a1.js +1 -0
  341. package/.next/static/chunks/app/api/sidebar/group-order/route-8440b6c72bed83a1.js +1 -0
  342. package/.next/static/chunks/app/api/skills/[id]/route-8440b6c72bed83a1.js +1 -0
  343. package/.next/static/chunks/app/api/skills/installations/route-8440b6c72bed83a1.js +1 -0
  344. package/.next/static/chunks/app/api/skills/operations/route-8440b6c72bed83a1.js +1 -0
  345. package/.next/static/chunks/app/api/skills/reindex/route-8440b6c72bed83a1.js +1 -0
  346. package/.next/static/chunks/app/api/skills/route-8440b6c72bed83a1.js +1 -0
  347. package/.next/static/chunks/app/api/slash-commands/route-8440b6c72bed83a1.js +1 -0
  348. package/.next/static/chunks/app/api/tasks/[taskId]/cancel/route-8440b6c72bed83a1.js +1 -0
  349. package/.next/static/chunks/app/api/tasks/[taskId]/route-8440b6c72bed83a1.js +1 -0
  350. package/.next/static/chunks/app/api/templates/[id]/route-8440b6c72bed83a1.js +1 -0
  351. package/.next/static/chunks/app/api/templates/route-8440b6c72bed83a1.js +1 -0
  352. package/.next/static/chunks/app/api/todos/route-8440b6c72bed83a1.js +1 -0
  353. package/.next/static/chunks/app/api/verification/runs/[runId]/route-8440b6c72bed83a1.js +1 -0
  354. package/.next/static/chunks/app/api/verification/runs/route-8440b6c72bed83a1.js +1 -0
  355. package/.next/static/chunks/app/api/worktrees/[id]/auto-yes/route-8440b6c72bed83a1.js +1 -0
  356. package/.next/static/chunks/app/api/worktrees/[id]/capture/route-8440b6c72bed83a1.js +1 -0
  357. package/.next/static/chunks/app/api/worktrees/[id]/cli-tool/route-8440b6c72bed83a1.js +1 -0
  358. package/.next/static/chunks/app/api/worktrees/[id]/cmate/schedules/route-8440b6c72bed83a1.js +1 -0
  359. package/.next/static/chunks/app/api/worktrees/[id]/current-output/route-8440b6c72bed83a1.js +1 -0
  360. package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/[logId]/route-8440b6c72bed83a1.js +1 -0
  361. package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/route-8440b6c72bed83a1.js +1 -0
  362. package/.next/static/chunks/app/api/worktrees/[id]/files/[...path]/route-8440b6c72bed83a1.js +1 -0
  363. package/.next/static/chunks/app/api/worktrees/[id]/git/branch/create/route-8440b6c72bed83a1.js +1 -0
  364. package/.next/static/chunks/app/api/worktrees/[id]/git/branch/delete/route-8440b6c72bed83a1.js +1 -0
  365. package/.next/static/chunks/app/api/worktrees/[id]/git/branches/route-8440b6c72bed83a1.js +1 -0
  366. package/.next/static/chunks/app/api/worktrees/[id]/git/checkout/route-8440b6c72bed83a1.js +1 -0
  367. package/.next/static/chunks/app/api/worktrees/[id]/git/commit/route-8440b6c72bed83a1.js +1 -0
  368. package/.next/static/chunks/app/api/worktrees/[id]/git/diff/route-8440b6c72bed83a1.js +1 -0
  369. package/.next/static/chunks/app/api/worktrees/[id]/git/fetch/route-8440b6c72bed83a1.js +1 -0
  370. package/.next/static/chunks/app/api/worktrees/[id]/git/log/route-8440b6c72bed83a1.js +1 -0
  371. package/.next/static/chunks/app/api/worktrees/[id]/git/pull/route-8440b6c72bed83a1.js +1 -0
  372. package/.next/static/chunks/app/api/worktrees/[id]/git/push/route-8440b6c72bed83a1.js +1 -0
  373. package/.next/static/chunks/app/api/worktrees/[id]/git/reset/route-8440b6c72bed83a1.js +1 -0
  374. package/.next/static/chunks/app/api/worktrees/[id]/git/revert/route-8440b6c72bed83a1.js +1 -0
  375. package/.next/static/chunks/app/api/worktrees/[id]/git/show/[commitHash]/route-8440b6c72bed83a1.js +1 -0
  376. package/.next/static/chunks/app/api/worktrees/[id]/git/stage/route-8440b6c72bed83a1.js +1 -0
  377. package/.next/static/chunks/app/api/worktrees/[id]/git/staged/route-8440b6c72bed83a1.js +1 -0
  378. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/[index]/route-8440b6c72bed83a1.js +1 -0
  379. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/apply/route-8440b6c72bed83a1.js +1 -0
  380. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/pop/route-8440b6c72bed83a1.js +1 -0
  381. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/push/route-8440b6c72bed83a1.js +1 -0
  382. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/route-8440b6c72bed83a1.js +1 -0
  383. package/.next/static/chunks/app/api/worktrees/[id]/git/status/route-8440b6c72bed83a1.js +1 -0
  384. package/.next/static/chunks/app/api/worktrees/[id]/git/unstage/route-8440b6c72bed83a1.js +1 -0
  385. package/.next/static/chunks/app/api/worktrees/[id]/git/working-diff/route-8440b6c72bed83a1.js +1 -0
  386. package/.next/static/chunks/app/api/worktrees/[id]/interrupt/route-8440b6c72bed83a1.js +1 -0
  387. package/.next/static/chunks/app/api/worktrees/[id]/kill-session/route-8440b6c72bed83a1.js +1 -0
  388. package/.next/static/chunks/app/api/worktrees/[id]/logs/[filename]/route-8440b6c72bed83a1.js +1 -0
  389. package/.next/static/chunks/app/api/worktrees/[id]/logs/route-8440b6c72bed83a1.js +1 -0
  390. package/.next/static/chunks/app/api/worktrees/[id]/marp-render/route-8440b6c72bed83a1.js +1 -0
  391. package/.next/static/chunks/app/api/worktrees/[id]/memos/[memoId]/route-8440b6c72bed83a1.js +1 -0
  392. package/.next/static/chunks/app/api/worktrees/[id]/memos/route-8440b6c72bed83a1.js +1 -0
  393. package/.next/static/chunks/app/api/worktrees/[id]/messages/route-8440b6c72bed83a1.js +1 -0
  394. package/.next/static/chunks/app/api/worktrees/[id]/prompt-response/route-8440b6c72bed83a1.js +1 -0
  395. package/.next/static/chunks/app/api/worktrees/[id]/respond/route-8440b6c72bed83a1.js +1 -0
  396. package/.next/static/chunks/app/api/worktrees/[id]/route-8440b6c72bed83a1.js +1 -0
  397. package/.next/static/chunks/app/api/worktrees/[id]/schedules/[scheduleId]/route-8440b6c72bed83a1.js +1 -0
  398. package/.next/static/chunks/app/api/worktrees/[id]/schedules/active/route-8440b6c72bed83a1.js +1 -0
  399. package/.next/static/chunks/app/api/worktrees/[id]/schedules/route-8440b6c72bed83a1.js +1 -0
  400. package/.next/static/chunks/app/api/worktrees/[id]/search/route-8440b6c72bed83a1.js +1 -0
  401. package/.next/static/chunks/app/api/worktrees/[id]/send/route-8440b6c72bed83a1.js +1 -0
  402. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route-8440b6c72bed83a1.js +1 -0
  403. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/install/route-8440b6c72bed83a1.js +1 -0
  404. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/plan/route-8440b6c72bed83a1.js +1 -0
  405. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall/route-8440b6c72bed83a1.js +1 -0
  406. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route-8440b6c72bed83a1.js +1 -0
  407. package/.next/static/chunks/app/api/worktrees/[id]/skills/route-8440b6c72bed83a1.js +1 -0
  408. package/.next/static/chunks/app/api/worktrees/[id]/slash-commands/route-8440b6c72bed83a1.js +1 -0
  409. package/.next/static/chunks/app/api/worktrees/[id]/special-keys/route-8440b6c72bed83a1.js +1 -0
  410. package/.next/static/chunks/app/api/worktrees/[id]/start-polling/route-8440b6c72bed83a1.js +1 -0
  411. package/.next/static/chunks/app/api/worktrees/[id]/tasks/route-8440b6c72bed83a1.js +1 -0
  412. package/.next/static/chunks/app/api/worktrees/[id]/terminal/route-8440b6c72bed83a1.js +1 -0
  413. package/.next/static/chunks/app/api/worktrees/[id]/timers/history/route-8440b6c72bed83a1.js +1 -0
  414. package/.next/static/chunks/app/api/worktrees/[id]/timers/route-8440b6c72bed83a1.js +1 -0
  415. package/.next/static/chunks/app/api/worktrees/[id]/todos/[todoId]/route-8440b6c72bed83a1.js +1 -0
  416. package/.next/static/chunks/app/api/worktrees/[id]/todos/route-8440b6c72bed83a1.js +1 -0
  417. package/.next/static/chunks/app/api/worktrees/[id]/tree/[...path]/route-8440b6c72bed83a1.js +1 -0
  418. package/.next/static/chunks/app/api/worktrees/[id]/tree/route-8440b6c72bed83a1.js +1 -0
  419. package/.next/static/chunks/app/api/worktrees/[id]/upload/[...path]/route-8440b6c72bed83a1.js +1 -0
  420. package/.next/static/chunks/app/api/worktrees/[id]/verify/route-8440b6c72bed83a1.js +1 -0
  421. package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/[runId]/route-8440b6c72bed83a1.js +1 -0
  422. package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/route-8440b6c72bed83a1.js +1 -0
  423. package/.next/static/chunks/app/api/worktrees/[id]/viewed/route-8440b6c72bed83a1.js +1 -0
  424. package/.next/static/chunks/app/api/worktrees/route-8440b6c72bed83a1.js +1 -0
  425. package/.next/static/chunks/app/manifest.webmanifest/route-8440b6c72bed83a1.js +1 -0
  426. package/.next/static/chunks/app/proxy/[...path]/route-8440b6c72bed83a1.js +1 -0
  427. package/.next/static/chunks/app/repositories/page-1ed1e5a542ecc168.js +1 -0
  428. package/.next/static/chunks/app/review/{page-f431d630097c2e85.js → page-b559bfb11c46931b.js} +1 -1
  429. package/.next/static/chunks/app/sessions/{page-20f07a99db64d2ca.js → page-3fa7e767d0ab3889.js} +1 -1
  430. package/.next/static/chunks/app/worktrees/[id]/page-5ffc84094830babb.js +1 -0
  431. package/.next/static/gR8Sh86RrTynJON8SWkWK/_buildManifest.js +1 -0
  432. package/.next/trace +12 -11
  433. package/.next/types/app/api/hooks/agent-event/route.ts +347 -0
  434. package/.next/types/app/api/metrics/vibe/route.ts +347 -0
  435. package/.next/types/app/api/tasks/[taskId]/cancel/route.ts +347 -0
  436. package/.next/types/app/api/tasks/[taskId]/route.ts +347 -0
  437. package/.next/types/app/api/verification/runs/[runId]/route.ts +347 -0
  438. package/.next/types/app/api/verification/runs/route.ts +347 -0
  439. package/.next/types/app/api/worktrees/[id]/tasks/route.ts +347 -0
  440. package/.next/types/app/api/worktrees/[id]/verify/route.ts +347 -0
  441. package/.next/types/app/api/worktrees/[id]/verify/runs/[runId]/route.ts +347 -0
  442. package/.next/types/app/api/worktrees/[id]/verify/runs/route.ts +347 -0
  443. package/.next/types/routes.d.ts +11 -1
  444. package/.next/types/validator.ts +90 -0
  445. package/dist/cli/commands/report.d.ts +1 -0
  446. package/dist/cli/commands/report.d.ts.map +1 -1
  447. package/dist/cli/commands/report.js +54 -0
  448. package/dist/cli/commands/send.d.ts.map +1 -1
  449. package/dist/cli/commands/send.js +86 -3
  450. package/dist/cli/commands/task.d.ts +11 -0
  451. package/dist/cli/commands/task.d.ts.map +1 -0
  452. package/dist/cli/commands/task.js +126 -0
  453. package/dist/cli/commands/verify.d.ts +19 -0
  454. package/dist/cli/commands/verify.d.ts.map +1 -0
  455. package/dist/cli/commands/verify.js +229 -0
  456. package/dist/cli/commands/wait.d.ts +2 -0
  457. package/dist/cli/commands/wait.d.ts.map +1 -1
  458. package/dist/cli/commands/wait.js +78 -13
  459. package/dist/cli/docs/agent-operations.d.ts +2 -2
  460. package/dist/cli/docs/agent-operations.d.ts.map +1 -1
  461. package/dist/cli/docs/agent-operations.js +92 -3
  462. package/dist/cli/program.d.ts.map +1 -1
  463. package/dist/cli/program.js +6 -0
  464. package/dist/cli/types/api-responses.d.ts +170 -0
  465. package/dist/cli/types/api-responses.d.ts.map +1 -1
  466. package/dist/cli/types/index.d.ts +82 -0
  467. package/dist/cli/types/index.d.ts.map +1 -1
  468. package/dist/cli/types/index.js +30 -1
  469. package/dist/cli/utils/api-client.d.ts +8 -0
  470. package/dist/cli/utils/api-client.d.ts.map +1 -1
  471. package/dist/cli/utils/verify-runner.d.ts +57 -0
  472. package/dist/cli/utils/verify-runner.d.ts.map +1 -0
  473. package/dist/cli/utils/verify-runner.js +174 -0
  474. package/dist/server/server.js +15 -0
  475. package/dist/server/src/config/auto-yes-config.js +22 -0
  476. package/dist/server/src/lib/auto-yes-poller.js +34 -2
  477. package/dist/server/src/lib/auto-yes-state.js +6 -19
  478. package/dist/server/src/lib/db/db.js +34 -1
  479. package/dist/server/src/lib/db/migrations/index.js +6 -0
  480. package/dist/server/src/lib/db/migrations/runner.js +1 -1
  481. package/dist/server/src/lib/db/migrations/v49-verification-runs.js +86 -0
  482. package/dist/server/src/lib/db/migrations/v50-tasks.js +68 -0
  483. package/dist/server/src/lib/db/migrations/v51-task-events.js +58 -0
  484. package/dist/server/src/lib/db/task-events-db.js +59 -0
  485. package/dist/server/src/lib/db/tasks-db.js +218 -0
  486. package/dist/server/src/lib/db/verification-db.js +272 -0
  487. package/dist/server/src/lib/polling/auto-yes-policy.js +117 -0
  488. package/dist/server/src/lib/polling/auto-yes-resolver.js +144 -4
  489. package/dist/server/src/lib/polling/response-checker.js +8 -0
  490. package/dist/server/src/lib/session/agent-event-state.js +46 -0
  491. package/dist/server/src/lib/session/current-output-builder.js +4 -0
  492. package/dist/server/src/lib/session/status-mapping.js +146 -0
  493. package/dist/server/src/lib/tasks/contract-parser.js +385 -0
  494. package/dist/server/src/lib/tasks/task-state-machine.js +183 -0
  495. package/dist/server/src/lib/tasks/task-transition-service.js +106 -0
  496. package/dist/server/src/lib/verification/verification-reconciler.js +49 -0
  497. package/dist/server/src/types/sidebar.js +7 -20
  498. package/package.json +5 -2
  499. package/scripts/hooks/cmate-agent-event.sh +175 -0
  500. package/.next/server/chunks/2064.js +0 -2
  501. package/.next/static/AKqbAyuzbFfg05qpbCI_K/_buildManifest.js +0 -1
  502. package/.next/static/chunks/app/api/app/update/route-55e398bd20e2d7a9.js +0 -1
  503. package/.next/static/chunks/app/api/app/update-check/route-55e398bd20e2d7a9.js +0 -1
  504. package/.next/static/chunks/app/api/assistant/conversation/route-55e398bd20e2d7a9.js +0 -1
  505. package/.next/static/chunks/app/api/assistant/current-output/route-55e398bd20e2d7a9.js +0 -1
  506. package/.next/static/chunks/app/api/assistant/messages/route-55e398bd20e2d7a9.js +0 -1
  507. package/.next/static/chunks/app/api/assistant/session/route-55e398bd20e2d7a9.js +0 -1
  508. package/.next/static/chunks/app/api/assistant/start/route-55e398bd20e2d7a9.js +0 -1
  509. package/.next/static/chunks/app/api/assistant/terminal/route-55e398bd20e2d7a9.js +0 -1
  510. package/.next/static/chunks/app/api/assistant/tools/route-55e398bd20e2d7a9.js +0 -1
  511. package/.next/static/chunks/app/api/auth/login/route-55e398bd20e2d7a9.js +0 -1
  512. package/.next/static/chunks/app/api/auth/logout/route-55e398bd20e2d7a9.js +0 -1
  513. package/.next/static/chunks/app/api/auth/status/route-55e398bd20e2d7a9.js +0 -1
  514. package/.next/static/chunks/app/api/daily-summary/route-55e398bd20e2d7a9.js +0 -1
  515. package/.next/static/chunks/app/api/daily-summary/status/route-55e398bd20e2d7a9.js +0 -1
  516. package/.next/static/chunks/app/api/external-apps/[id]/health/route-55e398bd20e2d7a9.js +0 -1
  517. package/.next/static/chunks/app/api/external-apps/[id]/route-55e398bd20e2d7a9.js +0 -1
  518. package/.next/static/chunks/app/api/external-apps/route-55e398bd20e2d7a9.js +0 -1
  519. package/.next/static/chunks/app/api/fs/browse/route-55e398bd20e2d7a9.js +0 -1
  520. package/.next/static/chunks/app/api/fs/recent-paths/route-55e398bd20e2d7a9.js +0 -1
  521. package/.next/static/chunks/app/api/hooks/claude-done/route-55e398bd20e2d7a9.js +0 -1
  522. package/.next/static/chunks/app/api/ollama/models/route-55e398bd20e2d7a9.js +0 -1
  523. package/.next/static/chunks/app/api/push/subscriptions/route-55e398bd20e2d7a9.js +0 -1
  524. package/.next/static/chunks/app/api/push/vapid/route-55e398bd20e2d7a9.js +0 -1
  525. package/.next/static/chunks/app/api/repositories/[id]/route-55e398bd20e2d7a9.js +0 -1
  526. package/.next/static/chunks/app/api/repositories/[id]/todos/[todoId]/route-55e398bd20e2d7a9.js +0 -1
  527. package/.next/static/chunks/app/api/repositories/[id]/todos/route-55e398bd20e2d7a9.js +0 -1
  528. package/.next/static/chunks/app/api/repositories/clone/[jobId]/route-55e398bd20e2d7a9.js +0 -1
  529. package/.next/static/chunks/app/api/repositories/clone/route-55e398bd20e2d7a9.js +0 -1
  530. package/.next/static/chunks/app/api/repositories/excluded/route-55e398bd20e2d7a9.js +0 -1
  531. package/.next/static/chunks/app/api/repositories/restore/route-55e398bd20e2d7a9.js +0 -1
  532. package/.next/static/chunks/app/api/repositories/route-55e398bd20e2d7a9.js +0 -1
  533. package/.next/static/chunks/app/api/repositories/scan/route-55e398bd20e2d7a9.js +0 -1
  534. package/.next/static/chunks/app/api/repositories/sync/route-55e398bd20e2d7a9.js +0 -1
  535. package/.next/static/chunks/app/api/repositories/validate-path/route-55e398bd20e2d7a9.js +0 -1
  536. package/.next/static/chunks/app/api/sidebar/group-order/route-55e398bd20e2d7a9.js +0 -1
  537. package/.next/static/chunks/app/api/skills/[id]/route-55e398bd20e2d7a9.js +0 -1
  538. package/.next/static/chunks/app/api/skills/installations/route-55e398bd20e2d7a9.js +0 -1
  539. package/.next/static/chunks/app/api/skills/operations/route-55e398bd20e2d7a9.js +0 -1
  540. package/.next/static/chunks/app/api/skills/reindex/route-55e398bd20e2d7a9.js +0 -1
  541. package/.next/static/chunks/app/api/skills/route-55e398bd20e2d7a9.js +0 -1
  542. package/.next/static/chunks/app/api/slash-commands/route-55e398bd20e2d7a9.js +0 -1
  543. package/.next/static/chunks/app/api/templates/[id]/route-55e398bd20e2d7a9.js +0 -1
  544. package/.next/static/chunks/app/api/templates/route-55e398bd20e2d7a9.js +0 -1
  545. package/.next/static/chunks/app/api/todos/route-55e398bd20e2d7a9.js +0 -1
  546. package/.next/static/chunks/app/api/worktrees/[id]/auto-yes/route-55e398bd20e2d7a9.js +0 -1
  547. package/.next/static/chunks/app/api/worktrees/[id]/capture/route-55e398bd20e2d7a9.js +0 -1
  548. package/.next/static/chunks/app/api/worktrees/[id]/cli-tool/route-55e398bd20e2d7a9.js +0 -1
  549. package/.next/static/chunks/app/api/worktrees/[id]/cmate/schedules/route-55e398bd20e2d7a9.js +0 -1
  550. package/.next/static/chunks/app/api/worktrees/[id]/current-output/route-55e398bd20e2d7a9.js +0 -1
  551. package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/[logId]/route-55e398bd20e2d7a9.js +0 -1
  552. package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/route-55e398bd20e2d7a9.js +0 -1
  553. package/.next/static/chunks/app/api/worktrees/[id]/files/[...path]/route-55e398bd20e2d7a9.js +0 -1
  554. package/.next/static/chunks/app/api/worktrees/[id]/git/branch/create/route-55e398bd20e2d7a9.js +0 -1
  555. package/.next/static/chunks/app/api/worktrees/[id]/git/branch/delete/route-55e398bd20e2d7a9.js +0 -1
  556. package/.next/static/chunks/app/api/worktrees/[id]/git/branches/route-55e398bd20e2d7a9.js +0 -1
  557. package/.next/static/chunks/app/api/worktrees/[id]/git/checkout/route-55e398bd20e2d7a9.js +0 -1
  558. package/.next/static/chunks/app/api/worktrees/[id]/git/commit/route-55e398bd20e2d7a9.js +0 -1
  559. package/.next/static/chunks/app/api/worktrees/[id]/git/diff/route-55e398bd20e2d7a9.js +0 -1
  560. package/.next/static/chunks/app/api/worktrees/[id]/git/fetch/route-55e398bd20e2d7a9.js +0 -1
  561. package/.next/static/chunks/app/api/worktrees/[id]/git/log/route-55e398bd20e2d7a9.js +0 -1
  562. package/.next/static/chunks/app/api/worktrees/[id]/git/pull/route-55e398bd20e2d7a9.js +0 -1
  563. package/.next/static/chunks/app/api/worktrees/[id]/git/push/route-55e398bd20e2d7a9.js +0 -1
  564. package/.next/static/chunks/app/api/worktrees/[id]/git/reset/route-55e398bd20e2d7a9.js +0 -1
  565. package/.next/static/chunks/app/api/worktrees/[id]/git/revert/route-55e398bd20e2d7a9.js +0 -1
  566. package/.next/static/chunks/app/api/worktrees/[id]/git/show/[commitHash]/route-55e398bd20e2d7a9.js +0 -1
  567. package/.next/static/chunks/app/api/worktrees/[id]/git/stage/route-55e398bd20e2d7a9.js +0 -1
  568. package/.next/static/chunks/app/api/worktrees/[id]/git/staged/route-55e398bd20e2d7a9.js +0 -1
  569. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/[index]/route-55e398bd20e2d7a9.js +0 -1
  570. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/apply/route-55e398bd20e2d7a9.js +0 -1
  571. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/pop/route-55e398bd20e2d7a9.js +0 -1
  572. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/push/route-55e398bd20e2d7a9.js +0 -1
  573. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/route-55e398bd20e2d7a9.js +0 -1
  574. package/.next/static/chunks/app/api/worktrees/[id]/git/status/route-55e398bd20e2d7a9.js +0 -1
  575. package/.next/static/chunks/app/api/worktrees/[id]/git/unstage/route-55e398bd20e2d7a9.js +0 -1
  576. package/.next/static/chunks/app/api/worktrees/[id]/git/working-diff/route-55e398bd20e2d7a9.js +0 -1
  577. package/.next/static/chunks/app/api/worktrees/[id]/interrupt/route-55e398bd20e2d7a9.js +0 -1
  578. package/.next/static/chunks/app/api/worktrees/[id]/kill-session/route-55e398bd20e2d7a9.js +0 -1
  579. package/.next/static/chunks/app/api/worktrees/[id]/logs/[filename]/route-55e398bd20e2d7a9.js +0 -1
  580. package/.next/static/chunks/app/api/worktrees/[id]/logs/route-55e398bd20e2d7a9.js +0 -1
  581. package/.next/static/chunks/app/api/worktrees/[id]/marp-render/route-55e398bd20e2d7a9.js +0 -1
  582. package/.next/static/chunks/app/api/worktrees/[id]/memos/[memoId]/route-55e398bd20e2d7a9.js +0 -1
  583. package/.next/static/chunks/app/api/worktrees/[id]/memos/route-55e398bd20e2d7a9.js +0 -1
  584. package/.next/static/chunks/app/api/worktrees/[id]/messages/route-55e398bd20e2d7a9.js +0 -1
  585. package/.next/static/chunks/app/api/worktrees/[id]/prompt-response/route-55e398bd20e2d7a9.js +0 -1
  586. package/.next/static/chunks/app/api/worktrees/[id]/respond/route-55e398bd20e2d7a9.js +0 -1
  587. package/.next/static/chunks/app/api/worktrees/[id]/route-55e398bd20e2d7a9.js +0 -1
  588. package/.next/static/chunks/app/api/worktrees/[id]/schedules/[scheduleId]/route-55e398bd20e2d7a9.js +0 -1
  589. package/.next/static/chunks/app/api/worktrees/[id]/schedules/active/route-55e398bd20e2d7a9.js +0 -1
  590. package/.next/static/chunks/app/api/worktrees/[id]/schedules/route-55e398bd20e2d7a9.js +0 -1
  591. package/.next/static/chunks/app/api/worktrees/[id]/search/route-55e398bd20e2d7a9.js +0 -1
  592. package/.next/static/chunks/app/api/worktrees/[id]/send/route-55e398bd20e2d7a9.js +0 -1
  593. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route-55e398bd20e2d7a9.js +0 -1
  594. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/install/route-55e398bd20e2d7a9.js +0 -1
  595. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/plan/route-55e398bd20e2d7a9.js +0 -1
  596. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall/route-55e398bd20e2d7a9.js +0 -1
  597. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route-55e398bd20e2d7a9.js +0 -1
  598. package/.next/static/chunks/app/api/worktrees/[id]/skills/route-55e398bd20e2d7a9.js +0 -1
  599. package/.next/static/chunks/app/api/worktrees/[id]/slash-commands/route-55e398bd20e2d7a9.js +0 -1
  600. package/.next/static/chunks/app/api/worktrees/[id]/special-keys/route-55e398bd20e2d7a9.js +0 -1
  601. package/.next/static/chunks/app/api/worktrees/[id]/start-polling/route-55e398bd20e2d7a9.js +0 -1
  602. package/.next/static/chunks/app/api/worktrees/[id]/terminal/route-55e398bd20e2d7a9.js +0 -1
  603. package/.next/static/chunks/app/api/worktrees/[id]/timers/history/route-55e398bd20e2d7a9.js +0 -1
  604. package/.next/static/chunks/app/api/worktrees/[id]/timers/route-55e398bd20e2d7a9.js +0 -1
  605. package/.next/static/chunks/app/api/worktrees/[id]/todos/[todoId]/route-55e398bd20e2d7a9.js +0 -1
  606. package/.next/static/chunks/app/api/worktrees/[id]/todos/route-55e398bd20e2d7a9.js +0 -1
  607. package/.next/static/chunks/app/api/worktrees/[id]/tree/[...path]/route-55e398bd20e2d7a9.js +0 -1
  608. package/.next/static/chunks/app/api/worktrees/[id]/tree/route-55e398bd20e2d7a9.js +0 -1
  609. package/.next/static/chunks/app/api/worktrees/[id]/upload/[...path]/route-55e398bd20e2d7a9.js +0 -1
  610. package/.next/static/chunks/app/api/worktrees/[id]/viewed/route-55e398bd20e2d7a9.js +0 -1
  611. package/.next/static/chunks/app/api/worktrees/route-55e398bd20e2d7a9.js +0 -1
  612. package/.next/static/chunks/app/manifest.webmanifest/route-55e398bd20e2d7a9.js +0 -1
  613. package/.next/static/chunks/app/proxy/[...path]/route-55e398bd20e2d7a9.js +0 -1
  614. package/.next/static/chunks/app/repositories/page-3c4fb889da48ce24.js +0 -1
  615. package/.next/static/chunks/app/worktrees/[id]/page-59a63a2c013ec1eb.js +0 -1
  616. /package/.next/static/{AKqbAyuzbFfg05qpbCI_K → gR8Sh86RrTynJON8SWkWK}/_ssgManifest.js +0 -0
@@ -17,7 +17,7 @@ document.addEventListener('click', function(e) {
17
17
  }, '*');
18
18
  }
19
19
  });
20
- </script>`;function aV({htmlContent:a,filePath:b}){let[c,d]=(0,h.useState)("preview"),[f,g]=(0,h.useState)("safe"),i=(0,h.useRef)(new Set),j=(0,k.c)("worktree"),l=(0,am.SC)(),m=(0,h.useCallback)(async a=>{if("interactive"===a&&!i.current.has(b)){if(!await l({description:j("htmlPreview.interactiveModeConfirm")}))return;i.current.add(b)}g(a)},[b,l,j]),n=(0,h.useMemo)(()=>"interactive"!==f?a:a.includes("</body>")?a.replace("</body>",`${aU}</body>`):a+aU,[a,f]),o=(0,h.useMemo)(()=>{try{return aO.highlight(a,{language:"html",ignoreIllegals:!0}).value}catch{return aO.highlightAuto(a).value}},[a]),p=(0,h.useMemo)(()=>Array.from({length:a.split("\n").length},(a,b)=>b+1),[a]),q=(0,h.useMemo)(()=>o.split("\n"),[o]);return(0,e.jsxs)("div",{className:"flex flex-col h-full","data-testid":"html-preview-mobile",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border bg-muted",children:[(0,e.jsx)("div",{className:"flex gap-1",children:["source","preview"].map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>d(a),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${c===a?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"}`,children:"source"===a?j("fileViewer.tabSource"):j("fileViewer.tabPreview")},a))}),(0,e.jsx)("div",{className:"flex gap-1",children:["safe","interactive"].map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>m(a),className:`px-2 py-1 text-xs font-medium rounded-md transition-colors ${f===a?"safe"===a?"bg-success-subtle text-success-foreground":"bg-warning-subtle text-warning-foreground":"text-muted-foreground hover:bg-muted"}`,children:"safe"===a?j("fileViewer.sandboxSafe"):j("fileViewer.sandboxInteractive")},a))})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto min-h-0",children:"source"===c?(0,e.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,e.jsx)("tbody",{children:p.map(a=>{let b=a-1;return(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{className:"pl-3 pr-2 text-right select-none font-mono border-r border-border bg-muted dark:bg-muted/50 sticky left-0 align-top whitespace-nowrap text-muted-foreground",children:a}),(0,e.jsx)("td",{className:"px-4 text-foreground align-top",children:(0,e.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono",children:(0,e.jsx)("code",{className:"hljs",dangerouslySetInnerHTML:{__html:q[b]??""}})})})]},a)})})}):(0,e.jsx)("iframe",{srcDoc:n,sandbox:ax[f],title:j("htmlPreview.title",{path:b}),className:"w-full h-full border-0 bg-white"},`${b}-${f}`)})]})}let aW=(0,h.memo)(function({isOpen:a,onClose:b,worktreeId:c,filePath:d,onFileSaved:f,onOpenFile:g}){let[i,j]=(0,h.useState)(null),[m,o]=(0,h.useState)(!1),[p,q]=(0,h.useState)(null),[r,s]=(0,h.useState)(!1),[t,u]=(0,h.useState)(!1),[v,w]=(0,h.useState)(null),[x,y]=(0,h.useState)(0),[z,A]=(0,h.useState)(!1),[B,C]=(0,h.useState)("viewer"),[D,E]=(0,h.useState)(!1),[F,G]=(0,h.useState)(null),[H,I]=(0,h.useState)(!1),J=(0,h.useRef)(null),K=(0,k.c)("worktree"),L=(0,am.SC)(),M=i?F??i.content:void 0,{searchOpen:N,searchQuery:O,searchMatches:P,searchCurrentIdx:R,searchInputRef:S,openSearch:T,closeSearch:U,nextMatch:V,prevMatch:W,setSearchQuery:X}=aN(M),Y=(0,h.useMemo)(()=>!!(i?.content&&!i.isImage&&!i.isVideo&&!i.isPdf),[i]),Z=i?.extension==="md",$=(0,h.useCallback)(async()=>{if(Y&&M)try{await (0,ay.l)(M),s(!0),setTimeout(()=>s(!1),ah.pX)}catch{}},[Y,M]),_=(0,h.useCallback)(async()=>{try{await (0,ay.l)(d),u(!0),setTimeout(()=>u(!1),ah.pX)}catch{}},[d]),aa=(0,h.useCallback)(()=>{A(a=>!a)},[]);(0,h.useEffect)(()=>{if(0===P.length||!J.current)return;let a=P[R],b=J.current.querySelector(`[data-line="${a}"]`);b&&"function"==typeof b.scrollIntoView&&b.scrollIntoView({block:"center",behavior:"smooth"})},[R,P]),(0,h.useEffect)(()=>{if(!z||Z)return;let a=a=>{"Escape"===a.key&&A(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[z,Z]),(0,h.useEffect)(()=>{if(!a||!d){j(null),q(null),s(!1),C("viewer"),E(!1),G(null),I(!1),U();return}C("viewer"),E(!1),G(null),I(!1),(async()=>{o(!0),q(null);try{let a=await fetch(`/api/worktrees/${c}/files/${(0,aF.o)(d)}`);if(!a.ok){let b=await a.json(),c="string"==typeof b.error?b.error:b.error?.message||K("fileViewer.loadError");throw Error(c)}let b=await a.json();j(b)}catch(a){q(a instanceof Error?a.message:K("fileViewer.loadError"))}finally{o(!1)}})()},[a,c,d]),(0,h.useEffect)(()=>{w(null),y(0),i&&"md"===i.extension&&aS.test(i.content)&&!(i.content.length>1e6)&&(async()=>{try{let a=await fetch(`/api/worktrees/${c}/marp-render`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:i.content})});if(a.ok){let b=await a.json();w(b.slides)}}catch{}})()},[i,c]);let ab=!!(v&&v.length>0),ac=(0,h.useCallback)(a=>{G(a)},[]),ad=(0,h.useCallback)((a,b)=>{j(a=>a?{...a,content:b}:a),G(b),f?.(a)},[f]),ae=(0,h.useCallback)(async()=>{(!H||await L({description:K("editor.unsavedCloseConfirm"),variant:"danger"}))&&b()},[H,L,K,b]);(0,h.useEffect)(()=>{if(!Z||D)return;let a=a=>{"Escape"===a.key&&(N?U():z?A(!1):ae())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[Z,D,N,z,ae]);let[af,ag]=(0,h.useState)("");(0,h.useEffect)(()=>{"viewer"===B&&void 0!==M&&ag(M)},[B,M]),(0,h.useEffect)(()=>{if(!Z||!a)return;let b=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=b}},[Z,a]);let ai=(0,h.useMemo)(()=>{if(!i||void 0===M||i.isImage||i.isVideo||i.isHtml||i.isPdf)return null;let a=Array.from({length:M.split("\n").length},(a,b)=>b+1);try{return{lineNumbers:a,highlightedHtml:aO.highlight(M,{language:i.extension,ignoreIllegals:!0}).value}}catch{return{lineNumbers:a,highlightedHtml:aO.highlightAuto(M).value}}},[i,M]),aj=()=>i?i.isImage?(0,e.jsx)(an.a,{src:i.content,alt:i.path,mimeType:i.mimeType}):i.isVideo?(0,e.jsx)(ao.u,{src:i.content,mimeType:i.mimeType}):i.isPdf?(0,e.jsx)("div",{className:"h-full min-h-[40vh]",children:(0,e.jsx)(ap.n,{dataUri:i.content,filePath:d,variant:"download"})}):i.isHtml?(0,e.jsx)(aV,{htmlContent:i.content,filePath:d}):ak():null,ak=()=>{if(!ai)return null;let a=new Set(P),b=P.length>0?P[R]:-1,c=ai.highlightedHtml.split("\n");return(0,e.jsx)("div",{ref:J,children:(0,e.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,e.jsx)("tbody",{children:ai.lineNumbers.map(d=>{let f=d-1,g=d===b,h=a.has(d);return(0,e.jsxs)("tr",{"data-line":d,className:g?"bg-warning/30":h?"bg-warning/15":"",children:[(0,e.jsx)("td",{className:`pl-3 pr-2 text-right select-none font-mono border-r border-border bg-muted dark:bg-muted/50 sticky left-0 align-top whitespace-nowrap ${g||h?"text-warning-foreground":"text-muted-foreground"}`,children:d}),(0,e.jsx)("td",{className:"px-4 text-foreground align-top",children:(0,e.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono",children:(0,e.jsx)("code",{className:"hljs",dangerouslySetInnerHTML:{__html:c[f]??""}})})})]},d)})})})})},al=`/api/worktrees/${c}/files/${(0,aF.o)(d)}?download=1`,av=d?d.split("/").pop()||d:"",ax=(a,b=!1)=>(0,e.jsxs)("a",{"data-testid":"download-file-button",href:al,download:av,className:a,"aria-label":K("actions.downloadFile"),title:K("actions.download"),children:[(0,e.jsx)(au,{className:"w-3.5 h-3.5"}),b&&(0,e.jsx)("span",{children:K("actions.download")})]}),aG=()=>(0,e.jsxs)("div",{className:"bg-muted px-3 py-1.5 border-b border-border flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("button",{onClick:_,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":K("actions.copyFilePath"),title:K("actions.copyPath"),children:t?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:d})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[Y&&(0,e.jsx)("button",{onClick:T,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":K("actions.searchInFile"),title:K("actions.search"),children:(0,e.jsx)(Q.A,{className:"w-3.5 h-3.5"})}),Y&&(0,e.jsx)("button",{"data-testid":"copy-content-button",onClick:$,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":K("actions.copyFileContent"),title:K("actions.copyContent"),children:r?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(as,{className:"w-3.5 h-3.5"})}),ax("p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground"),(0,e.jsx)("button",{onClick:aa,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":z?K("actions.exitFullscreen"):K("actions.fullscreen"),title:z?K("actions.exitFullscreen"):K("actions.fullscreen"),children:z?(0,e.jsx)(aA,{className:"w-3.5 h-3.5"}):(0,e.jsx)(aB,{className:"w-3.5 h-3.5"})})]})]}),aH=()=>(0,e.jsx)(aT,{searchInputRef:S,searchQuery:O,searchMatches:P,searchCurrentIdx:R,onQueryChange:X,onPrev:W,onNext:V,onClose:U});if(Z&&i&&!m&&!p){let a=a=>`flex min-h-[44px] items-center justify-center gap-1 rounded-md px-2 text-xs font-medium touch-manipulation transition-colors ${a?"bg-surface shadow-sm text-accent-600 dark:text-accent-400":"text-muted-foreground hover:text-foreground"}`;return(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)("div",{"data-testid":"markdown-file-screen",role:"dialog","aria-modal":"true","aria-label":d,className:"fixed inset-0 flex h-[100dvh] flex-col bg-surface",style:{zIndex:aE.M.MAXIMIZED_EDITOR},children:[z?(0,e.jsxs)("div",{"data-testid":"markdown-file-immersive-controls",className:"absolute right-2 top-2 z-10 flex items-center gap-1 rounded-lg border border-border bg-surface/90 shadow-sm",children:[(0,e.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:aa,"aria-pressed":!0,"aria-label":K("actions.exitFullscreen"),className:aR,children:(0,e.jsx)(aA,{className:"h-5 w-5"})}),(0,e.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void ae(),"aria-label":K("actions.close"),className:aR,children:(0,e.jsx)(az.A,{className:"h-5 w-5"})})]}):(0,e.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-1 border-b border-border bg-muted px-2",children:[(0,e.jsx)("p",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:d}),(0,e.jsxs)("div",{"data-testid":"markdown-file-mode-switch",role:"group","aria-label":K("fileViewer.modeSwitch"),className:"flex flex-shrink-0 items-center gap-0.5 rounded-lg bg-muted p-0.5",children:[(0,e.jsxs)("button",{type:"button","data-testid":"markdown-file-mode-viewer","aria-pressed":"viewer"===B,onClick:()=>C("viewer"),className:a("viewer"===B),children:[(0,e.jsx)(aC,{className:"h-4 w-4"}),K("fileViewer.modeViewer")]}),(0,e.jsxs)("button",{type:"button","data-testid":"markdown-file-mode-editor","aria-pressed":"editor"===B,onClick:()=>C("editor"),className:a("editor"===B),children:[(0,e.jsx)(aD.A,{className:"h-4 w-4"}),K("fileViewer.modeEditor")]})]}),(0,e.jsx)("button",{type:"button","data-testid":"markdown-file-actions-trigger",onClick:()=>E(!0),"aria-label":K("fileViewer.moreActions"),className:aR,children:(0,e.jsx)(l.A,{className:"h-5 w-5"})}),(0,e.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:aa,"aria-pressed":!1,"aria-label":K("actions.fullscreen"),className:aR,children:(0,e.jsx)(aB,{className:"h-5 w-5"})}),(0,e.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void ae(),"aria-label":K("actions.close"),className:aR,children:(0,e.jsx)(az.A,{className:"h-5 w-5"})})]}),N&&(0,e.jsx)("div",{className:"flex-shrink-0",children:aH()}),(0,e.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,e.jsx)("div",{className:"viewer"===B?"flex min-h-0 flex-1 flex-col":"hidden",children:N?(0,e.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:ak()}):ab?v?(0,e.jsxs)("div",{className:"flex h-full flex-col",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-2 bg-muted border-b border-border",children:[(0,e.jsx)("button",{type:"button",onClick:()=>y(a=>Math.max(0,a-1)),disabled:0===x,className:"min-h-[44px] px-3 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors touch-manipulation",children:K("actions.prev")}),(0,e.jsxs)("span",{className:"text-sm text-muted-foreground",children:[x+1," / ",v.length]}),(0,e.jsx)("button",{type:"button",onClick:()=>y(a=>Math.min(v.length-1,a+1)),disabled:x===v.length-1,className:"min-h-[44px] px-3 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors touch-manipulation",children:K("actions.next")})]}),(0,e.jsx)("iframe",{srcDoc:v[x],sandbox:"",title:K("fileViewer.slideTitle",{name:d,number:x+1}),className:"w-full flex-1 border-0"})]}):null:(0,e.jsx)("div",{"data-testid":"markdown-file-preview",className:"prose prose-sm dark:prose-invert min-h-0 max-w-none flex-1 overflow-y-auto p-4",children:(0,e.jsx)(aq.G8,{content:af,currentFilePath:d,worktreeId:c,onOpenFile:g})})}),(0,e.jsx)("div",{"data-testid":"markdown-file-editor",className:"editor"===B?"flex min-h-0 flex-1 flex-col":"hidden",children:(0,e.jsx)(aQ,{worktreeId:c,filePath:d,initialContent:i.content,embedded:!0,onSave:ad,onDirtyChange:I,onContentChange:ac,onOpenFile:g},d)})]}),(0,e.jsx)(aw,{open:D,onClose:()=>E(!1),onSearch:()=>{C("viewer"),T()},onCopyContent:$,onCopyPath:_,downloadUrl:al,downloadName:av,contentCopied:r,pathCopied:t})]})})}return z&&i&&!m&&!p?(0,e.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:aE.M.MAXIMIZED_EDITOR},children:[aG(),N&&aH(),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:aj()})]}):(0,e.jsx)(n.Jh,{isOpen:a,onClose:b,title:d,size:"xl",children:(0,e.jsxs)("div",{className:"max-h-[60vh] sm:max-h-[70vh] flex flex-col",children:[m&&(0,e.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,e.jsx)(n.y$,{size:"xl",variant:"accent"}),(0,e.jsx)("p",{className:"ml-3 text-muted-foreground",children:K("fileViewer.loading")})]}),p&&(0,e.jsxs)("div",{className:"bg-danger-subtle border border-danger-border rounded-lg p-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-5 h-5 text-danger-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("p",{className:"text-sm text-danger-foreground",children:p})]}),(0,e.jsx)("div",{className:"mt-3",children:ax("inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium bg-surface border border-border text-foreground hover:bg-muted transition-colors",!0)})]}),i&&!m&&!p&&(0,e.jsxs)("div",{className:"bg-muted rounded-lg overflow-hidden flex flex-col min-h-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex-shrink-0",children:[aG(),N&&aH()]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:aj()})]})]})})});var aX=c(52120),aY=c(1102),aZ=c(10290),a$=c(59581),a_=c(63474);function a0({worktreeId:a}){let[b,c]=(0,h.useState)([]),[d,f]=(0,h.useState)(null),[g,i]=(0,h.useState)(null),[j,l]=(0,h.useState)(!0),[m,o]=(0,h.useState)(null),[q,r]=(0,h.useState)(""),[t,u]=(0,h.useState)(0),[v,w]=(0,h.useState)("all"),[x,y]=(0,h.useState)(!1),{showToast:z}=(0,a_.dj)(),A=(0,k.c)("worktree"),B=(0,h.useMemo)(()=>"all"===v?b:b.filter(a=>a.toLowerCase().includes(v)),[b,v]),C=async b=>{try{l(!0),o(null);let c=await T.y.getLogFile(a,b);i(c.content),f(b),r(""),u(0)}catch(a){o((0,T.hS)(a))}finally{l(!1)}},D=(0,h.useCallback)(async()=>{if(d)try{y(!0);let b=await T.y.getLogFile(a,d,{sanitize:!0});await (0,ay.l)(b.content),z(A("logViewer.copied"),"success")}catch(a){z(A("logViewer.exportError",{error:(0,T.hS)(a)}),"error")}finally{y(!1)}},[a,d,z,A]),E=(0,h.useMemo)(()=>{let a;if(!q||!g)return[];let b=RegExp(p(q),"gi"),c=[];for(;null!==(a=b.exec(g));)c.push({index:a.index,length:a[0].length});return c},[q,g]),F=()=>{E.length>0&&u(a=>(a+1)%E.length)},G=()=>{E.length>0&&u(a=>(a-1+E.length)%E.length)},H=(0,h.useMemo)(()=>{if(!g||!q||0===E.length)return g;let a="",b=0;return E.forEach((c,d)=>{a+=s(g.substring(b,c.index));let e=g.substring(c.index,c.index+c.length),f=d===t;a+=`<mark class="${f?"bg-warning text-black":"bg-warning-border text-black"}" data-match-index="${d}">${s(e)}</mark>`,b=c.index+c.length}),a+=s(g.substring(b))},[g,q,E,t]);return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)(n.Zp,{padding:"md",children:[(0,e.jsx)(n.aR,{children:(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(n.ZB,{children:A("logViewer.title")}),(0,e.jsx)(n.Ex,{variant:"gray",children:B.length})]}),(0,e.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,e.jsx)(n.$n,{variant:"all"===v?"primary":"ghost",size:"sm",onClick:()=>w("all"),children:A("logViewer.all",{count:b.length})}),(0,e.jsx)(n.$n,{variant:"claude"===v?"primary":"ghost",size:"sm",onClick:()=>w("claude"),children:A("logViewer.toolCount",{tool:"Claude",count:b.filter(a=>a.toLowerCase().includes("claude")).length})}),(0,e.jsx)(n.$n,{variant:"codex"===v?"primary":"ghost",size:"sm",onClick:()=>w("codex"),children:A("logViewer.toolCount",{tool:"Codex",count:b.filter(a=>a.toLowerCase().includes("codex")).length})}),(0,e.jsx)(n.$n,{variant:"gemini"===v?"primary":"ghost",size:"sm",onClick:()=>w("gemini"),children:A("logViewer.toolCount",{tool:"Gemini",count:b.filter(a=>a.toLowerCase().includes("gemini")).length})}),(0,e.jsx)(n.$n,{variant:"antigravity"===v?"primary":"ghost",size:"sm",onClick:()=>w("antigravity"),children:A("logViewer.toolCount",{tool:"Antigravity",count:b.filter(a=>a.toLowerCase().includes("antigravity")).length})})]})]})}),(0,e.jsxs)(n.Wu,{children:[j&&0===b.length&&(0,e.jsx)("div",{className:"text-center py-4",children:(0,e.jsx)(n.y$,{size:"lg",variant:"accent",className:"inline-block"})}),m&&(0,e.jsx)("div",{className:"p-3 bg-danger-subtle border border-danger-border rounded text-sm text-danger-foreground",children:m}),!j&&0===B.length&&!m&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:"all"===v?A("logViewer.empty"):A("logViewer.emptyFiltered",{tool:v})}),B.length>0&&(0,e.jsx)("div",{className:"space-y-2",children:B.map(a=>(0,e.jsx)("button",{onClick:()=>C(a),className:`w-full text-left px-3 py-2 rounded text-sm font-mono transition-colors ${d===a?"bg-accent-50 text-accent-700 border border-accent-200":"hover:bg-muted border border-transparent"}`,children:a},a))})]})]}),d&&(0,e.jsxs)(n.Zp,{padding:"md",children:[(0,e.jsx)(n.aR,{children:(0,e.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(n.ZB,{className:"font-mono text-base",children:d}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(n.$n,{variant:"ghost",size:"sm",onClick:D,disabled:!d||x,title:A("logViewer.copyTitle"),children:x?A("logViewer.exporting"):A("logViewer.export")}),(0,e.jsx)(n.$n,{variant:"ghost",size:"sm",onClick:()=>{f(null),i(null),r(""),u(0)},children:A("actions.close")})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"relative flex-1",children:[(0,e.jsx)(n.pd,{type:"text",value:q,onChange:a=>r(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?G():F())},placeholder:A("logViewer.searchPlaceholder"),className:"w-full pr-20"}),E.length>0&&(0,e.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-muted-foreground",children:[t+1," / ",E.length]})]}),E.length>0&&(0,e.jsxs)("div",{className:"flex gap-1",children:[(0,e.jsx)(n.$n,{variant:"ghost",size:"sm",onClick:G,disabled:0===E.length,title:A("logViewer.prevMatch"),children:"↑"}),(0,e.jsx)(n.$n,{variant:"ghost",size:"sm",onClick:F,disabled:0===E.length,title:A("logViewer.nextMatch"),children:"↓"})]})]})]})}),(0,e.jsxs)(n.Wu,{children:[j&&(0,e.jsx)("div",{className:"text-center py-8",children:(0,e.jsx)(n.y$,{size:"xl",variant:"accent",className:"inline-block"})}),!j&&g&&(0,e.jsx)("div",{className:"bg-[#111827] text-[#f3f4f6] rounded p-4 overflow-x-auto max-h-[500px] scrollbar-thin",children:q&&E.length>0?(0,e.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",dangerouslySetInnerHTML:{__html:H||""}}):(0,e.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",children:g})}),!j&&q&&0===E.length&&g&&(0,e.jsx)("div",{className:"text-center py-4 text-sm text-muted-foreground",children:A("logViewer.noMatches",{query:q})})]})]})]})}function a1(){let[a,b]=(0,h.useState)(null),[c,d]=(0,h.useState)(!0),[e,f]=(0,h.useState)(null);return{data:a,loading:c,error:e}}var a2=c(94260);function a3({hasUpdate:a,latestVersion:b,releaseUrl:c,updateCommand:d,installType:f}){let g=(0,k.c)("worktree"),[i,j]=(0,h.useState)("idle"),[l,n]=(0,h.useState)(null),[o,p]=(0,h.useState)(null);(0,h.useRef)(!1);let q="global"===f,r="npx"===f,s=q||r,t=r?"npx commandmate@latest":"commandmate update",u=(0,h.useCallback)(async()=>{j("starting");try{let a=await T.GQ.startUpdate();n(a.logPath),j(a.willRestart?"updating":"no-restart")}catch(a){a instanceof T.hD&&400===a.status?p(g("update.errorNotGlobal")):a instanceof T.hD&&409===a.status?p(g("update.errorInProgress")):p(g("update.errorGeneric")),j("error")}},[g]);return a?(0,e.jsxs)("div",{className:"bg-accent-50 border border-accent-200 rounded-lg p-3 mt-2",role:"status","aria-label":g("update.available"),"data-testid":"update-notification-banner",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-accent-800 mb-1",children:g("update.available")}),b&&(0,e.jsx)("p",{className:"text-sm text-accent-700 mb-2",children:g("update.latestVersion",{version:b})}),s&&"idle"===i&&(0,e.jsx)(a2.$,{variant:"primary",size:"sm",className:"mb-2",onClick:()=>j("confirming"),"data-testid":"update-now-button",children:g("update.updateNow")}),r&&"idle"===i&&(0,e.jsx)("p",{className:"text-xs text-accent-600 mb-2","data-testid":"update-npx-notice",children:g("update.npxRestartNotice")}),("starting"===i||"updating"===i)&&(0,e.jsxs)("div",{className:"mb-2","data-testid":"update-progress",children:[(0,e.jsxs)("p",{className:"flex items-center text-sm text-accent-800",children:[(0,e.jsx)(m.y,{size:"sm",className:"mr-2"}),"starting"===i?g("update.starting"):g("update.updating")]}),"updating"===i&&(0,e.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:g("update.updatingHint")})]}),"no-restart"===i&&(0,e.jsxs)("div",{className:"mb-2","data-testid":"update-no-restart",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-accent-800",children:g("update.noRestartTitle")}),(0,e.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:g("update.noRestartDescription")})]}),"timeout"===i&&(0,e.jsxs)("div",{className:"mb-2","data-testid":"update-timeout",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-accent-800",children:g("update.timeoutTitle")}),(0,e.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:g("update.timeoutDescription")}),(0,e.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 mt-1 text-xs text-accent-900 font-mono",children:t})]}),"error"===i&&(0,e.jsxs)("div",{className:"mb-2","data-testid":"update-error",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-accent-800",children:g("update.errorTitle")}),(0,e.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:o}),(0,e.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 mt-1 text-xs text-accent-900 font-mono",children:t})]}),l&&("no-restart"===i||"timeout"===i)&&(0,e.jsx)("p",{className:"text-xs text-accent-500 mb-2","data-testid":"update-log-hint",children:g("update.logHint",{path:l})}),d&&q&&"idle"===i&&(0,e.jsxs)("div",{className:"mb-2",children:[(0,e.jsx)("p",{className:"text-xs text-accent-600 mb-1",children:g("update.updateCommand")}),(0,e.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 text-xs text-accent-900 font-mono",children:d})]}),c&&(0,e.jsxs)("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-accent-600 hover:text-accent-800 underline",children:[g("update.viewRelease"),(0,e.jsx)("span",{className:"ml-1","aria-hidden":"true",children:"→"})]}),(0,e.jsx)("p",{className:"text-xs text-accent-500 mt-2",children:g("update.dataPreserved")}),(0,e.jsx)(am.TM,{isOpen:"confirming"===i,title:g("update.confirmTitle"),description:g("update.confirmDescription",{version:b??""}),confirmLabel:g("update.confirmButton"),onConfirm:u,onCancel:()=>j("idle")})]}):null}function a4({version:a,className:b}){let c=(0,k.c)("worktree"),{data:d,loading:f}=a1(),g=(0,h.useMemo)(()=>d&&d.hasUpdate?{hasUpdate:d.hasUpdate,latestVersion:d.latestVersion,releaseUrl:d.releaseUrl,updateCommand:d.updateCommand,installType:d.installType}:null,[d]);return(0,e.jsxs)("div",{className:b,"data-testid":"version-section",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:c("update.version")}),(0,e.jsx)("p",{className:"text-sm text-foreground",children:a}),f&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1","data-testid":"version-loading",children:"..."}),g&&(0,e.jsx)(a3,{...g})]})}let a5="https://github.com/Kewton/CommandMate",a6=`${a5}/issues`,a7=`${a5}/issues/new`,a8=`${a7}?template=bug_report.md`,a9=`${a7}?template=feature_request.md`,ba=`${a7}?template=question.md`;function bb({className:a}){let b=(0,k.c)("worktree"),c=[{href:a8,label:b("feedback.bugReport")},{href:a9,label:b("feedback.featureRequest")},{href:ba,label:b("feedback.question")},{href:a6,label:b("feedback.viewIssues")}];return(0,e.jsxs)("div",{className:a,"data-testid":"feedback-section",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-2",children:b("feedback.title")}),(0,e.jsx)("div",{className:"flex flex-col gap-1",children:c.map(({href:a,label:b})=>(0,e.jsxs)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-accent-600 hover:text-accent-800 underline",children:[b,(0,e.jsx)("span",{className:"ml-1","aria-hidden":"true",children:"→"})]},a))})]})}var bc=c(98033),bd=c(67016),be=c(17252),bf=c(85351);let bg="application/x-commandmate-agent-instance",bh=(0,h.memo)(function({splitIndex:a,cliToolId:b,instanceId:c,instance:d,availableInstances:f,onInstanceChange:g,status:i="idle",onFocus:j,attaching:l=!1,headerExtras:m,terminal:n,footer:p,style:q,onDropInstance:r,draggedInstanceId:s}){let t=(0,k.c)("worktree"),[u,v]=(0,h.useState)(null),w=null!=r,x=(0,h.useCallback)(()=>null==s||f.some(a=>a.id===s)?"allowed":"forbidden",[s,f]),y=(0,h.useCallback)(a=>{if(!w)return;a.preventDefault();let b=x();a.dataTransfer.dropEffect="forbidden"===b?"none":"move",v(a=>a===b?a:b)},[w,x]),z=(0,h.useCallback)(a=>{if(!w)return;a.preventDefault();let b=x();v(a=>a===b?a:b)},[w,x]),A=(0,h.useCallback)(()=>{w&&v(null)},[w]),B=(0,h.useCallback)(a=>{if(!w)return;a.preventDefault(),v(null);let b=a.dataTransfer.getData(bg);b&&r?.(b)},[w,r]),C=(0,h.useCallback)(()=>{window.dispatchEvent(new CustomEvent("terminal-search-open"))},[]),D=(0,h.useCallback)(()=>{j()},[j]),E=`Terminal split ${a+1}`,F=(0,be.sw)(d??{cliTool:b}),G=t("terminal.selectInstance",{split:E});return(0,e.jsxs)("div",{role:"region","aria-label":E,"data-testid":`terminal-split-pane-${a}`,"data-split-index":a,style:q,className:`flex flex-col min-w-0 h-full rounded-lg overflow-hidden border border-border bg-surface${null===u?" focus-within:ring-1 focus-within:ring-accent-500/30":""}${"allowed"===u?" ring-2 ring-accent-400":"forbidden"===u?" ring-2 ring-red-300 cursor-not-allowed":""}`,onFocusCapture:D,onMouseDown:j,onDragOver:y,onDragEnter:z,onDragLeave:A,onDrop:B,children:[(0,e.jsxs)("div",{className:"px-2 py-1 flex items-center gap-2 bg-surface-2 border-b border-border flex-shrink-0",children:[(0,e.jsxs)(aZ.rI,{children:[(0,e.jsxs)(aZ.ty,{"data-testid":`cli-selector-${a}`,"aria-label":G,className:"flex items-center gap-1.5 min-w-0 max-w-[12rem] rounded px-1.5 py-0.5 text-xs border border-border bg-surface text-surface-foreground hover:bg-muted focus:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:ring-2 data-[state=open]:ring-ring transition-colors",children:[(0,e.jsx)(o.m,{status:i,size:"sm","aria-hidden":!0,"data-testid":`split-status-indicator-${a}`}),(0,e.jsx)("span",{className:"truncate",children:F}),(0,e.jsx)(bf.A,{size:14,"aria-hidden":"true",className:"flex-shrink-0 opacity-70"})]}),(0,e.jsx)(aZ.SQ,{align:"start",className:"min-w-[10rem]",children:(0,e.jsx)(aZ.Hr,{value:c,onValueChange:g,children:f.map(a=>(0,e.jsx)(aZ.Ht,{value:a.id,children:(0,be.sw)(a)},a.id))})})]}),m,(0,e.jsx)("button",{type:"button",onClick:C,"aria-label":`Search terminal output for ${E}`,"data-testid":`terminal-search-button-${a}`,className:"ml-auto flex items-center gap-1 px-1.5 py-0.5 text-xs text-muted-foreground hover:text-surface-foreground hover:bg-muted-foreground/10 rounded transition-colors",children:(0,e.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})})]}),(0,e.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[l?(0,e.jsxs)("div",{"data-testid":`terminal-attach-skeleton-${a}`,className:"absolute inset-0 flex items-center justify-center text-xs text-muted-foreground bg-surface-2/80",role:"status","aria-live":"polite",children:["Attaching ",F," session..."]}):null,n]}),(0,e.jsx)("div",{className:"flex-shrink-0 border-t border-border p-2 bg-surface-2",children:p})]})});var bi=c(8509),bj=c(70584),bk=c(24417),bl=c(3350),bm=c.n(bl),bn=c(19331);let bo=new(c.n(bn)())({fg:"#d1d5db",bg:"#1f2937",newline:!0,escapeXML:!0});function bp(a){let b=a.replace(/\0/g,"");b.length>1048576&&(b=b.slice(0,1048576));let c=bo.toHtml(b);return bm().sanitize(c,{ALLOWED_TAGS:["span","br"],ALLOWED_ATTR:["style"],ALLOW_DATA_ATTR:!1})}let bq=/\x1b(?:\[[0-9;?]*)?$/,br=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07]*\x07|\[[0-9;]*m/g;function bs(a){return""===a.replace(br,"").trim()}function bt({query:a,onQueryChange:b,matchCount:c,currentIndex:d,onNext:f,onPrev:g,onClose:i,isAtMaxMatches:j=!1}){let k=(0,h.useRef)(null),l=(0,h.useCallback)(a=>{"Escape"===a.key&&i()},[i]),m=(0,h.useCallback)(a=>{b(a.target.value)},[b]),n=0===c?"0/0":j?`${d+1}/500以上`:`${d+1}/${c}`;return(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-gray-800 border border-gray-600 rounded shadow-lg",role:"search","aria-label":"ターミナル内テキスト検索",children:[(0,e.jsx)("input",{ref:k,type:"text",value:a,onChange:m,onKeyDown:l,placeholder:"検索...",className:"bg-transparent text-gray-200 text-sm outline-none w-32 sm:w-40 placeholder-gray-500","aria-label":"検索キーワード",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,e.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"text-gray-400 text-xs min-w-[3rem] text-right",children:n}),(0,e.jsx)("button",{onClick:g,disabled:0===c,"aria-label":"前の結果",className:"text-gray-300 hover:text-white disabled:text-gray-600 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▲"}),(0,e.jsx)("button",{onClick:f,disabled:0===c,"aria-label":"次の結果",className:"text-gray-300 hover:text-white disabled:text-gray-600 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▼"}),(0,e.jsx)("button",{onClick:i,"aria-label":"検索を閉じる",className:"text-gray-400 hover:text-white min-w-[36px] min-h-[36px] flex items-center justify-center text-base ml-1",children:"✕"})]})}function bu(){return(0,e.jsxs)("div",{"data-testid":"thinking-indicator",className:"flex items-center gap-2 py-2 px-1 text-gray-400",children:[(0,e.jsxs)("span",{className:"flex gap-1",children:[(0,e.jsx)("span",{className:"animate-pulse delay-0",children:"."}),(0,e.jsx)("span",{className:"animate-pulse delay-150",children:"."}),(0,e.jsx)("span",{className:"animate-pulse delay-300",children:"."})]}),(0,e.jsx)("span",{className:"text-sm",children:"Thinking"})]})}let bv=(0,h.memo)(function({output:a,isActive:b,attaching:c=!1,isThinking:d=!1,autoScroll:f=!0,onScrollChange:g,disableAutoFollow:i=!1,compactTuiLayoutPadding:j=!1,className:k=""}){let{scrollRef:l,autoScroll:m,handleScroll:n,scrollToBottom:o,scrollToTop:p}=function(a={}){let{initialAutoScroll:b=!0,onAutoScrollChange:c}=a,d=(0,h.useRef)(null),[e,f]=(0,h.useState)(b),g=(0,h.useRef)(!1),i=(0,h.useRef)(null),j=(0,h.useCallback)(a=>{f(a),c?.(a)},[c]),k=(0,h.useCallback)(()=>{let a=d.current;if(!a)return!0;let{scrollTop:b,scrollHeight:c,clientHeight:e}=a;return c-e-b<=50},[]),l=(0,h.useCallback)(()=>{if(g.current)return;let a=k();a&&!e?j(!0):!a&&e&&j(!1)},[e,k,j]),m=(0,h.useCallback)(()=>{let a=d.current;a&&(g.current=!0,a.scrollTo({top:a.scrollHeight,behavior:"smooth"}),e||j(!0),i.current=setTimeout(()=>{g.current=!1,i.current=null},500))},[e,j]),n=(0,h.useCallback)(()=>{let a=d.current;a&&(g.current=!0,a.scrollTo({top:0,behavior:"smooth"}),e&&j(!1),i.current=setTimeout(()=>{g.current=!1,i.current=null},500))},[e,j]);return{scrollRef:d,autoScroll:e,setAutoScroll:j,scrollToBottom:m,scrollToTop:n,handleScroll:l}}({initialAutoScroll:f,onAutoScrollChange:g}),q=a??"",r=(0,h.useMemo)(()=>j?function(a){if(""===a)return"";let b=a.split("\n"),c=[],d=!1,e=0;for(;e<b.length;){if(!bs(b[e])){c.push(b[e]),d=!0,e++;continue}let a=e;for(;a<b.length&&bs(b[a]);)a++;let f=a-e,g=!d,h=a>=b.length;if(!g&&!h)if(f<=2)for(let d=e;d<a;d++)c.push(b[d]);else c.push(function(a){let b=a.match(br);return b?b.join(""):""}(b.slice(e,a).join("")));e=a}return c.join("\n")}(q):q,[j,q]),{isOpen:s,query:t,matchCount:u,currentIndex:v,isAtMaxMatches:w,openSearch:x,closeSearch:y,setQuery:z,nextMatch:A,prevMatch:B}=function({output:a,containerRef:b}){let[c,d]=(0,h.useState)(!1),[e,f]=(0,h.useState)(""),[g,i]=(0,h.useState)([]),[j,k]=(0,h.useState)(0),[l,m]=(0,h.useState)(!1),n=(0,h.useRef)(null),o=(0,h.useRef)(""),p=g.length,q=(0,h.useCallback)(a=>{if(a.length<2||!b.current)return{positions:[],capped:!1};let c=(b.current.textContent??"").toLowerCase(),d=a.toLowerCase(),e=[],f=0;for(;e.length<500;){let b=c.indexOf(d,f);if(-1===b)break;e.push({start:b,end:b+a.length}),f=b+1}let g=e.length>=500&&-1!==c.indexOf(d,f);return{positions:e,capped:g}},[b]),r=(0,h.useCallback)(a=>{let{positions:c,capped:d}=q(a);if(i(c),k(0),m(d),b.current)if(c.length>0){var e;e=b.current,aL(e,c,0,aG)}else aK(aG)},[q,b]),s=(0,h.useCallback)(a=>{f(a),n.current&&clearTimeout(n.current),o.current=a,n.current=setTimeout(()=>{r(a)},300)},[r]),t=(0,h.useCallback)(()=>{d(!0)},[]),u=(0,h.useCallback)(()=>{d(!1),f(""),o.current="",i([]),k(0),m(!1),n.current&&clearTimeout(n.current),aK(aG)},[]),v=(0,h.useCallback)(()=>{0!==p&&k(a=>{let c=(a+1)%p;return b.current&&g.length>0&&aL(b.current,g,c,aG),c})},[p,g,b]),w=(0,h.useCallback)(()=>{0!==p&&k(a=>{let c=(a-1+p)%p;return b.current&&g.length>0&&aL(b.current,g,c,aG),c})},[p,g,b]);return{isOpen:c,query:e,matchCount:p,currentIndex:j,isAtMaxMatches:l,openSearch:t,closeSearch:u,setQuery:s,nextMatch:v,prevMatch:w}}({output:r,containerRef:l}),C=(0,h.useCallback)(a=>{(a.ctrlKey||a.metaKey)&&"f"===a.key&&(a.preventDefault(),x())},[x]);(0,h.useEffect)(()=>{let a=()=>x();return window.addEventListener("terminal-search-open",a),()=>window.removeEventListener("terminal-search-open",a)},[x]);let[D,E]=(0,h.useState)(()=>r?[{key:0,html:bp(r)}]:[]),F=(0,h.useRef)(r),G=(0,h.useRef)(0);(0,h.useEffect)(()=>{let a=function(a,b){if(a===b)return{mode:"noop",text:b,appended:"",retainedLength:a.length};if(0===a.length||b.length<=a.length||!b.startsWith(a))return{mode:"replace",text:b,appended:"",retainedLength:0};let c=a.match(bq),d=c?a.length-c[0].length:a.length;return{mode:"append",text:b,appended:b.slice(d),retainedLength:d}}(F.current,r);if(F.current=r,"noop"!==a.mode){if("append"===a.mode)return void E(b=>(G.current+=1,b.length>=400)?[{key:G.current,html:bp(r)}]:[...b,{key:G.current,html:bp(a.appended)}]);G.current+=1,E(r?[{key:G.current,html:bp(r)}]:[])}},[r]);let[H,I]=(0,h.useState)(!1);(0,h.useEffect)(()=>{c?I(!1):b&&I(!0)},[c,b]);let J=!a,K=J&&c,L=J&&!c&&!b&&H,M=(0,h.useRef)(!1);(0,h.useEffect)(()=>{i&&(M.current=!0)},[i]),(0,h.useEffect)(()=>{if(l.current){if(M.current&&i&&r){l.current.scrollTo({top:0,behavior:"instant"}),M.current=!1;return}!i&&m&&l.current.scrollTo({top:l.current.scrollHeight,behavior:"instant"})}},[D,r,m,i,l]);let N=(0,h.useMemo)(()=>["terminal","font-mono","text-sm","p-4","rounded-lg","overflow-y-auto","overflow-x-hidden","bg-gray-900","text-gray-300","border","border-gray-700","h-full",b?"active":"",k].filter(Boolean).join(" "),[b,k]),[O,P]=(0,h.useState)(!1),Q=(0,h.useRef)(null),R=(0,h.useCallback)(()=>{P(!0),Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>P(!1),1500)},[]);(0,h.useEffect)(()=>()=>{Q.current&&clearTimeout(Q.current)},[]);let S=(0,h.useCallback)(()=>{n(),R()},[n,R]),T=["absolute bottom-4 right-4 flex items-center justify-center h-9 w-9 rounded-full bg-surface/80 backdrop-blur border border-border text-muted-foreground shadow-lg transition-opacity hover:text-surface-foreground hover:opacity-100 focus-visible:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",O?"opacity-100":"opacity-60"].join(" ");return(0,e.jsxs)("div",{className:"relative h-full flex flex-col",children:[s&&(0,e.jsx)("div",{className:"absolute top-2 right-2 z-10",children:(0,e.jsx)(bt,{query:t,onQueryChange:z,matchCount:u,currentIndex:v,onNext:A,onPrev:B,onClose:y,isAtMaxMatches:w})}),(0,e.jsxs)("div",{ref:l,role:"log","aria-live":"polite","aria-label":"Terminal output",className:N,onScroll:S,onKeyDown:C,tabIndex:0,children:[(0,e.jsx)("div",{className:"whitespace-pre-wrap break-words",children:D.map(a=>(0,e.jsx)("span",{dangerouslySetInnerHTML:{__html:a.html}},a.key))}),K&&(0,e.jsx)("div",{"data-testid":"terminal-loading-placeholder",className:"flex h-full items-center justify-center px-4 text-center text-sm text-gray-500 select-none",children:"読込中..."}),L&&(0,e.jsx)("div",{"data-testid":"terminal-ended-placeholder",className:"flex h-full items-center justify-center px-4 text-center text-sm text-gray-500 select-none",children:"セッションは終了しました(メッセージ送信で再開できます)"}),b&&d&&(0,e.jsx)(bu,{})]}),m?(0,e.jsx)("button",{type:"button",onClick:p,className:T,"aria-label":"Scroll to top",children:(0,e.jsx)(bj.A,{size:16,"aria-hidden":"true"})}):(0,e.jsx)("button",{type:"button",onClick:o,className:T,"aria-label":"Scroll to bottom",children:(0,e.jsx)(bk.A,{size:16,"aria-hidden":"true"})})]})}),bw=[{key:"Left",label:"◀",ariaLabel:"Send Left"},{key:"Up",label:"▲",ariaLabel:"Send Up"},{key:"Down",label:"▼",ariaLabel:"Send Down"},{key:"Right",label:"▶",ariaLabel:"Send Right"},{key:"Enter",label:"↵",ariaLabel:"Send Enter"}],bx={key:"Escape",label:"Esc",ariaLabel:"Send Escape"},by={key:"q",label:"q",ariaLabel:"Send q (quit)"};function bz({worktreeId:a,cliToolId:b,instanceId:c,onKeysSent:d}){let[f,g]=(0,h.useState)(null),i=ai(a,b,c,d),j="codex"===b?[...bw,bx,by]:[...bw,bx],k=(0,h.useCallback)(a=>{g(a),setTimeout(()=>g(null),ah.tX),i([a])},[i]);return(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 py-1.5 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800/50 rounded-lg",role:"toolbar","aria-label":"Terminal navigation keys",children:[(0,e.jsx)("span",{className:"text-xs text-amber-700 dark:text-amber-400 mx-2",title:"Send navigation / escape keys when the terminal is stuck in a TUI overlay",children:"Navigate"}),j.map(({key:a,label:b,ariaLabel:c})=>(0,e.jsx)("button",{type:"button",className:`min-w-[44px] min-h-[44px] px-3 py-2 text-sm font-medium rounded-md
20
+ </script>`;function aV({htmlContent:a,filePath:b}){let[c,d]=(0,h.useState)("preview"),[f,g]=(0,h.useState)("safe"),i=(0,h.useRef)(new Set),j=(0,k.c)("worktree"),l=(0,am.SC)(),m=(0,h.useCallback)(async a=>{if("interactive"===a&&!i.current.has(b)){if(!await l({description:j("htmlPreview.interactiveModeConfirm")}))return;i.current.add(b)}g(a)},[b,l,j]),n=(0,h.useMemo)(()=>"interactive"!==f?a:a.includes("</body>")?a.replace("</body>",`${aU}</body>`):a+aU,[a,f]),o=(0,h.useMemo)(()=>{try{return aO.highlight(a,{language:"html",ignoreIllegals:!0}).value}catch{return aO.highlightAuto(a).value}},[a]),p=(0,h.useMemo)(()=>Array.from({length:a.split("\n").length},(a,b)=>b+1),[a]),q=(0,h.useMemo)(()=>o.split("\n"),[o]);return(0,e.jsxs)("div",{className:"flex flex-col h-full","data-testid":"html-preview-mobile",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border bg-muted",children:[(0,e.jsx)("div",{className:"flex gap-1",children:["source","preview"].map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>d(a),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${c===a?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"}`,children:"source"===a?j("fileViewer.tabSource"):j("fileViewer.tabPreview")},a))}),(0,e.jsx)("div",{className:"flex gap-1",children:["safe","interactive"].map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>m(a),className:`px-2 py-1 text-xs font-medium rounded-md transition-colors ${f===a?"safe"===a?"bg-success-subtle text-success-foreground":"bg-warning-subtle text-warning-foreground":"text-muted-foreground hover:bg-muted"}`,children:"safe"===a?j("fileViewer.sandboxSafe"):j("fileViewer.sandboxInteractive")},a))})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto min-h-0",children:"source"===c?(0,e.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,e.jsx)("tbody",{children:p.map(a=>{let b=a-1;return(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{className:"pl-3 pr-2 text-right select-none font-mono border-r border-border bg-muted dark:bg-muted/50 sticky left-0 align-top whitespace-nowrap text-muted-foreground",children:a}),(0,e.jsx)("td",{className:"px-4 text-foreground align-top",children:(0,e.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono",children:(0,e.jsx)("code",{className:"hljs",dangerouslySetInnerHTML:{__html:q[b]??""}})})})]},a)})})}):(0,e.jsx)("iframe",{srcDoc:n,sandbox:ax[f],title:j("htmlPreview.title",{path:b}),className:"w-full h-full border-0 bg-white"},`${b}-${f}`)})]})}let aW=(0,h.memo)(function({isOpen:a,onClose:b,worktreeId:c,filePath:d,onFileSaved:f,onOpenFile:g}){let[i,j]=(0,h.useState)(null),[m,o]=(0,h.useState)(!1),[p,q]=(0,h.useState)(null),[r,s]=(0,h.useState)(!1),[t,u]=(0,h.useState)(!1),[v,w]=(0,h.useState)(null),[x,y]=(0,h.useState)(0),[z,A]=(0,h.useState)(!1),[B,C]=(0,h.useState)("viewer"),[D,E]=(0,h.useState)(!1),[F,G]=(0,h.useState)(null),[H,I]=(0,h.useState)(!1),J=(0,h.useRef)(null),K=(0,k.c)("worktree"),L=(0,am.SC)(),M=i?F??i.content:void 0,{searchOpen:N,searchQuery:O,searchMatches:P,searchCurrentIdx:R,searchInputRef:S,openSearch:T,closeSearch:U,nextMatch:V,prevMatch:W,setSearchQuery:X}=aN(M),Y=(0,h.useMemo)(()=>!!(i?.content&&!i.isImage&&!i.isVideo&&!i.isPdf),[i]),Z=i?.extension==="md",$=(0,h.useCallback)(async()=>{if(Y&&M)try{await (0,ay.l)(M),s(!0),setTimeout(()=>s(!1),ah.pX)}catch{}},[Y,M]),_=(0,h.useCallback)(async()=>{try{await (0,ay.l)(d),u(!0),setTimeout(()=>u(!1),ah.pX)}catch{}},[d]),aa=(0,h.useCallback)(()=>{A(a=>!a)},[]);(0,h.useEffect)(()=>{if(0===P.length||!J.current)return;let a=P[R],b=J.current.querySelector(`[data-line="${a}"]`);b&&"function"==typeof b.scrollIntoView&&b.scrollIntoView({block:"center",behavior:"smooth"})},[R,P]),(0,h.useEffect)(()=>{if(!z||Z)return;let a=a=>{"Escape"===a.key&&A(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[z,Z]),(0,h.useEffect)(()=>{if(!a||!d){j(null),q(null),s(!1),C("viewer"),E(!1),G(null),I(!1),U();return}C("viewer"),E(!1),G(null),I(!1),(async()=>{o(!0),q(null);try{let a=await fetch(`/api/worktrees/${c}/files/${(0,aF.o)(d)}`);if(!a.ok){let b=await a.json(),c="string"==typeof b.error?b.error:b.error?.message||K("fileViewer.loadError");throw Error(c)}let b=await a.json();j(b)}catch(a){q(a instanceof Error?a.message:K("fileViewer.loadError"))}finally{o(!1)}})()},[a,c,d]),(0,h.useEffect)(()=>{w(null),y(0),i&&"md"===i.extension&&aS.test(i.content)&&!(i.content.length>1e6)&&(async()=>{try{let a=await fetch(`/api/worktrees/${c}/marp-render`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:i.content})});if(a.ok){let b=await a.json();w(b.slides)}}catch{}})()},[i,c]);let ab=!!(v&&v.length>0),ac=(0,h.useCallback)(a=>{G(a)},[]),ad=(0,h.useCallback)((a,b)=>{j(a=>a?{...a,content:b}:a),G(b),f?.(a)},[f]),ae=(0,h.useCallback)(async()=>{(!H||await L({description:K("editor.unsavedCloseConfirm"),variant:"danger"}))&&b()},[H,L,K,b]);(0,h.useEffect)(()=>{if(!Z||D)return;let a=a=>{"Escape"===a.key&&(N?U():z?A(!1):ae())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[Z,D,N,z,ae]);let[af,ag]=(0,h.useState)("");(0,h.useEffect)(()=>{"viewer"===B&&void 0!==M&&ag(M)},[B,M]),(0,h.useEffect)(()=>{if(!Z||!a)return;let b=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=b}},[Z,a]);let ai=(0,h.useMemo)(()=>{if(!i||void 0===M||i.isImage||i.isVideo||i.isHtml||i.isPdf)return null;let a=Array.from({length:M.split("\n").length},(a,b)=>b+1);try{return{lineNumbers:a,highlightedHtml:aO.highlight(M,{language:i.extension,ignoreIllegals:!0}).value}}catch{return{lineNumbers:a,highlightedHtml:aO.highlightAuto(M).value}}},[i,M]),aj=()=>i?i.isImage?(0,e.jsx)(an.a,{src:i.content,alt:i.path,mimeType:i.mimeType}):i.isVideo?(0,e.jsx)(ao.u,{src:i.content,mimeType:i.mimeType}):i.isPdf?(0,e.jsx)("div",{className:"h-full min-h-[40vh]",children:(0,e.jsx)(ap.n,{dataUri:i.content,filePath:d,variant:"download"})}):i.isHtml?(0,e.jsx)(aV,{htmlContent:i.content,filePath:d}):ak():null,ak=()=>{if(!ai)return null;let a=new Set(P),b=P.length>0?P[R]:-1,c=ai.highlightedHtml.split("\n");return(0,e.jsx)("div",{ref:J,children:(0,e.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,e.jsx)("tbody",{children:ai.lineNumbers.map(d=>{let f=d-1,g=d===b,h=a.has(d);return(0,e.jsxs)("tr",{"data-line":d,className:g?"bg-warning/30":h?"bg-warning/15":"",children:[(0,e.jsx)("td",{className:`pl-3 pr-2 text-right select-none font-mono border-r border-border bg-muted dark:bg-muted/50 sticky left-0 align-top whitespace-nowrap ${g||h?"text-warning-foreground":"text-muted-foreground"}`,children:d}),(0,e.jsx)("td",{className:"px-4 text-foreground align-top",children:(0,e.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono",children:(0,e.jsx)("code",{className:"hljs",dangerouslySetInnerHTML:{__html:c[f]??""}})})})]},d)})})})})},al=`/api/worktrees/${c}/files/${(0,aF.o)(d)}?download=1`,av=d?d.split("/").pop()||d:"",ax=(a,b=!1)=>(0,e.jsxs)("a",{"data-testid":"download-file-button",href:al,download:av,className:a,"aria-label":K("actions.downloadFile"),title:K("actions.download"),children:[(0,e.jsx)(au,{className:"w-3.5 h-3.5"}),b&&(0,e.jsx)("span",{children:K("actions.download")})]}),aG=()=>(0,e.jsxs)("div",{className:"bg-muted px-3 py-1.5 border-b border-border flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("button",{onClick:_,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":K("actions.copyFilePath"),title:K("actions.copyPath"),children:t?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:d})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[Y&&(0,e.jsx)("button",{onClick:T,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":K("actions.searchInFile"),title:K("actions.search"),children:(0,e.jsx)(Q.A,{className:"w-3.5 h-3.5"})}),Y&&(0,e.jsx)("button",{"data-testid":"copy-content-button",onClick:$,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":K("actions.copyFileContent"),title:K("actions.copyContent"),children:r?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(as,{className:"w-3.5 h-3.5"})}),ax("p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground"),(0,e.jsx)("button",{onClick:aa,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":z?K("actions.exitFullscreen"):K("actions.fullscreen"),title:z?K("actions.exitFullscreen"):K("actions.fullscreen"),children:z?(0,e.jsx)(aA,{className:"w-3.5 h-3.5"}):(0,e.jsx)(aB,{className:"w-3.5 h-3.5"})})]})]}),aH=()=>(0,e.jsx)(aT,{searchInputRef:S,searchQuery:O,searchMatches:P,searchCurrentIdx:R,onQueryChange:X,onPrev:W,onNext:V,onClose:U});if(Z&&i&&!m&&!p){let a=a=>`flex min-h-[44px] items-center justify-center gap-1 rounded-md px-2 text-xs font-medium touch-manipulation transition-colors ${a?"bg-surface shadow-sm text-accent-600 dark:text-accent-400":"text-muted-foreground hover:text-foreground"}`;return(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)("div",{"data-testid":"markdown-file-screen",role:"dialog","aria-modal":"true","aria-label":d,className:"fixed inset-0 flex h-[100dvh] flex-col bg-surface",style:{zIndex:aE.M.MAXIMIZED_EDITOR},children:[z?(0,e.jsxs)("div",{"data-testid":"markdown-file-immersive-controls",className:"absolute right-2 top-2 z-10 flex items-center gap-1 rounded-lg border border-border bg-surface/90 shadow-sm",children:[(0,e.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:aa,"aria-pressed":!0,"aria-label":K("actions.exitFullscreen"),className:aR,children:(0,e.jsx)(aA,{className:"h-5 w-5"})}),(0,e.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void ae(),"aria-label":K("actions.close"),className:aR,children:(0,e.jsx)(az.A,{className:"h-5 w-5"})})]}):(0,e.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-1 border-b border-border bg-muted px-2",children:[(0,e.jsx)("p",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:d}),(0,e.jsxs)("div",{"data-testid":"markdown-file-mode-switch",role:"group","aria-label":K("fileViewer.modeSwitch"),className:"flex flex-shrink-0 items-center gap-0.5 rounded-lg bg-muted p-0.5",children:[(0,e.jsxs)("button",{type:"button","data-testid":"markdown-file-mode-viewer","aria-pressed":"viewer"===B,onClick:()=>C("viewer"),className:a("viewer"===B),children:[(0,e.jsx)(aC,{className:"h-4 w-4"}),K("fileViewer.modeViewer")]}),(0,e.jsxs)("button",{type:"button","data-testid":"markdown-file-mode-editor","aria-pressed":"editor"===B,onClick:()=>C("editor"),className:a("editor"===B),children:[(0,e.jsx)(aD.A,{className:"h-4 w-4"}),K("fileViewer.modeEditor")]})]}),(0,e.jsx)("button",{type:"button","data-testid":"markdown-file-actions-trigger",onClick:()=>E(!0),"aria-label":K("fileViewer.moreActions"),className:aR,children:(0,e.jsx)(l.A,{className:"h-5 w-5"})}),(0,e.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:aa,"aria-pressed":!1,"aria-label":K("actions.fullscreen"),className:aR,children:(0,e.jsx)(aB,{className:"h-5 w-5"})}),(0,e.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void ae(),"aria-label":K("actions.close"),className:aR,children:(0,e.jsx)(az.A,{className:"h-5 w-5"})})]}),N&&(0,e.jsx)("div",{className:"flex-shrink-0",children:aH()}),(0,e.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,e.jsx)("div",{className:"viewer"===B?"flex min-h-0 flex-1 flex-col":"hidden",children:N?(0,e.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:ak()}):ab?v?(0,e.jsxs)("div",{className:"flex h-full flex-col",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-2 bg-muted border-b border-border",children:[(0,e.jsx)("button",{type:"button",onClick:()=>y(a=>Math.max(0,a-1)),disabled:0===x,className:"min-h-[44px] px-3 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors touch-manipulation",children:K("actions.prev")}),(0,e.jsxs)("span",{className:"text-sm text-muted-foreground",children:[x+1," / ",v.length]}),(0,e.jsx)("button",{type:"button",onClick:()=>y(a=>Math.min(v.length-1,a+1)),disabled:x===v.length-1,className:"min-h-[44px] px-3 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors touch-manipulation",children:K("actions.next")})]}),(0,e.jsx)("iframe",{srcDoc:v[x],sandbox:"",title:K("fileViewer.slideTitle",{name:d,number:x+1}),className:"w-full flex-1 border-0"})]}):null:(0,e.jsx)("div",{"data-testid":"markdown-file-preview",className:"prose prose-sm dark:prose-invert min-h-0 max-w-none flex-1 overflow-y-auto p-4",children:(0,e.jsx)(aq.G8,{content:af,currentFilePath:d,worktreeId:c,onOpenFile:g})})}),(0,e.jsx)("div",{"data-testid":"markdown-file-editor",className:"editor"===B?"flex min-h-0 flex-1 flex-col":"hidden",children:(0,e.jsx)(aQ,{worktreeId:c,filePath:d,initialContent:i.content,embedded:!0,onSave:ad,onDirtyChange:I,onContentChange:ac,onOpenFile:g},d)})]}),(0,e.jsx)(aw,{open:D,onClose:()=>E(!1),onSearch:()=>{C("viewer"),T()},onCopyContent:$,onCopyPath:_,downloadUrl:al,downloadName:av,contentCopied:r,pathCopied:t})]})})}return z&&i&&!m&&!p?(0,e.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:aE.M.MAXIMIZED_EDITOR},children:[aG(),N&&aH(),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:aj()})]}):(0,e.jsx)(n.Jh,{isOpen:a,onClose:b,title:d,size:"xl",children:(0,e.jsxs)("div",{className:"max-h-[60vh] sm:max-h-[70vh] flex flex-col",children:[m&&(0,e.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,e.jsx)(n.y$,{size:"xl",variant:"accent"}),(0,e.jsx)("p",{className:"ml-3 text-muted-foreground",children:K("fileViewer.loading")})]}),p&&(0,e.jsxs)("div",{className:"bg-danger-subtle border border-danger-border rounded-lg p-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-5 h-5 text-danger-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("p",{className:"text-sm text-danger-foreground",children:p})]}),(0,e.jsx)("div",{className:"mt-3",children:ax("inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium bg-surface border border-border text-foreground hover:bg-muted transition-colors",!0)})]}),i&&!m&&!p&&(0,e.jsxs)("div",{className:"bg-muted rounded-lg overflow-hidden flex flex-col min-h-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex-shrink-0",children:[aG(),N&&aH()]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:aj()})]})]})})});var aX=c(52120),aY=c(1102),aZ=c(10290),a$=c(59581),a_=c(63474);function a0({worktreeId:a}){let[b,c]=(0,h.useState)([]),[d,f]=(0,h.useState)(null),[g,i]=(0,h.useState)(null),[j,l]=(0,h.useState)(!0),[m,o]=(0,h.useState)(null),[q,r]=(0,h.useState)(""),[t,u]=(0,h.useState)(0),[v,w]=(0,h.useState)("all"),[x,y]=(0,h.useState)(!1),{showToast:z}=(0,a_.dj)(),A=(0,k.c)("worktree"),B=(0,h.useMemo)(()=>"all"===v?b:b.filter(a=>a.toLowerCase().includes(v)),[b,v]),C=async b=>{try{l(!0),o(null);let c=await T.y.getLogFile(a,b);i(c.content),f(b),r(""),u(0)}catch(a){o((0,T.hS)(a))}finally{l(!1)}},D=(0,h.useCallback)(async()=>{if(d)try{y(!0);let b=await T.y.getLogFile(a,d,{sanitize:!0});await (0,ay.l)(b.content),z(A("logViewer.copied"),"success")}catch(a){z(A("logViewer.exportError",{error:(0,T.hS)(a)}),"error")}finally{y(!1)}},[a,d,z,A]),E=(0,h.useMemo)(()=>{let a;if(!q||!g)return[];let b=RegExp(p(q),"gi"),c=[];for(;null!==(a=b.exec(g));)c.push({index:a.index,length:a[0].length});return c},[q,g]),F=()=>{E.length>0&&u(a=>(a+1)%E.length)},G=()=>{E.length>0&&u(a=>(a-1+E.length)%E.length)},H=(0,h.useMemo)(()=>{if(!g||!q||0===E.length)return g;let a="",b=0;return E.forEach((c,d)=>{a+=s(g.substring(b,c.index));let e=g.substring(c.index,c.index+c.length),f=d===t;a+=`<mark class="${f?"bg-warning text-black":"bg-warning-border text-black"}" data-match-index="${d}">${s(e)}</mark>`,b=c.index+c.length}),a+=s(g.substring(b))},[g,q,E,t]);return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)(n.Zp,{padding:"md",children:[(0,e.jsx)(n.aR,{children:(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(n.ZB,{children:A("logViewer.title")}),(0,e.jsx)(n.Ex,{variant:"gray",children:B.length})]}),(0,e.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,e.jsx)(n.$n,{variant:"all"===v?"primary":"ghost",size:"sm",onClick:()=>w("all"),children:A("logViewer.all",{count:b.length})}),(0,e.jsx)(n.$n,{variant:"claude"===v?"primary":"ghost",size:"sm",onClick:()=>w("claude"),children:A("logViewer.toolCount",{tool:"Claude",count:b.filter(a=>a.toLowerCase().includes("claude")).length})}),(0,e.jsx)(n.$n,{variant:"codex"===v?"primary":"ghost",size:"sm",onClick:()=>w("codex"),children:A("logViewer.toolCount",{tool:"Codex",count:b.filter(a=>a.toLowerCase().includes("codex")).length})}),(0,e.jsx)(n.$n,{variant:"gemini"===v?"primary":"ghost",size:"sm",onClick:()=>w("gemini"),children:A("logViewer.toolCount",{tool:"Gemini",count:b.filter(a=>a.toLowerCase().includes("gemini")).length})}),(0,e.jsx)(n.$n,{variant:"antigravity"===v?"primary":"ghost",size:"sm",onClick:()=>w("antigravity"),children:A("logViewer.toolCount",{tool:"Antigravity",count:b.filter(a=>a.toLowerCase().includes("antigravity")).length})})]})]})}),(0,e.jsxs)(n.Wu,{children:[j&&0===b.length&&(0,e.jsx)("div",{className:"text-center py-4",children:(0,e.jsx)(n.y$,{size:"lg",variant:"accent",className:"inline-block"})}),m&&(0,e.jsx)("div",{className:"p-3 bg-danger-subtle border border-danger-border rounded text-sm text-danger-foreground",children:m}),!j&&0===B.length&&!m&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:"all"===v?A("logViewer.empty"):A("logViewer.emptyFiltered",{tool:v})}),B.length>0&&(0,e.jsx)("div",{className:"space-y-2",children:B.map(a=>(0,e.jsx)("button",{onClick:()=>C(a),className:`w-full text-left px-3 py-2 rounded text-sm font-mono transition-colors ${d===a?"bg-accent-50 text-accent-700 border border-accent-200":"hover:bg-muted border border-transparent"}`,children:a},a))})]})]}),d&&(0,e.jsxs)(n.Zp,{padding:"md",children:[(0,e.jsx)(n.aR,{children:(0,e.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(n.ZB,{className:"font-mono text-base",children:d}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(n.$n,{variant:"ghost",size:"sm",onClick:D,disabled:!d||x,title:A("logViewer.copyTitle"),children:x?A("logViewer.exporting"):A("logViewer.export")}),(0,e.jsx)(n.$n,{variant:"ghost",size:"sm",onClick:()=>{f(null),i(null),r(""),u(0)},children:A("actions.close")})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"relative flex-1",children:[(0,e.jsx)(n.pd,{type:"text",value:q,onChange:a=>r(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?G():F())},placeholder:A("logViewer.searchPlaceholder"),className:"w-full pr-20"}),E.length>0&&(0,e.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-muted-foreground",children:[t+1," / ",E.length]})]}),E.length>0&&(0,e.jsxs)("div",{className:"flex gap-1",children:[(0,e.jsx)(n.$n,{variant:"ghost",size:"sm",onClick:G,disabled:0===E.length,title:A("logViewer.prevMatch"),children:"↑"}),(0,e.jsx)(n.$n,{variant:"ghost",size:"sm",onClick:F,disabled:0===E.length,title:A("logViewer.nextMatch"),children:"↓"})]})]})]})}),(0,e.jsxs)(n.Wu,{children:[j&&(0,e.jsx)("div",{className:"text-center py-8",children:(0,e.jsx)(n.y$,{size:"xl",variant:"accent",className:"inline-block"})}),!j&&g&&(0,e.jsx)("div",{className:"bg-[#111827] text-[#f3f4f6] rounded p-4 overflow-x-auto max-h-[500px] scrollbar-thin",children:q&&E.length>0?(0,e.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",dangerouslySetInnerHTML:{__html:H||""}}):(0,e.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",children:g})}),!j&&q&&0===E.length&&g&&(0,e.jsx)("div",{className:"text-center py-4 text-sm text-muted-foreground",children:A("logViewer.noMatches",{query:q})})]})]})]})}function a1(){let[a,b]=(0,h.useState)(null),[c,d]=(0,h.useState)(!0),[e,f]=(0,h.useState)(null);return{data:a,loading:c,error:e}}var a2=c(94260);function a3({hasUpdate:a,latestVersion:b,releaseUrl:c,updateCommand:d,installType:f}){let g=(0,k.c)("worktree"),[i,j]=(0,h.useState)("idle"),[l,n]=(0,h.useState)(null),[o,p]=(0,h.useState)(null);(0,h.useRef)(!1);let q="global"===f,r="npx"===f,s=q||r,t=r?"npx commandmate@latest":"commandmate update",u=(0,h.useCallback)(async()=>{j("starting");try{let a=await T.GQ.startUpdate();n(a.logPath),j(a.willRestart?"updating":"no-restart")}catch(a){a instanceof T.hD&&400===a.status?p(g("update.errorNotGlobal")):a instanceof T.hD&&409===a.status?p(g("update.errorInProgress")):p(g("update.errorGeneric")),j("error")}},[g]);return a?(0,e.jsxs)("div",{className:"bg-accent-50 border border-accent-200 rounded-lg p-3 mt-2",role:"status","aria-label":g("update.available"),"data-testid":"update-notification-banner",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-accent-800 mb-1",children:g("update.available")}),b&&(0,e.jsx)("p",{className:"text-sm text-accent-700 mb-2",children:g("update.latestVersion",{version:b})}),s&&"idle"===i&&(0,e.jsx)(a2.$,{variant:"primary",size:"sm",className:"mb-2",onClick:()=>j("confirming"),"data-testid":"update-now-button",children:g("update.updateNow")}),r&&"idle"===i&&(0,e.jsx)("p",{className:"text-xs text-accent-600 mb-2","data-testid":"update-npx-notice",children:g("update.npxRestartNotice")}),("starting"===i||"updating"===i)&&(0,e.jsxs)("div",{className:"mb-2","data-testid":"update-progress",children:[(0,e.jsxs)("p",{className:"flex items-center text-sm text-accent-800",children:[(0,e.jsx)(m.y,{size:"sm",className:"mr-2"}),"starting"===i?g("update.starting"):g("update.updating")]}),"updating"===i&&(0,e.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:g("update.updatingHint")})]}),"no-restart"===i&&(0,e.jsxs)("div",{className:"mb-2","data-testid":"update-no-restart",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-accent-800",children:g("update.noRestartTitle")}),(0,e.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:g("update.noRestartDescription")})]}),"timeout"===i&&(0,e.jsxs)("div",{className:"mb-2","data-testid":"update-timeout",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-accent-800",children:g("update.timeoutTitle")}),(0,e.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:g("update.timeoutDescription")}),(0,e.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 mt-1 text-xs text-accent-900 font-mono",children:t})]}),"error"===i&&(0,e.jsxs)("div",{className:"mb-2","data-testid":"update-error",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-accent-800",children:g("update.errorTitle")}),(0,e.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:o}),(0,e.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 mt-1 text-xs text-accent-900 font-mono",children:t})]}),l&&("no-restart"===i||"timeout"===i)&&(0,e.jsx)("p",{className:"text-xs text-accent-500 mb-2","data-testid":"update-log-hint",children:g("update.logHint",{path:l})}),d&&q&&"idle"===i&&(0,e.jsxs)("div",{className:"mb-2",children:[(0,e.jsx)("p",{className:"text-xs text-accent-600 mb-1",children:g("update.updateCommand")}),(0,e.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 text-xs text-accent-900 font-mono",children:d})]}),c&&(0,e.jsxs)("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-accent-600 hover:text-accent-800 underline",children:[g("update.viewRelease"),(0,e.jsx)("span",{className:"ml-1","aria-hidden":"true",children:"→"})]}),(0,e.jsx)("p",{className:"text-xs text-accent-500 mt-2",children:g("update.dataPreserved")}),(0,e.jsx)(am.TM,{isOpen:"confirming"===i,title:g("update.confirmTitle"),description:g("update.confirmDescription",{version:b??""}),confirmLabel:g("update.confirmButton"),onConfirm:u,onCancel:()=>j("idle")})]}):null}function a4({version:a,className:b}){let c=(0,k.c)("worktree"),{data:d,loading:f}=a1(),g=(0,h.useMemo)(()=>d&&d.hasUpdate?{hasUpdate:d.hasUpdate,latestVersion:d.latestVersion,releaseUrl:d.releaseUrl,updateCommand:d.updateCommand,installType:d.installType}:null,[d]);return(0,e.jsxs)("div",{className:b,"data-testid":"version-section",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:c("update.version")}),(0,e.jsx)("p",{className:"text-sm text-foreground",children:a}),f&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1","data-testid":"version-loading",children:"..."}),g&&(0,e.jsx)(a3,{...g})]})}let a5="https://github.com/Kewton/CommandMate",a6=`${a5}/issues`,a7=`${a5}/issues/new`,a8=`${a7}?template=bug_report.md`,a9=`${a7}?template=feature_request.md`,ba=`${a7}?template=question.md`;function bb({className:a}){let b=(0,k.c)("worktree"),c=[{href:a8,label:b("feedback.bugReport")},{href:a9,label:b("feedback.featureRequest")},{href:ba,label:b("feedback.question")},{href:a6,label:b("feedback.viewIssues")}];return(0,e.jsxs)("div",{className:a,"data-testid":"feedback-section",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-2",children:b("feedback.title")}),(0,e.jsx)("div",{className:"flex flex-col gap-1",children:c.map(({href:a,label:b})=>(0,e.jsxs)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-accent-600 hover:text-accent-800 underline",children:[b,(0,e.jsx)("span",{className:"ml-1","aria-hidden":"true",children:"→"})]},a))})]})}var bc=c(98033),bd=c(65899),be=c(17252),bf=c(85351);let bg="application/x-commandmate-agent-instance",bh=(0,h.memo)(function({splitIndex:a,cliToolId:b,instanceId:c,instance:d,availableInstances:f,onInstanceChange:g,status:i="idle",onFocus:j,attaching:l=!1,headerExtras:m,terminal:n,footer:p,style:q,onDropInstance:r,draggedInstanceId:s}){let t=(0,k.c)("worktree"),[u,v]=(0,h.useState)(null),w=null!=r,x=(0,h.useCallback)(()=>null==s||f.some(a=>a.id===s)?"allowed":"forbidden",[s,f]),y=(0,h.useCallback)(a=>{if(!w)return;a.preventDefault();let b=x();a.dataTransfer.dropEffect="forbidden"===b?"none":"move",v(a=>a===b?a:b)},[w,x]),z=(0,h.useCallback)(a=>{if(!w)return;a.preventDefault();let b=x();v(a=>a===b?a:b)},[w,x]),A=(0,h.useCallback)(()=>{w&&v(null)},[w]),B=(0,h.useCallback)(a=>{if(!w)return;a.preventDefault(),v(null);let b=a.dataTransfer.getData(bg);b&&r?.(b)},[w,r]),C=(0,h.useCallback)(()=>{window.dispatchEvent(new CustomEvent("terminal-search-open"))},[]),D=(0,h.useCallback)(()=>{j()},[j]),E=`Terminal split ${a+1}`,F=(0,be.sw)(d??{cliTool:b}),G=t("terminal.selectInstance",{split:E});return(0,e.jsxs)("div",{role:"region","aria-label":E,"data-testid":`terminal-split-pane-${a}`,"data-split-index":a,style:q,className:`flex flex-col min-w-0 h-full rounded-lg overflow-hidden border border-border bg-surface${null===u?" focus-within:ring-1 focus-within:ring-accent-500/30":""}${"allowed"===u?" ring-2 ring-accent-400":"forbidden"===u?" ring-2 ring-red-300 cursor-not-allowed":""}`,onFocusCapture:D,onMouseDown:j,onDragOver:y,onDragEnter:z,onDragLeave:A,onDrop:B,children:[(0,e.jsxs)("div",{className:"px-2 py-1 flex items-center gap-2 bg-surface-2 border-b border-border flex-shrink-0",children:[(0,e.jsxs)(aZ.rI,{children:[(0,e.jsxs)(aZ.ty,{"data-testid":`cli-selector-${a}`,"aria-label":G,className:"flex items-center gap-1.5 min-w-0 max-w-[12rem] rounded px-1.5 py-0.5 text-xs border border-border bg-surface text-surface-foreground hover:bg-muted focus:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:ring-2 data-[state=open]:ring-ring transition-colors",children:[(0,e.jsx)(o.m,{status:i,size:"sm","aria-hidden":!0,"data-testid":`split-status-indicator-${a}`}),(0,e.jsx)("span",{className:"truncate",children:F}),(0,e.jsx)(bf.A,{size:14,"aria-hidden":"true",className:"flex-shrink-0 opacity-70"})]}),(0,e.jsx)(aZ.SQ,{align:"start",className:"min-w-[10rem]",children:(0,e.jsx)(aZ.Hr,{value:c,onValueChange:g,children:f.map(a=>(0,e.jsx)(aZ.Ht,{value:a.id,children:(0,be.sw)(a)},a.id))})})]}),m,(0,e.jsx)("button",{type:"button",onClick:C,"aria-label":`Search terminal output for ${E}`,"data-testid":`terminal-search-button-${a}`,className:"ml-auto flex items-center gap-1 px-1.5 py-0.5 text-xs text-muted-foreground hover:text-surface-foreground hover:bg-muted-foreground/10 rounded transition-colors",children:(0,e.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})})]}),(0,e.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[l?(0,e.jsxs)("div",{"data-testid":`terminal-attach-skeleton-${a}`,className:"absolute inset-0 flex items-center justify-center text-xs text-muted-foreground bg-surface-2/80",role:"status","aria-live":"polite",children:["Attaching ",F," session..."]}):null,n]}),(0,e.jsx)("div",{className:"flex-shrink-0 border-t border-border p-2 bg-surface-2",children:p})]})});var bi=c(8509),bj=c(70584),bk=c(24417),bl=c(3350),bm=c.n(bl),bn=c(19331);let bo=new(c.n(bn)())({fg:"#d1d5db",bg:"#1f2937",newline:!0,escapeXML:!0});function bp(a){let b=a.replace(/\0/g,"");b.length>1048576&&(b=b.slice(0,1048576));let c=bo.toHtml(b);return bm().sanitize(c,{ALLOWED_TAGS:["span","br"],ALLOWED_ATTR:["style"],ALLOW_DATA_ATTR:!1})}let bq=/\x1b(?:\[[0-9;?]*)?$/,br=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07]*\x07|\[[0-9;]*m/g;function bs(a){return""===a.replace(br,"").trim()}function bt({query:a,onQueryChange:b,matchCount:c,currentIndex:d,onNext:f,onPrev:g,onClose:i,isAtMaxMatches:j=!1}){let k=(0,h.useRef)(null),l=(0,h.useCallback)(a=>{"Escape"===a.key&&i()},[i]),m=(0,h.useCallback)(a=>{b(a.target.value)},[b]),n=0===c?"0/0":j?`${d+1}/500以上`:`${d+1}/${c}`;return(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-gray-800 border border-gray-600 rounded shadow-lg",role:"search","aria-label":"ターミナル内テキスト検索",children:[(0,e.jsx)("input",{ref:k,type:"text",value:a,onChange:m,onKeyDown:l,placeholder:"検索...",className:"bg-transparent text-gray-200 text-sm outline-none w-32 sm:w-40 placeholder-gray-500","aria-label":"検索キーワード",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,e.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"text-gray-400 text-xs min-w-[3rem] text-right",children:n}),(0,e.jsx)("button",{onClick:g,disabled:0===c,"aria-label":"前の結果",className:"text-gray-300 hover:text-white disabled:text-gray-600 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▲"}),(0,e.jsx)("button",{onClick:f,disabled:0===c,"aria-label":"次の結果",className:"text-gray-300 hover:text-white disabled:text-gray-600 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▼"}),(0,e.jsx)("button",{onClick:i,"aria-label":"検索を閉じる",className:"text-gray-400 hover:text-white min-w-[36px] min-h-[36px] flex items-center justify-center text-base ml-1",children:"✕"})]})}function bu(){return(0,e.jsxs)("div",{"data-testid":"thinking-indicator",className:"flex items-center gap-2 py-2 px-1 text-gray-400",children:[(0,e.jsxs)("span",{className:"flex gap-1",children:[(0,e.jsx)("span",{className:"animate-pulse delay-0",children:"."}),(0,e.jsx)("span",{className:"animate-pulse delay-150",children:"."}),(0,e.jsx)("span",{className:"animate-pulse delay-300",children:"."})]}),(0,e.jsx)("span",{className:"text-sm",children:"Thinking"})]})}let bv=(0,h.memo)(function({output:a,isActive:b,attaching:c=!1,isThinking:d=!1,autoScroll:f=!0,onScrollChange:g,disableAutoFollow:i=!1,compactTuiLayoutPadding:j=!1,className:k=""}){let{scrollRef:l,autoScroll:m,handleScroll:n,scrollToBottom:o,scrollToTop:p}=function(a={}){let{initialAutoScroll:b=!0,onAutoScrollChange:c}=a,d=(0,h.useRef)(null),[e,f]=(0,h.useState)(b),g=(0,h.useRef)(!1),i=(0,h.useRef)(null),j=(0,h.useCallback)(a=>{f(a),c?.(a)},[c]),k=(0,h.useCallback)(()=>{let a=d.current;if(!a)return!0;let{scrollTop:b,scrollHeight:c,clientHeight:e}=a;return c-e-b<=50},[]),l=(0,h.useCallback)(()=>{if(g.current)return;let a=k();a&&!e?j(!0):!a&&e&&j(!1)},[e,k,j]),m=(0,h.useCallback)(()=>{let a=d.current;a&&(g.current=!0,a.scrollTo({top:a.scrollHeight,behavior:"smooth"}),e||j(!0),i.current=setTimeout(()=>{g.current=!1,i.current=null},500))},[e,j]),n=(0,h.useCallback)(()=>{let a=d.current;a&&(g.current=!0,a.scrollTo({top:0,behavior:"smooth"}),e&&j(!1),i.current=setTimeout(()=>{g.current=!1,i.current=null},500))},[e,j]);return{scrollRef:d,autoScroll:e,setAutoScroll:j,scrollToBottom:m,scrollToTop:n,handleScroll:l}}({initialAutoScroll:f,onAutoScrollChange:g}),q=a??"",r=(0,h.useMemo)(()=>j?function(a){if(""===a)return"";let b=a.split("\n"),c=[],d=!1,e=0;for(;e<b.length;){if(!bs(b[e])){c.push(b[e]),d=!0,e++;continue}let a=e;for(;a<b.length&&bs(b[a]);)a++;let f=a-e,g=!d,h=a>=b.length;if(!g&&!h)if(f<=2)for(let d=e;d<a;d++)c.push(b[d]);else c.push(function(a){let b=a.match(br);return b?b.join(""):""}(b.slice(e,a).join("")));e=a}return c.join("\n")}(q):q,[j,q]),{isOpen:s,query:t,matchCount:u,currentIndex:v,isAtMaxMatches:w,openSearch:x,closeSearch:y,setQuery:z,nextMatch:A,prevMatch:B}=function({output:a,containerRef:b}){let[c,d]=(0,h.useState)(!1),[e,f]=(0,h.useState)(""),[g,i]=(0,h.useState)([]),[j,k]=(0,h.useState)(0),[l,m]=(0,h.useState)(!1),n=(0,h.useRef)(null),o=(0,h.useRef)(""),p=g.length,q=(0,h.useCallback)(a=>{if(a.length<2||!b.current)return{positions:[],capped:!1};let c=(b.current.textContent??"").toLowerCase(),d=a.toLowerCase(),e=[],f=0;for(;e.length<500;){let b=c.indexOf(d,f);if(-1===b)break;e.push({start:b,end:b+a.length}),f=b+1}let g=e.length>=500&&-1!==c.indexOf(d,f);return{positions:e,capped:g}},[b]),r=(0,h.useCallback)(a=>{let{positions:c,capped:d}=q(a);if(i(c),k(0),m(d),b.current)if(c.length>0){var e;e=b.current,aL(e,c,0,aG)}else aK(aG)},[q,b]),s=(0,h.useCallback)(a=>{f(a),n.current&&clearTimeout(n.current),o.current=a,n.current=setTimeout(()=>{r(a)},300)},[r]),t=(0,h.useCallback)(()=>{d(!0)},[]),u=(0,h.useCallback)(()=>{d(!1),f(""),o.current="",i([]),k(0),m(!1),n.current&&clearTimeout(n.current),aK(aG)},[]),v=(0,h.useCallback)(()=>{0!==p&&k(a=>{let c=(a+1)%p;return b.current&&g.length>0&&aL(b.current,g,c,aG),c})},[p,g,b]),w=(0,h.useCallback)(()=>{0!==p&&k(a=>{let c=(a-1+p)%p;return b.current&&g.length>0&&aL(b.current,g,c,aG),c})},[p,g,b]);return{isOpen:c,query:e,matchCount:p,currentIndex:j,isAtMaxMatches:l,openSearch:t,closeSearch:u,setQuery:s,nextMatch:v,prevMatch:w}}({output:r,containerRef:l}),C=(0,h.useCallback)(a=>{(a.ctrlKey||a.metaKey)&&"f"===a.key&&(a.preventDefault(),x())},[x]);(0,h.useEffect)(()=>{let a=()=>x();return window.addEventListener("terminal-search-open",a),()=>window.removeEventListener("terminal-search-open",a)},[x]);let[D,E]=(0,h.useState)(()=>r?[{key:0,html:bp(r)}]:[]),F=(0,h.useRef)(r),G=(0,h.useRef)(0);(0,h.useEffect)(()=>{let a=function(a,b){if(a===b)return{mode:"noop",text:b,appended:"",retainedLength:a.length};if(0===a.length||b.length<=a.length||!b.startsWith(a))return{mode:"replace",text:b,appended:"",retainedLength:0};let c=a.match(bq),d=c?a.length-c[0].length:a.length;return{mode:"append",text:b,appended:b.slice(d),retainedLength:d}}(F.current,r);if(F.current=r,"noop"!==a.mode){if("append"===a.mode)return void E(b=>(G.current+=1,b.length>=400)?[{key:G.current,html:bp(r)}]:[...b,{key:G.current,html:bp(a.appended)}]);G.current+=1,E(r?[{key:G.current,html:bp(r)}]:[])}},[r]);let[H,I]=(0,h.useState)(!1);(0,h.useEffect)(()=>{c?I(!1):b&&I(!0)},[c,b]);let J=!a,K=J&&c,L=J&&!c&&!b&&H,M=(0,h.useRef)(!1);(0,h.useEffect)(()=>{i&&(M.current=!0)},[i]),(0,h.useEffect)(()=>{if(l.current){if(M.current&&i&&r){l.current.scrollTo({top:0,behavior:"instant"}),M.current=!1;return}!i&&m&&l.current.scrollTo({top:l.current.scrollHeight,behavior:"instant"})}},[D,r,m,i,l]);let N=(0,h.useMemo)(()=>["terminal","font-mono","text-sm","p-4","rounded-lg","overflow-y-auto","overflow-x-hidden","bg-gray-900","text-gray-300","border","border-gray-700","h-full",b?"active":"",k].filter(Boolean).join(" "),[b,k]),[O,P]=(0,h.useState)(!1),Q=(0,h.useRef)(null),R=(0,h.useCallback)(()=>{P(!0),Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>P(!1),1500)},[]);(0,h.useEffect)(()=>()=>{Q.current&&clearTimeout(Q.current)},[]);let S=(0,h.useCallback)(()=>{n(),R()},[n,R]),T=["absolute bottom-4 right-4 flex items-center justify-center h-9 w-9 rounded-full bg-surface/80 backdrop-blur border border-border text-muted-foreground shadow-lg transition-opacity hover:text-surface-foreground hover:opacity-100 focus-visible:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",O?"opacity-100":"opacity-60"].join(" ");return(0,e.jsxs)("div",{className:"relative h-full flex flex-col",children:[s&&(0,e.jsx)("div",{className:"absolute top-2 right-2 z-10",children:(0,e.jsx)(bt,{query:t,onQueryChange:z,matchCount:u,currentIndex:v,onNext:A,onPrev:B,onClose:y,isAtMaxMatches:w})}),(0,e.jsxs)("div",{ref:l,role:"log","aria-live":"polite","aria-label":"Terminal output",className:N,onScroll:S,onKeyDown:C,tabIndex:0,children:[(0,e.jsx)("div",{className:"whitespace-pre-wrap break-words",children:D.map(a=>(0,e.jsx)("span",{dangerouslySetInnerHTML:{__html:a.html}},a.key))}),K&&(0,e.jsx)("div",{"data-testid":"terminal-loading-placeholder",className:"flex h-full items-center justify-center px-4 text-center text-sm text-gray-500 select-none",children:"読込中..."}),L&&(0,e.jsx)("div",{"data-testid":"terminal-ended-placeholder",className:"flex h-full items-center justify-center px-4 text-center text-sm text-gray-500 select-none",children:"セッションは終了しました(メッセージ送信で再開できます)"}),b&&d&&(0,e.jsx)(bu,{})]}),m?(0,e.jsx)("button",{type:"button",onClick:p,className:T,"aria-label":"Scroll to top",children:(0,e.jsx)(bj.A,{size:16,"aria-hidden":"true"})}):(0,e.jsx)("button",{type:"button",onClick:o,className:T,"aria-label":"Scroll to bottom",children:(0,e.jsx)(bk.A,{size:16,"aria-hidden":"true"})})]})}),bw=[{key:"Left",label:"◀",ariaLabel:"Send Left"},{key:"Up",label:"▲",ariaLabel:"Send Up"},{key:"Down",label:"▼",ariaLabel:"Send Down"},{key:"Right",label:"▶",ariaLabel:"Send Right"},{key:"Enter",label:"↵",ariaLabel:"Send Enter"}],bx={key:"Escape",label:"Esc",ariaLabel:"Send Escape"},by={key:"q",label:"q",ariaLabel:"Send q (quit)"};function bz({worktreeId:a,cliToolId:b,instanceId:c,onKeysSent:d}){let[f,g]=(0,h.useState)(null),i=ai(a,b,c,d),j="codex"===b?[...bw,bx,by]:[...bw,bx],k=(0,h.useCallback)(a=>{g(a),setTimeout(()=>g(null),ah.tX),i([a])},[i]);return(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 py-1.5 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800/50 rounded-lg",role:"toolbar","aria-label":"Terminal navigation keys",children:[(0,e.jsx)("span",{className:"text-xs text-amber-700 dark:text-amber-400 mx-2",title:"Send navigation / escape keys when the terminal is stuck in a TUI overlay",children:"Navigate"}),j.map(({key:a,label:b,ariaLabel:c})=>(0,e.jsx)("button",{type:"button",className:`min-w-[44px] min-h-[44px] px-3 py-2 text-sm font-medium rounded-md
21
21
  border border-amber-300 dark:border-amber-700
22
22
  focus:outline-none focus:ring-2 focus:ring-amber-500
23
23
  transition-colors duration-75
@@ -30,7 +30,7 @@ document.addEventListener('click', function(e) {
30
30
  ${a("git.aiPrompts.stashCleanupCurrent")}
31
31
  ${d}`}(s,a))}),(0,e.jsx)("button",{type:"button",onClick:j,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":s("git.stash.refresh"),children:(0,e.jsx)(ep,{})})]})]}),u&&(0,e.jsxs)("div",{className:"px-3 pb-3 space-y-2",children:[c&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-stash-error",children:c}),f&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-stash-action-error",children:f}),g&&(0,e.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,e.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-stash-conflict",children:g}),r&&(0,e.jsx)(eq,{className:"shrink-0",testId:"stash-conflict-ask-ai",onClick:()=>r(function(a,b){let c=a("git.aiPrompts.stashConflict");return b&&b.trim().length>0?`${c}
32
32
 
33
- ${b.trim()}`:c}(s,g))})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)("input",{type:"text",value:w,onChange:a=>x(a.target.value),placeholder:s("git.stash.messagePlaceholder"),className:"w-full px-2 py-1 text-xs border border-input rounded bg-surface dark:bg-surface-2 text-foreground","data-testid":"git-stash-push-message"}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,e.jsx)(n.Sc,{checked:y,onCheckedChange:a=>z(!0===a),"data-testid":"git-stash-include-untracked"}),s("git.stash.includeUntracked")]}),(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>{l(w,y),x(""),z(!1)},className:"px-2 py-1 text-xs rounded bg-accent-600 hover:bg-accent-700 text-white disabled:opacity-50","data-testid":"stash-push-button",children:s("git.stash.push")})]})]}),b?(0,e.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",role:"status",children:s("git.stash.loading")}):0===a.length?(0,e.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",children:s("git.stash.empty")}):(0,e.jsx)("ul",{className:"divide-y divide-border",children:a.map(a=>(0,e.jsx)("li",{className:"py-1.5","data-testid":"git-stash-row",children:(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("span",{className:"font-mono text-xs text-accent-600 dark:text-accent-400",children:["stash@","{",a.index,"}"]}),(0,e.jsx)("span",{className:"ml-2 text-xs text-foreground truncate",children:a.message})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>o(a.index),className:"px-1.5 py-0.5 text-xs rounded border border-input hover:bg-muted disabled:opacity-50","data-testid":"stash-apply-button",children:s("git.stash.apply")}),(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>m(a.index),className:"px-1.5 py-0.5 text-xs rounded border border-input hover:bg-muted disabled:opacity-50","data-testid":"stash-pop-button",children:s("git.stash.pop")}),(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>B(a.index),className:"px-1.5 py-0.5 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"stash-drop-button",children:s("git.stash.drop")})]})]})},a.index))})]}),null!==A&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"git-stash-drop-confirm",role:"dialog",children:[(0,e.jsxs)("p",{className:"text-xs text-danger-foreground",children:["stash@","{",A,"}",s("git.stash.dropConfirmSuffix")]}),i&&(0,e.jsx)("p",{className:"mt-1 text-xs text-danger-foreground","data-testid":"git-stash-drop-session-warning",children:s("git.danger.runningSessionWarning")}),(0,e.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>{p(A),B(null)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"git-stash-drop-confirm-button",children:s("git.stash.drop")}),(0,e.jsx)("button",{type:"button",onClick:()=>B(null),className:"px-2 py-1 text-xs rounded border border-input hover:bg-muted",children:t("cancel")})]})]})]})}),eD={soft:"git.danger.modeSoft",mixed:"git.danger.modeMixed",hard:"git.danger.modeHard"},eE=(0,h.memo)(function({selectedCommit:a,busy:b,actionError:c,conflictNotice:d,currentBranch:f,aheadCount:g,hasRunningSession:i,onReset:j,onRevert:l,onForcePush:m}){let{isMobile:o,onInsertToMessage:p}=ei(),q=(0,k.c)("worktree"),r=(0,k.c)("common"),[s,t]=(0,h.useState)(!1),[u,v]=(0,h.useState)("mixed"),[w,x]=(0,h.useState)(!0),[y,z]=(0,h.useState)(""),[A,B]=(0,h.useState)(!1),[C,D]=(0,h.useState)(!1),[E,F]=(0,h.useState)(!1),[G,H]=(0,h.useState)(!1),[I,J]=(0,h.useState)(!0),K=w?"HEAD":a,L=!w&&!a;return(0,e.jsxs)("div",{className:"border-t-2 border-danger-border","data-testid":"git-danger-zone-section",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>t(a=>!a),className:"w-full flex items-center gap-1 px-3 py-2 text-sm font-medium text-danger-foreground bg-danger-subtle cursor-pointer hover:bg-danger-subtle","data-testid":"git-danger-zone-toggle",children:[(0,e.jsx)("span",{className:"text-xs w-4 text-center",children:s?"▼":"▶"}),q("git.danger.title")]}),s&&(0,e.jsxs)("div",{className:"px-3 py-3 space-y-2 bg-danger-subtle",children:[c&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-danger-zone-error",children:c}),d&&(0,e.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-danger-zone-conflict",children:d}),(0,e.jsxs)("div",{className:`flex ${o?"flex-col":"flex-row"} gap-2`,children:[(0,e.jsx)("button",{type:"button",onClick:()=>B(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle","data-testid":"git-danger-zone-reset-open",children:q("git.danger.resetOpen")}),(0,e.jsx)("button",{type:"button",disabled:!a,onClick:()=>D(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"git-danger-zone-revert-open",children:q("git.danger.revertOpen")}),m&&(0,e.jsx)("button",{type:"button",disabled:b,onClick:()=>H(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"git-force-push-open",children:q("git.danger.forcePushOpen")})]}),!a&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:q("git.danger.selectCommitHint")})]}),A&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"reset-confirm",role:"dialog",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:q("git.danger.resetTitle")}),(0,e.jsxs)(n.z6,{value:w?"head":"commit",onValueChange:a=>x("head"===a),name:"reset-target",className:"flex flex-col gap-1 mb-2",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,e.jsx)(n.CU,{value:"head","data-testid":"reset-target-head"}),q("git.danger.resetTargetHead")]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,e.jsx)(n.CU,{value:"commit",disabled:!a,"data-testid":"reset-target-commit"}),q("git.danger.resetTargetSelectedPrefix"),a?q("git.danger.resetTargetSelectedHash",{hash:a.slice(0,7)}):q("git.danger.resetTargetNoneSelected")]})]}),(0,e.jsx)(n.z6,{value:u,onValueChange:a=>v(a),name:"reset-mode",className:"flex flex-col gap-1 mb-2",children:["soft","mixed","hard"].map(a=>(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,e.jsx)(n.CU,{value:a,"data-testid":`reset-mode-${a}`}),q(eD[a])]},a))}),"hard"===u&&(0,e.jsxs)("div",{className:"mb-2 space-y-1",children:[(0,e.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-history-loss-warning",children:q("git.danger.resetHardWarning")}),i&&(0,e.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-session-warning",children:q("git.danger.runningSessionWarning")}),(0,e.jsx)("input",{type:"text",value:y,onChange:a=>z(a.target.value),placeholder:q("git.danger.confirmPlaceholder",{branch:f??""}),className:"w-full px-2 py-1 text-xs border border-danger-border rounded bg-surface dark:bg-surface-2 text-foreground","data-testid":"reset-hard-branch-input"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,e.jsx)(eq,{className:"mr-auto",testId:"reset-ask-ai",disabled:L,onClick:()=>{K&&(p("hard"===u?q("git.aiPrompts.resetHard",{target:ez(K)}):q("git.aiPrompts.reset",{target:ez(K),mode:u})),B(!1),z(""))}}),(0,e.jsx)("button",{type:"button",disabled:b||L||"hard"===u&&y!==(f??""),onClick:()=>{K&&(j(K,u,"hard"===u?y:void 0),B(!1),z(""))},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"reset-confirm-button",children:q("git.danger.reset")}),(0,e.jsx)("button",{type:"button",onClick:()=>{B(!1),z("")},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:r("cancel")})]})]}),C&&a&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"revert-confirm",role:"dialog",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:q("git.danger.revertTitle")}),(0,e.jsxs)("p",{className:"text-xs text-foreground mb-2",children:[q("git.danger.revertBodyPrefix"),(0,e.jsx)("span",{className:"font-mono",children:a.slice(0,7)})]}),i&&(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"revert-session-warning",children:q("git.danger.runningSessionWarning")}),(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,e.jsx)(n.Sc,{checked:E,onCheckedChange:a=>F(!0===a),"data-testid":"revert-no-commit"}),q("git.danger.revertNoCommit")]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,e.jsx)(eq,{className:"mr-auto",testId:"revert-ask-ai",onClick:()=>{p(q("git.aiPrompts.revert",{commit:ez(a.slice(0,7))})),D(!1),F(!1)}}),(0,e.jsx)("button",{type:"button",disabled:b,onClick:()=>{l(a,E),D(!1),F(!1)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"revert-confirm-button",children:q("git.danger.revert")}),(0,e.jsx)("button",{type:"button",onClick:()=>{D(!1),F(!1)},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:r("cancel")})]})]}),G&&m&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"force-push-confirm",role:"dialog",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:q("git.danger.forcePushTitle")}),(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-protected-branch-warning",children:q("git.danger.protectedBranchWarning")}),i&&(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-session-warning",children:q("git.danger.runningSessionWarning")}),(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,e.jsx)(n.Sc,{checked:I,onCheckedChange:a=>J(!0===a),"data-testid":"force-push-with-lease"}),q("git.danger.forceWithLease")]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,e.jsx)(eq,{className:"mr-auto",testId:"force-push-ask-ai",onClick:()=>{p(function(a,{branch:b,ahead:c}){let d=b?ez(b):a("git.aiPrompts.forcePushCurrentBranch");return a("number"==typeof c&&c>0?"git.aiPrompts.forcePushAhead":"git.aiPrompts.forcePush",{branchRef:d,upstream:ez(`origin/${b??"<branch>"}`),ahead:c??0})}(q,{branch:f,ahead:g??null})),H(!1)}}),(0,e.jsx)("button",{type:"button",disabled:b,onClick:()=>{m(I),H(!1)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"force-push-confirm-button",children:q("git.danger.forcePush")}),(0,e.jsx)("button",{type:"button",onClick:()=>H(!1),className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:r("cancel")})]})]})]})}),eF=(0,h.memo)(function({worktreeId:a,onDiffSelect:b,isMobile:c=!1,worktree:d,onInsertToMessage:f,className:g=""}){let i=(0,k.c)("worktree"),{activeTab:j,setActiveTab:l,historyOpen:m,toggleHistory:o,advancedOpen:p,toggleAdvanced:q}=function(){let{value:a,setValue:b,isAvailable:c}=(0,d7.V)({key:ea.activeTab,defaultValue:"status",validate:eb}),{value:d,setValue:e}=(0,d7.V)({key:ea.historyOpen,defaultValue:!0,validate:ec}),{value:f,setValue:g}=(0,d7.V)({key:ea.advancedOpen,defaultValue:!1,validate:ec}),i=(0,h.useCallback)(a=>b(a),[b]);return{activeTab:a,setActiveTab:i,historyOpen:d,toggleHistory:(0,h.useCallback)(()=>e(a=>!a),[e]),advancedOpen:f,toggleAdvanced:(0,h.useCallback)(()=>g(a=>!a),[g]),isPersistent:c}}(),r=Object.values(d?.sessionStatusByCli??{}).some(a=>a?.isRunning===!0),{gitStatus:s,statusLoading:t,statusError:u,fetchStatus:v}=function(a){let[b,c]=(0,h.useState)(null),[d,e]=(0,h.useState)(!0),[f,g]=(0,h.useState)(null);return{gitStatus:b,statusLoading:d,statusError:f,fetchStatus:(0,h.useCallback)(async()=>{g(null);try{let b=await fetch(`/api/worktrees/${a}/git/status`);if(!b.ok){let a=await b.json().catch(()=>({}));g(a.error||"Failed to fetch git status");return}let d=await b.json();c(d)}catch{g("Failed to fetch git status")}finally{e(!1)}},[a])}}(a),{commits:w,selectedCommit:x,changedFiles:y,inlineDiffCommit:z,inlineFiles:A,inlineFilesLoading:B,inlineFilesError:C,selectedFile:D,diffContent:E,isLoading:F,isLoadingFiles:G,isLoadingDiff:H,commitError:I,detailError:J,setDiffContent:K,fetchCommits:L,handleCommitSelect:M,handleFileSelect:N,handleToggleInlineDiff:O,handleInlineDiffFile:P,handleRefresh:Q}=function(a,b){let[c,d]=(0,h.useState)([]),[e,f]=(0,h.useState)(null),[g,i]=(0,h.useState)([]),[j,k]=(0,h.useState)(null),[l,m]=(0,h.useState)([]),[n,o]=(0,h.useState)(!1),[p,q]=(0,h.useState)(null),[r,s]=(0,h.useState)(null),[t,u]=(0,h.useState)(null),[v,w]=(0,h.useState)(!0),[x,y]=(0,h.useState)(!1),[z,A]=(0,h.useState)(!1),[B,C]=(0,h.useState)(null),[D,E]=(0,h.useState)(null),F=(0,h.useCallback)(async()=>{w(!0),C(null);try{let b=await fetch(`/api/worktrees/${a}/git/log`);if(!b.ok){let a=await b.json();C(a.error||"Failed to fetch commit history");return}let c=await b.json();d(c.commits)}catch{C("Failed to fetch commit history")}finally{w(!1)}},[a]),G=(0,h.useCallback)(async b=>{y(!0),i([]),s(null),u(null),E(null);try{let c=await fetch(`/api/worktrees/${a}/git/show/${b}`);if(!c.ok){let a=await c.json();E(a.error||"Failed to fetch commit details");return}let d=await c.json();i(d.files)}catch{E("Failed to fetch commit details")}finally{y(!1)}},[a]),H=(0,h.useCallback)(async(c,d)=>{A(!0),u(null),E(null);try{let e=await fetch(`/api/worktrees/${a}/git/diff?commit=${c}&file=${encodeURIComponent(d)}`);if(!e.ok){let a=await e.json();E(a.error||"Failed to fetch diff");return}let f=await e.json();u(f.diff),b(f.diff,d)}catch{E("Failed to fetch diff")}finally{A(!1)}},[a,b]),I=(0,h.useCallback)(a=>{f(a),G(a)},[G]),J=(0,h.useCallback)(a=>{e&&(s(a),H(e,a))},[e,H]),K=(0,h.useCallback)(async b=>{if(j===b){k(null),m([]),q(null);return}k(b),m([]),q(null),o(!0);try{let c=await fetch(`/api/worktrees/${a}/git/show/${b}`);if(!c.ok){let a=await c.json().catch(()=>({}));q(a.error||"Failed to fetch commit details");return}let d=await c.json();m(Array.isArray(d.files)?d.files:[])}catch{q("Failed to fetch commit details")}finally{o(!1)}},[a,j]),L=(0,h.useCallback)((a,b)=>{f(a),s(b),i(l),H(a,b)},[l,H]),M=(0,h.useCallback)(()=>{f(null),i([]),s(null),u(null),E(null),F()},[F]);return{commits:c,selectedCommit:e,changedFiles:g,inlineDiffCommit:j,inlineFiles:l,inlineFilesLoading:n,inlineFilesError:p,selectedFile:r,diffContent:t,isLoading:v,isLoadingFiles:x,isLoadingDiff:z,commitError:B,detailError:D,setDiffContent:u,fetchCommits:F,handleCommitSelect:I,handleFileSelect:J,handleToggleInlineDiff:K,handleInlineDiffFile:L,handleRefresh:M}}(a,b),R=(0,h.useCallback)(async()=>{await L(),await v()},[L,v]),{staged:S,stagedLoading:T,stagedError:U,opBusy:V,commitMessage:W,setCommitMessage:X,amend:Y,setAmend:Z,committing:$,changesCommitError:_,fetchStaged:aa,handleStage:ab,handleUnstage:ac,handleChangesDiff:ad,fetchWorkingDiffText:ae,commit:af,commitAndPush:ag}=function(a,b){let{onWorkingDiff:c,onCommitted:d}=b,[e,f]=(0,h.useState)(null),[g,i]=(0,h.useState)(!0),[j,k]=(0,h.useState)(null),[l,m]=(0,h.useState)(!1),[n,o]=(0,h.useState)(""),[p,q]=(0,h.useState)(!1),[r,s]=(0,h.useState)(!1),[t,u]=(0,h.useState)(null),v=(0,h.useCallback)(async()=>{k(null);try{let b=await fetch(`/api/worktrees/${a}/git/staged`);if(!b.ok){let a=await b.json().catch(()=>({}));k(a.error||"Failed to fetch changes");return}let c=await b.json();f(c)}catch{k("Failed to fetch changes")}finally{i(!1)}},[a]),w=(0,h.useCallback)(async b=>{m(!0),k(null);try{let c=await fetch(`/api/worktrees/${a}/git/stage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[b]})});if(!c.ok){let a=await c.json().catch(()=>({}));k(a.error||"Failed to stage file");return}await v()}catch{k("Failed to stage file")}finally{m(!1)}},[a,v]),x=(0,h.useCallback)(async b=>{m(!0),k(null);try{let c=await fetch(`/api/worktrees/${a}/git/unstage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[b]})});if(!c.ok){let a=await c.json().catch(()=>({}));k(a.error||"Failed to unstage file");return}await v()}catch{k("Failed to unstage file")}finally{m(!1)}},[a,v]),y=(0,h.useCallback)(async()=>{u(null);try{let b=await fetch(`/api/worktrees/${a}/git/commit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:n,amend:p})});if(!b.ok){let a=await b.json().catch(()=>({}));return u(a.error||"Failed to commit"),!1}return o(""),q(!1),await v(),await d(),!0}catch{return u("Failed to commit"),!1}},[a,n,p,v,d]),z=(0,h.useCallback)(async()=>{s(!0);try{await y()}finally{s(!1)}},[y]),A=(0,h.useCallback)(async a=>{s(!0);try{await y()&&await a()}finally{s(!1)}},[y]);return{staged:e,stagedLoading:g,stagedError:j,opBusy:l,commitMessage:n,setCommitMessage:o,amend:p,setAmend:q,committing:r,changesCommitError:t,fetchStaged:v,handleStage:w,handleUnstage:x,handleChangesDiff:(0,h.useCallback)(async(b,d)=>{try{let e=await fetch(`/api/worktrees/${a}/git/working-diff?file=${encodeURIComponent(b)}&mode=${d}`);if(!e.ok)return;let f=await e.json();"string"==typeof f.diff&&c(f.diff,b)}catch{}},[a,c]),fetchWorkingDiffText:(0,h.useCallback)(async(b,c)=>{try{let d=await fetch(`/api/worktrees/${a}/git/working-diff?file=${encodeURIComponent(b)}&mode=${c}`);if(!d.ok)return null;let e=await d.json();return"string"==typeof e.diff?e.diff:null}catch{return null}},[a]),commit:z,commitAndPush:A}}(a,{onWorkingDiff:(0,h.useCallback)((a,c)=>{K(a),b(a,c)},[K,b]),onCommitted:R}),{branches:ah,branchInclude:ai,branchesLoading:aj,branchesError:ak,branchBusy:al,branchActionError:am,fetchBranches:an,handleBranchIncludeChange:ao,handleBranchesRefresh:ap,handleCheckout:aq,handleBranchCreate:ar,handleBranchDelete:as}=function(a,b){let{onCheckoutCascade:c}=b,[d,e]=(0,h.useState)([]),[f,g]=(0,h.useState)("local"),[i,j]=(0,h.useState)(!0),[k,l]=(0,h.useState)(null),[m,n]=(0,h.useState)(!1),[o,p]=(0,h.useState)(null),q=(0,h.useCallback)(async b=>{l(null);try{let c=await fetch(`/api/worktrees/${a}/git/branches?include=${b}`);if(!c.ok){let a=await c.json().catch(()=>({}));l(a.error||"Failed to fetch branches");return}let d=await c.json();e(Array.isArray(d.branches)?d.branches:[])}catch{l("Failed to fetch branches")}finally{j(!1)}},[a]),r=(0,h.useCallback)(a=>{g(a)},[]),s=(0,h.useCallback)(()=>{q(f)},[q,f]),t=(0,h.useCallback)(async(b,d)=>{n(!0),p(null);try{let e=await fetch(`/api/worktrees/${a}/git/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:b.name,force:d})});if(!e.ok){let a=await e.json().catch(()=>({}));p(a.error||"Failed to checkout branch");return}await Promise.all([c(),q(f)])}catch{p("Failed to checkout branch")}finally{n(!1)}},[a,f,c,q]),u=(0,h.useCallback)(async(b,c)=>{n(!0),p(null);try{let d=await fetch(`/api/worktrees/${a}/git/branch/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,from:c})});if(!d.ok){let a=await d.json().catch(()=>({}));p(a.error||"Failed to create branch");return}await q(f)}catch{p("Failed to create branch")}finally{n(!1)}},[a,f,q]),v=(0,h.useCallback)(async(b,c)=>{n(!0),p(null);try{let d=await fetch(`/api/worktrees/${a}/git/branch/delete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,force:c})});if(!d.ok){let a=await d.json().catch(()=>({}));p(a.error||"Failed to delete branch");return}await q(f)}catch{p("Failed to delete branch")}finally{n(!1)}},[a,f,q]);return{branches:d,branchInclude:f,branchesLoading:i,branchesError:k,branchBusy:m,branchActionError:o,fetchBranches:q,handleBranchIncludeChange:r,handleBranchesRefresh:s,handleCheckout:t,handleBranchCreate:u,handleBranchDelete:v}}(a,{onCheckoutCascade:(0,h.useCallback)(async()=>{await Promise.all([v(),aa(),L()])},[v,aa,L])}),{stashes:at,stashLoading:au,stashError:av,stashBusy:aw,stashActionError:ax,stashConflictNotice:ay,fetchStash:az,handleStashPush:aA,handleStashPop:aB,handleStashApply:aC,handleStashDrop:aD}=function(a,b){let{onStashMutated:c}=b,[d,e]=(0,h.useState)([]),[f,g]=(0,h.useState)(!0),[i,j]=(0,h.useState)(null),[k,l]=(0,h.useState)(!1),[m,n]=(0,h.useState)(null),[o,p]=(0,h.useState)(null),q=(0,h.useCallback)(async()=>{j(null);try{let b=await fetch(`/api/worktrees/${a}/git/stash`);if(!b.ok){let a=await b.json().catch(()=>({}));j(a.error||"Failed to fetch stashes");return}let c=await b.json();e(Array.isArray(c.stashes)?c.stashes:[])}catch{j("Failed to fetch stashes")}finally{g(!1)}},[a]),r=(0,h.useCallback)(async()=>{await Promise.all([q(),c()])},[q,c]),s=(0,h.useCallback)(async(a,b,c)=>{l(!0),n(null),p(null);try{let d=await fetch(a,b),e=await d.json().catch(()=>({}));if(!d.ok)return void n(e.error||c);if(e.conflict){let a=Array.isArray(e.conflictFiles)?e.conflictFiles.join(", "):"",b=e.stashRetained?" (stash retained)":"";p(`Stash operation produced conflicts: ${a}${b}`)}await r()}catch{n(c)}finally{l(!1)}},[r]),t=(0,h.useCallback)((b,c)=>{s(`/api/worktrees/${a}/git/stash/push`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:b||void 0,includeUntracked:c})},"Failed to stash changes")},[a,s]),u=(0,h.useCallback)(b=>{s(`/api/worktrees/${a}/git/stash/pop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:b})},"Failed to pop stash")},[a,s]);return{stashes:d,stashLoading:f,stashError:i,stashBusy:k,stashActionError:m,stashConflictNotice:o,fetchStash:q,handleStashPush:t,handleStashPop:u,handleStashApply:(0,h.useCallback)(b=>{s(`/api/worktrees/${a}/git/stash/apply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:b})},"Failed to apply stash")},[a,s]),handleStashDrop:(0,h.useCallback)(b=>{s(`/api/worktrees/${a}/git/stash/${b}`,{method:"DELETE"},"Failed to drop stash")},[a,s])}}(a,{onStashMutated:(0,h.useCallback)(async()=>{await Promise.all([v(),aa()])},[v,aa])}),{dangerBusy:aE,dangerActionError:aF,dangerConflictNotice:aG,handleReset:aH,handleRevert:aI}=function(a,b){let{onHeadMoved:c}=b,[d,e]=(0,h.useState)(!1),[f,g]=(0,h.useState)(null),[i,j]=(0,h.useState)(null);return{dangerBusy:d,dangerActionError:f,dangerConflictNotice:i,handleReset:(0,h.useCallback)(async(b,d,f)=>{e(!0),g(null),j(null);try{let e=await fetch(`/api/worktrees/${a}/git/reset`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:b,mode:d,confirmBranch:f})});if(!e.ok){let a=await e.json().catch(()=>({}));g(a.error||"Failed to reset");return}await c()}catch{g("Failed to reset")}finally{e(!1)}},[a,c]),handleRevert:(0,h.useCallback)(async(b,d)=>{e(!0),g(null),j(null);try{let e=await fetch(`/api/worktrees/${a}/git/revert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitHash:b,noCommit:d})});if(!e.ok){let a=await e.json().catch(()=>({}));g(a.error||"Failed to revert");return}let f=await e.json().catch(()=>({}));if(f.conflict){let a=Array.isArray(f.conflictFiles)?f.conflictFiles.join(", "):"";j(`Revert produced conflicts: ${a}`)}await c()}catch{g("Failed to revert")}finally{e(!1)}},[a,c])}}(a,{onHeadMoved:(0,h.useCallback)(async()=>{await Promise.all([v(),aa(),an(ai),L()])},[v,aa,an,ai,L])}),{operation:aJ,progressState:aK,error:aL,errorReason:aM,conflict:aN,conflictFiles:aO,runFetch:aP,runPull:aQ,runPush:aR,abort:aS}=function(a,b={}){let{onCascade:c}=b,[d,e]=(0,h.useState)(null),[f,g]=(0,h.useState)("idle"),[i,j]=(0,h.useState)(null),[k,l]=(0,h.useState)(null),[m,n]=(0,h.useState)(!1),[o,p]=(0,h.useState)([]),q=(0,h.useRef)(null),r=(0,h.useRef)(c),s=(0,h.useCallback)(async(b,c,d)=>{j(null),l(null),n(!1),p([]),e(b),g("running");let f=new AbortController;q.current=f;try{let e=await fetch(`/api/worktrees/${a}/git/${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d),signal:f.signal});if(!e.ok){var h,i;let a=await e.json().catch(()=>({}));l((h=a?.reason,"auth_failed"===h?"auth_failed":"protected_branch"===h?"protected_branch":null)),j((i=a?.error,"string"==typeof i&&i.length>0?i:null)),g("error");return}let k=await e.json().catch(()=>({success:!0}));"pull"===b&&k?.conflict&&(n(!0),p(Array.isArray(k.conflictFiles)?k.conflictFiles:[])),g("idle")}catch(a){a instanceof Error&&"AbortError"===a.name?g("idle"):(j(null),l(null),g("error"))}finally{e(null),q.current=null,r.current?.(b)}},[a]),t=(0,h.useCallback)(a=>{let b={prune:!0===a.prune};return void 0!==a.remote&&(b.remote=a.remote),s("fetch","fetch",b)},[s]),u=(0,h.useCallback)(a=>{let b={rebase:!0===a.rebase,ffOnly:!0===a.ffOnly};return void 0!==a.remote&&(b.remote=a.remote),void 0!==a.branch&&(b.branch=a.branch),s("pull","pull",b)},[s]);return{operation:d,progressState:f,error:i,errorReason:k,conflict:m,conflictFiles:o,runFetch:t,runPull:u,runPush:(0,h.useCallback)(a=>{let b={force:!0===a.force,forceWithLease:!0===a.forceWithLease,setUpstream:!0===a.setUpstream};return void 0!==a.remote&&(b.remote=a.remote),void 0!==a.branch&&(b.branch=a.branch),s("push","push",b)},[s]),abort:(0,h.useCallback)(()=>{q.current?.abort()},[])}}(a,{onCascade:(0,h.useCallback)(a=>{v(),an(ai),"pull"===a&&(aa(),L())},[v,an,ai,aa,L])}),aT="auth_failed"===aM?i("git.network.authFailedGuidance"):"protected_branch"===aM?i("git.danger.protectedBranchWarning"):aL,aU="running"===aK&&("push"===aJ||"pull"===aJ),aV=s?.aheadBehind!=null,aW=(0,h.useCallback)(()=>{aP({})},[aP]),aX=(0,h.useCallback)(()=>ag(()=>aR({setUpstream:!aV})),[ag,aR,aV]);cY({intervalMs:5e3,enabled:"running"!==aK,onPoll:v});let aY=(0,h.useMemo)(()=>({isMobile:c,onDiffSelect:b,onInsertToMessage:f}),[c,b,f]),aZ=(0,e.jsx)(eu,{gitStatus:s,statusLoading:t,statusError:u,onRefresh:aW,refreshing:"running"===aK}),a$=(0,e.jsx)(ev,{progressState:aK,operation:aJ,error:aT,conflict:aN,conflictFiles:aO,hasUpstream:aV,onPull:()=>aQ({}),onPush:()=>aR({setUpstream:!aV}),onAbort:aS,extraActions:(0,e.jsx)(ee,{branches:ah,busy:al||aU,actionError:am,hasRunningSession:r,isMobile:c,onCheckout:aq})}),a_=(0,e.jsx)(ex,{staged:S,loading:T,error:U,busy:V||aU,commitMessage:W,amend:Y,committing:$,commitError:_,onRefresh:aa,onDiff:ad,onPreview:ae,onStage:ab,onUnstage:ac,onCommitMessageChange:X,onAmendChange:Z,onCommit:af,onCommitAndPush:aX}),a0=(0,e.jsx)(ey,{commits:w,isLoading:F,commitError:I,commitListOpen:m,onToggleCommitList:o,onRefresh:Q,selectedCommit:x,onCommitSelect:M,inlineDiffCommit:z,inlineFiles:A,inlineFilesLoading:B,inlineFilesError:C,onToggleInlineDiff:O,onInlineDiffFile:P,changedFiles:y,isLoadingFiles:G,detailError:J,selectedFile:D,onFileSelect:N,diffContent:E,isLoadingDiff:H}),a1=(0,e.jsxs)(ef,{open:p,onToggle:q,children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-advanced-fetch",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:i("git.remote")}),(0,e.jsx)("div",{children:(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:()=>aP({}),disabled:"running"===aK,className:"px-2 py-1 text-xs rounded border border-input text-foreground hover:bg-muted disabled:opacity-50","data-testid":"git-fetch-button",children:i("git.network.fetch")})})]}),(0,e.jsx)(eB,{branches:ah,include:ai,loading:aj,error:ak,busy:al||aU,actionError:am,onIncludeChange:ao,onRefresh:ap,onCreate:ar,onDelete:as}),(0,e.jsx)(eC,{stashes:at,loading:au,error:av,busy:aw||aU,actionError:ax,conflictNotice:ay,hasRunningSession:r,onRefresh:az,onPush:aA,onPop:aB,onApply:aC,onDrop:aD}),(0,e.jsx)(eE,{selectedCommit:x,busy:aE||aU,actionError:aF,conflictNotice:aG,currentBranch:s?.currentBranch??null,aheadCount:s?.aheadBehind?.ahead??null,hasRunningSession:r,onReset:aH,onRevert:aI,onForcePush:a=>aR(a?{forceWithLease:!0}:{force:!0})})]});return(0,e.jsx)(eh,{value:aY,children:(0,e.jsx)(en,{activeTab:j,onTabChange:l,className:g,statusSection:aZ,quickActionsSection:a$,changesSection:a_,historySection:a0,advancedSection:a1})})}),eG=(0,h.memo)(function({worktreeId:a,worktree:b,onWorktreeUpdate:c}){let[d,f]=(0,h.useState)(!1),g=(0,k.c)("worktree"),i=(0,h.useRef)(b?.id),j=(0,h.useRef)(!1),l=eJ(b,c,b?.id,()=>{let a=b?.id!==i.current;return i.current=b?.id,a&&!j.current});return(j.current=l.isEditing,b)?(0,e.jsx)("div",{className:"p-4 space-y-4 overflow-y-auto h-full",children:(0,e.jsx)(eK,{worktreeId:a,worktree:b,cardClassName:"bg-surface rounded-lg border border-border p-4",descriptionEditor:l,showLogs:d,onToggleLogs:()=>f(!d),onWorktreeUpdate:c})}):(0,e.jsx)("div",{className:"text-muted-foreground text-center py-8",children:g("detail.loadingInfo")})}),eH=(0,h.memo)(function({activeTab:a,worktreeId:b,worktree:c,messages:d,cliToolId:f,instanceId:g,onFilePathClick:h,onFileSelect:i,onWorktreeUpdate:j,onNewFile:l,onNewDirectory:m,onRename:n,onDelete:o,onUpload:p,onMove:q,onFileTreeReset:r,refreshTrigger:s,fileSearch:t,showToast:u,selectedAgents:v,onSelectedAgentsChange:w,availableAgents:x,maxAgents:y,persistToServer:z,vibeLocalModel:A,onVibeLocalModelChange:B,vibeLocalContextWindow:C,onVibeLocalContextWindowChange:D,disableAutoFollow:E,historySubTab:G,onHistorySubTabChange:H,onDiffSelect:I,onInsertToMessage:J,showArchived:K,onShowArchivedChange:L,historyDisplayLimit:M,onHistoryDisplayLimitChange:N,historyUserOnly:O,onHistoryUserOnlyChange:P,useInstanceManagement:Q,instances:R,onInstancesChange:S,visibleInstanceIds:T,onToggleInstanceVisible:U}){let V=(0,k.c)("worktree");switch(a){case"terminal":return(0,e.jsx)(F,{componentName:"TerminalDisplay",children:(0,e.jsx)(bC,{worktreeId:b,cliToolId:f,instanceId:g,disableAutoFollow:E})});case"history":return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsxs)("div",{className:"flex border-b border-border shrink-0",children:[(0,e.jsx)("button",{type:"button",onClick:()=>H("message"),className:`flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ${"message"===G?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"}`,children:V("detail.subTabMessage")}),(0,e.jsx)("button",{type:"button",onClick:()=>H("git"),className:`flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ${"git"===G?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"}`,children:V("detail.subTabGit")})]}),"message"===G?(0,e.jsx)(F,{componentName:"HistoryPane",children:(0,e.jsx)(cC,{messages:d,worktreeId:b,onFilePathClick:h,className:"flex-1 min-h-0",showToast:u,onInsertToMessage:J,showArchived:K,onShowArchivedChange:L,historyDisplayLimit:M,onHistoryDisplayLimitChange:N,historyUserOnly:O,onHistoryUserOnlyChange:P})}):(0,e.jsx)(F,{componentName:"GitPane",children:(0,e.jsx)(eF,{worktreeId:b,onDiffSelect:I,isMobile:!0,worktree:c??void 0,onInsertToMessage:J,className:"flex-1 min-h-0"})})]});case"files":return(0,e.jsx)(F,{componentName:"FileTreeView",children:(0,e.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,e.jsx)(c2,{query:t.query,mode:t.mode,isSearching:t.isSearching,error:t.error,onQueryChange:t.setQuery,onModeChange:t.setMode,onClear:t.clearSearch}),(0,e.jsx)(c$,{worktreeId:b,onFileSelect:i,onNewFile:l,onNewDirectory:m,onRename:n,onDelete:o,onUpload:p,onMove:q,onResetView:r,refreshTrigger:s,pollingEnabled:"files"===a,searchQuery:t.query,searchMode:t.mode,searchResults:t.results?.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,e.jsx)(F,{componentName:"NotesAndLogsPane",children:(0,e.jsx)(d6,{worktreeId:b,className:"h-full",selectedAgents:v,onSelectedAgentsChange:w,availableAgents:x,maxAgents:y,persistToServer:z,vibeLocalModel:A,onVibeLocalModelChange:B,vibeLocalContextWindow:C,onVibeLocalContextWindowChange:D,onInsertToMessage:J,useInstanceManagement:Q,instances:R,onInstancesChange:S,visibleInstanceIds:T,onToggleInstanceVisible:U})});case"info":return(0,e.jsx)(eG,{worktreeId:b,worktree:c,onWorktreeUpdate:j});default:return null}}),eI=[{value:null,labelKey:"worktreeStatus.notSet"},{value:"ready",labelKey:"worktreeStatus.ready"},{value:"in_progress",labelKey:"worktreeStatus.inProgress"},{value:"in_review",labelKey:"worktreeStatus.inReview"},{value:"done",labelKey:"worktreeStatus.done"}];function eJ(a,b,c,d){let[e,f]=(0,h.useState)(!1),[g,i]=(0,h.useState)(""),[j,k]=(0,h.useState)(!1),l=(0,h.useCallback)(async()=>{if(a){k(!0);try{let c=await T.y.updateDescription(a.id,g);b(c),f(!1)}catch(a){console.error("Failed to save description:",a)}finally{k(!1)}}},[a,g,b]),m=(0,h.useCallback)(()=>{i(a?.description||""),f(!1)},[a]);return{isEditing:e,text:g,setText:i,isSaving:j,handleSave:l,handleCancel:m,startEditing:(0,h.useCallback)(()=>{f(!0)},[])}}let eK=(0,h.memo)(function({worktreeId:a,worktree:b,cardClassName:c,descriptionEditor:d,showLogs:f,onToggleLogs:g,onWorktreeUpdate:i}){let{isEditing:j,text:l,setText:m,isSaving:o,handleSave:p,handleCancel:q,startEditing:r}=d,s=(0,k.c)("worktree"),t=(0,k.c)("common"),[u,v]=(0,h.useState)(!1),[w,x]=(0,h.useState)(!1),y=(0,h.useRef)(void 0),z=(0,h.useRef)(void 0);(0,h.useEffect)(()=>()=>{y.current&&clearTimeout(y.current),z.current&&clearTimeout(z.current)},[]);let A=(0,h.useCallback)(async()=>{try{await (0,ay.l)(b.path),v(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>v(!1),ah.pX)}catch{}},[b.path]),B=(0,h.useCallback)(async()=>{try{await (0,ay.l)(b.repositoryPath),x(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>x(!1),ah.pX)}catch{}},[b.repositoryPath]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.worktree")}),(0,e.jsx)("p",{className:"text-lg font-semibold text-foreground",children:b.name})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.repository")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:B,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":s("detail.copyRepositoryPath"),title:w?s("detail.copied"):s("detail.copyRepositoryPath"),children:w?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("p",{className:"text-base text-foreground",children:b.repositoryDisplayName??b.repositoryName}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:b.repositoryPath})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.path")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:A,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":s("detail.copyWorktreePath"),title:u?s("detail.copied"):s("detail.copyPath"),children:u?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("p",{className:"text-sm text-foreground break-all font-mono",children:b.path})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.status")}),(0,e.jsx)("select",{value:b.status??"",onChange:async a=>{let c=a.target.value;try{let a=await fetch(`/api/worktrees/${b.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:""===c?null:c})});if(a.ok&&i){let b=await a.json();i(b)}}catch{}},className:"text-sm px-3 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent w-full","data-testid":"mobile-status-dropdown","aria-label":s("detail.worktreeStatusLabel"),children:eI.map(a=>(0,e.jsx)("option",{value:a.value??"",children:s(a.labelKey)},a.labelKey))})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.description")}),!j&&(0,e.jsx)("button",{type:"button",onClick:r,className:"text-sm text-accent-600 hover:text-accent-800 dark:text-accent-400 dark:hover:text-accent-300",children:s("actions.edit")})]}),j?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("textarea",{value:l,onChange:a=>m(a.target.value),placeholder:s("detail.addNotesPlaceholder"),className:"w-full min-h-[150px] p-3 border border-input dark:bg-surface dark:text-foreground rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:p,disabled:o,className:"px-4 py-2 bg-accent-600 text-white rounded-lg hover:bg-accent-700 disabled:opacity-50 text-sm font-medium",children:o?s("actions.saving"):s("actions.save")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:q,disabled:o,className:"px-4 py-2 bg-muted text-foreground rounded-lg hover:bg-border disabled:opacity-50 text-sm font-medium",children:t("cancel")})]})]}):(0,e.jsx)("div",{className:"min-h-[50px]",children:b.description?(0,e.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:b.description}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:s("detail.noDescription")})})]}),b.link&&(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.link")}),(0,e.jsx)("a",{href:b.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-600 hover:underline break-all",children:b.link})]}),b.updatedAt&&(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.lastUpdated")}),(0,e.jsx)("p",{className:"text-sm text-foreground",children:new Date(b.updatedAt).toLocaleString()})]}),(0,e.jsx)(a4,{version:"v0.16.0",className:c}),(0,e.jsx)(bb,{className:c}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.logs")}),(0,e.jsx)("button",{type:"button",onClick:g,className:"text-sm text-accent-600 hover:text-accent-800",children:f?s("detail.hide"):s("detail.show")})]}),f&&(0,e.jsx)(a0,{worktreeId:a})]})]})}),eL=(0,h.memo)(function({worktreeName:a,repositoryName:b,description:c,status:d,gitStatus:f,onBackClick:g,onInfoClick:i,hasUpdate:j,worktreeStatus:l,onWorktreeStatusChange:m,sessionStatusByCli:p,sessionStatusByInstance:q,instances:s,activeInstanceId:t,onActiveInstanceChange:u,onAgentDragStart:v,onAgentDragEnd:w,onKillSession:x}){let y=(0,k.c)("worktree"),z=(0,k.c)("common"),A=aX.sb[d],B=A?y(A):void 0,[D,E]=(0,h.useState)(null),F=s?.find(a=>a.id===t),G=!!t&&(q?.[t]?.isRunning??(F?p?.[F.cliTool]?.isRunning:void 0)??!1),H=(0,h.useCallback)((a,b)=>{a.dataTransfer.setData(bg,b),a.dataTransfer.effectAllowed="move",E(b),v?.(b)},[v]),I=(0,h.useCallback)(()=>{E(null),w?.()},[w]),J=c?r(c,50):null;return(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-surface border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("button",{type:"button",onClick:g,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":y("detail.goBack"),"data-testid":"worktree-back-button",children:[(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1h-2z"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:y("detail.home")})]}),(0,e.jsx)("div",{className:"w-px h-6 bg-border","aria-hidden":"true"}),(0,e.jsx)(o.m,{"data-testid":"desktop-status-indicator",status:d,size:"lg",label:B}),(0,e.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,e.jsx)("h1",{className:"text-lg font-semibold text-foreground truncate max-w-[200px] leading-tight",children:a}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"truncate max-w-[200px]",children:b}),f&&"(unknown)"!==f.currentBranch&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"/"}),(0,e.jsx)("span",{className:"truncate max-w-[150px] font-mono",title:f.currentBranch,"data-testid":"desktop-branch-name",children:r(f.currentBranch,30)}),f.isDirty&&(0,e.jsx)("span",{className:"text-warning",title:y("git.uncommittedChanges"),children:"*"})]}),J&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"—"}),(0,e.jsx)("span",{className:"truncate max-w-[300px] text-muted-foreground",title:c,children:J})]})]})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[s&&s.length>0&&(()=>{let a=(0,a$.Uw)(s.map(a=>({item:a,status:(0,bd.kA)(q?.[a.id]??p?.[a.cliTool]),isActive:a.id===t})),4),b=a.filter(a=>"overflow"===a.slot),c=b.find(a=>"running"===a.status||"generating"===a.status)?.status??b.find(a=>"waiting"===a.status)?.status??null;return(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0","data-testid":"desktop-agent-status-row",children:[a.map(a=>{if("overflow"===a.slot)return null;let b=a.item,c=y("detail.statusPill",{label:(0,be.sw)(b),status:z(`status.${a.status}`)}),d=a.isActive,f={draggable:!0,onDragStart:a=>H(a,b.id),onDragEnd:I},g=D===b.id?" opacity-50 cursor-grabbing":"";return"pill"===a.slot?(0,e.jsxs)("button",{type:"button","data-testid":`desktop-agent-status-${b.id}`,onClick:()=>u?.(b.id),...f,"aria-label":c,"aria-pressed":d,className:`flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${d?"bg-accent-100 dark:bg-accent-900/30 text-accent-900 dark:text-accent-100":"hover:bg-muted text-foreground"}${g}`,children:[(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0}),(0,e.jsx)("span",{className:"whitespace-nowrap",children:c})]},b.id):(0,e.jsx)(aY.m_,{content:c,placement:"bottom",children:(0,e.jsx)("button",{type:"button","data-testid":`desktop-agent-status-${b.id}`,onClick:()=>u?.(b.id),...f,"aria-label":c,"aria-pressed":d,className:`flex items-center justify-center w-6 h-6 rounded-full transition-colors ${d?"bg-accent-100 dark:bg-accent-900/30":"hover:bg-muted"}${g}`,children:(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0})})},b.id)}),b.length>0&&(0,e.jsxs)(aZ.rI,{children:[(0,e.jsx)(aZ.ty,{asChild:!0,children:(0,e.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-overflow","aria-label":y("agentStatus.moreAgents",{count:b.length}),className:"flex items-center gap-1 px-2 py-1 rounded text-xs tabular-nums text-muted-foreground hover:bg-muted transition-colors",children:[c&&(0,e.jsx)(o.m,{status:c,size:"sm","aria-hidden":!0,title:void 0}),"+",b.length]})}),(0,e.jsx)(aZ.SQ,{align:"end",children:b.map(a=>{let b=a.item,c=y("detail.statusPill",{label:(0,be.sw)(b),status:z(`status.${a.status}`)});return(0,e.jsxs)(aZ._2,{"data-testid":`desktop-agent-overflow-${b.id}`,onSelect:()=>u?.(b.id),children:[(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0}),(0,e.jsx)("span",{className:"whitespace-nowrap",children:c})]},b.id)})})]})]})})(),x&&G&&(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:x,className:"flex items-center gap-1 px-2 py-1.5 text-xs font-medium rounded-lg text-danger-foreground hover:bg-danger-subtle transition-colors flex-shrink-0","aria-label":y("terminal.endSession"),"data-testid":"desktop-kill-session",children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"✕"}),z("end")]}),m&&(0,e.jsx)("select",{value:l??"",onChange:a=>{let b=a.target.value;m(""===b?null:b)},onClick:a=>a.stopPropagation(),className:"text-xs px-2 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent cursor-pointer","data-testid":"desktop-status-dropdown","aria-label":y("detail.worktreeStatusLabel"),children:eI.map(a=>(0,e.jsx)("option",{value:a.value??"",children:y(a.labelKey)},a.labelKey))}),(0,e.jsx)(bi.g,{}),(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:i,className:"relative flex items-center gap-1.5 px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors","aria-label":y("detail.viewInfo"),children:[(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:y("detail.info")}),j&&(0,e.jsx)(C,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":y("tabs.updateAvailable")})]})]})]})}),eM=(0,h.memo)(function({worktreeId:a,worktree:b,isOpen:c,onClose:d,onWorktreeUpdate:f}){let[g,i]=(0,h.useState)(!1),j=(0,k.c)("worktree"),l=(0,h.useRef)(c),m=eJ(b,f,c,()=>{let a=c&&!l.current;return l.current=c,a});return b?(0,e.jsx)(bc.a,{isOpen:c,onClose:d,title:j("detail.infoModalTitle"),size:"md",children:(0,e.jsx)("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto","data-testid":"worktree-info-modal",children:(0,e.jsx)(eK,{worktreeId:a,worktree:b,cardClassName:"bg-muted rounded-lg p-4",descriptionEditor:m,showLogs:g,onToggleLogs:()=>i(!g),onWorktreeUpdate:f})})}):null}),eN=(0,h.memo)(function(){let a=(0,k.c)("worktree");return(0,e.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"status","aria-live":"polite",children:(0,e.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,e.jsx)(n.y$,{size:"xl",variant:"accent"}),(0,e.jsx)("p",{className:"text-muted-foreground",children:a("detail.loading")})]})})}),eO=(0,h.memo)(function({message:a,onRetry:b}){let c=(0,k.c)("worktree"),d=(0,k.c)("common");return(0,e.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"alert","aria-live":"assertive",children:(0,e.jsxs)("div",{className:"text-center p-6 bg-danger-subtle rounded-lg border border-danger-border max-w-md",children:[(0,e.jsx)("svg",{className:"mx-auto h-12 w-12 text-danger-foreground/70 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.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,e.jsx)("p",{className:"text-danger-foreground font-medium",children:c("detail.errorLoading")}),(0,e.jsx)("p",{className:"text-danger-foreground/80 text-sm mt-2",children:a}),b&&(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:b,className:"mt-4 px-4 py-2 bg-danger-foreground text-danger-subtle rounded-lg hover:opacity-90 transition-opacity focus:outline-none focus:ring-2 focus:ring-danger focus:ring-offset-2 ring-offset-background",children:d("retry")})]})})}),eP=(0,h.memo)(function({activityPane:a,rightPane:b,activityPaneWidth:c=18,minPaneWidth:d=10,maxPaneWidth:f=60,onActivityPaneResize:g,className:i=""}){let j=(0,h.useRef)(null),l=(0,k.c)("worktree"),[m,n]=(0,h.useState)(c),o=g?c:m,p=(0,h.useCallback)(a=>{let b=j.current;if(!b)return;let e=b.offsetWidth;if(0===e)return;let h=Math.min(f,Math.max(d,(g?c:m)+a/e*100));g?g(h):n(h)},[c,m,d,f,g]),q=(0,h.useMemo)(()=>`flex h-full min-h-0 ${i}`.trim(),[i]);return(0,e.jsx)("div",{ref:j,className:"h-full",children:(0,e.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:q,children:[null!==a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{id:"worktree-activity-pane","data-testid":"activity-pane-slot","aria-label":l("desktopLayout.activityPane"),style:{width:`${o}%`},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,e.jsx)(F,{componentName:"ActivityPane",children:a})}),(0,e.jsx)(ct,{onResize:p,orientation:"horizontal",ariaValueNow:o})]}),(0,e.jsx)("div",{id:"worktree-right-pane","data-testid":"right-pane-slot","aria-label":l("desktopLayout.terminalPane"),className:"flex-grow overflow-hidden min-w-0",children:(0,e.jsx)(F,{componentName:"TerminalPane",children:b})})]})})}),eQ=(0,x.A)("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),eR=(0,x.A)("file",[["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"}]]);var eS=c(57898);let eT=(0,x.A)("sticky-note",[["path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",key:"1dfntj"}],["path",{d:"M15 3v5a1 1 0 0 0 1 1h5",key:"6s6qgf"}]]),eU=(0,x.A)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);var eV=c(55056);let eW=(0,x.A)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),eX=(0,x.A)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),eY=[{id:"files",labelKey:"activityBar.files",icon:eR},{id:"git",labelKey:"activityBar.git",icon:eS.A},{id:"notes",labelKey:"activityBar.notes",icon:eT},{id:"schedules",labelKey:"activityBar.schedules",icon:eU},{id:"agent",labelKey:"activityBar.agent",icon:eV.A},{id:"timer",labelKey:"activityBar.timer",icon:eW},{id:"todo",labelKey:"activityBar.todo",icon:eX},{id:"skills",labelKey:"activityBar.skills",icon:de.A}];eY.map(a=>a.id);var eZ=c(81092);let e$=(0,h.memo)(function({active:a,onToggle:b,className:c=""}){let d=(0,k.c)("worktree"),f=(0,h.useRef)([]),{isOpen:g,toggle:i}=(0,eZ.VF)(),j=(0,h.useCallback)((a,c,d)=>{if("Enter"===a.key||" "===a.key){a.preventDefault(),b(d);return}if("ArrowDown"===a.key){a.preventDefault();let b=(c+1)%eY.length;f.current[b]?.focus();return}if("ArrowUp"===a.key){a.preventDefault();let b=(c-1+eY.length)%eY.length;f.current[b]?.focus();return}if("Home"===a.key){a.preventDefault(),f.current[0]?.focus();return}if("End"===a.key){a.preventDefault(),f.current[eY.length-1]?.focus();return}},[b]);return(0,e.jsxs)("div",{"data-testid":"activity-bar",className:`flex flex-col items-stretch w-12 flex-shrink-0 bg-muted border-r border-border ${c}`.trim(),children:[(0,e.jsx)(aY.m_,{content:d("activityBar.toggleSidebar"),placement:"right",children:(0,e.jsx)("button",{type:"button","data-testid":"activity-bar-toggle-sidebar",onClick:i,"aria-label":d("activityBar.toggleSidebar"),"aria-expanded":g,className:"flex items-center justify-center h-12 w-12 text-muted-foreground transition-colors hover:text-surface-foreground hover:bg-muted-foreground/10 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,e.jsx)(eQ,{size:20,"aria-hidden":"true"})})}),(0,e.jsx)("div",{className:"mx-2 my-1 border-b border-border","aria-hidden":"true"}),(0,e.jsx)("div",{id:"worktree-activity-bar",role:"tablist","aria-orientation":"vertical","aria-label":d("activityBar.label"),className:"flex flex-col items-stretch",children:eY.map((c,g)=>{let h=c.icon,i=a===c.id,k=d(c.labelKey);return(0,e.jsx)(aY.m_,{content:k,placement:"right",children:(0,e.jsx)("button",{ref:a=>{f.current[g]=a},type:"button",role:"tab","aria-selected":i,"aria-label":k,"aria-controls":"worktree-activity-pane",tabIndex:i||null===a&&0===g?0:-1,onClick:()=>b(c.id),onKeyDown:a=>j(a,g,c.id),"data-testid":`activity-bar-button-${c.id}`,className:"group flex items-center justify-center h-12 w-12 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,e.jsx)("span",{"aria-hidden":"true",className:`flex items-center justify-center h-9 w-9 rounded-md transition-colors ${i?"bg-accent-500/10 text-accent-600 dark:text-accent-400":"text-muted-foreground group-hover:text-surface-foreground group-hover:bg-muted-foreground/10"}`,children:(0,e.jsx)(h,{size:20,"aria-hidden":"true"})})})},c.id)})})]})}),e_="worktree-activity-pane",e0={files:"FileTreeView",git:"GitPane",notes:"MemoPane",schedules:"ExecutionLogPane",agent:"AgentSettingsPane",timer:"TimerPane",todo:"TodoPane",skills:"WorktreeSkillsPane"},e1=(0,h.memo)(function({active:a,activities:b,className:c=""}){if(null===a)return(0,e.jsx)("div",{id:e_,"data-testid":"activity-pane","data-active":"none",className:`h-full flex flex-col ${c}`.trim()});let d=b[a],f=e0[a];return(0,e.jsx)("div",{id:e_,"data-testid":"activity-pane","data-active":a,role:"tabpanel","aria-labelledby":`activity-bar-button-${a}`,className:`h-full flex flex-col min-h-0 ${c}`.trim(),children:(0,e.jsx)(F,{componentName:f,children:d??null})})}),e2=(0,h.memo)(function({inputRef:a,searchQuery:b,onQueryChange:c,matchCount:d,currentIdx:f,onNextMatch:g,onPrevMatch:h,onClose:i}){let j=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border-b border-input flex-shrink-0",children:[(0,e.jsx)("input",{ref:a,type:"text",value:b,onChange:a=>c(a.target.value),onKeyDown:a=>{"Escape"===a.key&&i(),"Enter"===a.key&&(a.shiftKey?h():g())},placeholder:j("fileSearch.placeholder"),className:"flex-1 min-w-0 px-2 py-0.5 text-sm bg-surface dark:text-foreground border border-input rounded outline-none focus:ring-1 focus:ring-ring",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground min-w-[3rem] text-right",children:d>0?`${f+1}/${d}`:"0/0"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:h,disabled:0===d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":j("fileSearch.prevMatch"),children:"▲"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:g,disabled:0===d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":j("fileSearch.nextMatch"),children:"▼"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:i,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white","aria-label":j("fileSearch.close"),children:(0,e.jsx)(az.A,{className:"w-4 h-4"})})]})}),e3=[{extension:".png",maxFileSize:0x1400000,allowedMimeTypes:["image/png"],magicBytes:[{bytes:[137,80,78,71,13,10,26,10]}]},{extension:".jpg",maxFileSize:0x1400000,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".jpeg",maxFileSize:0x1400000,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".gif",maxFileSize:0x1400000,allowedMimeTypes:["image/gif"],magicBytes:[{bytes:[71,73,70,56,55,97]},{bytes:[71,73,70,56,57,97]}]},{extension:".webp",maxFileSize:0x1400000,allowedMimeTypes:["image/webp"],magicBytes:[{bytes:[82,73,70,70],offset:0}]},{extension:".mp4",maxFileSize:0x6400000,allowedMimeTypes:["video/mp4"],magicBytes:[{bytes:[102,116,121,112],offset:4}]},{extension:".txt",maxFileSize:0x1400000,allowedMimeTypes:["text/plain"]},{extension:".log",maxFileSize:0x1400000,allowedMimeTypes:["text/plain"]},{extension:".md",maxFileSize:0x1400000,allowedMimeTypes:["text/markdown","text/plain"]},{extension:".csv",maxFileSize:0x1400000,allowedMimeTypes:["text/csv"]},{extension:".json",maxFileSize:0x1400000,allowedMimeTypes:["application/json"]},{extension:".yaml",maxFileSize:0x1400000,allowedMimeTypes:["text/yaml","application/x-yaml"]},{extension:".yml",maxFileSize:0x1400000,allowedMimeTypes:["text/yaml","application/x-yaml"]}],e4=e3.map(a=>a.extension),e5=[".md",".html",".htm",".yaml",".yml"];var e6=c(79689);function e7(){return(0,e.jsx)("div",{className:"flex items-center justify-center py-12 bg-surface",children:(0,e.jsx)(m.y,{size:"xl",variant:"accent"})})}let e8=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/HtmlPreview"]},ssr:!1,loading:()=>(0,e.jsx)(e7,{})}),e9=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/PdfPreview"]},ssr:!1,loading:()=>(0,e.jsx)(e7,{})}),fa=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/MarkdownEditor"]},ssr:!1,loading:()=>(0,e.jsx)(e7,{})}),fb=/^---\s*\nmarp:\s*true/;function fc(){let a=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,e.jsx)(m.y,{size:"xl",variant:"accent"}),(0,e.jsx)("p",{className:"ml-3 text-muted-foreground",children:a("fileViewer.loading")})]})}function fd({error:a}){return(0,e.jsx)("div",{className:"bg-danger-subtle border border-danger-border rounded-lg p-4 m-4",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-5 h-5 text-danger-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("p",{className:"text-sm text-danger-foreground",children:a})]})})}function fe({filePath:a,isMaximized:b,onToggleMaximize:c,copyableContent:d,onSearch:f}){let g=(0,k.c)("worktree"),[i,j]=(0,h.useState)(!1),[l,m]=(0,h.useState)(!1),n=(0,h.useRef)(null),o=(0,h.useRef)(null),p=async()=>{try{await (0,ay.l)(a),j(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>j(!1),ah.pX)}catch{}},q=async()=>{if(d)try{await (0,ay.l)(d),m(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>m(!1),ah.pX)}catch{}};return(0,e.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border gap-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("button",{type:"button",onClick:p,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.copyFilePath"),title:g("actions.copyPath"),children:i?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",title:a,children:a})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[f&&(0,e.jsx)("button",{type:"button",onClick:f,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.searchInFile"),title:g("actions.search"),children:(0,e.jsx)(Q.A,{className:"w-3.5 h-3.5"})}),d&&(0,e.jsx)("button",{type:"button",onClick:q,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.copyFileContent"),title:g("actions.copyContent"),children:l?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(as,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{type:"button",onClick:c,className:"flex-shrink-0 p-1.5 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g(b?"actions.minimize":"actions.maximize"),title:g(b?"actions.minimize":"actions.maximize"),children:b?(0,e.jsx)(aA,{className:"w-4 h-4"}):(0,e.jsx)(aB,{className:"w-4 h-4"})})]})]})}function ff({content:a,extension:b,searchMatches:c,searchCurrentIdx:d,totalLines:f,rangeStart:g,worktreeId:i,filePath:j,onLineRangeFetched:k}){let l=(0,h.useRef)(null),m=(0,h.useMemo)(()=>a.split("\n"),[a]),n=Math.max(1,g??1),o=m.length,p=Math.max(f??o,o),q=(0,h.useRef)(new Map),r=(0,h.useCallback)(a=>{let c=Math.floor(a/500),d=q.current,e=d.get(c);if(!e){let a=500*c,f=Math.min(a+500,m.length),g=m.slice(a,f).join("\n"),h="";try{h=aO.highlight(g,{language:b,ignoreIllegals:!0}).value}catch{h=aO.highlightAuto(g).value}e=h.split("\n"),d.set(c,e)}return e[a-500*c]??""},[m,b]),s=(0,h.useMemo)(()=>new Set(c??[]),[c]),t=(c?.length??0)>0?c[d??0]:-1,u=bU({count:p,getScrollElement:()=>l.current,estimateSize:()=>24,overscan:100}),v=u.getVirtualItems();return!function({virtualItems:a,worktreeId:b,filePath:c,onLineRangeFetched:d,loadedStart:e,loadedLineCount:f}){(0,h.useRef)(new Set)}({virtualItems:v,worktreeId:i,filePath:j,onLineRangeFetched:k,loadedStart:n,loadedLineCount:o}),(0,e.jsx)("div",{className:"overflow-auto h-full",ref:l,"data-testid":"file-content-code",children:(0,e.jsx)("div",{style:{height:u.getTotalSize(),width:"100%",position:"relative"},children:v.map(a=>{let b=a.index+1,c=b-n,d=c>=0&&c<o,f=b===t,g=s.has(b),h=d?r(c):"";return(0,e.jsxs)("div",{"data-line":b,"data-index":a.index,ref:u.measureElement,className:`absolute left-0 right-0 flex font-mono text-sm ${f?"bg-warning/30":g?"bg-warning/15":""}`,style:{top:0,transform:`translateY(${a.start}px)`,height:"24px",lineHeight:"24px"},children:[(0,e.jsx)("div",{className:`px-3 text-right select-none border-r border-border bg-muted dark:bg-muted/50 whitespace-nowrap ${f||g?"text-warning-foreground":"text-muted-foreground"}`,style:{minWidth:"4rem"},children:b}),(0,e.jsx)("div",{className:"px-4 text-foreground flex-1 min-w-0 overflow-hidden",children:d?(0,e.jsx)("code",{className:"hljs",style:{padding:0,background:"transparent",whiteSpace:"pre"},dangerouslySetInnerHTML:{__html:h}}):(0,e.jsx)(e6.E,{className:"h-4 w-3/4"})})]},a.key)})})})}function fg({slides:a,fileName:b}){let c=(0,k.c)("worktree"),[d,f]=(0,h.useState)(0);return 0===a.length?(0,e.jsx)("div",{className:"p-4 text-muted-foreground",children:c("fileViewer.noSlides",{fileName:b})}):(0,e.jsxs)("div",{className:"h-full flex flex-col","data-testid":"marp-preview",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border bg-muted",children:[(0,e.jsx)("button",{type:"button",onClick:()=>{f(a=>Math.max(0,a-1))},disabled:0===d,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:c("actions.prev")}),(0,e.jsxs)("span",{className:"text-sm text-muted-foreground",children:[d+1," / ",a.length]}),(0,e.jsx)("button",{type:"button",onClick:()=>{f(b=>Math.min(a.length-1,b+1))},disabled:d===a.length-1,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:c("actions.next")})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,e.jsx)("iframe",{srcDoc:a[d],sandbox:"",title:c("fileViewer.slideTitle",{name:b,number:d+1}),className:"w-full h-full border-0"})})]})}function fh({marpSlides:a,fileName:b,worktreeId:c,filePath:d,contentText:f,onFileSaved:g,isMaximized:i,onToggleMaximize:j,onDirtyChange:l,onOpenFile:m}){let n=(0,k.c)("worktree"),[o,p]=(0,h.useState)("slides");return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border bg-muted",children:[(0,e.jsxs)("div",{className:"flex gap-1",children:[(0,e.jsx)("button",{type:"button",onClick:()=>p("slides"),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${"slides"===o?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"}`,children:n("fileViewer.slides")}),(0,e.jsx)("button",{type:"button",onClick:()=>p("editor"),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${"editor"===o?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"}`,children:n("fileViewer.editor")})]}),(0,e.jsx)(fe,{filePath:d,isMaximized:i,onToggleMaximize:j,copyableContent:f})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:"slides"===o?(0,e.jsx)(fg,{slides:a,fileName:b}):(0,e.jsx)(fa,{worktreeId:c,filePath:d,onSave:g,initialViewMode:"split",onDirtyChange:l,onOpenFile:m})})]})}function fi({children:a,isMaximized:b,onToggle:c,filePath:d}){return b?(0,e.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:aE.M.MAXIMIZED_EDITOR},children:[(0,e.jsx)(fe,{filePath:d,isMaximized:b,onToggleMaximize:c}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:a})]}):(0,e.jsx)(e.Fragment,{children:a})}function fj({tab:a,content:b,worktreeId:c,isMaximized:d,onToggleMaximize:f,onFileSaved:g,onDirtyChange:h,onOpenFile:i}){let j=aN(b.content);return(0,e.jsxs)(e.Fragment,{children:[!d&&(0,e.jsx)(fe,{filePath:a.path,isMaximized:d,onToggleMaximize:f,copyableContent:b.content,onSearch:j.openSearch}),j.searchOpen&&(0,e.jsx)(e2,{inputRef:j.searchInputRef,searchQuery:j.searchQuery,onQueryChange:j.setSearchQuery,matchCount:j.searchMatches.length,currentIdx:j.searchCurrentIdx,onNextMatch:j.nextMatch,onPrevMatch:j.prevMatch,onClose:j.closeSearch}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:j.searchOpen&&j.searchQuery.length>=2?(0,e.jsx)(ff,{content:b.content,extension:"md",searchMatches:j.searchMatches,searchCurrentIdx:j.searchCurrentIdx}):(0,e.jsx)(fa,{worktreeId:c,filePath:a.path,onSave:g,initialViewMode:"preview",onDirtyChange:h,onOpenFile:i})})]})}function fk({tab:a,content:b,worktreeId:c,isMaximized:d,onToggleMaximize:f,onLoadContent:g}){let i=aN(b.content),j=(0,h.useCallback)(c=>{g&&g(a.path,{...b,content:c.content,totalLines:c.totalLines,totalBytes:c.totalBytes??b.totalBytes,range:c.range})},[g,a.path,b]),k=void 0!==b.range&&(b.totalLines??0)>b.range.end-b.range.start+1;return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fe,{filePath:a.path,isMaximized:d,onToggleMaximize:f,copyableContent:b.content,onSearch:i.openSearch}),i.searchOpen&&(0,e.jsx)(e2,{inputRef:i.searchInputRef,searchQuery:i.searchQuery,onQueryChange:i.setSearchQuery,matchCount:i.searchMatches.length,currentIdx:i.searchCurrentIdx,onNextMatch:i.nextMatch,onPrevMatch:i.prevMatch,onClose:i.closeSearch}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(ff,{content:b.content,extension:b.extension,searchMatches:i.searchOpen?i.searchMatches:void 0,searchCurrentIdx:i.searchOpen?i.searchCurrentIdx:void 0,totalLines:b.totalLines,rangeStart:b.range?.start,worktreeId:k?c:void 0,filePath:k?a.path:void 0,onLineRangeFetched:k?j:void 0})})]})}let fl=(0,h.memo)(function({tab:a,worktreeId:b,onLoadContent:c,onLoadError:d,onSetLoading:f,onFileSaved:g,onDirtyChange:i,onOpenFile:j}){let l=(0,k.c)("worktree"),m=(0,h.useRef)(l);m.current=l;let n=(0,h.useRef)(!1),[o,p]=(0,h.useState)(null),[q,r]=(0,h.useState)(!1);!function({tab:a,worktreeId:b,onLoadContent:c}){let d=(0,h.useRef)(null),e=(0,h.useRef)(c);e.current=c;let f=(0,h.useRef)(a.path);f.current=a.path,cY({intervalMs:5e3,enabled:function(a){if(null===a.content||a.loading||a.isDirty||a.content.isPdf)return!1;let{totalBytes:b}=a.content;return void 0===b||!(b>=1048576)}(a),onPoll:async()=>{let a=`/api/worktrees/${b}/files/${(0,aF.o)(f.current)}`,c={};d.current&&(c["If-Modified-Since"]=d.current);try{let b=await fetch(a,{headers:c});if(304===b.status||!b.ok)return;d.current=b.headers.get("Last-Modified");let g=await b.json();e.current(f.current,g)}catch{}}})}({tab:a,worktreeId:b,onLoadContent:c});let s=(0,h.useMemo)(()=>i?b=>i(a.path,b):void 0,[i,a.path]),t=(0,h.useCallback)(()=>{r(a=>!a)},[]);(0,h.useEffect)(()=>{if(!q)return;let a=a=>{"Escape"===a.key&&r(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[q]),(0,h.useEffect)(()=>{null!==a.content||a.loading||null!==a.error||n.current||(n.current=!0,f(a.path,!0),(async()=>{try{let e=await fetch(`/api/worktrees/${b}/files/${(0,aF.o)(a.path)}`);if(304===e.status)return;if(!e.ok){let b=await e.json(),c="string"==typeof b.error?b.error:b.error?.message||m.current("fileViewer.loadError");d(a.path,c);return}let f=await e.json();c(a.path,f)}catch(b){d(a.path,b instanceof Error?b.message:m.current("fileViewer.loadError"))}finally{n.current=!1}})())},[a.content,a.loading,a.error,a.path,b,c,d,f]);let u=a.content?.content??null,v=a.content?.extension??null;if((0,h.useEffect)(()=>{if(!u||"md"!==v||!fb.test(u)||u.length>1e6)return void p(null);let a=!1;return(async()=>{try{let c=await fetch(`/api/worktrees/${b}/marp-render`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:u})});if(c.ok){let b=await c.json();a||p(Array.isArray(b.slides)?b.slides:null)}}catch{}})(),()=>{a=!0}},[u,v,b]),a.loading)return(0,e.jsx)(fc,{});if(a.error)return(0,e.jsx)(fd,{error:a.error});if(!a.content)return null;let{content:w}=a;return w.isImage?(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fe,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsx)(an.a,{src:w.content,alt:w.path,mimeType:w.mimeType})})]})}):w.isVideo?(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fe,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsx)(ao.u,{src:w.content,mimeType:w.mimeType})})]})}):w.isPdf?(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fe,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(e9,{dataUri:w.content,filePath:a.path})})]})}):w.isHtml?(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fe,{filePath:a.path,isMaximized:q,onToggleMaximize:t,copyableContent:w.content}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(e8,{worktreeId:b,filePath:a.path,htmlContent:w.content,onFileSaved:g,onOpenFile:j})})]})}):"md"===w.extension?(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)("div",{className:"h-full flex flex-col",children:o?(0,e.jsx)(fh,{marpSlides:o,fileName:a.name,worktreeId:b,filePath:a.path,contentText:w.content,onFileSaved:g,isMaximized:q,onToggleMaximize:t,onDirtyChange:s,onOpenFile:j}):(0,e.jsx)(fj,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onFileSaved:g,onDirtyChange:s,onOpenFile:j})})}):!function(a){if(!a)return!1;let b=a.toLowerCase();return e5.includes(b)}("."+w.extension)?(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)(fk,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onLoadContent:c})}):(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)("div",{className:"h-full flex flex-col",children:(0,e.jsx)(fj,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onFileSaved:g,onDirtyChange:s,onOpenFile:j})})})});function fm(a,b,c){if(b<=0||c<=0)return 0;let d=a+b+8-c;return d>0?-Math.min(d,Math.max(0,a-8)):a<8?8-a:0}let fn=(0,h.memo)(function({tab:a,isActive:b,onActivate:c,onClose:d}){let f=(0,k.c)("worktree"),g=(0,h.useCallback)(()=>{b||c(a.path)},[b,c,a.path]),i=(0,h.useCallback)(b=>{b.stopPropagation(),d(a.path)},[d,a.path]),j=b?"border-accent-500 text-accent-600 dark:text-accent-400 bg-surface":"border-transparent text-muted-foreground hover:text-foreground";return(0,e.jsxs)("div",{"data-testid":`file-tab-${a.path}`,"data-active":b,onClick:g,className:`flex items-center gap-1 px-3 py-2 text-sm font-medium border-b-2 cursor-pointer flex-shrink-0 ${j}`,children:[(0,e.jsx)("span",{className:"truncate max-w-[120px]",title:a.path,children:a.name}),a.isDirty&&(0,e.jsx)("span",{"data-testid":`file-tab-dirty-${a.path}`,className:"w-2 h-2 rounded-full bg-warning flex-shrink-0",title:f("fileTabs.unsavedChanges")}),(0,e.jsx)("button",{type:"button",onClick:i,className:"ml-1 p-0.5 rounded-sm hover:bg-muted transition-colors","aria-label":f("fileTabs.closeTab",{name:a.name}),children:(0,e.jsx)(az.A,{className:"w-3 h-3"})})]})}),fo=(0,h.memo)(function({tabs:a,activeIndex:b,worktreeId:c,onClose:d,onActivate:f,onLoadContent:g,onLoadError:i,onSetLoading:j,onFileSaved:k,onDirtyChange:l,onMoveToFront:m,onOpenFile:n}){let[o,p]=(0,h.useState)(!1),q=(0,h.useRef)(null),r=(0,h.useRef)(null),s=(0,h.useRef)({x:0,y:0}),[t,u]=(0,h.useState)({x:0,y:0}),v=null!==b&&b>=0&&b<a.length?a[b]:null,w=a.length>5?a.slice(0,5):a,x=a.length>5?a.slice(5):[];(0,h.useEffect)(()=>{if(!o)return;let a=a=>{q.current&&!q.current.contains(a.target)&&p(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[o]),(0,h.useLayoutEffect)(()=>{let a=a=>{s.current=a,u(b=>b.x===a.x&&b.y===a.y?b:a)};if(!o)return void a({x:0,y:0});let b=r.current;if(!b)return;let c=b.getBoundingClientRect();a({x:fm(c.left-s.current.x,c.width,window.innerWidth),y:fm(c.top-s.current.y,c.height,window.innerHeight)})},[o]);let y=(0,h.useCallback)(a=>{p(!1),m?.(a)},[m]),z=(0,h.useCallback)(()=>{p(a=>!a)},[]);return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex border-b border-border bg-surface dark:bg-surface-2 min-w-0",children:[(0,e.jsx)("div",{className:"flex min-w-0 overflow-hidden flex-1",children:w.map((a,c)=>(0,e.jsx)(fn,{tab:a,isActive:c===b,onActivate:f,onClose:d},a.path))}),x.length>0&&(0,e.jsxs)("div",{className:"relative flex-shrink-0",ref:q,children:[(0,e.jsxs)("button",{type:"button","data-testid":"tab-dropdown-button",onClick:z,className:"flex items-center gap-0.5 px-2 py-2 text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-muted border-b-2 border-transparent transition-colors",children:[(0,e.jsx)(bf.A,{className:`w-3 h-3 transition-transform ${o?"rotate-180":""}`}),(0,e.jsxs)("span",{children:["+",x.length]})]}),o&&(0,e.jsx)("div",{ref:r,"data-testid":"tab-dropdown-menu",className:"absolute right-0 top-full mt-1 bg-surface border border-border rounded-md shadow-lg z-50 min-w-[200px] max-h-[300px] overflow-y-auto",style:0!==t.x||0!==t.y?{transform:`translate(${t.x}px, ${t.y}px)`}:void 0,children:x.map(a=>(0,e.jsxs)("button",{type:"button","data-testid":`tab-dropdown-item-${a.path}`,onClick:()=>y(a.path),className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-muted truncate",title:a.path,children:[a.name,a.isDirty&&(0,e.jsx)("span",{className:"ml-1 w-2 h-2 inline-block rounded-full bg-warning"})]},a.path))})]})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:v&&(0,e.jsx)(fl,{tab:v,worktreeId:c,onLoadContent:g,onLoadError:i,onSetLoading:j,onFileSaved:k,onDirtyChange:l,onOpenFile:n},v.path)})]})}),fp=(0,h.memo)(function({line:a}){let b="whitespace-pre font-mono text-xs leading-5";return a.startsWith("+")&&!a.startsWith("+++")?b+=" text-success-foreground bg-success-subtle":a.startsWith("-")&&!a.startsWith("---")?b+=" text-danger-foreground bg-danger-subtle":a.startsWith("@@")?b+=" text-info bg-info/10":a.startsWith("diff --git")||a.startsWith("index ")||a.startsWith("---")||a.startsWith("+++")?b+=" text-muted-foreground":b+=" text-foreground",(0,e.jsx)("div",{className:b,children:a})}),fq=(0,h.memo)(function({diff:a,filePath:b,onClose:c}){let d=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"h-full flex flex-col bg-surface",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-muted shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-accent-600 dark:text-accent-400 shrink-0",children:d("diffViewer.badge")}),(0,e.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:b})]}),(0,e.jsx)("button",{type:"button",onClick:c,className:"p-1 text-muted-foreground hover:text-foreground rounded shrink-0","aria-label":d("diffViewer.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",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-2",children:(0,e.jsx)("pre",{className:"text-xs",children:(0,e.jsx)("code",{children:a.split("\n").map((a,b)=>(0,e.jsx)(fp,{line:a},b))})})})]})});function fr(){let[a,b]=(0,h.useState)(!1),c=(0,h.useRef)(a);c.current=a;let d=(0,h.useCallback)(a=>{b(a)},[]);return{collapsed:a,toggle:(0,h.useCallback)(()=>{d(!c.current)},[d]),setCollapsed:d}}let fs=(0,h.memo)(function({terminal:a,terminalHeader:b,fileTabs:c,worktreeId:d,onCloseTab:f,onActivateTab:g,onLoadContent:i,onLoadError:j,onSetLoading:l,onFileSaved:m,diffContent:n,diffFilePath:o,onCloseDiff:p,onDirtyChange:q,onMoveToFront:r,onOpenFile:s}){let t=(0,k.c)("worktree"),u=(0,h.useRef)(null),[v,w]=(0,h.useState)(50),{collapsed:x,toggle:y}=fr(),z=(0,h.useCallback)(a=>{let b=u.current;if(!b)return;let c=b.offsetWidth;if(0===c)return;let d=a/c*100;w(a=>Math.min(80,Math.max(20,a+d)))},[]),A=(0,h.useMemo)(()=>({width:`${v}%`}),[v]),B=(0,h.useMemo)(()=>({width:`${100-v}%`}),[v]),C=(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[b,(0,e.jsx)("div",{className:"flex-1 min-h-0",children:a})]});return c.tabs.length>0||n&&o?x?(0,e.jsxs)("div",{ref:u,className:"flex h-full min-h-0",children:[(0,e.jsx)("div",{"data-testid":"terminal-pane",style:{width:"calc(100% - 36px)"},className:"flex-shrink-0 overflow-hidden",children:C}),(0,e.jsx)("div",{"data-testid":"file-panel-expand-bar",style:{width:"36px"},className:"flex-shrink-0 flex items-start justify-center bg-muted border-l border-border",children:(0,e.jsxs)("button",{type:"button","aria-label":t("terminal.showFiles"),title:t("terminal.showFiles"),onClick:y,className:"flex flex-col items-center gap-2 w-full pt-2 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,e.jsx)("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),(0,e.jsx)("span",{className:"text-xs font-medium tracking-wide select-none",style:{writingMode:"vertical-rl"},"aria-hidden":"true",children:t("terminal.filesLabel")})]})})]}):(0,e.jsxs)("div",{ref:u,className:"flex h-full min-h-0",children:[(0,e.jsx)("div",{"data-testid":"terminal-pane",style:A,className:"flex-shrink-0 overflow-hidden",children:C}),(0,e.jsx)(ct,{onResize:z,orientation:"horizontal",ariaValueNow:v}),(0,e.jsxs)("div",{"data-testid":"file-panel-pane",style:B,className:"flex-grow overflow-hidden flex",children:[(0,e.jsx)("button",{type:"button","aria-label":t("terminal.hideFiles"),title:t("terminal.hideFiles"),onClick:y,className:"flex-shrink-0 flex items-center justify-center w-5 h-full bg-muted border-r border-border text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),(0,e.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:n&&o&&p?(0,e.jsx)(fq,{diff:n,filePath:o,onClose:p}):(0,e.jsx)(fo,{tabs:c.tabs,activeIndex:c.activeIndex,worktreeId:d,onClose:f,onActivate:g,onLoadContent:i,onLoadError:j,onSetLoading:l,onFileSaved:m,onDirtyChange:q,onMoveToFront:r,onOpenFile:s})})]})]}):(0,e.jsx)("div",{className:"h-full",children:C})});var ft=c(51881);let fu=(0,x.A)("align-horizontal-distribute-center",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]]),fv=(0,x.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"}]]),fw=(0,x.A)("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),fx={splits:[{cliToolId:"claude",instanceId:"claude"}],widths:[1]};be.XH;function fy(a){let b=a.reduce((a,b)=>a+b,0);return b>0?a.map(a=>a/b):a.map(()=>1/a.length)}let fz=(0,h.memo)(function({worktreeId:a,instances:b,rosterReady:c=!0,renderPane:d,onFocusedSplitChange:f,showToast:g,onActiveInstanceChange:j,headerInstanceSelection:l}){let{splits:m,widths:n,addSplit:o,removeSplit:p,setSplitInstance:q,setSplitWidth:r,resetWidths:s,availableInstanceIds:t,focusedSplitIndex:u,setFocusedSplitIndex:v}=function(a,b,c=!0){let[d,e]=(0,h.useState)(()=>(function(a,b,c){let d=function(a,b){let c=b[0];return c?{splits:[{cliToolId:c.cliTool,instanceId:c.id}],widths:[1]}:{splits:fx.splits.map(a=>({...a})),widths:[...fx.widths]}}(0,b);return c?function(a,b){let c;if(0===b.length)return a;let d=new Map(b.map(a=>[a.id,a.cliTool])),e=new Set,f=Math.min(Math.max(a.splits.length,1),b.length,3),g=[];for(let b of a.splits){if(g.length>=f)break;let a=d.get(b.instanceId);a&&!e.has(b.instanceId)&&(e.add(b.instanceId),g.push({cliToolId:a,instanceId:b.instanceId}))}for(let a of b){if(g.length>=f)break;e.has(a.id)||(e.add(a.id),g.push({cliToolId:a.cliTool,instanceId:a.id}))}return(0===g.length&&g.push({cliToolId:b[0].cliTool,instanceId:b[0].id}),g.length===a.splits.length&&g.every((b,c)=>b.instanceId===a.splits[c].instanceId&&b.cliToolId===a.splits[c].cliToolId))?a:(c=g.length===a.widths.length?fy(a.widths):g.length<a.widths.length?fy(a.widths.slice(0,g.length)):Array.from({length:g.length},()=>1/g.length),{splits:g,widths:c})}(d,b):d})(0,b,c)),[f,g]=(0,h.useState)(0),i=(0,h.useRef)(d);i.current=d;let j=(0,h.useRef)(b);j.current=b,(0,h.useRef)(c).current=c,(0,h.useRef)(a),(0,h.useMemo)(()=>b.map(a=>`${a.id}:${a.cliTool}`).join("|"),[b]),(0,h.useRef)(a);let k=(0,h.useCallback)(()=>{e(a=>{if(a.splits.length>=3)return a;let b=new Set(a.splits.map(a=>a.instanceId)),c=function(a,b){for(let c of a)if(!b.has(c.id))return c;return null}(j.current,b);if(!c)return a;let d=a.widths.length-1,e=a.widths[d]/2,f=[...a.widths];return f[d]=e,f.push(e),{splits:[...a.splits,{cliToolId:c.cliTool,instanceId:c.id}],widths:f}})},[]),l=(0,h.useCallback)(()=>{e(a=>a.splits.length<=1?a:{splits:a.splits.slice(0,-1),widths:fy(a.widths.slice(0,-1))})},[]),m=(0,h.useCallback)((a,b)=>{let c=i.current,d=j.current;if(a<0||a>=c.splits.length)return!1;let f=d.find(a=>a.id===b);if(!f||c.splits[a].instanceId===b)return!1;for(let d=0;d<c.splits.length;d++)if(d!==a&&c.splits[d].instanceId===b)return!1;return e(c=>{if(a<0||a>=c.splits.length||c.splits[a].instanceId===b)return c;for(let d=0;d<c.splits.length;d++)if(d!==a&&c.splits[d].instanceId===b)return c;let d=c.splits.map((c,d)=>d===a?{cliToolId:f.cliTool,instanceId:b}:c);return{...c,splits:d}}),!0},[]),n=(0,h.useCallback)(a=>{e(b=>a.length!==b.widths.length||!function(a){if(!Array.isArray(a))return!1;for(let b of a)if("number"!=typeof b||!Number.isFinite(b)||b<=0)return!1;return!0}(a)?b:{...b,widths:[...a]})},[]),o=(0,h.useCallback)(()=>{e(a=>{let b=a.splits.length;return 0===b?a:{...a,widths:Array.from({length:b},()=>1/b)}})},[]),p=(0,h.useCallback)(a=>{let c=new Set;for(let b=0;b<d.splits.length;b++)b!==a&&c.add(d.splits[b].instanceId);return b.filter(a=>!c.has(a.id)).map(a=>a.id)},[d.splits,b]),q=(0,h.useCallback)(a=>{g(a)},[]);return{splits:d.splits,widths:d.widths,addSplit:k,removeSplit:l,setSplitInstance:m,setSplitWidth:n,resetWidths:o,availableInstanceIds:p,focusedSplitIndex:f,setFocusedSplitIndex:q}}(a,b,c),w=(0,h.useMemo)(()=>{let a=new Map;for(let c of b)a.set(c.id,c);return a},[b]),x=(0,k.c)("worktree"),{visible:y,toggle:z,setWidth:A}=co(),{collapsed:B,toggle:C}=fr(),D=!B,E=(0,h.useRef)(null),[F,G]=(0,h.useState)(!1),H=(0,h.useRef)(m.length),[I,J]=(0,h.useState)(null);(0,h.useEffect)(()=>{m.length>H.current&&J(m.length-1),H.current=m.length},[m.length]),(0,h.useEffect)(()=>{f?.(u)},[u,f]);let K=(0,h.useRef)(0),L=(0,h.useRef)(m);L.current=m,(0,h.useEffect)(()=>{if(!l||l.token===K.current)return;K.current=l.token;let{instanceId:a}=l,b=L.current.findIndex(b=>b.instanceId===a);if(0!==b){if(b>0)return void v(b);q(0,a)&&v(0)}},[l,q,v]),(0,h.useEffect)(()=>{if(null===I)return;let a=E.current;if(!a)return;let b=a.querySelector(`[data-split-index="${I}"]`);if(!b)return;let c=b.querySelector("textarea");c?.focus(),v(I),J(null)},[I,v]);let M=(0,h.useCallback)((a,b)=>{let c=E.current;if(!c)return;let d=c.offsetWidth;if(0===d)return;let e=n.reduce((a,b)=>a+b,0),f=b/d*e,g=[...n],h=g[a]+f,i=g[a+1]-f,j=.05*e;h<j||i<j||(g[a]=h,g[a+1]=i,r(g))},[n,r]),N=(0,h.useCallback)(()=>G(!0),[]),O=(0,h.useCallback)(()=>G(!1),[]),P=(0,h.useCallback)(()=>{s(),A(40)},[s,A]),Q=m.length<3&&!F,R=m.length>1&&!F,S=m.length>1||y,T=(0,h.useMemo)(()=>m.map((a,b)=>()=>v(b)),[m,v]),U=(0,h.useMemo)(()=>m.map((a,b)=>a=>q(b,a)),[m,q]),V=(0,h.useMemo)(()=>m.map((a,b)=>a=>{let c=(0,be.sw)(w.get(a)??{cliTool:"claude",alias:a});if(m[b]?.instanceId===a)return;let d=m.findIndex((c,d)=>d!==b&&c.instanceId===a);if(-1!==d)return void g?.(`${c} is already in use by split ${d+1}`,"warning");q(b,a)&&(j?.(a),g?.(`Moved ${c} to Split ${b+1}`,"success"))}),[m,q,g,j,w]);return(0,e.jsxs)("div",{role:"group","aria-label":"Terminal splits","data-testid":"terminal-split-container",className:"flex flex-col h-full min-h-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-surface border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums mr-1",children:[m.length," / ",3," splits"]}),(0,e.jsx)("button",{type:"button",onClick:o,disabled:!Q,"aria-disabled":!Q,"aria-label":x("terminal.addSplit"),title:x("terminal.addSplit"),"data-testid":"add-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(dM,{className:"w-4 h-4","aria-hidden":"true"})}),(0,e.jsx)("button",{type:"button",onClick:p,disabled:!R,"aria-disabled":!R,"aria-label":x("terminal.removeSplit"),title:x("terminal.removeSplit"),"data-testid":"remove-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(ft.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,e.jsx)("button",{type:"button",onClick:P,disabled:!S,"aria-disabled":!S,"aria-label":x("terminal.equalizeWidthsHint"),title:x("terminal.equalizeWidthsHint"),"data-testid":"equalize-split-widths",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(fu,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})}),(0,e.jsx)("div",{className:"ml-auto h-4 w-px bg-border","aria-hidden":"true"}),(0,e.jsxs)("button",{type:"button",onClick:z,"aria-pressed":y,"aria-label":x(y?"terminal.hideHistory":"terminal.showHistory"),title:x(y?"terminal.hideHistory":"terminal.showHistory"),"data-testid":"toggle-history-pane",className:`flex items-center gap-1 text-xs px-2 py-0.5 rounded border transition-colors ${y?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[(0,e.jsx)(fv,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:x("terminal.historyLabel")})]}),(0,e.jsxs)("button",{type:"button",onClick:C,"aria-pressed":D,"aria-label":x(D?"terminal.hideFiles":"terminal.showFiles"),title:x(D?"terminal.hideFiles":"terminal.showFiles"),"data-testid":"toggle-file-panel",className:`flex items-center gap-1 text-xs px-2 py-0.5 rounded border transition-colors ${D?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[(0,e.jsx)(fw,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:x("terminal.filesLabel")})]})]}),(0,e.jsx)("div",{ref:E,className:"flex flex-1 min-h-0 w-full",children:m.map((a,b)=>{let c=b===m.length-1;return(0,e.jsxs)(i().Fragment,{children:[(0,e.jsx)("div",{style:{flexGrow:n[b]??1,flexShrink:1,flexBasis:0,minWidth:0},className:"h-full",children:d({splitIndex:b,cliToolId:a.cliToolId,instanceId:a.instanceId,instance:w.get(a.instanceId),availableInstances:t(b).map(a=>w.get(a)).filter(a=>void 0!==a),onInstanceChange:U[b],onFocus:T[b],isFocused:u===b,onDropInstance:V[b]})}),c?null:(0,e.jsx)(fA,{resizerIdx:b,ariaValueNow:n.length?n[b]/n.reduce((a,b)=>a+b,0)*100:50,onResize:M,onStart:N,onEnd:O,onDoubleClick:s})]},`split-${b}`)})})]})});function fA({resizerIdx:a,ariaValueNow:b,onResize:c,onStart:d,onEnd:f,onDoubleClick:g}){let i=(0,h.useCallback)(b=>c(a,b),[a,c]);return(0,e.jsx)("div",{"data-testid":`split-resizer-${a}`,onMouseDownCapture:d,onTouchStartCapture:d,onMouseUpCapture:f,onTouchEndCapture:f,children:(0,e.jsx)(ct,{onResize:i,orientation:"horizontal",ariaValueNow:b,onDoubleClick:g})})}let fB=`
33
+ ${b.trim()}`:c}(s,g))})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)("input",{type:"text",value:w,onChange:a=>x(a.target.value),placeholder:s("git.stash.messagePlaceholder"),className:"w-full px-2 py-1 text-xs border border-input rounded bg-surface dark:bg-surface-2 text-foreground","data-testid":"git-stash-push-message"}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,e.jsx)(n.Sc,{checked:y,onCheckedChange:a=>z(!0===a),"data-testid":"git-stash-include-untracked"}),s("git.stash.includeUntracked")]}),(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>{l(w,y),x(""),z(!1)},className:"px-2 py-1 text-xs rounded bg-accent-600 hover:bg-accent-700 text-white disabled:opacity-50","data-testid":"stash-push-button",children:s("git.stash.push")})]})]}),b?(0,e.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",role:"status",children:s("git.stash.loading")}):0===a.length?(0,e.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",children:s("git.stash.empty")}):(0,e.jsx)("ul",{className:"divide-y divide-border",children:a.map(a=>(0,e.jsx)("li",{className:"py-1.5","data-testid":"git-stash-row",children:(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("span",{className:"font-mono text-xs text-accent-600 dark:text-accent-400",children:["stash@","{",a.index,"}"]}),(0,e.jsx)("span",{className:"ml-2 text-xs text-foreground truncate",children:a.message})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>o(a.index),className:"px-1.5 py-0.5 text-xs rounded border border-input hover:bg-muted disabled:opacity-50","data-testid":"stash-apply-button",children:s("git.stash.apply")}),(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>m(a.index),className:"px-1.5 py-0.5 text-xs rounded border border-input hover:bg-muted disabled:opacity-50","data-testid":"stash-pop-button",children:s("git.stash.pop")}),(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>B(a.index),className:"px-1.5 py-0.5 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"stash-drop-button",children:s("git.stash.drop")})]})]})},a.index))})]}),null!==A&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"git-stash-drop-confirm",role:"dialog",children:[(0,e.jsxs)("p",{className:"text-xs text-danger-foreground",children:["stash@","{",A,"}",s("git.stash.dropConfirmSuffix")]}),i&&(0,e.jsx)("p",{className:"mt-1 text-xs text-danger-foreground","data-testid":"git-stash-drop-session-warning",children:s("git.danger.runningSessionWarning")}),(0,e.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>{p(A),B(null)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"git-stash-drop-confirm-button",children:s("git.stash.drop")}),(0,e.jsx)("button",{type:"button",onClick:()=>B(null),className:"px-2 py-1 text-xs rounded border border-input hover:bg-muted",children:t("cancel")})]})]})]})}),eD={soft:"git.danger.modeSoft",mixed:"git.danger.modeMixed",hard:"git.danger.modeHard"},eE=(0,h.memo)(function({selectedCommit:a,busy:b,actionError:c,conflictNotice:d,currentBranch:f,aheadCount:g,hasRunningSession:i,onReset:j,onRevert:l,onForcePush:m}){let{isMobile:o,onInsertToMessage:p}=ei(),q=(0,k.c)("worktree"),r=(0,k.c)("common"),[s,t]=(0,h.useState)(!1),[u,v]=(0,h.useState)("mixed"),[w,x]=(0,h.useState)(!0),[y,z]=(0,h.useState)(""),[A,B]=(0,h.useState)(!1),[C,D]=(0,h.useState)(!1),[E,F]=(0,h.useState)(!1),[G,H]=(0,h.useState)(!1),[I,J]=(0,h.useState)(!0),K=w?"HEAD":a,L=!w&&!a;return(0,e.jsxs)("div",{className:"border-t-2 border-danger-border","data-testid":"git-danger-zone-section",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>t(a=>!a),className:"w-full flex items-center gap-1 px-3 py-2 text-sm font-medium text-danger-foreground bg-danger-subtle cursor-pointer hover:bg-danger-subtle","data-testid":"git-danger-zone-toggle",children:[(0,e.jsx)("span",{className:"text-xs w-4 text-center",children:s?"▼":"▶"}),q("git.danger.title")]}),s&&(0,e.jsxs)("div",{className:"px-3 py-3 space-y-2 bg-danger-subtle",children:[c&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-danger-zone-error",children:c}),d&&(0,e.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-danger-zone-conflict",children:d}),(0,e.jsxs)("div",{className:`flex ${o?"flex-col":"flex-row"} gap-2`,children:[(0,e.jsx)("button",{type:"button",onClick:()=>B(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle","data-testid":"git-danger-zone-reset-open",children:q("git.danger.resetOpen")}),(0,e.jsx)("button",{type:"button",disabled:!a,onClick:()=>D(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"git-danger-zone-revert-open",children:q("git.danger.revertOpen")}),m&&(0,e.jsx)("button",{type:"button",disabled:b,onClick:()=>H(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"git-force-push-open",children:q("git.danger.forcePushOpen")})]}),!a&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:q("git.danger.selectCommitHint")})]}),A&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"reset-confirm",role:"dialog",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:q("git.danger.resetTitle")}),(0,e.jsxs)(n.z6,{value:w?"head":"commit",onValueChange:a=>x("head"===a),name:"reset-target",className:"flex flex-col gap-1 mb-2",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,e.jsx)(n.CU,{value:"head","data-testid":"reset-target-head"}),q("git.danger.resetTargetHead")]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,e.jsx)(n.CU,{value:"commit",disabled:!a,"data-testid":"reset-target-commit"}),q("git.danger.resetTargetSelectedPrefix"),a?q("git.danger.resetTargetSelectedHash",{hash:a.slice(0,7)}):q("git.danger.resetTargetNoneSelected")]})]}),(0,e.jsx)(n.z6,{value:u,onValueChange:a=>v(a),name:"reset-mode",className:"flex flex-col gap-1 mb-2",children:["soft","mixed","hard"].map(a=>(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,e.jsx)(n.CU,{value:a,"data-testid":`reset-mode-${a}`}),q(eD[a])]},a))}),"hard"===u&&(0,e.jsxs)("div",{className:"mb-2 space-y-1",children:[(0,e.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-history-loss-warning",children:q("git.danger.resetHardWarning")}),i&&(0,e.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-session-warning",children:q("git.danger.runningSessionWarning")}),(0,e.jsx)("input",{type:"text",value:y,onChange:a=>z(a.target.value),placeholder:q("git.danger.confirmPlaceholder",{branch:f??""}),className:"w-full px-2 py-1 text-xs border border-danger-border rounded bg-surface dark:bg-surface-2 text-foreground","data-testid":"reset-hard-branch-input"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,e.jsx)(eq,{className:"mr-auto",testId:"reset-ask-ai",disabled:L,onClick:()=>{K&&(p("hard"===u?q("git.aiPrompts.resetHard",{target:ez(K)}):q("git.aiPrompts.reset",{target:ez(K),mode:u})),B(!1),z(""))}}),(0,e.jsx)("button",{type:"button",disabled:b||L||"hard"===u&&y!==(f??""),onClick:()=>{K&&(j(K,u,"hard"===u?y:void 0),B(!1),z(""))},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"reset-confirm-button",children:q("git.danger.reset")}),(0,e.jsx)("button",{type:"button",onClick:()=>{B(!1),z("")},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:r("cancel")})]})]}),C&&a&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"revert-confirm",role:"dialog",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:q("git.danger.revertTitle")}),(0,e.jsxs)("p",{className:"text-xs text-foreground mb-2",children:[q("git.danger.revertBodyPrefix"),(0,e.jsx)("span",{className:"font-mono",children:a.slice(0,7)})]}),i&&(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"revert-session-warning",children:q("git.danger.runningSessionWarning")}),(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,e.jsx)(n.Sc,{checked:E,onCheckedChange:a=>F(!0===a),"data-testid":"revert-no-commit"}),q("git.danger.revertNoCommit")]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,e.jsx)(eq,{className:"mr-auto",testId:"revert-ask-ai",onClick:()=>{p(q("git.aiPrompts.revert",{commit:ez(a.slice(0,7))})),D(!1),F(!1)}}),(0,e.jsx)("button",{type:"button",disabled:b,onClick:()=>{l(a,E),D(!1),F(!1)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"revert-confirm-button",children:q("git.danger.revert")}),(0,e.jsx)("button",{type:"button",onClick:()=>{D(!1),F(!1)},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:r("cancel")})]})]}),G&&m&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"force-push-confirm",role:"dialog",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:q("git.danger.forcePushTitle")}),(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-protected-branch-warning",children:q("git.danger.protectedBranchWarning")}),i&&(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-session-warning",children:q("git.danger.runningSessionWarning")}),(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,e.jsx)(n.Sc,{checked:I,onCheckedChange:a=>J(!0===a),"data-testid":"force-push-with-lease"}),q("git.danger.forceWithLease")]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,e.jsx)(eq,{className:"mr-auto",testId:"force-push-ask-ai",onClick:()=>{p(function(a,{branch:b,ahead:c}){let d=b?ez(b):a("git.aiPrompts.forcePushCurrentBranch");return a("number"==typeof c&&c>0?"git.aiPrompts.forcePushAhead":"git.aiPrompts.forcePush",{branchRef:d,upstream:ez(`origin/${b??"<branch>"}`),ahead:c??0})}(q,{branch:f,ahead:g??null})),H(!1)}}),(0,e.jsx)("button",{type:"button",disabled:b,onClick:()=>{m(I),H(!1)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"force-push-confirm-button",children:q("git.danger.forcePush")}),(0,e.jsx)("button",{type:"button",onClick:()=>H(!1),className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:r("cancel")})]})]})]})}),eF=(0,h.memo)(function({worktreeId:a,onDiffSelect:b,isMobile:c=!1,worktree:d,onInsertToMessage:f,className:g=""}){let i=(0,k.c)("worktree"),{activeTab:j,setActiveTab:l,historyOpen:m,toggleHistory:o,advancedOpen:p,toggleAdvanced:q}=function(){let{value:a,setValue:b,isAvailable:c}=(0,d7.V)({key:ea.activeTab,defaultValue:"status",validate:eb}),{value:d,setValue:e}=(0,d7.V)({key:ea.historyOpen,defaultValue:!0,validate:ec}),{value:f,setValue:g}=(0,d7.V)({key:ea.advancedOpen,defaultValue:!1,validate:ec}),i=(0,h.useCallback)(a=>b(a),[b]);return{activeTab:a,setActiveTab:i,historyOpen:d,toggleHistory:(0,h.useCallback)(()=>e(a=>!a),[e]),advancedOpen:f,toggleAdvanced:(0,h.useCallback)(()=>g(a=>!a),[g]),isPersistent:c}}(),r=Object.values(d?.sessionStatusByCli??{}).some(a=>a?.isRunning===!0),{gitStatus:s,statusLoading:t,statusError:u,fetchStatus:v}=function(a){let[b,c]=(0,h.useState)(null),[d,e]=(0,h.useState)(!0),[f,g]=(0,h.useState)(null);return{gitStatus:b,statusLoading:d,statusError:f,fetchStatus:(0,h.useCallback)(async()=>{g(null);try{let b=await fetch(`/api/worktrees/${a}/git/status`);if(!b.ok){let a=await b.json().catch(()=>({}));g(a.error||"Failed to fetch git status");return}let d=await b.json();c(d)}catch{g("Failed to fetch git status")}finally{e(!1)}},[a])}}(a),{commits:w,selectedCommit:x,changedFiles:y,inlineDiffCommit:z,inlineFiles:A,inlineFilesLoading:B,inlineFilesError:C,selectedFile:D,diffContent:E,isLoading:F,isLoadingFiles:G,isLoadingDiff:H,commitError:I,detailError:J,setDiffContent:K,fetchCommits:L,handleCommitSelect:M,handleFileSelect:N,handleToggleInlineDiff:O,handleInlineDiffFile:P,handleRefresh:Q}=function(a,b){let[c,d]=(0,h.useState)([]),[e,f]=(0,h.useState)(null),[g,i]=(0,h.useState)([]),[j,k]=(0,h.useState)(null),[l,m]=(0,h.useState)([]),[n,o]=(0,h.useState)(!1),[p,q]=(0,h.useState)(null),[r,s]=(0,h.useState)(null),[t,u]=(0,h.useState)(null),[v,w]=(0,h.useState)(!0),[x,y]=(0,h.useState)(!1),[z,A]=(0,h.useState)(!1),[B,C]=(0,h.useState)(null),[D,E]=(0,h.useState)(null),F=(0,h.useCallback)(async()=>{w(!0),C(null);try{let b=await fetch(`/api/worktrees/${a}/git/log`);if(!b.ok){let a=await b.json();C(a.error||"Failed to fetch commit history");return}let c=await b.json();d(c.commits)}catch{C("Failed to fetch commit history")}finally{w(!1)}},[a]),G=(0,h.useCallback)(async b=>{y(!0),i([]),s(null),u(null),E(null);try{let c=await fetch(`/api/worktrees/${a}/git/show/${b}`);if(!c.ok){let a=await c.json();E(a.error||"Failed to fetch commit details");return}let d=await c.json();i(d.files)}catch{E("Failed to fetch commit details")}finally{y(!1)}},[a]),H=(0,h.useCallback)(async(c,d)=>{A(!0),u(null),E(null);try{let e=await fetch(`/api/worktrees/${a}/git/diff?commit=${c}&file=${encodeURIComponent(d)}`);if(!e.ok){let a=await e.json();E(a.error||"Failed to fetch diff");return}let f=await e.json();u(f.diff),b(f.diff,d)}catch{E("Failed to fetch diff")}finally{A(!1)}},[a,b]),I=(0,h.useCallback)(a=>{f(a),G(a)},[G]),J=(0,h.useCallback)(a=>{e&&(s(a),H(e,a))},[e,H]),K=(0,h.useCallback)(async b=>{if(j===b){k(null),m([]),q(null);return}k(b),m([]),q(null),o(!0);try{let c=await fetch(`/api/worktrees/${a}/git/show/${b}`);if(!c.ok){let a=await c.json().catch(()=>({}));q(a.error||"Failed to fetch commit details");return}let d=await c.json();m(Array.isArray(d.files)?d.files:[])}catch{q("Failed to fetch commit details")}finally{o(!1)}},[a,j]),L=(0,h.useCallback)((a,b)=>{f(a),s(b),i(l),H(a,b)},[l,H]),M=(0,h.useCallback)(()=>{f(null),i([]),s(null),u(null),E(null),F()},[F]);return{commits:c,selectedCommit:e,changedFiles:g,inlineDiffCommit:j,inlineFiles:l,inlineFilesLoading:n,inlineFilesError:p,selectedFile:r,diffContent:t,isLoading:v,isLoadingFiles:x,isLoadingDiff:z,commitError:B,detailError:D,setDiffContent:u,fetchCommits:F,handleCommitSelect:I,handleFileSelect:J,handleToggleInlineDiff:K,handleInlineDiffFile:L,handleRefresh:M}}(a,b),R=(0,h.useCallback)(async()=>{await L(),await v()},[L,v]),{staged:S,stagedLoading:T,stagedError:U,opBusy:V,commitMessage:W,setCommitMessage:X,amend:Y,setAmend:Z,committing:$,changesCommitError:_,fetchStaged:aa,handleStage:ab,handleUnstage:ac,handleChangesDiff:ad,fetchWorkingDiffText:ae,commit:af,commitAndPush:ag}=function(a,b){let{onWorkingDiff:c,onCommitted:d}=b,[e,f]=(0,h.useState)(null),[g,i]=(0,h.useState)(!0),[j,k]=(0,h.useState)(null),[l,m]=(0,h.useState)(!1),[n,o]=(0,h.useState)(""),[p,q]=(0,h.useState)(!1),[r,s]=(0,h.useState)(!1),[t,u]=(0,h.useState)(null),v=(0,h.useCallback)(async()=>{k(null);try{let b=await fetch(`/api/worktrees/${a}/git/staged`);if(!b.ok){let a=await b.json().catch(()=>({}));k(a.error||"Failed to fetch changes");return}let c=await b.json();f(c)}catch{k("Failed to fetch changes")}finally{i(!1)}},[a]),w=(0,h.useCallback)(async b=>{m(!0),k(null);try{let c=await fetch(`/api/worktrees/${a}/git/stage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[b]})});if(!c.ok){let a=await c.json().catch(()=>({}));k(a.error||"Failed to stage file");return}await v()}catch{k("Failed to stage file")}finally{m(!1)}},[a,v]),x=(0,h.useCallback)(async b=>{m(!0),k(null);try{let c=await fetch(`/api/worktrees/${a}/git/unstage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[b]})});if(!c.ok){let a=await c.json().catch(()=>({}));k(a.error||"Failed to unstage file");return}await v()}catch{k("Failed to unstage file")}finally{m(!1)}},[a,v]),y=(0,h.useCallback)(async()=>{u(null);try{let b=await fetch(`/api/worktrees/${a}/git/commit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:n,amend:p})});if(!b.ok){let a=await b.json().catch(()=>({}));return u(a.error||"Failed to commit"),!1}return o(""),q(!1),await v(),await d(),!0}catch{return u("Failed to commit"),!1}},[a,n,p,v,d]),z=(0,h.useCallback)(async()=>{s(!0);try{await y()}finally{s(!1)}},[y]),A=(0,h.useCallback)(async a=>{s(!0);try{await y()&&await a()}finally{s(!1)}},[y]);return{staged:e,stagedLoading:g,stagedError:j,opBusy:l,commitMessage:n,setCommitMessage:o,amend:p,setAmend:q,committing:r,changesCommitError:t,fetchStaged:v,handleStage:w,handleUnstage:x,handleChangesDiff:(0,h.useCallback)(async(b,d)=>{try{let e=await fetch(`/api/worktrees/${a}/git/working-diff?file=${encodeURIComponent(b)}&mode=${d}`);if(!e.ok)return;let f=await e.json();"string"==typeof f.diff&&c(f.diff,b)}catch{}},[a,c]),fetchWorkingDiffText:(0,h.useCallback)(async(b,c)=>{try{let d=await fetch(`/api/worktrees/${a}/git/working-diff?file=${encodeURIComponent(b)}&mode=${c}`);if(!d.ok)return null;let e=await d.json();return"string"==typeof e.diff?e.diff:null}catch{return null}},[a]),commit:z,commitAndPush:A}}(a,{onWorkingDiff:(0,h.useCallback)((a,c)=>{K(a),b(a,c)},[K,b]),onCommitted:R}),{branches:ah,branchInclude:ai,branchesLoading:aj,branchesError:ak,branchBusy:al,branchActionError:am,fetchBranches:an,handleBranchIncludeChange:ao,handleBranchesRefresh:ap,handleCheckout:aq,handleBranchCreate:ar,handleBranchDelete:as}=function(a,b){let{onCheckoutCascade:c}=b,[d,e]=(0,h.useState)([]),[f,g]=(0,h.useState)("local"),[i,j]=(0,h.useState)(!0),[k,l]=(0,h.useState)(null),[m,n]=(0,h.useState)(!1),[o,p]=(0,h.useState)(null),q=(0,h.useCallback)(async b=>{l(null);try{let c=await fetch(`/api/worktrees/${a}/git/branches?include=${b}`);if(!c.ok){let a=await c.json().catch(()=>({}));l(a.error||"Failed to fetch branches");return}let d=await c.json();e(Array.isArray(d.branches)?d.branches:[])}catch{l("Failed to fetch branches")}finally{j(!1)}},[a]),r=(0,h.useCallback)(a=>{g(a)},[]),s=(0,h.useCallback)(()=>{q(f)},[q,f]),t=(0,h.useCallback)(async(b,d)=>{n(!0),p(null);try{let e=await fetch(`/api/worktrees/${a}/git/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:b.name,force:d})});if(!e.ok){let a=await e.json().catch(()=>({}));p(a.error||"Failed to checkout branch");return}await Promise.all([c(),q(f)])}catch{p("Failed to checkout branch")}finally{n(!1)}},[a,f,c,q]),u=(0,h.useCallback)(async(b,c)=>{n(!0),p(null);try{let d=await fetch(`/api/worktrees/${a}/git/branch/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,from:c})});if(!d.ok){let a=await d.json().catch(()=>({}));p(a.error||"Failed to create branch");return}await q(f)}catch{p("Failed to create branch")}finally{n(!1)}},[a,f,q]),v=(0,h.useCallback)(async(b,c)=>{n(!0),p(null);try{let d=await fetch(`/api/worktrees/${a}/git/branch/delete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,force:c})});if(!d.ok){let a=await d.json().catch(()=>({}));p(a.error||"Failed to delete branch");return}await q(f)}catch{p("Failed to delete branch")}finally{n(!1)}},[a,f,q]);return{branches:d,branchInclude:f,branchesLoading:i,branchesError:k,branchBusy:m,branchActionError:o,fetchBranches:q,handleBranchIncludeChange:r,handleBranchesRefresh:s,handleCheckout:t,handleBranchCreate:u,handleBranchDelete:v}}(a,{onCheckoutCascade:(0,h.useCallback)(async()=>{await Promise.all([v(),aa(),L()])},[v,aa,L])}),{stashes:at,stashLoading:au,stashError:av,stashBusy:aw,stashActionError:ax,stashConflictNotice:ay,fetchStash:az,handleStashPush:aA,handleStashPop:aB,handleStashApply:aC,handleStashDrop:aD}=function(a,b){let{onStashMutated:c}=b,[d,e]=(0,h.useState)([]),[f,g]=(0,h.useState)(!0),[i,j]=(0,h.useState)(null),[k,l]=(0,h.useState)(!1),[m,n]=(0,h.useState)(null),[o,p]=(0,h.useState)(null),q=(0,h.useCallback)(async()=>{j(null);try{let b=await fetch(`/api/worktrees/${a}/git/stash`);if(!b.ok){let a=await b.json().catch(()=>({}));j(a.error||"Failed to fetch stashes");return}let c=await b.json();e(Array.isArray(c.stashes)?c.stashes:[])}catch{j("Failed to fetch stashes")}finally{g(!1)}},[a]),r=(0,h.useCallback)(async()=>{await Promise.all([q(),c()])},[q,c]),s=(0,h.useCallback)(async(a,b,c)=>{l(!0),n(null),p(null);try{let d=await fetch(a,b),e=await d.json().catch(()=>({}));if(!d.ok)return void n(e.error||c);if(e.conflict){let a=Array.isArray(e.conflictFiles)?e.conflictFiles.join(", "):"",b=e.stashRetained?" (stash retained)":"";p(`Stash operation produced conflicts: ${a}${b}`)}await r()}catch{n(c)}finally{l(!1)}},[r]),t=(0,h.useCallback)((b,c)=>{s(`/api/worktrees/${a}/git/stash/push`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:b||void 0,includeUntracked:c})},"Failed to stash changes")},[a,s]),u=(0,h.useCallback)(b=>{s(`/api/worktrees/${a}/git/stash/pop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:b})},"Failed to pop stash")},[a,s]);return{stashes:d,stashLoading:f,stashError:i,stashBusy:k,stashActionError:m,stashConflictNotice:o,fetchStash:q,handleStashPush:t,handleStashPop:u,handleStashApply:(0,h.useCallback)(b=>{s(`/api/worktrees/${a}/git/stash/apply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:b})},"Failed to apply stash")},[a,s]),handleStashDrop:(0,h.useCallback)(b=>{s(`/api/worktrees/${a}/git/stash/${b}`,{method:"DELETE"},"Failed to drop stash")},[a,s])}}(a,{onStashMutated:(0,h.useCallback)(async()=>{await Promise.all([v(),aa()])},[v,aa])}),{dangerBusy:aE,dangerActionError:aF,dangerConflictNotice:aG,handleReset:aH,handleRevert:aI}=function(a,b){let{onHeadMoved:c}=b,[d,e]=(0,h.useState)(!1),[f,g]=(0,h.useState)(null),[i,j]=(0,h.useState)(null);return{dangerBusy:d,dangerActionError:f,dangerConflictNotice:i,handleReset:(0,h.useCallback)(async(b,d,f)=>{e(!0),g(null),j(null);try{let e=await fetch(`/api/worktrees/${a}/git/reset`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:b,mode:d,confirmBranch:f})});if(!e.ok){let a=await e.json().catch(()=>({}));g(a.error||"Failed to reset");return}await c()}catch{g("Failed to reset")}finally{e(!1)}},[a,c]),handleRevert:(0,h.useCallback)(async(b,d)=>{e(!0),g(null),j(null);try{let e=await fetch(`/api/worktrees/${a}/git/revert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitHash:b,noCommit:d})});if(!e.ok){let a=await e.json().catch(()=>({}));g(a.error||"Failed to revert");return}let f=await e.json().catch(()=>({}));if(f.conflict){let a=Array.isArray(f.conflictFiles)?f.conflictFiles.join(", "):"";j(`Revert produced conflicts: ${a}`)}await c()}catch{g("Failed to revert")}finally{e(!1)}},[a,c])}}(a,{onHeadMoved:(0,h.useCallback)(async()=>{await Promise.all([v(),aa(),an(ai),L()])},[v,aa,an,ai,L])}),{operation:aJ,progressState:aK,error:aL,errorReason:aM,conflict:aN,conflictFiles:aO,runFetch:aP,runPull:aQ,runPush:aR,abort:aS}=function(a,b={}){let{onCascade:c}=b,[d,e]=(0,h.useState)(null),[f,g]=(0,h.useState)("idle"),[i,j]=(0,h.useState)(null),[k,l]=(0,h.useState)(null),[m,n]=(0,h.useState)(!1),[o,p]=(0,h.useState)([]),q=(0,h.useRef)(null),r=(0,h.useRef)(c),s=(0,h.useCallback)(async(b,c,d)=>{j(null),l(null),n(!1),p([]),e(b),g("running");let f=new AbortController;q.current=f;try{let e=await fetch(`/api/worktrees/${a}/git/${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d),signal:f.signal});if(!e.ok){var h,i;let a=await e.json().catch(()=>({}));l((h=a?.reason,"auth_failed"===h?"auth_failed":"protected_branch"===h?"protected_branch":null)),j((i=a?.error,"string"==typeof i&&i.length>0?i:null)),g("error");return}let k=await e.json().catch(()=>({success:!0}));"pull"===b&&k?.conflict&&(n(!0),p(Array.isArray(k.conflictFiles)?k.conflictFiles:[])),g("idle")}catch(a){a instanceof Error&&"AbortError"===a.name?g("idle"):(j(null),l(null),g("error"))}finally{e(null),q.current=null,r.current?.(b)}},[a]),t=(0,h.useCallback)(a=>{let b={prune:!0===a.prune};return void 0!==a.remote&&(b.remote=a.remote),s("fetch","fetch",b)},[s]),u=(0,h.useCallback)(a=>{let b={rebase:!0===a.rebase,ffOnly:!0===a.ffOnly};return void 0!==a.remote&&(b.remote=a.remote),void 0!==a.branch&&(b.branch=a.branch),s("pull","pull",b)},[s]);return{operation:d,progressState:f,error:i,errorReason:k,conflict:m,conflictFiles:o,runFetch:t,runPull:u,runPush:(0,h.useCallback)(a=>{let b={force:!0===a.force,forceWithLease:!0===a.forceWithLease,setUpstream:!0===a.setUpstream};return void 0!==a.remote&&(b.remote=a.remote),void 0!==a.branch&&(b.branch=a.branch),s("push","push",b)},[s]),abort:(0,h.useCallback)(()=>{q.current?.abort()},[])}}(a,{onCascade:(0,h.useCallback)(a=>{v(),an(ai),"pull"===a&&(aa(),L())},[v,an,ai,aa,L])}),aT="auth_failed"===aM?i("git.network.authFailedGuidance"):"protected_branch"===aM?i("git.danger.protectedBranchWarning"):aL,aU="running"===aK&&("push"===aJ||"pull"===aJ),aV=s?.aheadBehind!=null,aW=(0,h.useCallback)(()=>{aP({})},[aP]),aX=(0,h.useCallback)(()=>ag(()=>aR({setUpstream:!aV})),[ag,aR,aV]);cY({intervalMs:5e3,enabled:"running"!==aK,onPoll:v});let aY=(0,h.useMemo)(()=>({isMobile:c,onDiffSelect:b,onInsertToMessage:f}),[c,b,f]),aZ=(0,e.jsx)(eu,{gitStatus:s,statusLoading:t,statusError:u,onRefresh:aW,refreshing:"running"===aK}),a$=(0,e.jsx)(ev,{progressState:aK,operation:aJ,error:aT,conflict:aN,conflictFiles:aO,hasUpstream:aV,onPull:()=>aQ({}),onPush:()=>aR({setUpstream:!aV}),onAbort:aS,extraActions:(0,e.jsx)(ee,{branches:ah,busy:al||aU,actionError:am,hasRunningSession:r,isMobile:c,onCheckout:aq})}),a_=(0,e.jsx)(ex,{staged:S,loading:T,error:U,busy:V||aU,commitMessage:W,amend:Y,committing:$,commitError:_,onRefresh:aa,onDiff:ad,onPreview:ae,onStage:ab,onUnstage:ac,onCommitMessageChange:X,onAmendChange:Z,onCommit:af,onCommitAndPush:aX}),a0=(0,e.jsx)(ey,{commits:w,isLoading:F,commitError:I,commitListOpen:m,onToggleCommitList:o,onRefresh:Q,selectedCommit:x,onCommitSelect:M,inlineDiffCommit:z,inlineFiles:A,inlineFilesLoading:B,inlineFilesError:C,onToggleInlineDiff:O,onInlineDiffFile:P,changedFiles:y,isLoadingFiles:G,detailError:J,selectedFile:D,onFileSelect:N,diffContent:E,isLoadingDiff:H}),a1=(0,e.jsxs)(ef,{open:p,onToggle:q,children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-advanced-fetch",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:i("git.remote")}),(0,e.jsx)("div",{children:(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:()=>aP({}),disabled:"running"===aK,className:"px-2 py-1 text-xs rounded border border-input text-foreground hover:bg-muted disabled:opacity-50","data-testid":"git-fetch-button",children:i("git.network.fetch")})})]}),(0,e.jsx)(eB,{branches:ah,include:ai,loading:aj,error:ak,busy:al||aU,actionError:am,onIncludeChange:ao,onRefresh:ap,onCreate:ar,onDelete:as}),(0,e.jsx)(eC,{stashes:at,loading:au,error:av,busy:aw||aU,actionError:ax,conflictNotice:ay,hasRunningSession:r,onRefresh:az,onPush:aA,onPop:aB,onApply:aC,onDrop:aD}),(0,e.jsx)(eE,{selectedCommit:x,busy:aE||aU,actionError:aF,conflictNotice:aG,currentBranch:s?.currentBranch??null,aheadCount:s?.aheadBehind?.ahead??null,hasRunningSession:r,onReset:aH,onRevert:aI,onForcePush:a=>aR(a?{forceWithLease:!0}:{force:!0})})]});return(0,e.jsx)(eh,{value:aY,children:(0,e.jsx)(en,{activeTab:j,onTabChange:l,className:g,statusSection:aZ,quickActionsSection:a$,changesSection:a_,historySection:a0,advancedSection:a1})})}),eG=(0,h.memo)(function({worktreeId:a,worktree:b,onWorktreeUpdate:c}){let[d,f]=(0,h.useState)(!1),g=(0,k.c)("worktree"),i=(0,h.useRef)(b?.id),j=(0,h.useRef)(!1),l=eJ(b,c,b?.id,()=>{let a=b?.id!==i.current;return i.current=b?.id,a&&!j.current});return(j.current=l.isEditing,b)?(0,e.jsx)("div",{className:"p-4 space-y-4 overflow-y-auto h-full",children:(0,e.jsx)(eK,{worktreeId:a,worktree:b,cardClassName:"bg-surface rounded-lg border border-border p-4",descriptionEditor:l,showLogs:d,onToggleLogs:()=>f(!d),onWorktreeUpdate:c})}):(0,e.jsx)("div",{className:"text-muted-foreground text-center py-8",children:g("detail.loadingInfo")})}),eH=(0,h.memo)(function({activeTab:a,worktreeId:b,worktree:c,messages:d,cliToolId:f,instanceId:g,onFilePathClick:h,onFileSelect:i,onWorktreeUpdate:j,onNewFile:l,onNewDirectory:m,onRename:n,onDelete:o,onUpload:p,onMove:q,onFileTreeReset:r,refreshTrigger:s,fileSearch:t,showToast:u,selectedAgents:v,onSelectedAgentsChange:w,availableAgents:x,maxAgents:y,persistToServer:z,vibeLocalModel:A,onVibeLocalModelChange:B,vibeLocalContextWindow:C,onVibeLocalContextWindowChange:D,disableAutoFollow:E,historySubTab:G,onHistorySubTabChange:H,onDiffSelect:I,onInsertToMessage:J,showArchived:K,onShowArchivedChange:L,historyDisplayLimit:M,onHistoryDisplayLimitChange:N,historyUserOnly:O,onHistoryUserOnlyChange:P,useInstanceManagement:Q,instances:R,onInstancesChange:S,visibleInstanceIds:T,onToggleInstanceVisible:U}){let V=(0,k.c)("worktree");switch(a){case"terminal":return(0,e.jsx)(F,{componentName:"TerminalDisplay",children:(0,e.jsx)(bC,{worktreeId:b,cliToolId:f,instanceId:g,disableAutoFollow:E})});case"history":return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsxs)("div",{className:"flex border-b border-border shrink-0",children:[(0,e.jsx)("button",{type:"button",onClick:()=>H("message"),className:`flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ${"message"===G?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"}`,children:V("detail.subTabMessage")}),(0,e.jsx)("button",{type:"button",onClick:()=>H("git"),className:`flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ${"git"===G?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"}`,children:V("detail.subTabGit")})]}),"message"===G?(0,e.jsx)(F,{componentName:"HistoryPane",children:(0,e.jsx)(cC,{messages:d,worktreeId:b,onFilePathClick:h,className:"flex-1 min-h-0",showToast:u,onInsertToMessage:J,showArchived:K,onShowArchivedChange:L,historyDisplayLimit:M,onHistoryDisplayLimitChange:N,historyUserOnly:O,onHistoryUserOnlyChange:P})}):(0,e.jsx)(F,{componentName:"GitPane",children:(0,e.jsx)(eF,{worktreeId:b,onDiffSelect:I,isMobile:!0,worktree:c??void 0,onInsertToMessage:J,className:"flex-1 min-h-0"})})]});case"files":return(0,e.jsx)(F,{componentName:"FileTreeView",children:(0,e.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,e.jsx)(c2,{query:t.query,mode:t.mode,isSearching:t.isSearching,error:t.error,onQueryChange:t.setQuery,onModeChange:t.setMode,onClear:t.clearSearch}),(0,e.jsx)(c$,{worktreeId:b,onFileSelect:i,onNewFile:l,onNewDirectory:m,onRename:n,onDelete:o,onUpload:p,onMove:q,onResetView:r,refreshTrigger:s,pollingEnabled:"files"===a,searchQuery:t.query,searchMode:t.mode,searchResults:t.results?.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,e.jsx)(F,{componentName:"NotesAndLogsPane",children:(0,e.jsx)(d6,{worktreeId:b,className:"h-full",selectedAgents:v,onSelectedAgentsChange:w,availableAgents:x,maxAgents:y,persistToServer:z,vibeLocalModel:A,onVibeLocalModelChange:B,vibeLocalContextWindow:C,onVibeLocalContextWindowChange:D,onInsertToMessage:J,useInstanceManagement:Q,instances:R,onInstancesChange:S,visibleInstanceIds:T,onToggleInstanceVisible:U})});case"info":return(0,e.jsx)(eG,{worktreeId:b,worktree:c,onWorktreeUpdate:j});default:return null}}),eI=[{value:null,labelKey:"worktreeStatus.notSet"},{value:"ready",labelKey:"worktreeStatus.ready"},{value:"in_progress",labelKey:"worktreeStatus.inProgress"},{value:"in_review",labelKey:"worktreeStatus.inReview"},{value:"done",labelKey:"worktreeStatus.done"}];function eJ(a,b,c,d){let[e,f]=(0,h.useState)(!1),[g,i]=(0,h.useState)(""),[j,k]=(0,h.useState)(!1),l=(0,h.useCallback)(async()=>{if(a){k(!0);try{let c=await T.y.updateDescription(a.id,g);b(c),f(!1)}catch(a){console.error("Failed to save description:",a)}finally{k(!1)}}},[a,g,b]),m=(0,h.useCallback)(()=>{i(a?.description||""),f(!1)},[a]);return{isEditing:e,text:g,setText:i,isSaving:j,handleSave:l,handleCancel:m,startEditing:(0,h.useCallback)(()=>{f(!0)},[])}}let eK=(0,h.memo)(function({worktreeId:a,worktree:b,cardClassName:c,descriptionEditor:d,showLogs:f,onToggleLogs:g,onWorktreeUpdate:i}){let{isEditing:j,text:l,setText:m,isSaving:o,handleSave:p,handleCancel:q,startEditing:r}=d,s=(0,k.c)("worktree"),t=(0,k.c)("common"),[u,v]=(0,h.useState)(!1),[w,x]=(0,h.useState)(!1),y=(0,h.useRef)(void 0),z=(0,h.useRef)(void 0);(0,h.useEffect)(()=>()=>{y.current&&clearTimeout(y.current),z.current&&clearTimeout(z.current)},[]);let A=(0,h.useCallback)(async()=>{try{await (0,ay.l)(b.path),v(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>v(!1),ah.pX)}catch{}},[b.path]),B=(0,h.useCallback)(async()=>{try{await (0,ay.l)(b.repositoryPath),x(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>x(!1),ah.pX)}catch{}},[b.repositoryPath]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.worktree")}),(0,e.jsx)("p",{className:"text-lg font-semibold text-foreground",children:b.name})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.repository")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:B,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":s("detail.copyRepositoryPath"),title:w?s("detail.copied"):s("detail.copyRepositoryPath"),children:w?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("p",{className:"text-base text-foreground",children:b.repositoryDisplayName??b.repositoryName}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:b.repositoryPath})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.path")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:A,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":s("detail.copyWorktreePath"),title:u?s("detail.copied"):s("detail.copyPath"),children:u?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("p",{className:"text-sm text-foreground break-all font-mono",children:b.path})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.status")}),(0,e.jsx)("select",{value:b.status??"",onChange:async a=>{let c=a.target.value;try{let a=await fetch(`/api/worktrees/${b.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:""===c?null:c})});if(a.ok&&i){let b=await a.json();i(b)}}catch{}},className:"text-sm px-3 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent w-full","data-testid":"mobile-status-dropdown","aria-label":s("detail.worktreeStatusLabel"),children:eI.map(a=>(0,e.jsx)("option",{value:a.value??"",children:s(a.labelKey)},a.labelKey))})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.description")}),!j&&(0,e.jsx)("button",{type:"button",onClick:r,className:"text-sm text-accent-600 hover:text-accent-800 dark:text-accent-400 dark:hover:text-accent-300",children:s("actions.edit")})]}),j?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("textarea",{value:l,onChange:a=>m(a.target.value),placeholder:s("detail.addNotesPlaceholder"),className:"w-full min-h-[150px] p-3 border border-input dark:bg-surface dark:text-foreground rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:p,disabled:o,className:"px-4 py-2 bg-accent-600 text-white rounded-lg hover:bg-accent-700 disabled:opacity-50 text-sm font-medium",children:o?s("actions.saving"):s("actions.save")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:q,disabled:o,className:"px-4 py-2 bg-muted text-foreground rounded-lg hover:bg-border disabled:opacity-50 text-sm font-medium",children:t("cancel")})]})]}):(0,e.jsx)("div",{className:"min-h-[50px]",children:b.description?(0,e.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:b.description}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:s("detail.noDescription")})})]}),b.link&&(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.link")}),(0,e.jsx)("a",{href:b.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-600 hover:underline break-all",children:b.link})]}),b.updatedAt&&(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.lastUpdated")}),(0,e.jsx)("p",{className:"text-sm text-foreground",children:new Date(b.updatedAt).toLocaleString()})]}),(0,e.jsx)(a4,{version:"v0.17.0",className:c}),(0,e.jsx)(bb,{className:c}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.logs")}),(0,e.jsx)("button",{type:"button",onClick:g,className:"text-sm text-accent-600 hover:text-accent-800",children:f?s("detail.hide"):s("detail.show")})]}),f&&(0,e.jsx)(a0,{worktreeId:a})]})]})}),eL=(0,h.memo)(function({worktreeName:a,repositoryName:b,description:c,status:d,gitStatus:f,onBackClick:g,onInfoClick:i,hasUpdate:j,worktreeStatus:l,onWorktreeStatusChange:m,sessionStatusByCli:p,sessionStatusByInstance:q,instances:s,activeInstanceId:t,onActiveInstanceChange:u,onAgentDragStart:v,onAgentDragEnd:w,onKillSession:x}){let y=(0,k.c)("worktree"),z=(0,k.c)("common"),A=aX.sb[d],B=A?y(A):void 0,[D,E]=(0,h.useState)(null),F=s?.find(a=>a.id===t),G=!!t&&(q?.[t]?.isRunning??(F?p?.[F.cliTool]?.isRunning:void 0)??!1),H=(0,h.useCallback)((a,b)=>{a.dataTransfer.setData(bg,b),a.dataTransfer.effectAllowed="move",E(b),v?.(b)},[v]),I=(0,h.useCallback)(()=>{E(null),w?.()},[w]),J=c?r(c,50):null;return(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-surface border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("button",{type:"button",onClick:g,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":y("detail.goBack"),"data-testid":"worktree-back-button",children:[(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1h-2z"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:y("detail.home")})]}),(0,e.jsx)("div",{className:"w-px h-6 bg-border","aria-hidden":"true"}),(0,e.jsx)(o.m,{"data-testid":"desktop-status-indicator",status:d,size:"lg",label:B}),(0,e.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,e.jsx)("h1",{className:"text-lg font-semibold text-foreground truncate max-w-[200px] leading-tight",children:a}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"truncate max-w-[200px]",children:b}),f&&"(unknown)"!==f.currentBranch&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"/"}),(0,e.jsx)("span",{className:"truncate max-w-[150px] font-mono",title:f.currentBranch,"data-testid":"desktop-branch-name",children:r(f.currentBranch,30)}),f.isDirty&&(0,e.jsx)("span",{className:"text-warning",title:y("git.uncommittedChanges"),children:"*"})]}),J&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"—"}),(0,e.jsx)("span",{className:"truncate max-w-[300px] text-muted-foreground",title:c,children:J})]})]})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[s&&s.length>0&&(()=>{let a=(0,a$.Uw)(s.map(a=>({item:a,status:(0,bd.kA)(q?.[a.id]??p?.[a.cliTool]),isActive:a.id===t})),4),b=a.filter(a=>"overflow"===a.slot),c=b.find(a=>"running"===a.status||"generating"===a.status)?.status??b.find(a=>"waiting"===a.status)?.status??null;return(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0","data-testid":"desktop-agent-status-row",children:[a.map(a=>{if("overflow"===a.slot)return null;let b=a.item,c=y("detail.statusPill",{label:(0,be.sw)(b),status:z(`status.${a.status}`)}),d=a.isActive,f={draggable:!0,onDragStart:a=>H(a,b.id),onDragEnd:I},g=D===b.id?" opacity-50 cursor-grabbing":"";return"pill"===a.slot?(0,e.jsxs)("button",{type:"button","data-testid":`desktop-agent-status-${b.id}`,onClick:()=>u?.(b.id),...f,"aria-label":c,"aria-pressed":d,className:`flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${d?"bg-accent-100 dark:bg-accent-900/30 text-accent-900 dark:text-accent-100":"hover:bg-muted text-foreground"}${g}`,children:[(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0}),(0,e.jsx)("span",{className:"whitespace-nowrap",children:c})]},b.id):(0,e.jsx)(aY.m_,{content:c,placement:"bottom",children:(0,e.jsx)("button",{type:"button","data-testid":`desktop-agent-status-${b.id}`,onClick:()=>u?.(b.id),...f,"aria-label":c,"aria-pressed":d,className:`flex items-center justify-center w-6 h-6 rounded-full transition-colors ${d?"bg-accent-100 dark:bg-accent-900/30":"hover:bg-muted"}${g}`,children:(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0})})},b.id)}),b.length>0&&(0,e.jsxs)(aZ.rI,{children:[(0,e.jsx)(aZ.ty,{asChild:!0,children:(0,e.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-overflow","aria-label":y("agentStatus.moreAgents",{count:b.length}),className:"flex items-center gap-1 px-2 py-1 rounded text-xs tabular-nums text-muted-foreground hover:bg-muted transition-colors",children:[c&&(0,e.jsx)(o.m,{status:c,size:"sm","aria-hidden":!0,title:void 0}),"+",b.length]})}),(0,e.jsx)(aZ.SQ,{align:"end",children:b.map(a=>{let b=a.item,c=y("detail.statusPill",{label:(0,be.sw)(b),status:z(`status.${a.status}`)});return(0,e.jsxs)(aZ._2,{"data-testid":`desktop-agent-overflow-${b.id}`,onSelect:()=>u?.(b.id),children:[(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0}),(0,e.jsx)("span",{className:"whitespace-nowrap",children:c})]},b.id)})})]})]})})(),x&&G&&(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:x,className:"flex items-center gap-1 px-2 py-1.5 text-xs font-medium rounded-lg text-danger-foreground hover:bg-danger-subtle transition-colors flex-shrink-0","aria-label":y("terminal.endSession"),"data-testid":"desktop-kill-session",children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"✕"}),z("end")]}),m&&(0,e.jsx)("select",{value:l??"",onChange:a=>{let b=a.target.value;m(""===b?null:b)},onClick:a=>a.stopPropagation(),className:"text-xs px-2 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent cursor-pointer","data-testid":"desktop-status-dropdown","aria-label":y("detail.worktreeStatusLabel"),children:eI.map(a=>(0,e.jsx)("option",{value:a.value??"",children:y(a.labelKey)},a.labelKey))}),(0,e.jsx)(bi.g,{}),(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:i,className:"relative flex items-center gap-1.5 px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors","aria-label":y("detail.viewInfo"),children:[(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:y("detail.info")}),j&&(0,e.jsx)(C,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":y("tabs.updateAvailable")})]})]})]})}),eM=(0,h.memo)(function({worktreeId:a,worktree:b,isOpen:c,onClose:d,onWorktreeUpdate:f}){let[g,i]=(0,h.useState)(!1),j=(0,k.c)("worktree"),l=(0,h.useRef)(c),m=eJ(b,f,c,()=>{let a=c&&!l.current;return l.current=c,a});return b?(0,e.jsx)(bc.a,{isOpen:c,onClose:d,title:j("detail.infoModalTitle"),size:"md",children:(0,e.jsx)("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto","data-testid":"worktree-info-modal",children:(0,e.jsx)(eK,{worktreeId:a,worktree:b,cardClassName:"bg-muted rounded-lg p-4",descriptionEditor:m,showLogs:g,onToggleLogs:()=>i(!g),onWorktreeUpdate:f})})}):null}),eN=(0,h.memo)(function(){let a=(0,k.c)("worktree");return(0,e.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"status","aria-live":"polite",children:(0,e.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,e.jsx)(n.y$,{size:"xl",variant:"accent"}),(0,e.jsx)("p",{className:"text-muted-foreground",children:a("detail.loading")})]})})}),eO=(0,h.memo)(function({message:a,onRetry:b}){let c=(0,k.c)("worktree"),d=(0,k.c)("common");return(0,e.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"alert","aria-live":"assertive",children:(0,e.jsxs)("div",{className:"text-center p-6 bg-danger-subtle rounded-lg border border-danger-border max-w-md",children:[(0,e.jsx)("svg",{className:"mx-auto h-12 w-12 text-danger-foreground/70 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.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,e.jsx)("p",{className:"text-danger-foreground font-medium",children:c("detail.errorLoading")}),(0,e.jsx)("p",{className:"text-danger-foreground/80 text-sm mt-2",children:a}),b&&(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:b,className:"mt-4 px-4 py-2 bg-danger-foreground text-danger-subtle rounded-lg hover:opacity-90 transition-opacity focus:outline-none focus:ring-2 focus:ring-danger focus:ring-offset-2 ring-offset-background",children:d("retry")})]})})}),eP=(0,h.memo)(function({activityPane:a,rightPane:b,activityPaneWidth:c=18,minPaneWidth:d=10,maxPaneWidth:f=60,onActivityPaneResize:g,className:i=""}){let j=(0,h.useRef)(null),l=(0,k.c)("worktree"),[m,n]=(0,h.useState)(c),o=g?c:m,p=(0,h.useCallback)(a=>{let b=j.current;if(!b)return;let e=b.offsetWidth;if(0===e)return;let h=Math.min(f,Math.max(d,(g?c:m)+a/e*100));g?g(h):n(h)},[c,m,d,f,g]),q=(0,h.useMemo)(()=>`flex h-full min-h-0 ${i}`.trim(),[i]);return(0,e.jsx)("div",{ref:j,className:"h-full",children:(0,e.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:q,children:[null!==a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{id:"worktree-activity-pane","data-testid":"activity-pane-slot","aria-label":l("desktopLayout.activityPane"),style:{width:`${o}%`},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,e.jsx)(F,{componentName:"ActivityPane",children:a})}),(0,e.jsx)(ct,{onResize:p,orientation:"horizontal",ariaValueNow:o})]}),(0,e.jsx)("div",{id:"worktree-right-pane","data-testid":"right-pane-slot","aria-label":l("desktopLayout.terminalPane"),className:"flex-grow overflow-hidden min-w-0",children:(0,e.jsx)(F,{componentName:"TerminalPane",children:b})})]})})}),eQ=(0,x.A)("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),eR=(0,x.A)("file",[["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"}]]);var eS=c(57898);let eT=(0,x.A)("sticky-note",[["path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",key:"1dfntj"}],["path",{d:"M15 3v5a1 1 0 0 0 1 1h5",key:"6s6qgf"}]]),eU=(0,x.A)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);var eV=c(55056);let eW=(0,x.A)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),eX=(0,x.A)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),eY=[{id:"files",labelKey:"activityBar.files",icon:eR},{id:"git",labelKey:"activityBar.git",icon:eS.A},{id:"notes",labelKey:"activityBar.notes",icon:eT},{id:"schedules",labelKey:"activityBar.schedules",icon:eU},{id:"agent",labelKey:"activityBar.agent",icon:eV.A},{id:"timer",labelKey:"activityBar.timer",icon:eW},{id:"todo",labelKey:"activityBar.todo",icon:eX},{id:"skills",labelKey:"activityBar.skills",icon:de.A}];eY.map(a=>a.id);var eZ=c(81092);let e$=(0,h.memo)(function({active:a,onToggle:b,className:c=""}){let d=(0,k.c)("worktree"),f=(0,h.useRef)([]),{isOpen:g,toggle:i}=(0,eZ.VF)(),j=(0,h.useCallback)((a,c,d)=>{if("Enter"===a.key||" "===a.key){a.preventDefault(),b(d);return}if("ArrowDown"===a.key){a.preventDefault();let b=(c+1)%eY.length;f.current[b]?.focus();return}if("ArrowUp"===a.key){a.preventDefault();let b=(c-1+eY.length)%eY.length;f.current[b]?.focus();return}if("Home"===a.key){a.preventDefault(),f.current[0]?.focus();return}if("End"===a.key){a.preventDefault(),f.current[eY.length-1]?.focus();return}},[b]);return(0,e.jsxs)("div",{"data-testid":"activity-bar",className:`flex flex-col items-stretch w-12 flex-shrink-0 bg-muted border-r border-border ${c}`.trim(),children:[(0,e.jsx)(aY.m_,{content:d("activityBar.toggleSidebar"),placement:"right",children:(0,e.jsx)("button",{type:"button","data-testid":"activity-bar-toggle-sidebar",onClick:i,"aria-label":d("activityBar.toggleSidebar"),"aria-expanded":g,className:"flex items-center justify-center h-12 w-12 text-muted-foreground transition-colors hover:text-surface-foreground hover:bg-muted-foreground/10 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,e.jsx)(eQ,{size:20,"aria-hidden":"true"})})}),(0,e.jsx)("div",{className:"mx-2 my-1 border-b border-border","aria-hidden":"true"}),(0,e.jsx)("div",{id:"worktree-activity-bar",role:"tablist","aria-orientation":"vertical","aria-label":d("activityBar.label"),className:"flex flex-col items-stretch",children:eY.map((c,g)=>{let h=c.icon,i=a===c.id,k=d(c.labelKey);return(0,e.jsx)(aY.m_,{content:k,placement:"right",children:(0,e.jsx)("button",{ref:a=>{f.current[g]=a},type:"button",role:"tab","aria-selected":i,"aria-label":k,"aria-controls":"worktree-activity-pane",tabIndex:i||null===a&&0===g?0:-1,onClick:()=>b(c.id),onKeyDown:a=>j(a,g,c.id),"data-testid":`activity-bar-button-${c.id}`,className:"group flex items-center justify-center h-12 w-12 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,e.jsx)("span",{"aria-hidden":"true",className:`flex items-center justify-center h-9 w-9 rounded-md transition-colors ${i?"bg-accent-500/10 text-accent-600 dark:text-accent-400":"text-muted-foreground group-hover:text-surface-foreground group-hover:bg-muted-foreground/10"}`,children:(0,e.jsx)(h,{size:20,"aria-hidden":"true"})})})},c.id)})})]})}),e_="worktree-activity-pane",e0={files:"FileTreeView",git:"GitPane",notes:"MemoPane",schedules:"ExecutionLogPane",agent:"AgentSettingsPane",timer:"TimerPane",todo:"TodoPane",skills:"WorktreeSkillsPane"},e1=(0,h.memo)(function({active:a,activities:b,className:c=""}){if(null===a)return(0,e.jsx)("div",{id:e_,"data-testid":"activity-pane","data-active":"none",className:`h-full flex flex-col ${c}`.trim()});let d=b[a],f=e0[a];return(0,e.jsx)("div",{id:e_,"data-testid":"activity-pane","data-active":a,role:"tabpanel","aria-labelledby":`activity-bar-button-${a}`,className:`h-full flex flex-col min-h-0 ${c}`.trim(),children:(0,e.jsx)(F,{componentName:f,children:d??null})})}),e2=(0,h.memo)(function({inputRef:a,searchQuery:b,onQueryChange:c,matchCount:d,currentIdx:f,onNextMatch:g,onPrevMatch:h,onClose:i}){let j=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border-b border-input flex-shrink-0",children:[(0,e.jsx)("input",{ref:a,type:"text",value:b,onChange:a=>c(a.target.value),onKeyDown:a=>{"Escape"===a.key&&i(),"Enter"===a.key&&(a.shiftKey?h():g())},placeholder:j("fileSearch.placeholder"),className:"flex-1 min-w-0 px-2 py-0.5 text-sm bg-surface dark:text-foreground border border-input rounded outline-none focus:ring-1 focus:ring-ring",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground min-w-[3rem] text-right",children:d>0?`${f+1}/${d}`:"0/0"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:h,disabled:0===d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":j("fileSearch.prevMatch"),children:"▲"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:g,disabled:0===d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":j("fileSearch.nextMatch"),children:"▼"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:i,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white","aria-label":j("fileSearch.close"),children:(0,e.jsx)(az.A,{className:"w-4 h-4"})})]})}),e3=[{extension:".png",maxFileSize:0x1400000,allowedMimeTypes:["image/png"],magicBytes:[{bytes:[137,80,78,71,13,10,26,10]}]},{extension:".jpg",maxFileSize:0x1400000,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".jpeg",maxFileSize:0x1400000,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".gif",maxFileSize:0x1400000,allowedMimeTypes:["image/gif"],magicBytes:[{bytes:[71,73,70,56,55,97]},{bytes:[71,73,70,56,57,97]}]},{extension:".webp",maxFileSize:0x1400000,allowedMimeTypes:["image/webp"],magicBytes:[{bytes:[82,73,70,70],offset:0}]},{extension:".mp4",maxFileSize:0x6400000,allowedMimeTypes:["video/mp4"],magicBytes:[{bytes:[102,116,121,112],offset:4}]},{extension:".txt",maxFileSize:0x1400000,allowedMimeTypes:["text/plain"]},{extension:".log",maxFileSize:0x1400000,allowedMimeTypes:["text/plain"]},{extension:".md",maxFileSize:0x1400000,allowedMimeTypes:["text/markdown","text/plain"]},{extension:".csv",maxFileSize:0x1400000,allowedMimeTypes:["text/csv"]},{extension:".json",maxFileSize:0x1400000,allowedMimeTypes:["application/json"]},{extension:".yaml",maxFileSize:0x1400000,allowedMimeTypes:["text/yaml","application/x-yaml"]},{extension:".yml",maxFileSize:0x1400000,allowedMimeTypes:["text/yaml","application/x-yaml"]}],e4=e3.map(a=>a.extension),e5=[".md",".html",".htm",".yaml",".yml"];var e6=c(79689);function e7(){return(0,e.jsx)("div",{className:"flex items-center justify-center py-12 bg-surface",children:(0,e.jsx)(m.y,{size:"xl",variant:"accent"})})}let e8=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/HtmlPreview"]},ssr:!1,loading:()=>(0,e.jsx)(e7,{})}),e9=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/PdfPreview"]},ssr:!1,loading:()=>(0,e.jsx)(e7,{})}),fa=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/MarkdownEditor"]},ssr:!1,loading:()=>(0,e.jsx)(e7,{})}),fb=/^---\s*\nmarp:\s*true/;function fc(){let a=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,e.jsx)(m.y,{size:"xl",variant:"accent"}),(0,e.jsx)("p",{className:"ml-3 text-muted-foreground",children:a("fileViewer.loading")})]})}function fd({error:a}){return(0,e.jsx)("div",{className:"bg-danger-subtle border border-danger-border rounded-lg p-4 m-4",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-5 h-5 text-danger-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("p",{className:"text-sm text-danger-foreground",children:a})]})})}function fe({filePath:a,isMaximized:b,onToggleMaximize:c,copyableContent:d,onSearch:f}){let g=(0,k.c)("worktree"),[i,j]=(0,h.useState)(!1),[l,m]=(0,h.useState)(!1),n=(0,h.useRef)(null),o=(0,h.useRef)(null),p=async()=>{try{await (0,ay.l)(a),j(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>j(!1),ah.pX)}catch{}},q=async()=>{if(d)try{await (0,ay.l)(d),m(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>m(!1),ah.pX)}catch{}};return(0,e.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border gap-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("button",{type:"button",onClick:p,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.copyFilePath"),title:g("actions.copyPath"),children:i?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",title:a,children:a})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[f&&(0,e.jsx)("button",{type:"button",onClick:f,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.searchInFile"),title:g("actions.search"),children:(0,e.jsx)(Q.A,{className:"w-3.5 h-3.5"})}),d&&(0,e.jsx)("button",{type:"button",onClick:q,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.copyFileContent"),title:g("actions.copyContent"),children:l?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(as,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{type:"button",onClick:c,className:"flex-shrink-0 p-1.5 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g(b?"actions.minimize":"actions.maximize"),title:g(b?"actions.minimize":"actions.maximize"),children:b?(0,e.jsx)(aA,{className:"w-4 h-4"}):(0,e.jsx)(aB,{className:"w-4 h-4"})})]})]})}function ff({content:a,extension:b,searchMatches:c,searchCurrentIdx:d,totalLines:f,rangeStart:g,worktreeId:i,filePath:j,onLineRangeFetched:k}){let l=(0,h.useRef)(null),m=(0,h.useMemo)(()=>a.split("\n"),[a]),n=Math.max(1,g??1),o=m.length,p=Math.max(f??o,o),q=(0,h.useRef)(new Map),r=(0,h.useCallback)(a=>{let c=Math.floor(a/500),d=q.current,e=d.get(c);if(!e){let a=500*c,f=Math.min(a+500,m.length),g=m.slice(a,f).join("\n"),h="";try{h=aO.highlight(g,{language:b,ignoreIllegals:!0}).value}catch{h=aO.highlightAuto(g).value}e=h.split("\n"),d.set(c,e)}return e[a-500*c]??""},[m,b]),s=(0,h.useMemo)(()=>new Set(c??[]),[c]),t=(c?.length??0)>0?c[d??0]:-1,u=bU({count:p,getScrollElement:()=>l.current,estimateSize:()=>24,overscan:100}),v=u.getVirtualItems();return!function({virtualItems:a,worktreeId:b,filePath:c,onLineRangeFetched:d,loadedStart:e,loadedLineCount:f}){(0,h.useRef)(new Set)}({virtualItems:v,worktreeId:i,filePath:j,onLineRangeFetched:k,loadedStart:n,loadedLineCount:o}),(0,e.jsx)("div",{className:"overflow-auto h-full",ref:l,"data-testid":"file-content-code",children:(0,e.jsx)("div",{style:{height:u.getTotalSize(),width:"100%",position:"relative"},children:v.map(a=>{let b=a.index+1,c=b-n,d=c>=0&&c<o,f=b===t,g=s.has(b),h=d?r(c):"";return(0,e.jsxs)("div",{"data-line":b,"data-index":a.index,ref:u.measureElement,className:`absolute left-0 right-0 flex font-mono text-sm ${f?"bg-warning/30":g?"bg-warning/15":""}`,style:{top:0,transform:`translateY(${a.start}px)`,height:"24px",lineHeight:"24px"},children:[(0,e.jsx)("div",{className:`px-3 text-right select-none border-r border-border bg-muted dark:bg-muted/50 whitespace-nowrap ${f||g?"text-warning-foreground":"text-muted-foreground"}`,style:{minWidth:"4rem"},children:b}),(0,e.jsx)("div",{className:"px-4 text-foreground flex-1 min-w-0 overflow-hidden",children:d?(0,e.jsx)("code",{className:"hljs",style:{padding:0,background:"transparent",whiteSpace:"pre"},dangerouslySetInnerHTML:{__html:h}}):(0,e.jsx)(e6.E,{className:"h-4 w-3/4"})})]},a.key)})})})}function fg({slides:a,fileName:b}){let c=(0,k.c)("worktree"),[d,f]=(0,h.useState)(0);return 0===a.length?(0,e.jsx)("div",{className:"p-4 text-muted-foreground",children:c("fileViewer.noSlides",{fileName:b})}):(0,e.jsxs)("div",{className:"h-full flex flex-col","data-testid":"marp-preview",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border bg-muted",children:[(0,e.jsx)("button",{type:"button",onClick:()=>{f(a=>Math.max(0,a-1))},disabled:0===d,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:c("actions.prev")}),(0,e.jsxs)("span",{className:"text-sm text-muted-foreground",children:[d+1," / ",a.length]}),(0,e.jsx)("button",{type:"button",onClick:()=>{f(b=>Math.min(a.length-1,b+1))},disabled:d===a.length-1,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:c("actions.next")})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,e.jsx)("iframe",{srcDoc:a[d],sandbox:"",title:c("fileViewer.slideTitle",{name:b,number:d+1}),className:"w-full h-full border-0"})})]})}function fh({marpSlides:a,fileName:b,worktreeId:c,filePath:d,contentText:f,onFileSaved:g,isMaximized:i,onToggleMaximize:j,onDirtyChange:l,onOpenFile:m}){let n=(0,k.c)("worktree"),[o,p]=(0,h.useState)("slides");return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border bg-muted",children:[(0,e.jsxs)("div",{className:"flex gap-1",children:[(0,e.jsx)("button",{type:"button",onClick:()=>p("slides"),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${"slides"===o?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"}`,children:n("fileViewer.slides")}),(0,e.jsx)("button",{type:"button",onClick:()=>p("editor"),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${"editor"===o?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"}`,children:n("fileViewer.editor")})]}),(0,e.jsx)(fe,{filePath:d,isMaximized:i,onToggleMaximize:j,copyableContent:f})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:"slides"===o?(0,e.jsx)(fg,{slides:a,fileName:b}):(0,e.jsx)(fa,{worktreeId:c,filePath:d,onSave:g,initialViewMode:"split",onDirtyChange:l,onOpenFile:m})})]})}function fi({children:a,isMaximized:b,onToggle:c,filePath:d}){return b?(0,e.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:aE.M.MAXIMIZED_EDITOR},children:[(0,e.jsx)(fe,{filePath:d,isMaximized:b,onToggleMaximize:c}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:a})]}):(0,e.jsx)(e.Fragment,{children:a})}function fj({tab:a,content:b,worktreeId:c,isMaximized:d,onToggleMaximize:f,onFileSaved:g,onDirtyChange:h,onOpenFile:i}){let j=aN(b.content);return(0,e.jsxs)(e.Fragment,{children:[!d&&(0,e.jsx)(fe,{filePath:a.path,isMaximized:d,onToggleMaximize:f,copyableContent:b.content,onSearch:j.openSearch}),j.searchOpen&&(0,e.jsx)(e2,{inputRef:j.searchInputRef,searchQuery:j.searchQuery,onQueryChange:j.setSearchQuery,matchCount:j.searchMatches.length,currentIdx:j.searchCurrentIdx,onNextMatch:j.nextMatch,onPrevMatch:j.prevMatch,onClose:j.closeSearch}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:j.searchOpen&&j.searchQuery.length>=2?(0,e.jsx)(ff,{content:b.content,extension:"md",searchMatches:j.searchMatches,searchCurrentIdx:j.searchCurrentIdx}):(0,e.jsx)(fa,{worktreeId:c,filePath:a.path,onSave:g,initialViewMode:"preview",onDirtyChange:h,onOpenFile:i})})]})}function fk({tab:a,content:b,worktreeId:c,isMaximized:d,onToggleMaximize:f,onLoadContent:g}){let i=aN(b.content),j=(0,h.useCallback)(c=>{g&&g(a.path,{...b,content:c.content,totalLines:c.totalLines,totalBytes:c.totalBytes??b.totalBytes,range:c.range})},[g,a.path,b]),k=void 0!==b.range&&(b.totalLines??0)>b.range.end-b.range.start+1;return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fe,{filePath:a.path,isMaximized:d,onToggleMaximize:f,copyableContent:b.content,onSearch:i.openSearch}),i.searchOpen&&(0,e.jsx)(e2,{inputRef:i.searchInputRef,searchQuery:i.searchQuery,onQueryChange:i.setSearchQuery,matchCount:i.searchMatches.length,currentIdx:i.searchCurrentIdx,onNextMatch:i.nextMatch,onPrevMatch:i.prevMatch,onClose:i.closeSearch}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(ff,{content:b.content,extension:b.extension,searchMatches:i.searchOpen?i.searchMatches:void 0,searchCurrentIdx:i.searchOpen?i.searchCurrentIdx:void 0,totalLines:b.totalLines,rangeStart:b.range?.start,worktreeId:k?c:void 0,filePath:k?a.path:void 0,onLineRangeFetched:k?j:void 0})})]})}let fl=(0,h.memo)(function({tab:a,worktreeId:b,onLoadContent:c,onLoadError:d,onSetLoading:f,onFileSaved:g,onDirtyChange:i,onOpenFile:j}){let l=(0,k.c)("worktree"),m=(0,h.useRef)(l);m.current=l;let n=(0,h.useRef)(!1),[o,p]=(0,h.useState)(null),[q,r]=(0,h.useState)(!1);!function({tab:a,worktreeId:b,onLoadContent:c}){let d=(0,h.useRef)(null),e=(0,h.useRef)(c);e.current=c;let f=(0,h.useRef)(a.path);f.current=a.path,cY({intervalMs:5e3,enabled:function(a){if(null===a.content||a.loading||a.isDirty||a.content.isPdf)return!1;let{totalBytes:b}=a.content;return void 0===b||!(b>=1048576)}(a),onPoll:async()=>{let a=`/api/worktrees/${b}/files/${(0,aF.o)(f.current)}`,c={};d.current&&(c["If-Modified-Since"]=d.current);try{let b=await fetch(a,{headers:c});if(304===b.status||!b.ok)return;d.current=b.headers.get("Last-Modified");let g=await b.json();e.current(f.current,g)}catch{}}})}({tab:a,worktreeId:b,onLoadContent:c});let s=(0,h.useMemo)(()=>i?b=>i(a.path,b):void 0,[i,a.path]),t=(0,h.useCallback)(()=>{r(a=>!a)},[]);(0,h.useEffect)(()=>{if(!q)return;let a=a=>{"Escape"===a.key&&r(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[q]),(0,h.useEffect)(()=>{null!==a.content||a.loading||null!==a.error||n.current||(n.current=!0,f(a.path,!0),(async()=>{try{let e=await fetch(`/api/worktrees/${b}/files/${(0,aF.o)(a.path)}`);if(304===e.status)return;if(!e.ok){let b=await e.json(),c="string"==typeof b.error?b.error:b.error?.message||m.current("fileViewer.loadError");d(a.path,c);return}let f=await e.json();c(a.path,f)}catch(b){d(a.path,b instanceof Error?b.message:m.current("fileViewer.loadError"))}finally{n.current=!1}})())},[a.content,a.loading,a.error,a.path,b,c,d,f]);let u=a.content?.content??null,v=a.content?.extension??null;if((0,h.useEffect)(()=>{if(!u||"md"!==v||!fb.test(u)||u.length>1e6)return void p(null);let a=!1;return(async()=>{try{let c=await fetch(`/api/worktrees/${b}/marp-render`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:u})});if(c.ok){let b=await c.json();a||p(Array.isArray(b.slides)?b.slides:null)}}catch{}})(),()=>{a=!0}},[u,v,b]),a.loading)return(0,e.jsx)(fc,{});if(a.error)return(0,e.jsx)(fd,{error:a.error});if(!a.content)return null;let{content:w}=a;return w.isImage?(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fe,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsx)(an.a,{src:w.content,alt:w.path,mimeType:w.mimeType})})]})}):w.isVideo?(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fe,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsx)(ao.u,{src:w.content,mimeType:w.mimeType})})]})}):w.isPdf?(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fe,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(e9,{dataUri:w.content,filePath:a.path})})]})}):w.isHtml?(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fe,{filePath:a.path,isMaximized:q,onToggleMaximize:t,copyableContent:w.content}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(e8,{worktreeId:b,filePath:a.path,htmlContent:w.content,onFileSaved:g,onOpenFile:j})})]})}):"md"===w.extension?(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)("div",{className:"h-full flex flex-col",children:o?(0,e.jsx)(fh,{marpSlides:o,fileName:a.name,worktreeId:b,filePath:a.path,contentText:w.content,onFileSaved:g,isMaximized:q,onToggleMaximize:t,onDirtyChange:s,onOpenFile:j}):(0,e.jsx)(fj,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onFileSaved:g,onDirtyChange:s,onOpenFile:j})})}):!function(a){if(!a)return!1;let b=a.toLowerCase();return e5.includes(b)}("."+w.extension)?(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)(fk,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onLoadContent:c})}):(0,e.jsx)(fi,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)("div",{className:"h-full flex flex-col",children:(0,e.jsx)(fj,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onFileSaved:g,onDirtyChange:s,onOpenFile:j})})})});function fm(a,b,c){if(b<=0||c<=0)return 0;let d=a+b+8-c;return d>0?-Math.min(d,Math.max(0,a-8)):a<8?8-a:0}let fn=(0,h.memo)(function({tab:a,isActive:b,onActivate:c,onClose:d}){let f=(0,k.c)("worktree"),g=(0,h.useCallback)(()=>{b||c(a.path)},[b,c,a.path]),i=(0,h.useCallback)(b=>{b.stopPropagation(),d(a.path)},[d,a.path]),j=b?"border-accent-500 text-accent-600 dark:text-accent-400 bg-surface":"border-transparent text-muted-foreground hover:text-foreground";return(0,e.jsxs)("div",{"data-testid":`file-tab-${a.path}`,"data-active":b,onClick:g,className:`flex items-center gap-1 px-3 py-2 text-sm font-medium border-b-2 cursor-pointer flex-shrink-0 ${j}`,children:[(0,e.jsx)("span",{className:"truncate max-w-[120px]",title:a.path,children:a.name}),a.isDirty&&(0,e.jsx)("span",{"data-testid":`file-tab-dirty-${a.path}`,className:"w-2 h-2 rounded-full bg-warning flex-shrink-0",title:f("fileTabs.unsavedChanges")}),(0,e.jsx)("button",{type:"button",onClick:i,className:"ml-1 p-0.5 rounded-sm hover:bg-muted transition-colors","aria-label":f("fileTabs.closeTab",{name:a.name}),children:(0,e.jsx)(az.A,{className:"w-3 h-3"})})]})}),fo=(0,h.memo)(function({tabs:a,activeIndex:b,worktreeId:c,onClose:d,onActivate:f,onLoadContent:g,onLoadError:i,onSetLoading:j,onFileSaved:k,onDirtyChange:l,onMoveToFront:m,onOpenFile:n}){let[o,p]=(0,h.useState)(!1),q=(0,h.useRef)(null),r=(0,h.useRef)(null),s=(0,h.useRef)({x:0,y:0}),[t,u]=(0,h.useState)({x:0,y:0}),v=null!==b&&b>=0&&b<a.length?a[b]:null,w=a.length>5?a.slice(0,5):a,x=a.length>5?a.slice(5):[];(0,h.useEffect)(()=>{if(!o)return;let a=a=>{q.current&&!q.current.contains(a.target)&&p(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[o]),(0,h.useLayoutEffect)(()=>{let a=a=>{s.current=a,u(b=>b.x===a.x&&b.y===a.y?b:a)};if(!o)return void a({x:0,y:0});let b=r.current;if(!b)return;let c=b.getBoundingClientRect();a({x:fm(c.left-s.current.x,c.width,window.innerWidth),y:fm(c.top-s.current.y,c.height,window.innerHeight)})},[o]);let y=(0,h.useCallback)(a=>{p(!1),m?.(a)},[m]),z=(0,h.useCallback)(()=>{p(a=>!a)},[]);return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex border-b border-border bg-surface dark:bg-surface-2 min-w-0",children:[(0,e.jsx)("div",{className:"flex min-w-0 overflow-hidden flex-1",children:w.map((a,c)=>(0,e.jsx)(fn,{tab:a,isActive:c===b,onActivate:f,onClose:d},a.path))}),x.length>0&&(0,e.jsxs)("div",{className:"relative flex-shrink-0",ref:q,children:[(0,e.jsxs)("button",{type:"button","data-testid":"tab-dropdown-button",onClick:z,className:"flex items-center gap-0.5 px-2 py-2 text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-muted border-b-2 border-transparent transition-colors",children:[(0,e.jsx)(bf.A,{className:`w-3 h-3 transition-transform ${o?"rotate-180":""}`}),(0,e.jsxs)("span",{children:["+",x.length]})]}),o&&(0,e.jsx)("div",{ref:r,"data-testid":"tab-dropdown-menu",className:"absolute right-0 top-full mt-1 bg-surface border border-border rounded-md shadow-lg z-50 min-w-[200px] max-h-[300px] overflow-y-auto",style:0!==t.x||0!==t.y?{transform:`translate(${t.x}px, ${t.y}px)`}:void 0,children:x.map(a=>(0,e.jsxs)("button",{type:"button","data-testid":`tab-dropdown-item-${a.path}`,onClick:()=>y(a.path),className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-muted truncate",title:a.path,children:[a.name,a.isDirty&&(0,e.jsx)("span",{className:"ml-1 w-2 h-2 inline-block rounded-full bg-warning"})]},a.path))})]})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:v&&(0,e.jsx)(fl,{tab:v,worktreeId:c,onLoadContent:g,onLoadError:i,onSetLoading:j,onFileSaved:k,onDirtyChange:l,onOpenFile:n},v.path)})]})}),fp=(0,h.memo)(function({line:a}){let b="whitespace-pre font-mono text-xs leading-5";return a.startsWith("+")&&!a.startsWith("+++")?b+=" text-success-foreground bg-success-subtle":a.startsWith("-")&&!a.startsWith("---")?b+=" text-danger-foreground bg-danger-subtle":a.startsWith("@@")?b+=" text-info bg-info/10":a.startsWith("diff --git")||a.startsWith("index ")||a.startsWith("---")||a.startsWith("+++")?b+=" text-muted-foreground":b+=" text-foreground",(0,e.jsx)("div",{className:b,children:a})}),fq=(0,h.memo)(function({diff:a,filePath:b,onClose:c}){let d=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"h-full flex flex-col bg-surface",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-muted shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-accent-600 dark:text-accent-400 shrink-0",children:d("diffViewer.badge")}),(0,e.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:b})]}),(0,e.jsx)("button",{type:"button",onClick:c,className:"p-1 text-muted-foreground hover:text-foreground rounded shrink-0","aria-label":d("diffViewer.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",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-2",children:(0,e.jsx)("pre",{className:"text-xs",children:(0,e.jsx)("code",{children:a.split("\n").map((a,b)=>(0,e.jsx)(fp,{line:a},b))})})})]})});function fr(){let[a,b]=(0,h.useState)(!1),c=(0,h.useRef)(a);c.current=a;let d=(0,h.useCallback)(a=>{b(a)},[]);return{collapsed:a,toggle:(0,h.useCallback)(()=>{d(!c.current)},[d]),setCollapsed:d}}let fs=(0,h.memo)(function({terminal:a,terminalHeader:b,fileTabs:c,worktreeId:d,onCloseTab:f,onActivateTab:g,onLoadContent:i,onLoadError:j,onSetLoading:l,onFileSaved:m,diffContent:n,diffFilePath:o,onCloseDiff:p,onDirtyChange:q,onMoveToFront:r,onOpenFile:s}){let t=(0,k.c)("worktree"),u=(0,h.useRef)(null),[v,w]=(0,h.useState)(50),{collapsed:x,toggle:y}=fr(),z=(0,h.useCallback)(a=>{let b=u.current;if(!b)return;let c=b.offsetWidth;if(0===c)return;let d=a/c*100;w(a=>Math.min(80,Math.max(20,a+d)))},[]),A=(0,h.useMemo)(()=>({width:`${v}%`}),[v]),B=(0,h.useMemo)(()=>({width:`${100-v}%`}),[v]),C=(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[b,(0,e.jsx)("div",{className:"flex-1 min-h-0",children:a})]});return c.tabs.length>0||n&&o?x?(0,e.jsxs)("div",{ref:u,className:"flex h-full min-h-0",children:[(0,e.jsx)("div",{"data-testid":"terminal-pane",style:{width:"calc(100% - 36px)"},className:"flex-shrink-0 overflow-hidden",children:C}),(0,e.jsx)("div",{"data-testid":"file-panel-expand-bar",style:{width:"36px"},className:"flex-shrink-0 flex items-start justify-center bg-muted border-l border-border",children:(0,e.jsxs)("button",{type:"button","aria-label":t("terminal.showFiles"),title:t("terminal.showFiles"),onClick:y,className:"flex flex-col items-center gap-2 w-full pt-2 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,e.jsx)("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),(0,e.jsx)("span",{className:"text-xs font-medium tracking-wide select-none",style:{writingMode:"vertical-rl"},"aria-hidden":"true",children:t("terminal.filesLabel")})]})})]}):(0,e.jsxs)("div",{ref:u,className:"flex h-full min-h-0",children:[(0,e.jsx)("div",{"data-testid":"terminal-pane",style:A,className:"flex-shrink-0 overflow-hidden",children:C}),(0,e.jsx)(ct,{onResize:z,orientation:"horizontal",ariaValueNow:v}),(0,e.jsxs)("div",{"data-testid":"file-panel-pane",style:B,className:"flex-grow overflow-hidden flex",children:[(0,e.jsx)("button",{type:"button","aria-label":t("terminal.hideFiles"),title:t("terminal.hideFiles"),onClick:y,className:"flex-shrink-0 flex items-center justify-center w-5 h-full bg-muted border-r border-border text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),(0,e.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:n&&o&&p?(0,e.jsx)(fq,{diff:n,filePath:o,onClose:p}):(0,e.jsx)(fo,{tabs:c.tabs,activeIndex:c.activeIndex,worktreeId:d,onClose:f,onActivate:g,onLoadContent:i,onLoadError:j,onSetLoading:l,onFileSaved:m,onDirtyChange:q,onMoveToFront:r,onOpenFile:s})})]})]}):(0,e.jsx)("div",{className:"h-full",children:C})});var ft=c(51881);let fu=(0,x.A)("align-horizontal-distribute-center",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]]),fv=(0,x.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"}]]),fw=(0,x.A)("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),fx={splits:[{cliToolId:"claude",instanceId:"claude"}],widths:[1]};be.XH;function fy(a){let b=a.reduce((a,b)=>a+b,0);return b>0?a.map(a=>a/b):a.map(()=>1/a.length)}let fz=(0,h.memo)(function({worktreeId:a,instances:b,rosterReady:c=!0,renderPane:d,onFocusedSplitChange:f,showToast:g,onActiveInstanceChange:j,headerInstanceSelection:l}){let{splits:m,widths:n,addSplit:o,removeSplit:p,setSplitInstance:q,setSplitWidth:r,resetWidths:s,availableInstanceIds:t,focusedSplitIndex:u,setFocusedSplitIndex:v}=function(a,b,c=!0){let[d,e]=(0,h.useState)(()=>(function(a,b,c){let d=function(a,b){let c=b[0];return c?{splits:[{cliToolId:c.cliTool,instanceId:c.id}],widths:[1]}:{splits:fx.splits.map(a=>({...a})),widths:[...fx.widths]}}(0,b);return c?function(a,b){let c;if(0===b.length)return a;let d=new Map(b.map(a=>[a.id,a.cliTool])),e=new Set,f=Math.min(Math.max(a.splits.length,1),b.length,3),g=[];for(let b of a.splits){if(g.length>=f)break;let a=d.get(b.instanceId);a&&!e.has(b.instanceId)&&(e.add(b.instanceId),g.push({cliToolId:a,instanceId:b.instanceId}))}for(let a of b){if(g.length>=f)break;e.has(a.id)||(e.add(a.id),g.push({cliToolId:a.cliTool,instanceId:a.id}))}return(0===g.length&&g.push({cliToolId:b[0].cliTool,instanceId:b[0].id}),g.length===a.splits.length&&g.every((b,c)=>b.instanceId===a.splits[c].instanceId&&b.cliToolId===a.splits[c].cliToolId))?a:(c=g.length===a.widths.length?fy(a.widths):g.length<a.widths.length?fy(a.widths.slice(0,g.length)):Array.from({length:g.length},()=>1/g.length),{splits:g,widths:c})}(d,b):d})(0,b,c)),[f,g]=(0,h.useState)(0),i=(0,h.useRef)(d);i.current=d;let j=(0,h.useRef)(b);j.current=b,(0,h.useRef)(c).current=c,(0,h.useRef)(a),(0,h.useMemo)(()=>b.map(a=>`${a.id}:${a.cliTool}`).join("|"),[b]),(0,h.useRef)(a);let k=(0,h.useCallback)(()=>{e(a=>{if(a.splits.length>=3)return a;let b=new Set(a.splits.map(a=>a.instanceId)),c=function(a,b){for(let c of a)if(!b.has(c.id))return c;return null}(j.current,b);if(!c)return a;let d=a.widths.length-1,e=a.widths[d]/2,f=[...a.widths];return f[d]=e,f.push(e),{splits:[...a.splits,{cliToolId:c.cliTool,instanceId:c.id}],widths:f}})},[]),l=(0,h.useCallback)(()=>{e(a=>a.splits.length<=1?a:{splits:a.splits.slice(0,-1),widths:fy(a.widths.slice(0,-1))})},[]),m=(0,h.useCallback)((a,b)=>{let c=i.current,d=j.current;if(a<0||a>=c.splits.length)return!1;let f=d.find(a=>a.id===b);if(!f||c.splits[a].instanceId===b)return!1;for(let d=0;d<c.splits.length;d++)if(d!==a&&c.splits[d].instanceId===b)return!1;return e(c=>{if(a<0||a>=c.splits.length||c.splits[a].instanceId===b)return c;for(let d=0;d<c.splits.length;d++)if(d!==a&&c.splits[d].instanceId===b)return c;let d=c.splits.map((c,d)=>d===a?{cliToolId:f.cliTool,instanceId:b}:c);return{...c,splits:d}}),!0},[]),n=(0,h.useCallback)(a=>{e(b=>a.length!==b.widths.length||!function(a){if(!Array.isArray(a))return!1;for(let b of a)if("number"!=typeof b||!Number.isFinite(b)||b<=0)return!1;return!0}(a)?b:{...b,widths:[...a]})},[]),o=(0,h.useCallback)(()=>{e(a=>{let b=a.splits.length;return 0===b?a:{...a,widths:Array.from({length:b},()=>1/b)}})},[]),p=(0,h.useCallback)(a=>{let c=new Set;for(let b=0;b<d.splits.length;b++)b!==a&&c.add(d.splits[b].instanceId);return b.filter(a=>!c.has(a.id)).map(a=>a.id)},[d.splits,b]),q=(0,h.useCallback)(a=>{g(a)},[]);return{splits:d.splits,widths:d.widths,addSplit:k,removeSplit:l,setSplitInstance:m,setSplitWidth:n,resetWidths:o,availableInstanceIds:p,focusedSplitIndex:f,setFocusedSplitIndex:q}}(a,b,c),w=(0,h.useMemo)(()=>{let a=new Map;for(let c of b)a.set(c.id,c);return a},[b]),x=(0,k.c)("worktree"),{visible:y,toggle:z,setWidth:A}=co(),{collapsed:B,toggle:C}=fr(),D=!B,E=(0,h.useRef)(null),[F,G]=(0,h.useState)(!1),H=(0,h.useRef)(m.length),[I,J]=(0,h.useState)(null);(0,h.useEffect)(()=>{m.length>H.current&&J(m.length-1),H.current=m.length},[m.length]),(0,h.useEffect)(()=>{f?.(u)},[u,f]);let K=(0,h.useRef)(0),L=(0,h.useRef)(m);L.current=m,(0,h.useEffect)(()=>{if(!l||l.token===K.current)return;K.current=l.token;let{instanceId:a}=l,b=L.current.findIndex(b=>b.instanceId===a);if(0!==b){if(b>0)return void v(b);q(0,a)&&v(0)}},[l,q,v]),(0,h.useEffect)(()=>{if(null===I)return;let a=E.current;if(!a)return;let b=a.querySelector(`[data-split-index="${I}"]`);if(!b)return;let c=b.querySelector("textarea");c?.focus(),v(I),J(null)},[I,v]);let M=(0,h.useCallback)((a,b)=>{let c=E.current;if(!c)return;let d=c.offsetWidth;if(0===d)return;let e=n.reduce((a,b)=>a+b,0),f=b/d*e,g=[...n],h=g[a]+f,i=g[a+1]-f,j=.05*e;h<j||i<j||(g[a]=h,g[a+1]=i,r(g))},[n,r]),N=(0,h.useCallback)(()=>G(!0),[]),O=(0,h.useCallback)(()=>G(!1),[]),P=(0,h.useCallback)(()=>{s(),A(40)},[s,A]),Q=m.length<3&&!F,R=m.length>1&&!F,S=m.length>1||y,T=(0,h.useMemo)(()=>m.map((a,b)=>()=>v(b)),[m,v]),U=(0,h.useMemo)(()=>m.map((a,b)=>a=>q(b,a)),[m,q]),V=(0,h.useMemo)(()=>m.map((a,b)=>a=>{let c=(0,be.sw)(w.get(a)??{cliTool:"claude",alias:a});if(m[b]?.instanceId===a)return;let d=m.findIndex((c,d)=>d!==b&&c.instanceId===a);if(-1!==d)return void g?.(`${c} is already in use by split ${d+1}`,"warning");q(b,a)&&(j?.(a),g?.(`Moved ${c} to Split ${b+1}`,"success"))}),[m,q,g,j,w]);return(0,e.jsxs)("div",{role:"group","aria-label":"Terminal splits","data-testid":"terminal-split-container",className:"flex flex-col h-full min-h-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-surface border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums mr-1",children:[m.length," / ",3," splits"]}),(0,e.jsx)("button",{type:"button",onClick:o,disabled:!Q,"aria-disabled":!Q,"aria-label":x("terminal.addSplit"),title:x("terminal.addSplit"),"data-testid":"add-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(dM,{className:"w-4 h-4","aria-hidden":"true"})}),(0,e.jsx)("button",{type:"button",onClick:p,disabled:!R,"aria-disabled":!R,"aria-label":x("terminal.removeSplit"),title:x("terminal.removeSplit"),"data-testid":"remove-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(ft.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,e.jsx)("button",{type:"button",onClick:P,disabled:!S,"aria-disabled":!S,"aria-label":x("terminal.equalizeWidthsHint"),title:x("terminal.equalizeWidthsHint"),"data-testid":"equalize-split-widths",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(fu,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})}),(0,e.jsx)("div",{className:"ml-auto h-4 w-px bg-border","aria-hidden":"true"}),(0,e.jsxs)("button",{type:"button",onClick:z,"aria-pressed":y,"aria-label":x(y?"terminal.hideHistory":"terminal.showHistory"),title:x(y?"terminal.hideHistory":"terminal.showHistory"),"data-testid":"toggle-history-pane",className:`flex items-center gap-1 text-xs px-2 py-0.5 rounded border transition-colors ${y?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[(0,e.jsx)(fv,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:x("terminal.historyLabel")})]}),(0,e.jsxs)("button",{type:"button",onClick:C,"aria-pressed":D,"aria-label":x(D?"terminal.hideFiles":"terminal.showFiles"),title:x(D?"terminal.hideFiles":"terminal.showFiles"),"data-testid":"toggle-file-panel",className:`flex items-center gap-1 text-xs px-2 py-0.5 rounded border transition-colors ${D?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[(0,e.jsx)(fw,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:x("terminal.filesLabel")})]})]}),(0,e.jsx)("div",{ref:E,className:"flex flex-1 min-h-0 w-full",children:m.map((a,b)=>{let c=b===m.length-1;return(0,e.jsxs)(i().Fragment,{children:[(0,e.jsx)("div",{style:{flexGrow:n[b]??1,flexShrink:1,flexBasis:0,minWidth:0},className:"h-full",children:d({splitIndex:b,cliToolId:a.cliToolId,instanceId:a.instanceId,instance:w.get(a.instanceId),availableInstances:t(b).map(a=>w.get(a)).filter(a=>void 0!==a),onInstanceChange:U[b],onFocus:T[b],isFocused:u===b,onDropInstance:V[b]})}),c?null:(0,e.jsx)(fA,{resizerIdx:b,ariaValueNow:n.length?n[b]/n.reduce((a,b)=>a+b,0)*100:50,onResize:M,onStart:N,onEnd:O,onDoubleClick:s})]},`split-${b}`)})})]})});function fA({resizerIdx:a,ariaValueNow:b,onResize:c,onStart:d,onEnd:f,onDoubleClick:g}){let i=(0,h.useCallback)(b=>c(a,b),[a,c]);return(0,e.jsx)("div",{"data-testid":`split-resizer-${a}`,onMouseDownCapture:d,onTouchStartCapture:d,onMouseUpCapture:f,onTouchEndCapture:f,children:(0,e.jsx)(ct,{onResize:i,orientation:"horizontal",ariaValueNow:b,onDoubleClick:g})})}let fB=`
34
34
  px-6 py-2 rounded-lg font-medium transition-all
35
35
  disabled:opacity-50 disabled:cursor-not-allowed
36
36
  focus:outline-none focus:ring-2 focus:ring-offset-2