commandmate 0.26.1 → 0.27.1

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 (840) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +430 -402
  3. package/.next/app-path-routes-manifest.json +32 -28
  4. package/.next/build-manifest.json +5 -5
  5. package/.next/prerender-manifest.json +12 -12
  6. package/.next/react-loadable-manifest.json +6 -6
  7. package/.next/required-server-files.json +1 -1
  8. package/.next/routes-manifest.json +24 -0
  9. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  10. package/.next/server/app/api/app/update/route_client-reference-manifest.js +1 -1
  11. package/.next/server/app/api/app/update-check/route.js +1 -1
  12. package/.next/server/app/api/app/update-check/route_client-reference-manifest.js +1 -1
  13. package/.next/server/app/api/assistant/conversation/route.js +1 -1
  14. package/.next/server/app/api/assistant/conversation/route.js.nft.json +1 -1
  15. package/.next/server/app/api/assistant/conversation/route_client-reference-manifest.js +1 -1
  16. package/.next/server/app/api/assistant/current-output/route.js +1 -1
  17. package/.next/server/app/api/assistant/current-output/route.js.nft.json +1 -1
  18. package/.next/server/app/api/assistant/current-output/route_client-reference-manifest.js +1 -1
  19. package/.next/server/app/api/assistant/messages/route.js +1 -1
  20. package/.next/server/app/api/assistant/messages/route.js.nft.json +1 -1
  21. package/.next/server/app/api/assistant/messages/route_client-reference-manifest.js +1 -1
  22. package/.next/server/app/api/assistant/session/route.js +1 -1
  23. package/.next/server/app/api/assistant/session/route.js.nft.json +1 -1
  24. package/.next/server/app/api/assistant/session/route_client-reference-manifest.js +1 -1
  25. package/.next/server/app/api/assistant/start/route.js +1 -1
  26. package/.next/server/app/api/assistant/start/route.js.nft.json +1 -1
  27. package/.next/server/app/api/assistant/start/route_client-reference-manifest.js +1 -1
  28. package/.next/server/app/api/assistant/terminal/route.js +2 -2
  29. package/.next/server/app/api/assistant/terminal/route.js.nft.json +1 -1
  30. package/.next/server/app/api/assistant/terminal/route_client-reference-manifest.js +1 -1
  31. package/.next/server/app/api/assistant/tools/route.js +1 -1
  32. package/.next/server/app/api/assistant/tools/route.js.nft.json +1 -1
  33. package/.next/server/app/api/assistant/tools/route_client-reference-manifest.js +1 -1
  34. package/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  35. package/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  36. package/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  37. package/.next/server/app/api/capabilities/route.js +1 -0
  38. package/.next/server/app/api/capabilities/route.js.nft.json +1 -0
  39. package/.next/server/app/api/capabilities/route_client-reference-manifest.js +1 -0
  40. package/.next/server/app/api/daily-summary/route_client-reference-manifest.js +1 -1
  41. package/.next/server/app/api/daily-summary/status/route_client-reference-manifest.js +1 -1
  42. package/.next/server/app/api/external-apps/[id]/health/route_client-reference-manifest.js +1 -1
  43. package/.next/server/app/api/external-apps/[id]/route_client-reference-manifest.js +1 -1
  44. package/.next/server/app/api/external-apps/route_client-reference-manifest.js +1 -1
  45. package/.next/server/app/api/fs/browse/route.js +2 -2
  46. package/.next/server/app/api/fs/browse/route.js.nft.json +1 -1
  47. package/.next/server/app/api/fs/browse/route_client-reference-manifest.js +1 -1
  48. package/.next/server/app/api/fs/recent-paths/route.js +2 -2
  49. package/.next/server/app/api/fs/recent-paths/route.js.nft.json +1 -1
  50. package/.next/server/app/api/fs/recent-paths/route_client-reference-manifest.js +1 -1
  51. package/.next/server/app/api/hooks/agent-event/route.js +1 -1
  52. package/.next/server/app/api/hooks/agent-event/route.js.nft.json +1 -1
  53. package/.next/server/app/api/hooks/agent-event/route_client-reference-manifest.js +1 -1
  54. package/.next/server/app/api/hooks/claude-done/route.js +19 -1
  55. package/.next/server/app/api/hooks/claude-done/route.js.nft.json +1 -1
  56. package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
  57. package/.next/server/app/api/hooks/permission-request/route.js +1 -1
  58. package/.next/server/app/api/hooks/permission-request/route.js.nft.json +1 -1
  59. package/.next/server/app/api/hooks/permission-request/route_client-reference-manifest.js +1 -1
  60. package/.next/server/app/api/metrics/vibe/route_client-reference-manifest.js +1 -1
  61. package/.next/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
  62. package/.next/server/app/api/push/escalation/route.js +1 -1
  63. package/.next/server/app/api/push/escalation/route.js.nft.json +1 -1
  64. package/.next/server/app/api/push/escalation/route_client-reference-manifest.js +1 -1
  65. package/.next/server/app/api/push/subscriptions/route.js +1 -1
  66. package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
  67. package/.next/server/app/api/push/vapid/route.js +1 -1
  68. package/.next/server/app/api/push/vapid/route.js.nft.json +1 -1
  69. package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
  70. package/.next/server/app/api/repositories/[id]/route_client-reference-manifest.js +1 -1
  71. package/.next/server/app/api/repositories/[id]/todos/[todoId]/route.js +1 -1
  72. package/.next/server/app/api/repositories/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  73. package/.next/server/app/api/repositories/[id]/todos/route.js +1 -1
  74. package/.next/server/app/api/repositories/[id]/todos/route_client-reference-manifest.js +1 -1
  75. package/.next/server/app/api/repositories/clone/[jobId]/route.js +1 -1
  76. package/.next/server/app/api/repositories/clone/[jobId]/route.js.nft.json +1 -1
  77. package/.next/server/app/api/repositories/clone/[jobId]/route_client-reference-manifest.js +1 -1
  78. package/.next/server/app/api/repositories/clone/route.js +1 -1
  79. package/.next/server/app/api/repositories/clone/route.js.nft.json +1 -1
  80. package/.next/server/app/api/repositories/clone/route_client-reference-manifest.js +1 -1
  81. package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
  82. package/.next/server/app/api/repositories/restore/route.js +1 -1
  83. package/.next/server/app/api/repositories/restore/route.js.nft.json +1 -1
  84. package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
  85. package/.next/server/app/api/repositories/route.js +1 -1
  86. package/.next/server/app/api/repositories/route.js.nft.json +1 -1
  87. package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
  88. package/.next/server/app/api/repositories/scan/route.js +1 -1
  89. package/.next/server/app/api/repositories/scan/route.js.nft.json +1 -1
  90. package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +1 -1
  91. package/.next/server/app/api/repositories/sync/route.js +1 -1
  92. package/.next/server/app/api/repositories/sync/route.js.nft.json +1 -1
  93. package/.next/server/app/api/repositories/sync/route_client-reference-manifest.js +1 -1
  94. package/.next/server/app/api/repositories/validate-path/route.js +1 -1
  95. package/.next/server/app/api/repositories/validate-path/route.js.nft.json +1 -1
  96. package/.next/server/app/api/repositories/validate-path/route_client-reference-manifest.js +1 -1
  97. package/.next/server/app/api/sidebar/group-order/route_client-reference-manifest.js +1 -1
  98. package/.next/server/app/api/skills/[id]/route_client-reference-manifest.js +1 -1
  99. package/.next/server/app/api/skills/installations/route_client-reference-manifest.js +1 -1
  100. package/.next/server/app/api/skills/operations/route_client-reference-manifest.js +1 -1
  101. package/.next/server/app/api/skills/reindex/route_client-reference-manifest.js +1 -1
  102. package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
  103. package/.next/server/app/api/slash-commands/route.js.nft.json +1 -1
  104. package/.next/server/app/api/slash-commands/route_client-reference-manifest.js +1 -1
  105. package/.next/server/app/api/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
  106. package/.next/server/app/api/tasks/[taskId]/route.js +1 -1
  107. package/.next/server/app/api/tasks/[taskId]/route_client-reference-manifest.js +1 -1
  108. package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
  109. package/.next/server/app/api/templates/route_client-reference-manifest.js +1 -1
  110. package/.next/server/app/api/todos/route.js +1 -1
  111. package/.next/server/app/api/todos/route_client-reference-manifest.js +1 -1
  112. package/.next/server/app/api/verification/runs/[runId]/route.js +1 -1
  113. package/.next/server/app/api/verification/runs/[runId]/route_client-reference-manifest.js +1 -1
  114. package/.next/server/app/api/verification/runs/route.js +1 -1
  115. package/.next/server/app/api/verification/runs/route_client-reference-manifest.js +1 -1
  116. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js +1 -1
  117. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js.nft.json +1 -1
  118. package/.next/server/app/api/worktrees/[id]/auto-yes/route_client-reference-manifest.js +1 -1
  119. package/.next/server/app/api/worktrees/[id]/capture/route.js +1 -1
  120. package/.next/server/app/api/worktrees/[id]/capture/route.js.nft.json +1 -1
  121. package/.next/server/app/api/worktrees/[id]/capture/route_client-reference-manifest.js +1 -1
  122. package/.next/server/app/api/worktrees/[id]/clear-composer/route.js +1 -0
  123. package/.next/server/app/api/worktrees/[id]/clear-composer/route.js.nft.json +1 -0
  124. package/.next/server/app/api/worktrees/[id]/clear-composer/route_client-reference-manifest.js +1 -0
  125. package/.next/server/app/api/worktrees/[id]/cli-tool/route.js +1 -1
  126. package/.next/server/app/api/worktrees/[id]/cli-tool/route_client-reference-manifest.js +1 -1
  127. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route.js +1 -1
  128. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route.js.nft.json +1 -1
  129. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route_client-reference-manifest.js +1 -1
  130. package/.next/server/app/api/worktrees/[id]/current-output/route.js +2 -1
  131. package/.next/server/app/api/worktrees/[id]/current-output/route.js.nft.json +1 -1
  132. package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
  133. package/.next/server/app/api/worktrees/[id]/env/route.js +2 -0
  134. package/.next/server/app/api/worktrees/[id]/env/route.js.nft.json +1 -0
  135. package/.next/server/app/api/worktrees/[id]/env/route_client-reference-manifest.js +1 -0
  136. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route.js +1 -1
  137. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route_client-reference-manifest.js +1 -1
  138. package/.next/server/app/api/worktrees/[id]/execution-logs/route.js +1 -1
  139. package/.next/server/app/api/worktrees/[id]/execution-logs/route_client-reference-manifest.js +1 -1
  140. package/.next/server/app/api/worktrees/[id]/files/[...path]/route.js +1 -1
  141. package/.next/server/app/api/worktrees/[id]/files/[...path]/route.js.nft.json +1 -1
  142. package/.next/server/app/api/worktrees/[id]/files/[...path]/route_client-reference-manifest.js +1 -1
  143. package/.next/server/app/api/worktrees/[id]/git/branch/create/route_client-reference-manifest.js +1 -1
  144. package/.next/server/app/api/worktrees/[id]/git/branch/delete/route_client-reference-manifest.js +1 -1
  145. package/.next/server/app/api/worktrees/[id]/git/branches/route.js +1 -1
  146. package/.next/server/app/api/worktrees/[id]/git/branches/route_client-reference-manifest.js +1 -1
  147. package/.next/server/app/api/worktrees/[id]/git/checkout/route_client-reference-manifest.js +1 -1
  148. package/.next/server/app/api/worktrees/[id]/git/commit/route.js +1 -1
  149. package/.next/server/app/api/worktrees/[id]/git/commit/route_client-reference-manifest.js +1 -1
  150. package/.next/server/app/api/worktrees/[id]/git/diff/route_client-reference-manifest.js +1 -1
  151. package/.next/server/app/api/worktrees/[id]/git/fetch/route_client-reference-manifest.js +1 -1
  152. package/.next/server/app/api/worktrees/[id]/git/log/route.js +1 -1
  153. package/.next/server/app/api/worktrees/[id]/git/log/route_client-reference-manifest.js +1 -1
  154. package/.next/server/app/api/worktrees/[id]/git/pull/route_client-reference-manifest.js +1 -1
  155. package/.next/server/app/api/worktrees/[id]/git/push/route_client-reference-manifest.js +1 -1
  156. package/.next/server/app/api/worktrees/[id]/git/reset/route_client-reference-manifest.js +1 -1
  157. package/.next/server/app/api/worktrees/[id]/git/revert/route_client-reference-manifest.js +1 -1
  158. package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route_client-reference-manifest.js +1 -1
  159. package/.next/server/app/api/worktrees/[id]/git/stage/route_client-reference-manifest.js +1 -1
  160. package/.next/server/app/api/worktrees/[id]/git/staged/route.js +1 -1
  161. package/.next/server/app/api/worktrees/[id]/git/staged/route_client-reference-manifest.js +1 -1
  162. package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route_client-reference-manifest.js +1 -1
  163. package/.next/server/app/api/worktrees/[id]/git/stash/apply/route_client-reference-manifest.js +1 -1
  164. package/.next/server/app/api/worktrees/[id]/git/stash/pop/route_client-reference-manifest.js +1 -1
  165. package/.next/server/app/api/worktrees/[id]/git/stash/push/route.js +1 -1
  166. package/.next/server/app/api/worktrees/[id]/git/stash/push/route_client-reference-manifest.js +1 -1
  167. package/.next/server/app/api/worktrees/[id]/git/stash/route.js +1 -1
  168. package/.next/server/app/api/worktrees/[id]/git/stash/route_client-reference-manifest.js +1 -1
  169. package/.next/server/app/api/worktrees/[id]/git/status/route.js +1 -1
  170. package/.next/server/app/api/worktrees/[id]/git/status/route_client-reference-manifest.js +1 -1
  171. package/.next/server/app/api/worktrees/[id]/git/unstage/route_client-reference-manifest.js +1 -1
  172. package/.next/server/app/api/worktrees/[id]/git/working-diff/route.js +1 -1
  173. package/.next/server/app/api/worktrees/[id]/git/working-diff/route_client-reference-manifest.js +1 -1
  174. package/.next/server/app/api/worktrees/[id]/interrupt/route.js +1 -1
  175. package/.next/server/app/api/worktrees/[id]/interrupt/route.js.nft.json +1 -1
  176. package/.next/server/app/api/worktrees/[id]/interrupt/route_client-reference-manifest.js +1 -1
  177. package/.next/server/app/api/worktrees/[id]/kill-session/route.js +1 -1
  178. package/.next/server/app/api/worktrees/[id]/kill-session/route.js.nft.json +1 -1
  179. package/.next/server/app/api/worktrees/[id]/kill-session/route_client-reference-manifest.js +1 -1
  180. package/.next/server/app/api/worktrees/[id]/logs/[filename]/route.js +1 -1
  181. package/.next/server/app/api/worktrees/[id]/logs/[filename]/route_client-reference-manifest.js +1 -1
  182. package/.next/server/app/api/worktrees/[id]/logs/route_client-reference-manifest.js +1 -1
  183. package/.next/server/app/api/worktrees/[id]/marp-render/route.js +1 -1
  184. package/.next/server/app/api/worktrees/[id]/marp-render/route_client-reference-manifest.js +1 -1
  185. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route.js +1 -1
  186. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route_client-reference-manifest.js +1 -1
  187. package/.next/server/app/api/worktrees/[id]/memos/route.js +1 -1
  188. package/.next/server/app/api/worktrees/[id]/memos/route_client-reference-manifest.js +1 -1
  189. package/.next/server/app/api/worktrees/[id]/messages/route.js +1 -1
  190. package/.next/server/app/api/worktrees/[id]/messages/route_client-reference-manifest.js +1 -1
  191. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js +1 -1
  192. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js.nft.json +1 -1
  193. package/.next/server/app/api/worktrees/[id]/prompt-response/route_client-reference-manifest.js +1 -1
  194. package/.next/server/app/api/worktrees/[id]/resolve-target/route.js +1 -0
  195. package/.next/server/app/api/worktrees/[id]/resolve-target/route.js.nft.json +1 -0
  196. package/.next/server/app/api/worktrees/[id]/resolve-target/route_client-reference-manifest.js +1 -0
  197. package/.next/server/app/api/worktrees/[id]/respond/route.js +1 -1
  198. package/.next/server/app/api/worktrees/[id]/respond/route.js.nft.json +1 -1
  199. package/.next/server/app/api/worktrees/[id]/respond/route_client-reference-manifest.js +1 -1
  200. package/.next/server/app/api/worktrees/[id]/route.js +1 -1
  201. package/.next/server/app/api/worktrees/[id]/route.js.nft.json +1 -1
  202. package/.next/server/app/api/worktrees/[id]/route_client-reference-manifest.js +1 -1
  203. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js +1 -5
  204. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js.nft.json +1 -1
  205. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route_client-reference-manifest.js +1 -1
  206. package/.next/server/app/api/worktrees/[id]/schedules/active/route.js +1 -1
  207. package/.next/server/app/api/worktrees/[id]/schedules/active/route.js.nft.json +1 -1
  208. package/.next/server/app/api/worktrees/[id]/schedules/active/route_client-reference-manifest.js +1 -1
  209. package/.next/server/app/api/worktrees/[id]/schedules/route.js +2 -6
  210. package/.next/server/app/api/worktrees/[id]/schedules/route.js.nft.json +1 -1
  211. package/.next/server/app/api/worktrees/[id]/schedules/route_client-reference-manifest.js +1 -1
  212. package/.next/server/app/api/worktrees/[id]/search/route.js +1 -1
  213. package/.next/server/app/api/worktrees/[id]/search/route.js.nft.json +1 -1
  214. package/.next/server/app/api/worktrees/[id]/search/route_client-reference-manifest.js +1 -1
  215. package/.next/server/app/api/worktrees/[id]/send/route.js +3 -1
  216. package/.next/server/app/api/worktrees/[id]/send/route.js.nft.json +1 -1
  217. package/.next/server/app/api/worktrees/[id]/send/route_client-reference-manifest.js +1 -1
  218. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route.js +1 -1
  219. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route.js.nft.json +1 -1
  220. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route_client-reference-manifest.js +1 -1
  221. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route_client-reference-manifest.js +1 -1
  222. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route_client-reference-manifest.js +1 -1
  223. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route_client-reference-manifest.js +1 -1
  224. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route_client-reference-manifest.js +1 -1
  225. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update/route_client-reference-manifest.js +1 -1
  226. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update-plan/route_client-reference-manifest.js +1 -1
  227. package/.next/server/app/api/worktrees/[id]/skills/route.js +1 -1
  228. package/.next/server/app/api/worktrees/[id]/skills/route_client-reference-manifest.js +1 -1
  229. package/.next/server/app/api/worktrees/[id]/slash-commands/route.js +1 -1
  230. package/.next/server/app/api/worktrees/[id]/slash-commands/route.js.nft.json +1 -1
  231. package/.next/server/app/api/worktrees/[id]/slash-commands/route_client-reference-manifest.js +1 -1
  232. package/.next/server/app/api/worktrees/[id]/special-keys/route.js +1 -1
  233. package/.next/server/app/api/worktrees/[id]/special-keys/route.js.nft.json +1 -1
  234. package/.next/server/app/api/worktrees/[id]/special-keys/route_client-reference-manifest.js +1 -1
  235. package/.next/server/app/api/worktrees/[id]/start-polling/route.js +1 -1
  236. package/.next/server/app/api/worktrees/[id]/start-polling/route.js.nft.json +1 -1
  237. package/.next/server/app/api/worktrees/[id]/start-polling/route_client-reference-manifest.js +1 -1
  238. package/.next/server/app/api/worktrees/[id]/tasks/route.js +1 -1
  239. package/.next/server/app/api/worktrees/[id]/tasks/route_client-reference-manifest.js +1 -1
  240. package/.next/server/app/api/worktrees/[id]/terminal/route.js +1 -1
  241. package/.next/server/app/api/worktrees/[id]/terminal/route.js.nft.json +1 -1
  242. package/.next/server/app/api/worktrees/[id]/terminal/route_client-reference-manifest.js +1 -1
  243. package/.next/server/app/api/worktrees/[id]/timers/history/route.js +1 -1
  244. package/.next/server/app/api/worktrees/[id]/timers/history/route_client-reference-manifest.js +1 -1
  245. package/.next/server/app/api/worktrees/[id]/timers/route.js +3 -1
  246. package/.next/server/app/api/worktrees/[id]/timers/route.js.nft.json +1 -1
  247. package/.next/server/app/api/worktrees/[id]/timers/route_client-reference-manifest.js +1 -1
  248. package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route.js +1 -1
  249. package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  250. package/.next/server/app/api/worktrees/[id]/todos/route.js +1 -1
  251. package/.next/server/app/api/worktrees/[id]/todos/route_client-reference-manifest.js +1 -1
  252. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route.js +1 -1
  253. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route.js.nft.json +1 -1
  254. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route_client-reference-manifest.js +1 -1
  255. package/.next/server/app/api/worktrees/[id]/tree/route.js +1 -1
  256. package/.next/server/app/api/worktrees/[id]/tree/route.js.nft.json +1 -1
  257. package/.next/server/app/api/worktrees/[id]/tree/route_client-reference-manifest.js +1 -1
  258. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route.js +1 -1
  259. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route.js.nft.json +1 -1
  260. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route_client-reference-manifest.js +1 -1
  261. package/.next/server/app/api/worktrees/[id]/verify/route.js +1 -1
  262. package/.next/server/app/api/worktrees/[id]/verify/route.js.nft.json +1 -1
  263. package/.next/server/app/api/worktrees/[id]/verify/route_client-reference-manifest.js +1 -1
  264. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route.js +1 -1
  265. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route_client-reference-manifest.js +1 -1
  266. package/.next/server/app/api/worktrees/[id]/verify/runs/route.js +1 -1
  267. package/.next/server/app/api/worktrees/[id]/verify/runs/route_client-reference-manifest.js +1 -1
  268. package/.next/server/app/api/worktrees/[id]/viewed/route.js +1 -1
  269. package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
  270. package/.next/server/app/api/worktrees/route.js +1 -1
  271. package/.next/server/app/api/worktrees/route.js.nft.json +1 -1
  272. package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
  273. package/.next/server/app/chat/page.js +2 -2
  274. package/.next/server/app/chat/page.js.nft.json +1 -1
  275. package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  276. package/.next/server/app/login/page.js +2 -2
  277. package/.next/server/app/login/page.js.nft.json +1 -1
  278. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  279. package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
  280. package/.next/server/app/more/page.js +2 -2
  281. package/.next/server/app/more/page.js.nft.json +1 -1
  282. package/.next/server/app/more/page_client-reference-manifest.js +1 -1
  283. package/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  284. package/.next/server/app/page.js +1 -1
  285. package/.next/server/app/page.js.nft.json +1 -1
  286. package/.next/server/app/page_client-reference-manifest.js +1 -1
  287. package/.next/server/app/proxy/[...path]/route_client-reference-manifest.js +1 -1
  288. package/.next/server/app/repositories/page.js +2 -2
  289. package/.next/server/app/repositories/page.js.nft.json +1 -1
  290. package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
  291. package/.next/server/app/review/page.js +1 -1
  292. package/.next/server/app/review/page.js.nft.json +1 -1
  293. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  294. package/.next/server/app/sessions/page.js +1 -1
  295. package/.next/server/app/sessions/page.js.nft.json +1 -1
  296. package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  297. package/.next/server/app/skills/[skillId]/page.js +2 -2
  298. package/.next/server/app/skills/[skillId]/page.js.nft.json +1 -1
  299. package/.next/server/app/skills/[skillId]/page_client-reference-manifest.js +1 -1
  300. package/.next/server/app/skills/installed/page.js +2 -2
  301. package/.next/server/app/skills/installed/page.js.nft.json +1 -1
  302. package/.next/server/app/skills/installed/page_client-reference-manifest.js +1 -1
  303. package/.next/server/app/skills/page.js +2 -2
  304. package/.next/server/app/skills/page.js.nft.json +1 -1
  305. package/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  306. package/.next/server/app/worktrees/[id]/files/[...path]/page.js +2 -2
  307. package/.next/server/app/worktrees/[id]/files/[...path]/page.js.nft.json +1 -1
  308. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
  309. package/.next/server/app/worktrees/[id]/page.js +9 -7
  310. package/.next/server/app/worktrees/[id]/page.js.nft.json +1 -1
  311. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
  312. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
  313. package/.next/server/app-paths-manifest.json +32 -28
  314. package/.next/server/chunks/1029.js +1 -1
  315. package/.next/server/chunks/1068.js +3 -1
  316. package/.next/server/chunks/1296.js +1 -1
  317. package/.next/server/chunks/1538.js +7 -0
  318. package/.next/server/chunks/1601.js +2 -2
  319. package/.next/server/chunks/2119.js +1 -1
  320. package/.next/server/chunks/2404.js +3 -2
  321. package/.next/server/chunks/2445.js +1 -1
  322. package/.next/server/chunks/2546.js +1 -1
  323. package/.next/server/chunks/2689.js +13 -0
  324. package/.next/server/chunks/2759.js +8 -0
  325. package/.next/server/chunks/2839.js +1 -0
  326. package/.next/server/chunks/3241.js +1 -1
  327. package/.next/server/chunks/3292.js +1 -0
  328. package/.next/server/chunks/3417.js +1 -1
  329. package/.next/server/chunks/3480.js +1 -17
  330. package/.next/server/chunks/4393.js +1 -1
  331. package/.next/server/chunks/4423.js +1 -0
  332. package/.next/server/chunks/4444.js +22 -8
  333. package/.next/server/chunks/4565.js +3 -0
  334. package/.next/server/chunks/467.js +1 -0
  335. package/.next/server/chunks/4905.js +5 -0
  336. package/.next/server/chunks/5017.js +1 -0
  337. package/.next/server/chunks/5089.js +1 -0
  338. package/.next/server/chunks/5164.js +1 -1
  339. package/.next/server/chunks/5220.js +1 -0
  340. package/.next/server/chunks/5354.js +1 -0
  341. package/.next/server/chunks/552.js +19 -0
  342. package/.next/server/chunks/5571.js +1 -1
  343. package/.next/server/chunks/5998.js +3 -3
  344. package/.next/server/chunks/6130.js +1 -1
  345. package/.next/server/chunks/6274.js +11 -11
  346. package/.next/server/chunks/6285.js +1 -1
  347. package/.next/server/chunks/6401.js +1 -1
  348. package/.next/server/chunks/6781.js +1 -1
  349. package/.next/server/chunks/7472.js +1 -0
  350. package/.next/server/chunks/7506.js +1 -0
  351. package/.next/server/chunks/848.js +1 -1
  352. package/.next/server/chunks/8536.js +1 -1
  353. package/.next/server/chunks/880.js +1 -1
  354. package/.next/server/chunks/8807.js +5 -5
  355. package/.next/server/chunks/9067.js +1 -1
  356. package/.next/server/chunks/9284.js +1 -0
  357. package/.next/server/chunks/9358.js +1 -1
  358. package/.next/server/chunks/9508.js +1 -0
  359. package/.next/server/chunks/9938.js +1 -0
  360. package/.next/server/middleware-build-manifest.js +1 -1
  361. package/.next/server/middleware-manifest.json +5 -5
  362. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  363. package/.next/server/pages/500.html +1 -1
  364. package/.next/server/server-reference-manifest.json +1 -1
  365. package/.next/static/9IXgWfBUtnEnRqnbmErTp/_buildManifest.js +1 -0
  366. package/.next/static/chunks/{2053-dfac2d49227cc942.js → 2053-c0e931eb4391baa1.js} +1 -1
  367. package/.next/static/chunks/3361-5d6e93fba8a92bc1.js +1 -0
  368. package/.next/static/chunks/3922.0d2e64daf9f187da.js +1 -0
  369. package/.next/static/chunks/{5229-35f9acab97a553c5.js → 5229-1f5f19740a8d6c11.js} +1 -1
  370. package/.next/static/chunks/{6381-0e097c0286155883.js → 6381-8cfe50a5ca5425b1.js} +1 -1
  371. package/.next/static/chunks/{8649-f551b0010dba4986.js → 8521-c43994fb58501d13.js} +1 -1
  372. package/.next/static/chunks/app/api/app/update/route-6add0d88e2828c23.js +1 -0
  373. package/.next/static/chunks/app/api/app/update-check/route-6add0d88e2828c23.js +1 -0
  374. package/.next/static/chunks/app/api/assistant/conversation/route-6add0d88e2828c23.js +1 -0
  375. package/.next/static/chunks/app/api/assistant/current-output/route-6add0d88e2828c23.js +1 -0
  376. package/.next/static/chunks/app/api/assistant/messages/route-6add0d88e2828c23.js +1 -0
  377. package/.next/static/chunks/app/api/assistant/session/route-6add0d88e2828c23.js +1 -0
  378. package/.next/static/chunks/app/api/assistant/start/route-6add0d88e2828c23.js +1 -0
  379. package/.next/static/chunks/app/api/assistant/terminal/route-6add0d88e2828c23.js +1 -0
  380. package/.next/static/chunks/app/api/assistant/tools/route-6add0d88e2828c23.js +1 -0
  381. package/.next/static/chunks/app/api/auth/login/route-6add0d88e2828c23.js +1 -0
  382. package/.next/static/chunks/app/api/auth/logout/route-6add0d88e2828c23.js +1 -0
  383. package/.next/static/chunks/app/api/auth/status/route-6add0d88e2828c23.js +1 -0
  384. package/.next/static/chunks/app/api/capabilities/route-6add0d88e2828c23.js +1 -0
  385. package/.next/static/chunks/app/api/daily-summary/route-6add0d88e2828c23.js +1 -0
  386. package/.next/static/chunks/app/api/daily-summary/status/route-6add0d88e2828c23.js +1 -0
  387. package/.next/static/chunks/app/api/external-apps/[id]/health/route-6add0d88e2828c23.js +1 -0
  388. package/.next/static/chunks/app/api/external-apps/[id]/route-6add0d88e2828c23.js +1 -0
  389. package/.next/static/chunks/app/api/external-apps/route-6add0d88e2828c23.js +1 -0
  390. package/.next/static/chunks/app/api/fs/browse/route-6add0d88e2828c23.js +1 -0
  391. package/.next/static/chunks/app/api/fs/recent-paths/route-6add0d88e2828c23.js +1 -0
  392. package/.next/static/chunks/app/api/hooks/agent-event/route-6add0d88e2828c23.js +1 -0
  393. package/.next/static/chunks/app/api/hooks/claude-done/route-6add0d88e2828c23.js +1 -0
  394. package/.next/static/chunks/app/api/hooks/permission-request/route-6add0d88e2828c23.js +1 -0
  395. package/.next/static/chunks/app/api/metrics/vibe/route-6add0d88e2828c23.js +1 -0
  396. package/.next/static/chunks/app/api/ollama/models/route-6add0d88e2828c23.js +1 -0
  397. package/.next/static/chunks/app/api/push/escalation/route-6add0d88e2828c23.js +1 -0
  398. package/.next/static/chunks/app/api/push/subscriptions/route-6add0d88e2828c23.js +1 -0
  399. package/.next/static/chunks/app/api/push/vapid/route-6add0d88e2828c23.js +1 -0
  400. package/.next/static/chunks/app/api/repositories/[id]/route-6add0d88e2828c23.js +1 -0
  401. package/.next/static/chunks/app/api/repositories/[id]/todos/[todoId]/route-6add0d88e2828c23.js +1 -0
  402. package/.next/static/chunks/app/api/repositories/[id]/todos/route-6add0d88e2828c23.js +1 -0
  403. package/.next/static/chunks/app/api/repositories/clone/[jobId]/route-6add0d88e2828c23.js +1 -0
  404. package/.next/static/chunks/app/api/repositories/clone/route-6add0d88e2828c23.js +1 -0
  405. package/.next/static/chunks/app/api/repositories/excluded/route-6add0d88e2828c23.js +1 -0
  406. package/.next/static/chunks/app/api/repositories/restore/route-6add0d88e2828c23.js +1 -0
  407. package/.next/static/chunks/app/api/repositories/route-6add0d88e2828c23.js +1 -0
  408. package/.next/static/chunks/app/api/repositories/scan/route-6add0d88e2828c23.js +1 -0
  409. package/.next/static/chunks/app/api/repositories/sync/route-6add0d88e2828c23.js +1 -0
  410. package/.next/static/chunks/app/api/repositories/validate-path/route-6add0d88e2828c23.js +1 -0
  411. package/.next/static/chunks/app/api/sidebar/group-order/route-6add0d88e2828c23.js +1 -0
  412. package/.next/static/chunks/app/api/skills/[id]/route-6add0d88e2828c23.js +1 -0
  413. package/.next/static/chunks/app/api/skills/installations/route-6add0d88e2828c23.js +1 -0
  414. package/.next/static/chunks/app/api/skills/operations/route-6add0d88e2828c23.js +1 -0
  415. package/.next/static/chunks/app/api/skills/reindex/route-6add0d88e2828c23.js +1 -0
  416. package/.next/static/chunks/app/api/skills/route-6add0d88e2828c23.js +1 -0
  417. package/.next/static/chunks/app/api/slash-commands/route-6add0d88e2828c23.js +1 -0
  418. package/.next/static/chunks/app/api/tasks/[taskId]/cancel/route-6add0d88e2828c23.js +1 -0
  419. package/.next/static/chunks/app/api/tasks/[taskId]/route-6add0d88e2828c23.js +1 -0
  420. package/.next/static/chunks/app/api/templates/[id]/route-6add0d88e2828c23.js +1 -0
  421. package/.next/static/chunks/app/api/templates/route-6add0d88e2828c23.js +1 -0
  422. package/.next/static/chunks/app/api/todos/route-6add0d88e2828c23.js +1 -0
  423. package/.next/static/chunks/app/api/verification/runs/[runId]/route-6add0d88e2828c23.js +1 -0
  424. package/.next/static/chunks/app/api/verification/runs/route-6add0d88e2828c23.js +1 -0
  425. package/.next/static/chunks/app/api/worktrees/[id]/auto-yes/route-6add0d88e2828c23.js +1 -0
  426. package/.next/static/chunks/app/api/worktrees/[id]/capture/route-6add0d88e2828c23.js +1 -0
  427. package/.next/static/chunks/app/api/worktrees/[id]/clear-composer/route-6add0d88e2828c23.js +1 -0
  428. package/.next/static/chunks/app/api/worktrees/[id]/cli-tool/route-6add0d88e2828c23.js +1 -0
  429. package/.next/static/chunks/app/api/worktrees/[id]/cmate/schedules/route-6add0d88e2828c23.js +1 -0
  430. package/.next/static/chunks/app/api/worktrees/[id]/current-output/route-6add0d88e2828c23.js +1 -0
  431. package/.next/static/chunks/app/api/worktrees/[id]/env/route-6add0d88e2828c23.js +1 -0
  432. package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/[logId]/route-6add0d88e2828c23.js +1 -0
  433. package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/route-6add0d88e2828c23.js +1 -0
  434. package/.next/static/chunks/app/api/worktrees/[id]/files/[...path]/route-6add0d88e2828c23.js +1 -0
  435. package/.next/static/chunks/app/api/worktrees/[id]/git/branch/create/route-6add0d88e2828c23.js +1 -0
  436. package/.next/static/chunks/app/api/worktrees/[id]/git/branch/delete/route-6add0d88e2828c23.js +1 -0
  437. package/.next/static/chunks/app/api/worktrees/[id]/git/branches/route-6add0d88e2828c23.js +1 -0
  438. package/.next/static/chunks/app/api/worktrees/[id]/git/checkout/route-6add0d88e2828c23.js +1 -0
  439. package/.next/static/chunks/app/api/worktrees/[id]/git/commit/route-6add0d88e2828c23.js +1 -0
  440. package/.next/static/chunks/app/api/worktrees/[id]/git/diff/route-6add0d88e2828c23.js +1 -0
  441. package/.next/static/chunks/app/api/worktrees/[id]/git/fetch/route-6add0d88e2828c23.js +1 -0
  442. package/.next/static/chunks/app/api/worktrees/[id]/git/log/route-6add0d88e2828c23.js +1 -0
  443. package/.next/static/chunks/app/api/worktrees/[id]/git/pull/route-6add0d88e2828c23.js +1 -0
  444. package/.next/static/chunks/app/api/worktrees/[id]/git/push/route-6add0d88e2828c23.js +1 -0
  445. package/.next/static/chunks/app/api/worktrees/[id]/git/reset/route-6add0d88e2828c23.js +1 -0
  446. package/.next/static/chunks/app/api/worktrees/[id]/git/revert/route-6add0d88e2828c23.js +1 -0
  447. package/.next/static/chunks/app/api/worktrees/[id]/git/show/[commitHash]/route-6add0d88e2828c23.js +1 -0
  448. package/.next/static/chunks/app/api/worktrees/[id]/git/stage/route-6add0d88e2828c23.js +1 -0
  449. package/.next/static/chunks/app/api/worktrees/[id]/git/staged/route-6add0d88e2828c23.js +1 -0
  450. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/[index]/route-6add0d88e2828c23.js +1 -0
  451. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/apply/route-6add0d88e2828c23.js +1 -0
  452. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/pop/route-6add0d88e2828c23.js +1 -0
  453. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/push/route-6add0d88e2828c23.js +1 -0
  454. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/route-6add0d88e2828c23.js +1 -0
  455. package/.next/static/chunks/app/api/worktrees/[id]/git/status/route-6add0d88e2828c23.js +1 -0
  456. package/.next/static/chunks/app/api/worktrees/[id]/git/unstage/route-6add0d88e2828c23.js +1 -0
  457. package/.next/static/chunks/app/api/worktrees/[id]/git/working-diff/route-6add0d88e2828c23.js +1 -0
  458. package/.next/static/chunks/app/api/worktrees/[id]/interrupt/route-6add0d88e2828c23.js +1 -0
  459. package/.next/static/chunks/app/api/worktrees/[id]/kill-session/route-6add0d88e2828c23.js +1 -0
  460. package/.next/static/chunks/app/api/worktrees/[id]/logs/[filename]/route-6add0d88e2828c23.js +1 -0
  461. package/.next/static/chunks/app/api/worktrees/[id]/logs/route-6add0d88e2828c23.js +1 -0
  462. package/.next/static/chunks/app/api/worktrees/[id]/marp-render/route-6add0d88e2828c23.js +1 -0
  463. package/.next/static/chunks/app/api/worktrees/[id]/memos/[memoId]/route-6add0d88e2828c23.js +1 -0
  464. package/.next/static/chunks/app/api/worktrees/[id]/memos/route-6add0d88e2828c23.js +1 -0
  465. package/.next/static/chunks/app/api/worktrees/[id]/messages/route-6add0d88e2828c23.js +1 -0
  466. package/.next/static/chunks/app/api/worktrees/[id]/prompt-response/route-6add0d88e2828c23.js +1 -0
  467. package/.next/static/chunks/app/api/worktrees/[id]/resolve-target/route-6add0d88e2828c23.js +1 -0
  468. package/.next/static/chunks/app/api/worktrees/[id]/respond/route-6add0d88e2828c23.js +1 -0
  469. package/.next/static/chunks/app/api/worktrees/[id]/route-6add0d88e2828c23.js +1 -0
  470. package/.next/static/chunks/app/api/worktrees/[id]/schedules/[scheduleId]/route-6add0d88e2828c23.js +1 -0
  471. package/.next/static/chunks/app/api/worktrees/[id]/schedules/active/route-6add0d88e2828c23.js +1 -0
  472. package/.next/static/chunks/app/api/worktrees/[id]/schedules/route-6add0d88e2828c23.js +1 -0
  473. package/.next/static/chunks/app/api/worktrees/[id]/search/route-6add0d88e2828c23.js +1 -0
  474. package/.next/static/chunks/app/api/worktrees/[id]/send/route-6add0d88e2828c23.js +1 -0
  475. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route-6add0d88e2828c23.js +1 -0
  476. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/install/route-6add0d88e2828c23.js +1 -0
  477. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/plan/route-6add0d88e2828c23.js +1 -0
  478. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall/route-6add0d88e2828c23.js +1 -0
  479. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route-6add0d88e2828c23.js +1 -0
  480. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/update/route-6add0d88e2828c23.js +1 -0
  481. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/update-plan/route-6add0d88e2828c23.js +1 -0
  482. package/.next/static/chunks/app/api/worktrees/[id]/skills/route-6add0d88e2828c23.js +1 -0
  483. package/.next/static/chunks/app/api/worktrees/[id]/slash-commands/route-6add0d88e2828c23.js +1 -0
  484. package/.next/static/chunks/app/api/worktrees/[id]/special-keys/route-6add0d88e2828c23.js +1 -0
  485. package/.next/static/chunks/app/api/worktrees/[id]/start-polling/route-6add0d88e2828c23.js +1 -0
  486. package/.next/static/chunks/app/api/worktrees/[id]/tasks/route-6add0d88e2828c23.js +1 -0
  487. package/.next/static/chunks/app/api/worktrees/[id]/terminal/route-6add0d88e2828c23.js +1 -0
  488. package/.next/static/chunks/app/api/worktrees/[id]/timers/history/route-6add0d88e2828c23.js +1 -0
  489. package/.next/static/chunks/app/api/worktrees/[id]/timers/route-6add0d88e2828c23.js +1 -0
  490. package/.next/static/chunks/app/api/worktrees/[id]/todos/[todoId]/route-6add0d88e2828c23.js +1 -0
  491. package/.next/static/chunks/app/api/worktrees/[id]/todos/route-6add0d88e2828c23.js +1 -0
  492. package/.next/static/chunks/app/api/worktrees/[id]/tree/[...path]/route-6add0d88e2828c23.js +1 -0
  493. package/.next/static/chunks/app/api/worktrees/[id]/tree/route-6add0d88e2828c23.js +1 -0
  494. package/.next/static/chunks/app/api/worktrees/[id]/upload/[...path]/route-6add0d88e2828c23.js +1 -0
  495. package/.next/static/chunks/app/api/worktrees/[id]/verify/route-6add0d88e2828c23.js +1 -0
  496. package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/[runId]/route-6add0d88e2828c23.js +1 -0
  497. package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/route-6add0d88e2828c23.js +1 -0
  498. package/.next/static/chunks/app/api/worktrees/[id]/viewed/route-6add0d88e2828c23.js +1 -0
  499. package/.next/static/chunks/app/api/worktrees/route-6add0d88e2828c23.js +1 -0
  500. package/.next/static/chunks/app/chat/{page-439b35c9cb90dbe0.js → page-231df45127e876c2.js} +1 -1
  501. package/.next/static/chunks/app/login/{page-eefd515d8c37e5ee.js → page-adc51f0f7cbb7ac6.js} +1 -1
  502. package/.next/static/chunks/app/manifest.webmanifest/route-6add0d88e2828c23.js +1 -0
  503. package/.next/static/chunks/app/more/{page-889b7546a8a553dc.js → page-3266dfa945972649.js} +1 -1
  504. package/.next/static/chunks/app/{page-a8d04ac0e3e4c9fc.js → page-0305431f43195431.js} +1 -1
  505. package/.next/static/chunks/app/proxy/[...path]/route-6add0d88e2828c23.js +1 -0
  506. package/.next/static/chunks/app/repositories/{page-f3c4d8839b1ca203.js → page-ae8fa55749976f79.js} +1 -1
  507. package/.next/static/chunks/app/review/{page-6dc88649fe88ac16.js → page-8f63aff862fee421.js} +1 -1
  508. package/.next/static/chunks/app/sessions/{page-2c9ed9e969097688.js → page-4d5382b257077c14.js} +1 -1
  509. package/.next/static/chunks/app/skills/[skillId]/{page-19beef6121c4c982.js → page-aaf0bcb1dfb558b9.js} +1 -1
  510. package/.next/static/chunks/app/skills/installed/{page-d5b9cef6d21fabda.js → page-dafc486410e839b7.js} +1 -1
  511. package/.next/static/chunks/app/skills/{page-06ef637e07dd9377.js → page-9e3c91da31514893.js} +1 -1
  512. package/.next/static/chunks/app/worktrees/[id]/files/[...path]/{page-5fed3984fafcd910.js → page-90f96977c741bbf8.js} +1 -1
  513. package/.next/static/chunks/app/worktrees/[id]/layout-6add0d88e2828c23.js +1 -0
  514. package/.next/static/chunks/app/worktrees/[id]/page-f7b3dfbe757dc6b8.js +1 -0
  515. package/.next/static/chunks/{webpack-9d892a9ff07c289d.js → webpack-6a9668cf54a26eba.js} +1 -1
  516. package/.next/static/css/928e5a8830fbf997.css +1 -0
  517. package/.next/trace +13 -12
  518. package/.next/types/app/api/capabilities/route.ts +347 -0
  519. package/.next/types/app/api/worktrees/[id]/clear-composer/route.ts +347 -0
  520. package/.next/types/app/api/worktrees/[id]/env/route.ts +347 -0
  521. package/.next/types/app/api/worktrees/[id]/resolve-target/route.ts +347 -0
  522. package/.next/types/routes.d.ts +5 -1
  523. package/.next/types/validator.ts +36 -0
  524. package/dist/cli/commands/auto-yes.d.ts.map +1 -1
  525. package/dist/cli/commands/auto-yes.js +40 -2
  526. package/dist/cli/commands/capture.d.ts.map +1 -1
  527. package/dist/cli/commands/capture.js +28 -13
  528. package/dist/cli/commands/instances.d.ts +30 -18
  529. package/dist/cli/commands/instances.d.ts.map +1 -1
  530. package/dist/cli/commands/instances.js +32 -36
  531. package/dist/cli/commands/ls.d.ts.map +1 -1
  532. package/dist/cli/commands/ls.js +73 -1
  533. package/dist/cli/commands/respond.d.ts.map +1 -1
  534. package/dist/cli/commands/respond.js +18 -1
  535. package/dist/cli/commands/send.d.ts.map +1 -1
  536. package/dist/cli/commands/send.js +21 -15
  537. package/dist/cli/commands/status.d.ts.map +1 -1
  538. package/dist/cli/commands/status.js +38 -0
  539. package/dist/cli/commands/wait.d.ts +26 -0
  540. package/dist/cli/commands/wait.d.ts.map +1 -1
  541. package/dist/cli/commands/wait.js +390 -43
  542. package/dist/cli/config/cli-dependencies.d.ts.map +1 -1
  543. package/dist/cli/config/cli-dependencies.js +16 -0
  544. package/dist/cli/config/cli-tool-ids.d.ts +11 -0
  545. package/dist/cli/config/cli-tool-ids.d.ts.map +1 -1
  546. package/dist/cli/config/cli-tool-ids.js +12 -1
  547. package/dist/cli/types/api-responses.d.ts +443 -2
  548. package/dist/cli/types/api-responses.d.ts.map +1 -1
  549. package/dist/cli/utils/api-client.d.ts +18 -0
  550. package/dist/cli/utils/api-client.d.ts.map +1 -1
  551. package/dist/cli/utils/api-client.js +22 -0
  552. package/dist/cli/utils/server-capabilities.d.ts +56 -0
  553. package/dist/cli/utils/server-capabilities.d.ts.map +1 -0
  554. package/dist/cli/utils/server-capabilities.js +166 -0
  555. package/dist/cli/utils/session-target.d.ts +70 -0
  556. package/dist/cli/utils/session-target.d.ts.map +1 -0
  557. package/dist/cli/utils/session-target.js +118 -0
  558. package/dist/lib/cli-tools/copilot-executable.d.ts +79 -0
  559. package/dist/lib/cli-tools/copilot-executable.d.ts.map +1 -0
  560. package/dist/lib/cli-tools/copilot-executable.js +155 -0
  561. package/dist/lib/cli-tools/types.d.ts +61 -0
  562. package/dist/lib/cli-tools/types.d.ts.map +1 -1
  563. package/dist/lib/cli-tools/types.js +41 -0
  564. package/dist/lib/detection/ansi.d.ts +2 -1
  565. package/dist/lib/detection/ansi.d.ts.map +1 -1
  566. package/dist/lib/detection/ansi.js +3 -2
  567. package/dist/lib/detection/tools/verified-against.d.ts +84 -0
  568. package/dist/lib/detection/tools/verified-against.d.ts.map +1 -0
  569. package/dist/lib/detection/tools/verified-against.js +88 -0
  570. package/dist/lib/detection/version-probes.d.ts +207 -0
  571. package/dist/lib/detection/version-probes.d.ts.map +1 -0
  572. package/dist/lib/detection/version-probes.js +290 -0
  573. package/dist/lib/security/env-sanitizer.d.ts +198 -0
  574. package/dist/lib/security/env-sanitizer.d.ts.map +1 -0
  575. package/dist/lib/security/env-sanitizer.js +232 -0
  576. package/dist/server/locales/en/notifications.json +17 -6
  577. package/dist/server/locales/ja/notifications.json +17 -6
  578. package/dist/server/src/config/activity-bar-config.js +4 -0
  579. package/dist/server/src/config/cli-tool-timing-config.js +59 -2
  580. package/dist/server/src/config/copilot-constants.js +11 -1
  581. package/dist/server/src/config/detection-evidence-config.js +129 -0
  582. package/dist/server/src/config/schedule-config.js +56 -7
  583. package/dist/server/src/config/tmux-pane-config.js +18 -1
  584. package/dist/server/src/lib/auto-yes-poller.js +36 -0
  585. package/dist/server/src/lib/cli-tools/antigravity.js +4 -2
  586. package/dist/server/src/lib/cli-tools/base.js +131 -10
  587. package/dist/server/src/lib/cli-tools/capture-spec.js +56 -0
  588. package/dist/server/src/lib/cli-tools/claude.js +1 -1
  589. package/dist/server/src/lib/cli-tools/codex.js +6 -2
  590. package/dist/server/src/lib/cli-tools/composer-spec.js +96 -0
  591. package/dist/server/src/lib/cli-tools/copilot-executable.js +155 -0
  592. package/dist/server/src/lib/cli-tools/copilot.js +307 -81
  593. package/dist/server/src/lib/cli-tools/gemini.js +8 -6
  594. package/dist/server/src/lib/cli-tools/graceful-exit.js +181 -0
  595. package/dist/server/src/lib/cli-tools/index.js +11 -1
  596. package/dist/server/src/lib/cli-tools/manager.js +56 -4
  597. package/dist/server/src/lib/cli-tools/opencode-config.js +195 -24
  598. package/dist/server/src/lib/cli-tools/opencode.js +233 -30
  599. package/dist/server/src/lib/cli-tools/session-name.js +57 -0
  600. package/dist/server/src/lib/cli-tools/submit-verified-sender.js +213 -30
  601. package/dist/server/src/lib/cli-tools/types.js +41 -0
  602. package/dist/server/src/lib/cli-tools/vibe-local.js +7 -3
  603. package/dist/server/src/lib/cmate-cli-tool-parser.js +29 -1
  604. package/dist/server/src/lib/cmate-parser.js +12 -4
  605. package/dist/server/src/lib/db/db.js +5 -1
  606. package/dist/server/src/lib/db/migrations/v41-push-subscriptions.js +11 -0
  607. package/dist/server/src/lib/db/push-subscriptions-db.js +60 -3
  608. package/dist/server/src/lib/detection/ansi.js +3 -2
  609. package/dist/server/src/lib/detection/cli-patterns.js +901 -67
  610. package/dist/server/src/lib/detection/composer-text.js +455 -0
  611. package/dist/server/src/lib/detection/idle-evidence-observation.js +51 -0
  612. package/dist/server/src/lib/detection/model-info-extractor.js +195 -4
  613. package/dist/server/src/lib/detection/prompt-detect-multiple-choice.js +19 -0
  614. package/dist/server/src/lib/detection/status-detector.js +76 -675
  615. package/dist/server/src/lib/detection/status-reason.js +57 -0
  616. package/dist/server/src/lib/detection/tools/antigravity/detect.js +75 -0
  617. package/dist/server/src/lib/detection/tools/claude/detect.js +144 -0
  618. package/dist/server/src/lib/detection/tools/claude/patterns.js +98 -0
  619. package/dist/server/src/lib/detection/tools/claude/prompt.js +124 -0
  620. package/dist/server/src/lib/detection/tools/codex/detect.js +343 -0
  621. package/dist/server/src/lib/detection/tools/codex/prompt.js +104 -0
  622. package/dist/server/src/lib/detection/tools/copilot/detect.js +185 -0
  623. package/dist/server/src/lib/detection/tools/copilot/prompt.js +89 -0
  624. package/dist/server/src/lib/detection/tools/dialog-block.js +159 -0
  625. package/dist/server/src/lib/detection/tools/frame.js +47 -0
  626. package/dist/server/src/lib/detection/tools/opencode/detect.js +242 -0
  627. package/dist/server/src/lib/detection/tools/opencode/prompt.js +85 -0
  628. package/dist/server/src/lib/detection/tools/registry.js +58 -0
  629. package/dist/server/src/lib/detection/tools/run-detection.js +202 -0
  630. package/dist/server/src/lib/detection/tools/types.js +34 -0
  631. package/dist/server/src/lib/detection/tools/verified-against.js +88 -0
  632. package/dist/server/src/lib/hooks/agent-event-types.js +19 -1
  633. package/dist/server/src/lib/hooks/permission-adjudication.js +160 -0
  634. package/dist/server/src/lib/hooks/permission-decision-service.js +81 -14
  635. package/dist/server/src/lib/hooks/permission-decision-state.js +62 -0
  636. package/dist/server/src/lib/hooks/permission-request-payload.js +18 -1
  637. package/dist/server/src/lib/hooks/sources/antigravity/source.js +10 -0
  638. package/dist/server/src/lib/hooks/sources/claude/source.js +20 -0
  639. package/dist/server/src/lib/hooks/sources/codex/source.js +10 -0
  640. package/dist/server/src/lib/hooks/sources/copilot/hook-settings.js +403 -50
  641. package/dist/server/src/lib/hooks/sources/copilot/source.js +40 -4
  642. package/dist/server/src/lib/hooks/sources/define-source.js +23 -1
  643. package/dist/server/src/lib/hooks/sources/event-mapper.js +29 -1
  644. package/dist/server/src/lib/hooks/sources/gemini/source.js +10 -0
  645. package/dist/server/src/lib/hooks/sources/index.js +3 -1
  646. package/dist/server/src/lib/hooks/sources/launch-command.js +96 -1
  647. package/dist/server/src/lib/hooks/sources/legacy-relay.js +12 -0
  648. package/dist/server/src/lib/hooks/sources/opencode/client.js +295 -32
  649. package/dist/server/src/lib/hooks/sources/opencode/ingest.js +120 -42
  650. package/dist/server/src/lib/hooks/sources/opencode/mappers.js +95 -3
  651. package/dist/server/src/lib/hooks/sources/opencode/ports.js +70 -9
  652. package/dist/server/src/lib/hooks/sources/opencode/runtime.js +62 -4
  653. package/dist/server/src/lib/hooks/sources/opencode/source.js +54 -3
  654. package/dist/server/src/lib/hooks/sources/opencode/subscription.js +254 -26
  655. package/dist/server/src/lib/hooks/sources/opencode/turn-gate.js +119 -4
  656. package/dist/server/src/lib/hooks/sources/pending-decisions.js +40 -2
  657. package/dist/server/src/lib/hooks/tool-input-normalization-state.js +67 -0
  658. package/dist/server/src/lib/hooks/tool-input-normalization.js +157 -0
  659. package/dist/server/src/lib/job-executor.js +16 -4
  660. package/dist/server/src/lib/polling/auto-yes-dialog-gate.js +184 -0
  661. package/dist/server/src/lib/polling/response-checker.js +243 -26
  662. package/dist/server/src/lib/push/failure-episode-state.js +127 -0
  663. package/dist/server/src/lib/push/failure-push-notifier.js +344 -0
  664. package/dist/server/src/lib/push/index.js +35 -1
  665. package/dist/server/src/lib/push/prompt-card-state.js +93 -0
  666. package/dist/server/src/lib/push/prompt-push-gate.js +130 -0
  667. package/dist/server/src/lib/push/push-sender.js +82 -7
  668. package/dist/server/src/lib/push/resolution-push-notifier.js +193 -0
  669. package/dist/server/src/lib/push/waiting-push-notifier.js +42 -0
  670. package/dist/server/src/lib/response-cleaner.js +93 -20
  671. package/dist/server/src/lib/response-extractor.js +98 -5
  672. package/dist/server/src/lib/security/env-sanitizer.js +179 -5
  673. package/dist/server/src/lib/session/agent-event-state.js +1038 -189
  674. package/dist/server/src/lib/session/agent-session-lifecycle.js +8 -0
  675. package/dist/server/src/lib/session/claude-executor.js +23 -3
  676. package/dist/server/src/lib/session/claude-session.js +11 -1
  677. package/dist/server/src/lib/session/composer-clear.js +95 -0
  678. package/dist/server/src/lib/session/current-output-builder.js +267 -25
  679. package/dist/server/src/lib/session/provisional-turn.js +310 -0
  680. package/dist/server/src/lib/session/resolve-session-target.js +156 -0
  681. package/dist/server/src/lib/session/send-user-message.js +14 -18
  682. package/dist/server/src/lib/session/session-start-error.js +53 -1
  683. package/dist/server/src/lib/session/status-evidence.js +217 -0
  684. package/dist/server/src/lib/session/structured-prompt.js +46 -4
  685. package/dist/server/src/lib/session/waiting-episode-state.js +24 -0
  686. package/dist/server/src/lib/tmux/key-sequence.js +120 -0
  687. package/dist/server/src/lib/tmux/tmux.js +91 -19
  688. package/dist/server/src/lib/tui-accumulator.js +68 -1
  689. package/dist/server/src/lib/verification/gate-runner.js +84 -1
  690. package/dist/server/src/lib/ws-server.js +8 -5
  691. package/dist/server/src/types/cli-tool-contracts.js +75 -0
  692. package/dist/server/src/types/terminal-keys.js +37 -0
  693. package/dist/types/cli-tool-contracts.d.ts +235 -0
  694. package/dist/types/cli-tool-contracts.d.ts.map +1 -0
  695. package/dist/types/cli-tool-contracts.js +75 -0
  696. package/package.json +3 -2
  697. package/public/sw.js +65 -2
  698. package/.next/server/chunks/1841.js +0 -1
  699. package/.next/server/chunks/233.js +0 -1
  700. package/.next/server/chunks/3022.js +0 -1
  701. package/.next/server/chunks/3270.js +0 -1
  702. package/.next/server/chunks/4455.js +0 -1
  703. package/.next/server/chunks/5959.js +0 -27
  704. package/.next/server/chunks/7458.js +0 -6
  705. package/.next/server/chunks/8730.js +0 -1
  706. package/.next/server/chunks/9058.js +0 -1
  707. package/.next/server/chunks/9687.js +0 -3
  708. package/.next/static/chunks/3898-ef488bfa804507d9.js +0 -1
  709. package/.next/static/chunks/9263.f2034ec525abcf72.js +0 -1
  710. package/.next/static/chunks/app/api/app/update/route-fae89f8d4cc3ff97.js +0 -1
  711. package/.next/static/chunks/app/api/app/update-check/route-fae89f8d4cc3ff97.js +0 -1
  712. package/.next/static/chunks/app/api/assistant/conversation/route-fae89f8d4cc3ff97.js +0 -1
  713. package/.next/static/chunks/app/api/assistant/current-output/route-fae89f8d4cc3ff97.js +0 -1
  714. package/.next/static/chunks/app/api/assistant/messages/route-fae89f8d4cc3ff97.js +0 -1
  715. package/.next/static/chunks/app/api/assistant/session/route-fae89f8d4cc3ff97.js +0 -1
  716. package/.next/static/chunks/app/api/assistant/start/route-fae89f8d4cc3ff97.js +0 -1
  717. package/.next/static/chunks/app/api/assistant/terminal/route-fae89f8d4cc3ff97.js +0 -1
  718. package/.next/static/chunks/app/api/assistant/tools/route-fae89f8d4cc3ff97.js +0 -1
  719. package/.next/static/chunks/app/api/auth/login/route-fae89f8d4cc3ff97.js +0 -1
  720. package/.next/static/chunks/app/api/auth/logout/route-fae89f8d4cc3ff97.js +0 -1
  721. package/.next/static/chunks/app/api/auth/status/route-fae89f8d4cc3ff97.js +0 -1
  722. package/.next/static/chunks/app/api/daily-summary/route-fae89f8d4cc3ff97.js +0 -1
  723. package/.next/static/chunks/app/api/daily-summary/status/route-fae89f8d4cc3ff97.js +0 -1
  724. package/.next/static/chunks/app/api/external-apps/[id]/health/route-fae89f8d4cc3ff97.js +0 -1
  725. package/.next/static/chunks/app/api/external-apps/[id]/route-fae89f8d4cc3ff97.js +0 -1
  726. package/.next/static/chunks/app/api/external-apps/route-fae89f8d4cc3ff97.js +0 -1
  727. package/.next/static/chunks/app/api/fs/browse/route-fae89f8d4cc3ff97.js +0 -1
  728. package/.next/static/chunks/app/api/fs/recent-paths/route-fae89f8d4cc3ff97.js +0 -1
  729. package/.next/static/chunks/app/api/hooks/agent-event/route-fae89f8d4cc3ff97.js +0 -1
  730. package/.next/static/chunks/app/api/hooks/claude-done/route-fae89f8d4cc3ff97.js +0 -1
  731. package/.next/static/chunks/app/api/hooks/permission-request/route-fae89f8d4cc3ff97.js +0 -1
  732. package/.next/static/chunks/app/api/metrics/vibe/route-fae89f8d4cc3ff97.js +0 -1
  733. package/.next/static/chunks/app/api/ollama/models/route-fae89f8d4cc3ff97.js +0 -1
  734. package/.next/static/chunks/app/api/push/escalation/route-fae89f8d4cc3ff97.js +0 -1
  735. package/.next/static/chunks/app/api/push/subscriptions/route-fae89f8d4cc3ff97.js +0 -1
  736. package/.next/static/chunks/app/api/push/vapid/route-fae89f8d4cc3ff97.js +0 -1
  737. package/.next/static/chunks/app/api/repositories/[id]/route-fae89f8d4cc3ff97.js +0 -1
  738. package/.next/static/chunks/app/api/repositories/[id]/todos/[todoId]/route-fae89f8d4cc3ff97.js +0 -1
  739. package/.next/static/chunks/app/api/repositories/[id]/todos/route-fae89f8d4cc3ff97.js +0 -1
  740. package/.next/static/chunks/app/api/repositories/clone/[jobId]/route-fae89f8d4cc3ff97.js +0 -1
  741. package/.next/static/chunks/app/api/repositories/clone/route-fae89f8d4cc3ff97.js +0 -1
  742. package/.next/static/chunks/app/api/repositories/excluded/route-fae89f8d4cc3ff97.js +0 -1
  743. package/.next/static/chunks/app/api/repositories/restore/route-fae89f8d4cc3ff97.js +0 -1
  744. package/.next/static/chunks/app/api/repositories/route-fae89f8d4cc3ff97.js +0 -1
  745. package/.next/static/chunks/app/api/repositories/scan/route-fae89f8d4cc3ff97.js +0 -1
  746. package/.next/static/chunks/app/api/repositories/sync/route-fae89f8d4cc3ff97.js +0 -1
  747. package/.next/static/chunks/app/api/repositories/validate-path/route-fae89f8d4cc3ff97.js +0 -1
  748. package/.next/static/chunks/app/api/sidebar/group-order/route-fae89f8d4cc3ff97.js +0 -1
  749. package/.next/static/chunks/app/api/skills/[id]/route-fae89f8d4cc3ff97.js +0 -1
  750. package/.next/static/chunks/app/api/skills/installations/route-fae89f8d4cc3ff97.js +0 -1
  751. package/.next/static/chunks/app/api/skills/operations/route-fae89f8d4cc3ff97.js +0 -1
  752. package/.next/static/chunks/app/api/skills/reindex/route-fae89f8d4cc3ff97.js +0 -1
  753. package/.next/static/chunks/app/api/skills/route-fae89f8d4cc3ff97.js +0 -1
  754. package/.next/static/chunks/app/api/slash-commands/route-fae89f8d4cc3ff97.js +0 -1
  755. package/.next/static/chunks/app/api/tasks/[taskId]/cancel/route-fae89f8d4cc3ff97.js +0 -1
  756. package/.next/static/chunks/app/api/tasks/[taskId]/route-fae89f8d4cc3ff97.js +0 -1
  757. package/.next/static/chunks/app/api/templates/[id]/route-fae89f8d4cc3ff97.js +0 -1
  758. package/.next/static/chunks/app/api/templates/route-fae89f8d4cc3ff97.js +0 -1
  759. package/.next/static/chunks/app/api/todos/route-fae89f8d4cc3ff97.js +0 -1
  760. package/.next/static/chunks/app/api/verification/runs/[runId]/route-fae89f8d4cc3ff97.js +0 -1
  761. package/.next/static/chunks/app/api/verification/runs/route-fae89f8d4cc3ff97.js +0 -1
  762. package/.next/static/chunks/app/api/worktrees/[id]/auto-yes/route-fae89f8d4cc3ff97.js +0 -1
  763. package/.next/static/chunks/app/api/worktrees/[id]/capture/route-fae89f8d4cc3ff97.js +0 -1
  764. package/.next/static/chunks/app/api/worktrees/[id]/cli-tool/route-fae89f8d4cc3ff97.js +0 -1
  765. package/.next/static/chunks/app/api/worktrees/[id]/cmate/schedules/route-fae89f8d4cc3ff97.js +0 -1
  766. package/.next/static/chunks/app/api/worktrees/[id]/current-output/route-fae89f8d4cc3ff97.js +0 -1
  767. package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/[logId]/route-fae89f8d4cc3ff97.js +0 -1
  768. package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/route-fae89f8d4cc3ff97.js +0 -1
  769. package/.next/static/chunks/app/api/worktrees/[id]/files/[...path]/route-fae89f8d4cc3ff97.js +0 -1
  770. package/.next/static/chunks/app/api/worktrees/[id]/git/branch/create/route-fae89f8d4cc3ff97.js +0 -1
  771. package/.next/static/chunks/app/api/worktrees/[id]/git/branch/delete/route-fae89f8d4cc3ff97.js +0 -1
  772. package/.next/static/chunks/app/api/worktrees/[id]/git/branches/route-fae89f8d4cc3ff97.js +0 -1
  773. package/.next/static/chunks/app/api/worktrees/[id]/git/checkout/route-fae89f8d4cc3ff97.js +0 -1
  774. package/.next/static/chunks/app/api/worktrees/[id]/git/commit/route-fae89f8d4cc3ff97.js +0 -1
  775. package/.next/static/chunks/app/api/worktrees/[id]/git/diff/route-fae89f8d4cc3ff97.js +0 -1
  776. package/.next/static/chunks/app/api/worktrees/[id]/git/fetch/route-fae89f8d4cc3ff97.js +0 -1
  777. package/.next/static/chunks/app/api/worktrees/[id]/git/log/route-fae89f8d4cc3ff97.js +0 -1
  778. package/.next/static/chunks/app/api/worktrees/[id]/git/pull/route-fae89f8d4cc3ff97.js +0 -1
  779. package/.next/static/chunks/app/api/worktrees/[id]/git/push/route-fae89f8d4cc3ff97.js +0 -1
  780. package/.next/static/chunks/app/api/worktrees/[id]/git/reset/route-fae89f8d4cc3ff97.js +0 -1
  781. package/.next/static/chunks/app/api/worktrees/[id]/git/revert/route-fae89f8d4cc3ff97.js +0 -1
  782. package/.next/static/chunks/app/api/worktrees/[id]/git/show/[commitHash]/route-fae89f8d4cc3ff97.js +0 -1
  783. package/.next/static/chunks/app/api/worktrees/[id]/git/stage/route-fae89f8d4cc3ff97.js +0 -1
  784. package/.next/static/chunks/app/api/worktrees/[id]/git/staged/route-fae89f8d4cc3ff97.js +0 -1
  785. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/[index]/route-fae89f8d4cc3ff97.js +0 -1
  786. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/apply/route-fae89f8d4cc3ff97.js +0 -1
  787. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/pop/route-fae89f8d4cc3ff97.js +0 -1
  788. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/push/route-fae89f8d4cc3ff97.js +0 -1
  789. package/.next/static/chunks/app/api/worktrees/[id]/git/stash/route-fae89f8d4cc3ff97.js +0 -1
  790. package/.next/static/chunks/app/api/worktrees/[id]/git/status/route-fae89f8d4cc3ff97.js +0 -1
  791. package/.next/static/chunks/app/api/worktrees/[id]/git/unstage/route-fae89f8d4cc3ff97.js +0 -1
  792. package/.next/static/chunks/app/api/worktrees/[id]/git/working-diff/route-fae89f8d4cc3ff97.js +0 -1
  793. package/.next/static/chunks/app/api/worktrees/[id]/interrupt/route-fae89f8d4cc3ff97.js +0 -1
  794. package/.next/static/chunks/app/api/worktrees/[id]/kill-session/route-fae89f8d4cc3ff97.js +0 -1
  795. package/.next/static/chunks/app/api/worktrees/[id]/logs/[filename]/route-fae89f8d4cc3ff97.js +0 -1
  796. package/.next/static/chunks/app/api/worktrees/[id]/logs/route-fae89f8d4cc3ff97.js +0 -1
  797. package/.next/static/chunks/app/api/worktrees/[id]/marp-render/route-fae89f8d4cc3ff97.js +0 -1
  798. package/.next/static/chunks/app/api/worktrees/[id]/memos/[memoId]/route-fae89f8d4cc3ff97.js +0 -1
  799. package/.next/static/chunks/app/api/worktrees/[id]/memos/route-fae89f8d4cc3ff97.js +0 -1
  800. package/.next/static/chunks/app/api/worktrees/[id]/messages/route-fae89f8d4cc3ff97.js +0 -1
  801. package/.next/static/chunks/app/api/worktrees/[id]/prompt-response/route-fae89f8d4cc3ff97.js +0 -1
  802. package/.next/static/chunks/app/api/worktrees/[id]/respond/route-fae89f8d4cc3ff97.js +0 -1
  803. package/.next/static/chunks/app/api/worktrees/[id]/route-fae89f8d4cc3ff97.js +0 -1
  804. package/.next/static/chunks/app/api/worktrees/[id]/schedules/[scheduleId]/route-fae89f8d4cc3ff97.js +0 -1
  805. package/.next/static/chunks/app/api/worktrees/[id]/schedules/active/route-fae89f8d4cc3ff97.js +0 -1
  806. package/.next/static/chunks/app/api/worktrees/[id]/schedules/route-fae89f8d4cc3ff97.js +0 -1
  807. package/.next/static/chunks/app/api/worktrees/[id]/search/route-fae89f8d4cc3ff97.js +0 -1
  808. package/.next/static/chunks/app/api/worktrees/[id]/send/route-fae89f8d4cc3ff97.js +0 -1
  809. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route-fae89f8d4cc3ff97.js +0 -1
  810. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/install/route-fae89f8d4cc3ff97.js +0 -1
  811. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/plan/route-fae89f8d4cc3ff97.js +0 -1
  812. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall/route-fae89f8d4cc3ff97.js +0 -1
  813. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route-fae89f8d4cc3ff97.js +0 -1
  814. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/update/route-fae89f8d4cc3ff97.js +0 -1
  815. package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/update-plan/route-fae89f8d4cc3ff97.js +0 -1
  816. package/.next/static/chunks/app/api/worktrees/[id]/skills/route-fae89f8d4cc3ff97.js +0 -1
  817. package/.next/static/chunks/app/api/worktrees/[id]/slash-commands/route-fae89f8d4cc3ff97.js +0 -1
  818. package/.next/static/chunks/app/api/worktrees/[id]/special-keys/route-fae89f8d4cc3ff97.js +0 -1
  819. package/.next/static/chunks/app/api/worktrees/[id]/start-polling/route-fae89f8d4cc3ff97.js +0 -1
  820. package/.next/static/chunks/app/api/worktrees/[id]/tasks/route-fae89f8d4cc3ff97.js +0 -1
  821. package/.next/static/chunks/app/api/worktrees/[id]/terminal/route-fae89f8d4cc3ff97.js +0 -1
  822. package/.next/static/chunks/app/api/worktrees/[id]/timers/history/route-fae89f8d4cc3ff97.js +0 -1
  823. package/.next/static/chunks/app/api/worktrees/[id]/timers/route-fae89f8d4cc3ff97.js +0 -1
  824. package/.next/static/chunks/app/api/worktrees/[id]/todos/[todoId]/route-fae89f8d4cc3ff97.js +0 -1
  825. package/.next/static/chunks/app/api/worktrees/[id]/todos/route-fae89f8d4cc3ff97.js +0 -1
  826. package/.next/static/chunks/app/api/worktrees/[id]/tree/[...path]/route-fae89f8d4cc3ff97.js +0 -1
  827. package/.next/static/chunks/app/api/worktrees/[id]/tree/route-fae89f8d4cc3ff97.js +0 -1
  828. package/.next/static/chunks/app/api/worktrees/[id]/upload/[...path]/route-fae89f8d4cc3ff97.js +0 -1
  829. package/.next/static/chunks/app/api/worktrees/[id]/verify/route-fae89f8d4cc3ff97.js +0 -1
  830. package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/[runId]/route-fae89f8d4cc3ff97.js +0 -1
  831. package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/route-fae89f8d4cc3ff97.js +0 -1
  832. package/.next/static/chunks/app/api/worktrees/[id]/viewed/route-fae89f8d4cc3ff97.js +0 -1
  833. package/.next/static/chunks/app/api/worktrees/route-fae89f8d4cc3ff97.js +0 -1
  834. package/.next/static/chunks/app/manifest.webmanifest/route-fae89f8d4cc3ff97.js +0 -1
  835. package/.next/static/chunks/app/proxy/[...path]/route-fae89f8d4cc3ff97.js +0 -1
  836. package/.next/static/chunks/app/worktrees/[id]/layout-fae89f8d4cc3ff97.js +0 -1
  837. package/.next/static/chunks/app/worktrees/[id]/page-fdfca039b7f5837e.js +0 -1
  838. package/.next/static/css/e865c4979a41aa03.css +0 -1
  839. package/.next/static/wyFLOpmKpr45BHZ4svYpE/_buildManifest.js +0 -1
  840. /package/.next/static/{wyFLOpmKpr45BHZ4svYpE → 9IXgWfBUtnEnRqnbmErTp}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1479],{8269:(e,t,n)=>{"use strict";n.d(t,{hU:()=>r});var a=n(12115);function r(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{onSwipeLeft:t,onSwipeRight:n,onSwipeUp:r,onSwipeDown:s,threshold:l=50,enabled:i=!0,axis:o="both",directionLock:c,directionLockThreshold:d=12,suppressWhenScrollable:u=!0,edgeStartZone:m=0,onSwipeMove:h,onSwipeEnd:x}=e,f=null!=c?c:"both"!==o,p="horizontal"===o?"horizontal":"vertical",g="both"===o||"horizontal"===o,b="both"===o||"vertical"===o,v=(0,a.useRef)(null),[y,j]=(0,a.useState)(!1),[w,k]=(0,a.useState)(null),N=(0,a.useRef)(null),C=(0,a.useRef)(null),S=(0,a.useCallback)(()=>{k(null)},[]),T=(0,a.useCallback)(e=>{if(!i)return;if(u&&e.target instanceof HTMLElement&&function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"vertical",n=e;for(;n;){let e=getComputedStyle(n);if("horizontal"===t){let{overflowX:t}=e;if(("auto"===t||"scroll"===t)&&n.scrollWidth>n.clientWidth)return!0}else{let{overflowY:t}=e;if(("auto"===t||"scroll"===t)&&n.scrollHeight>n.clientHeight)return!0}n=n.parentElement}return!1}(e.target,p)){N.current=null;return}let t=e.touches[0];if(m>0&&v.current){let e=v.current.getBoundingClientRect(),n=t.clientX-e.left,a=e.right-t.clientX;if(n>m&&a>m){N.current=null;return}}N.current={x:t.clientX,y:t.clientY},C.current={committed:null,cancelled:!1},j(!0)},[i,u,p,m]),E=(0,a.useCallback)(e=>{if(!i||!N.current)return;let t=e.touches[0],n=t.clientX-N.current.x,a=t.clientY-N.current.y,r=Math.abs(n),s=Math.abs(a);if(f){let e=C.current;if(e){if(e.cancelled)return;if(null===e.committed&&Math.max(r,s)>=d){let t=r>s?"horizontal":"vertical";if(e.committed=t,t!==o){e.cancelled=!0;return}}if(null!==e.committed&&e.committed!==o)return}}g&&r>s&&r>=l?k(n<0?"left":"right"):b&&s>=l&&k(a<0?"up":"down"),null==h||h({deltaX:n,deltaY:a})},[i,l,o,f,d,g,b,h]),I=(0,a.useCallback)(e=>{var a;if(!i||!N.current)return void j(!1);let o=f&&(null==(a=C.current)?void 0:a.cancelled)===!0,c=e.changedTouches[0];if(!o&&c){let e=c.clientX-N.current.x,a=c.clientY-N.current.y,i=Math.abs(e),o=Math.abs(a);i>o?g&&i>=l&&(e<0?(k("left"),null==t||t()):(k("right"),null==n||n())):b&&o>=l&&(a<0?(k("up"),null==r||r()):(k("down"),null==s||s()))}N.current=null,C.current=null,j(!1),null==x||x()},[i,l,f,g,b,t,n,r,s,x]),M=(0,a.useCallback)(()=>{N.current&&(N.current=null,C.current=null,j(!1),null==x||x())},[x]);return(0,a.useEffect)(()=>{let e=v.current;if(e)return e.addEventListener("touchstart",T),e.addEventListener("touchmove",E),e.addEventListener("touchend",I),e.addEventListener("touchcancel",M),()=>{e.removeEventListener("touchstart",T),e.removeEventListener("touchmove",E),e.removeEventListener("touchend",I),e.removeEventListener("touchcancel",M)}},[T,E,I,M]),{ref:v,isSwiping:y,swipeDirection:w,resetSwipeDirection:S}}},11063:(e,t,n)=>{"use strict";n.d(t,{Ko:()=>r,j6:()=>a}),n(19985);let a=5242880,r={safe:"",interactive:"allow-scripts"}},17846:(e,t,n)=>{"use strict";n.d(t,{a:()=>l});var a=n(95155),r=n(12115),s=n(18955);function l(e){let{src:t,alt:n,onError:l}=e,i=(0,s.c)("worktree"),[o,c]=(0,r.useState)(!1);return o?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,a.jsx)("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),(0,a.jsx)("p",{className:"text-sm",children:i("imageViewer.loadError")}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:n})]}):(0,a.jsx)("div",{className:"flex items-center justify-center p-4",children:(0,a.jsx)("img",{src:t,alt:n,onError:()=>{c(!0),null==l||l()},style:{maxWidth:"100%",maxHeight:"500px",objectFit:"contain"},className:"rounded-lg shadow-sm"})})}},19985:(e,t,n)=>{"use strict";n.d(t,{F5:()=>i,Fg:()=>a,HB:()=>s,Hv:()=>l});let a=0x1400000,r=[{extension:".png",mimeType:"image/png",magicBytes:[137,80,78,71]},{extension:".jpg",mimeType:"image/jpeg",magicBytes:[255,216,255]},{extension:".jpeg",mimeType:"image/jpeg",magicBytes:[255,216,255]},{extension:".gif",mimeType:"image/gif",magicBytes:[71,73,70,56]},{extension:".webp",mimeType:"image/webp",magicBytes:[82,73,70,70]},{extension:".svg",mimeType:"image/svg+xml"}];function s(e){return e?e.startsWith(".")?e.toLowerCase():"."+e.toLowerCase():""}let l=[".png",".jpg",".jpeg",".gif",".webp",".svg"].filter(e=>".svg"!==e),i=l.map(e=>(function(e){let t=s(e),n=r.find(e=>e.extension===t);return(null==n?void 0:n.mimeType)||"application/octet-stream"})(e)).filter(e=>"application/octet-stream"!==e).join(",")},20252:(e,t,n)=>{Promise.resolve().then(n.bind(n,62492))},27307:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PdfPreview:()=>o,default:()=>c});var a=n(95155),r=n(12115),s=n(18955);n(19985);let l=void 0;var i=n(3005);function o(e){let{dataUri:t,filePath:n,variant:o="iframe"}=e,[c,d]=(0,r.useState)(null),[u,m]=(0,r.useState)(!1),h=(0,s.c)("worktree");if((0,r.useEffect)(()=>{let e=!1,n=null;return d(null),m(!1),(async()=>{try{let a=await fetch(t);if(!a.ok)throw Error("fetch failed: ".concat(a.status));let r=await a.blob();if(e)return;n=URL.createObjectURL(r),d(n)}catch(t){if(e)return;m(!0)}})(),()=>{e=!0,n&&URL.revokeObjectURL(n)}},[t,n]),u)return(0,a.jsxs)("div",{className:"h-full flex flex-col items-center justify-center gap-3 p-6 text-center","data-testid":"pdf-preview-error",children:[(0,a.jsx)("p",{className:"text-sm text-danger-foreground",children:h("pdfPreview.loadError")}),(0,a.jsx)("a",{href:t,download:n.split("/").pop()||"document.pdf",className:"inline-flex items-center gap-2 px-4 py-2 rounded-md border border-input text-sm text-foreground hover:bg-muted",rel:"noopener",children:h("pdfPreview.downloadPdf")})]});if(!c)return(0,a.jsx)("div",{className:"h-full flex items-center justify-center","data-testid":"pdf-preview-loading",children:(0,a.jsx)(i.y,{size:"xl",variant:"accent"})});if("download"===o){let e=n.split("/").pop()||"document.pdf";return(0,a.jsxs)("div",{className:"h-full flex flex-col items-center justify-center gap-4 p-6 text-center","data-testid":"pdf-preview-download",children:[(0,a.jsx)("svg",{className:"w-16 h-16 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,a.jsx)("p",{className:"text-sm text-foreground break-all",children:e}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 w-full max-w-xs",children:[(0,a.jsx)("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center gap-2 px-6 py-3 rounded-lg bg-accent-600 hover:bg-accent-700 active:bg-accent-800 text-white text-sm font-medium transition-colors",children:h("pdfPreview.openInNewTab")}),(0,a.jsx)("a",{href:c,download:e,className:"inline-flex items-center justify-center gap-2 px-6 py-2 rounded-lg border border-input text-sm text-foreground hover:bg-muted transition-colors",children:h("pdfPreview.download")})]})]})}return(0,a.jsx)("iframe",{src:c,sandbox:l,title:h("pdfPreview.title",{path:n}),className:"w-full h-full border-0 bg-white","data-testid":"pdf-preview-iframe"})}let c=o},46892:(e,t,n)=>{"use strict";n.d(t,{PL:()=>r,sb:()=>s});let a={idle:"bg-muted-foreground",ready:"bg-success",spinner:"border-info",waiting:"bg-warning"},r={idle:{className:a.idle,labelKey:"status.idle",type:"dot"},ready:{className:a.ready,labelKey:"status.ready",type:"dot"},running:{className:a.spinner,labelKey:"status.running",type:"spinner"},waiting:{className:a.waiting,labelKey:"status.waiting",type:"dot"},generating:{className:a.spinner,labelKey:"status.generating",type:"spinner"}},s={idle:"detailStatus.idle",ready:"detailStatus.ready",running:"detailStatus.running",waiting:"detailStatus.waiting"}},50857:(e,t,n)=>{"use strict";function a(e){return"running"===e||"generating"===e||"waiting"===e}function r(e){return e.isActive||a(e.status)}function s(e,t){let n=e.map((e,t)=>({it:e,index:t})).filter(e=>{let{it:t}=e;return r(t)}),a=new Set;return t>0&&n.length>0&&[...n].sort((e,t)=>Number(t.it.isActive)-Number(e.it.isActive)||e.index-t.index).slice(0,t).forEach(e=>{let{index:t}=e;return a.add(t)}),e.map((e,t)=>r(e)?{...e,slot:a.has(t)?"pill":"overflow"}:{...e,slot:"dot"})}n.d(t,{Qo:()=>a,Uw:()=>s})},51434:(e,t,n)=>{"use strict";n.d(t,{C:()=>r});var a=n(12115);function r(){let[e,t]=(0,a.useState)(!1),[n,r]=(0,a.useState)(0),[s,l]=(0,a.useState)(null),i=(0,a.useCallback)(()=>{if(null==window.visualViewport)return;let e=window.visualViewport,n=window.innerHeight,a=e.height,s=n-a,i=s>100;t(i),r(i?s:0),l(a)},[]);return(0,a.useEffect)(()=>{if(null==window.visualViewport)return;let e=window.visualViewport;return i(),e.addEventListener("resize",i),()=>{e.removeEventListener("resize",i)}},[i]),{isKeyboardVisible:e,keyboardHeight:n,viewportHeight:s}}},53292:(e,t,n)=>{"use strict";n.d(t,{Ll:()=>a,bu:()=>r});let a=2e3,r=4e3},60850:(e,t,n)=>{"use strict";n.d(t,{U:()=>r});var a=n(12115);function r(e){let{value:t,saveFn:n,debounceMs:r=300,disabled:s=!1,maxRetries:l=3,onSaveComplete:i}=e,[o,c]=(0,a.useState)(!1),[d,u]=(0,a.useState)(null),m=(0,a.useRef)(t),h=(0,a.useRef)(n),x=(0,a.useRef)(i),f=(0,a.useRef)(null),p=(0,a.useRef)(!0),g=(0,a.useRef)(t);(0,a.useEffect)(()=>{m.current=t},[t]),(0,a.useEffect)(()=>{h.current=n},[n]),(0,a.useEffect)(()=>{x.current=i},[i]),(0,a.useEffect)(()=>(p.current=!0,()=>{p.current=!1,f.current&&clearTimeout(f.current)}),[]);let b=(0,a.useCallback)(async e=>{if(!p.current)return;c(!0),u(null);let t=null,n=0;for(;n<=l;)try{if(await h.current(e),p.current){var a;c(!1),u(null),null==(a=x.current)||a.call(x)}return}catch(e){if(t=e instanceof Error?e:Error(String(e)),++n<=l){let e=1e3*Math.pow(2,n-1);await new Promise(t=>setTimeout(t,e))}}p.current&&(c(!1),u(t))},[l]),v=(0,a.useCallback)(()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]),y=(0,a.useCallback)(async()=>{s||(v(),await b(m.current))},[s,v,b]);return(0,a.useEffect)(()=>{if(t!==g.current&&!s)return v(),f.current=setTimeout(()=>{b(m.current)},r),()=>{v()}},[t,s,r,v,b]),{isSaving:o,error:d,saveNow:y}}},62492:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>iE});var a,r=n(95155),s=n(20063),l=n(15229),i=n(12115),o=n(67909),c=n(18955),d=n(37772),u=n(3005),m=n(43361),h=n(48481),x=n(64269);let f=(0,i.memo)(function(e){let{path:t,className:n="w-6 h-6"}=e;return(0,r.jsx)("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:t})})}),p={back:"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",menu:"M4 6h16M4 12h16M4 18h16"};function g(e){let{worktreeName:t,repositoryName:n,status:a,gitStatus:s,onBackClick:l,onMenuClick:i}=e,o=(0,c.c)("common"),d=(0,c.c)("worktree");return(0,r.jsx)("header",{"data-testid":"mobile-header",role:"banner",className:"sticky top-0 inset-x-0 bg-surface border-b border-border shadow-sm pt-safe z-40",children:(0,r.jsxs)("div",{className:"flex items-center justify-between h-14 px-4",children:[(0,r.jsx)("div",{className:"w-10 flex-shrink-0",children:l&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:l,"aria-label":o("back"),className:"p-2 -ml-2 rounded-full hover:bg-muted transition-colors dark:text-foreground",children:(0,r.jsx)(f,{path:p.back})})}),(0,r.jsxs)("div",{className:"flex-1 flex items-center justify-center min-w-0 px-2",children:[(0,r.jsx)(h.m,{"data-testid":"status-indicator",status:a,size:"sm",className:"mr-2"}),(0,r.jsxs)("div",{className:"flex flex-col items-center min-w-0",children:[(0,r.jsx)("h1",{role:"heading","data-testid":"worktree-name",title:t,className:"text-sm font-medium text-foreground truncate text-center leading-tight",children:t}),(0,r.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[n&&(0,r.jsx)("span",{className:"truncate max-w-[100px] text-center",children:n}),s&&"(unknown)"!==s.currentBranch&&(0,r.jsxs)(r.Fragment,{children:[n&&(0,r.jsx)("span",{className:"text-muted-foreground/50",children:"/"}),(0,r.jsx)("span",{className:"truncate max-w-[80px] font-mono",title:s.currentBranch,"data-testid":"mobile-branch-name",children:(0,x.W5)(s.currentBranch,20)}),s.isDirty&&(0,r.jsx)("span",{className:"text-warning",title:d("git.uncommittedChanges"),children:"*"})]})]})]})]}),(0,r.jsx)("div",{className:"w-10 flex-shrink-0 flex justify-end",children:i&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:i,"aria-label":o("menu"),className:"p-2 -mr-2 rounded-full hover:bg-muted transition-colors dark:text-foreground",children:(0,r.jsx)(f,{path:p.menu})})})]})})}var b=n(22479),v=n(26983),y=n(59847),j=n(53842),w=n(23327);function k(e){let{"data-testid":t,"aria-label":n,className:a=""}=e;return(0,r.jsx)("span",{"data-testid":t,className:"w-2 h-2 rounded-full bg-accent-500 ".concat(a).trim(),"aria-label":n})}let N=[{id:"terminal",labelKey:"tabs.terminal",icon:(0,r.jsx)(b.A,{size:20,"aria-hidden":"true"})},{id:"history",labelKey:"tabs.history",icon:(0,r.jsx)(v.A,{size:20,"aria-hidden":"true"})},{id:"files",labelKey:"tabs.files",icon:(0,r.jsx)(y.A,{size:20,"aria-hidden":"true"})},{id:"memo",labelKey:"tabs.memo",icon:(0,r.jsx)(j.A,{size:20,"aria-hidden":"true"})},{id:"info",labelKey:"tabs.info",icon:(0,r.jsx)(w.A,{size:20,"aria-hidden":"true"})}];function C(e){let{activeTab:t,onTabChange:n,hasNewOutput:a=!1,hasPrompt:s=!1,hasUpdate:l=!1,onSearchParamsChange:o,inFlow:d=!1}=e,u=(0,c.c)("worktree"),m=(0,i.useRef)([]),h=(0,i.useCallback)(e=>{let n=e===t;return"".concat("flex flex-col items-center justify-center flex-1 min-h-[44px] py-2 px-1 transition-colors relative touch-manipulation"," ").concat(n?"text-accent-600 dark:text-accent-400":"text-muted-foreground hover:text-foreground")},[t]),x=(0,i.useCallback)(e=>{n(e),null==o||o("memo"===e?"notes":e)},[n,o]),f=(0,i.useCallback)((e,t)=>{var n;let a=null;switch(e.key){case"ArrowRight":case"ArrowDown":a=(t+1)%N.length;break;case"ArrowLeft":case"ArrowUp":a=(t-1+N.length)%N.length;break;case"Home":a=0;break;case"End":a=N.length-1;break;default:return}e.preventDefault(),null==(n=m.current[a])||n.focus(),x(N[a].id)},[x]),p=(0,i.useMemo)(()=>(0,r.jsxs)(r.Fragment,{children:[a&&(0,r.jsx)("span",{"data-testid":"new-output-badge",className:"absolute top-1 right-1 w-2 h-2 bg-success rounded-full","aria-label":u("tabs.newOutput")}),s&&(0,r.jsx)("span",{"data-testid":"prompt-badge",className:"absolute top-1 right-3 w-2 h-2 bg-warning rounded-full","aria-label":u("tabs.promptWaiting")})]}),[a,s,u]);return(0,r.jsx)("nav",{"data-testid":"mobile-tab-bar",role:"tablist","aria-label":u("tabs.ariaLabel"),className:"".concat(d?"flex-shrink-0":"fixed bottom-0"," inset-x-0 border-t border-border bg-background supports-[backdrop-filter]:bg-background/80 backdrop-blur-md flex pb-safe z-40"),children:N.map((e,n)=>(0,r.jsxs)("button",{ref:e=>{m.current[n]=e},type:"button","data-testid":"mobile-tab-".concat(e.id),role:"tab","aria-selected":t===e.id,"aria-label":u(e.labelKey),tabIndex:t===e.id?0:-1,onClick:()=>x(e.id),onKeyDown:e=>f(e,n),className:h(e.id),children:[t===e.id&&(0,r.jsx)("span",{"aria-hidden":"true",className:"absolute top-0 inset-x-2 h-0.5 rounded-full bg-accent-500"}),e.icon,(0,r.jsx)("span",{className:"text-xs mt-1 whitespace-nowrap",children:u(e.labelKey)}),"terminal"===e.id&&p,"info"===e.id&&l&&(0,r.jsx)(k,{"data-testid":"info-update-badge",className:"absolute top-1 right-1","aria-label":u("tabs.updateAvailable")})]},e.id))})}function S(e){return null!=e&&"unclassified"!==e.type}class T extends i.Component{static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){var n,a;console.error("[ErrorBoundary:".concat(this.props.componentName||"unknown","]"),e,t),null==(n=(a=this.props).onError)||n.call(a,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,r.jsx)(E,{componentName:this.props.componentName,error:this.state.error,onRetry:this.handleRetry}):this.props.children}constructor(e){super(e),this.handleRetry=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}}function E(e){let{componentName:t,error:n,onRetry:a}=e,s=(0,c.c)("error"),l=(0,c.c)("common");return(0,r.jsxs)("div",{className:"p-4 bg-danger-subtle border border-danger-border rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-danger-foreground mb-2",children:[(0,r.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),(0,r.jsx)("span",{className:"font-medium",children:t?s("boundary.errorOccurredIn",{componentName:t}):s("boundary.errorOccurred")})]}),n&&(0,r.jsx)("p",{className:"text-sm text-danger-foreground/80 mb-3",children:n.message}),a&&(0,r.jsx)("button",{onClick:a,className:"px-4 py-2 bg-danger-foreground text-danger-subtle rounded hover:opacity-90 transition-opacity text-sm",children:l("retry")})]})}let I={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",none:""};function M(e){let{visible:t,duration:n=200}=e,[a,r]=(0,i.useState)(t?"visible":"hidden"),s=(0,i.useRef)(null),l=(0,i.useRef)(t);(0,i.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]),(0,i.useEffect)(()=>{let e=l.current;l.current=t,s.current&&(clearTimeout(s.current),s.current=null);let a=e=>{s.current=setTimeout(()=>{r(e),s.current=null},n)};t&&!e?(r("fade-in"),a("visible")):!t&&e?(r("fade-out"),a("hidden")):t?r(e=>"fade-out"===e?(a("visible"),"fade-in"):e):r(e=>"fade-in"===e?(a("hidden"),"fade-out"):e)},[t,n]);let o="hidden"!==a,c="fade-in"===a||"fade-out"===a;return{shouldRender:o,animationClass:(0,i.useMemo)(()=>{switch(a){case"fade-in":return I.fadeIn;case"fade-out":return I.fadeOut;default:return I.none}},[a]),isAnimating:c}}var A=n(92539),L=n(8269);let R={base:"px-6 py-3 rounded-lg font-medium transition-all touch-manipulation disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-offset-2",primary:"bg-accent-600 text-white hover:bg-accent-700 focus:ring-ring",secondary:"bg-muted border-2 border-input hover:bg-muted/80 text-foreground focus:ring-ring",defaultSelected:"bg-muted-foreground text-background hover:bg-muted-foreground/90"},P=(0,i.memo)(function(e){let{promptData:t,visible:n,answering:a,onRespond:s,onDismiss:l,cliToolName:o}=e,{shouldRender:c,animationClass:d}=M({visible:n&&null!==t,duration:300}),u=(0,i.useId)(),m=n&&null!==t,h=(0,A.r)({active:m}),[x,f]=(0,i.useState)(0);(0,i.useEffect)(()=>{n||f(0)},[n]);let p=(0,i.useCallback)(e=>{let{deltaY:t}=e;f(t>0?t:0)},[]),g=(0,i.useCallback)(()=>{null==l||l()},[l]),b=(0,i.useCallback)(()=>{f(0)},[]),{ref:v}=(0,L.hU)({axis:"vertical",threshold:100,enabled:m,onSwipeMove:p,onSwipeDown:g,onSwipeEnd:b}),y=(0,i.useCallback)(e=>{h.current=e,v.current=e},[h,v]),j=(0,i.useCallback)(()=>{l&&l()},[l]),w=(0,i.useCallback)(e=>{e.stopPropagation()},[]);if(!c||!t)return null;let k="animate-fade-out"===d;return(0,r.jsxs)(T,{componentName:"MobilePromptSheet",children:[(0,r.jsx)("div",{"data-testid":"prompt-overlay",onClick:j,className:"fixed inset-0 bg-black/50 z-50 transition-opacity duration-300 ".concat(k?"opacity-0":"opacity-100"," ").concat(k?"pointer-events-none":""),"aria-hidden":"true"}),(0,r.jsxs)("div",{ref:y,"data-testid":"mobile-prompt-sheet",role:"dialog","aria-modal":"true","aria-labelledby":u,onClick:w,style:{transform:x>0?"translateY(".concat(x,"px)"):void 0},className:"fixed bottom-0 inset-x-0 bg-surface rounded-t-2xl z-50 pb-safe transform transition-transform duration-300 ".concat(k?"translate-y-full":"translate-y-0"),children:[(0,r.jsx)("div",{className:"flex justify-center pt-3 pb-2",children:(0,r.jsx)("div",{"data-testid":"drag-handle",className:"w-10 h-1 bg-input rounded-full","aria-hidden":"true"})}),(0,r.jsx)("div",{className:"px-4 pb-6",children:(0,r.jsx)(D,{promptData:t,answering:a,onRespond:s,labelId:u,cliToolName:o})})]})]})});function D(e){let{promptData:t,answering:n,onRespond:a,labelId:s,cliToolName:l}=e,o=(0,c.c)("prompt"),[d,u]=(0,i.useState)(()=>{if("multiple_choice"===t.type){var e;let n=t.options.find(e=>e.isDefault);return null!=(e=null==n?void 0:n.number)?e:null}return null}),[h,x]=(0,i.useState)(""),[f,p]=(0,i.useState)(!1),g=(0,i.useMemo)(()=>{var e;return"multiple_choice"!==t.type?null:null!=(e=t.options.find(e=>e.number===d))?e:null},[t,d]),b=(null==g?void 0:g.requiresTextInput)===!0,v=n||f,y=(0,i.useCallback)(async e=>{if(!v){p(!0);try{await a(e)}catch(e){}finally{p(!1)}}},[v,a]),j=(0,i.useCallback)(async()=>{if(!v&&null!==d){p(!0);try{let e=b&&h.trim()?h.trim():d.toString();await a(e)}catch(e){}finally{p(!1)}}},[v,a,d,b,h]);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h3",{id:s,className:"text-lg font-semibold text-foreground",children:l?o("confirmationFrom",{toolName:l}):o("confirmationFromClaude")}),S(t)&&t.instructionText&&(0,r.jsx)("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap text-sm text-muted-foreground bg-muted rounded p-2 border border-border",children:t.instructionText}),(0,r.jsx)("p",{className:"text-foreground leading-relaxed",children:t.question}),v&&(0,r.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-muted-foreground",role:"status","aria-live":"polite",children:[(0,r.jsx)(m.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{children:o("sending")})]}),"yes_no"===t.type&&(0,r.jsx)(F,{promptData:t,disabled:v,onYes:()=>y("yes"),onNo:()=>y("no")}),"multiple_choice"===t.type&&(0,r.jsx)(O,{promptData:t,disabled:v,selectedOption:d,onSelectOption:u,textInputValue:h,onTextInputChange:x,showTextInput:b,onSubmit:j})]})}let F=(0,i.memo)(function(e){let{promptData:t,disabled:n,onYes:a,onNo:s}=e,l=(0,c.c)("prompt"),i="yes"===t.defaultOption,o="no"===t.defaultOption;return(0,r.jsxs)("div",{className:"flex gap-3",role:"group","aria-label":l("yesNoGroupLabel"),children:[(0,r.jsx)("button",{type:"button",onClick:a,disabled:n,className:"flex-1 ".concat(R.base," ").concat(R.primary," ").concat(i?"ring-2 ring-accent-300":""),children:l("yes")}),(0,r.jsx)("button",{type:"button",onClick:s,disabled:n,className:"flex-1 ".concat(R.base," ").concat(o?R.defaultSelected:R.secondary),children:l("no")})]})}),O=(0,i.memo)(function(e){let{promptData:t,disabled:n,selectedOption:a,onSelectOption:s,textInputValue:l,onTextInputChange:o,showTextInput:d,onSubmit:u}=e,h=(0,i.useId)(),x=(0,c.c)("prompt");return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:x("selectAnOption")}),(0,r.jsx)(m.z6,{name:h,value:null!=a?String(a):"",onValueChange:e=>s(Number(e)),disabled:n,className:"flex flex-col gap-2",children:t.options.map(e=>{let t=a===e.number;return(0,r.jsxs)("label",{className:"flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ".concat(t?"bg-accent-50 dark:bg-accent-900/30 border-2 border-accent-500":"bg-surface border-2 border-border hover:border-input"," ").concat(n?"opacity-50 cursor-not-allowed":""),children:[(0,r.jsx)(m.CU,{value:String(e.number),className:"mt-1"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("span",{className:"font-medium text-foreground",children:[e.number,". ",e.label]}),e.isDefault&&(0,r.jsx)("span",{className:"ml-2 text-xs text-accent-600 bg-accent-100 px-2 py-0.5 rounded",children:x("default")})]})]},e.number)})})]}),d&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"text-input-".concat(h),className:"sr-only",children:x("customValueInput")}),(0,r.jsx)("input",{id:"text-input-".concat(h),type:"text",value:l,onChange:e=>o(e.target.value),disabled:n,placeholder:x("enterValuePlaceholder"),inputMode:"text",enterKeyHint:"done",className:"w-full px-4 py-3 border-2 border-input rounded-lg bg-surface text-foreground focus:outline-none focus:border-ring disabled:opacity-50"})]}),(0,r.jsx)("button",{type:"button",onClick:u,disabled:n||null===a,className:"w-full ".concat(R.base," ").concat(R.primary),children:x("submit")})]})});var z=n(86651),_=n(84926);function B(e){let{open:t,onClose:n,onSearch:a,onEnd:s,endDisabled:l=!1}=e,o=(0,c.c)("worktree"),d=(0,i.useId)(),u=(0,A.r)({active:t}),m=(0,i.useCallback)(()=>{a(),n()},[a,n]),h=(0,i.useCallback)(()=>{s(),n()},[s,n]);return((0,i.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&n()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,n]),t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"terminal-actions-overlay",onClick:n,className:"fixed inset-0 bg-black/50 z-50","aria-hidden":"true"}),(0,r.jsxs)("div",{ref:u,"data-testid":"mobile-terminal-actions-sheet",role:"dialog","aria-modal":"true","aria-labelledby":d,tabIndex:-1,className:"fixed bottom-0 inset-x-0 z-50 rounded-t-2xl border-t border-border bg-surface pb-safe",children:[(0,r.jsx)("div",{className:"flex justify-center pt-3 pb-2",children:(0,r.jsx)("div",{className:"w-10 h-1 rounded-full bg-muted-foreground/30","aria-hidden":"true"})}),(0,r.jsx)("h2",{id:d,className:"px-4 pb-2 text-sm font-medium text-muted-foreground",children:o("terminal.moreActions")}),(0,r.jsxs)("div",{className:"px-2 pb-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-search",onClick:m,className:"flex w-full items-center gap-3 rounded-lg px-3 py-3 text-sm text-foreground hover:bg-muted transition-colors touch-manipulation",children:[(0,r.jsx)(z.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),o("terminal.searchTerminal")]}),(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-end",onClick:h,disabled:l,className:"flex w-full items-center gap-3 rounded-lg px-3 py-3 text-sm text-danger hover:bg-danger/10 transition-colors touch-manipulation disabled:opacity-40 disabled:hover:bg-transparent",children:[(0,r.jsx)(_.A,{size:18,"aria-hidden":"true"}),o("terminal.endSession")]})]})]})]}):null}var V=n(80344),W=n(79651);function H(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e=>{var t;return null!=(t=e.description)?t:""};if(!t.trim())return e;let a=t.toLowerCase();return e.map(e=>({...e,commands:e.commands.filter(e=>{let t=e.name.toLowerCase().includes(a),r=n(e).toLowerCase().includes(a);return t||r})})).filter(e=>e.commands.length>0)}function U(e,t){return"codex-skill"===e.source?"antigravity"===t?"/".concat(e.name):"$".concat(e.name):"/".concat(e.name)}function K(e,t){var n;return e.descriptionKey?t(e.descriptionKey):null!=(n=e.description)?n:""}function $(e){let{groups:t,onSelect:n,highlightedIndex:a=-1,className:s="",cliToolId:l}=e,i=(0,c.c)("worktree"),o=0;return 0===t.length?(0,r.jsx)("div",{className:"text-sm text-muted-foreground p-4 text-center ".concat(s),children:i("slashCommands.empty")}):(0,r.jsx)("div",{className:"overflow-y-auto ".concat(s),children:t.map(e=>(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider bg-muted",children:e.label}),(0,r.jsx)("div",{children:e.commands.map(e=>{var t;let s=o;o++;let c=s===a;return(0,r.jsxs)("button",{type:"button","data-command-item":!0,"data-highlighted":c,onClick:()=>n(e),className:"w-full px-3 py-2 text-left flex items-start gap-2 hover:bg-accent-50 dark:hover:bg-accent-900/30 transition-colors ".concat(c?"bg-accent-100 dark:bg-accent-900/40":""),children:[(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-mono text-sm flex-shrink-0",children:U(e,l)}),(null==(t=e.cliTools)?void 0:t.length)===1&&"codex"===e.cliTools[0]&&(0,r.jsx)("span",{className:"mt-0.5 rounded border border-accent-200 bg-accent-50 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-accent-700 dark:border-accent-800 dark:bg-accent-950/40 dark:text-accent-300",children:"Codex"}),"user-catalog"===e.source&&(0,r.jsx)("span",{"data-testid":"user-catalog-badge",className:"mt-0.5 rounded border border-border bg-muted px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:i("slashCommands.sourceBadge.userCatalog")}),(0,r.jsx)("span",{className:"text-muted-foreground text-sm truncate",children:K(e,i)})]},e.name)})})]},e.category))})}function q(e,t,n){if(t<=0||n<=0)return 0;let a=e+t+8-n;return a>0?-Math.min(a,Math.max(0,e-8)):e<8?8-e:0}let G=(0,i.memo)(function(e){let{isOpen:t,groups:n,onSelect:a,onClose:s,isMobile:l=!1,position:o,onFreeInput:d,isCatalogStale:u=!1,cliToolId:m}=e,[h,x]=(0,i.useState)(""),[f,p]=(0,i.useState)(0),g=(0,i.useRef)(null),b=(0,i.useRef)(null),v=(0,i.useRef)({x:0,y:0}),[y,j]=(0,i.useState)({x:0,y:0}),w=(0,c.c)("worktree"),k=(0,c.c)("common"),N=(0,i.useMemo)(()=>H(n,h,e=>K(e,w)),[n,h,w]),C=(0,i.useMemo)(()=>N.flatMap(e=>e.commands),[N]);(0,i.useEffect)(()=>{t&&(x(""),p(0),setTimeout(()=>{var e;null==(e=g.current)||e.focus()},50))},[t]);let S=(0,i.useCallback)(e=>{a(e),s()},[a,s]),T=(0,i.useCallback)(e=>{if(t)switch(e.key){case"Escape":e.preventDefault(),s();break;case"ArrowDown":e.preventDefault(),p(e=>Math.min(e+1,C.length-1));break;case"ArrowUp":e.preventDefault(),p(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),C[f]&&S(C[f])}},[t,C,f,s,S]);if((0,i.useEffect)(()=>{if(t)return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[t,T]),(0,i.useLayoutEffect)(()=>{let e=e=>{v.current=e,j(t=>t.x===e.x&&t.y===e.y?t:e)};if(!t||l)return void e({x:0,y:0});let n=b.current;if(!n)return;let a=n.getBoundingClientRect();e({x:q(a.left-v.current.x,a.width,window.innerWidth),y:q(a.top-v.current.y,a.height,window.innerHeight)})},[t,l,N,null==o?void 0:o.top,null==o?void 0:o.left]),!t)return null;let E=u?(0,r.jsx)("div",{"data-testid":"slash-command-stale-note",className:"px-3 py-2 border-t border-border text-xs text-muted-foreground",children:w("slashCommands.catalogStale.hint")}):null;if(l)return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40",onClick:s,"aria-hidden":"true"}),(0,r.jsxs)("div",{"data-testid":"slash-command-bottom-sheet",className:"fixed bottom-0 left-0 right-0 bg-surface rounded-t-xl z-50 max-h-[70vh] flex flex-col shadow-xl",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:w("slashCommands.title")}),(0,r.jsx)("button",{type:"button",onClick:s,"aria-label":k("close"),className:"p-2 rounded-full hover:bg-muted",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"px-4 py-2 border-b border-border",children:(0,r.jsx)("input",{ref:g,type:"text",value:h,onChange:e=>x(e.target.value),placeholder:w("slashCommands.searchPlaceholder"),className:"w-full px-3 py-2 border border-input bg-surface dark:bg-surface-2 text-foreground rounded-lg focus:outline-none focus:ring-2 focus:ring-ring"})}),d&&(0,r.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:()=>d(h),className:"w-full px-4 py-3 text-left border-b border-border flex items-center gap-2 hover:bg-accent-50 dark:hover:bg-accent-900/30 transition-colors",children:[(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,r.jsx)("span",{className:"text-muted-foreground",children:w("slashCommands.enterCustomCommand")})]}),(0,r.jsx)($,{groups:N,onSelect:S,highlightedIndex:f,className:"flex-1 overflow-y-auto pb-20",cliToolId:m}),E]})]});let I=o?{top:o.top,left:o.left}:{bottom:"100%",left:0,marginBottom:"4px"};return(0,r.jsxs)("div",{ref:b,role:"listbox","data-testid":"slash-command-dropdown",className:"absolute bg-surface border border-border rounded-lg shadow-lg z-50 w-80 max-h-96 flex flex-col",style:0!==y.x||0!==y.y?{...I,transform:"translate(".concat(y.x,"px, ").concat(y.y,"px)")}:I,children:[(0,r.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,r.jsx)("input",{ref:g,type:"text",value:h,onChange:e=>x(e.target.value),placeholder:w("slashCommands.searchPlaceholder"),className:"w-full px-3 py-1.5 text-sm border border-input bg-surface dark:bg-surface-2 text-foreground rounded focus:outline-none focus:ring-1 focus:ring-ring"})}),d&&(0,r.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:()=>d(h),className:"w-full px-3 py-2 text-left border-b border-border flex items-center gap-2 hover:bg-accent-50 dark:hover:bg-accent-900/30 transition-colors text-sm",children:[(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,r.jsx)("span",{className:"text-muted-foreground",children:w("slashCommands.enterCustomCommand")})]}),(0,r.jsx)($,{groups:N,onSelect:S,highlightedIndex:f,className:"flex-1 overflow-y-auto",cliToolId:m}),E,(0,r.jsxs)("div",{className:"px-3 py-1.5 border-t border-border text-xs text-muted-foreground flex gap-3",children:[(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded",children:"Enter"})," ",w("slashCommands.selectHint")]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded",children:"Esc"})," ",w("slashCommands.closeHint")]})]})]})}),J=(0,i.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,disabled:s=!1,onInterrupt:l}=e,o=(0,c.c)("worktree"),[d,m]=(0,i.useState)(!1),h=(0,i.useRef)(0),x=(0,i.useCallback)(async()=>{let e=Date.now();if(!(e-h.current<1e3)){h.current=e,m(!0);try{let e=a&&a!==n?{cliToolId:n,instanceId:a}:{cliToolId:n},r=await fetch("/api/worktrees/".concat(t,"/interrupt"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.ok)null==l||l();else{let e=await r.json().catch(()=>({}));console.error("[InterruptButton] Failed to send interrupt:",e.error||r.statusText)}}catch(e){console.error("[InterruptButton] Error sending interrupt:",e)}finally{m(!1)}}},[t,n,a,l]);return(0,r.jsx)("button",{type:"button",onClick:x,disabled:s||d,className:"flex-shrink-0 p-2 text-danger hover:bg-danger/10 rounded-full transition-colors disabled:text-muted-foreground/40 disabled:hover:bg-transparent","aria-label":o("interrupt.stopProcessing"),"data-testid":"interrupt-button",children:d?(0,r.jsx)(u.y,{size:"md"}):(0,r.jsx)(Y,{})})});function Y(){return(0,r.jsx)("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}var Q=n(74385),X=n(38218),Z=n(19985);let ee="commandmate:draft-message:",et="Queued (session busy) — your message will run after the current task finishes.";function en(e,t){return"".concat(ee).concat(e,":").concat(t)}let ea=(0,i.memo)(function(e){let{worktreeId:t,onMessageSent:n,cliToolId:a,instanceId:s,isSessionRunning:l=!1,pendingInsertText:o,onInsertConsumed:d,splitIndex:u=0,onFocus:h,isProcessing:x=!1,showToast:f,autoYesSlot:p,onOptimisticSend:g}=e,b=(0,c.c)("worktree"),[v,y]=(0,i.useState)(""),[j,w]=(0,i.useState)(!1),[k,N]=(0,i.useState)(null),[C,S]=(0,i.useState)(!1),[T,E]=(0,i.useState)(!1),[I,M]=(0,i.useState)(!1),A=(0,i.useRef)(null),L=(0,i.useRef)(null),R=(0,i.useRef)(!1),P=(0,i.useRef)(null),D=(0,i.useRef)(null),F=(0,X.a)(),{groups:O,isCatalogStale:z}=function(e,t){let[n,a]=(0,i.useState)([]),[r,s]=(0,i.useState)(!0),[l,o]=(0,i.useState)(null),[c,d]=(0,i.useState)(""),[u,m]=(0,i.useState)(t||"claude"),[h,x]=(0,i.useState)({}),f=(0,i.useCallback)(async()=>{try{var n;s(!0),o(null);let r=e?"/api/worktrees/".concat(e,"/slash-commands"):"/api/slash-commands";t&&(r+="?cliTool=".concat(t));let l=await fetch(r,{cache:"no-store"});if(!l.ok)throw Error("HTTP error ".concat(l.status));let i=await l.json();a(i.groups),m(i.cliTool||t||"claude"),x(null!=(n=i.catalogStaleness)?n:{})}catch(e){o((0,V.hS)(e)),a([]),x({})}finally{s(!1)}},[e,t]);(0,i.useEffect)(()=>{f()},[f]),(0,i.useEffect)(()=>{if(!e)return;let t=t=>{let n=t.detail;(null==n?void 0:n.worktreeId)===e&&f()};return window.addEventListener(Q.I,t),()=>window.removeEventListener(Q.I,t)},[e,f]);let p=(0,i.useMemo)(()=>n.flatMap(e=>e.commands),[n]),g=(0,i.useMemo)(()=>H(n,c),[n,c]),b=(0,i.useMemo)(()=>Object.values(h).some(e=>e.stale),[h]);return{groups:n,filteredGroups:g,allCommands:p,loading:r,error:l,filter:c,setFilter:d,refresh:(0,i.useCallback)(()=>{f()},[f]),cliTool:u,isCatalogStale:b}}(t,a),{attachedImage:_,fileInputRef:B,isUploading:K,error:$,acceptAttribute:q,openFileDialog:Y,handleFileSelect:ea,removeAttachment:er,resetAfterSend:es}=function(e,t){let[n,a]=(0,i.useState)(null),[r,s]=(0,i.useState)(!1),[l,o]=(0,i.useState)(null),c=(0,i.useRef)(null),d=(0,i.useCallback)(()=>{var e;null==(e=c.current)||e.click()},[]),u=(0,i.useCallback)(async n=>{var r;let l=null==(r=n.target.files)?void 0:r[0];if(!l)return;o(null);let i=function(e){let t=e.name.lastIndexOf(".");if(-1===t)return"Unsupported file format";let n=(0,Z.HB)(e.name.substring(t));if(!Z.Hv.includes(n))return"Unsupported file format: ".concat(n);if(e.size>Z.Fg){let e=Z.Fg/1024/1024;return"File size exceeds ".concat(e,"MB limit")}return null}(l);if(i){o(i),c.current&&(c.current.value="");return}s(!0);try{let n=await t(e,l);a({file:l,path:n.path})}catch(e){o(e instanceof Error?e.message:"Upload failed")}finally{s(!1),c.current&&(c.current.value="")}},[e,t]),m=(0,i.useCallback)(()=>{a(null),o(null)},[]),h=(0,i.useCallback)(()=>{a(null)},[]);return{attachedImage:n,fileInputRef:c,isUploading:r,error:l,acceptAttribute:Z.F5,openFileDialog:d,handleFileSelect:u,removeAttachment:m,resetAfterSend:h}}(t,(0,i.useCallback)((e,t)=>V.y.uploadImageFile(e,t),[]));(0,i.useEffect)(()=>{try{0===u&&function(e){try{let t="".concat(ee).concat(e),n=window.localStorage.getItem(t);if(null===n)return;let a=en(e,0);null===window.localStorage.getItem(a)&&window.localStorage.setItem(a,n),window.localStorage.removeItem(t)}catch(e){}}(t);let e=window.localStorage.getItem(en(t,u));e?y(e):y("")}catch(e){}return()=>{D.current&&clearTimeout(D.current)}},[t,u]),(0,i.useEffect)(()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{try{let e=en(t,u);v?window.localStorage.setItem(e,v):window.localStorage.removeItem(e)}catch(e){}},500)},[v,t,u]),(0,i.useEffect)(()=>{let e=A.current;e&&(v?(e.style.height="auto",e.style.height="".concat(Math.min(e.scrollHeight,160),"px")):e.style.height="24px")},[v]),(0,i.useEffect)(()=>{o&&(y(e=>""===e.trim()?o:e+"\n\n"+o),null==d||d())},[o,d]);let el=(0,i.useCallback)(async()=>{if(C||!v.trim()&&!_||j)return;let e=v.trim(),r=a||"claude",l={cliToolId:r};if(s&&s!==r&&(l.instanceId=s),_&&(l.imagePath=_.path),g){N(null),g(e,l),y(""),M(!1),es();try{window.localStorage.removeItem(en(t,u))}catch(e){}x&&(null==f||f(et,"warning")),null==n||n(r);return}try{w(!0),N(null),await V.y.sendMessage(t,e,l),y(""),M(!1),es();try{window.localStorage.removeItem(en(t,u))}catch(e){}x&&(null==f||f(et,"warning")),null==n||n(r)}catch(e){N((0,V.hS)(e))}finally{w(!1)}},[C,v,_,j,t,a,s,n,es,u,x,f,g]),ei=(0,i.useCallback)(async e=>{e.preventDefault(),await el()},[el]),eo=(0,i.useCallback)(()=>{S(!0),R.current=!1,L.current&&clearTimeout(L.current)},[]),ec=(0,i.useCallback)(()=>{S(!1),R.current=!0,L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{R.current=!1},300)},[]),ed=(0,i.useCallback)(e=>{var t;y("".concat(U(e,a)," ")),E(!1),null==(t=A.current)||t.focus()},[a]),eu=(0,i.useCallback)(()=>{var e;E(!1),M(!1),null==(e=A.current)||e.focus()},[]),em=(0,i.useCallback)(e=>{E(!1),M(!0),y(e?"/".concat(e):"/"),setTimeout(()=>{var e;null==(e=A.current)||e.focus()},50)},[]),eh=(0,i.useCallback)(e=>{let t=e.target.value;if(y(t),""===t){M(!1),E(!1);return}if(I)return;let n="/"===t||t.startsWith("/")&&!t.includes(" "),r="codex"===a&&("$"===t||t.startsWith("$")&&!t.includes(" "));n||r?E(!0):E(!1)},[I,a]),ex=(0,i.useCallback)(e=>{let{keyCode:t}=e.nativeEvent;if(229!==t){if("Escape"===e.key&&T){e.preventDefault(),eu();return}if(R.current&&"Enter"===e.key){R.current=!1;return}if("Enter"===e.key&&!C&&(!T||I)){if(F)return;e.shiftKey||(e.preventDefault(),el())}}},[T,I,C,F,el,eu]);return(0,r.jsxs)("div",{ref:P,className:"space-y-2 relative","data-testid":"message-input-container",children:[(k||$)&&(0,r.jsx)("div",{className:"p-2 bg-danger-subtle border border-danger-border rounded text-sm text-danger-foreground",children:k||$}),_&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-accent-50 dark:bg-accent-900/20 border border-accent-200 dark:border-accent-800 rounded-lg text-sm","data-testid":"image-attachment-preview",children:[(0,r.jsx)("svg",{className:"h-4 w-4 flex-shrink-0 text-accent-600 dark:text-accent-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),(0,r.jsx)("span",{className:"truncate text-accent-800 dark:text-accent-300",children:_.file.name}),(0,r.jsx)("button",{type:"button",onClick:er,className:"flex-shrink-0 p-0.5 text-accent-600 hover:text-danger-foreground dark:text-accent-400 rounded transition-colors","aria-label":b("composer.removeAttachment"),"data-testid":"remove-attachment-button",children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("input",{ref:B,type:"file",accept:q,onChange:ea,className:"hidden","data-testid":"image-file-input"}),(0,r.jsxs)("form",{onSubmit:ei,className:"rounded-xl bg-surface border border-border shadow-sm px-3 py-2 focus-within:ring-2 focus-within:ring-accent-500/40 transition-shadow flex flex-col gap-1.5",children:[(0,r.jsxs)("div",{className:F?"flex flex-col gap-1":"flex items-center gap-2",children:[F&&(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:()=>{I&&M(!1),E(!0)},className:"flex-shrink-0 p-2 text-muted-foreground hover:text-accent-600 hover:bg-accent-50 dark:hover:text-accent-400 dark:hover:bg-accent-900/30 rounded-full transition-colors","aria-label":b("composer.showSlashCommands"),"data-testid":"mobile-command-button",children:(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"})})}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:Y,disabled:K||j,className:"flex-shrink-0 p-2 text-muted-foreground hover:text-accent-600 hover:bg-accent-50 dark:hover:text-accent-400 dark:hover:bg-accent-900/30 rounded-full transition-colors disabled:text-muted-foreground/50 disabled:hover:bg-transparent","aria-label":b("composer.attachImage"),"data-testid":"attach-image-button",children:K?(0,r.jsx)(m.y$,{size:"md"}):(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}),(0,r.jsx)(J,{worktreeId:t,cliToolId:a||"claude",instanceId:s,disabled:!l})]}),!F&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:Y,disabled:K||j,className:"flex-shrink-0 p-2 text-muted-foreground hover:text-accent-600 hover:bg-accent-50 dark:hover:text-accent-400 dark:hover:bg-accent-900/30 rounded-full transition-colors disabled:text-muted-foreground/50 disabled:hover:bg-transparent","aria-label":b("composer.attachImage"),"data-testid":"attach-image-button",children:K?(0,r.jsx)(m.y$,{size:"md"}):(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,r.jsx)("textarea",{ref:A,"data-testid":"message-input-textarea",value:v,onChange:eh,onKeyDown:ex,onCompositionStart:eo,onCompositionEnd:ec,onFocus:h,placeholder:b("composer.placeholder"),disabled:j,rows:1,inputMode:"text",enterKeyHint:"send",className:"flex-1 outline-none bg-transparent resize-none overflow-y-auto scrollbar-thin",style:{minHeight:"36px",maxHeight:"160px",paddingTop:"8px",paddingBottom:"8px",lineHeight:"20px"}}),!F&&(0,r.jsx)(J,{worktreeId:t,cliToolId:a||"claude",instanceId:s,disabled:!l}),(0,r.jsx)(m.$n,{variant:"ghost",type:"submit","data-testid":"send-message-button","data-can-send":String((!!v.trim()||!!_)&&!j),disabled:!v.trim()&&!_||j,className:"flex-shrink-0 p-2 rounded-full transition-colors disabled:hover:bg-transparent ".concat((v.trim()||_)&&!j?"bg-accent-600 text-white hover:bg-accent-700 shadow-sm":"text-muted-foreground/50"),"aria-label":b("composer.sendMessage"),children:j?(0,r.jsx)(m.y$,{size:"md"}):(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]})]}),(p||!F)&&(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 min-w-0","data-testid":"composer-meta-row",children:[(0,r.jsx)("div",{className:"flex items-center gap-2 min-w-0 overflow-x-auto scrollbar-hide",children:p}),!F&&(0,r.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground select-none",children:[(0,r.jsx)(W.u,{children:"/"}),(0,r.jsx)("span",{children:b("composer.commandsHint")}),(0,r.jsx)("span",{"aria-hidden":"true",className:"opacity-50",children:"\xb7"}),(0,r.jsx)(W.u,{children:"⇧"}),(0,r.jsx)(W.u,{children:"↵"}),(0,r.jsx)("span",{children:b("composer.newlineHint")})]})]})]}),(0,r.jsx)(G,{isOpen:T,groups:O,onSelect:ed,onClose:eu,isMobile:F,onFreeInput:em,isCatalogStale:z,cliToolId:a})]})});var er=n(9900);function es(e,t,n,a){return(0,i.useCallback)(r=>{let s=n&&n!==t?{cliToolId:t,keys:r,instanceId:n}:{cliToolId:t,keys:r};fetch("/api/worktrees/".concat(encodeURIComponent(e),"/special-keys"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}).then(()=>{a&&setTimeout(a,er.LK)}).catch(e=>{console.error("Failed to send special keys:",e)})},[e,t,n,a])}let el=[{key:"Left",label:"◀",ariaLabel:"Left"},{key:"Up",label:"▲",ariaLabel:"Up"},{key:"Down",label:"▼",ariaLabel:"Down"},{key:"Right",label:"▶",ariaLabel:"Right"},{key:"Enter",label:"↵",ariaLabel:"Enter"},{key:"Escape",label:"Esc",ariaLabel:"Escape"}],ei=[{key:"PageUp",label:"PgUp",ariaLabel:"Page Up"},{key:"PageDown",label:"PgDn",ariaLabel:"Page Down"},{key:"Home",label:"Home",ariaLabel:"Home"},{key:"End",label:"End",ariaLabel:"End"},{key:"q",label:"q",ariaLabelKey:"navigation.quitPager"}];function eo(e){let{worktreeId:t,cliToolId:n,instanceId:a,onKeysSent:s,showPagerKeys:l=!1}=e,o=(0,c.c)("worktree"),[d,u]=(0,i.useState)(null),m=es(t,n,a,s),h=(0,i.useCallback)(e=>{u(e[0]),setTimeout(()=>u(null),er.tX),m(e)},[m]),x=(0,i.useMemo)(()=>l?[...el,...ei]:el,[l]),f=(0,i.useCallback)(e=>{let t={ArrowLeft:"Left",ArrowUp:"Up",ArrowDown:"Down",ArrowRight:"Right",Enter:"Enter",Escape:"Escape"}[e.key];t&&(e.preventDefault(),h([t]))},[h]);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 py-1.5 bg-muted rounded-lg",onKeyDown:f,role:"toolbar","aria-label":o("navigation.toolbarLabel"),children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground mx-2",children:o("navigation.caption")}),x.map(e=>{let{key:t,label:n,ariaLabel:a,ariaLabelKey:s}=e;return(0,r.jsx)("button",{type:"button",className:"min-w-[44px] min-h-[44px] px-3 py-2 text-sm font-medium rounded-md\n border border-border\n focus:outline-none focus:ring-2 focus:ring-ring\n transition-colors duration-75\n ".concat(d===t?"bg-accent-500 text-white border-accent-500 scale-95":"bg-surface dark:bg-surface-2 hover:bg-muted active:bg-muted"),"aria-label":s?o(s):a,onClick:()=>h([t]),children:n},t)})]})}var ec=n(36402),ed=n(17846),eu=n(69264),em=n(27307),eh=n(24027),ex=n(5917),ef=n(75426),ep=n(51963),eg=n(39867);let eb="flex w-full items-center gap-3 rounded-lg px-3 min-h-[44px] py-3 text-sm text-foreground hover:bg-muted transition-colors touch-manipulation";function ev(e){let{open:t,onClose:n,onSearch:a,onCopyContent:s,onCopyPath:l,downloadUrl:o,downloadName:d,contentCopied:u,pathCopied:m}=e,h=(0,c.c)("worktree"),x=(0,i.useId)(),f=(0,A.r)({active:t}),p=(0,i.useCallback)(()=>{a(),n()},[a,n]),g=(0,i.useCallback)(()=>{s(),n()},[s,n]),b=(0,i.useCallback)(()=>{l(),n()},[l,n]);return((0,i.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&(e.stopPropagation(),n())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,n]),t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"file-actions-overlay",onClick:n,className:"fixed inset-0 bg-black/50 z-50","aria-hidden":"true"}),(0,r.jsxs)("div",{ref:f,"data-testid":"mobile-file-actions-sheet",role:"dialog","aria-modal":"true","aria-labelledby":x,tabIndex:-1,className:"fixed bottom-0 inset-x-0 z-50 rounded-t-2xl border-t border-border bg-surface pb-safe",children:[(0,r.jsx)("div",{className:"flex justify-center pt-3 pb-2",children:(0,r.jsx)("div",{className:"w-10 h-1 rounded-full bg-muted-foreground/30","aria-hidden":"true"})}),(0,r.jsx)("h2",{id:x,className:"px-4 pb-2 text-sm font-medium text-muted-foreground",children:h("fileViewer.moreActions")}),(0,r.jsxs)("div",{className:"px-2 pb-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"file-actions-sheet-search",onClick:p,className:eb,children:[(0,r.jsx)(z.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),h("actions.searchInFile")]}),(0,r.jsxs)("button",{type:"button","data-testid":"file-actions-sheet-copy-content",onClick:g,className:eb,children:[u?(0,r.jsx)(ex.A,{size:18,"aria-hidden":"true",className:"text-success"}):(0,r.jsx)(ef.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),h("actions.copyFileContent")]}),(0,r.jsxs)("button",{type:"button","data-testid":"file-actions-sheet-copy-path",onClick:b,className:eb,children:[m?(0,r.jsx)(ex.A,{size:18,"aria-hidden":"true",className:"text-success"}):(0,r.jsx)(ep.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),h("actions.copyFilePath")]}),(0,r.jsxs)("a",{"data-testid":"download-file-button",href:o,download:d,onClick:n,className:eb,"aria-label":h("actions.downloadFile"),children:[(0,r.jsx)(eg.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),h("actions.downloadFile")]})]})]})]}):null}var ey=n(11063),ej=n(60322),ew=n(65229),ek=n(97624),eN=n(37354),eC=n(57828),eS=n(18514),eT=n(59854),eE=n(76246);let eI={highlightName:"terminal-search",currentHighlightName:"terminal-search-current",fallbackOverlayId:"terminal-search-fallback-overlay",fallbackOverlayBgColor:"rgba(255, 165, 0, 0.6)"},eM={highlightName:"history-search",currentHighlightName:"history-search-current",fallbackOverlayId:"history-search-fallback-overlay",fallbackOverlayBgColor:"rgba(59, 130, 246, 0.6)"};function eA(){return"undefined"!=typeof CSS&&null!==CSS&&"highlights"in CSS}function eL(e,t,n){let a=document.createRange(),r=!1;for(let{node:s,start:l,end:i}of e)if(!r&&t<i&&t>=l&&(a.setStart(s,t-l),r=!0),r&&n<=i)return a.setEnd(s,n-l),a;return r?a:null}function eR(e){var t;eA()&&(CSS.highlights.delete(e.highlightName),CSS.highlights.delete(e.currentHighlightName)),null==(t=document.getElementById(e.fallbackOverlayId))||t.remove()}function eP(e,t,n,a){if(0===t.length)return void eR(a);let r=function(e){let t,n=[],a=0,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;t=r.nextNode();){var s,l;let e=null!=(l=null==(s=t.nodeValue)?void 0:s.length)?l:0;n.push({node:t,start:a,end:a+e}),a+=e}return n}(e),s=t[n],l=s?eL(r,s.start,s.end):null;if(eA()){let e=[];t.forEach((t,a)=>{if(a===n)return;let s=eL(r,t.start,t.end);s&&e.push(s)}),CSS.highlights.set(a.highlightName,new Highlight(...e)),CSS.highlights.delete(a.currentHighlightName)}if(function(e,t,n){let a=document.getElementById(n.fallbackOverlayId);if(!t||"function"!=typeof t.getBoundingClientRect){null==a||a.remove();return}let r=t.getBoundingClientRect(),s=e.getBoundingClientRect();a?a.style.backgroundColor=n.fallbackOverlayBgColor:((a=document.createElement("div")).id=n.fallbackOverlayId,a.style.position="absolute",a.style.backgroundColor=n.fallbackOverlayBgColor,a.style.borderRadius="2px",a.style.pointerEvents="none",a.style.zIndex="5",e instanceof HTMLElement&&(e.style.position="relative"),e.appendChild(a)),a.style.top="".concat(r.top-s.top+e.scrollTop,"px"),a.style.left="".concat(r.left-s.left+e.scrollLeft,"px"),a.style.width="".concat(r.width,"px"),a.style.height="".concat(r.height,"px")}(e,l,a),l){let e=l.startContainer,t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"})}}function eD(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eM;eR(e)}function eF(e){let[t,n]=(0,i.useState)(!1),[a,r]=(0,i.useState)(""),[s,l]=(0,i.useState)(""),[o,c]=(0,i.useState)([]),[d,u]=(0,i.useState)(0),m=(0,i.useRef)(null),h=(0,i.useRef)(null),x=(0,i.useCallback)(()=>{n(!0),setTimeout(()=>{var e;return null==(e=m.current)?void 0:e.focus()},50)},[]),f=(0,i.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]),p=(0,i.useCallback)(()=>{n(!1),r(""),l(""),c([]),u(0),f()},[f]);(0,i.useEffect)(()=>{if(!a||a.length<2){l(""),f();return}return f(),h.current=setTimeout(()=>{l(a)},300),f},[a,f]),(0,i.useEffect)(()=>{if(!s||s.length<2||!e){c([]),u(0);return}let t=e.split("\n"),n=s.toLowerCase(),a=[];t.forEach((e,t)=>{e.toLowerCase().includes(n)&&a.push(t+1)}),c(a),u(0)},[s,e]);let g=(0,i.useCallback)(()=>{0!==o.length&&u(e=>(e+1)%o.length)},[o.length]),b=(0,i.useCallback)(()=>{0!==o.length&&u(e=>(e-1+o.length)%o.length)},[o.length]);return{searchOpen:t,searchQuery:a,searchMatches:o,searchCurrentIdx:d,searchInputRef:m,openSearch:x,closeSearch:p,nextMatch:g,prevMatch:b,setSearchQuery:r}}var eO=n(90487);function ez(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex h-full items-center justify-center bg-surface text-muted-foreground",children:[(0,r.jsx)(m.y$,{size:"lg",className:"mr-2"}),(0,r.jsx)("span",{children:e("detail.loadingEditor")})]})}n(1226);let e_=(0,o.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(ez,{})}),eB="flex min-h-[44px] min-w-[44px] flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface hover:text-foreground transition-colors touch-manipulation",eV=/^---\s*\nmarp:\s*true/;function eW(e){let{searchInputRef:t,searchQuery:n,searchMatches:a,searchCurrentIdx:s,onQueryChange:l,onPrev:i,onNext:o,onClose:d}=e,u=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border-b border-border",children:[(0,r.jsx)("input",{ref:t,type:"text",value:n,onChange:e=>l(e.target.value),onKeyDown:e=>{"Escape"===e.key&&d(),"Enter"===e.key&&(e.shiftKey?i():o())},placeholder:u("fileSearch.placeholder"),className:"flex-1 min-w-0 px-2 py-0.5 text-sm bg-surface dark:bg-surface-2 text-foreground border border-input rounded outline-none focus:ring-1 focus:ring-ring",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground min-w-[3rem] text-right",children:a.length>0?"".concat(s+1,"/").concat(a.length):"0/0"}),(0,r.jsx)("button",{onClick:i,disabled:0===a.length,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground disabled:text-muted-foreground","aria-label":u("fileSearch.prevMatch"),children:"▲"}),(0,r.jsx)("button",{onClick:o,disabled:0===a.length,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground disabled:text-muted-foreground","aria-label":u("fileSearch.nextMatch"),children:"▼"}),(0,r.jsx)("button",{onClick:d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground","aria-label":u("fileSearch.close"),children:(0,r.jsx)(ew.A,{className:"w-4 h-4"})})]})}let eH="\n<script>\ndocument.addEventListener('click', function(e) {\n var target = e.target;\n while (target && target.tagName !== 'A') {\n target = target.parentElement;\n }\n if (target && target.href) {\n e.preventDefault();\n parent.postMessage({\n type: 'commandmate:link-click',\n href: target.getAttribute('href')\n }, '*');\n }\n});\n<\/script>";function eU(e){let{htmlContent:t,filePath:n}=e,[a,s]=(0,i.useState)("preview"),[l,o]=(0,i.useState)("safe"),d=(0,i.useRef)(new Set),u=(0,c.c)("worktree"),m=(0,ec.SC)(),h=(0,i.useCallback)(async e=>{if("interactive"===e&&!d.current.has(n)){if(!await m({description:u("htmlPreview.interactiveModeConfirm")}))return;d.current.add(n)}o(e)},[n,m,u]),x=(0,i.useMemo)(()=>"interactive"!==l?t:t.includes("</body>")?t.replace("</body>","".concat(eH,"</body>")):t+eH,[t,l]);(0,i.useEffect)(()=>{if("interactive"!==l)return;let e=e=>{if("null"!==e.origin)return;let t=e.data;if(!t||"object"!=typeof t||"commandmate:link-click"!==t.type||"string"!=typeof t.href)return;let n=t.href;(n.startsWith("http://")||n.startsWith("https://"))&&window.open(n,"_blank","noopener,noreferrer")};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[l]);let f=(0,i.useMemo)(()=>{try{return eO.A.highlight(t,{language:"html",ignoreIllegals:!0}).value}catch(e){return eO.A.highlightAuto(t).value}},[t]),p=(0,i.useMemo)(()=>Array.from({length:t.split("\n").length},(e,t)=>t+1),[t]),g=(0,i.useMemo)(()=>f.split("\n"),[f]);return(0,r.jsxs)("div",{className:"flex flex-col h-full","data-testid":"html-preview-mobile",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border bg-muted",children:[(0,r.jsx)("div",{className:"flex gap-1",children:["source","preview"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>s(e),className:"px-3 py-1 text-xs font-medium rounded-md transition-colors ".concat(a===e?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"),children:"source"===e?u("fileViewer.tabSource"):u("fileViewer.tabPreview")},e))}),(0,r.jsx)("div",{className:"flex gap-1",children:["safe","interactive"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>h(e),className:"px-2 py-1 text-xs font-medium rounded-md transition-colors ".concat(l===e?"safe"===e?"bg-success-subtle text-success-foreground":"bg-warning-subtle text-warning-foreground":"text-muted-foreground hover:bg-muted"),children:"safe"===e?u("fileViewer.sandboxSafe"):u("fileViewer.sandboxInteractive")},e))})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto min-h-0",children:"source"===a?(0,r.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,r.jsx)("tbody",{children:p.map(e=>{var t;let n=e-1;return(0,r.jsxs)("tr",{children:[(0,r.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:e}),(0,r.jsx)("td",{className:"px-4 text-foreground align-top",children:(0,r.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono",children:(0,r.jsx)("code",{className:"hljs",dangerouslySetInnerHTML:{__html:null!=(t=g[n])?t:""}})})})]},e)})})}):(0,r.jsx)("iframe",{srcDoc:x,sandbox:ey.Ko[l],title:u("htmlPreview.title",{path:n}),className:"w-full h-full border-0 bg-white"},"".concat(n,"-").concat(l))})]})}let eK=(0,i.memo)(function(e){let{isOpen:t,onClose:n,worktreeId:a,filePath:s,onFileSaved:l,onOpenFile:o}=e,[u,h]=(0,i.useState)(null),[x,f]=(0,i.useState)(!1),[p,g]=(0,i.useState)(null),[b,v]=(0,i.useState)(!1),[y,j]=(0,i.useState)(!1),[w,k]=(0,i.useState)(null),[N,C]=(0,i.useState)(0),[S,T]=(0,i.useState)(!1),[E,I]=(0,i.useState)("viewer"),[M,A]=(0,i.useState)(!1),[L,R]=(0,i.useState)(null),[P,D]=(0,i.useState)(!1),F=(0,i.useRef)(null),O=(0,c.c)("worktree"),_=(0,ec.SC)(),B=u?null!=L?L:u.content:void 0,{searchOpen:V,searchQuery:W,searchMatches:H,searchCurrentIdx:U,searchInputRef:K,openSearch:$,closeSearch:q,nextMatch:G,prevMatch:J,setSearchQuery:Y}=eF(B),Q=(0,i.useMemo)(()=>!!((null==u?void 0:u.content)&&!u.isImage&&!u.isVideo&&!u.isPdf),[u]),X=(null==u?void 0:u.extension)==="md",Z=(0,i.useCallback)(async()=>{if(Q&&B)try{await (0,ej.l)(B),v(!0),setTimeout(()=>v(!1),er.pX)}catch(e){}},[Q,B]),ee=(0,i.useCallback)(async()=>{try{await (0,ej.l)(s),j(!0),setTimeout(()=>j(!1),er.pX)}catch(e){}},[s]),et=(0,i.useCallback)(()=>{T(e=>!e)},[]);(0,i.useEffect)(()=>{if(0===H.length||!F.current)return;let e=H[U],t=F.current.querySelector('[data-line="'.concat(e,'"]'));t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"})},[U,H]),(0,i.useEffect)(()=>{if(!S||X)return;let e=e=>{"Escape"===e.key&&T(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[S,X]),(0,i.useEffect)(()=>{if(!t||!s){h(null),g(null),v(!1),I("viewer"),A(!1),R(null),D(!1),q();return}I("viewer"),A(!1),R(null),D(!1),(async()=>{f(!0),g(null);try{let t=await fetch("/api/worktrees/".concat(a,"/files/").concat((0,eE.o)(s)));if(!t.ok){var e;let n=await t.json(),a="string"==typeof n.error?n.error:(null==(e=n.error)?void 0:e.message)||O("fileViewer.loadError");throw Error(a)}let n=await t.json();h(n)}catch(e){g(e instanceof Error?e.message:O("fileViewer.loadError"))}finally{f(!1)}})()},[t,a,s]),(0,i.useEffect)(()=>{k(null),C(0),u&&"md"===u.extension&&eV.test(u.content)&&!(u.content.length>1e6)&&(async()=>{try{let e=await fetch("/api/worktrees/".concat(a,"/marp-render"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:u.content})});if(e.ok){let t=await e.json();k(t.slides)}}catch(e){}})()},[u,a]);let en=!!(w&&w.length>0),ea=(0,i.useCallback)(e=>{R(e)},[]),es=(0,i.useCallback)((e,t)=>{h(e=>e?{...e,content:t}:e),R(t),null==l||l(e)},[l]),el=(0,i.useCallback)(async()=>{(!P||await _({description:O("editor.unsavedCloseConfirm"),variant:"danger"}))&&n()},[P,_,O,n]);(0,i.useEffect)(()=>{if(!X||M)return;let e=e=>{"Escape"===e.key&&(V?q():S?T(!1):el())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[X,M,V,S,el]);let[ei,eo]=(0,i.useState)("");(0,i.useEffect)(()=>{"viewer"===E&&void 0!==B&&eo(B)},[E,B]),(0,i.useEffect)(()=>{if(!X||!t)return;let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[X,t]);let eb=(0,i.useMemo)(()=>{if(!u||void 0===B||u.isImage||u.isVideo||u.isHtml||u.isPdf)return null;let e=Array.from({length:B.split("\n").length},(e,t)=>t+1);try{return{lineNumbers:e,highlightedHtml:eO.A.highlight(B,{language:u.extension,ignoreIllegals:!0}).value}}catch(t){return{lineNumbers:e,highlightedHtml:eO.A.highlightAuto(B).value}}},[u,B]),ey=()=>u?u.isImage?(0,r.jsx)(ed.a,{src:u.content,alt:u.path,mimeType:u.mimeType}):u.isVideo?(0,r.jsx)(eu.u,{src:u.content,mimeType:u.mimeType}):u.isPdf?(0,r.jsx)("div",{className:"h-full min-h-[40vh]",children:(0,r.jsx)(em.PdfPreview,{dataUri:u.content,filePath:s,variant:"download"})}):u.isHtml?(0,r.jsx)(eU,{htmlContent:u.content,filePath:s}):eI():null,eI=()=>{if(!eb)return null;let e=new Set(H),t=H.length>0?H[U]:-1,n=eb.highlightedHtml.split("\n");return(0,r.jsx)("div",{ref:F,children:(0,r.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,r.jsx)("tbody",{children:eb.lineNumbers.map(a=>{var s;let l=a-1,i=a===t,o=e.has(a);return(0,r.jsxs)("tr",{"data-line":a,className:i?"bg-warning/30":o?"bg-warning/15":"",children:[(0,r.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 ".concat(i||o?"text-warning-foreground":"text-muted-foreground"),children:a}),(0,r.jsx)("td",{className:"px-4 text-foreground align-top",children:(0,r.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono",children:(0,r.jsx)("code",{className:"hljs",dangerouslySetInnerHTML:{__html:null!=(s=n[l])?s:""}})})})]},a)})})})})},eM="/api/worktrees/".concat(a,"/files/").concat((0,eE.o)(s),"?download=1"),eA=s?s.split("/").pop()||s:"",eL=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,r.jsxs)("a",{"data-testid":"download-file-button",href:eM,download:eA,className:e,"aria-label":O("actions.downloadFile"),title:O("actions.download"),children:[(0,r.jsx)(eg.A,{className:"w-3.5 h-3.5"}),t&&(0,r.jsx)("span",{children:O("actions.download")})]})},eR=()=>(0,r.jsxs)("div",{className:"bg-muted px-3 py-1.5 border-b border-border flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)("button",{onClick:ee,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":O("actions.copyFilePath"),title:O("actions.copyPath"),children:y?(0,r.jsx)(ex.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ep.A,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:s})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[Q&&(0,r.jsx)("button",{onClick:$,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":O("actions.searchInFile"),title:O("actions.search"),children:(0,r.jsx)(z.A,{className:"w-3.5 h-3.5"})}),Q&&(0,r.jsx)("button",{"data-testid":"copy-content-button",onClick:Z,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":O("actions.copyFileContent"),title:O("actions.copyContent"),children:b?(0,r.jsx)(ex.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ef.A,{className:"w-3.5 h-3.5"})}),eL("p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground"),(0,r.jsx)("button",{onClick:et,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":S?O("actions.exitFullscreen"):O("actions.fullscreen"),title:S?O("actions.exitFullscreen"):O("actions.fullscreen"),children:S?(0,r.jsx)(ek.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(eN.A,{className:"w-3.5 h-3.5"})})]})]}),eP=()=>(0,r.jsx)(eW,{searchInputRef:K,searchQuery:W,searchMatches:H,searchCurrentIdx:U,onQueryChange:Y,onPrev:J,onNext:G,onClose:q});if(X&&u&&!x&&!p){let e=e=>"flex min-h-[44px] items-center justify-center gap-1 rounded-md px-2 text-xs font-medium touch-manipulation transition-colors ".concat(e?"bg-surface shadow-sm text-accent-600 dark:text-accent-400":"text-muted-foreground hover:text-foreground");return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{"data-testid":"markdown-file-screen",role:"dialog","aria-modal":"true","aria-label":s,className:"fixed inset-0 flex h-[100dvh] flex-col bg-surface",style:{zIndex:eT.M.MAXIMIZED_EDITOR},children:[S?(0,r.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,r.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:et,"aria-pressed":!0,"aria-label":O("actions.exitFullscreen"),className:eB,children:(0,r.jsx)(ek.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void el(),"aria-label":O("actions.close"),className:eB,children:(0,r.jsx)(ew.A,{className:"h-5 w-5"})})]}):(0,r.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-1 border-b border-border bg-muted px-2",children:[(0,r.jsx)("p",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:s}),(0,r.jsxs)("div",{"data-testid":"markdown-file-mode-switch",role:"group","aria-label":O("fileViewer.modeSwitch"),className:"flex flex-shrink-0 items-center gap-0.5 rounded-lg bg-muted p-0.5",children:[(0,r.jsxs)("button",{type:"button","data-testid":"markdown-file-mode-viewer","aria-pressed":"viewer"===E,onClick:()=>I("viewer"),className:e("viewer"===E),children:[(0,r.jsx)(eC.A,{className:"h-4 w-4"}),O("fileViewer.modeViewer")]}),(0,r.jsxs)("button",{type:"button","data-testid":"markdown-file-mode-editor","aria-pressed":"editor"===E,onClick:()=>I("editor"),className:e("editor"===E),children:[(0,r.jsx)(eS.A,{className:"h-4 w-4"}),O("fileViewer.modeEditor")]})]}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-actions-trigger",onClick:()=>A(!0),"aria-label":O("fileViewer.moreActions"),className:eB,children:(0,r.jsx)(d.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:et,"aria-pressed":!1,"aria-label":O("actions.fullscreen"),className:eB,children:(0,r.jsx)(eN.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void el(),"aria-label":O("actions.close"),className:eB,children:(0,r.jsx)(ew.A,{className:"h-5 w-5"})})]}),V&&(0,r.jsx)("div",{className:"flex-shrink-0",children:eP()}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,r.jsx)("div",{className:"viewer"===E?"flex min-h-0 flex-1 flex-col":"hidden",children:V?(0,r.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:eI()}):en?w?(0,r.jsxs)("div",{className:"flex h-full flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-2 bg-muted border-b border-border",children:[(0,r.jsx)("button",{type:"button",onClick:()=>C(e=>Math.max(0,e-1)),disabled:0===N,className:"min-h-[44px] px-3 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors touch-manipulation",children:O("actions.prev")}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground",children:[N+1," / ",w.length]}),(0,r.jsx)("button",{type:"button",onClick:()=>C(e=>Math.min(w.length-1,e+1)),disabled:N===w.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:O("actions.next")})]}),(0,r.jsx)("iframe",{srcDoc:w[N],sandbox:"",title:O("fileViewer.slideTitle",{name:s,number:N+1}),className:"w-full flex-1 border-0"})]}):null:(0,r.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,r.jsx)(eh.G8,{content:ei,currentFilePath:s,worktreeId:a,onOpenFile:o})})}),(0,r.jsx)("div",{"data-testid":"markdown-file-editor",className:"editor"===E?"flex min-h-0 flex-1 flex-col":"hidden",children:(0,r.jsx)(e_,{worktreeId:a,filePath:s,initialContent:u.content,embedded:!0,onSave:es,onDirtyChange:D,onContentChange:ea,onOpenFile:o},s)})]}),(0,r.jsx)(ev,{open:M,onClose:()=>A(!1),onSearch:()=>{I("viewer"),$()},onCopyContent:Z,onCopyPath:ee,downloadUrl:eM,downloadName:eA,contentCopied:b,pathCopied:y})]})})}return S&&u&&!x&&!p?(0,r.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:eT.M.MAXIMIZED_EDITOR},children:[eR(),V&&eP(),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:ey()})]}):(0,r.jsx)(m.Jh,{isOpen:t,onClose:n,title:s,size:"xl",children:(0,r.jsxs)("div",{className:"max-h-[60vh] sm:max-h-[70vh] flex flex-col",children:[x&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,r.jsx)(m.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"ml-3 text-muted-foreground",children:O("fileViewer.loading")})]}),p&&(0,r.jsxs)("div",{className:"bg-danger-subtle border border-danger-border rounded-lg p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-5 h-5 text-danger-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsx)("p",{className:"text-sm text-danger-foreground",children:p})]}),(0,r.jsx)("div",{className:"mt-3",children:eL("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)})]}),u&&!x&&!p&&(0,r.jsxs)("div",{className:"bg-muted rounded-lg overflow-hidden flex flex-col min-h-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex-shrink-0",children:[eR(),V&&eP()]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:ey()})]})]})})});var e$=n(46892),eq=n(41898),eG=n(26232),eJ=n(50857),eY=n(94442);function eQ(e){let{worktreeId:t}=e,[n,a]=(0,i.useState)([]),[s,l]=(0,i.useState)(null),[o,d]=(0,i.useState)(null),[u,h]=(0,i.useState)(!0),[f,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(""),[v,y]=(0,i.useState)(0),[j,w]=(0,i.useState)("all"),[k,N]=(0,i.useState)(!1),{showToast:C}=(0,eY.dj)(),S=(0,c.c)("worktree");(0,i.useEffect)(()=>{(async()=>{try{h(!0),p(null);let e=await V.y.getLogs(t);a(e)}catch(e){p((0,V.hS)(e))}finally{h(!1)}})()},[t]);let T=(0,i.useMemo)(()=>"all"===j?n:n.filter(e=>e.toLowerCase().includes(j)),[n,j]),E=async e=>{try{h(!0),p(null);let n=await V.y.getLogFile(t,e);d(n.content),l(e),b(""),y(0)}catch(e){p((0,V.hS)(e))}finally{h(!1)}},I=(0,i.useCallback)(async()=>{if(s)try{N(!0);let e=await V.y.getLogFile(t,s,{sanitize:!0});await (0,ej.l)(e.content),C(S("logViewer.copied"),"success")}catch(e){C(S("logViewer.exportError",{error:(0,V.hS)(e)}),"error")}finally{N(!1)}},[t,s,C,S]),M=(0,i.useMemo)(()=>{let e;if(!g||!o)return[];let t=RegExp((0,x.Nt)(g),"gi"),n=[];for(;null!==(e=t.exec(o));)n.push({index:e.index,length:e[0].length});return n},[g,o]);(0,i.useEffect)(()=>{y(0)},[g]);let A=()=>{M.length>0&&y(e=>(e+1)%M.length)},L=()=>{M.length>0&&y(e=>(e-1+M.length)%M.length)},R=(0,i.useMemo)(()=>{if(!o||!g||0===M.length)return o;let e="",t=0;return M.forEach((n,a)=>{e+=(0,x.ZD)(o.substring(t,n.index));let r=o.substring(n.index,n.index+n.length),s=a===v;e+='<mark class="'.concat(s?"bg-warning text-black":"bg-warning-border text-black",'" data-match-index="').concat(a,'">').concat((0,x.ZD)(r),"</mark>"),t=n.index+n.length}),e+=(0,x.ZD)(o.substring(t))},[o,g,M,v]);return(0,i.useEffect)(()=>{M.length>0&&v>=0&&setTimeout(()=>{let e=document.querySelector('mark[data-match-index="'.concat(v,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"})},100)},[v,M.length]),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(m.Zp,{padding:"md",children:[(0,r.jsx)(m.aR,{children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(m.ZB,{children:S("logViewer.title")}),(0,r.jsx)(m.Ex,{variant:"gray",children:T.length})]}),(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,r.jsx)(m.$n,{variant:"all"===j?"primary":"ghost",size:"sm",onClick:()=>w("all"),children:S("logViewer.all",{count:n.length})}),(0,r.jsx)(m.$n,{variant:"claude"===j?"primary":"ghost",size:"sm",onClick:()=>w("claude"),children:S("logViewer.toolCount",{tool:"Claude",count:n.filter(e=>e.toLowerCase().includes("claude")).length})}),(0,r.jsx)(m.$n,{variant:"codex"===j?"primary":"ghost",size:"sm",onClick:()=>w("codex"),children:S("logViewer.toolCount",{tool:"Codex",count:n.filter(e=>e.toLowerCase().includes("codex")).length})}),(0,r.jsx)(m.$n,{variant:"gemini"===j?"primary":"ghost",size:"sm",onClick:()=>w("gemini"),children:S("logViewer.toolCount",{tool:"Gemini",count:n.filter(e=>e.toLowerCase().includes("gemini")).length})}),(0,r.jsx)(m.$n,{variant:"antigravity"===j?"primary":"ghost",size:"sm",onClick:()=>w("antigravity"),children:S("logViewer.toolCount",{tool:"Antigravity",count:n.filter(e=>e.toLowerCase().includes("antigravity")).length})})]})]})}),(0,r.jsxs)(m.Wu,{children:[u&&0===n.length&&(0,r.jsx)("div",{className:"text-center py-4",children:(0,r.jsx)(m.y$,{size:"lg",variant:"accent",className:"inline-block"})}),f&&(0,r.jsx)("div",{className:"p-3 bg-danger-subtle border border-danger-border rounded text-sm text-danger-foreground",children:f}),!u&&0===T.length&&!f&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:"all"===j?S("logViewer.empty"):S("logViewer.emptyFiltered",{tool:j})}),T.length>0&&(0,r.jsx)("div",{className:"space-y-2",children:T.map(e=>(0,r.jsx)("button",{onClick:()=>E(e),className:"w-full text-left px-3 py-2 rounded text-sm font-mono transition-colors ".concat(s===e?"bg-accent-50 text-accent-700 border border-accent-200":"hover:bg-muted border border-transparent"),children:e},e))})]})]}),s&&(0,r.jsxs)(m.Zp,{padding:"md",children:[(0,r.jsx)(m.aR,{children:(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(m.ZB,{className:"font-mono text-base",children:s}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:I,disabled:!s||k,title:S("logViewer.copyTitle"),children:k?S("logViewer.exporting"):S("logViewer.export")}),(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:()=>{l(null),d(null),b(""),y(0)},children:S("actions.close")})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)(m.pd,{type:"text",value:g,onChange:e=>b(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?L():A())},placeholder:S("logViewer.searchPlaceholder"),className:"w-full pr-20"}),M.length>0&&(0,r.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-muted-foreground",children:[v+1," / ",M.length]})]}),M.length>0&&(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:L,disabled:0===M.length,title:S("logViewer.prevMatch"),children:"↑"}),(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:A,disabled:0===M.length,title:S("logViewer.nextMatch"),children:"↓"})]})]})]})}),(0,r.jsxs)(m.Wu,{children:[u&&(0,r.jsx)("div",{className:"text-center py-8",children:(0,r.jsx)(m.y$,{size:"xl",variant:"accent",className:"inline-block"})}),!u&&o&&(0,r.jsx)("div",{className:"bg-[#111827] text-[#f3f4f6] rounded p-4 overflow-x-auto max-h-[500px] scrollbar-thin",children:g&&M.length>0?(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",dangerouslySetInnerHTML:{__html:R||""}}):(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",children:o})}),!u&&g&&0===M.length&&o&&(0,r.jsx)("div",{className:"text-center py-4 text-sm text-muted-foreground",children:S("logViewer.noMatches",{query:g})})]})]})]})}function eX(){let[e,t]=(0,i.useState)(null),[n,a]=(0,i.useState)(!0),[r,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return async function(){try{a(!0),s(null);let n=await V.GQ.checkForUpdate();e||t(n)}catch(t){e||s(t instanceof Error?t.message:"Failed to check for updates")}finally{e||a(!1)}}(),()=>{e=!0}},[]),{data:e,loading:n,error:r}}var eZ=n(31166);function e0(e){let{hasUpdate:t,latestVersion:n,releaseUrl:a,updateCommand:s,installType:l}=e,o=(0,c.c)("worktree"),[d,m]=(0,i.useState)("idle"),[h,x]=(0,i.useState)(null),[f,p]=(0,i.useState)(null),g=(0,i.useRef)(!1),b="global"===l,v="npx"===l,y=b||v,j=v?"npx commandmate@latest":"commandmate update",w=(0,i.useCallback)(async()=>{m("starting");try{let e=await V.GQ.startUpdate();x(e.logPath),m(e.willRestart?"updating":"no-restart")}catch(e){e instanceof V.hD&&400===e.status?p(o("update.errorNotGlobal")):e instanceof V.hD&&409===e.status?p(o("update.errorInProgress")):p(o("update.errorGeneric")),m("error")}},[o]);return((0,i.useEffect)(()=>{if("updating"!==d)return;let e=!1,t=Date.now();g.current=!1;let n=setInterval(async()=>{if(e)return;if(Date.now()-t>3e5)return void m("timeout");let n=await V.GQ.ping();if(!e){if(!n){g.current=!0;return}g.current&&window.location.reload()}},2e3);return()=>{e=!0,clearInterval(n)}},[d]),t)?(0,r.jsxs)("div",{className:"bg-accent-50 border border-accent-200 rounded-lg p-3 mt-2",role:"status","aria-label":o("update.available"),"data-testid":"update-notification-banner",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-accent-800 mb-1",children:o("update.available")}),n&&(0,r.jsx)("p",{className:"text-sm text-accent-700 mb-2",children:o("update.latestVersion",{version:n})}),y&&"idle"===d&&(0,r.jsx)(eZ.$,{variant:"primary",size:"sm",className:"mb-2",onClick:()=>m("confirming"),"data-testid":"update-now-button",children:o("update.updateNow")}),v&&"idle"===d&&(0,r.jsx)("p",{className:"text-xs text-accent-600 mb-2","data-testid":"update-npx-notice",children:o("update.npxRestartNotice")}),("starting"===d||"updating"===d)&&(0,r.jsxs)("div",{className:"mb-2","data-testid":"update-progress",children:[(0,r.jsxs)("p",{className:"flex items-center text-sm text-accent-800",children:[(0,r.jsx)(u.y,{size:"sm",className:"mr-2"}),"starting"===d?o("update.starting"):o("update.updating")]}),"updating"===d&&(0,r.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:o("update.updatingHint")})]}),"no-restart"===d&&(0,r.jsxs)("div",{className:"mb-2","data-testid":"update-no-restart",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-accent-800",children:o("update.noRestartTitle")}),(0,r.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:o("update.noRestartDescription")})]}),"timeout"===d&&(0,r.jsxs)("div",{className:"mb-2","data-testid":"update-timeout",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-accent-800",children:o("update.timeoutTitle")}),(0,r.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:o("update.timeoutDescription")}),(0,r.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 mt-1 text-xs text-accent-900 font-mono",children:j})]}),"error"===d&&(0,r.jsxs)("div",{className:"mb-2","data-testid":"update-error",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-accent-800",children:o("update.errorTitle")}),(0,r.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:f}),(0,r.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 mt-1 text-xs text-accent-900 font-mono",children:j})]}),h&&("no-restart"===d||"timeout"===d)&&(0,r.jsx)("p",{className:"text-xs text-accent-500 mb-2","data-testid":"update-log-hint",children:o("update.logHint",{path:h})}),s&&b&&"idle"===d&&(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("p",{className:"text-xs text-accent-600 mb-1",children:o("update.updateCommand")}),(0,r.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 text-xs text-accent-900 font-mono",children:s})]}),a&&(0,r.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:[o("update.viewRelease"),(0,r.jsx)("span",{className:"ml-1","aria-hidden":"true",children:"→"})]}),(0,r.jsx)("p",{className:"text-xs text-accent-500 mt-2",children:o("update.dataPreserved")}),(0,r.jsx)(ec.TM,{isOpen:"confirming"===d,title:o("update.confirmTitle"),description:o("update.confirmDescription",{version:null!=n?n:""}),confirmLabel:o("update.confirmButton"),onConfirm:w,onCancel:()=>m("idle")})]}):null}function e1(e){let{version:t,className:n}=e,a=(0,c.c)("worktree"),{data:s,loading:l}=eX(),o=(0,i.useMemo)(()=>s&&s.hasUpdate?{hasUpdate:s.hasUpdate,latestVersion:s.latestVersion,releaseUrl:s.releaseUrl,updateCommand:s.updateCommand,installType:s.installType}:null,[s]);return(0,r.jsxs)("div",{className:n,"data-testid":"version-section",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:a("update.version")}),(0,r.jsx)("p",{className:"text-sm text-foreground",children:t}),l&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1","data-testid":"version-loading",children:"..."}),o&&(0,r.jsx)(e0,{...o})]})}let e2="https://github.com/Kewton/CommandMate",e4="".concat(e2,"/issues"),e5="".concat(e2,"/issues/new"),e3="".concat(e5,"?template=bug_report.md"),e6="".concat(e5,"?template=feature_request.md"),e8="".concat(e5,"?template=question.md");function e9(e){let{className:t}=e,n=(0,c.c)("worktree"),a=[{href:e3,label:n("feedback.bugReport")},{href:e6,label:n("feedback.featureRequest")},{href:e8,label:n("feedback.question")},{href:e4,label:n("feedback.viewIssues")}];return(0,r.jsxs)("div",{className:t,"data-testid":"feedback-section",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-2",children:n("feedback.title")}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:a.map(e=>{let{href:t,label:n}=e;return(0,r.jsxs)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-accent-600 hover:text-accent-800 underline",children:[n,(0,r.jsx)("span",{className:"ml-1","aria-hidden":"true",children:"→"})]},t)})})]})}var e7=n(94465),te=n(38606),tt=n(54014),tn=n(24033);let ta="application/x-commandmate-agent-instance",tr=(0,i.memo)(function(e){let{splitIndex:t,cliToolId:n,instanceId:a,instance:s,availableInstances:l,onInstanceChange:o,status:d="idle",agentModel:u,onFocus:m,attaching:x=!1,headerExtras:f,terminal:p,footer:g,style:b,onDropInstance:v,draggedInstanceId:y}=e,j=(0,c.c)("worktree"),[w,k]=(0,i.useState)(null),N=null!=v,C=(0,i.useCallback)(()=>null==y||l.some(e=>e.id===y)?"allowed":"forbidden",[y,l]),S=(0,i.useCallback)(e=>{if(!N)return;e.preventDefault();let t=C();e.dataTransfer.dropEffect="forbidden"===t?"none":"move",k(e=>e===t?e:t)},[N,C]),T=(0,i.useCallback)(e=>{if(!N)return;e.preventDefault();let t=C();k(e=>e===t?e:t)},[N,C]),E=(0,i.useCallback)(()=>{N&&k(null)},[N]),I=(0,i.useCallback)(e=>{if(!N)return;e.preventDefault(),k(null);let t=e.dataTransfer.getData(ta);t&&(null==v||v(t))},[N,v]),M=(0,i.useCallback)(()=>{window.dispatchEvent(new CustomEvent("terminal-search-open"))},[]),A=(0,i.useCallback)(()=>{m()},[m]),L="Terminal split ".concat(t+1),R=(0,tt.sw)(null!=s?s:{cliTool:n}),P=j("terminal.selectInstance",{split:L});return(0,r.jsxs)("div",{role:"region","aria-label":L,"data-testid":"terminal-split-pane-".concat(t),"data-split-index":t,style:b,className:"flex flex-col min-w-0 h-full rounded-lg overflow-hidden border border-border bg-surface".concat(null===w?" focus-within:ring-1 focus-within:ring-accent-500/30":"").concat("allowed"===w?" ring-2 ring-accent-400":"forbidden"===w?" ring-2 ring-red-300 cursor-not-allowed":""),onFocusCapture:A,onMouseDown:m,onDragOver:S,onDragEnter:T,onDragLeave:E,onDrop:I,children:[(0,r.jsxs)("div",{className:"px-2 py-1 flex items-center gap-2 bg-surface-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)(eG.rI,{children:[(0,r.jsxs)(eG.ty,{"data-testid":"cli-selector-".concat(t),"aria-label":P,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,r.jsx)(h.m,{status:d,size:"sm","aria-hidden":!0,"data-testid":"split-status-indicator-".concat(t)}),(0,r.jsx)("span",{className:"truncate",children:R}),(0,r.jsx)(tn.A,{size:14,"aria-hidden":"true",className:"flex-shrink-0 opacity-70"})]}),(0,r.jsx)(eG.SQ,{align:"start",className:"min-w-[10rem]",children:(0,r.jsx)(eG.Hr,{value:a,onValueChange:o,children:l.map(e=>(0,r.jsx)(eG.Ht,{value:e.id,children:(0,tt.sw)(e)},e.id))})})]}),u&&(0,r.jsx)("span",{"data-testid":"split-agent-model-".concat(t),title:j("agentModel.modelLabel",{model:u}),className:"min-w-0 max-w-[10rem] truncate text-[11px] leading-none text-muted-foreground",children:u}),f,(0,r.jsx)("button",{type:"button",onClick:M,"aria-label":"Search terminal output for ".concat(L),"data-testid":"terminal-search-button-".concat(t),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,r.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,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[x?(0,r.jsxs)("div",{"data-testid":"terminal-attach-skeleton-".concat(t),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 ",R," session..."]}):null,p]}),(0,r.jsx)("div",{className:"flex-shrink-0 border-t border-border p-2 bg-surface-2",children:g})]})});var ts=n(34681),tl=n(20562),ti=n(8803),to=n(46980),tc=n.n(to),td=n(62459),tu=n.n(td);let tm="[... 古い出力を省略しました / older output truncated ...]",th=new(tu())({fg:"#d1d5db",bg:"#1f2937",newline:!0,escapeXML:!0}),tx=/[\x40-\x7e]/;function tf(e){let t=function(e){if(e.length<=1048576)return e;let t=tm+"\n",n=1048576-t.length;if(n<=0)return tm.slice(0,1048576);let a=e.length-n,r=e.indexOf("\n",a);if(-1!==r&&r-a<=65536)return t+e.slice(r+1);let s=function(e,t){let n=e.lastIndexOf("\x1b",t-1);if(-1===n)return t;let a=e.slice(n+1,t);if(tx.test(a.slice(1)))return t;for(let n=t;n<e.length;n++)if(tx.test(e[n]))return n+1;return e.length}(e,a),l=e.charCodeAt(s);return l>=56320&&l<=57343&&(s+=1),t+e.slice(s)}(e.replace(/\0/g,"")),n=th.toHtml(t);return tc().sanitize(n,{ALLOWED_TAGS:["span","br"],ALLOWED_ATTR:["style"],ALLOW_DATA_ATTR:!1})}let tp=/\x1b(?:\[[0-9;?]*)?$/,tg=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\[[0-9;]*m/g;function tb(e){return e.replace(tg,"")}function tv(e){return""===tb(e).trim()}function ty(e){let{query:t,onQueryChange:n,matchCount:a,currentIndex:s,onNext:l,onPrev:o,onClose:c,isAtMaxMatches:d=!1}=e,u=(0,i.useRef)(null);(0,i.useEffect)(()=>{var e;null==(e=u.current)||e.focus()},[]);let m=(0,i.useCallback)(e=>{"Escape"===e.key&&c()},[c]),h=(0,i.useCallback)(e=>{n(e.target.value)},[n]),x=0===a?"0/0":d?"".concat(s+1,"/").concat(500,"以上"):"".concat(s+1,"/").concat(a);return(0,r.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,r.jsx)("input",{ref:u,type:"text",value:t,onChange:h,onKeyDown:m,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,r.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"text-gray-400 text-xs min-w-[3rem] text-right",children:x}),(0,r.jsx)("button",{onClick:o,disabled:0===a,"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,r.jsx)("button",{onClick:l,disabled:0===a,"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,r.jsx)("button",{onClick:c,"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 tj(){return(0,r.jsxs)("div",{"data-testid":"thinking-indicator",className:"flex items-center gap-2 py-2 px-1 text-gray-400",children:[(0,r.jsxs)("span",{className:"flex gap-1",children:[(0,r.jsx)("span",{className:"animate-pulse delay-0",children:"."}),(0,r.jsx)("span",{className:"animate-pulse delay-150",children:"."}),(0,r.jsx)("span",{className:"animate-pulse delay-300",children:"."})]}),(0,r.jsx)("span",{className:"text-sm",children:"Thinking"})]})}let tw=(0,i.memo)(function(e){let{output:t,isActive:n,attaching:a=!1,isThinking:s=!1,autoScroll:l=!0,onScrollChange:o,disableAutoFollow:c=!1,compactTuiLayoutPadding:d=!1,className:u=""}=e,{scrollRef:m,autoScroll:h,handleScroll:x,scrollToBottom:f,scrollToTop:p}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{initialAutoScroll:t=!0,onAutoScrollChange:n}=e,a=(0,i.useRef)(null),[r,s]=(0,i.useState)(t),l=(0,i.useRef)(!1),o=(0,i.useRef)(null);(0,i.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]);let c=(0,i.useCallback)(e=>{s(e),null==n||n(e)},[n]),d=(0,i.useCallback)(()=>{let e=a.current;if(!e)return!0;let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;return n-r-t<=50},[]),u=(0,i.useCallback)(()=>{if(l.current)return;let e=d();e&&!r?c(!0):!e&&r&&c(!1)},[r,d,c]),m=(0,i.useCallback)(()=>{let e=a.current;e&&(l.current=!0,e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),r||c(!0),o.current=setTimeout(()=>{l.current=!1,o.current=null},500))},[r,c]),h=(0,i.useCallback)(()=>{let e=a.current;e&&(l.current=!0,e.scrollTo({top:0,behavior:"smooth"}),r&&c(!1),o.current=setTimeout(()=>{l.current=!1,o.current=null},500))},[r,c]);return{scrollRef:a,autoScroll:r,setAutoScroll:c,scrollToBottom:m,scrollToTop:h,handleScroll:u}}({initialAutoScroll:l,onAutoScrollChange:o}),g=null!=t?t:"",b=(0,i.useMemo)(()=>d?function(e){if(""===e)return"";let t=e.split("\n"),n=[],a=!1,r=0;for(;r<t.length;){if(!tv(t[r])){n.push(t[r]),a=!0,r++;continue}let e=r;for(;e<t.length&&tv(t[e]);)e++;let s=e-r,l=!a,i=e>=t.length;if(!l&&!i)if(s<=2)for(let a=r;a<e;a++)n.push(t[a]);else n.push(function(e){let t=e.match(tg);return t?t.join(""):""}(t.slice(r,e).join("")));r=e}return n.join("\n")}(g):g,[d,g]),{isOpen:v,query:y,matchCount:j,currentIndex:w,isAtMaxMatches:k,openSearch:N,closeSearch:C,setQuery:S,nextMatch:T,prevMatch:E}=function(e){let{output:t,containerRef:n}=e,[a,r]=(0,i.useState)(!1),[s,l]=(0,i.useState)(""),[o,c]=(0,i.useState)([]),[d,u]=(0,i.useState)(0),[m,h]=(0,i.useState)(!1),x=(0,i.useRef)(null),f=(0,i.useRef)(""),p=o.length,g=(0,i.useCallback)(e=>{var t;if(e.length<2||!n.current)return{positions:[],capped:!1};let a=(null!=(t=n.current.textContent)?t:"").toLowerCase(),r=e.toLowerCase(),s=[],l=0;for(;s.length<500;){let t=a.indexOf(r,l);if(-1===t)break;s.push({start:t,end:t+e.length}),l=t+1}let i=s.length>=500&&-1!==a.indexOf(r,l);return{positions:s,capped:i}},[n]),b=(0,i.useCallback)(e=>{let{positions:t,capped:a}=g(e);if(c(t),u(0),h(a),n.current)if(t.length>0){var r;r=n.current,eP(r,t,0,eI)}else eR(eI)},[g,n]),v=(0,i.useCallback)(e=>{l(e),x.current&&clearTimeout(x.current),f.current=e,x.current=setTimeout(()=>{b(e)},300)},[b]),y=(0,i.useCallback)(()=>{r(!0)},[]),j=(0,i.useCallback)(()=>{r(!1),l(""),f.current="",c([]),u(0),h(!1),x.current&&clearTimeout(x.current),eR(eI)},[]),w=(0,i.useCallback)(()=>{0!==p&&u(e=>{let t=(e+1)%p;return n.current&&o.length>0&&eP(n.current,o,t,eI),t})},[p,o,n]),k=(0,i.useCallback)(()=>{0!==p&&u(e=>{let t=(e-1+p)%p;return n.current&&o.length>0&&eP(n.current,o,t,eI),t})},[p,o,n]);return(0,i.useEffect)(()=>{f.current.length<2||b(f.current)},[t,b]),(0,i.useEffect)(()=>()=>{x.current&&clearTimeout(x.current),eR(eI)},[]),{isOpen:a,query:s,matchCount:p,currentIndex:d,isAtMaxMatches:m,openSearch:y,closeSearch:j,setQuery:v,nextMatch:w,prevMatch:k}}({output:b,containerRef:m}),I=(0,i.useCallback)(e=>{(e.ctrlKey||e.metaKey)&&"f"===e.key&&(e.preventDefault(),N())},[N]);(0,i.useEffect)(()=>{let e=()=>N();return window.addEventListener("terminal-search-open",e),()=>window.removeEventListener("terminal-search-open",e)},[N]);let[M,A]=(0,i.useState)(()=>b?[{key:0,html:tf(b)}]:[]),L=(0,i.useRef)(b),R=(0,i.useRef)(0);(0,i.useEffect)(()=>{let e=function(e,t){if(e===t)return{mode:"noop",text:t,appended:"",retainedLength:e.length};if(0===e.length||t.length<=e.length||!t.startsWith(e))return{mode:"replace",text:t,appended:"",retainedLength:0};let n=e.match(tp),a=n?e.length-n[0].length:e.length;return{mode:"append",text:t,appended:t.slice(a),retainedLength:a}}(L.current,b);if(L.current=b,"noop"===e.mode)return;let t="append"===e.mode&&e.appended.length>1048576;if("append"===e.mode&&!t)return void A(t=>(R.current+=1,t.length>=400)?[{key:R.current,html:tf(b)}]:[...t,{key:R.current,html:tf(e.appended)}]);R.current+=1,A(b?[{key:R.current,html:tf(b)}]:[])},[b]);let[P,D]=(0,i.useState)(!1);(0,i.useEffect)(()=>{a?D(!1):n&&D(!0)},[a,n]);let F=!t,O=F&&a,z=F&&!a&&!n&&P,_=(0,i.useRef)(!1);(0,i.useEffect)(()=>{c&&(_.current=!0)},[c]),(0,i.useEffect)(()=>{if(m.current){if(_.current&&c&&b){m.current.scrollTo({top:0,behavior:"instant"}),_.current=!1;return}!c&&h&&m.current.scrollTo({top:m.current.scrollHeight,behavior:"instant"})}},[M,b,h,c,m]);let B=(0,i.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",n?"active":"",u].filter(Boolean).join(" "),[n,u]),[V,W]=(0,i.useState)(!1),H=(0,i.useRef)(null),U=(0,i.useCallback)(()=>{W(!0),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>W(!1),1500)},[]);(0,i.useEffect)(()=>()=>{H.current&&clearTimeout(H.current)},[]);let K=(0,i.useCallback)(()=>{x(),U()},[x,U]),$=["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",V?"opacity-100":"opacity-60"].join(" ");return(0,r.jsxs)("div",{className:"relative h-full flex flex-col",children:[v&&(0,r.jsx)("div",{className:"absolute top-2 right-2 z-10",children:(0,r.jsx)(ty,{query:y,onQueryChange:S,matchCount:j,currentIndex:w,onNext:T,onPrev:E,onClose:C,isAtMaxMatches:k})}),(0,r.jsxs)("div",{ref:m,role:"log","aria-live":"polite","aria-label":"Terminal output",className:B,onScroll:K,onKeyDown:I,tabIndex:0,children:[(0,r.jsx)("div",{className:"whitespace-pre-wrap break-words",children:M.map(e=>(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:e.html}},e.key))}),O&&(0,r.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:"読込中..."}),z&&(0,r.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:"セッションは終了しました(メッセージ送信で再開できます)"}),n&&s&&(0,r.jsx)(tj,{})]}),h?(0,r.jsx)("button",{type:"button",onClick:p,className:$,"aria-label":"Scroll to top",children:(0,r.jsx)(tl.A,{size:16,"aria-hidden":"true"})}):(0,r.jsx)("button",{type:"button",onClick:f,className:$,"aria-label":"Scroll to bottom",children:(0,r.jsx)(ti.A,{size:16,"aria-hidden":"true"})})]})}),tk=[{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"}],tN={key:"Escape",label:"Esc",ariaLabel:"Send Escape"},tC={key:"q",label:"q",ariaLabel:"Send q (quit)"};function tS(e){let{worktreeId:t,cliToolId:n,instanceId:a,onKeysSent:s}=e,[l,o]=(0,i.useState)(null),c=es(t,n,a,s),d="codex"===n?[...tk,tN,tC]:[...tk,tN],u=(0,i.useCallback)(e=>{o(e),setTimeout(()=>o(null),er.tX),c([e])},[c]);return(0,r.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,r.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"}),d.map(e=>{let{key:t,label:n,ariaLabel:a}=e;return(0,r.jsx)("button",{type:"button",className:"min-w-[44px] min-h-[44px] px-3 py-2 text-sm font-medium rounded-md\n border border-amber-300 dark:border-amber-700\n focus:outline-none focus:ring-2 focus:ring-amber-500\n transition-colors duration-75\n ".concat(l===t?"bg-amber-500 text-white border-amber-500 scale-95":"bg-white dark:bg-gray-700 hover:bg-amber-50 dark:hover:bg-gray-600 active:bg-amber-100 dark:active:bg-gray-500"),"aria-label":a,onClick:()=>u(t),children:n},t)})]})}function tT(e){return""!==(null!=e?e:"").trim()}function tE(e){let{worktreeId:t,cliToolId:n,instanceId:a,composerText:s,onActionSent:l}=e,o=(0,c.c)("worktree"),[d,u]=(0,i.useState)(!1),m=es(t,n,a,l),h=(0,i.useCallback)(()=>{m(["Enter"])},[m]),x=(0,i.useCallback)(()=>{u(!0);let e=a&&a!==n?{cliToolId:n,instanceId:a}:{cliToolId:n};fetch("/api/worktrees/".concat(encodeURIComponent(t),"/clear-composer"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(()=>{l&&setTimeout(l,er.LK)}).catch(e=>{console.error("Failed to clear composer:",e)}).finally(()=>{u(!1)})},[t,n,a,l]);if(!tT(s))return null;let f=s.length>300?"".concat(s.slice(0,300),"…"):s;return(0,r.jsxs)("div",{"data-testid":"unsent-composer-bar",role:"region","aria-label":o("unsentComposer.regionLabel"),className:"flex flex-wrap items-center gap-2 px-2 py-1.5 bg-info-subtle border border-info-border rounded-lg",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-info-foreground shrink-0",children:o("unsentComposer.label")}),(0,r.jsx)("code",{"data-testid":"unsent-composer-text",className:"flex-1 min-w-0 font-mono text-xs text-foreground break-all line-clamp-3 whitespace-pre-wrap",children:f}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:h,"aria-label":o("unsentComposer.run"),className:"min-h-[32px] px-3 rounded-md text-xs font-medium bg-info-foreground text-info-subtle hover:opacity-90 transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background",children:o("unsentComposer.run")}),(0,r.jsx)("button",{type:"button",onClick:x,disabled:d,"aria-label":o("unsentComposer.clear"),className:"min-h-[32px] px-3 rounded-md text-xs font-medium bg-surface border border-info-border text-info-foreground hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background",children:o("unsentComposer.clear")})]})]})}var tI=n(63365);let tM=/^[>❯]/,tA=/^\u203A/;function tL(e){return void 0===e||""===tb(e).trim()}function tR(e){let t=[],n={dim:!1,bold:!1},a=0;for(;a<e.length;){let r=e[a];if("\x1b"!==r){t.push({ch:r,dim:n.dim,bold:n.bold}),a++;continue}let s=e[a+1];if("["===s){let t=a+2;for(;t<e.length&&!/[A-Za-z]/.test(e[t]);)t++;if(t>=e.length)break;"m"===e[t]&&(n=function(e,t){let n=""===e?["0"]:e.split(";"),{dim:a,bold:r}=t;for(let e=0;e<n.length;e++){let t=""===n[e]?0:Number(n[e]);if(!Number.isNaN(t)){if(38===t||48===t||58===t){let t=""===n[e+1]||void 0===n[e+1]?-1:Number(n[e+1]);5===t?e+=2:2===t?e+=4:e+=1;continue}0===t||22===t?(a=!1,r=!1):1===t?r=!0:2===t&&(a=!0)}}return{dim:a,bold:r}}(e.slice(a+2,t),n)),a=t+1;continue}if("]"===s){let t=a+2;for(;t<e.length;){if("\x07"===e[t]){t++;break}if("\x1b"===e[t]&&"\\"===e[t+1]){t+=2;break}t++}a=t;continue}a+=2}return t}let tP=new Set(["claude","codex"]);function tD(e){let t=e.length;for(;t>0&&""===e[t-1].trim();)t--;return e.slice(0,t)}function tF(e){let{worktreeId:t,cliToolId:n,instanceId:a,enabled:r=!0}=e,s=null!=a?a:n,[l,o]=(0,i.useState)(()=>({output:"",realtimeSnippet:"",isRunning:!1,isThinking:!1,isSelectionListActive:!1,isPagerActive:!1,isUnclassifiedActive:!1,composerText:"",attaching:!0,autoScroll:!0})),[c,d]=(0,i.useState)(()=>({visible:!1,data:null,messageId:null,answering:!1})),u=(0,i.useRef)(0),m=(0,i.useRef)(n);m.current=n;let h=(0,i.useRef)(s);h.current=s;let x=(0,i.useRef)(c.visible);x.current=c.visible;let{connected:f,subscribe:p,unsubscribe:g,addListener:b}=(0,tI.xM)(),v=(0,i.useRef)(0),y=(0,i.useRef)(0),j=(0,i.useRef)(null),w=(0,i.useRef)(null),[k,N]=(0,i.useState)(!1),C=(0,i.useCallback)(()=>{N(!0),null!==w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{w.current=null,N(!1)},5e3)},[]),S=(0,i.useCallback)(e=>{var t,n;let a=null!=(n=null!=(t=e.fullOutput)?t:e.realtimeSnippet)?n:"";!0===e.isUnclassifiedActive&&!0!==e.isPromptWaiting&&!0!==e.isSelectionListActive&&!0!==e.isPagerActive?(y.current+=1,null!=j.current||(j.current=Date.now())):(y.current=0,j.current=null);let r=y.current>=2&&null!==j.current&&Date.now()-j.current>=500,s=e.isRunning?function(e,t){if(!tP.has(t))return{text:"",state:"unsupported_tool"};let n=e.split("\n"),a=function(e,t){if("claude"===t){let t=function(e){var t;let n=e=>/^─{10,}$/.test(tb(e).trimEnd()),a=e.length-1;for(;a>=0&&""===e[a].trim();)a--;if(a<0)return null;let r=-1;for(let t=a;t>=Math.max(0,a-4);t--)if(n(e[t])){r=t;break}if(r<0)return null;let s=-1;for(let t=r-1;t>=Math.max(0,r-40);t--)if(n(e[t])){s=t;break}return s<0||!tM.test(tb(null!=(t=e[s+1])?t:""))?null:{openingSeparator:s,closingSeparator:r}}(e);return null===t?null:{firstRow:t.openingSeparator+1,lastRow:t.closingSeparator-1,glyph:tM}}let n=function(e){let t=e.length-1;for(;t>=0&&tL(e[t]);)t--;if(t<0)return null;for(let n=0;n<4&&t>=0;n++){let n=t,a=t;for(;a>0&&!tL(e[a-1]);)a--;if(function(e){if(void 0===e)return!1;let t=tR(e);if(0===t.length||"›"!==t[0].ch||t[0].dim||t.length>1&&" "!==t[1].ch)return!1;let n=t.slice(2).find(e=>" "!==e.ch);return void 0===n||!n.bold}(e[a]))return{firstRow:a,lastRow:Math.min(n,a+40-1)};for(t=a-1;t>=0&&tL(e[t]);)t--}return null}(e);return null===n?null:{firstRow:n.firstRow,lastRow:n.lastRow,glyph:tA}}(n,t);if(null===a)return{text:"",state:"no_composer"};let r=[],s=[];for(let e=a.firstRow;e<=a.lastRow;e++){var l;let t=function(e,t,n){if(t){let t=e.findIndex(e=>n.test(e.ch));if(t<0)return e;let a=t+1;return a<e.length&&/\s/.test(e[a].ch)&&a++,e.slice(a)}let a=0;for(;a<2&&a<e.length&&" "===e[a].ch;)a++;return e.slice(a)}(tR(null!=(l=n[e])?l:""),e===a.firstRow,a.glyph);r.push(t.filter(e=>!e.dim).map(e=>e.ch).join("").trimEnd()),s.push(t.map(e=>e.ch).join("").trimEnd())}let i=tD(r).join("\n");return""!==i.trim()?{text:i.slice(0,2e3),state:"content"}:{text:"",state:""===tD(s).join("\n").trim()?"empty":"ghost"}}(a,m.current).text:"";o(t=>{var n,l,i,o,c;let d=!1===e.isRunning,u=!!a||!!e.isRunning||d;return{...t,output:u?a:t.output,realtimeSnippet:null!=(n=e.realtimeSnippet)?n:"",isRunning:null!=(l=e.isRunning)&&l,isThinking:null!=(i=e.thinking)&&i,isSelectionListActive:null!=(o=e.isSelectionListActive)&&o,isPagerActive:null!=(c=e.isPagerActive)&&c,isUnclassifiedActive:r,composerText:s,attaching:!1}}),e.isPromptWaiting&&e.promptData?d(t=>{var n,a;return{...t,visible:!0,data:null!=(n=e.promptData)?n:t.data,messageId:null!=(a=t.messageId)?a:"prompt-".concat(Date.now())}}):!e.isPromptWaiting&&x.current&&d({visible:!1,data:null,messageId:null,answering:!1})},[]),T=(0,i.useCallback)(async()=>{let e=++u.current;try{let a=await fetch("/api/worktrees/".concat(t,"/current-output?cliTool=").concat(n,"&instance=").concat(encodeURIComponent(s)));if(!a.ok)return;let r=await a.json();if(u.current!==e||m.current!==n||h.current!==s||r.cliToolId&&r.cliToolId!==n)return;S(r)}catch(t){if(u.current!==e||m.current!==n||h.current!==s)return;console.error("[useTerminalPanePolling] fetch error:",t)}},[t,n,s,S]),E="".concat(t,"::").concat(n,"::").concat(s),I=(0,i.useRef)(E);(0,i.useEffect)(()=>{I.current!==E&&(I.current=E,u.current+=1,v.current=0,y.current=0,j.current=null,N(!1),null!==w.current&&(clearTimeout(w.current),w.current=null),o(e=>({...e,output:"",realtimeSnippet:"",isRunning:!1,isThinking:!1,isSelectionListActive:!1,isPagerActive:!1,isUnclassifiedActive:!1,composerText:"",attaching:!0})),d({visible:!1,data:null,messageId:null,answering:!1}))},[E]),(0,i.useEffect)(()=>{if(r)return p(t),()=>g(t)},[r,t,p,g]),(0,i.useEffect)(()=>{v.current=0,N(!1),null!==w.current&&(clearTimeout(w.current),w.current=null)},[f]),(0,i.useEffect)(()=>()=>{null!==w.current&&clearTimeout(w.current)},[]),(0,i.useEffect)(()=>{if(r)return b(e=>{var n;if("terminal_snapshot"!==e.type||e.worktreeId!==t||e.cliToolId!==m.current||e.instanceId!==h.current||e.version<=v.current)return;v.current=e.version,C();let a=e.output.split("\n").slice(-100).join("\n");S({fullOutput:e.output,realtimeSnippet:a,isRunning:e.isRunning,thinking:e.thinking,isSelectionListActive:e.isSelectionListActive,isPagerActive:e.isPagerActive,isUnclassifiedActive:e.isUnclassifiedActive,isPromptWaiting:e.isPromptWaiting,promptData:null!=(n=e.promptData)?n:null})})},[r,t,b,S,C]),(0,i.useEffect)(()=>{if(r)return b(e=>{if("session_status_changed"===e.type)e.worktreeId===t&&!1===e.isRunning&&(null==e.instance||e.instance===h.current)&&(null==e.cliTool||e.cliTool===m.current)&&(v.current=0,S({fullOutput:"",realtimeSnippet:"",isRunning:!1,thinking:!1,isSelectionListActive:!1,isPagerActive:!1,isUnclassifiedActive:!1,isPromptWaiting:!1,promptData:null}))})},[r,t,b,S]),(0,i.useEffect)(()=>{if(!r)return;let e=!1,t=c.visible||l.isSelectionListActive||l.isPagerActive||l.isUnclassifiedActive,n=setInterval(()=>{"hidden"!==document.visibilityState&&T()},f&&k&&!t?15e3:l.isRunning||t?2e3:5e3);"undefined"!=typeof document&&"hidden"!==document.visibilityState&&T();let a=()=>{"visible"!==document.visibilityState||e||T()};return document.addEventListener("visibilitychange",a),()=>{e=!0,null!==n&&(clearInterval(n),n=null),document.removeEventListener("visibilitychange",a)}},[r,f,k,l.isRunning,l.isSelectionListActive,l.isPagerActive,l.isUnclassifiedActive,c.visible,T]);let M=(0,i.useCallback)(e=>{o(t=>t.autoScroll===e?t:{...t,autoScroll:e})},[]),A=(0,i.useCallback)(e=>{d(t=>({...t,answering:e}))},[]);return{terminal:l,prompt:c,setAutoScroll:M,setPromptAnswering:A,clearPrompt:(0,i.useCallback)(()=>{d({visible:!1,data:null,messageId:null,answering:!1})},[]),refresh:(0,i.useCallback)(()=>T(),[T])}}let tO=(0,i.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,disableAutoFollow:s}=e,{terminal:l,prompt:i,setAutoScroll:o,refresh:c}=tF({worktreeId:t,cliToolId:n,instanceId:a}),d="claude"===n||"codex"===n,u=l.isUnclassifiedActive&&!i.visible,m=tT(l.composerText);return(0,r.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(tw,{output:l.output,isActive:l.isRunning,isThinking:l.isThinking,autoScroll:l.autoScroll,onScrollChange:o,disableAutoFollow:s,compactTuiLayoutPadding:d,className:"h-full"})}),m?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1",children:(0,r.jsx)(tE,{worktreeId:t,cliToolId:n,instanceId:a,composerText:l.composerText,onActionSent:c})}):null,u?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1 pb-2",children:(0,r.jsx)(tS,{worktreeId:t,cliToolId:n,instanceId:a,onKeysSent:c})}):null]})});var tz=n(96195),t_=n(12181),tB=n(20508),tV=n(27937);function tW(e){if(0===e.length)return"0";let t=e[e.length-1],n=t.timestamp instanceof Date?t.timestamp.getTime():String(t.timestamp);return"".concat(e.length,"|").concat(t.id,"|").concat(n)}var tH=n(35299),tU=n(6132),tK=n(48314),t$=n(54916),tq=n(36809),tG=n(55041),tJ=n(8574);let tY={en:tJ.c,ja:tG.ja};function tQ(e){var t;return null!=(t=tY[e])?t:tJ.c}var tX=n(83012);let tZ=/(\/[^\s\n<>"']+\.[a-zA-Z0-9]+)/g;function t0(e){let t=e.split("\n");if(t.length<=2&&e.length<=100)return{text:e,isTruncated:!1};let n=t.slice(0,2).join("\n");return n.length>100&&(n=n.slice(0,100)),{text:n,isTruncated:!0}}let t1=(0,i.memo)(function(e){let{content:t,onFilePathClick:n}=e,a=(0,c.c)("worktree"),s=(0,i.useMemo)(()=>(function(e){let t=e.match(tZ);if(!t||0===t.length)return[{type:"text",content:e}];let n=[],a=0;return t.forEach(t=>{let r=e.indexOf(t,a);r>a&&n.push({type:"text",content:e.slice(a,r)}),n.push({type:"path",content:t}),a=r+t.length}),a<e.length&&n.push({type:"text",content:e.slice(a)}),n})(t),[t]),l=(0,i.useCallback)(e=>()=>n(e),[n]);return(0,r.jsx)("span",{children:s.map((e,t)=>"path"===e.type?(0,r.jsx)("button",{type:"button",onClick:l(e.content),className:"text-accent-700 dark:text-accent-400 hover:text-accent-600 dark:hover:text-accent-300 hover:underline cursor-pointer font-mono text-sm","aria-label":a("conversation.openFile",{path:e.content}),children:e.content},t):(0,r.jsx)("span",{children:e.content},t))})});function t2(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{"data-testid":"pending-indicator",className:"flex items-center gap-2 text-muted-foreground py-2",children:[(0,r.jsxs)("div",{className:"flex gap-1","aria-hidden":"true",children:[(0,r.jsx)("span",{className:"w-2 h-2 bg-muted-foreground rounded-full animate-pulse"}),(0,r.jsx)("span",{className:"w-2 h-2 bg-muted-foreground rounded-full animate-pulse",style:{animationDelay:"150ms"}}),(0,r.jsx)("span",{className:"w-2 h-2 bg-muted-foreground rounded-full animate-pulse",style:{animationDelay:"300ms"}})]}),(0,r.jsx)("span",{className:"text-sm",children:e("conversation.waitingForResponse")})]})}let t4=(0,i.memo)(function(e){let{message:t,onFilePathClick:n,onCopy:a,onInsertToMessage:s,onRetryPending:l,onDiscardPending:i}=e,o=(0,tq.Ym)(),d=(0,c.c)("worktree"),u=(0,c.c)("common"),m=tQ(o),h=(0,tX.bg)(t.timestamp,m),x=t.optimisticState,f=["group relative border-l-2 p-3 transition-opacity","error"===x?"border-danger-border bg-danger-subtle":"border-accent-500 bg-accent-500/10","sending"===x?"opacity-70":""].filter(Boolean).join(" ");return(0,r.jsxs)("div",{className:f,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-accent-700 dark:text-accent-400",children:d("conversation.you")}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:h}),"sending"===x&&(0,r.jsxs)("span",{"data-testid":"optimistic-sending",className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,r.jsx)(tH.A,{size:12,className:"animate-spin","aria-hidden":"true"}),(0,r.jsx)("span",{children:d("conversation.sending")})]}),"error"===x&&(0,r.jsxs)("span",{"data-testid":"optimistic-error",className:"flex items-center gap-1 text-xs text-danger-foreground",children:[(0,r.jsx)(tU.A,{size:12,"aria-hidden":"true"}),(0,r.jsx)("span",{children:d("conversation.failedToSend")})]}),"error"===x?(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[l&&(0,r.jsxs)("button",{type:"button","data-testid":"pending-retry",onClick:()=>l(t.id),className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-accent-700 dark:text-accent-400 hover:bg-muted transition-colors","aria-label":d("conversation.retrySending"),title:u("retry"),children:[(0,r.jsx)(tK.A,{size:12,"aria-hidden":"true"}),u("retry")]}),i&&(0,r.jsxs)("button",{type:"button","data-testid":"pending-discard",onClick:()=>i(t.id),className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-muted-foreground hover:text-danger-foreground hover:bg-muted transition-colors","aria-label":d("conversation.discardMessage"),title:d("conversation.discard"),children:[(0,r.jsx)(ew.A,{size:12,"aria-hidden":"true"}),d("conversation.discard")]})]}):(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100 [@media(hover:none)]:opacity-100",children:[s&&(0,r.jsx)("button",{type:"button","data-testid":"insert-user-message",onClick:()=>s(t.content),className:"p-1 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 hover:bg-muted rounded transition-colors","aria-label":d("conversation.insertToMessage"),title:d("conversation.insertToMessage"),children:(0,r.jsx)(t$.A,{size:14,"aria-hidden":"true"})}),a&&(0,r.jsx)("button",{type:"button","data-testid":"copy-user-message",onClick:()=>a(t.content),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors","aria-label":d("conversation.copyMessage"),title:d("conversation.copy"),children:(0,r.jsx)(ef.A,{size:14,"aria-hidden":"true"})})]})]}),(0,r.jsx)("div",{"data-message-id":t.id,className:"text-sm text-foreground whitespace-pre-wrap break-words [word-break:break-word] max-w-full overflow-x-hidden",children:(0,r.jsx)(t1,{content:t.content,onFilePathClick:n})})]})}),t5=(0,i.memo)(function(e){let{message:t,index:n,total:a,isExpanded:s,onFilePathClick:l,onCopy:o,hasLongContent:d=!1,onToggleExpand:u}=e,m=(0,tq.Ym)(),h=(0,c.c)("worktree"),x=tQ(m),f=(0,tX.bg)(t.timestamp,x),{text:p,isTruncated:g}=(0,i.useMemo)(()=>t0(t.content),[t.content]),b=s||!g?t.content:p;return(0,r.jsxs)("div",{className:"assistant-message-item group relative",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:h("conversation.assistant")}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:f}),a>1&&(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",n+1,"/",a,")"]}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100 [@media(hover:none)]:opacity-100",children:[0===n&&d&&!!u&&(0,r.jsxs)("button",{type:"button",onClick:u,className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-accent-700 dark:text-accent-400 hover:text-accent-600 dark:hover:text-accent-300 hover:bg-muted transition-colors","aria-expanded":s,"aria-label":h(s?"conversation.collapseMessage":"conversation.expandMessage"),children:[(0,r.jsx)(tn.A,{size:12,className:"transition-transform ".concat(s?"rotate-180":""),"aria-hidden":"true"}),h(s?"conversation.collapse":"conversation.expand")]}),o&&(0,r.jsx)("button",{type:"button","data-testid":"copy-assistant-message",onClick:()=>o(t.content),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors","aria-label":h("conversation.copyMessage"),title:h("conversation.copy"),children:(0,r.jsx)(ef.A,{size:14,"aria-hidden":"true"})})]})]}),(0,r.jsxs)("div",{"data-message-id":t.id,className:"text-xs text-foreground whitespace-pre-wrap break-words [word-break:break-word] max-w-full overflow-x-hidden",children:[(0,r.jsx)(t1,{content:b,onFilePathClick:l}),!s&&g&&(0,r.jsx)("span",{className:"text-muted-foreground",children:"..."})]})]})}),t3=(0,i.memo)(function(e){let{messages:t,isExpanded:n,onFilePathClick:a,onCopy:s,hasLongContent:l=!1,onToggleExpand:o}=e;return(0,r.jsx)("div",{className:"bg-surface-2/50 border-l-2 border-border p-2 border-t border-border space-y-2",children:t.map((e,c)=>(0,r.jsxs)(i.Fragment,{children:[c>0&&(0,r.jsx)("div",{"data-testid":"assistant-message-divider",className:"border-t border-dashed border-border"}),(0,r.jsx)(t5,{message:e,index:c,total:t.length,isExpanded:n,onFilePathClick:a,onCopy:s,hasLongContent:l,onToggleExpand:o})]},e.id))})});function t6(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{"data-testid":"orphan-indicator",className:"bg-warning/10 text-warning-foreground text-xs px-3 py-1 flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.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,r.jsx)("span",{children:e("conversation.systemMessage")})]})}let t8=(0,i.memo)(function(e){var t;let{pair:n,onFilePathClick:a,isExpanded:s=!1,onToggleExpand:l,onCopy:o,onInsertToMessage:d,showAssistant:u=!0,onRetryPending:m,onDiscardPending:h}=e,x=(0,c.c)("worktree"),f=(null==(t=n.userMessage)?void 0:t.optimisticState)!==void 0,p=(0,i.useMemo)(()=>n.assistantMessages.some(e=>{let{isTruncated:t}=t0(e.content);return t}),[n.assistantMessages]),g=(0,i.useCallback)(()=>{l&&l()},[l]),b=(0,i.useMemo)(()=>{let e="pending"===n.status?"pending":"orphan"===n.status?"orphan border-l-4 border-warning":"";return"".concat("border border-border rounded-lg overflow-hidden mb-4 transition-colors"," ").concat(e).trim()},[n.status]),v=n.userMessage?x("conversation.conversationLabel",{preview:"".concat(n.userMessage.content.substring(0,50)).concat(n.userMessage.content.length>50?"...":"")}):x("conversation.systemMessageLabel");return(0,r.jsxs)("div",{"data-testid":"conversation-pair-card",role:"article","aria-label":v,className:b,children:["orphan"===n.status&&(0,r.jsx)(t6,{}),n.userMessage&&(0,r.jsx)(t4,{message:n.userMessage,onFilePathClick:a,onCopy:o,onInsertToMessage:d,onRetryPending:m,onDiscardPending:h}),"pending"!==n.status||f?u&&n.assistantMessages.length>0?(0,r.jsx)(t3,{messages:n.assistantMessages,isExpanded:s,onFilePathClick:a,onCopy:o,hasLongContent:p,onToggleExpand:g}):null:(0,r.jsx)("div",{className:"bg-muted/40 border-l-2 border-border p-3 border-t border-border",children:(0,r.jsx)(t2,{})})]})});function t9(e){let{query:t,onQueryChange:n,matchCount:a,currentIndex:s,onNext:l,onPrev:o,onClose:d,isAtMaxMatches:u,onCompositionStart:m,onCompositionEnd:h}=e,x=(0,i.useRef)(null),f=(0,c.c)("worktree");(0,i.useEffect)(()=>{var e;null==(e=x.current)||e.focus()},[]);let p=(0,i.useCallback)(e=>{"Escape"===e.key&&d()},[d]),g=(0,i.useCallback)(e=>{n(e.target.value)},[n]),b=0===a?"0/0":u?f("history.search.countAtMax",{current:s+1,max:500}):"".concat(s+1,"/").concat(a);return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-surface border border-border rounded shadow-lg",role:"search","aria-label":f("history.search.regionLabel"),children:[(0,r.jsx)("input",{ref:x,type:"text",value:t,onChange:g,onKeyDown:p,onCompositionStart:m,onCompositionEnd:h,placeholder:f("history.search.placeholder"),className:"bg-transparent text-foreground text-sm outline-none w-32 sm:w-40 placeholder-muted-foreground","aria-label":f("history.search.keywordLabel"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,r.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"text-muted-foreground text-xs min-w-[3rem] text-right",children:b}),(0,r.jsx)("button",{type:"button",onClick:o,disabled:0===a,"aria-label":f("history.search.prev"),className:"text-muted-foreground hover:text-foreground disabled:opacity-40 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▲"}),(0,r.jsx)("button",{type:"button",onClick:l,disabled:0===a,"aria-label":f("history.search.next"),className:"text-muted-foreground hover:text-foreground disabled:opacity-40 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▼"}),(0,r.jsx)("button",{type:"button",onClick:d,"aria-label":f("history.search.close"),className:"text-muted-foreground hover:text-foreground min-w-[36px] min-h-[36px] flex items-center justify-center text-base ml-1",children:"✕"})]})}let t7="commandmate.worktree.historyVisible",ne="commandmate.worktree.historyWidth";function nt(e){return Number.isFinite(e)?Math.min(60,Math.max(10,e)):40}let nn="commandmate:historyPaneStateChange";function na(e){try{window.dispatchEvent(new CustomEvent(nn,{detail:e}))}catch(e){}}function nr(){let[e,t]=(0,i.useState)(!0),[n,a]=(0,i.useState)(40),r=(0,i.useRef)(e);r.current=e;let s=(0,i.useRef)(n);return s.current=n,(0,i.useEffect)(()=>{let e=function(){try{let e=window.localStorage.getItem(t7);if("true"===e)return!0;if("false"===e)return!1}catch(e){}return!0}(),n=function(){try{let e=window.localStorage.getItem(ne);if(null===e)return 40;let t=Number(e);if(Number.isFinite(t))return nt(t)}catch(e){}return 40}();t(e),a(n)},[]),(0,i.useEffect)(()=>{let e=e=>{e.detail&&(e.detail.visible!==r.current&&t(e.detail.visible),e.detail.width!==s.current&&a(e.detail.width))};return window.addEventListener(nn,e),()=>window.removeEventListener(nn,e)},[]),{visible:e,width:n,toggle:(0,i.useCallback)(()=>{let e=!r.current;t(e);try{window.localStorage.setItem(t7,String(e))}catch(e){}na({visible:e,width:s.current})},[]),setWidth:(0,i.useCallback)(e=>{let t=nt(e);a(t);try{window.localStorage.setItem(ne,String(t))}catch(e){}na({visible:r.current,width:t})},[])}}var ns=n(72115);let nl="worktree-history-pane",ni=(0,i.memo)(function(e){let{onToggle:t}=e,n=(0,c.c)("worktree");return(0,r.jsx)("div",{"data-testid":"terminal-container-expand-bar",style:{width:"".concat(36,"px")},className:"flex-shrink-0 flex items-start justify-center bg-gray-100 dark:bg-gray-800 border-r border-gray-200 dark:border-gray-700",children:(0,r.jsxs)("button",{type:"button","data-testid":"history-pane-expand","aria-label":n("terminal.showHistory"),title:n("terminal.showHistory"),"aria-expanded":"false","aria-controls":nl,onClick:t,className:"flex flex-col items-center gap-2 w-full pt-2 text-gray-500 dark:text-gray-400 hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,r.jsx)("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,r.jsx)("span",{className:"text-xs font-medium tracking-wide select-none",style:{writingMode:"vertical-rl"},"aria-hidden":"true",children:n("terminal.historyLabel")})]})})}),no=(0,i.memo)(function(e){let{history:t,terminal:n}=e,{visible:a,width:s,toggle:l,setWidth:o}=nr(),c=(0,i.useRef)(null),d=(0,i.useCallback)(e=>{let t=c.current;if(!t)return;let n=t.offsetWidth;0!==n&&o(s+e/n*100)},[s,o]);return(0,r.jsxs)("div",{ref:c,className:"flex h-full min-h-0 w-full",children:[null!=t&&(a?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:nl,"data-testid":"terminal-container-history-slot","aria-label":"History pane",style:{width:"".concat(s,"%")},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,r.jsx)(T,{componentName:"HistoryPane",children:t})}),(0,r.jsx)(ns.f,{onResize:d,orientation:"horizontal",ariaValueNow:s})]}):(0,r.jsx)(ni,{onToggle:l})),(0,r.jsx)("div",{"data-testid":"terminal-container-terminal-slot","aria-label":"Terminal pane",className:"flex-grow overflow-hidden min-w-0",children:(0,r.jsx)(T,{componentName:"TerminalAndFilePanel",children:n})})]})}),nc=[50,100,150,200,250,500,1e3],nd="commandmate:historyDisplayLimit";function nu(e){return nc.includes(e)}let nm="commandmate:historyUserOnly";function nh(e){return"split-history-slot-".concat(e)}function nx(){let e=(0,c.c)("worktree");return(0,r.jsx)("div",{"data-testid":"loading-indicator",role:"status","aria-label":e("history.loading"),children:[0,1,2].map(e=>(0,r.jsxs)("div",{className:"mb-4 overflow-hidden rounded-lg border border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 p-3",children:[(0,r.jsx)(m.EA,{className:"h-4 w-4 rounded-full"}),(0,r.jsx)(m.EA,{className:"h-4 w-1/3"})]}),(0,r.jsxs)("div",{className:"space-y-2 px-3 pb-3",children:[(0,r.jsx)(m.EA,{className:"h-3 w-full"}),(0,r.jsx)(m.EA,{className:"h-3 w-5/6"}),(0,r.jsx)(m.EA,{className:"h-3 w-2/3"})]})]},e))})}function nf(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[(0,r.jsx)("svg",{className:"w-12 h-12 mb-2 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),(0,r.jsx)("p",{className:"text-sm",children:e("history.empty")})]})}let np=["h-full","flex","flex-col","overflow-hidden","bg-surface-2","rounded-lg","border","border-border"],ng=(0,i.memo)(function(e){let{messages:t,worktreeId:n,onFilePathClick:a,isLoading:s=!1,className:l="",showToast:o,onInsertToMessage:d,onRetryPending:u,onDiscardPending:h,showArchived:x=!1,onShowArchivedChange:f,historyDisplayLimit:p,onHistoryDisplayLimitChange:g,historyUserOnly:b=!1,onHistoryUserOnlyChange:v,onCollapse:y,splitIndex:j,cliToolId:w}=e,k=(0,c.c)("worktree"),N=(0,i.useRef)(null),C=(0,i.useMemo)(()=>void 0===j?eM:{highlightName:"history-search-".concat(j),currentHighlightName:"history-search-current-".concat(j),fallbackOverlayId:"history-search-fallback-overlay-".concat(j),fallbackOverlayBgColor:eM.fallbackOverlayBgColor},[j]),S=void 0===j?"history-pane-collapse-button":"history-pane-collapse-button-".concat(j),T=void 0===j?nl:nh(j),E=(0,i.useRef)(!0),I=(0,i.useRef)(-1),M=(0,i.useRef)(null),{pairs:A,isExpanded:L,toggleExpand:R}=function(e){let t=(0,i.useMemo)(()=>(function(e){if(0===e.length)return[];let t=[...e].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()),n=[],a=null;for(let e of t)if("user"===e.role)a={id:e.id,userMessage:e,assistantMessages:[],status:"pending"},n.push(a);else if("assistant"===e.role)if(a&&null!==a.userMessage)a.assistantMessages.push(e),a.status="completed";else if(a&&null===a.userMessage)a.assistantMessages.push(e);else{let t={id:"orphan-".concat(e.id),userMessage:null,assistantMessages:[e],status:"orphan"};n.push(t),a=t}return n})(e),[e]),[n,a]=(0,i.useState)(new Set),r=(0,i.useCallback)(e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),s=(0,i.useCallback)(e=>n.has(e),[n]),l=(0,i.useCallback)(()=>{a(new Set(t.map(e=>e.id)))},[t]);return{pairs:t,expandedPairs:n,toggleExpand:r,isExpanded:s,expandAll:l,collapseAll:(0,i.useCallback)(()=>{a(new Set)},[])}}(t),{isOpen:P,query:D,matchCount:F,currentIndex:O,isAtMaxMatches:_,matchPositions:B,currentMatch:V,openSearch:W,closeSearch:H,setQuery:U,onCompositionStart:K,onCompositionEnd:$,nextMatch:q,prevMatch:G}=function(e){let{messages:t}=e,[n,a]=(0,i.useState)(!1),[r,s]=(0,i.useState)(""),[l,o]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),[u,m]=(0,i.useState)(!1),h=(0,i.useRef)(null),x=(0,i.useRef)(""),f=(0,i.useRef)(!1),p=(0,i.useRef)(tW(t)),g=(0,i.useRef)(t);g.current=t;let b=l.reduce((e,t)=>e+t.ranges.length,0),v=(0,i.useMemo)(()=>(function(e,t){if(0===e.length||t<0)return null;let n=0;for(let a of e){if(t<n+a.ranges.length)return{messageId:a.messageId,localIndex:t-n};n+=a.ranges.length}return null})(l,c),[l,c]),y=(0,i.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]),j=(0,i.useCallback)(e=>{let{positions:t,capped:n}=function(e,t){if(t.length<2||0===e.length)return{positions:[],capped:!1};let n=t.toLowerCase(),a=t.length,r=[],s=0,l=!1;for(let t of e){if(l)break;let i=t.content;if(!i)continue;let o=i.toLowerCase(),c=[],d=0;for(;;){let r=o.indexOf(n,d);if(-1===r)break;if(c.push({start:r,end:r+a}),d=r+1,(s+=1)>=500){if(-1!==o.indexOf(n,d))l=!0;else{let a=e.indexOf(t)+1;for(let t=a;t<e.length;t++){let a=e[t].content;if(a&&-1!==a.toLowerCase().indexOf(n)){l=!0;break}}}break}}c.length>0&&r.push({messageId:t.id,ranges:c})}return{positions:r,capped:l}}(g.current,e);o(t),d(0),m(n)},[]),w=(0,i.useCallback)(e=>{y(),x.current=e,f.current||(h.current=setTimeout(()=>{j(e)},300))},[y,j]),k=(0,i.useCallback)(e=>{s(e),w(e)},[w]),N=(0,i.useCallback)(()=>{a(!0)},[]),C=(0,i.useCallback)(()=>{a(!1),s(""),x.current="",o([]),d(0),m(!1),y()},[y]),S=(0,i.useCallback)(()=>{d(e=>0===b?0:(e+1)%b)},[b]),T=(0,i.useCallback)(()=>{d(e=>0===b?0:(e-1+b)%b)},[b]),E=(0,i.useCallback)(()=>{f.current=!0,y()},[y]),I=(0,i.useCallback)(()=>{f.current=!1;let e=x.current;e.length>=2&&(y(),h.current=setTimeout(()=>{j(e)},300))},[y,j]);return(0,i.useEffect)(()=>{let e=tW(t);if(e===p.current)return;p.current=e;let n=x.current;n.length>=2&&j(n)},[t,j]),(0,i.useEffect)(()=>()=>{y(),x.current=""},[y]),{isOpen:n,query:r,matchCount:b,currentIndex:c,isAtMaxMatches:u,matchPositions:l,currentMatch:v,openSearch:N,closeSearch:C,setQuery:k,onCompositionStart:E,onCompositionEnd:I,nextMatch:S,prevMatch:T}}({messages:(0,i.useMemo)(()=>t.filter(e=>!e.archived&&"string"==typeof e.content&&e.content.length>0&&(!b||"user"===e.role)),[t,b])}),J=P&&B.length>0,[Y,Q]=(0,i.useState)(new Set);(0,i.useEffect)(()=>{H()},[n]);let X=(0,i.useMemo)(()=>b?A.filter(e=>e.userMessage):A,[A,b]),Z=(0,i.useMemo)(()=>{let e=new Map;for(let t of X)for(let n of(t.userMessage&&e.set(t.userMessage.id,t.id),t.assistantMessages))e.set(n.id,t.id);return e},[X]),ee=(0,i.useMemo)(()=>{let e=new Map;return X.forEach((t,n)=>e.set(t.id,n)),e},[X]),et=(0,tz.Te)({count:X.length,getScrollElement:()=>N.current,estimateSize:()=>160,overscan:6,getItemKey:e=>{var t,n;return null!=(n=null==(t=X[e])?void 0:t.id)?n:e}}),en=et.getVirtualItems(),ea=en.length>0?"".concat(en[0].index,"-").concat(en[en.length-1].index):"",er=(0,i.useCallback)(()=>{let e=N.current;e&&(E.current=function(e){let{scrollTop:t,scrollHeight:n,clientHeight:a}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:80,s=n-t-a;return!!Number.isFinite(s)&&s<=r}({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}))},[]);(0,i.useLayoutEffect)(()=>{let e=I.current,t=X.length;I.current=t,-1!==e&&t>e&&t>0&&E.current&&!J&&et.scrollToIndex(t-1,{align:"end"})},[X.length,J,et]),(0,i.useLayoutEffect)(()=>{if(!P||0===B.length)return void Q(e=>0===e.size?e:new Set);Q(function(e,t){let n=new Map;for(let e of t)for(let t of(e.userMessage&&n.set(e.userMessage.id,e.id),e.assistantMessages))n.set(t.id,e.id);let a=new Set;for(let t of e){let e=n.get(t.messageId);e&&a.add(e)}return a}(B,A))},[P,B,A]),(0,i.useEffect)(()=>{if(!P||!V)return;let e=Z.get(V.messageId);if(void 0===e)return;let t=ee.get(e);void 0!==t&&et.scrollToIndex(t,{align:"center"})},[P,V,Z,ee,et]),(0,i.useLayoutEffect)(()=>{let e=N.current;if(!e)return;if(!P||0===B.length)return void eD(C);let t=null;for(let a of B){var n;let r=(n=a.messageId,e.querySelector('[data-message-id="'.concat(CSS.escape(n),'"]')));if(!r)continue;let s=(null==V?void 0:V.messageId)===a.messageId,l=s?V.localIndex:-1;!function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:eM;eP(e,t,n,a)}(r,a.ranges,l,C),s&&r instanceof HTMLElement&&(t=r)}return t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"}),()=>{eD(C)}},[P,B,V,Y,C,ea]),(0,i.useEffect)(()=>{let e=N.current;if(P)null===M.current&&e&&(M.current=e.scrollTop);else{if(null!==M.current&&e){let t=M.current;requestAnimationFrame(()=>{e.scrollTop=t})}M.current=null}},[P]);let es=(0,i.useMemo)(()=>[...np,l].filter(Boolean).join(" "),[l]),el=(0,i.useCallback)(e=>a(e),[a]),ei=(0,i.useCallback)(e=>()=>R(e),[R]),eo=(0,i.useRef)(k);eo.current=k;let ec=(0,i.useCallback)(async e=>{try{await (0,ej.l)(e),null==o||o(eo.current("history.copied"),"success")}catch(e){console.error("[HistoryPane] Failed to copy to clipboard"),null==o||o(eo.current("history.copyFailed"),"error")}},[o]),ed=e=>{var t,n;let a=(null==(t=e.userMessage)?void 0:t.archived)===!0||(null==(n=e.assistantMessages)?void 0:n.some(e=>!0===e.archived)),s=L(e.id)||Y.has(e.id);return(0,r.jsx)("div",{className:a?"opacity-60":"",children:(0,r.jsx)(t8,{pair:e,onFilePathClick:el,isExpanded:s,onToggleExpand:ei(e.id),onCopy:ec,onInsertToMessage:d,onRetryPending:u,onDiscardPending:h,showAssistant:!b})})},eu=(0,i.useCallback)(e=>{let t=parseInt(e.target.value,10);nu(t)&&(null==g||g(t))},[g]),em=(0,i.useCallback)(()=>{P?H():W()},[P,W,H]);return(0,r.jsxs)("div",{role:"region","aria-label":k("history.regionLabel"),className:es,children:[(0,r.jsxs)("div",{className:"flex-shrink-0 bg-surface-2 border-b border-border px-4 py-2 flex items-center justify-between flex-wrap gap-1",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:k("history.title")}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[g&&void 0!==p&&(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer",children:[(0,r.jsx)("span",{children:k("history.show")}),(0,r.jsx)("select",{value:p,onChange:eu,"aria-label":k("history.displayLimit"),className:"rounded border border-input bg-surface text-foreground text-xs px-1.5 py-0.5 focus:outline-none focus:ring-1 focus:ring-ring",children:nc.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]}),f&&(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer",children:[(0,r.jsx)(m.Sc,{checked:x,onCheckedChange:e=>f(!0===e),className:"h-3.5 w-3.5"}),k("history.showArchived")]}),v&&(0,r.jsx)("button",{type:"button",onClick:()=>v(!b),"aria-label":k("history.showUserOnly"),"aria-pressed":b,className:"p-1 rounded transition-colors ".concat(b?"bg-accent-500/15 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:text-foreground"),title:k(b?"history.showAllMessages":"history.showUserOnly"),children:b?(0,r.jsx)(t_.A,{size:14,"aria-hidden":"true"}):(0,r.jsx)(tB.A,{size:14,"aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:em,"aria-label":k(P?"history.closeSearch":"history.openSearch"),"aria-pressed":P,className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors",title:k(P?"history.closeSearch":"history.openSearch"),children:(0,r.jsx)(z.A,{size:14,"aria-hidden":"true"})}),y&&(0,r.jsx)("button",{type:"button",onClick:y,"aria-label":k("terminal.hideHistory"),"aria-expanded":"true","aria-controls":T,className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors",title:k("terminal.hideHistory"),"data-testid":S,children:(0,r.jsx)(tV.A,{size:14,"aria-hidden":"true"})})]})]}),P&&(0,r.jsx)("div",{className:"flex-shrink-0 px-3 py-2 bg-surface-2 border-b border-border",children:(0,r.jsx)(t9,{query:D,onQueryChange:U,matchCount:F,currentIndex:O,onNext:q,onPrev:G,onClose:H,isAtMaxMatches:_,onCompositionStart:K,onCompositionEnd:$})}),(0,r.jsx)("div",{ref:N,"data-testid":"history-scroll-container",onScroll:er,className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden p-4",children:s?(0,r.jsx)(nx,{}):0===X.length?(0,r.jsx)(nf,{}):0===en.length?(0,r.jsx)("div",{"data-testid":"history-fallback-list",children:X.slice(0,30).map(e=>(0,r.jsx)("div",{children:ed(e)},e.id))}):(0,r.jsx)("div",{style:{height:et.getTotalSize(),width:"100%",position:"relative"},children:en.map(e=>{let t=X[e.index];return t?(0,r.jsx)("div",{"data-index":e.index,ref:et.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:"translateY(".concat(e.start,"px)")},children:ed(t)},e.key):null})})})]})}),nb={isOpen:!1,position:{x:0,y:0},targetPath:null,targetType:null};var nv=n(7504),ny=n(22198),nj=n(21786),nw=n(26754),nk=n(71360),nN=n(9286);function nC(e,t,n){let a=n-t-8;return a<8?8:Math.min(Math.max(e,8),a)}let nS=(0,i.memo)(function(e){let{isOpen:t,position:n,targetPath:a,targetType:s,onClose:l,onNewFile:o,onNewDirectory:d,onRename:u,onDelete:m,onUpload:h,onMove:x}=e,f=(0,c.c)("worktree"),p=(0,i.useRef)(null),{shouldRender:g,isExiting:b}=(0,nN.O)(t,er.$B),v="".concat(n.x,":").concat(n.y,":").concat(s),[y,j]=(0,i.useState)(null),w=(null==y?void 0:y.key)===v?y:null;(0,i.useLayoutEffect)(()=>{if(!t)return;let e=p.current;if(!e)return;let a=e.getBoundingClientRect();j({key:v,left:nC(n.x,a.width,window.innerWidth),top:nC(n.y,a.height,window.innerHeight)})},[t,v,n.x,n.y]);let k=(0,i.useCallback)(e=>{e&&a&&e(a),l()},[a,l]),N=[{id:"new-file",label:f("fileTree.newFile"),icon:(0,r.jsx)(nv.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>k(o),showFor:["directory"]},{id:"new-directory",label:f("fileTree.newDirectory"),icon:(0,r.jsx)(ny.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>k(d),showFor:["directory"]},{id:"upload",label:f("contextMenu.uploadFile"),icon:(0,r.jsx)(nj.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>k(h),showFor:["directory"],showDividerAfter:!0},{id:"rename",label:f("contextMenu.rename"),icon:(0,r.jsx)(eS.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>k(u)},{id:"move",label:f("contextMenu.move"),icon:(0,r.jsx)(nw.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>{x&&a&&s&&x(a,s),l()},showDividerAfter:!0},{id:"delete",label:f("contextMenu.delete"),icon:(0,r.jsx)(nk.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>k(m),variant:"danger"}].filter(e=>!e.showFor||s&&e.showFor.includes(s));return((0,i.useEffect)(()=>{if(!t)return;let e=e=>{if("Escape"===e.key)return void l();if("ArrowDown"===e.key||"ArrowUp"===e.key){var t;let n;e.preventDefault();let a=null==(t=p.current)?void 0:t.querySelectorAll('[role="menuitem"]');if(!(null==a?void 0:a.length))return;let r=Array.from(a).findIndex(e=>e===document.activeElement);n="ArrowDown"===e.key?r<a.length-1?r+1:0:r>0?r-1:a.length-1,a[n].focus()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,l]),(0,i.useEffect)(()=>{if(t&&p.current){let e=p.current.querySelector('[role="menuitem"]');e&&e.focus()}},[t]),g)?(0,r.jsx)("div",{ref:p,"data-testid":"context-menu",role:"menu","aria-label":f("contextMenu.label"),className:"fixed min-w-[160px] py-1 bg-surface rounded-lg shadow-lg border border-border ".concat(b?"animate-out fade-out-0 zoom-out-95 duration-100 fill-mode-forwards pointer-events-none":"animate-in fade-in-0 zoom-in-95 duration-100"),style:{zIndex:eT.M.CONTEXT_MENU,left:"".concat(w?w.left:0,"px"),top:"".concat(w?w.top:0,"px")},children:N.map((e,t)=>(0,r.jsxs)(i.Fragment,{children:[(0,r.jsxs)("button",{role:"menuitem","data-testid":"context-menu-".concat(e.id),onClick:e.onClick,disabled:!a,className:"w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors focus:outline-none focus:bg-muted ".concat("danger"===e.variant?"text-danger hover:bg-danger-subtle focus:bg-danger-subtle":"text-foreground hover:bg-muted"," ").concat(a?"":"opacity-50 cursor-not-allowed"),children:[e.icon,(0,r.jsx)("span",{children:e.label})]}),e.showDividerAfter&&t<N.length-1&&(0,r.jsx)("div",{"data-testid":"context-menu-divider",className:"my-1 border-t border-border"})]},e.id))}):null});var nT=n(30061);let nE="commandmate.worktree.fileMetadataDisplay",nI={showSize:!0,showCreated:!1,showModified:!1},nM="commandmate:fileMetadataDisplayChange";function nA(e){return void 0===e?"":e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(1)," KB"):"".concat((e/1048576).toFixed(1)," MB")}let nL=(0,i.memo)(function(e){let{expanded:t}=e;return(0,r.jsx)("svg",{"data-testid":"chevron-icon",className:"w-4 h-4 text-muted-foreground transition-transform ".concat(t?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),nR=(0,i.memo)(function(e){let{open:t}=e;return(0,r.jsx)("svg",{"data-testid":"folder-icon",className:"w-5 h-5 text-warning",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:t?(0,r.jsx)("path",{d:"M19 20H5c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h6l2 2h6c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2zM5 6v12h14V8h-7l-2-2H5z"}):(0,r.jsx)("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}),nP=(0,i.memo)(function(e){let{text:t,query:n}=e;if(!n||!n.trim())return(0,r.jsx)(r.Fragment,{children:t});let a=(0,x.Nt)(n),s=t.split(RegExp("(".concat(a,")"),"gi"));return(0,r.jsx)(r.Fragment,{children:s.map((e,t)=>e.toLowerCase()===n.toLowerCase()?(0,r.jsx)("mark",{className:"bg-warning-border text-foreground px-0.5 rounded",children:e},t):(0,r.jsx)("span",{children:e},t))})}),nD=(0,i.memo)(function(e){let{extension:t}=e,n=(0,i.useMemo)(()=>t&&({ts:"text-info",tsx:"text-info",js:"text-warning",jsx:"text-warning",json:"text-warning",md:"text-muted-foreground",css:"text-accent-500",scss:"text-accent-500",html:"text-warning",py:"text-success"})[t]||"text-muted-foreground",[t]);return(0,r.jsx)("svg",{"data-testid":"file-icon",className:"w-5 h-5 ".concat(n),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),nF=(0,i.memo)(function e(t){let{item:n,path:a,depth:s,worktreeId:l,expanded:o,cache:d,onToggle:m,onFileSelect:h,onLoadChildren:x,onContextMenu:f,searchQuery:p,searchMode:g,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y=nI}=t,j=(0,c.c)("worktree"),[w,k]=(0,i.useState)(!1),N=a?"".concat(a,"/").concat(n.name):n.name,C=o.has(N),S="directory"===n.type,T=d.get(N),E=(0,i.useMemo)(()=>v?tQ(v):void 0,[v]),I=(0,i.useMemo)(()=>{if(S)return;let e=[];if(void 0!==n.size&&e.push("".concat(j("fileTree.metadata.size"),": ").concat(nA(n.size))),n.birthtime){let t=(0,tX.bg)(new Date(n.birthtime),E);t&&e.push("".concat(j("fileTree.metadata.created"),": ").concat(t))}if(n.mtime){let t=(0,tX.bg)(new Date(n.mtime),E);t&&e.push("".concat(j("fileTree.metadata.modified"),": ").concat(t))}return e.length>0?e.join("\n"):void 0},[S,n.size,n.birthtime,n.mtime,E,j]),M=(0,i.useCallback)(async()=>{S?(C||T||(k(!0),await x(N),k(!1)),m(N)):null==h||h(N)},[S,C,T,N,x,m,h]),A=(0,i.useCallback)(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),M())},[M]),L=(0,i.useCallback)(e=>{e.preventDefault(),null==f||f(e,N,S?"directory":"file")},[N,S,f]),R=function(e){let{delay:t=500,moveThreshold:n=10,onLongPress:a}=e,r=(0,i.useRef)(null),s=(0,i.useRef)(null),l=(0,i.useRef)(null),o=(0,i.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null),s.current=null,l.current=null},[]);(0,i.useEffect)(()=>()=>o(),[o]);let c=(0,i.useCallback)(e=>{if(1!==e.touches.length)return;let n=e.touches[0];s.current={x:n.clientX,y:n.clientY},l.current=e,r.current=setTimeout(()=>{l.current&&a(l.current),o()},t)},[t,a,o]),d=(0,i.useCallback)(e=>{if(!s.current||1!==e.touches.length)return;let t=e.touches[0],a=t.clientX-s.current.x,r=t.clientY-s.current.y;Math.sqrt(a*a+r*r)>n&&o()},[n,o]);return{onTouchStart:c,onTouchMove:d,onTouchEnd:(0,i.useCallback)(()=>{o()},[o]),onTouchCancel:(0,i.useCallback)(()=>{o()},[o])}}({onLongPress:(0,i.useCallback)(e=>{null==f||f(e,N,S?"directory":"file")},[N,S,f])}),P={...function(e){let t=Math.min(e,20);return{paddingLeft:"".concat(.5+ +t,"rem")}}(s),touchAction:"manipulation",WebkitTouchCallout:"none"};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{"data-testid":"tree-item-".concat(n.name),role:"treeitem","aria-selected":!1,"aria-expanded":S?C:void 0,tabIndex:0,className:"flex items-center gap-2 py-1.5 pr-2 cursor-pointer hover:bg-muted rounded transition-colors",style:P,onClick:M,onKeyDown:A,onContextMenu:L,onTouchStart:R.onTouchStart,onTouchMove:R.onTouchMove,onTouchEnd:R.onTouchEnd,onTouchCancel:R.onTouchCancel,children:[S?(0,r.jsx)("span",{className:"w-4 h-4 flex items-center justify-center",children:w?(0,r.jsx)(u.y,{size:"xs",variant:"accent"}):(0,r.jsx)(nL,{expanded:C})}):(0,r.jsx)("span",{className:"w-4 h-4"}),S?(0,r.jsx)(nR,{open:C}):(0,r.jsx)(nD,{extension:n.extension}),(0,r.jsx)(nT.nR,{content:n.name,metadata:I,className:"flex-1 truncate text-sm text-foreground",children:"name"===g&&p?(0,r.jsx)(nP,{text:n.name,query:p}):n.name}),y.showSize&&(0,r.jsx)("span",{"data-testid":"tree-item-size",className:"text-xs text-muted-foreground flex-shrink-0",children:S?void 0!==n.itemCount&&j("fileTree.itemCount",{count:n.itemCount}):nA(n.size)}),!S&&y.showCreated&&n.birthtime&&(0,r.jsx)("span",{"data-testid":"tree-item-created",className:"text-xs text-muted-foreground flex-shrink-0",children:(0,tX.fw)(n.birthtime,E)}),!S&&y.showModified&&n.mtime&&(0,r.jsx)("span",{"data-testid":"tree-item-modified",className:"text-xs text-muted-foreground flex-shrink-0",children:(0,tX.fw)(n.mtime,E)})]}),S&&C&&T&&(0,r.jsx)("div",{role:"group",children:T.filter(e=>{let t=N?"".concat(N,"/").concat(e.name):e.name;if(!(null==p?void 0:p.trim()))return!0;if("name"===g){let t=p.toLowerCase();return!!e.name.toLowerCase().includes(t)||"directory"===e.type}if("content"===g&&b&&b.size>0){if(b.has(t))return!0;if("directory"===e.type){for(let e of b)if(e.startsWith(t+"/"))return!0}return!1}return!0}).map(t=>(0,r.jsx)(e,{item:t,path:N,depth:s+1,worktreeId:l,expanded:o,cache:d,onToggle:m,onFileSelect:h,onLoadChildren:x,onContextMenu:f,searchQuery:p,searchMode:g,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y},t.name))})]})});var nO=n(26989);let nz=[{key:"showSize",labelKey:"fileTree.metadata.showSize"},{key:"showCreated",labelKey:"fileTree.metadata.showCreated"},{key:"showModified",labelKey:"fileTree.metadata.showModified"}];function n_(e,t,n){if(t<=0||n<=0)return 0;let a=e+t+8-n;return a>0?-Math.min(a,Math.max(0,e-8)):e<8?8-e:0}let nB=(0,i.memo)(function(e){let{settings:t,onToggle:n}=e,a=(0,c.c)("worktree"),[s,l]=(0,i.useState)(!1),o=(0,i.useRef)(null),d=(0,i.useRef)(null),u=(0,i.useRef)({x:0,y:0}),[h,x]=(0,i.useState)({x:0,y:0});(0,i.useEffect)(()=>{if(!s)return;let e=e=>{o.current&&!o.current.contains(e.target)&&l(!1)},t=e=>{"Escape"===e.key&&l(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[s]),(0,i.useLayoutEffect)(()=>{let e=e=>{u.current=e,x(t=>t.x===e.x&&t.y===e.y?t:e)};if(!s)return void e({x:0,y:0});let t=d.current;if(!t)return;let n=t.getBoundingClientRect();e({x:n_(n.left-u.current.x,n.width,window.innerWidth),y:n_(n.top-u.current.y,n.height,window.innerHeight)})},[s]);let f=(0,i.useCallback)(e=>{n(e)},[n]);return(0,r.jsxs)("div",{className:"relative",ref:o,"data-testid":"file-metadata-toggle",children:[(0,r.jsx)("button",{type:"button","data-testid":"file-metadata-toggle-button",onClick:()=>l(e=>!e),"aria-haspopup":"menu","aria-expanded":s,"aria-label":a("fileTree.metadata.settingsLabel"),title:a("fileTree.metadata.settingsLabel"),className:"flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:(0,r.jsx)(nO.A,{className:"w-4 h-4","aria-hidden":"true"})}),s&&(0,r.jsxs)("div",{ref:d,role:"menu","data-testid":"file-metadata-toggle-menu",className:"absolute right-0 top-full z-20 mt-1 min-w-[12rem] rounded border border-border bg-surface shadow-lg p-1",style:0!==h.x||0!==h.y?{transform:"translate(".concat(h.x,"px, ").concat(h.y,"px)")}:void 0,children:[(0,r.jsx)("div",{className:"px-2 py-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:a("fileTree.metadata.settingsTitle")}),nz.map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-2 px-2 py-1.5 text-xs text-foreground hover:bg-muted rounded cursor-pointer",children:[(0,r.jsx)(m.Sc,{"data-testid":"file-metadata-toggle-".concat(e.key),checked:t[e.key],onCheckedChange:()=>f(e.key),className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:a(e.labelKey)})]},e.key))]})]})});function nV(e){let{intervalMs:t,enabled:n,onPoll:a}=e,r=(0,i.useRef)(a);r.current=a;let s=(0,i.useRef)(n);s.current=n;let l=(0,i.useRef)(null);(0,i.useEffect)(()=>{function e(){null!==l.current&&(clearInterval(l.current),l.current=null)}function a(){e(),l.current=setInterval(()=>{r.current()},t)}function i(){"hidden"===document.visibilityState?e():"visible"===document.visibilityState&&s.current&&(r.current(),a())}return n?a():e(),document.addEventListener("visibilitychange",i),()=>{e(),document.removeEventListener("visibilitychange",i)}},[t,n])}function nW(e){return"commandmate:file-tree-expanded:"+e}function nH(e){try{let t=window.localStorage.getItem(nW(e));if(!t)return new Set;let n=JSON.parse(t);if(Array.isArray(n)&&n.every(e=>"string"==typeof e))return new Set(n)}catch(e){}return new Set}var nU=n(89559);let nK=(0,i.memo)(function(e){let{worktreeId:t,onFileSelect:n,onNewFile:a,onNewDirectory:s,onRename:l,onDelete:o,onUpload:d,onMove:u,className:h="",refreshTrigger:f=0,pollingEnabled:p=!1,searchQuery:g,searchMode:b,searchResults:v,onSearchResultSelect:y,onResetView:j}=e,w=(0,tq.Ym)(),k=(0,c.c)("worktree"),{settings:N,toggle:C}=function(){let[e,t]=(0,i.useState)(nI),n=(0,i.useRef)(e);n.current=e,(0,i.useEffect)(()=>{t(function(){try{var e;let t=window.localStorage.getItem(nE);if(!t)return{...nI};return e=JSON.parse(t),"object"!=typeof e||null===e?{...nI}:{showSize:"boolean"==typeof e.showSize?e.showSize:nI.showSize,showCreated:"boolean"==typeof e.showCreated?e.showCreated:nI.showCreated,showModified:"boolean"==typeof e.showModified?e.showModified:nI.showModified}}catch(e){return{...nI}}}())},[]),(0,i.useEffect)(()=>{let e=e=>{if(e.detail){var a,r;a=e.detail.settings,r=n.current,(a.showSize!==r.showSize||a.showCreated!==r.showCreated||a.showModified!==r.showModified)&&t(e.detail.settings)}};return window.addEventListener(nM,e),()=>window.removeEventListener(nM,e)},[]);let a=(0,i.useCallback)(e=>{n.current=e,t(e);try{window.localStorage.setItem(nE,JSON.stringify(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(nM,{detail:{settings:e}}))}catch(e){}},[]);return{settings:e,toggle:(0,i.useCallback)(e=>{a({...n.current,[e]:!n.current[e]})},[a]),setSettings:a}}(),[S,T]=(0,i.useState)(!0),[E,I]=(0,i.useState)(null),[M,A]=(0,i.useState)([]),{expanded:L,setExpanded:R,resetExpanded:P}=function(e){let[t,n]=(0,i.useState)(()=>nH(e)),a=(0,i.useRef)(e);(0,i.useEffect)(()=>{a.current!==e&&(a.current=e,n(nH(e)))},[e]),(0,i.useEffect)(()=>{!function(e,t){try{let n=nW(e);if(0===t.size)return void window.localStorage.removeItem(n);window.localStorage.setItem(n,JSON.stringify(Array.from(t)))}catch(e){}}(a.current,t)},[t]);let r=(0,i.useCallback)(()=>{n(new Set)},[]);return{expanded:t,setExpanded:n,resetExpanded:r}}(t),[D,F]=(0,i.useState)(()=>new Map),O=(0,i.useRef)(null),z=(0,i.useRef)(L);z.current=L;let _=(0,i.useRef)(k);_.current=k;let B=(0,i.useRef)(new Set),{menuState:V,openMenu:W,closeMenu:H}=function(){let[e,t]=(0,i.useState)(nb),n=(0,i.useCallback)((e,n,a)=>{let r,s;if(e.preventDefault(),"touches"in e&&e.touches.length>0)r=e.touches[0].clientX,s=e.touches[0].clientY;else{if(!("clientX"in e))return;r=e.clientX,s=e.clientY}t({isOpen:!0,position:{x:r,y:s},targetPath:n,targetType:a})},[]),a=(0,i.useCallback)(()=>{t(e=>({...e,isOpen:!1}))},[]),r=(0,i.useCallback)(()=>{t(nb)},[]);return(0,i.useEffect)(()=>{if(!e.isOpen)return;let t=()=>{a()},n=setTimeout(()=>{document.addEventListener("click",t)},0);return()=>{clearTimeout(n),document.removeEventListener("click",t)}},[e.isOpen,a]),(0,i.useEffect)(()=>{if(!e.isOpen)return;let t=e=>{"Escape"===e.key&&a()};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[e.isOpen,a]),{menuState:e,openMenu:n,closeMenu:a,resetMenu:r}}(),U=(0,i.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{let n=e?"/api/worktrees/".concat(t,"/tree/").concat(e):"/api/worktrees/".concat(t,"/tree"),a=await fetch(n);if(!a.ok)throw Error(_.current("fileTree.loadDirectoryError",{status:a.status}));return await a.json()}catch(e){throw console.error("[FileTreeView] Error fetching directory:",e),e}},[t]),K=(0,i.useRef)(!0);(0,i.useEffect)(()=>(K.current=!0,()=>{K.current=!1}),[]);let $=(0,i.useCallback)(async()=>{if(K.current){T(!0),I(null);try{let e=await U();if(!K.current||!e)return;let t=Array.from(z.current),n=new Map,a=[];for(let e=0;e<t.length;e+=5){if(!K.current)return;let r=t.slice(e,e+5);for(let[e,t]of(await Promise.allSettled(r.map(async e=>{let t=await U(e);return{dirPath:e,data:t}}))).entries())"fulfilled"===t.status&&t.value.data?n.set(t.value.dirPath,t.value.data.items):a.push(r[e])}if(!K.current)return;A(e.items),F(n),a.length>0&&R(e=>{let t=new Set(e);for(let e of a)e&&t.delete(e);return t})}catch(e){K.current&&I(e instanceof Error?e.message:_.current("fileTree.loadError"))}finally{K.current&&T(!1)}}},[U,R]);(0,i.useEffect)(()=>{$()},[$,f]);let q=(0,i.useRef)(null),G=(0,i.useRef)(!1);(0,i.useEffect)(()=>{q.current=null},[t]),nV({intervalMs:5e3,enabled:p,onPoll:(0,i.useCallback)(async()=>{if(K.current&&!G.current){G.current=!0;try{let e=["",...Array.from(z.current)],t=new Map;for(let n=0;n<e.length;n+=5){if(!K.current)return;let a=e.slice(n,n+5);for(let{dirPath:e,hash:n}of(await Promise.all(a.map(async e=>{try{var t;let n=await U(e);return{dirPath:e,hash:JSON.stringify(null!=(t=null==n?void 0:n.items)?t:null)}}catch(t){return{dirPath:e,hash:"unavailable"}}}))))t.set(e,n)}if(!K.current)return;let n=q.current;if(q.current=t,null===n)return;let a=!1;for(let[e,r]of t){let t=n.get(e);if(void 0!==t&&t!==r){a=!0;break}}a&&$()}finally{G.current=!1}}},[U,$])});let J=(0,i.useCallback)(async e=>{if(!(D.has(e)||B.current.has(e))){B.current.add(e);try{let t=await U(e);t&&F(n=>{let a=new Map(n);return a.set(e,t.items),a})}catch(e){console.error("[FileTreeView] Error loading children:",e)}finally{B.current.delete(e)}}},[D,U]),Y=(0,i.useCallback)(e=>{R(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[R]),Q=(0,i.useCallback)(()=>{var e;P(),F(new Map),null==(e=O.current)||e.scrollTo({top:0}),null==j||j()},[P,j]),X=(0,i.useMemo)(()=>"content"===b&&v&&0!==v.length?(0,x.q3)(v.map(e=>e.filePath)):new Set,[b,v]);(0,i.useEffect)(()=>{X.size>0&&R(e=>{let t=new Set(e);for(let e of X)(D.has(e)||(null==v?void 0:v.some(t=>t.filePath.startsWith(e+"/"))))&&t.add(e);return t})},[X,D,v,R]);let Z=(0,i.useMemo)(()=>{if(!(null==g?void 0:g.trim()))return M;if("name"===b){let e=g.toLowerCase(),t=(n,a)=>n.filter(n=>{let r=a?"".concat(a,"/").concat(n.name):n.name,s=n.name.toLowerCase().includes(e);if("directory"===n.type){let e=D.get(r);if(e&&t(e,r).length>0)return!0}return s});return t(M,"")}return"content"===b&&X.size>0?M.filter(e=>{if(X.has(e.name))return!0;if("directory"===e.type){for(let t of X)if(t.startsWith(e.name+"/")||t===e.name)return!0}return!1}):M},[M,g,b,X,D]);if(S&&0===M.length)return(0,r.jsx)("div",{"data-testid":"file-tree-loading",className:"p-2 ".concat(h),role:"status","aria-label":k("fileTree.loading"),children:[0,8,16,8,0,8].map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1.5 pr-2",style:{paddingLeft:"".concat(8+e,"px")},children:[(0,r.jsx)(m.EA,{className:"h-4 w-4 shrink-0 rounded"}),(0,r.jsx)(m.EA,{className:"h-4 ".concat(t%3==0?"w-32":t%3==1?"w-24":"w-40"," max-w-full")})]},t))});if(E&&0===M.length)return(0,r.jsx)("div",{"data-testid":"file-tree-error",className:"p-4 bg-danger-subtle border border-danger-border rounded-lg ".concat(h),children:(0,r.jsx)("p",{className:"text-sm text-danger",children:E})});let ee=S&&M.length>0,et=!!E&&M.length>0;return 0===M.length?(0,r.jsxs)("div",{"data-testid":"file-tree-empty",className:"p-4 text-center text-muted-foreground ".concat(h),children:[(0,r.jsx)("p",{className:"text-sm",children:k("fileTree.empty")}),(a||s)&&(0,r.jsxs)("div",{className:"flex flex-col gap-2 mt-4",children:[a&&(0,r.jsxs)(m.$n,{variant:"ghost","data-testid":"empty-new-file-button",onClick:()=>a(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-foreground bg-surface border border-input rounded-md hover:bg-muted transition-colors",children:[(0,r.jsx)(nv.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newFile")})]}),s&&(0,r.jsxs)(m.$n,{variant:"ghost","data-testid":"empty-new-directory-button",onClick:()=>s(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-foreground bg-surface border border-input rounded-md hover:bg-muted transition-colors",children:[(0,r.jsx)(ny.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newDirectory")})]})]})]}):(null==g?void 0:g.trim())&&0===Z.length?(0,r.jsx)("div",{"data-testid":"file-tree-no-results",className:"p-4 text-center text-muted-foreground ".concat(h),children:(0,r.jsx)("p",{className:"text-sm",children:k("content"===b?"fileTree.noResultsContaining":"fileTree.noResultsMatching",{query:g})})}):(0,r.jsxs)("div",{ref:O,"data-testid":"file-tree-view",role:"tree","aria-label":k("fileTree.label"),className:"overflow-auto bg-surface ".concat(h),children:[(0,r.jsxs)("div",{"data-testid":"file-tree-toolbar",className:"flex items-center gap-1 p-1 border-b border-border",children:[a&&(0,r.jsxs)("button",{"data-testid":"toolbar-new-file-button",onClick:()=>a(""),className:"flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:[(0,r.jsx)(nv.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newFile")})]}),s&&(0,r.jsxs)("button",{"data-testid":"toolbar-new-directory-button",onClick:()=>s(""),className:"flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:[(0,r.jsx)(ny.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newDirectory")})]}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,r.jsx)(nB,{settings:N,onToggle:C}),ee&&(0,r.jsxs)("div",{"data-testid":"file-tree-refetch-indicator",role:"status","aria-live":"polite",className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"w-3 h-3 border-2 border-input border-t-accent-500 rounded-full animate-spin"}),(0,r.jsx)("span",{className:"sr-only",children:k("fileTree.refreshing")})]}),(0,r.jsx)("button",{"data-testid":"file-tree-refresh-button",type:"button",onClick:()=>{$()},disabled:ee,"aria-label":k("fileTree.refreshLabel"),title:k("actions.refresh"),className:"flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,r.jsx)(nU.A,{className:"w-4 h-4 ".concat(ee?"animate-spin":""),"aria-hidden":"true"})}),(0,r.jsx)("button",{"data-testid":"file-tree-reset-button",type:"button",onClick:Q,"aria-label":k("fileTree.resetViewLabel"),title:k("actions.resetView"),className:"flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:(0,r.jsx)(tK.A,{className:"w-4 h-4","aria-hidden":"true"})})]})]}),et&&(0,r.jsxs)("div",{"data-testid":"file-tree-refetch-error",role:"alert",className:"flex items-center gap-2 px-2 py-1 text-xs bg-danger-subtle border-b border-danger-border text-danger-foreground",children:[(0,r.jsx)(tU.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"flex-1 truncate",children:E}),(0,r.jsx)(m.$n,{variant:"ghost","data-testid":"file-tree-refetch-retry-button",onClick:()=>{$()},className:"px-2 py-0.5 text-xs rounded border border-danger-border hover:bg-danger-subtle transition-colors",children:k("actions.retry")})]}),Z.map(e=>(0,r.jsx)(nF,{item:e,path:"",depth:0,worktreeId:t,expanded:L,cache:D,onToggle:Y,onFileSelect:y||n,onLoadChildren:J,onContextMenu:W,searchQuery:g,searchMode:b,matchedPaths:X,dateFnsLocaleStr:w,metadataDisplay:N},e.name)),(0,r.jsx)(nS,{isOpen:V.isOpen,position:V.position,targetPath:V.targetPath,targetType:V.targetType,onClose:H,onNewFile:a,onNewDirectory:s,onRename:l,onDelete:o,onUpload:d,onMove:u})]})}),n$=(0,i.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),nq=(0,i.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),nG=(0,i.memo)(function(){let e=(0,c.c)("worktree");return(0,r.jsx)(u.y,{size:"sm",variant:"accent","data-testid":"search-loading",role:"status","aria-hidden":!1,"aria-label":e("search.searching")})}),nJ=(0,i.memo)(function(e){let{query:t,mode:n,isSearching:a,error:s,onQueryChange:l,onModeChange:o,onClear:d,placeholder:u,className:m=""}=e,h=(0,i.useRef)(null),x=(0,c.c)("worktree"),f=(0,i.useCallback)(e=>{l(e.target.value)},[l]),p=(0,i.useCallback)(()=>{var e;d(),null==(e=h.current)||e.focus()},[d]),g=(0,i.useCallback)(e=>{if("Escape"===e.key)if(t)p();else{var n;null==(n=h.current)||n.blur()}},[t,p]);return(0,i.useEffect)(()=>{if(!(window.innerWidth<X.D)){let e=setTimeout(()=>{var e;null==(e=h.current)||e.focus()},100);return()=>clearTimeout(e)}},[]),(0,r.jsxs)("div",{"data-testid":"search-bar",className:"flex flex-col gap-2 p-2 bg-surface dark:bg-surface-2 border-b border-border ".concat(m),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(n$,{})}),(0,r.jsx)("input",{ref:h,type:"text","data-testid":"search-input",value:t,onChange:f,onKeyDown:g,placeholder:null!=u?u:x("search.placeholder"),className:"flex-1 min-w-0 px-2 py-1 text-sm bg-muted text-foreground border border-input rounded focus:outline-none focus:ring-1 focus:ring-ring focus:border-accent-500","aria-label":x("search.label"),"aria-busy":a}),(0,r.jsx)("div",{className:"flex-shrink-0 w-6 h-6 flex items-center justify-center",children:a?(0,r.jsx)(nG,{}):t?(0,r.jsx)("button",{type:"button","data-testid":"search-clear",onClick:p,className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors","aria-label":x("search.clear"),children:(0,r.jsx)(nq,{})}):null})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground mr-1",children:x("search.mode")}),(0,r.jsx)("button",{type:"button","data-testid":"mode-name",onClick:()=>o("name"),className:"px-2 py-0.5 text-xs rounded transition-colors ".concat("name"===n?"bg-accent-100 dark:bg-accent-900 text-accent-700 dark:text-accent-300 font-medium":"bg-muted text-muted-foreground hover:bg-muted/80"),"aria-pressed":"name"===n,children:x("search.modeName")}),(0,r.jsx)("button",{type:"button","data-testid":"mode-content",onClick:()=>o("content"),className:"px-2 py-0.5 text-xs rounded transition-colors ".concat("content"===n?"bg-accent-100 dark:bg-accent-900 text-accent-700 dark:text-accent-300 font-medium":"bg-muted text-muted-foreground hover:bg-muted/80"),"aria-pressed":"content"===n,children:x("search.modeContent")})]}),s&&(0,r.jsx)("div",{"data-testid":"search-error",className:"text-xs text-danger bg-danger-subtle px-2 py-1 rounded",role:"alert",children:s})]})});function nY(e){return 0===e.length?"0":e.map(e=>"".concat(e.id,":").concat(e.title.length,":").concat(e.content.length)).join("|")}var nQ=n(12108),nX=n(60850);let nZ=(0,i.memo)(function(e){var t,n;let{memo:a,onUpdate:s,onDelete:l,isSaving:o,error:d,className:u="",onInsertToMessage:m,onMoveUp:h,onMoveDown:x,canMoveUp:f=!0,canMoveDown:p=!0}=e,g=(0,c.c)("schedule"),b=(0,c.c)("worktree"),v=!!(h||x),[y,j]=(0,i.useState)(a.title),[w,k]=(0,i.useState)(a.content),[N,C]=(0,i.useState)(!1),S=(0,i.useRef)(void 0);(0,i.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);let{isSaving:T,error:E,saveNow:I}=(0,nX.U)({value:y,saveFn:async e=>{await s(a.id,{title:e})}}),{isSaving:M,error:A,saveNow:L}=(0,nX.U)({value:w,saveFn:async e=>{await s(a.id,{content:e})}}),R=null!=(n=null!=(t=null!=d?d:null==E?void 0:E.message)?t:null==A?void 0:A.message)?n:null,P=(0,i.useCallback)(e=>{j(e.target.value)},[]),D=(0,i.useCallback)(e=>{k(e.target.value)},[]),F=(0,i.useCallback)(()=>{I()},[I]),O=(0,i.useCallback)(()=>{L()},[L]),z=(0,i.useCallback)(()=>{l(a.id)},[a.id,l]),_=(0,i.useCallback)(()=>{w.trim()&&(null==m||m(w))},[w,m]),B=(0,i.useCallback)(async()=>{if(w.trim())try{await (0,ej.l)(w),C(!0),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>C(!1),2e3)}catch(e){}},[w]);return(0,r.jsxs)("div",{"data-testid":"memo-card","data-memo-id":a.id,tabIndex:-1,className:"bg-surface dark:bg-surface-2 border border-border rounded-lg p-4 space-y-3 focus:outline-none ".concat(u),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"text",value:y,onChange:P,onBlur:F,placeholder:g("memoTitlePlaceholder"),className:"flex-1 min-w-0 text-sm font-medium text-foreground bg-transparent border-none focus:outline-none focus:ring-0 p-0"}),(null!=o?o:T||M)&&(0,r.jsx)("span",{"data-testid":"saving-indicator",className:"text-xs text-muted-foreground",children:b("actions.saving")}),v&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button","data-testid":"memo-move-up-".concat(a.id),onClick:h,disabled:!f,"aria-label":g("memoMoveUp"),title:g("memoMoveUp"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-foreground transition-colors rounded disabled:opacity-30 disabled:cursor-not-allowed",children:(0,r.jsx)(nQ.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button","data-testid":"memo-move-down-".concat(a.id),onClick:x,disabled:!p,"aria-label":g("memoMoveDown"),title:g("memoMoveDown"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-foreground transition-colors rounded disabled:opacity-30 disabled:cursor-not-allowed",children:(0,r.jsx)(tn.A,{className:"w-4 h-4","aria-hidden":"true"})})]}),m&&(0,r.jsx)("button",{type:"button","data-testid":"insert-memo-content",onClick:_,"aria-label":g("memoInsertToMessage"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 transition-colors rounded",title:g("memoInsertToMessage"),children:(0,r.jsx)(t$.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:B,"aria-label":g("memoCopyContent"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-foreground transition-colors rounded",children:N?(0,r.jsx)(ex.A,{className:"w-4 h-4 text-success"}):(0,r.jsx)(ef.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{type:"button",onClick:z,"aria-label":g("memoDelete"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-danger transition-colors rounded",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}),(0,r.jsx)("textarea",{value:w,onChange:D,onBlur:O,placeholder:g("memoContentPlaceholder"),rows:4,className:"w-full text-sm text-foreground bg-muted border border-border rounded-md p-2 resize-y focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),R&&(0,r.jsx)("div",{className:"text-xs text-danger",children:R})]})}),n0=(0,i.memo)(function(e){let{currentCount:t,maxCount:n,onAdd:a,isLoading:s=!1,className:l=""}=e,i=(0,c.c)("schedule"),o=Math.max(0,n-t),d=t>=n||s;return(0,r.jsxs)("div",{"data-testid":"memo-add-button",className:"flex flex-col items-center gap-2 ".concat(l),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{d||a()},disabled:d,"aria-label":i("memoAdd"),"aria-disabled":d,className:"\n flex items-center gap-2 px-4 py-2 rounded-lg border-2 border-dashed\n transition-colors focus:outline-none focus:ring-2 focus:ring-ring\n ".concat(d?"border-border text-muted-foreground cursor-not-allowed opacity-50":"border-border text-muted-foreground hover:border-accent-400 dark:hover:border-accent-500 hover:text-accent-600 dark:hover:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/30","\n "),children:[s?(0,r.jsx)(u.y,{"data-testid":"loading-indicator",size:"md",variant:"accent"}):(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),(0,r.jsx)("span",{className:"text-sm font-medium",children:i("memoAdd")})]}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:i("memoRemaining",{count:o})})]})});function n1(e){let{query:t,onQueryChange:n,matchCount:a,currentIndex:s,onNext:l,onPrev:o,onClose:d,onCompositionStart:u,onCompositionEnd:h}=e,x=(0,c.c)("schedule"),f=(0,i.useRef)(null);(0,i.useEffect)(()=>{var e;null==(e=f.current)||e.focus()},[]);let p=(0,i.useCallback)(e=>{"Escape"===e.key?d():"Enter"===e.key&&(e.preventDefault(),l())},[d,l]),g=(0,i.useCallback)(e=>{n(e.target.value)},[n]),b=0===a?"0/0":"".concat(s+1,"/").concat(a);return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border border-input rounded",role:"search","aria-label":x("memoSearchLabel"),children:[(0,r.jsx)("input",{ref:f,type:"text",value:t,onChange:g,onKeyDown:p,onCompositionStart:u,onCompositionEnd:h,placeholder:x("memoSearchPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-foreground text-sm outline-none placeholder-muted-foreground","aria-label":x("memoSearchInputLabel"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,r.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"text-muted-foreground text-xs min-w-[3rem] text-right",children:b}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:o,disabled:0===a,"aria-label":x("memoSearchPrev"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▲"}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:l,disabled:0===a,"aria-label":x("memoSearchNext"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▼"}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:d,"aria-label":x("memoSearchClose"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white min-w-[36px] min-h-[36px] flex items-center justify-center text-base ml-1",children:"✕"})]})}let n2=(0,i.memo)(function(e){let{worktreeId:t,className:n="",onInsertToMessage:a}=e,s=(0,c.c)("schedule"),l=(0,c.c)("common"),o=(0,ec.SC)(),[d,m]=(0,i.useState)([]),[h,x]=(0,i.useState)(!0),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)(!1),k=(0,i.useRef)(null),{query:N,matches:C,currentMatch:S,totalCount:T,setQuery:E,reset:I,navigateNext:M,navigatePrev:A,onCompositionStart:L,onCompositionEnd:R}=function(e){let{memos:t}=e,[n,a]=(0,i.useState)(""),[r,s]=(0,i.useState)([]),[l,o]=(0,i.useState)(-1),c=(0,i.useRef)(null),d=(0,i.useRef)(""),u=(0,i.useRef)(!1),m=(0,i.useRef)(nY(t)),h=(0,i.useRef)(t);h.current=t;let x=r.length,f=(0,i.useCallback)(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),p=(0,i.useCallback)(e=>{let t=function(e,t){if(t.length<2||0===e.length)return[];let n=t.toLowerCase();return e.filter(e=>-1!==e.title.toLowerCase().indexOf(n)||-1!==e.content.toLowerCase().indexOf(n))}(h.current,e);s(t),o(t.length>0?0:-1)},[]),g=(0,i.useCallback)(e=>{f(),d.current=e,u.current||(c.current=setTimeout(()=>{p(e)},300))},[f,p]),b=(0,i.useCallback)(e=>{a(e),g(e)},[g]),v=(0,i.useCallback)(()=>{a(""),d.current="",s([]),o(-1),f()},[f]),y=(0,i.useCallback)(()=>{o(e=>0===x?-1:(e+1)%x)},[x]),j=(0,i.useCallback)(()=>{o(e=>0===x?-1:(e-1+x)%x)},[x]),w=(0,i.useCallback)(()=>{u.current=!0,f()},[f]),k=(0,i.useCallback)(()=>{u.current=!1;let e=d.current;e.length>=2&&(f(),c.current=setTimeout(()=>{p(e)},300))},[f,p]);return(0,i.useEffect)(()=>{let e=nY(t);if(e===m.current)return;m.current=e;let n=d.current;n.length>=2&&p(n)},[t,p]),(0,i.useEffect)(()=>()=>{f(),d.current=""},[f]),{query:n,matches:r,currentMatch:l,totalCount:x,setQuery:b,reset:v,navigateNext:y,navigatePrev:j,onCompositionStart:w,onCompositionEnd:k}}({memos:d}),P=j&&N.length>0,D=P?C:d,F=(0,i.useCallback)(async()=>{x(!0),b(null);try{let e=await V.$T.getAll(t);m(e.sort((e,t)=>e.position-t.position))}catch(e){b((0,V.hS)(e))}finally{x(!1)}},[t]);(0,i.useEffect)(()=>{F()},[F]);let O=(0,i.useCallback)(async()=>{p(!0),y(null);try{let e=await V.$T.create(t,{title:s("memoDefaultTitle"),content:""});m(t=>[...t,e])}catch(e){y((0,V.hS)(e))}finally{p(!1)}},[t,s]),_=(0,i.useCallback)(async(e,n)=>{await V.$T.update(t,e,n),m(t=>t.map(t=>t.id===e?{...t,...n}:t))},[t]),B=(0,i.useCallback)(async e=>{var n;let a=d.find(t=>t.id===e);if(await o({description:l("confirmDelete",{name:null!=(n=null==a?void 0:a.title)?n:""}),variant:"danger"}))try{await V.$T.delete(t,e),m(t=>t.filter(t=>t.id!==e))}catch(e){console.error("Failed to delete memo:",e)}},[t,d,o,l]),W=(0,i.useCallback)(async(e,n)=>{let a=e+n;if(a<0||a>=d.length)return;let r=[...d];[r[e],r[a]]=[r[a],r[e]],m(r);try{await V.$T.reorder(t,r.map(e=>e.id))}catch(e){b((0,V.hS)(e)),await F()}},[d,t,F]),H=(0,i.useCallback)(()=>{F()},[F]),U=(0,i.useCallback)(()=>{w(e=>(e&&I(),!e))},[I]),K=(0,i.useCallback)(()=>{w(!1),I()},[I]);return((0,i.useEffect)(()=>{var e;if(!P||S<0)return;let t=C[S];if(!t)return;let n=null==(e=k.current)?void 0:e.querySelector('[data-memo-id="'.concat(t.id,'"]'));n&&(n.scrollIntoView({block:"nearest"}),n.focus({preventScroll:!0}))},[P,S,C]),h)?(0,r.jsx)("div",{"data-testid":"memo-pane",className:"flex flex-col items-center justify-center h-full p-4 ".concat(n),children:(0,r.jsxs)("div",{"data-testid":"memo-loading",className:"flex flex-col items-center gap-3",children:[(0,r.jsx)(u.y,{size:"xl",variant:"accent"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:s("memoLoading")})]})}):g?(0,r.jsx)("div",{"data-testid":"memo-pane",className:"flex flex-col items-center justify-center h-full p-4 ".concat(n),children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[(0,r.jsx)("svg",{className:"w-12 h-12 text-danger",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsx)("span",{className:"text-sm text-danger-foreground",children:g}),(0,r.jsx)("button",{type:"button",onClick:H,"aria-label":l("retry"),className:"px-4 py-2 text-sm font-medium text-white bg-accent-500 rounded-lg hover:bg-accent-600 transition-colors",children:l("retry")})]})}):(0,r.jsxs)("div",{ref:k,"data-testid":"memo-pane",className:"flex flex-col gap-4 p-4 overflow-y-auto ".concat(n),children:[(0,r.jsx)("div",{"data-testid":"memo-pane-header",className:"flex items-center gap-2",children:j?(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(n1,{query:N,onQueryChange:E,matchCount:T,currentIndex:S,onNext:M,onPrev:A,onClose:K,onCompositionStart:L,onCompositionEnd:R})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("button",{type:"button","data-testid":"memo-search-toggle",onClick:U,"aria-label":s("memoSearchToggle"),className:"p-1.5 text-muted-foreground hover:text-foreground transition-colors rounded",children:(0,r.jsx)(z.A,{className:"w-4 h-4","aria-hidden":"true"})})]})}),0===d.length&&!P&&!v&&(0,r.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,r.jsx)("p",{children:s("memoEmpty")}),(0,r.jsx)("p",{className:"text-sm",children:s("memoEmptyHint")})]}),P&&0===D.length&&(0,r.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:(0,r.jsx)("p",{children:s("memoNoMatch")})}),D.map((e,t)=>(0,r.jsx)(nZ,{memo:e,onUpdate:_,onDelete:B,onInsertToMessage:a,onMoveUp:P?void 0:()=>W(t,-1),onMoveDown:P?void 0:()=>W(t,1),canMoveUp:!P&&t>0,canMoveDown:!P&&t<d.length-1},e.id)),v&&(0,r.jsx)("div",{className:"text-center py-2 text-sm text-danger",children:v}),!P&&(0,r.jsx)(n0,{currentCount:d.length,maxCount:20,onAdd:O,isLoading:f,className:"mt-2"})]})});var n4=n(85872),n5=n(53292),n3=n(53482);let n6={todo:"border-input text-muted-foreground",doing:"border-warning-border bg-warning-subtle text-warning-foreground",done:"border-success-border bg-success-subtle text-success-foreground"},n8=i.memo(function(e){let{worktreeId:t,className:n=""}=e,a=(0,c.c)("worktree"),s=(0,c.c)("common"),l=(0,ec.SC)(),[o,d]=(0,i.useState)([]),[u,m]=(0,i.useState)(""),[h,x]=(0,i.useState)(!0),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)(""),[k,N]=(0,i.useState)(""),[C,S]=(0,i.useState)(!1),T=(0,i.useCallback)(e=>{switch(e){case"doing":return a("todo.statusDoing");case"done":return a("todo.statusDone");default:return a("todo.statusTodo")}},[a]),E=(0,i.useCallback)(async()=>{x(!0),b(null);try{let e=await n4.Ar.list(t);d(e)}catch(e){b(e instanceof Error?e.message:a("todo.loadError")),d([])}finally{x(!1)}},[t,a]);(0,i.useEffect)(()=>{E()},[t]);let I=(0,i.useCallback)(async()=>{let e=u.trim();if(e&&!f){p(!0),b(null);try{let n=await n4.Ar.create(t,e);d(e=>[...e,n]),m("")}catch(e){b(e instanceof Error?e.message:a("todo.addError"))}finally{p(!1)}}},[u,f,t,a]),M=(0,i.useCallback)(async e=>{let n=function(e){let t=n4.KG.indexOf(e);return n4.KG[(t+1)%n4.KG.length]}(e.status);d(t=>t.map(t=>t.id===e.id?{...t,status:n,done:"done"===n}:t)),b(null);try{await n4.Ar.update(t,e.id,{status:n})}catch(e){b(e instanceof Error?e.message:a("todo.updateError")),E()}},[t,E,a]),A=(0,i.useCallback)(async e=>{if(await l({description:s("confirmDelete",{name:e.content}),variant:"danger"})){b(null);try{await n4.Ar.remove(t,e.id),d(t=>t.filter(t=>t.id!==e.id))}catch(e){b(e instanceof Error?e.message:a("todo.deleteError"))}}},[t,a,l,s]),L=(0,i.useCallback)(e=>{y(e),w(e.content),N(e.detail),b(null)},[]),R=(0,i.useCallback)(()=>{y(null),S(!1)},[]),P=(0,i.useCallback)(async()=>{if(!v)return;let e=j.trim();if(e&&!C){S(!0),b(null);try{let n=await n4.Ar.update(t,v.id,{content:e,detail:k});d(e=>e.map(e=>e.id===v.id?n:e)),R()}catch(e){b(e instanceof Error?e.message:a("todo.updateError")),S(!1)}}},[v,j,k,C,t,R,a]),D=(0,i.useCallback)(async(e,n)=>{let r=e+n;if(r<0||r>=o.length)return;let s=[...o];[s[e],s[r]]=[s[r],s[e]],d(s),b(null);try{await n4.Ar.reorder(t,s.map(e=>e.id))}catch(e){b(e instanceof Error?e.message:a("todo.reorderError")),E()}},[o,t,E,a]),F=(0,i.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),I())},[I]),O=(0,i.useMemo)(()=>({todo:o.filter(e=>"todo"===e.status).length,doing:o.filter(e=>"doing"===e.status).length,done:o.filter(e=>"done"===e.status).length}),[o]);return(0,r.jsxs)("div",{"data-testid":"todo-pane",className:"flex flex-col h-full overflow-y-auto p-4 ".concat(n).trim(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,r.jsx)("input",{type:"text",value:u,onChange:e=>m(e.target.value),onKeyDown:F,maxLength:n5.Ll,placeholder:a("todo.addPlaceholder"),"data-testid":"todo-input",className:"flex-1 min-w-0 rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("button",{type:"button",onClick:I,disabled:f||0===u.trim().length,"data-testid":"todo-add-button",className:"shrink-0 rounded-md bg-accent-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-700 disabled:opacity-50",children:a("todo.add")})]}),(0,r.jsxs)("div",{className:"mb-2 flex justify-end gap-2 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{"data-testid":"todo-count-todo",children:[T("todo")," ",O.todo]}),(0,r.jsxs)("span",{"data-testid":"todo-count-doing",children:[T("doing")," ",O.doing]}),(0,r.jsxs)("span",{"data-testid":"todo-count-done",children:[T("done")," ",O.done]})]}),g&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"todo-error",children:g}),h?(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"todo-loading",children:a("todo.loading")}):0===o.length?(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"todo-empty",children:a("todo.empty")}):(0,r.jsx)("ul",{className:"space-y-1","data-testid":"todo-list",children:o.map((e,t)=>(0,r.jsxs)("li",{className:"flex items-center gap-2 rounded-md px-1 py-1 hover:bg-muted group","data-testid":"todo-item",children:[(0,r.jsx)("button",{type:"button",onClick:()=>M(e),"data-testid":"todo-status","data-status":e.status,"aria-label":a("todo.cycleStatus",{status:T(e.status)}),title:a("todo.cycleStatus",{status:T(e.status)}),className:"shrink-0 inline-flex min-h-[44px] items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium sm:min-h-0 ".concat(n6[e.status]),children:T(e.status)}),(0,r.jsxs)("button",{type:"button",onClick:()=>L(e),"data-testid":"todo-content","aria-label":a("todo.edit"),title:a("todo.edit"),className:"group/content flex min-h-[44px] min-w-0 flex-1 items-center gap-1.5 text-left sm:min-h-0",children:[(0,r.jsx)("span",{className:"min-w-0 break-words text-sm ".concat("done"===e.status?"line-through text-muted-foreground":"text-foreground group-hover/content:text-accent-700 dark:group-hover/content:text-accent-300"),children:e.content}),""!==e.detail.trim()&&(0,r.jsxs)("svg",{"data-testid":"todo-detail-indicator","aria-label":a("todo.hasDetail"),className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,r.jsx)("title",{children:a("todo.hasDetail")}),(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h10"})]})]}),(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>D(t,-1),disabled:0===t,"aria-label":a("todo.moveUp"),"data-testid":"todo-move-up",className:"p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,r.jsx)("button",{type:"button",onClick:()=>D(t,1),disabled:t===o.length-1,"aria-label":a("todo.moveDown"),"data-testid":"todo-move-down",className:"p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,r.jsx)("button",{type:"button",onClick:()=>A(e),"aria-label":a("todo.delete"),"data-testid":"todo-delete",className:"inline-flex min-h-[44px] min-w-[44px] shrink-0 items-center justify-center text-muted-foreground opacity-100 transition-opacity hover:text-danger-foreground sm:min-h-0 sm:min-w-0 sm:opacity-0 sm:group-hover:opacity-100",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},e.id))}),(0,r.jsx)(e7.a,{isOpen:null!==v,onClose:R,title:a("todo.editTitle"),size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:a("todo.contentLabel")}),(0,r.jsx)("input",{type:"text",value:j,onChange:e=>w(e.target.value),maxLength:n5.Ll,placeholder:a("todo.contentPlaceholder"),"data-testid":"todo-edit-content",className:"w-full rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,r.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,r.jsxs)("span",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:a("todo.detailLabel")}),""!==k.trim()&&(0,r.jsx)(n3.i,{text:k,label:a("todo.copyDetail"),className:"!border-input !bg-surface dark:!bg-surface-2 !text-muted-foreground hover:!bg-muted"})]}),(0,r.jsx)("textarea",{value:k,onChange:e=>N(e.target.value),maxLength:n5.bu,rows:6,placeholder:a("todo.detailPlaceholder"),"data-testid":"todo-edit-detail",className:"w-full resize-y rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:R,"data-testid":"todo-edit-cancel",className:"rounded-md border border-input px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted",children:a("todo.cancel")}),(0,r.jsx)("button",{type:"button",onClick:P,disabled:C||0===j.trim().length,"data-testid":"todo-edit-save",className:"rounded-md bg-accent-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-700 disabled:opacity-50",children:a("todo.save")})]})]})})]})});var n9=n(95740),n7=n(66630),ae=n(37586),at=n(47650);function an(e){let{isOpen:t,onClose:n,title:a,children:s,footer:l,showCloseButton:o=!0}=e,d=(0,c.c)("common"),[u,m]=(0,i.useState)(null);return((0,i.useEffect)(()=>{let e=e=>{"Escape"===e.key&&t&&n()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,n]),(0,i.useEffect)(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[t]),(0,i.useEffect)(()=>{if(!t)return;let e=window.visualViewport;if(!e)return;let n=()=>m(e.height);return n(),e.addEventListener("resize",n),()=>e.removeEventListener("resize",n)},[t]),t)?(0,at.createPortal)((0,r.jsxs)("div",{"data-testid":"full-screen-modal",role:"dialog","aria-modal":"true",className:"fixed inset-0 flex flex-col bg-surface animate-slide-up",style:{zIndex:eT.M.MODAL,height:u?"".concat(u,"px"):"100dvh"},children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsx)("h3",{className:"text-base font-semibold text-foreground truncate pr-2",children:a}),o&&(0,r.jsx)("button",{type:"button",onClick:n,"aria-label":d("close"),"data-testid":"full-screen-modal-close",className:"flex-shrink-0 -mr-1 p-1 text-muted-foreground hover:text-foreground transition-colors",children:(0,r.jsx)(ew.A,{className:"w-6 h-6"})})]}),(0,r.jsx)("div",{"data-testid":"full-screen-modal-body",className:"flex-1 min-h-0 overflow-y-auto overscroll-contain px-4 py-4",onFocusCapture:e=>{let t=e.target;t&&"function"==typeof t.scrollIntoView&&window.requestAnimationFrame(()=>{t.scrollIntoView({block:"center",behavior:"smooth"})})},children:s}),l&&(0,r.jsx)("div",{"data-testid":"full-screen-modal-footer",className:"flex-shrink-0 border-t border-border bg-surface px-4 py-3",style:{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom))"},children:l})]}),document.body):null}let aa=["default","acceptEdits","plan","dontAsk","bypassPermissions"],ar=["read-only","workspace-write","danger-full-access"],as=["allow-all-tools","yolo"],al=["--dangerously-skip-permissions"],ai=[],ao=[],ac=[],ad=[],au={claude:"acceptEdits",codex:"workspace-write",gemini:"","vibe-local":"",opencode:"",copilot:"allow-all-tools",antigravity:"--dangerously-skip-permissions"};function am(e){switch(e){case"claude":return aa;case"codex":return ar;case"copilot":return as;case"antigravity":return al;case"gemini":return ai;case"vibe-local":return ao;case"opencode":return ac;default:return ad}}let ah=/^[\w\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\uF900-\uFAFF\s-]{1,100}$/,ax=/^[a-zA-Z0-9][a-zA-Z0-9\-._/:]*$/,af=new Set(["copilot","opencode"]),ap=[{value:"0 */1 * * *",labelKey:"cronPresetHourly"},{value:"0 9 * * *",labelKey:"cronPresetDaily9"},{value:"0 9 * * 1",labelKey:"cronPresetWeeklyMon9"}],ag={name:"",cronExpression:"0 9 * * *",message:"",cliToolId:"claude",enabled:!0,permission:null!=(a=au.claude)?a:"",model:""},ab="w-full px-3 py-2 text-sm border border-input rounded-md bg-surface dark:bg-surface-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring",av="block text-xs font-semibold text-foreground mb-1",ay="mt-1 text-xs text-danger-foreground";function aj(e){let{onClick:t,label:n,title:a,testId:s}=e;return(0,r.jsxs)("button",{type:"button","data-testid":s,onClick:t,title:a,className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-info-border text-info-foreground hover:bg-info-subtle transition-colors",children:[(0,r.jsx)(n9.A,{size:14,"aria-hidden":"true"}),n]})}function aw(e){let{id:t,title:n,summary:a,icon:s,isOpen:l,onToggle:i,children:o}=e,c="schedule-section-".concat(t,"-content");return(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,r.jsxs)("button",{type:"button","data-testid":"schedule-section-".concat(t),"aria-expanded":l,"aria-controls":c,onClick:()=>i(t),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left bg-surface-2 hover:bg-muted transition-colors",children:[(0,r.jsx)("span",{className:"flex-shrink-0 text-accent-600 dark:text-accent-400",children:s}),(0,r.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"block text-sm font-semibold text-foreground",children:n}),a&&(0,r.jsx)("span",{"data-testid":"schedule-section-".concat(t,"-summary"),className:"block truncate text-xs text-muted-foreground",children:a})]}),(0,r.jsx)(tn.A,{className:"flex-shrink-0 w-4 h-4 text-muted-foreground transition-transform ".concat(l?"rotate-180":"")})]}),l&&(0,r.jsx)("div",{id:c,className:"px-3 py-3 flex flex-col gap-4",children:o})]})}function ak(e){var t,n;let{isOpen:a,worktreeId:s,initialValues:l,originalName:o,onInsertToMessage:d,instances:u,onClose:h,onSaved:x}=e,f=(0,c.c)("schedule"),p=(0,X.a)(),g=(0,i.useMemo)(()=>u&&u.length>0?u:(0,tt.lu)([...tt.XH]),[u]),[b,v]=(0,i.useState)(ag),[y,j]=(0,i.useState)(""),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(null),[T,E]=(0,i.useState)(()=>new Set(["basic","advanced","message"]));(0,i.useEffect)(()=>{var e,t,n,r,s,i,o,c,d,u;if(!a)return;S(null),N(!1);let m=null!=(t=null==l?void 0:l.cliToolId)?t:ag.cliToolId;v({name:null!=(n=null==l?void 0:l.name)?n:ag.name,cronExpression:null!=(r=null==l?void 0:l.cronExpression)?r:ag.cronExpression,message:null!=(s=null==l?void 0:l.message)?s:ag.message,cliToolId:m,enabled:null!=(i=null==l?void 0:l.enabled)?i:ag.enabled,permission:null!=(o=null==l?void 0:l.permission)?o:ag.permission,model:null!=(c=null==l?void 0:l.model)?c:ag.model});let h=g.find(e=>e.cliTool===m);j(null!=(u=null!=(d=null==h?void 0:h.id)?d:null==(e=g[0])?void 0:e.id)?u:m)},[a,l,g]),(0,i.useEffect)(()=>{a&&E(new Set(p?["basic"]:["basic","advanced","message"]))},[a,p]);let I=(0,i.useCallback)(e=>{E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),M=am(b.cliToolId),A=M.length>0,L="copilot"===b.cliToolId,R=!!o,P=(0,i.useMemo)(()=>{let e=b.name.trim();return e?e.length>100?f("edit.errorNameTooLong",{max:100}):ah.test(e)?null:f("edit.errorNameInvalid"):f("edit.errorNameRequired")},[b.name,f]),D=(0,i.useMemo)(()=>!function(e){if(e.length>100)return!1;let t=e.trim().split(/\s+/);return t.length>=5&&t.length<=6}(b.cronExpression.trim())?f("edit.errorCronInvalid"):null,[b.cronExpression,f]),F=(0,i.useMemo)(()=>b.message.trim()?b.message.length>1e4?f("edit.errorMessageTooLong",{max:1e4}):null:f("edit.errorMessageRequired"),[b.message,f]),O=(0,i.useMemo)(()=>{var e;return L&&b.model.trim()?(e=b.model.trim(),/[\x00-\x1f\x7f]/.test(e)?{valid:!1,reason:"Model name contains control characters"}:""===e.trim()?{valid:!1,reason:"Model name must not be empty"}:!ax.test(e)?{valid:!1,reason:"Model name contains invalid characters"}:e.length>128?{valid:!1,reason:"Model name exceeds ".concat(128," characters")}:{valid:!0}).valid?null:f("edit.errorModelInvalid"):null},[L,b.model,f]),z=!P&&!D&&!F&&!O,_=(0,i.useCallback)(e=>{v(t=>({...t,cliToolId:e,permission:function(e){let t=au[e];if(void 0!==t)return t;let n=am(e);return n.length>0?n[0]:""}(e),model:"copilot"===e?t.model:""}))},[]),B=(0,i.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&(j(e),_(t.cliTool))},[g,_]),V=ap.some(e=>e.value===b.cronExpression)?b.cronExpression:"custom",W=(0,i.useCallback)(e=>{"custom"!==e&&v(t=>({...t,cronExpression:e}))},[]),H=(0,i.useCallback)(e=>{null==d||d(e),h()},[d,h]),U=(0,i.useCallback)(async()=>{if(z&&!k){N(!0),S(null);try{let e=await fetch("/api/worktrees/".concat(s,"/cmate/schedules"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name.trim(),cronExpression:b.cronExpression.trim(),message:b.message.trim(),cliToolId:b.cliToolId,enabled:b.enabled,permission:A?b.permission:"",model:L&&b.model.trim()?b.model.trim():void 0,originalName:null!=o?o:void 0})});if(!e.ok){let t=await e.json().catch(()=>({}));S(t.error||f("edit.saveError"));return}x(),h()}catch(e){S(f("edit.saveError"))}finally{N(!1)}}},[z,k,s,b,A,L,o,x,h,f]),K=null!=(n=null==(t=g.find(e=>e.id===y))?void 0:t.alias)?n:(0,tt.f_)(b.cliToolId),$=b.name.trim()?"".concat(b.name.trim()," \xb7 ").concat(b.cronExpression):b.cronExpression,q=[K,A?b.permission:null,L&&b.model.trim()?b.model.trim():null].filter(Boolean).join(" \xb7 "),G=b.message.trim(),J=G.length>32?"".concat(G.slice(0,32),"…"):G,Y=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:av,htmlFor:"schedule-name-input",children:f("edit.name")}),(0,r.jsx)("input",{id:"schedule-name-input","data-testid":"schedule-name-input",type:"text",value:b.name,maxLength:100,placeholder:f("edit.namePlaceholder"),onChange:e=>v(t=>({...t,name:e.target.value})),className:ab}),P&&(0,r.jsx)("p",{className:ay,"data-testid":"schedule-name-error",children:P})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground",htmlFor:"schedule-cron-input",children:f("edit.cron")}),d&&(0,r.jsx)(aj,{testId:"schedule-cron-ask-ai",label:f("edit.askAiCron"),title:f("edit.askAiHint"),onClick:()=>H(function(e,t){let n=t.trim();return 0===n.length?e("edit.aiPrompts.cron"):e("edit.aiPrompts.cronRefine",{current:"`"+n+"`"})}(f,b.cronExpression))})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)("input",{id:"schedule-cron-input","data-testid":"schedule-cron-input",type:"text",value:b.cronExpression,placeholder:f("edit.cronPlaceholder"),onChange:e=>v(t=>({...t,cronExpression:e.target.value})),className:"".concat(ab," font-mono sm:flex-1")}),(0,r.jsxs)("select",{"data-testid":"schedule-cron-preset","aria-label":f("edit.cronPreset"),value:V,onChange:e=>W(e.target.value),className:"".concat(ab," sm:w-48"),children:[ap.map(e=>(0,r.jsx)("option",{value:e.value,children:f("edit.".concat(e.labelKey))},e.value)),(0,r.jsx)("option",{value:"custom",children:f("edit.cronPresetCustom")})]})]}),D&&(0,r.jsx)("p",{className:ay,"data-testid":"schedule-cron-error",children:D})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)(m.Sc,{"data-testid":"schedule-enabled-toggle",checked:b.enabled,onCheckedChange:e=>v(t=>({...t,enabled:!0===e}))}),(0,r.jsx)("span",{className:"text-sm text-foreground",children:f("edit.enabledLabel")})]})]}),Q=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:av,htmlFor:"schedule-cli-tool-select",children:f("edit.cliTool")}),(0,r.jsx)("select",{id:"schedule-cli-tool-select","data-testid":"schedule-cli-tool-select",value:y,onChange:e=>B(e.target.value),className:ab,children:g.map(e=>(0,r.jsx)("option",{value:e.id,children:e.alias},e.id))})]}),L&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:av,htmlFor:"schedule-model-input",children:f("edit.model")}),(0,r.jsx)("input",{id:"schedule-model-input","data-testid":"schedule-model-input",type:"text",value:b.model,placeholder:f("edit.modelPlaceholder"),onChange:e=>v(t=>({...t,model:e.target.value})),className:ab}),O&&(0,r.jsx)("p",{className:ay,"data-testid":"schedule-model-error",children:O})]}),A&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:av,htmlFor:"schedule-permission-select",children:f("edit.permission")}),(0,r.jsx)("select",{id:"schedule-permission-select","data-testid":"schedule-permission-select",value:b.permission,onChange:e=>v(t=>({...t,permission:e.target.value})),className:ab,children:M.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),Z=(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground",htmlFor:"schedule-message-input",children:f("edit.message")}),d&&(0,r.jsx)(aj,{testId:"schedule-message-ask-ai",label:f("edit.askAiMessage"),title:f("edit.askAiHint"),onClick:()=>H(function(e,t){let n=t.trim();return 0===n.length?e("edit.aiPrompts.messageDraft"):e("edit.aiPrompts.messageDraftNamed",{name:"`"+n+"`"})}(f,b.name))})]}),(0,r.jsx)("textarea",{id:"schedule-message-input","data-testid":"schedule-message-input",value:b.message,rows:4,maxLength:1e4,placeholder:f("edit.messagePlaceholder"),onChange:e=>v(t=>({...t,message:e.target.value})),className:"".concat(ab," resize-none")}),(0,r.jsxs)("div",{className:"mt-1 flex items-center justify-between",children:[F?(0,r.jsx)("p",{className:ay,"data-testid":"schedule-message-error",children:F}):(0,r.jsx)("span",{}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"schedule-message-count",children:f("edit.charCount",{count:b.message.length,max:1e4})})]})]}),ee=(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)(aw,{id:"basic",title:f("edit.sectionBasic"),summary:$,icon:(0,r.jsx)(w.A,{className:"w-4 h-4"}),isOpen:T.has("basic"),onToggle:I,children:Y}),(0,r.jsx)(aw,{id:"advanced",title:f("edit.sectionAdvanced"),summary:q,icon:(0,r.jsx)(n7.A,{className:"w-4 h-4"}),isOpen:T.has("advanced"),onToggle:I,children:Q}),(0,r.jsx)(aw,{id:"message",title:f("edit.sectionMessage"),summary:J,icon:(0,r.jsx)(ae.A,{className:"w-4 h-4"}),isOpen:T.has("message"),onToggle:I,children:Z}),C&&(0,r.jsx)("div",{className:"text-xs p-2 rounded bg-danger-subtle text-danger-foreground","data-testid":"schedule-submit-error",children:C})]}),et=(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:h,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:f("edit.cancel")}),(0,r.jsx)("button",{type:"button","data-testid":"schedule-save-button",onClick:()=>void U(),disabled:!z||k,className:"px-4 py-2 text-sm font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-md transition-colors",children:f("edit.save")})]}),en=R?f("edit.titleEdit"):f("edit.titleCreate");return p?(0,r.jsx)(an,{isOpen:a,onClose:h,title:en,footer:et,children:ee}):(0,r.jsx)(e7.a,{isOpen:a,onClose:h,title:en,size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[ee,(0,r.jsx)("div",{className:"pt-2 border-t border-border",children:et})]})})}function aN(e){return new Date(e).toLocaleString()}function aC(e,t){if(null===t)return null;let n=t-e;if(n<0)return null;let a=Math.floor(n/1e3),r=Math.floor(a/60),s=a%60;return r>0?"".concat(r,"m ").concat(s,"s"):"".concat(s,"s")}let aS=(0,i.memo)(function(e){let{worktreeId:t,logs:n}=e,a=(0,c.c)("schedule"),[s,l]=(0,i.useState)(null),[o,d]=(0,i.useState)(null),u=(0,i.useCallback)(async e=>{if(s===e){l(null),d(null);return}try{let n=await fetch("/api/worktrees/".concat(t,"/execution-logs/").concat(e));if(n.ok){let t=await n.json();d(t.log),l(e)}}catch(e){console.error("Failed to fetch log detail:",e)}},[t,s]);return 0===n.length?(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:a("noLogs")}):(0,r.jsx)("div",{className:"space-y-2","data-testid":"execution-logs-view",children:n.map(e=>(0,r.jsxs)("div",{className:"border border-border rounded bg-surface",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>void u(e.id),className:"w-full text-left p-3 hover:bg-muted transition-colors",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-sm truncate max-w-[60%]",children:e.schedule_name||a("unknownSchedule")}),(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded ".concat(function(e){switch(e){case"completed":return"text-success-foreground bg-success-subtle";case"failed":return"text-danger-foreground bg-danger-subtle";case"timeout":return"text-warning-foreground bg-warning-subtle";case"running":return"text-accent-600 dark:text-accent-400 bg-accent-50 dark:bg-accent-900/30";case"cancelled":return"text-muted-foreground bg-muted"}}(e.status)),children:a("status.".concat(e.status))})]}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[aN(e.started_at),aC(e.started_at,e.completed_at)&&(0,r.jsxs)("span",{className:"ml-2",children:["(",aC(e.started_at,e.completed_at),")"]}),null!==e.exit_code&&(0,r.jsxs)("span",{className:"ml-2",children:[a("exitCode"),": ",e.exit_code]})]})]}),s===e.id&&o&&(0,r.jsxs)("div",{className:"border-t border-border p-3 bg-muted space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:a("message")}),(0,r.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-foreground",children:o.message})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:a("response")}),(0,r.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-foreground max-h-60 overflow-y-auto",children:o.result||a("noOutput")})]})]})]},e.id))})});function aT(){return(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,r.jsx)("path",{d:"M13.586 3.586a2 2 0 112.828 2.828l-8.5 8.5a1 1 0 01-.43.26l-3 .857a.5.5 0 01-.617-.618l.857-3a1 1 0 01.26-.43l8.5-8.5z"})})}function aE(){return(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M8 2a1 1 0 00-.894.553L6.382 4H3a1 1 0 000 2h.293l.668 9.357A2 2 0 005.956 17h8.088a2 2 0 001.995-1.643L16.707 6H17a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0012 2H8zm1 5a1 1 0 012 0v6a1 1 0 11-2 0V7zm-3 0a1 1 0 011 1v5a1 1 0 11-2 0V8a1 1 0 011-1z",clipRule:"evenodd"})})}let aI=(0,i.memo)(function(e){let{worktreeId:t,className:n="",onInsertToMessage:a,instances:s}=e,l=(0,c.c)("schedule"),o=(0,ec.SC)(),[d,u]=(0,i.useState)([]),[h,x]=(0,i.useState)([]),[f,p]=(0,i.useState)([]),[g,b]=(0,i.useState)(!0),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)("schedules"),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(!1),[T,E]=(0,i.useState)(void 0),[I,M]=(0,i.useState)(void 0),A=(0,i.useCallback)(async()=>{b(!0),y(null);try{let[e,n,a]=await Promise.all([fetch("/api/worktrees/".concat(t,"/execution-logs")),fetch("/api/worktrees/".concat(t,"/schedules")),fetch("/api/worktrees/".concat(t,"/schedules/active"))]);if(e.ok){let t=await e.json();u(t.logs||[])}if(n.ok){let e=await n.json();x(e.schedules||[])}if(a.ok){let e=await a.json();p(e.schedules||[])}else p([])}catch(e){y(e instanceof Error?e.message:"Failed to fetch data")}finally{b(!1)}},[t]);(0,i.useEffect)(()=>{A()},[A]);let L=(0,i.useCallback)(async e=>{try{var n,a,r,s,l,i,o;let c=await fetch("/api/worktrees/".concat(t,"/files/CMATE.md"));if(!c.ok)return null;let d=await c.json(),u="string"==typeof d.content?d.content:"",m=(null!=(n=(function(e){let t=new Map,n=e.split("\n"),a=null,r=!1,s=!1;for(let e of n){let n=e.trim(),l=n.match(/^##\s+(.+)$/);if(l){a=l[1].trim(),r=!1,s=!1,t.has(a)||t.set(a,[]);continue}if(!n||!n.startsWith("|")||!a)continue;if(!r){r=!0;continue}if(!s){if(n.match(/^\|[\s-:|]+\|$/)){s=!0;continue}s=!0}let i=n.split("|").slice(1,-1).map(e=>e.trim());i.length>0&&t.get(a).push(i)}return t})(u).get("Schedules"))?n:[]).find(t=>{var n;return(null!=(n=t[0])?n:"").trim()===e});if(!m)return null;let h=function(e){let t=e.trim();if(!t)return{cliToolId:"claude",model:void 0};let n=t.split(/\s+/),a=n[0];return 1===n.length?{cliToolId:a,model:void 0}:af.has(a)?3===n.length&&"--model"===n[1]?{cliToolId:a,model:n[2]}:{cliToolId:a,error:"".concat(a," only supports: ").concat(a," --model <modelName>")}:{cliToolId:a,error:'CLI Tool "'.concat(a,'" does not support additional options')}}(null!=(a=m[3])?a:"claude"),x=(null!=(r=m[4])?r:"true").trim().toLowerCase();return{name:e,cronExpression:(null!=(s=m[1])?s:"").trim(),message:(null!=(l=m[2])?l:"").trim(),cliToolId:h.cliToolId||"claude",enabled:""===x||"true"===x,permission:(null!=(i=m[5])?i:"").trim(),model:null!=(o=h.model)?o:""}}catch(e){return null}},[t]),R=(0,i.useCallback)(()=>{M(void 0),E(void 0),S(!0)},[]),P=(0,i.useCallback)(async e=>{let t=await L(e.name);M(e.name),E(null!=t?t:{name:e.name,cronExpression:e.cron_expression,message:e.message,cliToolId:e.cli_tool_id,enabled:1===e.enabled,permission:"",model:""}),S(!0)},[L]),D=(0,i.useCallback)(async e=>{if(await o({description:l("edit.confirmDelete",{name:e}),variant:"danger"}))try{(await fetch("/api/worktrees/".concat(t,"/cmate/schedules"),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})})).ok&&await A()}catch(e){console.error("Failed to delete schedule:",e)}},[t,l,A,o]),F=(0,i.useCallback)(async e=>{try{(await fetch("/api/worktrees/".concat(t,"/cmate/schedules"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,enabled:1!==e.enabled})})).ok&&await A()}catch(e){console.error("Failed to toggle schedule:",e)}},[t,A]);return g?(0,r.jsx)("div",{className:"flex items-center justify-center h-full p-4 ".concat(n),children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)(m.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:l("loading")})]})}):v?(0,r.jsx)("div",{className:"flex items-center justify-center h-full p-4 ".concat(n),children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("span",{className:"text-sm text-danger-foreground",children:v}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:()=>void A(),className:"ml-2 px-3 py-1 text-sm text-white bg-accent-500 rounded hover:bg-accent-600",children:l("retry")})]})}):(0,r.jsxs)("div",{className:"flex flex-col h-full ".concat(n),children:[(0,r.jsxs)("div",{className:"flex shrink-0 border-b border-border px-4 pt-3",children:[(0,r.jsxs)("button",{type:"button","data-testid":"schedule-tab-schedules",role:"tab","aria-selected":"schedules"===j,onClick:()=>w("schedules"),className:"-mb-px px-3 py-2 text-sm font-medium border-b-2 transition-colors ".concat("schedules"===j?"border-accent-500 text-accent-700 dark:text-accent-300":"border-transparent text-muted-foreground hover:text-foreground"),children:[l("tabs.schedules")," (",h.length,")"]}),(0,r.jsxs)("button",{type:"button","data-testid":"schedule-tab-logs",role:"tab","aria-selected":"logs"===j,onClick:()=>w("logs"),className:"-mb-px px-3 py-2 text-sm font-medium border-b-2 transition-colors ".concat("logs"===j?"border-accent-500 text-accent-700 dark:text-accent-300":"border-transparent text-muted-foreground hover:text-foreground"),children:[l("tabs.logs")," (",d.length,")"]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:"schedules"===j?(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"rounded border border-accent-100 bg-accent-50/60 p-3 dark:border-accent-900/40 dark:bg-accent-950/20",children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.jsxs)("span",{className:"text-sm font-semibold text-accent-900 dark:text-accent-200",children:[l("activeSchedulesTitle")," (",f.length,")"]}),(0,r.jsx)("span",{className:"text-xs text-accent-700 dark:text-accent-300",children:l("activeSchedulesDescription")})]}),0===f.length?(0,r.jsx)("p",{className:"text-xs text-accent-800 dark:text-accent-300",children:l("noActiveSchedules")}):(0,r.jsx)("div",{className:"space-y-2",children:f.map(e=>(0,r.jsxs)("div",{className:"rounded border border-accent-200/80 bg-white/80 p-3 dark:border-accent-900/40 dark:bg-surface/60",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"font-medium text-sm text-foreground",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded ".concat(e.isCronActive?"bg-success-subtle text-success-foreground":"bg-danger-subtle text-danger-foreground"),children:e.isCronActive?l("activeState.active"):l("activeState.inactive")}),e.isExecuting&&(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-accent-100 text-accent-700 dark:bg-accent-900/30 dark:text-accent-300",children:l("activeState.executing")})]})]}),(0,r.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{children:[l("cron"),": ",e.cronExpression||"N/A"]}),(0,r.jsxs)("span",{className:"ml-3",children:[l("agentLabel"),": ",e.cliToolId]}),e.model&&(0,r.jsxs)("span",{className:"ml-3",children:["model: ",e.model]}),e.nextRunAt&&(0,r.jsxs)("span",{className:"ml-3",children:[l("nextRun"),": ",aN(e.nextRunAt)]})]})]},e.scheduleId))})]}),0===h.length?(0,r.jsxs)("div",{className:"flex flex-col items-center text-center py-8 px-4",children:[(0,r.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-accent-50 text-accent-600 dark:bg-accent-900/30 dark:text-accent-300",children:(0,r.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",className:"w-7 h-7",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 7.5V12l3 2"})]})}),(0,r.jsx)("p",{className:"font-semibold text-foreground mb-1",children:l("emptyState.title")}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mb-5 max-w-xs",children:l("emptyState.description")}),(0,r.jsxs)(m.$n,{variant:"ghost",type:"button","data-testid":"schedule-empty-cta",onClick:R,className:"inline-flex items-center gap-1.5 px-5 py-2.5 text-sm font-semibold text-white bg-accent-600 hover:bg-accent-700 rounded-lg shadow-sm transition-colors",children:[(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,r.jsx)("path",{d:"M10 4a1 1 0 011 1v4h4a1 1 0 110 2h-4v4a1 1 0 11-2 0v-4H5a1 1 0 110-2h4V5a1 1 0 011-1z"})}),l("emptyState.createButton")]}),(0,r.jsx)("button",{type:"button","data-testid":"schedule-manual-toggle","aria-expanded":k,onClick:()=>N(e=>!e),className:"mt-5 text-xs text-accent-700 dark:text-accent-300 hover:underline",children:l("emptyState.manualToggle")}),k&&(0,r.jsxs)("ol",{"data-testid":"schedule-manual-steps",className:"mt-3 text-xs text-left inline-block space-y-1.5 list-decimal list-inside text-muted-foreground",children:[(0,r.jsx)("li",{children:l("noSchedulesStep1")}),(0,r.jsx)("li",{children:l("noSchedulesStep2")}),(0,r.jsx)("li",{children:l("noSchedulesStep3")}),(0,r.jsx)("li",{children:l("noSchedulesStep4")})]})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-2 flex items-center justify-end",children:(0,r.jsxs)(m.$n,{variant:"ghost",type:"button","data-testid":"schedule-new-button",onClick:R,className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-white bg-accent-600 hover:bg-accent-700 rounded transition-colors whitespace-nowrap",children:[(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-3.5 h-3.5",children:(0,r.jsx)("path",{d:"M10 4a1 1 0 011 1v4h4a1 1 0 110 2h-4v4a1 1 0 11-2 0v-4H5a1 1 0 110-2h4V5a1 1 0 011-1z"})}),l("edit.newSchedule")]})}),(0,r.jsx)("div",{className:"space-y-2",children:h.map(e=>{let t=1===e.enabled;return(0,r.jsxs)("div",{className:"border border-border rounded p-3 bg-white dark:bg-surface",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"font-medium text-sm truncate",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":t,"aria-label":t?l("edit.disable"):l("edit.enable"),title:t?l("edit.disable"):l("edit.enable"),"data-testid":"schedule-toggle-".concat(e.name),onClick:()=>void F(e),className:"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors ".concat(t?"bg-success":"bg-input"),children:(0,r.jsx)("span",{className:"inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform ".concat(t?"translate-x-4":"translate-x-0.5")})}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button","data-testid":"schedule-edit-".concat(e.name),"aria-label":l("edit.edit"),title:l("edit.edit"),onClick:()=>void P(e),className:"p-1.5 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/20 rounded transition-colors",children:(0,r.jsx)(aT,{})}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button","data-testid":"schedule-delete-".concat(e.name),"aria-label":l("edit.delete"),title:l("edit.delete"),onClick:()=>void D(e.name),className:"p-1.5 text-muted-foreground hover:text-danger-foreground hover:bg-danger-subtle rounded transition-colors",children:(0,r.jsx)(aE,{})})]})]}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[(0,r.jsxs)("span",{children:[l("cron"),": ",e.cron_expression||"N/A"]}),e.last_executed_at&&(0,r.jsxs)("span",{className:"ml-3",children:[l("lastRun"),": ",aN(e.last_executed_at)]})]})]},e.id)})})]})]}):(0,r.jsx)(aS,{worktreeId:t,logs:d})}),(0,r.jsx)(ak,{isOpen:C,worktreeId:t,initialValues:T,originalName:I,onInsertToMessage:a,instances:s,onClose:()=>S(!1),onSaved:()=>{A()}})]})}),aM=(0,i.memo)(function(e){let{worktreeId:t,vibeLocalModel:n,onVibeLocalModelChange:a,vibeLocalContextWindow:s,onVibeLocalContextWindowChange:l}=e,o=(0,c.c)("schedule"),[d,m]=(0,i.useState)([]),[h,x]=(0,i.useState)(null),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(null!=s?String(s):""),[j,w]=(0,i.useState)(!1);(0,i.useEffect)(()=>{y(null!=s?String(s):"")},[s]),(0,i.useEffect)(()=>{let e=!1;return p(!0),fetch("/api/ollama/models").then(e=>e.json()).then(t=>{e||(m(t.models),x(0===t.models.length&&t.error?t.error:null))}).catch(()=>{e||(m([]),x("Failed to fetch models"))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[]);let k=(0,i.useCallback)(async e=>{let n=e.target.value,r=""===n?null:n;b(!0);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({vibeLocalModel:r})})).ok&&a(r)}catch(e){}finally{b(!1)}},[t,a]),N=(0,i.useCallback)(e=>{y(e.target.value)},[]),C=(0,i.useCallback)(async()=>{let e=v.trim(),n=parseInt(e,10),a=""===e||Number.isNaN(n)?null:n,r=null!=s?s:null;if(a!==r){w(!0);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({vibeLocalContextWindow:a})})).ok?null==l||l(a):y(null!=r?String(r):"")}catch(e){y(null!=r?String(r):"")}finally{w(!1)}}},[v,s,t,l]);return(0,r.jsxs)("div",{className:"mt-4 pt-4 border-t border-border",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-2",children:o("vibeLocalModel")}),f?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(u.y,{size:"xs",variant:"muted"}),o("loading")]}):h&&0===d.length?(0,r.jsx)("p",{className:"text-xs text-warning-foreground",children:o("ollamaNotAvailable")}):(0,r.jsxs)("select",{"data-testid":"vibe-local-model-select",value:null!=n?n:"",onChange:k,disabled:g,className:"w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50",children:[(0,r.jsx)("option",{value:"",children:o("vibeLocalModelDefault")}),d.map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name,e.parameterSize?" (".concat(e.parameterSize,")"):""]},e.name))]}),(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-2",children:o("vibeLocalContextWindow")}),(0,r.jsx)("input",{type:"number","data-testid":"vibe-local-context-window-input",step:"1",min:tt.vz,max:tt.NL,value:v,onChange:N,onBlur:C,placeholder:o("vibeLocalContextWindowDefault"),disabled:j,className:"w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50"})]})]})}),aA=(0,i.memo)(function(e){let{worktreeId:t,selectedAgents:n,onSelectedAgentsChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d,maxAgents:u=2,availableAgents:h=tt.XH,persistToServer:x=!0}=e,f=(0,c.c)("schedule"),p=n.length>u?n.slice(0,u):n,[g,b]=(0,i.useState)(()=>new Set(p)),[v,y]=(0,i.useState)(!1),[j,w]=(0,i.useState)(!1),k=(0,i.useRef)(g);k.current=g,(0,i.useEffect)(()=>{j||b(new Set(p))},[n,j,u]);let N=g.has("vibe-local"),C=(0,i.useCallback)(async(e,n)=>{let r=new Set(k.current);if(n?r.add(e):(r.delete(e),w(!0)),b(r),r.size>=2){let e=Array.from(r);if(!x){b(new Set(e)),a(e),w(!1);return}y(!0);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({selectedAgents:e})})).ok?(b(new Set(e)),a(e)):b(new Set(p))}catch(e){b(new Set(p))}finally{y(!1),w(!1)}}},[t,p,a,x]),S=g.size>=u;return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:f("agentSettings")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:f("selectAgents")}),(0,r.jsx)("div",{className:"space-y-3",children:h.map(e=>{let t=g.has(e),n=!t&&S;return(0,r.jsxs)("label",{className:"flex items-center gap-3 p-2 rounded-lg border transition-colors ".concat(t?"border-accent-200 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30":n?"border-border bg-muted opacity-50":"border-border hover:border-input hover:bg-muted"),children:[(0,r.jsx)(m.Sc,{"data-testid":"agent-checkbox-".concat(e),"aria-label":(0,tt.oo)(e),checked:t,disabled:n||v,onCheckedChange:t=>C(e,!0===t)}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:(0,tt.oo)(e)})]},e)})}),v&&(0,r.jsxs)("div",{"data-testid":"agent-settings-loading",className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(m.y$,{size:"xs",variant:"muted"}),f("loading")]}),N&&(0,r.jsx)(aM,{worktreeId:t,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d})]})});function aL(e){return"".concat("commandmate:worktree:mobileInstances:").concat(e)}function aR(e,t){if(0===t.length)return[];if(null!==e){let n=new Set(e),a=t.filter(e=>n.has(e.id));if(a.length>0)return a}return[...t]}var aP=n(49476),aD=n(20017),aF=n(6191);let aO=(0,i.memo)(function(e){let{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d,modelByInstance:m}=e,h=(0,c.c)("schedule"),x=(0,c.c)("common"),f=(0,c.c)("worktree"),p=(0,ec.SC)(),[g,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)({}),[k,N]=(0,i.useState)(tt.XH[0]),[C,S]=(0,i.useState)(null),T=n.length>=tt.Ab,E=n.length<=1,I=n.some(e=>"vibe-local"===e.cliTool),M=(0,i.useCallback)(async e=>{let n=e.map((e,t)=>({...e,order:t}));b(!0),y(null);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentInstances:n})})).ok?a(n):y(h("agentInstanceSaveError"))}catch(e){y(h("agentInstanceSaveError"))}finally{b(!1)}},[t,a,h]),A=(0,i.useCallback)(()=>{if(n.length>=tt.Ab)return;let e=function(e,t){let n=new Set(t.map(e=>e.id));if(!n.has(e))return e;let a=2;for(;n.has("".concat(e,"-").concat(a));)a++;return"".concat(e,"-").concat(a)}(k,n);M([...n,{id:e,cliTool:k,alias:function(e,t){let n=(0,tt.oo)(e);if(t===e)return n;let a=t.slice(e.length+1);return a?"".concat(n," ").concat(a):n}(k,e),order:n.length}])},[k,n,M]),L=(0,i.useCallback)(async e=>{var t;if(n.length<=1)return;let a=n.find(t=>t.id===e);await p({description:x("confirmDelete",{name:null!=(t=null==a?void 0:a.alias)?t:""}),variant:"danger"})&&M(n.filter(t=>t.id!==e))},[n,M,p,x]),R=(0,i.useCallback)((e,t)=>{let a=e+t;if(a<0||a>=n.length)return;let r=[...n];[r[e],r[a]]=[r[a],r[e]],M(r)},[n,M]),P=(0,i.useCallback)((e,t)=>{w(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n});let a=n.find(t=>t.id===e);a&&t!==a.alias&&M(n.map(n=>n.id===e?{...n,alias:t}:n))},[n,M]),D=(0,i.useCallback)((e,t)=>{if(e===t||e<0||t<0||e>=n.length||t>=n.length)return;let a=[...n],[r]=a.splice(e,1);a.splice(t,0,r),M(a)},[n,M]);return(0,r.jsxs)("div",{className:"p-4","data-testid":"agent-instances-pane",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:h("agentInstances")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:h("agentInstancesDescription")}),(0,r.jsx)("div",{className:"space-y-2",children:n.map((e,t)=>{var a;let s=e.id in j?j[e.id]:e.alias,l=C===t,i=null!=(a=null==m?void 0:m[e.id])?a:null;return(0,r.jsxs)("div",{"data-testid":"agent-instance-row-".concat(e.id),draggable:!0,onDragStart:()=>S(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{null!==C&&D(C,t),S(null)},onDragEnd:()=>S(null),className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-surface transition-colors hover:border-accent-300 dark:hover:border-accent-700 focus-within:border-accent-500 ".concat(l?"opacity-50":""),children:[(0,r.jsx)("span",{className:"cursor-grab text-muted-foreground shrink-0","aria-hidden":"true",children:(0,r.jsx)(aP.A,{className:"w-4 h-4"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("input",{type:"text","data-testid":"agent-instance-alias-".concat(e.id),"aria-label":h("agentInstanceAliasLabel"),value:s,maxLength:tt.pQ,disabled:g,placeholder:h("agentInstanceAliasPlaceholder"),onChange:t=>w(n=>({...n,[e.id]:t.target.value})),onBlur:t=>P(e.id,t.target.value),onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()},className:"w-full text-sm font-medium border border-input rounded-md px-2 py-1 bg-surface dark:bg-surface-2 text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50"}),(0,r.jsx)(nT.nR,{content:(0,tt.oo)(e.cliTool),className:"mt-0.5 block truncate text-xs text-muted-foreground"}),i&&(0,r.jsx)("span",{"data-testid":"agent-instance-model-".concat(e.id),title:f("agentModel.modelLabel",{model:i}),className:"mt-0.5 block truncate text-xs text-muted-foreground",children:i})]}),(0,r.jsxs)(eG.rI,{children:[(0,r.jsx)(eG.ty,{asChild:!0,children:(0,r.jsx)("button",{type:"button","data-testid":"agent-instance-menu-".concat(e.id),"aria-label":h("agentInstanceActions"),title:h("agentInstanceActions"),disabled:g,className:"shrink-0 p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted disabled:opacity-30 disabled:cursor-not-allowed",children:(0,r.jsx)(aD.A,{className:"w-4 h-4"})})}),(0,r.jsxs)(eG.SQ,{align:"end",children:[(0,r.jsxs)(eG._2,{"data-testid":"agent-instance-move-up-".concat(e.id),disabled:0===t,onSelect:()=>R(t,-1),children:[(0,r.jsx)(nQ.A,{className:"w-4 h-4"}),h("agentInstanceMoveUp")]}),(0,r.jsxs)(eG._2,{"data-testid":"agent-instance-move-down-".concat(e.id),disabled:t===n.length-1,onSelect:()=>R(t,1),children:[(0,r.jsx)(tn.A,{className:"w-4 h-4"}),h("agentInstanceMoveDown")]}),(0,r.jsx)(eG.mB,{}),(0,r.jsxs)(eG._2,{"data-testid":"agent-instance-delete-".concat(e.id),disabled:E,onSelect:()=>{L(e.id)},className:"text-danger-foreground focus:text-danger-foreground",children:[(0,r.jsx)(nk.A,{className:"w-4 h-4"}),h("agentInstanceDelete")]})]})]})]},e.id)})}),(0,r.jsxs)("div",{className:"mt-4 flex items-center gap-2",children:[(0,r.jsx)("select",{"data-testid":"agent-instance-add-tool","aria-label":h("agentInstanceBaseTool"),value:k,disabled:g||T,onChange:e=>N(e.target.value),className:"flex-1 min-w-0 text-sm border border-input rounded-md px-2 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50",children:tt.XH.map(e=>(0,r.jsx)("option",{value:e,children:(0,tt.oo)(e)},e))}),(0,r.jsxs)("button",{type:"button","data-testid":"agent-instance-add",disabled:g||T,onClick:A,className:"flex items-center gap-1 text-sm font-medium px-3 py-2 rounded-md border border-accent-200 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 hover:bg-accent-100 dark:hover:bg-accent-900/50 disabled:opacity-40 disabled:cursor-not-allowed shrink-0",children:[(0,r.jsx)(aF.A,{className:"w-4 h-4"}),h("agentInstanceAdd")]})]}),T&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:h("agentInstanceMax",{max:tt.Ab})}),E&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:h("agentInstanceMin",{min:1})}),g&&(0,r.jsxs)("div",{"data-testid":"agent-instances-loading",className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(u.y,{size:"xs",variant:"muted"}),h("loading")]}),v&&(0,r.jsx)("p",{"data-testid":"agent-instances-error",className:"mt-3 text-xs text-danger-foreground",children:v}),I&&(0,r.jsx)(aM,{worktreeId:t,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d})]})}),az=(0,i.memo)(function(e){let{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:i,onVibeLocalContextWindowChange:o,visibleInstanceIds:d,onToggleInstanceVisible:u,modelByInstance:h}=e,x=(0,c.c)("schedule"),f=(0,c.c)("worktree"),p=new Set(d),g=d.length<=1;return(0,r.jsxs)("div",{"data-testid":"mobile-agent-instances-pane",children:[(0,r.jsx)(aO,{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:i,onVibeLocalContextWindowChange:o,modelByInstance:h}),(0,r.jsxs)("div",{"data-testid":"mobile-visible-instances",className:"px-4 pb-4 border-t border-border mt-2 pt-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:x("mobileVisibleInstances")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:x("mobileVisibleInstancesDescription")}),(0,r.jsx)("div",{className:"space-y-1",children:n.map(e=>{var t;let n=p.has(e.id),a=n&&g,s=null!=(t=null==h?void 0:h[e.id])?t:null;return(0,r.jsxs)("label",{className:"flex items-center gap-2 p-2 rounded-lg cursor-pointer ".concat(a?"opacity-60 cursor-not-allowed":"hover:bg-muted"),children:[(0,r.jsx)(m.Sc,{"data-testid":"mobile-visible-instance-toggle-".concat(e.id),checked:n,disabled:a,onCheckedChange:()=>u(e.id)}),(0,r.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"block text-sm font-medium text-foreground truncate",children:(0,tt.sw)(e)}),(0,r.jsx)("span",{className:"block text-xs text-muted-foreground truncate",children:(0,tt.oo)(e.cliTool)}),s&&(0,r.jsx)("span",{"data-testid":"mobile-visible-instance-model-".concat(e.id),title:f("agentModel.modelLabel",{model:s}),className:"block text-xs text-muted-foreground truncate",children:s})]})]},e.id)})}),g&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:x("mobileVisibleInstanceMin")})]})]})}),a_=Array.from({length:Math.floor(104)+1},(e,t)=>3e5+3e5*t);var aB=n(82912),aV=n.n(aB);let aW=[36e5,108e5,288e5],aH={36e5:"autoYes.durations.1h",108e5:"autoYes.durations.3h",288e5:"autoYes.durations.8h"};function aU(e){if(e.length>500)return{valid:!1,error:"Pattern must be ".concat(500," characters or less")};if(!aV()(e))return{valid:!1,error:"Pattern may cause performance issues (catastrophic backtracking detected)"};try{return new RegExp(e),{valid:!0}}catch(e){return{valid:!1,error:"Invalid regular expression syntax"}}}function aK(e){let t=Math.max(0,e-Date.now()),n=Math.floor(t/36e5),a=Math.floor(t%36e5/6e4),r=Math.floor(t%6e4/1e3);return n>0?"".concat(n,":").concat(a.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0")):"".concat(a.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0"))}function a$(e){let t=Math.floor(e/6e4),n=Math.floor(t/60),a=t%60;return n>0&&a>0?"".concat(n,"h ").concat(a,"m"):n>0?"".concat(n,"h"):"".concat(a,"m")}let aq="w-full px-3 py-2 text-sm border border-input rounded-md bg-surface dark:bg-surface-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring";function aG(e){let{isOpen:t,worktreeId:n,instances:a,onClose:s,onSaved:l}=e,o=(0,c.c)("schedule"),d=(0,X.a)(),u=(0,i.useMemo)(()=>a&&a.length>0?a:(0,tt.lu)([...tt.XH]),[a]),[m,h]=(0,i.useState)(""),[x,f]=(0,i.useState)(()=>{var e,t;return null!=(t=null==(e=u[0])?void 0:e.id)?t:tt.XH[0]}),[p,g]=(0,i.useState)(a_[0]),[b,v]=(0,i.useState)(!1),[y,j]=(0,i.useState)(null);(0,i.useEffect)(()=>{var e,n;t&&(h(""),g(a_[0]),j(null),v(!1),f(null!=(n=null==(e=u[0])?void 0:e.id)?n:tt.XH[0]))},[t,u]),(0,i.useEffect)(()=>{if(!u.some(e=>e.id===x)){var e,t;f(null!=(t=null==(e=u[0])?void 0:e.id)?t:tt.XH[0])}},[u,x]);let w=m.trim().length>0&&!b,k=(0,i.useCallback)(async()=>{if(!m.trim()||b)return;let e=u.find(e=>e.id===x);if(e){j(null),v(!0);try{let t=await fetch("/api/worktrees/".concat(n,"/timers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:e.cliTool,instanceId:e.id,message:m.trim(),delayMs:p})});if(t.ok){let e=await t.json();l(),"session_not_running"===e.warning?(j("session_not_running"),h("")):s()}}catch(e){}finally{v(!1)}}},[n,u,x,m,p,b,l,s]),N=(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-instance-select",children:o("timer.agent")}),(0,r.jsx)("select",{id:"timer-instance-select","data-testid":"timer-instance-select",value:x,onChange:e=>f(e.target.value),className:aq,children:u.map(e=>(0,r.jsx)("option",{value:e.id,children:e.alias},e.id))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-message-input",children:o("timer.message")}),(0,r.jsx)("textarea",{id:"timer-message-input","data-testid":"timer-message-input",value:m,onChange:e=>h(e.target.value),placeholder:o("timer.message"),maxLength:1e4,rows:3,className:"".concat(aq," resize-none")})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-delay-select",children:o("timer.delay")}),(0,r.jsx)("select",{id:"timer-delay-select","data-testid":"timer-delay-select",value:p,onChange:e=>g(Number(e.target.value)),className:aq,children:a_.map(e=>(0,r.jsx)("option",{value:e,children:a$(e)},e))})]}),"session_not_running"===y&&(0,r.jsx)("div",{"data-testid":"timer-session-warning",className:"text-xs p-2 rounded bg-warning-subtle text-warning-foreground",children:o("timer.sessionWarning")})]}),C=(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:s,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:o("timer.close")}),(0,r.jsx)("button",{type:"button","data-testid":"timer-register-button",onClick:()=>void k(),disabled:!w,className:"px-4 py-2 text-sm font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-md transition-colors",children:o("timer.register")})]}),S=o("timer.titleCreate");return d?(0,r.jsx)(an,{isOpen:t,onClose:s,title:S,footer:C,children:N}):(0,r.jsx)(e7.a,{isOpen:t,onClose:s,title:S,size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[N,(0,r.jsx)("div",{className:"pt-2 border-t border-border",children:C})]})})}function aJ(e){return new Date(e).toLocaleString()}function aY(e){var t,n;let{timer:a,instances:s,onClose:l}=e,i=(0,c.c)("schedule"),o=(0,X.a)();if(!a)return null;let d=null!=(n=null==(t=s.find(e=>e.id===a.instanceId))?void 0:t.alias)?n:a.cliToolId,u=e=>{let{label:t,children:n}=e;return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-0.5",children:t}),(0,r.jsx)("div",{className:"text-sm text-foreground break-words",children:n})]})},m=(0,r.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"timer-detail-body",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:i("timer.message")}),(0,r.jsx)("pre",{"data-testid":"timer-detail-message",className:"text-sm whitespace-pre-wrap break-words font-mono text-foreground bg-muted rounded p-2 max-h-60 overflow-y-auto",children:a.message})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(u,{label:i("timer.agent"),children:(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-medium",children:d})}),(0,r.jsx)(u,{label:i("timer.statusLabel"),children:(0,r.jsx)("span",{className:function(e){switch(e){case"pending":return"text-info";case"sending":case"no_session":return"text-warning-foreground";case"sent":return"text-success-foreground";case"failed":return"text-danger-foreground";default:return"text-muted-foreground"}}(a.status),children:i("timer.status.".concat(a.status))})}),(0,r.jsx)(u,{label:i("timer.delay"),children:a$(a.delayMs)}),(0,r.jsx)(u,{label:i("timer.scheduledTime"),children:aJ(a.scheduledSendTime)}),(0,r.jsx)(u,{label:i("timer.createdTime"),children:aJ(a.createdAt)}),null!==a.sentAt&&(0,r.jsx)(u,{label:i("timer.sentTime"),children:aJ(a.sentAt)})]}),"failed"===a.status&&a.error&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-danger-foreground mb-1",children:i("timer.failureReason")}),(0,r.jsx)("pre",{"data-testid":"timer-detail-error",className:"text-xs whitespace-pre-wrap break-words font-mono text-danger-foreground bg-danger-subtle rounded p-2 max-h-40 overflow-y-auto",children:a.error})]})]}),h=(0,r.jsx)("div",{className:"flex items-center justify-end",children:(0,r.jsx)("button",{type:"button","data-testid":"timer-detail-close",onClick:l,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:i("timer.close")})}),x=i("timer.detailTitle");return o?(0,r.jsx)(an,{isOpen:!0,title:x,onClose:l,footer:h,children:m}):(0,r.jsx)(e7.a,{isOpen:!0,title:x,onClose:l,size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[m,(0,r.jsx)("div",{className:"pt-2 border-t border-border",children:h})]})})}let aQ=(0,i.memo)(function(e){let{worktreeId:t,instances:n}=e,a=(0,c.c)("schedule"),s=(0,ec.SC)(),l=(0,i.useMemo)(()=>n&&n.length>0?n:(0,tt.lu)([...tt.XH]),[n]),[o,d]=(0,i.useState)([]),[u,m]=(0,i.useState)(!1),[h,x]=(0,i.useState)(!1),[f,p]=(0,i.useState)(null),[,g]=(0,i.useState)(0),b=(0,i.useRef)(null),y=(0,i.useRef)(null),j=(0,i.useRef)(null),w=(0,i.useCallback)(async()=>{try{let n=await fetch("/api/worktrees/".concat(t,"/timers"));if(n.ok){var e;let t=await n.json();d(t.timers),m(null!=(e=t.hasMore)&&e),t.timers.length>0?j.current=t.timers[t.timers.length-1].createdAt:j.current=null}}catch(e){}},[t]),k=(0,i.useCallback)(async()=>{if(null!=j.current)try{let n=new URLSearchParams;n.set("before",String(j.current)),n.set("limit",String(50));let a=await fetch("/api/worktrees/".concat(t,"/timers?").concat(n));if(a.ok){var e;let t=await a.json();d(e=>[...e,...t.timers]),m(null!=(e=t.hasMore)&&e),t.timers.length>0&&(j.current=t.timers[t.timers.length-1].createdAt)}}catch(e){}},[t]);(0,i.useEffect)(()=>{function e(){return w(),b.current=setInterval(()=>{w()},1e4),y.current=setInterval(()=>{g(e=>e+1)},1e3),t}function t(){b.current&&clearInterval(b.current),y.current&&clearInterval(y.current),b.current=null,y.current=null}e();let n=()=>{"hidden"===document.visibilityState?t():e()};return document.addEventListener("visibilitychange",n),()=>{t(),document.removeEventListener("visibilitychange",n)}},[w]);let N=(0,i.useCallback)(async e=>{try{(await fetch("/api/worktrees/".concat(t,"/timers?timerId=").concat(e),{method:"DELETE"})).ok&&w()}catch(e){}},[t,w]),C=(0,i.useCallback)(async()=>{if(await s({description:a("timer.clearConfirm"),variant:"danger"}))try{(await fetch("/api/worktrees/".concat(t,"/timers/history"),{method:"DELETE"})).ok&&w()}catch(e){}},[t,w,a,s]),S=o.filter(e=>"pending"===e.status).length>=5;return(0,r.jsxs)("div",{className:"flex flex-col h-full p-3 gap-3 overflow-auto",children:[0===o.length?(0,r.jsxs)("div",{className:"flex flex-col items-center text-center py-8 px-4",children:[(0,r.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-accent-50 text-accent-600 dark:bg-accent-900/30 dark:text-accent-300",children:(0,r.jsx)(v.A,{className:"w-7 h-7"})}),(0,r.jsx)("p",{className:"font-semibold text-foreground mb-1",children:a("timer.title")}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mb-5 max-w-xs",children:a("timer.noTimers")}),(0,r.jsxs)("button",{type:"button","data-testid":"timer-empty-cta",onClick:()=>x(!0),className:"inline-flex items-center gap-1.5 px-5 py-2.5 text-sm font-semibold text-white bg-accent-600 hover:bg-accent-700 rounded-lg shadow-sm transition-colors",children:[(0,r.jsx)(aF.A,{className:"w-4 h-4"}),a("timer.createButton")]})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[S&&(0,r.jsx)("span",{className:"text-xs text-warning-foreground",children:a("timer.maxReached",{max:5})}),(0,r.jsxs)("button",{type:"button","data-testid":"timer-new-button",onClick:()=>x(!0),disabled:S,className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded transition-colors whitespace-nowrap",children:[(0,r.jsx)(aF.A,{className:"w-3.5 h-3.5"}),a("timer.newTimer")]})]}),o.map(e=>{var t,n;return(0,r.jsxs)("div",{role:"button",tabIndex:0,"data-testid":"timer-row",onClick:()=>p(e),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),p(e))},className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-surface text-left cursor-pointer hover:bg-muted transition-colors",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-sm text-foreground truncate",children:e.message.length>60?e.message.slice(0,60)+"...":e.message}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-medium",children:null!=(n=null==(t=l.find(t=>t.id===e.instanceId))?void 0:t.alias)?n:e.cliToolId}),(0,r.jsx)("span",{className:function(e){switch(e){case"pending":return"text-info";case"sending":case"no_session":return"text-warning-foreground";case"sent":return"text-success-foreground";case"failed":return"text-danger-foreground";default:return"text-muted-foreground"}}(e.status),children:a("timer.status.".concat(e.status))}),"pending"===e.status&&(0,r.jsx)("span",{className:"text-muted-foreground",children:aK(e.scheduledSendTime)}),(0,r.jsx)("span",{className:"text-muted-foreground",children:a$(e.delayMs)})]})]}),"pending"===e.status&&(0,r.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),N(e.id)},className:"px-2 py-1 text-xs text-danger-foreground hover:bg-danger-subtle rounded transition-colors",children:a("timer.cancel")})]},e.id)}),u&&(0,r.jsx)("button",{type:"button",onClick:k,className:"px-3 py-2 text-sm text-accent-600 dark:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/20 rounded-md transition-colors text-center",children:a("timer.loadMore")}),o.some(e=>"pending"!==e.status)&&(0,r.jsx)("button",{type:"button",onClick:C,className:"px-3 py-2 text-sm text-muted-foreground hover:bg-muted rounded-md transition-colors text-center",children:a("timer.clearHistory")})]}),(0,r.jsx)(aG,{isOpen:h,worktreeId:t,instances:n,onClose:()=>x(!1),onSaved:()=>{w()}}),(0,r.jsx)(aY,{timer:f,instances:l,onClose:()=>p(null)})]})});var aX=n(35626),aZ=n(99648);let a0={verified:"skills.compatibility.axisOutcome.verified",unsupported:"skills.compatibility.axisOutcome.unsupported",unknown:"skills.compatibility.axisOutcome.unknown"},a1={mechanical:"skills.compatibility.evidenceKind.mechanical",self_report:"skills.compatibility.evidenceKind.selfReport",not_measured:"skills.compatibility.evidenceKind.notMeasured"},a2={outcome:"unknown",evidenceKind:"not_measured",labelKey:a0.unknown,evidenceKindKey:a1.not_measured,limitationKey:null},a4={SESSION_RESTART:"skills.compatibility.reload.sessionRestart",SESSION_RESTART_NO_SLASH:"skills.compatibility.reload.sessionRestartNoSlash",UNKNOWN:"skills.compatibility.reload.unknown"};function a5(e){return{agent:e,discoveryRoots:[],discovery:a2,invocation:a2,testedVersion:null,testedDate:null,evidenceSource:null,reloadKey:a4.UNKNOWN,skipReasonKey:"skills.compatibility.skipReason.notMeasured"}}aZ.td,a0.verified,a1.mechanical,a0.verified,a1.mechanical,a4.SESSION_RESTART,aZ.Co,a0.verified,a1.self_report,a0.unsupported,a1.mechanical,a4.SESSION_RESTART_NO_SLASH,a5("gemini"),a5("vibe-local"),a5("opencode"),a5("copilot"),a5("antigravity");let a3={SATISFIED:"SKILL_COMPAT_SATISFIED",HOST_VERSION_OUT_OF_RANGE:"SKILL_COMPAT_HOST_VERSION_OUT_OF_RANGE",HOST_VERSION_UNKNOWN:"SKILL_COMPAT_HOST_VERSION_UNKNOWN",RANGE_UNSUPPORTED:"SKILL_COMPAT_RANGE_UNSUPPORTED"};a3.SATISFIED,a3.HOST_VERSION_OUT_OF_RANGE,a3.HOST_VERSION_UNKNOWN,a3.RANGE_UNSUPPORTED;let a6={CONFIRMED:"SKILL_AGENT_EVIDENCE_CONFIRMED",RESTRICTED:"SKILL_AGENT_EVIDENCE_RESTRICTED",STALE_DECLARATION:"SKILL_AGENT_EVIDENCE_STALE_DECLARATION",UNVERIFIED:"SKILL_AGENT_EVIDENCE_UNVERIFIED"};a6.CONFIRMED,a6.RESTRICTED,a6.STALE_DECLARATION,a6.UNVERIFIED;let a8=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;function a9(e){if("string"!=typeof e||e.length>64)return null;let t=a8.exec(e);return t?{major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3]),prerelease:t[4]?t[4].split("."):[],build:t[5]?t[5].split("."):[]}:null}let a7={UP_TO_DATE:"SKILL_UPDATE_UP_TO_DATE",HIGHEST_COMPATIBLE:"SKILL_UPDATE_RECOMMEND_HIGHEST_COMPATIBLE",LATEST_UNVERIFIED:"SKILL_UPDATE_RECOMMEND_LATEST_UNVERIFIED",NONE_COMPATIBLE:"SKILL_UPDATE_RECOMMEND_NONE_COMPATIBLE",INSTALLED_VERSION_INVALID:"SKILL_UPDATE_INSTALLED_VERSION_INVALID",RANGE_UNSUPPORTED:"SKILL_UPDATE_RANGE_UNSUPPORTED"};function re(e,t){let n=function(e,t){let n=a9(e),a=a9(t);return n&&a?n.major!==a.major?n.major<a.major?-1:1:n.minor!==a.minor?n.minor<a.minor?-1:1:n.patch!==a.patch?n.patch<a.patch?-1:1:function(e,t){if(0===e.length&&0===t.length)return 0;if(0===e.length)return 1;if(0===t.length)return -1;let n=Math.min(e.length,t.length);for(let a=0;a<n;a++){let n=e[a],r=t[a];if(n===r)continue;let s=/^\d+$/.test(n),l=/^\d+$/.test(r);if(s&&l)return Number(n)<Number(r)?-1:1;if(s)return -1;if(l)return 1;return n<r?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}(n.prerelease,a.prerelease):null}(e,t);return null!==n&&n>0}a7.UP_TO_DATE,a7.HIGHEST_COMPATIBLE,a7.LATEST_UNVERIFIED,a7.NONE_COMPATIBLE,a7.INSTALLED_VERSION_INVALID,a7.RANGE_UNSUPPORTED;var rt=n(75333),rn=n(34380),ra=n(37381),rr=n(95584),rs=n(80130);let rl={open:!1,selectedVersion:null,busy:!1,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applying:!1,applyResult:null,applyFailure:null};function ri(e){let{heading:t,paths:n,testid:a}=e;return 0===n.length?null:(0,r.jsxs)("div",{"data-testid":a,children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5",children:n.map(e=>(0,r.jsx)("li",{className:"break-all font-mono text-xs text-foreground",children:e},e))})]})}function ro(e){var t;let{skillId:n,skillName:a,worktreeId:s,installedVersion:l,versions:o}=e,d=(0,c.c)("skills"),u=(0,i.useMemo)(()=>o.filter(e=>re(e.version,l)),[o,l]),h=(0,i.useMemo)(()=>{var e,t,n;return null!=(n=null==(e=null!=(t=u.find(e=>"compatible"===e.compatibility.commandmate.status))?t:u[0])?void 0:e.version)?n:null},[u]),[x,f]=(0,i.useState)(rl),p=(0,i.useCallback)(()=>{f({...rl,open:!0,selectedVersion:h})},[h]),g=(0,i.useCallback)(()=>{f(rl)},[]),b=(0,i.useCallback)(async()=>{let e=x.selectedVersion;if(!e)return;f(e=>({...e,busy:!0,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applyResult:null,applyFailure:null}));let t=await (0,rs.Sw)(s,n,{version:e});f(e=>({...e,busy:!1,plan:t.ok?t.data.plan:null,failure:t.ok?null:t.failure}))},[n,x.selectedVersion,s]),v=(0,i.useCallback)(async()=>{var e;let t=x.plan;if(!t||!t.updatable)return;f(e=>({...e,applying:!0,applyFailure:null}));let a=await (0,rs.h2)(s,n,{planToken:t.token,version:t.update.toVersion,acknowledgeRisk:x.riskAcknowledged,acknowledgeRiskIncrease:x.riskIncreaseAcknowledged,idempotencyKey:(e=t.token,"skill-update-".concat(e))});f(e=>({...e,applying:!1,applyResult:a.ok?a.data:null,applyFailure:a.ok?null:a.failure}))},[n,x.plan,x.riskAcknowledged,x.riskIncreaseAcknowledged,s]);if(0===u.length)return(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-uptodate",children:d("update.upToDate",{version:l})});let y=x.plan,j=x.applyResult;return(0,r.jsxs)("div",{"data-testid":"skill-update-dialog-host",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(m.Ex,{variant:"info","data-testid":"skill-update-badge",children:d("update.badge")}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:d("update.fromTo",{from:l,to:u[0].version})}),(0,r.jsx)(m.$n,{variant:"secondary",size:"sm",onClick:p,"data-testid":"skill-update-trigger",children:d("update.open")})]}),(0,r.jsx)(m.Jh,{isOpen:x.open,onClose:g,title:d("update.heading"),size:"lg",children:(0,r.jsxs)("div",{className:"space-y-3 p-4","data-testid":"skill-update-dialog",children:[(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:d("update.intro",{skill:a,version:l})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:d("update.ready")}),(0,r.jsxs)("label",{className:"block text-xs font-medium text-muted-foreground",children:[d("update.versionPicker"),(0,r.jsx)("select",{className:"".concat("w-full rounded-md border border-input bg-surface px-3 py-2 text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"," mt-1"),value:null!=(t=x.selectedVersion)?t:"",onChange:e=>f(t=>({...t,selectedVersion:e.target.value,plan:null,failure:null})),disabled:x.busy,"data-testid":"skill-update-version-select",children:u.map(e=>(0,r.jsxs)("option",{value:e.version,children:[e.version,e.prerelease?" (".concat(d("detail.prerelease"),")"):"","compatible"!==e.compatibility.commandmate.status?" — ".concat(d(rr.OV[e.compatibility.commandmate.status])):""]},e.version))})]}),(0,r.jsx)(m.$n,{variant:"primary",disabled:x.busy||!x.selectedVersion,onClick:b,"data-testid":"skill-update-build",children:x.busy?d("update.building"):d("update.build")}),x.failure&&(0,r.jsxs)(ra.u,{tone:"danger","data-testid":"skill-update-error",children:[(0,r.jsx)("p",{children:d((0,rr.FW)(x.failure.code))}),(0,r.jsx)("p",{className:"mt-1 break-words",children:d("state.errorCode",{code:x.failure.code})})]}),y&&(0,r.jsxs)("div",{className:"space-y-3","data-testid":"skill-update-plan",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground",children:d("update.fromTo",{from:y.update.fromVersion,to:y.update.toVersion})}),null!==y.update.latestVersion&&y.update.latestVersion!==y.update.toVersion&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:d("update.latestAvailable",{version:y.update.latestVersion})})]}),(0,r.jsx)(ra.u,{tone:y.updatable?"info":"warning","data-testid":"skill-update-next-action",children:d((0,rr.e5)(y.nextActionKey))}),y.blockers.length>0&&(0,r.jsx)("ul",{className:"space-y-1","data-testid":"skill-update-blockers",children:y.blockers.map(e=>{var t;return(0,r.jsxs)("li",{className:"text-xs text-danger-foreground",children:[e.path&&(0,r.jsx)("span",{className:"mr-1 break-all font-mono",children:e.path}),d((0,rr.e5)(e.messageKey))]},"".concat(e.code,":").concat(null!=(t=e.path)?t:""))})}),(0,r.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-risk",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d("plan.riskHeading")}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-foreground",children:[(0,r.jsx)(rt.qW,{risk:y.securityDiff.risk.from.effective}),(0,r.jsx)("span",{"aria-hidden":"true",children:"→"}),(0,r.jsx)(rt.qW,{risk:y.securityDiff.risk.to.effective})]}),y.riskIncreased&&y.riskIncreaseMessageKey&&(0,r.jsx)(ra.u,{tone:"danger","data-testid":"skill-update-risk-increase",children:d((0,rr.e5)(y.riskIncreaseMessageKey))}),y.requiresRiskAcknowledgement&&y.riskAcknowledgementMessageKey&&(0,r.jsx)(ra.u,{tone:"warning","data-testid":"skill-update-high-risk",children:d((0,rr.e5)(y.riskAcknowledgementMessageKey))}),y.updatable&&!x.applyResult&&y.requiresRiskAcknowledgement&&(0,r.jsxs)("label",{className:"flex items-start gap-2 text-xs text-foreground",children:[(0,r.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:x.riskAcknowledged,onChange:e=>f(t=>({...t,riskAcknowledged:e.target.checked})),"data-testid":"skill-update-ack-risk"}),d("update.ackRisk")]}),y.updatable&&!x.applyResult&&y.riskIncreased&&(0,r.jsxs)("label",{className:"flex items-start gap-2 text-xs text-foreground",children:[(0,r.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:x.riskIncreaseAcknowledged,onChange:e=>f(t=>({...t,riskIncreaseAcknowledged:e.target.checked})),"data-testid":"skill-update-ack-risk-increase"}),d("update.ackRiskIncrease")]})]}),(0,r.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-security-diff",children:[y.securityDiff.permissions.added.length>0&&(0,r.jsxs)("div",{"data-testid":"skill-update-permissions-added",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d("update.permissionsAdded")}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5",children:y.securityDiff.permissions.added.map(e=>{var t;return(0,r.jsx)("li",{className:"text-xs text-foreground",children:d(null!=(t=rr.z2[e])?t:"plan.permissionsNone")},e)})})]}),y.securityDiff.permissions.removed.length>0&&(0,r.jsxs)("div",{"data-testid":"skill-update-permissions-removed",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d("update.permissionsRemoved")}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5",children:y.securityDiff.permissions.removed.map(e=>{var t;return(0,r.jsx)("li",{className:"text-xs text-foreground",children:d(null!=(t=rr.z2[e])?t:"plan.permissionsNone")},e)})})]}),(0,r.jsx)(ri,{heading:d("update.scriptsAdded"),paths:y.securityDiff.scripts.added,testid:"skill-update-scripts-added"}),(0,r.jsx)(ri,{heading:d("update.scriptsRemoved"),paths:y.securityDiff.scripts.removed,testid:"skill-update-scripts-removed"}),(0,r.jsx)(ri,{heading:d("update.executablesAdded"),paths:y.securityDiff.executables.added,testid:"skill-update-executables-added"}),(0,r.jsx)(ri,{heading:d("update.executablesRemoved"),paths:y.securityDiff.executables.removed,testid:"skill-update-executables-removed"})]}),y.securityDiff.changelogs.length>0&&(0,r.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-changelogs",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d("detail.changelogHeading")}),y.securityDiff.changelogs.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-foreground",children:e.version}),(0,r.jsx)("p",{className:"whitespace-pre-wrap text-xs text-muted-foreground",children:e.changelog})]},e.version))]}),(0,r.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-files",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d("update.filesHeading")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-stats",children:d("update.stats",{added:y.stats.added,updated:y.stats.updated,removed:y.stats.removed,unchanged:y.stats.unchanged})}),(0,r.jsx)("ul",{className:"space-y-1",children:y.files.filter(e=>"unchanged"!==e.change).map(e=>{var t,n;return(0,r.jsxs)("li",{"data-testid":"skill-update-file",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(m.Ex,{variant:null!=(t=rr.JD[e.change])?t:"gray",children:d(null!=(n=rr.KS[e.change])?n:"update.change.update")}),(0,r.jsx)("span",{className:"break-all font-mono text-xs text-foreground",children:e.path})]}),e.diff&&(0,r.jsxs)("details",{className:"mt-1",children:[(0,r.jsx)("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:d("update.showDiff")}),(0,r.jsx)("pre",{className:"mt-1 overflow-x-auto rounded-md bg-muted p-2 text-xs text-foreground",children:e.diff})]})]},e.path)})})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-expiry",children:d("plan.expiresAt",{timestamp:y.expiresAt})}),y.updatable&&!x.applyResult&&(0,r.jsx)(m.$n,{variant:"primary",disabled:x.applying||y.requiresRiskAcknowledgement&&!x.riskAcknowledged||y.riskIncreased&&!x.riskIncreaseAcknowledged,onClick:v,"data-testid":"skill-update-apply",children:x.applying?d("update.applying"):d("update.apply")}),x.applyFailure&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-apply-error",children:[(0,r.jsxs)(ra.u,{tone:"danger",children:[(0,r.jsx)("p",{children:d((0,rr.FW)(x.applyFailure.code))}),(0,r.jsx)("p",{className:"mt-1 break-words",children:d("state.errorCode",{code:x.applyFailure.code})})]}),x.applyFailure.nextActionKey&&(0,r.jsx)(ra.u,{tone:"warning",children:d((0,rr.e5)(x.applyFailure.nextActionKey))}),x.applyFailure.blockers&&x.applyFailure.blockers.length>0&&(0,r.jsx)("ul",{className:"space-y-1","data-testid":"skill-update-apply-error-blockers",children:x.applyFailure.blockers.map(e=>{var t;return(0,r.jsxs)("li",{className:"text-xs text-danger-foreground",children:[e.path&&(0,r.jsx)("span",{className:"mr-1 break-all font-mono",children:e.path}),d((0,rr.e5)(e.messageKey))]},"".concat(e.code,":").concat(null!=(t=e.path)?t:""))})})]})]}),j&&(0,r.jsxs)("div",{className:"space-y-3","data-testid":"skill-update-result",children:[(0,r.jsx)(ra.u,{tone:"succeeded"===j.operation.result?"info":"warning","data-testid":"skill-update-result-next-action",children:d((0,rr.e5)(j.operation.nextActionKey))}),"reload"in j&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm font-semibold text-foreground",children:d("update.fromTo",{from:j.update.fromVersion,to:j.update.toVersion})}),(0,r.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-result-reload",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d("operation.reloadHeading")}),(0,r.jsx)("ul",{className:"space-y-1",children:j.reload.agents.map(e=>(0,r.jsx)("li",{className:"text-xs text-muted-foreground",children:d((0,rr.e5)(e.messageKey),{agent:(0,tt.f_)(e.agent),skillId:j.reload.skillId,version:j.reload.version})},e.agent))})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-result-rollback",children:d((0,rr.e5)(j.rollback.messageKey),{version:j.rollback.backup.fromVersion})})]})]})]})})]})}let rc={status:"loading",skills:[],failure:null},rd={status:"loading",skills:[],failure:null};function ru(e){var t,n,a,s,l,o,d,u;let{worktreeId:h,className:x=""}=e,f=(0,c.c)("skills"),[p,g]=(0,i.useState)(rc),[b,v]=(0,i.useState)(rd),[y,j]=(0,i.useState)(null),[w,k]=(0,i.useState)(0),[N,C]=(0,i.useState)(0);(0,i.useEffect)(()=>{let e=new AbortController;return g(rc),(0,rs.s5)(e.signal).then(t=>{e.signal.aborted||g(t.ok?{status:"loaded",skills:t.data.skills,failure:null}:{status:"error",skills:[],failure:t.failure})}).catch(()=>{}),()=>e.abort()},[w]),(0,i.useEffect)(()=>{let e=new AbortController;return v(rd),(0,rs.Gj)(h,e.signal).then(t=>{e.signal.aborted||v(t.ok?{status:"loaded",skills:t.data.skills,failure:null}:{status:"error",skills:[],failure:t.failure})}).catch(()=>{}),()=>e.abort()},[h,N]);let S=(0,i.useMemo)(()=>new Map(b.skills.map(e=>[e.skillId,e.version])),[b.skills]),T=(0,i.useMemo)(()=>new Map(p.skills.map(e=>[e.id,{name:e.name,summary:e.summary,latest:e.latest}])),[p.skills]),E=(0,i.useMemo)(()=>{let e=new Map;for(let[r,s]of S){var t,n,a;e.set(r,(a=null!=(n=null==(t=T.get(r))?void 0:t.latest)?n:null,null!==s&&null!==a&&re(a,s)))}return e},[S,T]),I=(0,i.useMemo)(()=>{var e;return null!=(e=p.skills.find(e=>e.id===y))?e:null},[p.skills,y]),M=(0,i.useMemo)(()=>{var e;return null!=(e=b.skills.find(e=>e.skillId===y))?e:null},[b.skills,y]);if(y){let e=null!=(a=null==I?void 0:I.compatibility)?a:null,t=I?I.recommendedVersion:null!=(s=null==M?void 0:M.version)?s:null,n=I?I.recommendedVersion?e&&"compatible"!==e.status?f("detail.install.blockedIncompatible",{reason:f((0,rr.e5)(e.messageKey),{range:e.requiredRange,currentVersion:null!=(l=e.currentVersion)?l:""})}):null:f("detail.install.blockedNoVersion"):null;return(0,r.jsxs)("div",{className:"flex flex-col min-h-0 ".concat(x).trim(),"data-testid":"worktree-skills-pane",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b border-border p-3",children:[(0,r.jsxs)(m.$n,{variant:"ghost",size:"sm",onClick:()=>{j(null),C(e=>e+1)},"data-testid":"worktree-skills-back",children:[(0,r.jsx)(aX.A,{size:14,"aria-hidden":"true",className:"mr-1"}),f("worktreePane.back")]}),(0,r.jsx)("h2",{className:"min-w-0 truncate text-sm font-semibold text-foreground",children:null!=(o=null==I?void 0:I.name)?o:y})]}),(0,r.jsxs)("div",{className:"min-h-0 flex-1 space-y-3 overflow-auto p-3",children:[M&&I&&(0,r.jsx)(ro,{skillId:y,skillName:I.name,worktreeId:h,installedVersion:M.version,versions:I.versions}),(0,r.jsx)(rn.B,{skillId:y,version:t,blockedReason:n,worktreeId:h})]})]})}return(0,r.jsx)("div",{className:"flex flex-col min-h-0 ".concat(x).trim(),"data-testid":"worktree-skills-pane",children:(0,r.jsxs)("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-3",children:[(0,r.jsxs)("section",{className:"space-y-2","data-testid":"worktree-skills-installed",children:[(0,r.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:f("worktreePane.installedHeading")}),"loading"===b.status?(0,r.jsx)(m.EA,{className:"h-16 w-full rounded-lg","data-testid":"worktree-skills-installed-loading"}):"error"===b.status?(0,r.jsxs)(m.Zp,{className:"space-y-2","data-testid":"worktree-skills-installed-error",children:[(0,r.jsxs)(ra.u,{tone:"danger",children:[(0,r.jsx)("p",{children:f("worktreePane.installedError")}),(0,r.jsx)("p",{className:"mt-1 break-words",children:f("state.errorCode",{code:null!=(d=null==(t=b.failure)?void 0:t.code)?d:""})})]}),(0,r.jsx)(m.$n,{variant:"secondary",size:"sm",onClick:()=>C(e=>e+1),"data-testid":"worktree-skills-installed-retry",children:f("state.retry")})]}):0===b.skills.length?(0,r.jsx)(m.Zp,{"data-testid":"worktree-skills-installed-empty",children:(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:f("worktreePane.installedEmpty")})}):(0,r.jsx)("ul",{className:"space-y-2",children:b.skills.map(e=>{var t;let n=T.get(e.skillId);return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>j(e.skillId),"data-testid":"worktree-skills-installed-".concat(e.skillId),className:"w-full rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"break-all text-sm font-semibold text-foreground",children:null!=(t=null==n?void 0:n.name)?t:e.skillId}),(0,r.jsx)(rt.qW,{risk:e.effectiveRisk}),E.get(e.skillId)&&(0,r.jsx)(m.Ex,{variant:"info","data-testid":"worktree-skills-update-badge-".concat(e.skillId),children:f("worktreePane.updateBadge")})]}),(null==n?void 0:n.summary)&&(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground line-clamp-2","data-testid":"worktree-skills-installed-summary-".concat(e.skillId),children:n.summary}),(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:f("worktreePane.version",{version:e.version})})]})},e.skillId)})})]}),(0,r.jsxs)("section",{className:"space-y-2","data-testid":"worktree-skills-catalog",children:[(0,r.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:f("worktreePane.catalogHeading")}),"loading"===p.status?(0,r.jsx)(m.EA,{className:"h-24 w-full rounded-lg","data-testid":"worktree-skills-catalog-loading"}):"error"===p.status?(0,r.jsxs)(m.Zp,{className:"space-y-2","data-testid":"worktree-skills-catalog-error",children:[(0,r.jsxs)(ra.u,{tone:"danger",children:[(0,r.jsx)("p",{children:f("state.errorNotice")}),(0,r.jsx)("p",{className:"mt-1 break-words",children:f("state.errorCode",{code:null!=(u=null==(n=p.failure)?void 0:n.code)?u:""})})]}),(0,r.jsx)(m.$n,{variant:"secondary",size:"sm",onClick:()=>k(e=>e+1),"data-testid":"worktree-skills-catalog-retry",children:f("state.retry")})]}):0===p.skills.length?(0,r.jsx)(m.Zp,{"data-testid":"worktree-skills-catalog-empty",children:(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:f("state.empty")})}):(0,r.jsx)("ul",{className:"space-y-2",children:p.skills.map(e=>{let t=(0,rr.gh)(e),n=S.has(e.id),a=!0===E.get(e.id);return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>j(e.id),"data-testid":"worktree-skills-catalog-".concat(e.id),className:"w-full rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"min-w-0 break-all text-sm font-semibold text-foreground",children:e.name}),n&&(a?(0,r.jsx)(m.Ex,{variant:"info","data-testid":"worktree-skills-catalog-update-badge-".concat(e.id),children:f("worktreePane.updateBadge")}):(0,r.jsx)(m.Ex,{variant:"info","data-testid":"worktree-skills-installed-badge-".concat(e.id),children:f("worktreePane.installedBadge")}))]}),(0,r.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:f("card.provider",{provider:e.provider.name})}),(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground","data-testid":"worktree-skills-catalog-version-".concat(e.id),children:f("worktreePane.version",{version:e.latest})}),e.summary&&(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2","data-testid":"worktree-skills-catalog-summary-".concat(e.id),children:e.summary}),(0,r.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[e.compatibility&&(0,r.jsx)(rt.Xz,{status:e.compatibility.status}),t&&(0,r.jsx)(rt.qW,{risk:t})]})]})},e.id)})})]})]})})}var rm=n(76907),rh=n(52799);let rx={pending:"gray",running:"info",waiting_input:"warning",verifying:"info",succeeded:"success",failed:"error",not_started:"warning",cancelled:"gray"},rf={running:"info",passed:"success",failed:"error",not_started:"warning",error:"error",cancelled:"gray"},rp={running:"info",passed:"success",failed:"error",timeout:"error",skipped:"gray",error:"error"},rg=["failed","timeout","error"];class rb extends Error{constructor(e,t,n=null){super(e),this.name="VerificationApiError",this.status=t,this.runningRunId=n}}async function rv(e,t){let n=await e.json().catch(()=>({})),a="string"==typeof n.error?n.error:"".concat(t," (").concat(e.status,")"),r="number"==typeof n.runningRunId?n.runningRunId:null;throw new rb(a,e.status,r)}function ry(e){return"/api/worktrees/".concat(encodeURIComponent(e))}async function rj(e,t){var n,a;let r=await fetch("".concat(ry(e),"/tasks?limit=1"),{signal:t});return r.ok?null!=(a=null==(n=(await r.json()).tasks)?void 0:n[0])?a:null:rv(r,"Failed to load tasks")}async function rw(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,a=arguments.length>2?arguments[2]:void 0,r=await fetch("".concat(ry(e),"/verify/runs?limit=").concat(n),{signal:a});return r.ok?null!=(t=(await r.json()).runs)?t:[]:rv(r,"Failed to load verification runs")}async function rk(e,t,n){let a=await fetch("".concat(ry(e),"/verify/runs/").concat(t),{signal:n});return 404===a.status?null:a.ok?(await a.json()).run:rv(a,"Failed to load the verification run")}async function rN(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=await fetch("".concat(ry(e),"/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)return rv(n,"Failed to start verification");let a=await n.json();if("number"!=typeof a.runId)throw new rb("Verification response carried no run id",n.status);return a.runId}function rC(e){if(!e)return"—";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function rS(e){let{heading:t,action:n,children:a,testId:s}=e;return(0,r.jsxs)("section",{className:"border-b border-border px-3 py-3 last:border-b-0","data-testid":s,children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,r.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t}),n]}),a]})}function rT(e){let{label:t,children:n}=e;return(0,r.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,r.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:t}),(0,r.jsx)("span",{className:"min-w-0 break-words text-xs text-foreground",children:n})]})}function rE(e){var t,n;let{task:a}=e,s=(0,c.c)("worktree"),l=a.contract,i=null!=(t=l.goal)?t:"",o=i.length>240?"".concat(i.slice(0,240),"…"):i;return(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-contract",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"min-w-0 break-words text-sm font-medium text-foreground",children:l.title||a.title}),(0,r.jsx)(rh.E,{variant:rx[a.status],"data-testid":"verification-task-status",children:s("task.status.".concat(a.status))})]}),(0,r.jsx)("p",{className:"whitespace-pre-wrap break-words text-xs text-muted-foreground",children:o}),(0,r.jsxs)("div",{className:"space-y-1 pt-1",children:[(0,r.jsx)(rT,{label:s("verification.contract.scopeAllow"),children:(0,r.jsx)("span",{className:"font-mono",children:l.scope.allow.join(", ")||"—"})}),l.scope.deny.length>0&&(0,r.jsx)(rT,{label:s("verification.contract.scopeDeny"),children:(0,r.jsx)("span",{className:"font-mono",children:l.scope.deny.join(", ")})}),(0,r.jsx)(rT,{label:s("verification.contract.gates"),children:(0,r.jsx)("span",{className:"font-mono",children:null===l.verify.gates?s("verification.contract.gatesAll"):l.verify.gates.join(", ")||s("verification.contract.gatesAll")})}),(0,r.jsx)(rT,{label:s("verification.contract.autoYes"),children:(0,r.jsx)("span",{className:"font-mono",children:null!=(n=l.autoYes.mode)?n:s("verification.contract.autoYesUnset")})}),a.contractPath&&(0,r.jsx)(rT,{label:s("verification.contract.file"),children:(0,r.jsx)("span",{className:"font-mono",children:a.contractPath})}),(0,r.jsx)(rT,{label:s("verification.contract.updated"),children:rC(a.updatedAt)})]})]})}function rI(e){let{run:t,selected:n,onSelect:a}=e,s=(0,c.c)("worktree"),l=s("verification.runStatus.".concat(t.status));return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>a(t.id),"aria-current":n?"true":void 0,"aria-label":s("verification.runs.select",{runId:t.id,verdict:l}),"data-testid":"verification-run-".concat(t.id),className:"flex w-full flex-col gap-0.5 rounded-md border px-2 py-2 text-left text-xs transition-colors touch-manipulation focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ".concat(n?"border-accent-500 bg-accent-50 dark:bg-accent-900/30":"border-border bg-surface hover:bg-muted"),children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)(rh.E,{variant:rf[t.status],className:"flex-shrink-0 font-mono",children:l}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:rC(t.startedAt)})]}),(0,r.jsxs)("span",{className:"flex flex-wrap gap-x-2 font-mono text-[11px] text-muted-foreground",children:[(0,r.jsx)("span",{children:s("verification.runs.runLabel",{runId:t.id})}),(0,r.jsx)("span",{children:s("verification.runs.trigger",{trigger:t.trigger})})]})]})})}function rM(e){let{gate:t}=e,n=(0,c.c)("worktree"),a=rg.includes(t.status),[s,l]=(0,i.useState)(null),o=null!=s?s:a,d=function(e,t){let n=(null!=e?e:"").replace(/\n+$/,"");if(""===n)return{lines:[],omitted:0};let a=n.split("\n");return a.length<=40?{lines:a,omitted:0}:{lines:a.slice(-40),omitted:a.length-t}}(t.logTail,40),u=function(e){if(null==e||!Number.isFinite(e))return null;if(e<1e3)return"".concat(Math.max(0,Math.round(e)),"ms");let t=e/1e3;return t<10?"".concat(t.toFixed(1),"s"):"".concat(Math.round(t),"s")}(t.durationMs);return(0,r.jsxs)("li",{className:"rounded-md border border-border bg-surface p-2","data-testid":"verification-gate-".concat(t.gateId),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(rh.E,{variant:rp[t.status],className:"flex-shrink-0 font-mono",children:n("verification.gateStatus.".concat(t.status))}),(0,r.jsx)("span",{className:"min-w-0 break-all font-mono text-xs font-medium text-foreground",children:t.gateId}),"contract"===t.source&&(0,r.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground",children:n("verification.gates.contractSource")})]}),(0,r.jsxs)("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5 font-mono text-[11px] text-muted-foreground",children:[null!==t.exitCode&&void 0!==t.exitCode&&(0,r.jsx)("span",{children:n("verification.gates.exitCode",{code:t.exitCode})}),u&&(0,r.jsx)("span",{children:n("verification.gates.duration",{duration:u})}),t.command&&(0,r.jsx)("span",{className:"break-all",children:t.command})]}),(0,r.jsx)("button",{type:"button",onClick:()=>l(!o),"aria-expanded":o,"data-testid":"verification-gate-log-toggle-".concat(t.gateId),className:"mt-1 rounded text-[11px] font-medium text-accent-600 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:text-accent-400 touch-manipulation",children:n(o?"verification.gates.hideLog":"verification.gates.showLog")}),o&&(0,r.jsx)("div",{className:"mt-1","data-testid":"verification-gate-log-".concat(t.gateId),children:0===d.lines.length?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("verification.gates.noLog")}):(0,r.jsxs)(r.Fragment,{children:[d.omitted>0&&(0,r.jsx)("p",{className:"mb-1 text-[11px] text-muted-foreground",children:n("verification.gates.logOmitted",{count:d.omitted,runId:t.runId})}),(0,r.jsx)("pre",{className:"max-h-64 overflow-auto rounded bg-terminal-surface p-2 font-mono text-[11px] leading-relaxed text-terminal-foreground",children:d.lines.join("\n")})]})})]})}let rA=(0,i.memo)(function(e){let{state:t,className:n=""}=e,a=(0,c.c)("worktree"),{task:s,runs:l,selectedRunId:o,selectedRun:d,loading:u,error:m,detailError:h,detailLoading:x,rerunPending:f,rerunFailure:p,selectRun:g,refresh:b,rerun:v}=t,y=(0,i.useCallback)(()=>{v()},[v]);return(0,r.jsxs)("div",{className:"flex h-full flex-col overflow-y-auto bg-surface ".concat(n).trim(),"data-testid":"verification-pane",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)(rm.A,{size:16,"aria-hidden":"true",className:"flex-shrink-0 text-muted-foreground"}),(0,r.jsx)("h2",{className:"truncate text-sm font-semibold text-foreground",children:a("verification.title")})]}),(0,r.jsx)("button",{type:"button",onClick:b,"aria-label":a("verification.refresh"),title:a("verification.refresh"),"data-testid":"verification-refresh-button",className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation",children:(0,r.jsx)(nU.A,{size:14,"aria-hidden":"true"})})]}),m&&(0,r.jsx)("p",{className:"border-b border-danger-border bg-danger-subtle px-3 py-2 text-xs text-danger-foreground","data-testid":"verification-error",role:"alert",children:a("verification.loadError",{message:m})}),u?(0,r.jsx)("p",{className:"px-3 py-4 text-xs text-muted-foreground","data-testid":"verification-loading",children:a("verification.loading")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rS,{heading:a("verification.contract.heading"),testId:"verification-contract-section",children:s?(0,r.jsx)(rE,{task:s}):(0,r.jsx)("p",{className:"whitespace-pre-line text-xs text-muted-foreground","data-testid":"verification-contract-empty",children:a("verification.contract.empty")})}),(0,r.jsxs)(rS,{heading:a("verification.runs.heading"),testId:"verification-runs-section",action:(0,r.jsx)(eZ.$,{type:"button",size:"sm",variant:"secondary",onClick:y,disabled:f,"data-testid":"verification-rerun-button",children:a(f?"verification.runs.rerunPending":"verification.runs.rerun")}),children:[p&&(0,r.jsx)("p",{className:"mb-2 rounded border border-warning-border bg-warning-subtle px-2 py-1 text-xs text-warning-foreground","data-testid":"verification-rerun-failure",role:"alert",children:"conflict"===p.kind?null!==p.runningRunId?a("verification.runs.rerunConflict",{runId:p.runningRunId}):a("verification.runs.rerunConflictUnknown"):a("verification.runs.rerunError",{message:p.message})}),0===l.length?(0,r.jsx)("p",{className:"whitespace-pre-line text-xs text-muted-foreground","data-testid":"verification-runs-empty",children:a("verification.runs.empty")}):(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-runs",children:l.map(e=>(0,r.jsx)(rI,{run:e,selected:e.id===o,onSelect:g},e.id))})]}),null!==o&&(0,r.jsx)(rS,{heading:a("verification.gates.heading",{runId:o}),testId:"verification-gates-section",children:null!==h?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-error",role:"alert",children:"not-found"===h?a("verification.gates.notFound"):a("verification.gates.loadError",{message:h})}):null===d?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-loading",children:a(x?"verification.gates.loading":"verification.gates.empty")}):0===d.gates.length?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-empty",children:a("verification.gates.empty")}):(0,r.jsx)("ul",{className:"space-y-1.5","data-testid":"verification-gates",children:d.gates.map(e=>(0,r.jsx)(rM,{gate:e},e.id))})})]})]})});var rL=n(70532),rR=n(46046),rP=n(52056),rD=n(47972),rF=n(5590),rO=n(25840);class rz extends Error{constructor(e,t,n=[]){super(t),this.name="EnvApiError",this.code=e,this.issues=n}}async function r_(e,t){var n,a,r,s,l,i;let o=await e.json().catch(()=>null);return new rz(null!=(s=null==o||null==(n=o.error)?void 0:n.code)?s:"HTTP_".concat(e.status),null!=(l=null==o||null==(a=o.error)?void 0:a.message)?l:t,null!=(i=null==o||null==(r=o.error)?void 0:r.issues)?i:[])}function rB(e,t){let n="/api/worktrees/".concat(encodeURIComponent(e),"/env");return void 0===t?n:"".concat(n,"?file=").concat(encodeURIComponent(t))}async function rV(e,t){var n,a;let r=await fetch(rB(e,t),{cache:"no-store"});if(!r.ok)throw await r_(r,"Failed to load env files");let s=await r.json();return{files:null!=(n=s.files)?n:[],selected:null!=(a=s.selected)?a:null}}async function rW(e,t,n){var a;let r=await fetch(rB(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:t,content:n})});if(!r.ok)throw await r_(r,"Failed to save env file");let s=await r.json();return{file:s.file,issues:null!=(a=s.issues)?a:[]}}let rH=/^[A-Za-z_][A-Za-z0-9_]*$/;function rU(e){return e.split(/\r\n|\n|\r/)}function rK(e,t,n){for(let a=n;a<e.length;a+=1){if('"'===t&&"\\"===e[a]){a+=1;continue}if(e[a]===t)return a}return -1}function r$(e){let t=rU(e),n=[],a=[],r=new Map;for(let e=0;e<t.length;e+=1){let s,l=e+1,i=t[e].trim();if(""===i||i.startsWith("#"))continue;let o=/^export\s+/.test(i),c=o?i.replace(/^export\s+/,""):i,d=c.indexOf("=");if(-1===d){a.push({line:l,code:"invalid-syntax",severity:"error"});continue}let u=c.slice(0,d).trim();if(!rH.test(u)){a.push({line:l,code:"invalid-key",severity:"error",...u.length>0&&u.length<=64?{key:u}:{}});continue}let m=c.slice(d+1).replace(/^[ \t]+/,""),h=null,x=l;if(m.startsWith('"')||m.startsWith("'")){h=m[0];let n=m.slice(1),r=rK(n,h,0);for(;-1===r&&e+1<t.length;)e+=1,x=e+1,n+="\n".concat(t[e]),r=rK(n,h,0);if(-1===r){a.push({line:l,code:"unterminated-quote",severity:"error",key:u});continue}let i=n.slice(0,r);s='"'===h?function(e){let t="";for(let n=0;n<e.length;n+=1){let a=e[n];if("\\"!==a||n===e.length-1){t+=a;continue}let r=e[n+1];switch(n+=1,r){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+=" ";break;case"\\":t+="\\";break;case'"':t+='"';break;default:t+="\\".concat(r)}}return t}(i):i}else s=(function(e){let t=/\s#/.exec(e);return t?e.slice(0,t.index):e})(m).replace(/[ \t]+$/,"");void 0!==r.get(u)&&a.push({line:l,code:"duplicate-key",severity:"warning",key:u}),r.set(u,l),n.push({key:u,value:s,line:l,endLine:x,exported:o,quote:h})}return{entries:n,issues:a}}let rq=/[\s#'"$`\\]/;function rG(e){if(!rq.test(e))return e;let t=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t");return'"'.concat(t,'"')}function rJ(e,t,n){let a=rU(e),r=new Map(t.map(e=>[e.line,e])),s=new Map,l=[];for(let e of n)null!==e.sourceLine&&r.has(e.sourceLine)?s.set(e.sourceLine,e):l.push(e);let i=[],o=0;for(let e=0;e<a.length;e+=1){let t=e+1;if(t<=o)continue;let n=r.get(t);if(!n){i.push(a[e]);continue}o=n.endLine;let l=s.get(t);l&&i.push("".concat(n.exported?"export ":"").concat(l.key,"=").concat(rG(l.value)))}for(let e of(i.length>0&&""===i[i.length-1]&&i.pop(),l))i.push("".concat(e.key,"=").concat(rG(e.value)));return 0===i.length?"":"".concat(i.join("\n"),"\n")}let rY=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/,rQ=0;function rX(){return rQ+=1,"env-row-".concat(rQ)}function rZ(e){return e.map(e=>({id:rX(),key:e.key,value:e.value,sourceLine:e.line}))}let r0="••••••••";function r1(e){return 0===e.length?"":r0}let r2="flex-shrink-0 px-2 opacity-80 transition-opacity hover:opacity-100 [@media(hover:none)]:opacity-100",r4={"invalid-syntax":"envManager.issues.invalidSyntax","invalid-key":"envManager.issues.invalidKey","unterminated-quote":"envManager.issues.unterminatedQuote","duplicate-key":"envManager.issues.duplicateKey","control-character":"envManager.issues.controlCharacter","too-large":"envManager.issues.tooLarge","too-many-entries":"envManager.issues.tooManyEntries"},r5=(0,i.memo)(function(e){let{worktreeId:t,className:n=""}=e,a=(0,c.c)("worktree"),s=function(e){var t;let[n,a]=(0,i.useState)([]),[r,s]=(0,i.useState)(".env"),[l,o]=(0,i.useState)(null),[c,d]=(0,i.useState)(!0),[u,m]=(0,i.useState)(!1),[h,x]=(0,i.useState)(null),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)("kv"),[v,y]=(0,i.useState)([]),[j,w]=(0,i.useState)(""),[k,N]=(0,i.useState)(""),[C,S]=(0,i.useState)([]),[T,E]=(0,i.useState)(""),[I,M]=(0,i.useState)(new Set),[A,L]=(0,i.useState)(!1),[R,P]=(0,i.useState)(0),D=(0,i.useRef)(0);(0,i.useEffect)(()=>{let t=!1,n=D.current+1;return D.current=n,d(!0),x(null),p(!1),rV(e,r).then(e=>{var r,s;if(t||D.current!==n)return;a(e.files);let l=e.selected;o(l);let i=null!=(r=null==l?void 0:l.content)?r:"",c=null!=(s=null==l?void 0:l.entries)?s:[];E(i),N(i),S(c),y(rZ(c)),w(i),M(new Set),L(!1)}).catch(e=>{var a,r;if(t||D.current!==n)return;let s=e instanceof rz?e:null;x({code:null!=(a=null==s?void 0:s.code)?a:"UNKNOWN",message:null!=(r=null==s?void 0:s.message)?r:e instanceof Error?e.message:"Failed to load"}),o(null)}).finally(()=>{t||D.current!==n||d(!1)}),()=>{t=!0}},[e,r,R]);let F=(0,i.useMemo)(()=>"raw"===g?j:rJ(k,C,v),[g,j,k,C,v]),O=(0,i.useMemo)(()=>(function(e){let t=[];if("string"!=typeof e)return{valid:!1,issues:[{line:null,code:"invalid-syntax",severity:"error"}],entries:[]};if(new TextEncoder().encode(e).length>262144)return{valid:!1,issues:[{line:null,code:"too-large",severity:"error"}],entries:[]};let n=e.split(/\r\n|\n|\r/);for(let e=0;e<n.length;e+=1)rY.test(n[e])&&t.push({line:e+1,code:"control-character",severity:"error"});let a=r$(e);return t.push(...a.issues),a.entries.length>1e3&&t.push({line:null,code:"too-many-entries",severity:"error"}),t.sort((e,t)=>{var n,a;return(null!=(n=e.line)?n:0)-(null!=(a=t.line)?a:0)}),{valid:!t.some(e=>"error"===e.severity),issues:t,entries:a.entries}})(F),[F]),z=(0,i.useMemo)(()=>"raw"===g?j!==T:k!==T||v.length!==C.length||v.some((e,t)=>{var n,a;return e.key!==(null==(n=C[t])?void 0:n.key)||e.value!==(null==(a=C[t])?void 0:a.value)}),[g,j,T,k,v,C]),_=(0,i.useCallback)(e=>{if(e!==g){if("raw"===e)w(rJ(k,C,v));else{let e=r$(j);N(j),S(e.entries),y(rZ(e.entries))}b(e)}},[g,k,C,v,j]),B=(0,i.useCallback)(e=>{s(e),b("kv")},[]),V=(0,i.useCallback)(e=>{w(e),p(!1)},[]),W=(0,i.useCallback)((e,t)=>{y(n=>n.map(n=>n.id===e?{...n,...t}:n)),p(!1)},[]),H=(0,i.useCallback)(e=>{var t,n;let a={id:rX(),key:null!=(t=null==e?void 0:e.key)?t:"",value:null!=(n=null==e?void 0:e.value)?n:"",sourceLine:null};y(e=>[...e,a]),p(!1),(null==e?void 0:e.key)&&M(t=>new Set([...t,e.key]))},[]),U=(0,i.useCallback)(e=>{y(t=>t.filter(t=>t.id!==e)),p(!1)},[]),K=(0,i.useCallback)(e=>{M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),$=(0,i.useCallback)(()=>L(e=>!e),[]),q=(0,i.useCallback)(()=>{M(new Set(v.map(e=>e.key)))},[v]),G=(0,i.useCallback)(()=>M(new Set),[]),J=(0,i.useCallback)(()=>P(e=>e+1),[]),Y=(0,i.useCallback)(()=>{O.valid&&!u&&(m(!0),x(null),rW(e,r,F).then(()=>{p(!0),P(e=>e+1)}).catch(e=>{var t,n;let a=e instanceof rz?e:null;x({code:null!=(t=null==a?void 0:a.code)?t:"UNKNOWN",message:null!=(n=null==a?void 0:a.message)?n:e instanceof Error?e.message:"Failed to save"})}).finally(()=>m(!1)))},[O.valid,u,e,r,F]);return{files:n,selectedFile:r,detail:l,loading:c,saving:u,error:h,saved:f,mode:g,rows:v,rawDraft:j,revealedKeys:I,rawRevealed:A,suggestions:null!=(t=null==l?void 0:l.suggestions)?t:[],issues:O.issues,canSave:O.valid,dirty:z,selectFile:B,setMode:_,setRawDraft:V,updateRow:W,addRow:H,removeRow:U,toggleReveal:K,toggleRawReveal:$,revealAll:q,hideAll:G,reload:J,save:Y}}(t),{mode:l,rows:o,revealedKeys:d,rawRevealed:m}=s,h=(0,i.useMemo)(()=>s.issues.filter(e=>"error"===e.severity),[s.issues]),x=(0,i.useMemo)(()=>s.issues.filter(e=>"warning"===e.severity),[s.issues]),f="raw"===l?m:o.length>0&&o.every(e=>d.has(e.key)),p=(0,i.useCallback)(()=>{if("raw"===l)return void s.toggleRawReveal();f?s.hideAll():s.revealAll()},[l,f,s]),g=(0,i.useMemo)(()=>"raw"!==l||m?"":function(e,t){let n=e.split(/\r\n|\n|\r/),a=new Map,r=new Set;for(let e of t){a.set(e.line,e);for(let t=e.line+1;t<=e.endLine;t+=1)r.add(t)}let s=[];for(let e=0;e<n.length;e+=1){let t=e+1;if(r.has(t))continue;let l=a.get(t);if(!l){s.push(n[e]);continue}s.push("".concat(l.exported?"export ":"").concat(l.key,"=").concat(r1(l.value)))}return s.join("\n")}(s.rawDraft,r$(s.rawDraft).entries),[l,m,s.rawDraft]),b=(0,i.useCallback)((e,t)=>{var n,s,l;return(0,r.jsx)("li",{children:a(r4[e.code],{line:null!=(n=e.line)?n:0,key:null!=(s=e.key)?s:""})},"".concat(e.code,"-").concat(null!=(l=e.line)?l:"file","-").concat(t))},[a]);return(0,r.jsxs)("div",{"data-testid":"env-manager-pane",role:"region","aria-label":a("envManager.title"),className:"flex flex-col h-full min-h-0 bg-background ".concat(n).trim(),children:[(0,r.jsxs)("div",{className:"flex-shrink-0 border-b border-border bg-surface dark:bg-surface-2 p-2 space-y-2",children:[(0,r.jsx)("div",{role:"group","aria-label":a("envManager.filePickerLabel"),className:"flex gap-1 overflow-x-auto scrollbar-hide",children:s.files.map(e=>(0,r.jsxs)(eZ.$,{size:"sm",variant:e.name===s.selectedFile?"primary":"ghost",onClick:()=>s.selectFile(e.name),"aria-pressed":e.name===s.selectedFile,"data-testid":"env-file-".concat(e.name),className:"flex-shrink-0 whitespace-nowrap min-h-[44px] gap-1.5 font-mono text-xs",children:[e.name,!e.exists&&(0,r.jsx)(rh.E,{variant:"gray",children:a("envManager.notCreated")}),e.isExample&&(0,r.jsx)(rh.E,{variant:"info",children:a("envManager.templateBadge")})]},e.name))}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)("div",{role:"group","aria-label":a("envManager.viewModeLabel"),className:"flex gap-1",children:[(0,r.jsx)(eZ.$,{size:"sm",variant:"kv"===l?"primary":"ghost",onClick:()=>s.setMode("kv"),"aria-pressed":"kv"===l,"data-testid":"env-mode-kv",className:"min-h-[44px]",children:a("envManager.viewKeyValue")}),(0,r.jsx)(eZ.$,{size:"sm",variant:"raw"===l?"primary":"ghost",onClick:()=>s.setMode("raw"),"aria-pressed":"raw"===l,"data-testid":"env-mode-raw",className:"min-h-[44px]",children:a("envManager.viewRaw")})]}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,r.jsxs)(eZ.$,{size:"sm",variant:"ghost",onClick:p,"data-testid":"env-toggle-all","aria-pressed":f,className:"min-h-[44px] gap-1.5",children:[f?(0,r.jsx)(rL.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(eC.A,{size:16,"aria-hidden":"true"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:f?a("envManager.hideAll"):a("envManager.revealAll")})]}),(0,r.jsx)(eZ.$,{size:"sm",variant:"ghost",onClick:s.reload,"data-testid":"env-reload","aria-label":a("envManager.reload"),className:"min-h-[44px]",children:(0,r.jsx)(nU.A,{size:16,"aria-hidden":"true"})}),(0,r.jsxs)(eZ.$,{size:"sm",variant:"primary",onClick:s.save,loading:s.saving,disabled:!s.canSave||!s.dirty,"data-testid":"env-save",className:"min-h-[44px] gap-1.5",children:[(0,r.jsx)(rR.A,{size:16,"aria-hidden":"true"}),a("envManager.save")]})]})]})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto p-2 space-y-3",children:[(0,r.jsx)("p",{"data-testid":"env-description",className:"text-xs text-muted-foreground",children:a("envManager.description")}),s.loading&&(0,r.jsxs)("div",{className:"flex items-center gap-2 p-4 text-sm text-muted-foreground",children:[(0,r.jsx)(u.y,{size:"sm"}),a("envManager.loading")]}),s.error&&(0,r.jsx)("div",{role:"alert","data-testid":"env-error",className:"rounded-md border border-danger-border bg-danger-subtle p-2 text-sm text-danger-foreground",children:a("envManager.loadError")}),!s.loading&&s.detail&&!s.detail.exists&&(0,r.jsx)("p",{"data-testid":"env-not-created",className:"rounded-md border border-border bg-muted p-2 text-xs text-muted-foreground",children:a("envManager.notCreatedHint",{file:s.selectedFile})}),s.saved&&!s.dirty&&(0,r.jsx)("p",{"data-testid":"env-saved",className:"text-xs text-success-foreground",children:a("envManager.saved")}),h.length>0&&(0,r.jsxs)("div",{role:"alert","data-testid":"env-errors",className:"rounded-md border border-danger-border bg-danger-subtle p-2 text-xs text-danger-foreground",children:[(0,r.jsxs)("p",{className:"flex items-center gap-1.5 font-medium",children:[(0,r.jsx)(rP.A,{size:14,"aria-hidden":"true"}),a("envManager.validationFailed")]}),(0,r.jsx)("ul",{className:"mt-1 list-disc pl-5 space-y-0.5",children:h.map(b)})]}),x.length>0&&(0,r.jsx)("div",{"data-testid":"env-warnings",className:"rounded-md border border-warning-border bg-warning-subtle p-2 text-xs text-warning-foreground",children:(0,r.jsx)("ul",{className:"list-disc pl-5 space-y-0.5",children:x.map(b)})}),!s.loading&&"kv"===l&&(0,r.jsxs)("div",{"data-testid":"env-kv-view",className:"space-y-2",children:[0===o.length&&(0,r.jsx)("p",{"data-testid":"env-empty",className:"px-1 py-4 text-center text-sm text-muted-foreground",children:a("envManager.empty")}),o.map(e=>{let t=d.has(e.key);return(0,r.jsxs)("div",{"data-testid":"env-row","data-env-key":e.key,className:"flex flex-col gap-1 rounded-md border border-border bg-surface dark:bg-surface-2 p-2 sm:flex-row sm:items-center sm:gap-2",children:[(0,r.jsx)(rF.p,{inputSize:"sm",value:e.key,onChange:t=>s.updateRow(e.id,{key:t.target.value}),"aria-label":a("envManager.keyLabel"),spellCheck:!1,autoComplete:"off","data-testid":"env-row-key",className:"font-mono text-xs sm:w-2/5"}),(0,r.jsxs)("div",{className:"flex flex-1 items-center gap-1",children:[(0,r.jsx)(rF.p,{inputSize:"sm",readOnly:!t,value:t?e.value:r1(e.value),onChange:t=>s.updateRow(e.id,{value:t.target.value}),"aria-label":a("envManager.valueLabel",{key:e.key}),spellCheck:!1,autoComplete:"off","data-testid":"env-row-value","data-masked":t?"false":"true",className:"flex-1 font-mono text-xs"}),(0,r.jsx)(eZ.$,{size:"sm",variant:"ghost",onClick:()=>s.toggleReveal(e.key),"aria-label":t?a("envManager.hideValue",{key:e.key}):a("envManager.showValue",{key:e.key}),"aria-pressed":t,"data-testid":"env-row-reveal",className:"".concat(r2," min-h-[44px]"),children:t?(0,r.jsx)(rL.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(eC.A,{size:16,"aria-hidden":"true"})}),(0,r.jsx)(eZ.$,{size:"sm",variant:"ghost",onClick:()=>s.removeRow(e.id),"aria-label":a("envManager.removeRow",{key:e.key}),"data-testid":"env-row-remove",className:"".concat(r2," min-h-[44px] text-danger"),children:(0,r.jsx)(nk.A,{size:16,"aria-hidden":"true"})})]})]},e.id)}),(0,r.jsxs)(eZ.$,{size:"sm",variant:"secondary",onClick:()=>s.addRow(),"data-testid":"env-add-row",className:"min-h-[44px] gap-1.5",children:[(0,r.jsx)(aF.A,{size:16,"aria-hidden":"true"}),a("envManager.addRow")]}),s.suggestions.length>0&&(0,r.jsxs)(rD.Zp,{"data-testid":"env-suggestions",className:"mt-3",children:[(0,r.jsxs)(rD.aR,{children:[(0,r.jsx)(rD.ZB,{className:"text-sm",children:a("envManager.suggestionsTitle")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a("envManager.suggestionsHint")})]}),(0,r.jsx)(rD.Wu,{className:"flex flex-wrap gap-2",children:s.suggestions.map(e=>(0,r.jsxs)(eZ.$,{size:"sm",variant:"secondary",onClick:()=>s.addRow({key:e.key,value:e.value}),"data-testid":"env-suggestion-".concat(e.key),className:"min-h-[44px] gap-1.5 font-mono text-xs",children:[(0,r.jsx)(aF.A,{size:14,"aria-hidden":"true"}),e.key,(0,r.jsx)("span",{className:"font-sans text-muted-foreground",children:e.source})]},"".concat(e.source,":").concat(e.key)))})]})]}),!s.loading&&"raw"===l&&(0,r.jsx)("div",{"data-testid":"env-raw-view",className:"space-y-2",children:m?(0,r.jsx)(rO.T,{value:s.rawDraft,onChange:e=>s.setRawDraft(e.target.value),"aria-label":a("envManager.rawLabel"),spellCheck:!1,"data-testid":"env-raw-editor",className:"min-h-[240px] font-mono text-xs"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rO.T,{readOnly:!0,value:g,"aria-label":a("envManager.rawMaskedLabel"),spellCheck:!1,"data-testid":"env-raw-masked",className:"min-h-[240px] font-mono text-xs"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a("envManager.rawMaskedHint",{mask:r0})})]})})]})]})}),r3=[{id:"notes",labelKey:"notes"},{id:"logs",labelKey:"logs"},{id:"agent",labelKey:"agentTab"},{id:"timer",labelKey:"timerTab"},{id:"todo",labelKey:"todoTab"},{id:"skills",labelKey:"skillsTab"},{id:"verification",labelKey:"verificationTab"},{id:"env",labelKey:"envTab"}],r6=(0,i.memo)(function(e){var t,n;let{worktreeId:a,className:s="",selectedAgents:l,onSelectedAgentsChange:o,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:h,maxAgents:x,availableAgents:f,persistToServer:p,onInsertToMessage:g,useInstanceManagement:b=!1,instances:v,onInstancesChange:y,visibleInstanceIds:j,onToggleInstanceVisible:w,modelByInstance:k,verification:N,requestedSubTab:C}=e,S=(0,c.c)("schedule"),[T,E]=(0,i.useState)(null!=(t=null==C?void 0:C.tab)?t:"notes"),I=(0,i.useRef)(null!=(n=null==C?void 0:C.token)?n:null);(0,i.useEffect)(()=>{C&&C.token!==I.current&&(I.current=C.token,E(C.tab))},[C]);let M=(0,i.useCallback)(e=>{E(e)},[]),A=(0,i.useRef)({});(0,i.useEffect)(()=>{var e,t;null==(t=A.current[T])||null==(e=t.scrollIntoView)||e.call(t,{block:"nearest",inline:"nearest"})},[T]);let L=N?r3:r3.filter(e=>"verification"!==e.id);return(0,r.jsxs)("div",{className:"flex flex-col h-full ".concat(s),children:[(0,r.jsx)("div",{className:"flex overflow-x-auto scrollbar-hide border-b border-border bg-surface dark:bg-surface-2 flex-shrink-0",children:L.map(e=>(0,r.jsx)("button",{type:"button",ref:t=>{A.current[e.id]=t},onClick:()=>M(e.id),className:"flex-shrink-0 whitespace-nowrap px-3 py-2 text-sm font-medium transition-colors ".concat(T===e.id?"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 hover:bg-muted"),children:S(e.labelKey)},e.id))}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["notes"===T&&(0,r.jsx)(n2,{worktreeId:a,className:"h-full",onInsertToMessage:g}),"logs"===T&&(0,r.jsx)(aI,{worktreeId:a,className:"h-full",onInsertToMessage:g,instances:v}),"agent"===T&&(b&&v&&y&&j&&w?(0,r.jsx)("div",{className:"h-full overflow-y-auto",children:(0,r.jsx)(az,{worktreeId:a,instances:v,onInstancesChange:y,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:h,visibleInstanceIds:j,onToggleInstanceVisible:w,modelByInstance:k})}):(0,r.jsx)(aA,{worktreeId:a,selectedAgents:l,onSelectedAgentsChange:o,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:h,maxAgents:x,availableAgents:f,persistToServer:p})),"timer"===T&&(0,r.jsx)(aQ,{worktreeId:a,instances:v,selectedAgents:l}),"todo"===T&&(0,r.jsx)(n8,{worktreeId:a,className:"h-full"}),"skills"===T&&(0,r.jsx)(ru,{worktreeId:a,className:"h-full"}),"verification"===T&&N&&(0,r.jsx)(rA,{state:N,className:"h-full"}),"env"===T&&(0,r.jsx)(r5,{worktreeId:a,className:"h-full"})]})]})});var r8=n(2317);let r9=["status","changes","history","advanced"],r7="commandmate:gitPane:",se={activeTab:"".concat(r7,"activeTab"),historyOpen:"".concat(r7,"historyOpen"),advancedOpen:"".concat(r7,"advancedOpen")};function st(e){return"string"==typeof e&&r9.includes(e)}let sn=e=>"boolean"==typeof e,sa=i.useLayoutEffect;function sr(e,t,n){return Math.max(8,Math.min(e,n-t-8))}let ss=(0,i.memo)(function(e){var t,n;let{branches:a,busy:s,actionError:l,hasRunningSession:o,isMobile:d,onCheckout:u}=e,h=(0,c.c)("worktree"),x=(0,c.c)("common"),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(!1),j=(0,i.useRef)(null),w=(0,i.useRef)(null),[k,N]=(0,i.useState)(null),C=a.filter(e=>!e.isCurrent),S=(0,i.useCallback)(()=>{let e=j.current,t=w.current;if(!e||!t)return;let n=e.getBoundingClientRect(),a=t.getBoundingClientRect(),r=window.innerHeight-n.bottom,s=n.top;N({top:sr(r<a.height+4+8&&s>r?n.top-a.height-4:n.bottom+4,a.height,window.innerHeight),left:sr(n.left,a.width,window.innerWidth)})},[]);sa(()=>f?(S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}):void N(null),[f,C.length,S]);let T=(0,i.useCallback)(e=>{y(!1),b({...e}),p(!1)},[]),E=(0,i.useCallback)(()=>{g&&(u(g,v),b(null))},[g,v,u]);return(0,r.jsxs)("div",{className:"relative",ref:j,"data-testid":"branch-checkout-dropdown",children:[(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",onClick:()=>p(e=>!e),disabled:s||0===C.length,className:"flex items-center gap-1 px-2 py-1 text-xs rounded border border-input text-accent-700 dark:text-accent-300 hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"branch-checkout-dropdown-toggle","aria-haspopup":"menu","aria-expanded":f,"aria-label":h("git.checkout.ariaLabel"),children:[h("git.checkout.action"),(0,r.jsx)("span",{"aria-hidden":"true",className:"text-[10px]",children:"▾"})]}),f&&"undefined"!=typeof document&&(0,at.createPortal)((0,r.jsx)("div",{ref:w,className:"fixed z-50 min-w-[12rem] max-w-[calc(100vw-1rem)] max-h-64 overflow-y-auto rounded border border-border bg-surface shadow-lg",style:{top:null!=(t=null==k?void 0:k.top)?t:-9999,left:null!=(n=null==k?void 0:k.left)?n:-9999},role:"menu","data-testid":"branch-checkout-menu",children:0===C.length?(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:h("git.checkout.noBranches")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:C.map(e=>{var t;let n=null!==e.checkedOutWorktreePath;return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>T(e),disabled:s||n,className:"w-full text-left px-3 py-1.5 font-mono text-xs text-foreground hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","aria-label":h("git.checkout.checkoutBranch",{name:e.name}),title:n?h("git.checkout.checkedOutElsewhere",{path:null!=(t=e.checkedOutWorktreePath)?t:""}):void 0,children:[e.name,e.isDefault&&(0,r.jsx)("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:h("git.checkout.defaultBadge")})]})},"".concat(e.isRemote?"r":"l",":").concat(e.name))})})}),document.body),l&&(0,r.jsx)("div",{className:"mt-1 text-xs text-danger-foreground",role:"alert","data-testid":"branch-checkout-error",children:l}),g&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-checkout-confirm",children:(0,r.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,r.jsxs)("h3",{className:"text-sm font-medium text-foreground",children:[h("git.checkout.confirmTitlePrefix"),(0,r.jsx)("span",{className:"font-mono",children:g.name}),h("git.checkout.confirmTitleSuffix")]}),(0,r.jsx)("div",{className:"rounded border border-warning-border bg-warning-subtle px-3 py-2 text-xs text-warning-foreground",role:"alert","data-testid":"branch-history-loss-warning",children:h("git.checkout.historyLossWarning")}),o&&(0,r.jsx)("div",{className:"rounded border border-danger-border bg-danger-subtle px-3 py-2 text-xs text-danger-foreground",role:"alert","data-testid":"branch-session-warning",children:h("git.checkout.runningSessionWarning")}),(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)(m.Sc,{checked:v,onCheckedChange:e=>y(!0===e),"data-testid":"branch-checkout-force"}),h("git.checkout.forceLabel")]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2 ".concat(d?"flex-wrap":""),children:[(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:()=>b(null),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:x("cancel")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:E,disabled:s,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50","data-testid":"branch-checkout-confirm-button",children:h("git.checkout.action")})]})]})})]})}),sl=(0,i.memo)(function(e){let{open:t,onToggle:n,children:a}=e,s=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex flex-col border-t border-border","data-testid":"git-advanced-section",children:[(0,r.jsxs)("button",{type:"button",onClick:n,className:"w-full flex items-center gap-1 px-3 py-2 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground","data-testid":"git-advanced-toggle","aria-expanded":t,children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:t?"▼":"▶"}),s("git.advancedOperations")]}),t&&(0,r.jsx)("div",{className:"flex flex-col","data-testid":"git-advanced-content",children:a})]})}),si=(0,i.createContext)(null);function so(e){let{value:t,children:n}=e;return(0,r.jsx)(si.Provider,{value:t,children:n})}function sc(){let e=(0,i.useContext)(si);if(null===e)throw Error("useGitPaneContext must be used within a GitPaneProvider");return e}let sd=(0,i.memo)(function(e){let{path:t}=e;return(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:t})})}),su={status:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",changes:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",history:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z",advanced:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"},sm={status:"git.tabs.status",changes:"git.tabs.changes",history:"git.tabs.history",advanced:"git.tabs.advanced"},sh=(0,i.memo)(function(e){let{activeTab:t,onTabChange:n}=e,a=(0,c.c)("worktree");return(0,r.jsx)("div",{role:"tablist","aria-label":a("git.paneSections"),"data-testid":"git-pane-mobile-tabs",className:"flex shrink-0 border-b border-border bg-surface sticky top-0 z-30",children:r9.map(e=>{let s=e===t,l=a(sm[e]);return(0,r.jsxs)("button",{type:"button",role:"tab","aria-selected":s,"aria-label":l,"data-testid":"git-tab-".concat(e),onClick:()=>n(e),className:"flex flex-1 flex-col items-center justify-center gap-1 py-2 px-1 text-xs transition-colors border-b-2 ".concat(s?"text-accent-600 dark:text-accent-400 border-accent-500 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground border-transparent hover:text-foreground hover:bg-muted"),children:[(0,r.jsx)(sd,{path:su[e]}),(0,r.jsx)("span",{children:l})]},e)})})});function sx(e){let{activeTab:t,onTabChange:n,className:a="",statusSection:s,quickActionsSection:l,changesSection:i,historySection:o,advancedSection:c}=e,{isMobile:d}=sc();return d?(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden ".concat(a),"data-testid":"git-pane-mobile",children:[(0,r.jsx)(sh,{activeTab:t,onTabChange:n}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col min-h-0","data-testid":"git-pane-mobile-panel","data-active-tab":t,children:["status"===t&&(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0",children:[s,l]}),"changes"===t&&(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:i}),"history"===t&&o,"advanced"===t&&(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:c})]})]}):(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden ".concat(a),"data-testid":"git-pane-desktop",children:[(0,r.jsx)("div",{"data-testid":"git-group-read","data-git-group":"read",className:"border-l-2 border-info-border bg-info-subtle",children:s}),(0,r.jsxs)("div",{"data-testid":"git-group-write","data-git-group":"write",className:"border-l-2 border-input bg-muted/70 dark:bg-muted/30",children:[l,i]}),(0,r.jsx)("div",{"data-testid":"git-group-history","data-git-group":"read",className:"flex-1 flex flex-col min-h-0 border-l-2 border-info-border bg-info-subtle",children:o}),(0,r.jsx)("div",{"data-testid":"git-group-advanced","data-git-group":"advanced",className:"border-l-2 border-t-2 border-input bg-muted/50 dark:bg-muted/40",children:c})]})}let sf={added:"text-success-foreground",modified:"text-warning-foreground",deleted:"text-danger-foreground",renamed:"text-info",untracked:"text-accent-600 dark:text-accent-400",unmerged:"text-warning-foreground"},sp=(0,i.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),sg=(0,i.memo)(function(e){let{onClick:t,disabled:n=!1,testId:a,className:s=""}=e,l=(0,c.c)("worktree");return(0,r.jsxs)("button",{type:"button",disabled:n,onClick:t,className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-info-border text-info-foreground hover:bg-info-subtle disabled:opacity-50 disabled:cursor-not-allowed ".concat(s),"data-testid":a,title:l("git.askAiTooltip"),children:[(0,r.jsx)(n9.A,{size:14,"aria-hidden":"true"}),l("git.askAi")]})}),sb=(0,i.memo)(function(e){let{line:t}=e,n="whitespace-pre font-mono text-xs";return t.startsWith("+")&&!t.startsWith("+++")?n+=" text-success-foreground bg-success-subtle":t.startsWith("-")&&!t.startsWith("---")?n+=" text-danger-foreground bg-danger-subtle":t.startsWith("@@")?n+=" text-info":n+=" text-foreground",(0,r.jsx)("div",{className:n,children:t})}),sv=(0,i.memo)(function(e){let{message:t}=e;return(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-danger-foreground",role:"alert",children:t})}),sy={no_upstream:{badgeKey:"git.currentStatus.noUpstreamBadge",tooltipKey:"git.currentStatus.noUpstreamTooltip"},upstream_gone:{badgeKey:"git.currentStatus.upstreamGoneBadge",tooltipKey:"git.currentStatus.upstreamGoneTooltip"},detached:{badgeKey:"git.currentStatus.detachedBadge",tooltipKey:"git.currentStatus.detachedTooltip"},error:{badgeKey:"git.currentStatus.aheadBehindErrorBadge",tooltipKey:"git.currentStatus.aheadBehindErrorTooltip"}},sj=(0,i.memo)(function(e){var t;let{gitStatus:n,statusLoading:a,statusError:s,onRefresh:l,refreshing:o=!1}=e,{isMobile:d}=sc(),m=(0,c.c)("worktree"),h=(0,tq.Ym)(),x=(0,i.useMemo)(()=>{let e=null==n?void 0:n.lastFetchAt;if(null==e)return m("git.currentStatus.lastFetchNever");let t=(0,tX.fw)(new Date(e).toISOString(),tQ(h));return t?m("git.currentStatus.lastFetch",{relative:t}):m("git.currentStatus.lastFetchNever")},[null==n?void 0:n.lastFetchAt,h,m]),f=n&&!n.aheadBehind&&null!=(t=n.aheadBehindReason)?t:null;return(0,r.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-status-section",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:m("git.currentStatus.title")}),(0,r.jsx)("button",{type:"button",onClick:l,disabled:o,className:"p-1 text-muted-foreground hover:text-foreground rounded disabled:opacity-50","aria-label":o?m("git.currentStatus.refreshing"):m("git.currentStatus.refresh"),"aria-busy":o,"data-testid":"git-status-refresh-button",children:o?(0,r.jsx)(u.y,{size:"sm",variant:"accent"}):(0,r.jsx)(sp,{})})]}),a&&!n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1",role:"status",children:[(0,r.jsx)(u.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:m("git.currentStatus.loading")})]}),s&&!n&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-status-error",children:s}),n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center flex-wrap ".concat(d?"gap-1.5":"gap-2"),children:[(0,r.jsx)("span",{className:"inline-flex items-center max-w-full truncate rounded px-2 py-0.5 text-xs font-mono bg-accent-50 text-accent-700 dark:bg-accent-900/30 dark:text-accent-300","data-testid":"git-status-branch-chip",title:n.currentBranch,children:n.currentBranch}),n.isDirty&&(0,r.jsx)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium bg-warning-subtle text-warning-foreground","data-testid":"git-status-dirty-badge",children:m("git.currentStatus.uncommitted")}),n.aheadBehind&&(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs font-mono bg-muted text-foreground","data-testid":"git-status-ahead-behind",children:[(0,r.jsxs)("span",{title:m("git.currentStatus.aheadTooltip"),children:["↑",n.aheadBehind.ahead]}),(0,r.jsxs)("span",{title:m("git.currentStatus.behindTooltip"),children:["↓",n.aheadBehind.behind]})]}),f&&(0,r.jsx)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium bg-muted text-muted-foreground border border-border","data-testid":"git-status-ahead-behind-reason","data-reason":f,title:m(sy[f].tooltipKey),children:m(sy[f].badgeKey)})]}),(0,r.jsx)("div",{className:"text-[11px] text-muted-foreground","data-testid":"git-status-last-fetch",title:m("git.currentStatus.lastFetchTooltip"),children:x}),n.isBranchMismatch&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 rounded px-2 py-1 text-xs bg-warning-subtle text-warning-foreground border border-warning-border",role:"alert","data-testid":"git-status-mismatch-warning",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"⚠"}),(0,r.jsxs)("span",{children:[m("branchMismatch.changedFrom")," ",(0,r.jsx)("span",{className:"font-medium",children:n.initialBranch})," ",m("branchMismatch.to")," ",(0,r.jsx)("span",{className:"font-medium",children:n.currentBranch})]})]})]})]})}),sw=(0,i.memo)(function(e){let{progressState:t,operation:n,error:a,conflict:s,conflictFiles:l,hasUpstream:o,onFetch:d,onPull:m,onPush:h,onAbort:x,extraActions:f}=e,{isMobile:p}=sc(),g=(0,c.c)("worktree"),b="running"===t,v=null!=a?a:g("git.network.failed"),[y,j]=(0,i.useState)(0);return(0,i.useEffect)(()=>{if(!b)return void j(0);let e=setInterval(()=>j(e=>e+1),1e3);return()=>clearInterval(e)},[b]),(0,r.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-network-section",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:g("git.network.quickActions")}),(0,r.jsxs)("div",{className:"flex items-center ".concat(p?"flex-wrap gap-1.5":"gap-2"),children:[d&&(0,r.jsx)("button",{type:"button",onClick:d,disabled:b,className:"px-2 py-1 text-xs rounded border border-border text-foreground hover:bg-muted disabled:opacity-50","data-testid":"git-fetch-button",children:g("git.network.fetch")}),(0,r.jsx)("button",{type:"button",onClick:m,disabled:b,className:"px-2 py-1 text-xs rounded border border-accent-300 dark:border-accent-700 text-accent-700 dark:text-accent-300 hover:bg-accent-50 dark:hover:bg-accent-900/30 disabled:opacity-50","data-testid":"git-pull-button",children:g("git.network.pull")}),(0,r.jsx)("button",{type:"button",onClick:h,disabled:b,className:"px-2 py-1 text-xs rounded border border-success-border text-success-foreground hover:bg-success-subtle disabled:opacity-50","data-testid":"git-push-button",title:o?void 0:g("git.network.noUpstreamTooltip"),children:g("git.network.push")}),f]}),b&&(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded px-2 py-1 text-xs bg-accent-50 text-accent-800 dark:bg-accent-900/20 dark:text-accent-300 ".concat(p?"sticky top-0 z-40":""),"data-testid":"git-network-progress-bar",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",role:"status","data-testid":"git-network-operation-spinner",children:[(0,r.jsx)(u.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{children:g("git.network.progress",{operation:g("push"===n?"git.network.pushing":"pull"===n?"git.network.pulling":"git.network.fetching"),elapsed:y})})]}),(0,r.jsx)("button",{type:"button",onClick:x,className:"ml-auto px-1.5 py-0.5 rounded border border-accent-400 dark:border-accent-600 hover:bg-accent-100 dark:hover:bg-accent-900/40","data-testid":"git-network-abort-button",children:g("git.network.abort")})]}),"error"===t&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-network-operation-error",children:v}),s&&(0,r.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-network-conflict",children:g("git.network.conflicts",{files:l.join(", ")})})]})}),sk=(0,i.memo)(function(e){let{title:t,testId:n,files:a,actionLabel:s,mode:l,defaultOpen:o,busy:d,onDiff:u,onToggleStage:h,onPreview:x}=e,f=(0,c.c)("worktree"),[p,g]=(0,i.useState)(o),[b,v]=(0,i.useState)(null),[y,j]=(0,i.useState)(null),[w,k]=(0,i.useState)(!1),[N,C]=(0,i.useState)(null),S=(0,i.useCallback)(async e=>{if(b===e){v(null),j(null),C(null);return}v(e),j(null),C(null),k(!0);try{let t=await x(e,l);j(null!=t?t:"")}catch(e){C(f("git.changes.previewFailed"))}finally{k(!1)}},[b,x,l,f]);return(0,r.jsxs)("div",{className:"border-t border-border","data-testid":n,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>g(e=>!e),className:"w-full flex items-center gap-1 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground",children:[(0,r.jsx)("span",{className:"w-4 text-center",children:p?"▼":"▶"}),f("git.changes.listHeader",{title:t,count:a.length})]}),p&&0===a.length&&(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:f("git.changes.empty")}),p&&a.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:a.map(e=>{let t=b===e.path;return(0,r.jsxs)("li",{className:"flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[(0,r.jsx)("span",{className:"inline-block w-16 shrink-0 text-xs font-medium ".concat(sf[e.status]),children:e.status}),(0,r.jsx)("span",{className:"flex-1 truncate font-mono text-xs text-foreground",title:e.path,children:e.path}),(0,r.jsx)("button",{type:"button",onClick:()=>S(e.path),className:"shrink-0 w-5 text-center text-xs text-muted-foreground hover:text-foreground","aria-label":f("git.changes.togglePreview",{path:e.path}),"aria-expanded":t,"data-testid":"git-changes-preview-toggle",children:t?"▼":"▶"}),(0,r.jsx)("button",{type:"button",onClick:()=>u(e.path,l),className:"shrink-0 px-1.5 py-0.5 text-xs text-accent-600 dark:text-accent-400 hover:underline","aria-label":f("git.changes.showDiff",{path:e.path}),"data-testid":"git-changes-diff-button",children:f("git.changes.diff")}),(0,r.jsx)("button",{type:"button",onClick:()=>h(e.path),disabled:d,className:"shrink-0 px-1.5 py-0.5 text-xs rounded border border-input text-foreground hover:bg-muted disabled:opacity-50","aria-label":f("git.changes.fileAction",{action:s,path:e.path}),"data-testid":"git-changes-toggle-button",children:s})]}),t&&(0,r.jsxs)("div",{className:"px-3 pb-2 bg-muted/40","data-testid":"git-changes-inline-preview",children:[w&&(0,r.jsxs)("div",{className:"flex items-center gap-2 py-2",role:"status",children:[(0,r.jsx)(m.y$,{size:"xs",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:f("git.changes.loadingPreview")})]}),N&&(0,r.jsx)("div",{className:"py-2 text-xs text-danger-foreground",role:"alert",children:N}),!w&&!N&&null!==y&&(""===y.trim()?(0,r.jsx)("div",{className:"py-2 text-xs text-muted-foreground",children:f("git.changes.noDiff")}):(0,r.jsxs)("div",{className:"overflow-x-auto",children:[(0,r.jsx)("pre",{className:"text-xs",children:(0,r.jsx)("code",{children:y.split("\n").slice(0,20).map((e,t)=>(0,r.jsx)(sb,{line:e},t))})}),y.split("\n").length>20&&(0,r.jsx)("button",{type:"button",onClick:()=>u(e.path,l),className:"mt-1 text-xs text-accent-600 dark:text-accent-400 hover:underline","data-testid":"git-changes-preview-more",children:f("git.changes.truncated")})]}))]})]},"".concat(e.status,":").concat(e.path))})})]})}),sN=(0,i.memo)(function(e){var t,n,a;let{staged:s,loading:l,error:i,busy:o,commitMessage:d,amend:u,committing:h,commitError:x,onRefresh:f,onDiff:p,onPreview:g,onStage:b,onUnstage:v,onCommitMessageChange:y,onAmendChange:j,onCommit:w,onCommitAndPush:k}=e,{isMobile:N}=sc(),C=(0,c.c)("worktree"),S=null!=(t=null==s?void 0:s.staged)?t:[],T=null!=(n=null==s?void 0:s.unstaged)?n:[],E=null!=(a=null==s?void 0:s.untracked)?a:[],I=!h&&d.trim().length>0&&(S.length>0||u),M=!N;return(0,r.jsxs)("div",{className:"flex flex-col border-b border-border","data-testid":"git-changes-section",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:C("git.changes.title")}),(0,r.jsx)("button",{type:"button",onClick:f,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":C("git.changes.refresh"),children:(0,r.jsx)(sp,{})})]}),l&&!s&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2",role:"status",children:[(0,r.jsx)(m.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:C("git.changes.loading")})]}),i&&!s&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-changes-error",children:i}),s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sk,{title:C("git.changes.staged"),testId:"git-staged-list",files:S,actionLabel:C("git.changes.unstage"),mode:"staged",defaultOpen:M,busy:o,onDiff:p,onPreview:g,onToggleStage:v}),(0,r.jsx)(sk,{title:C("git.changes.unstaged"),testId:"git-unstaged-list",files:T,actionLabel:C("git.changes.stage"),mode:"unstaged",defaultOpen:M,busy:o,onDiff:p,onPreview:g,onToggleStage:b}),(0,r.jsx)(sk,{title:C("git.changes.untracked"),testId:"git-untracked-list",files:E,actionLabel:C("git.changes.stage"),mode:"untracked",defaultOpen:M,busy:o,onDiff:p,onPreview:g,onToggleStage:b}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 px-3 py-2 border-t border-border",children:[(0,r.jsx)("textarea",{value:d,onChange:e=>y(e.target.value),placeholder:C("git.changes.commitMessage"),rows:N?2:3,className:"w-full resize-y rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"git-commit-message","aria-label":C("git.changes.commitMessage")}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)(m.Sc,{checked:u,onCheckedChange:e=>j(!0===e),"data-testid":"git-amend-checkbox"}),C("git.changes.amend")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:w,disabled:!I,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"git-commit-button",children:C(h?"git.changes.committing":"git.changes.commit")}),(0,r.jsx)("button",{type:"button",onClick:k,disabled:!I||o,title:C("git.changes.commitAndPushTooltip"),className:"px-3 py-1 text-xs font-medium rounded border border-accent-600 text-accent-700 dark:text-accent-300 hover:bg-accent-50 dark:hover:bg-accent-900/30 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"git-commit-push-button",children:C("git.changes.commitAndPush")})]})]}),x&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-commit-error",children:x})]})]})]})}),sC=(0,i.memo)(function(e){let{commits:t,isLoading:n,commitError:a,commitListOpen:s,onToggleCommitList:l,onRefresh:o,selectedCommit:d,onCommitSelect:m,inlineDiffCommit:h,inlineFiles:x,inlineFilesLoading:f,inlineFilesError:p,onToggleInlineDiff:g,onInlineDiffFile:b,changedFiles:v,isLoadingFiles:y,detailError:j,selectedFile:w,onFileSelect:k,diffContent:N,isLoadingDiff:C}=e,{isMobile:S}=sc(),T=(0,c.c)("worktree"),[E,I]=(0,i.useState)(!0),[M,A]=(0,i.useState)(!0);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,r.jsxs)("button",{type:"button",onClick:l,className:"flex items-center gap-1 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground",children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:s?"▼":"▶"}),T("git.history.title")]}),(0,r.jsx)("button",{type:"button",onClick:o,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":T("git.history.refresh"),children:(0,r.jsx)(sp,{})})]}),s&&n&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-8",role:"status",children:[(0,r.jsx)(u.y,{size:"lg",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:T("git.history.loading")})]}),s&&a&&!n&&(0,r.jsx)("div",{className:"px-3 py-4 text-sm text-danger-foreground",role:"alert",children:a}),s&&!n&&!a&&0===t.length&&(0,r.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:T("git.history.empty")}),!n&&!a&&t.length>0&&(0,r.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[s&&(0,r.jsx)("div",{className:"overflow-y-auto ".concat(d?"max-h-[40%] shrink-0":"flex-1"),children:(0,r.jsx)("ul",{className:"divide-y divide-border",children:t.map(e=>{let t=h===e.hash;return(0,r.jsxs)("li",{children:[(0,r.jsxs)("div",{className:"flex items-stretch",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>m(e.hash),className:"flex-1 min-w-0 text-left px-3 py-2 text-sm hover:bg-muted transition-colors ".concat(d===e.hash?"bg-accent-50 dark:bg-accent-900/30":""),children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsx)("span",{className:"font-mono text-xs text-accent-600 dark:text-accent-400 shrink-0",children:e.shortHash}),(0,r.jsx)("span",{className:"truncate text-foreground",children:e.message})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:e.author}),(0,r.jsx)("span",{children:new Date(e.date).toLocaleDateString()})]})]}),(0,r.jsx)("button",{type:"button",onClick:()=>g(e.hash),className:"shrink-0 px-2 text-xs text-accent-600 dark:text-accent-400 hover:bg-muted hover:underline","aria-label":T("git.history.viewDiffFor",{hash:e.shortHash}),"aria-expanded":t,"data-testid":"git-commit-view-diff-button",children:t?T("git.history.hideDiff"):T("git.history.viewDiff")})]}),t&&(0,r.jsxs)("div",{className:"border-t border-border bg-muted/40","data-testid":"git-commit-inline-files",children:[f&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-3",role:"status",children:[(0,r.jsx)(u.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:T("git.history.loadingChangedFiles")})]}),p&&(0,r.jsx)(sv,{message:p}),!f&&!p&&0===x.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:T("git.history.noChangedFiles")}),!f&&x.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:x.map(t=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>b(e.hash,t.path),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ".concat(w===t.path&&d===e.hash?"bg-accent-50 dark:bg-accent-900/30":""),"aria-label":T("git.history.showCommitDiff",{path:t.path}),"data-testid":"git-commit-inline-file",children:[(0,r.jsx)("span",{className:"inline-block w-14 font-medium ".concat(sf[t.status]),children:t.status}),(0,r.jsx)("span",{className:"font-mono text-foreground",children:t.path})]})},t.path))})]})]},e.hash)})})}),d&&(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0 border-t border-border",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>I(e=>!e),className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground bg-surface-2 sticky top-0 z-10 cursor-pointer hover:text-foreground",children:[(0,r.jsx)("span",{className:"w-4 text-center",children:E?"▼":"▶"}),T("git.history.changedFiles")]}),E&&(0,r.jsxs)(r.Fragment,{children:[j&&(0,r.jsx)(sv,{message:j}),y&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-4",role:"status",children:[(0,r.jsx)(u.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:T("git.history.loadingChangedFiles")})]}),!y&&!j&&0===v.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:T("git.history.noChangedFiles")}),!y&&v.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:v.map(e=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>k(e.path),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ".concat(w===e.path?"bg-accent-50 dark:bg-accent-900/30":""),children:[(0,r.jsx)("span",{className:"inline-block w-14 font-medium ".concat(sf[e.status]),children:e.status}),(0,r.jsx)("span",{className:"font-mono text-foreground",children:e.path})]})},e.path))})]}),S&&w&&(0,r.jsxs)("div",{className:"border-t border-border",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>A(e=>!e),className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground bg-surface-2 sticky top-0 z-10 cursor-pointer hover:text-foreground",children:[(0,r.jsx)("span",{className:"w-4 text-center",children:M?"▼":"▶"}),T("git.history.diffLabel",{file:w})]}),M&&(0,r.jsxs)(r.Fragment,{children:[C&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-4",role:"status",children:[(0,r.jsx)(u.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:T("git.history.loadingDiff")})]}),!C&&N&&(0,r.jsx)("div",{className:"overflow-x-auto p-2",children:(0,r.jsx)("pre",{className:"text-xs",children:(0,r.jsx)("code",{children:N.split("\n").map((e,t)=>(0,r.jsx)(sb,{line:e},t))})})}),!C&&!N&&!j&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:T("git.history.noDiff")})]})]}),!S&&w&&!j&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground border-t border-border",children:C?T("git.history.loadingDiff"):T("git.history.diffInFilePanel",{file:w})})]})]})]})});function sS(e){return"`"+e+"`"}let sT={local:"git.branches.filterLocal",remote:"git.branches.filterRemote",all:"git.branches.filterAll"},sE=(0,i.memo)(function(e){let{branches:t,include:n,loading:a,error:s,busy:l,actionError:o,onIncludeChange:d,onRefresh:u,onCreate:h,onDelete:x}=e,{isMobile:f,onInsertToMessage:p}=sc(),g=(0,c.c)("worktree"),b=(0,c.c)("common"),[v,y]=(0,i.useState)(!f),[j,w]=(0,i.useState)(!1),[k,N]=(0,i.useState)(""),[C,S]=(0,i.useState)(""),[T,E]=(0,i.useState)(null),[I,M]=(0,i.useState)(!1),A=(0,i.useCallback)(()=>{0!==k.trim().length&&(h(k.trim(),C.trim()||void 0),w(!1),N(""),S(""))},[k,C,h]),L=(0,i.useCallback)(()=>{T&&(x(T.name,I),E(null),M(!1))},[T,I,x]);return(0,r.jsxs)("div",{className:"flex flex-col border-b border-border","data-testid":"git-branches-section",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>y(e=>!e),className:"flex items-center gap-1 text-sm font-medium text-muted-foreground hover:text-foreground",children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:v?"▼":"▶"}),g("git.branches.title")]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>w(!0),className:"px-2 py-0.5 text-xs rounded border border-input text-foreground hover:bg-muted","data-testid":"git-branch-create-open",children:g("git.branches.newButton")}),(0,r.jsx)("button",{type:"button",onClick:u,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":g("git.branches.refresh"),children:(0,r.jsx)(sp,{})})]})]}),v&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex items-center gap-1 px-3 pb-2",children:["local","remote","all"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>d(e),className:"px-2 py-0.5 text-xs rounded ".concat(n===e?"bg-accent-100 text-accent-800 dark:bg-accent-900/40 dark:text-accent-200":"text-muted-foreground hover:bg-muted"),"data-testid":"git-branches-tab-".concat(e),children:g(sT[e])},e))}),a&&0===t.length&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2",role:"status",children:[(0,r.jsx)(m.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:g("git.branches.loading")})]}),s&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-error",children:s}),o&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-action-error",children:o}),!a&&!s&&0===t.length&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-muted-foreground",children:g("git.branches.empty")}),t.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border max-h-64 overflow-y-auto",children:t.map(e=>{let t=l||e.isCurrent||e.isDefault;return(0,r.jsxs)("li",{className:"flex items-center gap-2 px-3 py-1.5","data-testid":"git-branch-row",children:[(0,r.jsxs)("span",{className:"flex-1 truncate font-mono text-xs text-foreground",title:e.name,children:[e.isCurrent&&(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400 mr-1",children:"●"}),e.name,e.isDefault&&(0,r.jsx)("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:g("git.branches.defaultBadge")})]}),(0,r.jsx)("button",{type:"button",onClick:()=>{M(!1),E(e)},disabled:t,className:"shrink-0 px-1.5 py-0.5 text-xs rounded border border-input text-danger-foreground hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","aria-label":g("git.branches.deleteBranch",{name:e.name}),children:g("git.branches.delete")})]},"".concat(e.isRemote?"r":"l",":").concat(e.name))})})]}),j&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-create-modal",children:(0,r.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:g("git.branches.createTitle")}),(0,r.jsx)("input",{type:"text",value:k,onChange:e=>N(e.target.value),placeholder:g("git.branches.namePlaceholder"),className:"w-full rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"branch-create-name-input","aria-label":g("git.branches.nameLabel")}),(0,r.jsxs)("select",{value:C,onChange:e=>S(e.target.value),className:"w-full rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"branch-create-from-select","aria-label":g("git.branches.baseLabel"),children:[(0,r.jsx)("option",{value:"",children:g("git.branches.currentHead")}),t.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},"from:".concat(e.isRemote?"r":"l",":").concat(e.name)))]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[p&&(0,r.jsx)(sg,{className:"mr-auto",testId:"branch-create-ask-ai",disabled:0===k.trim().length,onClick:()=>{p(function(e,t,n){let a=n&&n.trim().length>0?sS(n.trim()):e("git.aiPrompts.branchCreateBaseHead");return e("git.aiPrompts.branchCreate",{base:a,name:sS(t.trim())})}(g,k,C)),w(!1)}}),(0,r.jsx)("button",{type:"button",onClick:()=>w(!1),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:b("cancel")}),(0,r.jsx)("button",{type:"button",onClick:A,disabled:l||0===k.trim().length,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"branch-create-submit",children:g("git.branches.create")})]})]})}),T&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-delete-confirm",children:(0,r.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,r.jsxs)("h3",{className:"text-sm font-medium text-foreground",children:[g("git.branches.deleteTitlePrefix"),(0,r.jsx)("span",{className:"font-mono",children:T.name}),g("git.branches.deleteTitleSuffix")]}),(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)(m.Sc,{checked:I,onCheckedChange:e=>M(!0===e),"data-testid":"branch-delete-force"}),g("git.branches.forceDeleteLabel")]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[p&&T&&(0,r.jsx)(sg,{className:"mr-auto",testId:"branch-delete-ask-ai",onClick:()=>{p(g(I?"git.aiPrompts.branchDeleteForce":"git.aiPrompts.branchDelete",{name:sS(T.name)})),E(null),M(!1)}}),(0,r.jsx)("button",{type:"button",onClick:()=>E(null),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:b("cancel")}),(0,r.jsx)("button",{type:"button",onClick:L,disabled:l,className:"px-3 py-1 text-xs font-medium rounded bg-danger text-white hover:bg-danger/90 disabled:opacity-50","data-testid":"branch-delete-confirm-button",children:g("git.branches.delete")})]})]})})]})}),sI=(0,i.memo)(function(e){let{stashes:t,loading:n,error:a,busy:s,actionError:l,conflictNotice:o,hasRunningSession:d,onRefresh:u,onPush:h,onPop:x,onApply:f,onDrop:p}=e,{isMobile:g,onInsertToMessage:b}=sc(),v=(0,c.c)("worktree"),y=(0,c.c)("common"),[j,w]=(0,i.useState)(!g),[k,N]=(0,i.useState)(""),[C,S]=(0,i.useState)(!1),[T,E]=(0,i.useState)(null);return(0,r.jsxs)("div",{className:"border-b border-border","data-testid":"git-stash-section",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>w(e=>!e),className:"flex items-center gap-1 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground",children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:j?"▼":"▶"}),v("git.stash.titlePrefix"),t.length>0&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:v("git.stash.count",{count:t.length})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[j&&b&&t.length>0&&(0,r.jsx)(sg,{testId:"stash-cleanup-ask-ai",onClick:()=>b(function(e,t){let n=e("git.aiPrompts.stashCleanup");if(0===t.length)return n;let a=t.map(e=>"- stash@{".concat(e.index,"}: ").concat(e.message)).join("\n");return"".concat(n,"\n\n").concat(e("git.aiPrompts.stashCleanupCurrent"),"\n").concat(a)}(v,t))}),(0,r.jsx)("button",{type:"button",onClick:u,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":v("git.stash.refresh"),children:(0,r.jsx)(sp,{})})]})]}),j&&(0,r.jsxs)("div",{className:"px-3 pb-3 space-y-2",children:[a&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-stash-error",children:a}),l&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-stash-action-error",children:l}),o&&(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-stash-conflict",children:o}),b&&(0,r.jsx)(sg,{className:"shrink-0",testId:"stash-conflict-ask-ai",onClick:()=>b(function(e,t){let n=e("git.aiPrompts.stashConflict");return t&&t.trim().length>0?"".concat(n,"\n\n").concat(t.trim()):n}(v,o))})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,r.jsx)("input",{type:"text",value:k,onChange:e=>N(e.target.value),placeholder:v("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,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,r.jsx)(m.Sc,{checked:C,onCheckedChange:e=>S(!0===e),"data-testid":"git-stash-include-untracked"}),v("git.stash.includeUntracked")]}),(0,r.jsx)("button",{type:"button",disabled:s,onClick:()=>{h(k,C),N(""),S(!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:v("git.stash.push")})]})]}),n?(0,r.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",role:"status",children:v("git.stash.loading")}):0===t.length?(0,r.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",children:v("git.stash.empty")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:t.map(e=>(0,r.jsx)("li",{className:"py-1.5","data-testid":"git-stash-row",children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("span",{className:"font-mono text-xs text-accent-600 dark:text-accent-400",children:["stash@","{",e.index,"}"]}),(0,r.jsx)("span",{className:"ml-2 text-xs text-foreground truncate",children:e.message})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)("button",{type:"button",disabled:s,onClick:()=>f(e.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:v("git.stash.apply")}),(0,r.jsx)("button",{type:"button",disabled:s,onClick:()=>x(e.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:v("git.stash.pop")}),(0,r.jsx)("button",{type:"button",disabled:s,onClick:()=>E(e.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:v("git.stash.drop")})]})]})},e.index))})]}),null!==T&&(0,r.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,r.jsxs)("p",{className:"text-xs text-danger-foreground",children:["stash@","{",T,"}",v("git.stash.dropConfirmSuffix")]}),d&&(0,r.jsx)("p",{className:"mt-1 text-xs text-danger-foreground","data-testid":"git-stash-drop-session-warning",children:v("git.danger.runningSessionWarning")}),(0,r.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",disabled:s,onClick:()=>{p(T),E(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:v("git.stash.drop")}),(0,r.jsx)("button",{type:"button",onClick:()=>E(null),className:"px-2 py-1 text-xs rounded border border-input hover:bg-muted",children:y("cancel")})]})]})]})}),sM={soft:"git.danger.modeSoft",mixed:"git.danger.modeMixed",hard:"git.danger.modeHard"},sA=(0,i.memo)(function(e){let{selectedCommit:t,busy:n,actionError:a,conflictNotice:s,currentBranch:l,aheadCount:o,hasRunningSession:d,onReset:u,onRevert:h,onForcePush:x}=e,{isMobile:f,onInsertToMessage:p}=sc(),g=(0,c.c)("worktree"),b=(0,c.c)("common"),[v,y]=(0,i.useState)(!1),[j,w]=(0,i.useState)("mixed"),[k,N]=(0,i.useState)(!0),[C,S]=(0,i.useState)(""),[T,E]=(0,i.useState)(!1),[I,M]=(0,i.useState)(!1),[A,L]=(0,i.useState)(!1),[R,P]=(0,i.useState)(!1),[D,F]=(0,i.useState)(!0),O=k?"HEAD":t,z=!k&&!t;return(0,r.jsxs)("div",{className:"border-t-2 border-danger-border","data-testid":"git-danger-zone-section",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>y(e=>!e),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,r.jsx)("span",{className:"text-xs w-4 text-center",children:v?"▼":"▶"}),g("git.danger.title")]}),v&&(0,r.jsxs)("div",{className:"px-3 py-3 space-y-2 bg-danger-subtle",children:[a&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-danger-zone-error",children:a}),s&&(0,r.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-danger-zone-conflict",children:s}),(0,r.jsxs)("div",{className:"flex ".concat(f?"flex-col":"flex-row"," gap-2"),children:[(0,r.jsx)("button",{type:"button",onClick:()=>E(!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:g("git.danger.resetOpen")}),(0,r.jsx)("button",{type:"button",disabled:!t,onClick:()=>M(!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:g("git.danger.revertOpen")}),x&&(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>P(!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:g("git.danger.forcePushOpen")})]}),!t&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:g("git.danger.selectCommitHint")})]}),T&&(0,r.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"reset-confirm",role:"dialog",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:g("git.danger.resetTitle")}),(0,r.jsxs)(m.z6,{value:k?"head":"commit",onValueChange:e=>N("head"===e),name:"reset-target",className:"flex flex-col gap-1 mb-2",children:[(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,r.jsx)(m.CU,{value:"head","data-testid":"reset-target-head"}),g("git.danger.resetTargetHead")]}),(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,r.jsx)(m.CU,{value:"commit",disabled:!t,"data-testid":"reset-target-commit"}),g("git.danger.resetTargetSelectedPrefix"),t?g("git.danger.resetTargetSelectedHash",{hash:t.slice(0,7)}):g("git.danger.resetTargetNoneSelected")]})]}),(0,r.jsx)(m.z6,{value:j,onValueChange:e=>w(e),name:"reset-mode",className:"flex flex-col gap-1 mb-2",children:["soft","mixed","hard"].map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,r.jsx)(m.CU,{value:e,"data-testid":"reset-mode-".concat(e)}),g(sM[e])]},e))}),"hard"===j&&(0,r.jsxs)("div",{className:"mb-2 space-y-1",children:[(0,r.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-history-loss-warning",children:g("git.danger.resetHardWarning")}),d&&(0,r.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-session-warning",children:g("git.danger.runningSessionWarning")}),(0,r.jsx)("input",{type:"text",value:C,onChange:e=>S(e.target.value),placeholder:g("git.danger.confirmPlaceholder",{branch:null!=l?l:""}),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,r.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,r.jsx)(sg,{className:"mr-auto",testId:"reset-ask-ai",disabled:z,onClick:()=>{O&&(p("hard"===j?g("git.aiPrompts.resetHard",{target:sS(O)}):g("git.aiPrompts.reset",{target:sS(O),mode:j})),E(!1),S(""))}}),(0,r.jsx)("button",{type:"button",disabled:n||z||"hard"===j&&C!==(null!=l?l:""),onClick:()=>{O&&(u(O,j,"hard"===j?C:void 0),E(!1),S(""))},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:g("git.danger.reset")}),(0,r.jsx)("button",{type:"button",onClick:()=>{E(!1),S("")},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:b("cancel")})]})]}),I&&t&&(0,r.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"revert-confirm",role:"dialog",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:g("git.danger.revertTitle")}),(0,r.jsxs)("p",{className:"text-xs text-foreground mb-2",children:[g("git.danger.revertBodyPrefix"),(0,r.jsx)("span",{className:"font-mono",children:t.slice(0,7)})]}),d&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"revert-session-warning",children:g("git.danger.runningSessionWarning")}),(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,r.jsx)(m.Sc,{checked:A,onCheckedChange:e=>L(!0===e),"data-testid":"revert-no-commit"}),g("git.danger.revertNoCommit")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,r.jsx)(sg,{className:"mr-auto",testId:"revert-ask-ai",onClick:()=>{p(g("git.aiPrompts.revert",{commit:sS(t.slice(0,7))})),M(!1),L(!1)}}),(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>{h(t,A),M(!1),L(!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:g("git.danger.revert")}),(0,r.jsx)("button",{type:"button",onClick:()=>{M(!1),L(!1)},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:b("cancel")})]})]}),R&&x&&(0,r.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"force-push-confirm",role:"dialog",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:g("git.danger.forcePushTitle")}),(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-protected-branch-warning",children:g("git.danger.protectedBranchWarning")}),d&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-session-warning",children:g("git.danger.runningSessionWarning")}),(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,r.jsx)(m.Sc,{checked:D,onCheckedChange:e=>F(!0===e),"data-testid":"force-push-with-lease"}),g("git.danger.forceWithLease")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,r.jsx)(sg,{className:"mr-auto",testId:"force-push-ask-ai",onClick:()=>{p(function(e,t){let{branch:n,ahead:a}=t,r=n?sS(n):e("git.aiPrompts.forcePushCurrentBranch");return e("number"==typeof a&&a>0?"git.aiPrompts.forcePushAhead":"git.aiPrompts.forcePush",{branchRef:r,upstream:sS("origin/".concat(null!=n?n:"<branch>")),ahead:null!=a?a:0})}(g,{branch:l,ahead:null!=o?o:null})),P(!1)}}),(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>{x(D),P(!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:g("git.danger.forcePush")}),(0,r.jsx)("button",{type:"button",onClick:()=>P(!1),className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:b("cancel")})]})]})]})}),sL=(0,i.memo)(function(e){var t,n,a,s;let{worktreeId:l,onDiffSelect:o,isMobile:d=!1,worktree:u,onInsertToMessage:h,className:x=""}=e,f=(0,c.c)("worktree"),{activeTab:p,setActiveTab:g,historyOpen:b,toggleHistory:v,advancedOpen:y,toggleAdvanced:j}=function(){let{value:e,setValue:t,isAvailable:n}=(0,r8.V)({key:se.activeTab,defaultValue:"status",validate:st}),{value:a,setValue:r}=(0,r8.V)({key:se.historyOpen,defaultValue:!0,validate:sn}),{value:s,setValue:l}=(0,r8.V)({key:se.advancedOpen,defaultValue:!1,validate:sn}),o=(0,i.useCallback)(e=>t(e),[t]);return{activeTab:e,setActiveTab:o,historyOpen:a,toggleHistory:(0,i.useCallback)(()=>r(e=>!e),[r]),advancedOpen:s,toggleAdvanced:(0,i.useCallback)(()=>l(e=>!e),[l]),isPersistent:n}}(),w=Object.values(null!=(n=null==u?void 0:u.sessionStatusByCli)?n:{}).some(e=>(null==e?void 0:e.isRunning)===!0),{gitStatus:k,statusLoading:N,statusError:C,fetchStatus:S}=function(e){let[t,n]=(0,i.useState)(null),[a,r]=(0,i.useState)(!0),[s,l]=(0,i.useState)(null),o=(0,i.useCallback)(async()=>{l(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/status"));if(!t.ok){let e=await t.json().catch(()=>({}));l(e.error||"Failed to fetch git status");return}let a=await t.json();n(a)}catch(e){l("Failed to fetch git status")}finally{r(!1)}},[e]);return(0,i.useEffect)(()=>{o()},[o]),{gitStatus:t,statusLoading:a,statusError:s,fetchStatus:o}}(l),{commits:T,selectedCommit:E,changedFiles:I,inlineDiffCommit:M,inlineFiles:A,inlineFilesLoading:L,inlineFilesError:R,selectedFile:P,diffContent:D,isLoading:F,isLoadingFiles:O,isLoadingDiff:z,commitError:_,detailError:B,setDiffContent:V,fetchCommits:W,handleCommitSelect:H,handleFileSelect:U,handleToggleInlineDiff:K,handleInlineDiffFile:$,handleRefresh:q}=function(e,t){let[n,a]=(0,i.useState)([]),[r,s]=(0,i.useState)(null),[l,o]=(0,i.useState)([]),[c,d]=(0,i.useState)(null),[u,m]=(0,i.useState)([]),[h,x]=(0,i.useState)(!1),[f,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)(!0),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(!1),[T,E]=(0,i.useState)(null),[I,M]=(0,i.useState)(null),A=(0,i.useCallback)(async()=>{w(!0),E(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/log"));if(!t.ok){let e=await t.json();E(e.error||"Failed to fetch commit history");return}let n=await t.json();a(n.commits)}catch(e){E("Failed to fetch commit history")}finally{w(!1)}},[e]),L=(0,i.useCallback)(async t=>{N(!0),o([]),b(null),y(null),M(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/show/").concat(t));if(!n.ok){let e=await n.json();M(e.error||"Failed to fetch commit details");return}let a=await n.json();o(a.files)}catch(e){M("Failed to fetch commit details")}finally{N(!1)}},[e]),R=(0,i.useCallback)(async(n,a)=>{S(!0),y(null),M(null);try{let r=await fetch("/api/worktrees/".concat(e,"/git/diff?commit=").concat(n,"&file=").concat(encodeURIComponent(a)));if(!r.ok){let e=await r.json();M(e.error||"Failed to fetch diff");return}let s=await r.json();y(s.diff),t(s.diff,a)}catch(e){M("Failed to fetch diff")}finally{S(!1)}},[e,t]);(0,i.useEffect)(()=>{A()},[A]);let P=(0,i.useCallback)(e=>{s(e),L(e)},[L]),D=(0,i.useCallback)(e=>{r&&(b(e),R(r,e))},[r,R]),F=(0,i.useCallback)(async t=>{if(c===t){d(null),m([]),p(null);return}d(t),m([]),p(null),x(!0);try{let n=await fetch("/api/worktrees/".concat(e,"/git/show/").concat(t));if(!n.ok){let e=await n.json().catch(()=>({}));p(e.error||"Failed to fetch commit details");return}let a=await n.json();m(Array.isArray(a.files)?a.files:[])}catch(e){p("Failed to fetch commit details")}finally{x(!1)}},[e,c]),O=(0,i.useCallback)((e,t)=>{s(e),b(t),o(u),R(e,t)},[u,R]),z=(0,i.useCallback)(()=>{s(null),o([]),b(null),y(null),M(null),A()},[A]);return{commits:n,selectedCommit:r,changedFiles:l,inlineDiffCommit:c,inlineFiles:u,inlineFilesLoading:h,inlineFilesError:f,selectedFile:g,diffContent:v,isLoading:j,isLoadingFiles:k,isLoadingDiff:C,commitError:T,detailError:I,setDiffContent:y,fetchCommits:A,handleCommitSelect:P,handleFileSelect:D,handleToggleInlineDiff:F,handleInlineDiffFile:O,handleRefresh:z}}(l,o),G=(0,i.useCallback)(async()=>{await W(),await S()},[W,S]),{staged:J,stagedLoading:Y,stagedError:Q,opBusy:X,commitMessage:Z,setCommitMessage:ee,amend:et,setAmend:en,committing:ea,changesCommitError:er,fetchStaged:es,handleStage:el,handleUnstage:ei,handleChangesDiff:eo,fetchWorkingDiffText:ec,commit:ed,commitAndPush:eu}=function(e,t){let{onWorkingDiff:n,onCommitted:a}=t,[r,s]=(0,i.useState)(null),[l,o]=(0,i.useState)(!0),[c,d]=(0,i.useState)(null),[u,m]=(0,i.useState)(!1),[h,x]=(0,i.useState)(""),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(null),j=(0,i.useCallback)(async()=>{d(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/staged"));if(!t.ok){let e=await t.json().catch(()=>({}));d(e.error||"Failed to fetch changes");return}let n=await t.json();s(n)}catch(e){d("Failed to fetch changes")}finally{o(!1)}},[e]);(0,i.useEffect)(()=>{j()},[j]);let w=(0,i.useCallback)(async t=>{m(!0),d(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/stage"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[t]})});if(!n.ok){let e=await n.json().catch(()=>({}));d(e.error||"Failed to stage file");return}await j()}catch(e){d("Failed to stage file")}finally{m(!1)}},[e,j]),k=(0,i.useCallback)(async t=>{m(!0),d(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/unstage"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[t]})});if(!n.ok){let e=await n.json().catch(()=>({}));d(e.error||"Failed to unstage file");return}await j()}catch(e){d("Failed to unstage file")}finally{m(!1)}},[e,j]),N=(0,i.useCallback)(async()=>{y(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/commit"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:h,amend:f})});if(!t.ok){let e=await t.json().catch(()=>({}));return y(e.error||"Failed to commit"),!1}return x(""),p(!1),await j(),await a(),!0}catch(e){return y("Failed to commit"),!1}},[e,h,f,j,a]),C=(0,i.useCallback)(async()=>{b(!0);try{await N()}finally{b(!1)}},[N]),S=(0,i.useCallback)(async e=>{b(!0);try{await N()&&await e()}finally{b(!1)}},[N]);return{staged:r,stagedLoading:l,stagedError:c,opBusy:u,commitMessage:h,setCommitMessage:x,amend:f,setAmend:p,committing:g,changesCommitError:v,fetchStaged:j,handleStage:w,handleUnstage:k,handleChangesDiff:(0,i.useCallback)(async(t,a)=>{try{let r=await fetch("/api/worktrees/".concat(e,"/git/working-diff?file=").concat(encodeURIComponent(t),"&mode=").concat(a));if(!r.ok)return;let s=await r.json();"string"==typeof s.diff&&n(s.diff,t)}catch(e){}},[e,n]),fetchWorkingDiffText:(0,i.useCallback)(async(t,n)=>{try{let a=await fetch("/api/worktrees/".concat(e,"/git/working-diff?file=").concat(encodeURIComponent(t),"&mode=").concat(n));if(!a.ok)return null;let r=await a.json();return"string"==typeof r.diff?r.diff:null}catch(e){return null}},[e]),commit:C,commitAndPush:S}}(l,{onWorkingDiff:(0,i.useCallback)((e,t)=>{V(e),o(e,t)},[V,o]),onCommitted:G}),{branches:em,branchInclude:eh,branchesLoading:ex,branchesError:ef,branchBusy:ep,branchActionError:eg,fetchBranches:eb,handleBranchIncludeChange:ev,handleBranchesRefresh:ey,handleCheckout:ej,handleBranchCreate:ew,handleBranchDelete:ek}=function(e,t){let{onCheckoutCascade:n}=t,[a,r]=(0,i.useState)([]),[s,l]=(0,i.useState)("local"),[o,c]=(0,i.useState)(!0),[d,u]=(0,i.useState)(null),[m,h]=(0,i.useState)(!1),[x,f]=(0,i.useState)(null),p=(0,i.useCallback)(async t=>{u(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/branches?include=").concat(t));if(!n.ok){let e=await n.json().catch(()=>({}));u(e.error||"Failed to fetch branches");return}let a=await n.json();r(Array.isArray(a.branches)?a.branches:[])}catch(e){u("Failed to fetch branches")}finally{c(!1)}},[e]);(0,i.useEffect)(()=>{p(s)},[p,s]);let g=(0,i.useCallback)(e=>{l(e)},[]),b=(0,i.useCallback)(()=>{p(s)},[p,s]),v=(0,i.useCallback)(async(t,a)=>{h(!0),f(null);try{let r=await fetch("/api/worktrees/".concat(e,"/git/checkout"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t.name,force:a})});if(!r.ok){let e=await r.json().catch(()=>({}));f(e.error||"Failed to checkout branch");return}await Promise.all([n(),p(s)])}catch(e){f("Failed to checkout branch")}finally{h(!1)}},[e,s,n,p]),y=(0,i.useCallback)(async(t,n)=>{h(!0),f(null);try{let a=await fetch("/api/worktrees/".concat(e,"/git/branch/create"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,from:n})});if(!a.ok){let e=await a.json().catch(()=>({}));f(e.error||"Failed to create branch");return}await p(s)}catch(e){f("Failed to create branch")}finally{h(!1)}},[e,s,p]),j=(0,i.useCallback)(async(t,n)=>{h(!0),f(null);try{let a=await fetch("/api/worktrees/".concat(e,"/git/branch/delete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,force:n})});if(!a.ok){let e=await a.json().catch(()=>({}));f(e.error||"Failed to delete branch");return}await p(s)}catch(e){f("Failed to delete branch")}finally{h(!1)}},[e,s,p]);return{branches:a,branchInclude:s,branchesLoading:o,branchesError:d,branchBusy:m,branchActionError:x,fetchBranches:p,handleBranchIncludeChange:g,handleBranchesRefresh:b,handleCheckout:v,handleBranchCreate:y,handleBranchDelete:j}}(l,{onCheckoutCascade:(0,i.useCallback)(async()=>{await Promise.all([S(),es(),W()])},[S,es,W])}),{stashes:eN,stashLoading:eC,stashError:eS,stashBusy:eT,stashActionError:eE,stashConflictNotice:eI,fetchStash:eM,handleStashPush:eA,handleStashPop:eL,handleStashApply:eR,handleStashDrop:eP}=function(e,t){let{onStashMutated:n}=t,[a,r]=(0,i.useState)([]),[s,l]=(0,i.useState)(!0),[o,c]=(0,i.useState)(null),[d,u]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),[x,f]=(0,i.useState)(null),p=(0,i.useCallback)(async()=>{c(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/stash"));if(!t.ok){let e=await t.json().catch(()=>({}));c(e.error||"Failed to fetch stashes");return}let n=await t.json();r(Array.isArray(n.stashes)?n.stashes:[])}catch(e){c("Failed to fetch stashes")}finally{l(!1)}},[e]);(0,i.useEffect)(()=>{p()},[p]);let g=(0,i.useCallback)(async()=>{await Promise.all([p(),n()])},[p,n]),b=(0,i.useCallback)(async(e,t,n)=>{u(!0),h(null),f(null);try{let a=await fetch(e,t),r=await a.json().catch(()=>({}));if(!a.ok)return void h(r.error||n);if(r.conflict){let e=Array.isArray(r.conflictFiles)?r.conflictFiles.join(", "):"",t=r.stashRetained?" (stash retained)":"";f("Stash operation produced conflicts: ".concat(e).concat(t))}await g()}catch(e){h(n)}finally{u(!1)}},[g]),v=(0,i.useCallback)((t,n)=>{b("/api/worktrees/".concat(e,"/git/stash/push"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t||void 0,includeUntracked:n})},"Failed to stash changes")},[e,b]),y=(0,i.useCallback)(t=>{b("/api/worktrees/".concat(e,"/git/stash/pop"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:t})},"Failed to pop stash")},[e,b]);return{stashes:a,stashLoading:s,stashError:o,stashBusy:d,stashActionError:m,stashConflictNotice:x,fetchStash:p,handleStashPush:v,handleStashPop:y,handleStashApply:(0,i.useCallback)(t=>{b("/api/worktrees/".concat(e,"/git/stash/apply"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:t})},"Failed to apply stash")},[e,b]),handleStashDrop:(0,i.useCallback)(t=>{b("/api/worktrees/".concat(e,"/git/stash/").concat(t),{method:"DELETE"},"Failed to drop stash")},[e,b])}}(l,{onStashMutated:(0,i.useCallback)(async()=>{await Promise.all([S(),es()])},[S,es])}),{dangerBusy:eD,dangerActionError:eF,dangerConflictNotice:eO,handleReset:ez,handleRevert:e_}=function(e,t){let{onHeadMoved:n}=t,[a,r]=(0,i.useState)(!1),[s,l]=(0,i.useState)(null),[o,c]=(0,i.useState)(null);return{dangerBusy:a,dangerActionError:s,dangerConflictNotice:o,handleReset:(0,i.useCallback)(async(t,a,s)=>{r(!0),l(null),c(null);try{let r=await fetch("/api/worktrees/".concat(e,"/git/reset"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:t,mode:a,confirmBranch:s})});if(!r.ok){let e=await r.json().catch(()=>({}));l(e.error||"Failed to reset");return}await n()}catch(e){l("Failed to reset")}finally{r(!1)}},[e,n]),handleRevert:(0,i.useCallback)(async(t,a)=>{r(!0),l(null),c(null);try{let r=await fetch("/api/worktrees/".concat(e,"/git/revert"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitHash:t,noCommit:a})});if(!r.ok){let e=await r.json().catch(()=>({}));l(e.error||"Failed to revert");return}let s=await r.json().catch(()=>({}));if(s.conflict){let e=Array.isArray(s.conflictFiles)?s.conflictFiles.join(", "):"";c("Revert produced conflicts: ".concat(e))}await n()}catch(e){l("Failed to revert")}finally{r(!1)}},[e,n])}}(l,{onHeadMoved:(0,i.useCallback)(async()=>{await Promise.all([S(),es(),eb(eh),W()])},[S,es,eb,eh,W])}),{operation:eB,progressState:eV,error:eW,errorReason:eH,conflict:eU,conflictFiles:eK,runFetch:e$,runPull:eq,runPush:eG,abort:eJ}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{onCascade:n}=t,[a,r]=(0,i.useState)(null),[s,l]=(0,i.useState)("idle"),[o,c]=(0,i.useState)(null),[d,u]=(0,i.useState)(null),[m,h]=(0,i.useState)(!1),[x,f]=(0,i.useState)([]),p=(0,i.useRef)(null),g=(0,i.useRef)(n);(0,i.useEffect)(()=>{g.current=n},[n]),(0,i.useEffect)(()=>()=>{var e;null==(e=p.current)||e.abort()},[]);let b=(0,i.useCallback)(async(t,n,a)=>{var s,i,o;c(null),u(null),h(!1),f([]),r(t),l("running");let d=new AbortController;p.current=d;try{let r=await fetch("/api/worktrees/".concat(e,"/git/").concat(n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:d.signal});if(!r.ok){let e=await r.json().catch(()=>({}));u((s=null==e?void 0:e.reason,"auth_failed"===s?"auth_failed":"protected_branch"===s?"protected_branch":null)),c((i=null==e?void 0:e.error,"string"==typeof i&&i.length>0?i:null)),l("error");return}let o=await r.json().catch(()=>({success:!0}));"pull"===t&&(null==o?void 0:o.conflict)&&(h(!0),f(Array.isArray(o.conflictFiles)?o.conflictFiles:[])),l("idle")}catch(e){e instanceof Error&&"AbortError"===e.name?l("idle"):(c(null),u(null),l("error"))}finally{r(null),p.current=null,null==(o=g.current)||o.call(g,t)}},[e]),v=(0,i.useCallback)(e=>{let t={prune:!0===e.prune};return void 0!==e.remote&&(t.remote=e.remote),b("fetch","fetch",t)},[b]),y=(0,i.useCallback)(e=>{let t={rebase:!0===e.rebase,ffOnly:!0===e.ffOnly};return void 0!==e.remote&&(t.remote=e.remote),void 0!==e.branch&&(t.branch=e.branch),b("pull","pull",t)},[b]);return{operation:a,progressState:s,error:o,errorReason:d,conflict:m,conflictFiles:x,runFetch:v,runPull:y,runPush:(0,i.useCallback)(e=>{let t={force:!0===e.force,forceWithLease:!0===e.forceWithLease,setUpstream:!0===e.setUpstream};return void 0!==e.remote&&(t.remote=e.remote),void 0!==e.branch&&(t.branch=e.branch),b("push","push",t)},[b]),abort:(0,i.useCallback)(()=>{var e;null==(e=p.current)||e.abort()},[])}}(l,{onCascade:(0,i.useCallback)(e=>{S(),eb(eh),"pull"===e&&(es(),W())},[S,eb,eh,es,W])}),eY="auth_failed"===eH?f("git.network.authFailedGuidance"):"protected_branch"===eH?f("git.danger.protectedBranchWarning"):eW,eQ="running"===eV&&("push"===eB||"pull"===eB),eX=(null==k?void 0:k.aheadBehind)!=null,eZ=(0,i.useCallback)(()=>{e$({})},[e$]),e0=(0,i.useCallback)(()=>eu(()=>eG({setUpstream:!eX})),[eu,eG,eX]);nV({intervalMs:5e3,enabled:"running"!==eV,onPoll:S});let e1=(0,i.useMemo)(()=>({isMobile:d,onDiffSelect:o,onInsertToMessage:h}),[d,o,h]),e2=(0,r.jsx)(sj,{gitStatus:k,statusLoading:N,statusError:C,onRefresh:eZ,refreshing:"running"===eV}),e4=(0,r.jsx)(sw,{progressState:eV,operation:eB,error:eY,conflict:eU,conflictFiles:eK,hasUpstream:eX,onPull:()=>eq({}),onPush:()=>eG({setUpstream:!eX}),onAbort:eJ,extraActions:(0,r.jsx)(ss,{branches:em,busy:ep||eQ,actionError:eg,hasRunningSession:w,isMobile:d,onCheckout:ej})}),e5=(0,r.jsx)(sN,{staged:J,loading:Y,error:Q,busy:X||eQ,commitMessage:Z,amend:et,committing:ea,commitError:er,onRefresh:es,onDiff:eo,onPreview:ec,onStage:el,onUnstage:ei,onCommitMessageChange:ee,onAmendChange:en,onCommit:ed,onCommitAndPush:e0}),e3=(0,r.jsx)(sC,{commits:T,isLoading:F,commitError:_,commitListOpen:b,onToggleCommitList:v,onRefresh:q,selectedCommit:E,onCommitSelect:H,inlineDiffCommit:M,inlineFiles:A,inlineFilesLoading:L,inlineFilesError:R,onToggleInlineDiff:K,onInlineDiffFile:$,changedFiles:I,isLoadingFiles:O,detailError:B,selectedFile:P,onFileSelect:U,diffContent:D,isLoadingDiff:z}),e6=(0,r.jsxs)(sl,{open:y,onToggle:j,children:[(0,r.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-advanced-fetch",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:f("git.remote")}),(0,r.jsx)("div",{children:(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:()=>e$({}),disabled:"running"===eV,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:f("git.network.fetch")})})]}),(0,r.jsx)(sE,{branches:em,include:eh,loading:ex,error:ef,busy:ep||eQ,actionError:eg,onIncludeChange:ev,onRefresh:ey,onCreate:ew,onDelete:ek}),(0,r.jsx)(sI,{stashes:eN,loading:eC,error:eS,busy:eT||eQ,actionError:eE,conflictNotice:eI,hasRunningSession:w,onRefresh:eM,onPush:eA,onPop:eL,onApply:eR,onDrop:eP}),(0,r.jsx)(sA,{selectedCommit:E,busy:eD||eQ,actionError:eF,conflictNotice:eO,currentBranch:null!=(a=null==k?void 0:k.currentBranch)?a:null,aheadCount:null!=(s=null==k||null==(t=k.aheadBehind)?void 0:t.ahead)?s:null,hasRunningSession:w,onReset:ez,onRevert:e_,onForcePush:e=>eG(e?{forceWithLease:!0}:{force:!0})})]});return(0,r.jsx)(so,{value:e1,children:(0,r.jsx)(sx,{activeTab:p,onTabChange:g,className:x,statusSection:e2,quickActionsSection:e4,changesSection:e5,historySection:e3,advancedSection:e6})})}),sR=(0,i.memo)(function(e){let{worktreeId:t,worktree:n,onWorktreeUpdate:a}=e,[s,l]=(0,i.useState)(!1),o=(0,c.c)("worktree"),d=(0,i.useRef)(null==n?void 0:n.id),u=(0,i.useRef)(!1),m=s_(n,a,null==n?void 0:n.id,()=>{let e=(null==n?void 0:n.id)!==d.current;return d.current=null==n?void 0:n.id,e&&!u.current});return(u.current=m.isEditing,n)?(0,r.jsx)("div",{className:"p-4 space-y-4 overflow-y-auto h-full",children:(0,r.jsx)(sB,{worktreeId:t,worktree:n,cardClassName:"bg-surface rounded-lg border border-border p-4",descriptionEditor:m,showLogs:s,onToggleLogs:()=>l(!s),onWorktreeUpdate:a})}):(0,r.jsx)("div",{className:"text-muted-foreground text-center py-8",children:o("detail.loadingInfo")})}),sP=(0,i.memo)(function(e){let{activeTab:t,worktreeId:n,worktree:a,messages:s,cliToolId:l,instanceId:i,onFilePathClick:o,onFileSelect:d,onWorktreeUpdate:u,onNewFile:m,onNewDirectory:h,onRename:x,onDelete:f,onUpload:p,onMove:g,onFileTreeReset:b,refreshTrigger:v,fileSearch:y,showToast:j,selectedAgents:w,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:S,vibeLocalModel:E,onVibeLocalModelChange:I,vibeLocalContextWindow:M,onVibeLocalContextWindowChange:A,disableAutoFollow:L,historySubTab:R,onHistorySubTabChange:P,onDiffSelect:D,onInsertToMessage:F,showArchived:O,onShowArchivedChange:z,historyDisplayLimit:_,onHistoryDisplayLimitChange:B,historyUserOnly:V,onHistoryUserOnlyChange:W,useInstanceManagement:H,instances:U,onInstancesChange:K,visibleInstanceIds:$,onToggleInstanceVisible:q,verification:G,toolsSubTabRequest:J}=e,Y=(0,c.c)("worktree");switch(t){case"terminal":return(0,r.jsx)(T,{componentName:"TerminalDisplay",children:(0,r.jsx)(tO,{worktreeId:n,cliToolId:l,instanceId:i,disableAutoFollow:L})});case"history":return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsxs)("div",{className:"flex border-b border-border shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:()=>P("message"),className:"flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ".concat("message"===R?"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:Y("detail.subTabMessage")}),(0,r.jsx)("button",{type:"button",onClick:()=>P("git"),className:"flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ".concat("git"===R?"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:Y("detail.subTabGit")})]}),"message"===R?(0,r.jsx)(T,{componentName:"HistoryPane",children:(0,r.jsx)(ng,{messages:s,worktreeId:n,onFilePathClick:o,className:"flex-1 min-h-0",showToast:j,onInsertToMessage:F,showArchived:O,onShowArchivedChange:z,historyDisplayLimit:_,onHistoryDisplayLimitChange:B,historyUserOnly:V,onHistoryUserOnlyChange:W})}):(0,r.jsx)(T,{componentName:"GitPane",children:(0,r.jsx)(sL,{worktreeId:n,onDiffSelect:D,isMobile:!0,worktree:null!=a?a:void 0,onInsertToMessage:F,className:"flex-1 min-h-0"})})]});case"files":var Q;return(0,r.jsx)(T,{componentName:"FileTreeView",children:(0,r.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,r.jsx)(nJ,{query:y.query,mode:y.mode,isSearching:y.isSearching,error:y.error,onQueryChange:y.setQuery,onModeChange:y.setMode,onClear:y.clearSearch}),(0,r.jsx)(nK,{worktreeId:n,onFileSelect:d,onNewFile:m,onNewDirectory:h,onRename:x,onDelete:f,onUpload:p,onMove:g,onResetView:b,refreshTrigger:v,pollingEnabled:"files"===t,searchQuery:y.query,searchMode:y.mode,searchResults:null==(Q=y.results)?void 0:Q.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,r.jsx)(T,{componentName:"NotesAndLogsPane",children:(0,r.jsx)(r6,{worktreeId:n,className:"h-full",selectedAgents:w,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:S,vibeLocalModel:E,onVibeLocalModelChange:I,vibeLocalContextWindow:M,onVibeLocalContextWindowChange:A,onInsertToMessage:F,useInstanceManagement:H,instances:U,onInstancesChange:K,visibleInstanceIds:$,onToggleInstanceVisible:q,modelByInstance:sz(null==a?void 0:a.sessionStatusByInstance),verification:G,requestedSubTab:J})});case"info":return(0,r.jsx)(sR,{worktreeId:n,worktree:a,onWorktreeUpdate:u});default:return null}}),sD="v".concat("0.27.1"),sF=[{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 sO(e,t){return e?t?"".concat(e," \xb7 ").concat(t):e:null}function sz(e){if(!e)return{};let t={};for(let[n,a]of Object.entries(e)){let e=sO(null==a?void 0:a.model,null==a?void 0:a.reasoningEffort);e&&(t[n]=e)}return t}function s_(e,t,n,a){let[r,s]=(0,i.useState)(!1),[l,o]=(0,i.useState)(""),[c,d]=(0,i.useState)(!1);(0,i.useEffect)(()=>{a()&&e&&(o(e.description||""),s(!1))},[n,e]);let u=(0,i.useCallback)(async()=>{if(e){d(!0);try{let n=await V.y.updateDescription(e.id,l);t(n),s(!1)}catch(e){console.error("Failed to save description:",e)}finally{d(!1)}}},[e,l,t]),m=(0,i.useCallback)(()=>{o((null==e?void 0:e.description)||""),s(!1)},[e]);return{isEditing:r,text:l,setText:o,isSaving:c,handleSave:u,handleCancel:m,startEditing:(0,i.useCallback)(()=>{s(!0)},[])}}let sB=(0,i.memo)(function(e){var t,n;let{worktreeId:a,worktree:s,cardClassName:l,descriptionEditor:o,showLogs:d,onToggleLogs:u,onWorktreeUpdate:h}=e,{isEditing:x,text:f,setText:p,isSaving:g,handleSave:b,handleCancel:v,startEditing:y}=o,j=(0,c.c)("worktree"),w=(0,c.c)("common"),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(!1),T=(0,i.useRef)(void 0),E=(0,i.useRef)(void 0);(0,i.useEffect)(()=>()=>{T.current&&clearTimeout(T.current),E.current&&clearTimeout(E.current)},[]);let I=(0,i.useCallback)(async()=>{try{await (0,ej.l)(s.path),N(!0),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>N(!1),er.pX)}catch(e){}},[s.path]),M=(0,i.useCallback)(async()=>{try{await (0,ej.l)(s.repositoryPath),S(!0),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>S(!1),er.pX)}catch(e){}},[s.repositoryPath]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:l,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:j("detail.worktree")}),(0,r.jsx)("p",{className:"text-lg font-semibold text-foreground",children:s.name})]}),(0,r.jsxs)("div",{className:l,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:j("detail.repository")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:M,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":j("detail.copyRepositoryPath"),title:C?j("detail.copied"):j("detail.copyRepositoryPath"),children:C?(0,r.jsx)(ex.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ep.A,{className:"w-3.5 h-3.5"})})]}),(0,r.jsx)("p",{className:"text-base text-foreground",children:null!=(t=s.repositoryDisplayName)?t:s.repositoryName}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:s.repositoryPath})]}),(0,r.jsxs)("div",{className:l,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:j("detail.path")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:I,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":j("detail.copyWorktreePath"),title:k?j("detail.copied"):j("detail.copyPath"),children:k?(0,r.jsx)(ex.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ep.A,{className:"w-3.5 h-3.5"})})]}),(0,r.jsx)("p",{className:"text-sm text-foreground break-all font-mono",children:s.path})]}),(0,r.jsxs)("div",{className:l,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:j("detail.status")}),(0,r.jsx)("select",{value:null!=(n=s.status)?n:"",onChange:async e=>{let t=e.target.value;try{let e=await fetch("/api/worktrees/".concat(s.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:""===t?null:t})});if(e.ok&&h){let t=await e.json();h(t)}}catch(e){}},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":j("detail.worktreeStatusLabel"),children:sF.map(e=>{var t;return(0,r.jsx)("option",{value:null!=(t=e.value)?t:"",children:j(e.labelKey)},e.labelKey)})})]}),(0,r.jsxs)("div",{className:l,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:j("detail.description")}),!x&&(0,r.jsx)("button",{type:"button",onClick:y,className:"text-sm text-accent-600 hover:text-accent-800 dark:text-accent-400 dark:hover:text-accent-300",children:j("actions.edit")})]}),x?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("textarea",{value:f,onChange:e=>p(e.target.value),placeholder:j("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,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:b,disabled:g,className:"px-4 py-2 bg-accent-600 text-white rounded-lg hover:bg-accent-700 disabled:opacity-50 text-sm font-medium",children:g?j("actions.saving"):j("actions.save")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:v,disabled:g,className:"px-4 py-2 bg-muted text-foreground rounded-lg hover:bg-border disabled:opacity-50 text-sm font-medium",children:w("cancel")})]})]}):(0,r.jsx)("div",{className:"min-h-[50px]",children:s.description?(0,r.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.description}):(0,r.jsx)("p",{className:"text-sm text-muted-foreground italic",children:j("detail.noDescription")})})]}),s.link&&(0,r.jsxs)("div",{className:l,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:j("detail.link")}),(0,r.jsx)("a",{href:s.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-600 hover:underline break-all",children:s.link})]}),s.updatedAt&&(0,r.jsxs)("div",{className:l,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:j("detail.lastUpdated")}),(0,r.jsx)("p",{className:"text-sm text-foreground",children:new Date(s.updatedAt).toLocaleString()})]}),(0,r.jsx)(e1,{version:sD,className:l}),(0,r.jsx)(e9,{className:l}),(0,r.jsxs)("div",{className:l,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:j("detail.logs")}),(0,r.jsx)("button",{type:"button",onClick:u,className:"text-sm text-accent-600 hover:text-accent-800",children:d?j("detail.hide"):j("detail.show")})]}),d&&(0,r.jsx)(eQ,{worktreeId:a})]})]})}),sV=(0,i.memo)(function(e){var t,n,a,s;let{worktreeName:l,repositoryName:o,description:d,status:u,gitStatus:f,onBackClick:p,onInfoClick:g,hasUpdate:b,worktreeStatus:v,onWorktreeStatusChange:y,sessionStatusByCli:j,sessionStatusByInstance:w,instances:N,activeInstanceId:C,onActiveInstanceChange:S,onAgentDragStart:T,onAgentDragEnd:E,onKillSession:I,verificationChip:M}=e,A=(0,c.c)("worktree"),L=(0,c.c)("common"),R=e$.sb[u],P=R?A(R):void 0,[D,F]=(0,i.useState)(null),O=null==N?void 0:N.find(e=>e.id===C),z=!!C&&null!=(s=null!=(a=null==w||null==(t=w[C])?void 0:t.isRunning)?a:O?null==j||null==(n=j[O.cliTool])?void 0:n.isRunning:void 0)&&s,_=(0,i.useCallback)((e,t)=>{e.dataTransfer.setData(ta,t),e.dataTransfer.effectAllowed="move",F(t),null==T||T(t)},[T]),B=(0,i.useCallback)(()=>{F(null),null==E||E()},[E]),V=d?(0,x.W5)(d,50):null;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-surface border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("button",{type:"button",onClick:p,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":A("detail.goBack"),"data-testid":"worktree-back-button",children:[(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.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,r.jsx)("span",{className:"text-sm font-medium",children:A("detail.home")})]}),(0,r.jsx)("div",{className:"w-px h-6 bg-border","aria-hidden":"true"}),(0,r.jsx)(h.m,{"data-testid":"desktop-status-indicator",status:u,size:"lg",label:P}),(0,r.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold text-foreground truncate max-w-[200px] leading-tight",children:l}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"truncate max-w-[200px]",children:o}),f&&"(unknown)"!==f.currentBranch&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"/"}),(0,r.jsx)("span",{className:"truncate max-w-[150px] font-mono",title:f.currentBranch,"data-testid":"desktop-branch-name",children:(0,x.W5)(f.currentBranch,30)}),f.isDirty&&(0,r.jsx)("span",{className:"text-warning",title:A("git.uncommittedChanges"),children:"*"})]}),V&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"—"}),(0,r.jsx)("span",{className:"truncate max-w-[300px] text-muted-foreground",title:d,children:V})]})]})]}),M&&(0,r.jsx)("div",{className:"min-w-0 max-w-[360px]",children:M})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[N&&N.length>0&&(()=>{var e,t,n,a;let s=(0,eJ.Uw)(N.map(e=>{var t;return{item:e,status:(0,te.kA)(null!=(t=null==w?void 0:w[e.id])?t:null==j?void 0:j[e.cliTool]),isActive:e.id===C}}),4),l=s.filter(e=>"overflow"===e.slot),i=null!=(a=null!=(n=null==(e=l.find(e=>"running"===e.status||"generating"===e.status))?void 0:e.status)?n:null==(t=l.find(e=>"waiting"===e.status))?void 0:t.status)?a:null,o=N.some(e=>{var t,n;return(null==(t=null!=(n=null==w?void 0:w[e.id])?n:null==j?void 0:j[e.cliTool])?void 0:t.awaitingInstruction)===!0});return(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0","data-testid":"desktop-agent-status-row",children:[s.map(e=>{if("overflow"===e.slot)return null;let t=e.item,n=(0,tt.sw)(t),a=A("detail.statusPill",{label:n,status:L("status.".concat(e.status))}),s=null==w?void 0:w[t.id],l=sO(null==s?void 0:s.model,null==s?void 0:s.reasoningEffort),i=l?A("detail.statusPillWithModel",{label:n,status:L("status.".concat(e.status)),model:l}):a,o=e.isActive,c={draggable:!0,onDragStart:e=>_(e,t.id),onDragEnd:B},d=D===t.id?" opacity-50 cursor-grabbing":"";return"pill"===e.slot?(0,r.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-".concat(t.id),onClick:()=>null==S?void 0:S(t.id),...c,"aria-label":i,title:i,"aria-pressed":o,className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ".concat(o?"bg-accent-100 dark:bg-accent-900/30 text-accent-900 dark:text-accent-100":"hover:bg-muted text-foreground").concat(d),children:[(0,r.jsx)(h.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:a})]},t.id):(0,r.jsx)(eq.m_,{content:i,placement:"bottom",children:(0,r.jsx)("button",{type:"button","data-testid":"desktop-agent-status-".concat(t.id),onClick:()=>null==S?void 0:S(t.id),...c,"aria-label":i,"aria-pressed":o,className:"flex items-center justify-center w-6 h-6 rounded-full transition-colors ".concat(o?"bg-accent-100 dark:bg-accent-900/30":"hover:bg-muted").concat(d),children:(0,r.jsx)(h.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0})})},t.id)}),l.length>0&&(0,r.jsxs)(eG.rI,{children:[(0,r.jsx)(eG.ty,{asChild:!0,children:(0,r.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-overflow","aria-label":A("agentStatus.moreAgents",{count:l.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:[i&&(0,r.jsx)(h.m,{status:i,size:"sm","aria-hidden":!0,title:void 0}),"+",l.length]})}),(0,r.jsx)(eG.SQ,{align:"end",children:l.map(e=>{let t=e.item,n=A("detail.statusPill",{label:(0,tt.sw)(t),status:L("status.".concat(e.status))});return(0,r.jsxs)(eG._2,{"data-testid":"desktop-agent-overflow-".concat(t.id),onSelect:()=>null==S?void 0:S(t.id),children:[(0,r.jsx)(h.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:n})]},t.id)})})]}),o&&(0,r.jsx)("span",{"data-testid":"desktop-awaiting-instruction-badge",className:"flex-shrink-0 rounded-full bg-success-subtle px-1.5 py-0.5 text-[10px] font-medium leading-4 text-success-foreground",title:A("awaitingInstruction.label"),children:A("awaitingInstruction.badge")})]})})(),I&&z&&(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",onClick:I,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":A("terminal.endSession"),"data-testid":"desktop-kill-session",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"✕"}),L("end")]}),y&&(0,r.jsx)("select",{value:null!=v?v:"",onChange:e=>{let t=e.target.value;y(""===t?null:t)},onClick:e=>e.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":A("detail.worktreeStatusLabel"),children:sF.map(e=>{var t;return(0,r.jsx)("option",{value:null!=(t=e.value)?t:"",children:A(e.labelKey)},e.labelKey)})}),(0,r.jsx)(ts.g,{}),(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",onClick:g,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":A("detail.viewInfo"),children:[(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.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,r.jsx)("span",{className:"text-sm font-medium",children:A("detail.info")}),b&&(0,r.jsx)(k,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":A("tabs.updateAvailable")})]})]})]})}),sW=(0,i.memo)(function(e){let{worktreeId:t,worktree:n,isOpen:a,onClose:s,onWorktreeUpdate:l}=e,[o,d]=(0,i.useState)(!1),u=(0,c.c)("worktree"),m=(0,i.useRef)(a),h=s_(n,l,a,()=>{let e=a&&!m.current;return m.current=a,e});return n?(0,r.jsx)(e7.a,{isOpen:a,onClose:s,title:u("detail.infoModalTitle"),size:"md",children:(0,r.jsx)("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto","data-testid":"worktree-info-modal",children:(0,r.jsx)(sB,{worktreeId:t,worktree:n,cardClassName:"bg-muted rounded-lg p-4",descriptionEditor:h,showLogs:o,onToggleLogs:()=>d(!o),onWorktreeUpdate:l})})}):null}),sH=(0,i.memo)(function(){let e=(0,c.c)("worktree");return(0,r.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"status","aria-live":"polite",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)(m.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"text-muted-foreground",children:e("detail.loading")})]})})}),sU=(0,i.memo)(function(e){let{message:t,onRetry:n}=e,a=(0,c.c)("worktree"),s=(0,c.c)("common");return(0,r.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"alert","aria-live":"assertive",children:(0,r.jsxs)("div",{className:"text-center p-6 bg-danger-subtle rounded-lg border border-danger-border max-w-md",children:[(0,r.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,r.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,r.jsx)("p",{className:"text-danger-foreground font-medium",children:a("detail.errorLoading")}),(0,r.jsx)("p",{className:"text-danger-foreground/80 text-sm mt-2",children:t}),n&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:n,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:s("retry")})]})})}),sK=(0,i.memo)(function(e){let{activityPane:t,rightPane:n,activityPaneWidth:a=18,minPaneWidth:s=10,maxPaneWidth:l=60,onActivityPaneResize:o,className:d=""}=e,u=(0,i.useRef)(null),m=(0,c.c)("worktree"),[h,x]=(0,i.useState)(a),f=o?a:h,p=(0,i.useCallback)(e=>{let t=u.current;if(!t)return;let n=t.offsetWidth;if(0===n)return;let r=Math.min(l,Math.max(s,(o?a:h)+e/n*100));o?o(r):x(r)},[a,h,s,l,o]),g=(0,i.useMemo)(()=>"flex h-full min-h-0 ".concat(d).trim(),[d]);return(0,r.jsx)("div",{ref:u,className:"h-full",children:(0,r.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:g,children:[null!==t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:"worktree-activity-pane","data-testid":"activity-pane-slot","aria-label":m("desktopLayout.activityPane"),style:{width:"".concat(f,"%")},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,r.jsx)(T,{componentName:"ActivityPane",children:t})}),(0,r.jsx)(ns.f,{onResize:p,orientation:"horizontal",ariaValueNow:f})]}),(0,r.jsx)("div",{id:"worktree-right-pane","data-testid":"right-pane-slot","aria-label":m("desktopLayout.terminalPane"),className:"flex-grow overflow-hidden min-w-0",children:(0,r.jsx)(T,{componentName:"TerminalPane",children:n})})]})})});var s$=n(9540),sq=n(92001),sG=n(39332),sJ=n(11047),sY=n(16485),sQ=n(78192),sX=n(39324),sZ=n(80298),s0=n(55867);let s1=[{id:"files",labelKey:"activityBar.files",icon:sq.A},{id:"git",labelKey:"activityBar.git",icon:sG.A},{id:"notes",labelKey:"activityBar.notes",icon:sJ.A},{id:"schedules",labelKey:"activityBar.schedules",icon:sY.A},{id:"agent",labelKey:"activityBar.agent",icon:sQ.A},{id:"timer",labelKey:"activityBar.timer",icon:sX.A},{id:"todo",labelKey:"activityBar.todo",icon:sZ.A},{id:"skills",labelKey:"activityBar.skills",icon:n9.A},{id:"verification",labelKey:"activityBar.verification",icon:rm.A},{id:"env",labelKey:"activityBar.env",icon:s0.A}],s2=new Set(s1.map(e=>e.id)),s4="files",s5="__closed__";function s3(e){return"".concat("commandmate.worktree.activeActivity-").concat(e)}var s6=n(32916);let s8=(0,i.memo)(function(e){let{active:t,onToggle:n,className:a=""}=e,s=(0,c.c)("worktree"),l=(0,i.useRef)([]),{isOpen:o,toggle:d}=(0,s6.VF)(),u=(0,i.useCallback)((e,t,a)=>{var r,s,i,o;if("Enter"===e.key||" "===e.key){e.preventDefault(),n(a);return}if("ArrowDown"===e.key){e.preventDefault();let n=(t+1)%s1.length;null==(r=l.current[n])||r.focus();return}if("ArrowUp"===e.key){e.preventDefault();let n=(t-1+s1.length)%s1.length;null==(s=l.current[n])||s.focus();return}if("Home"===e.key){e.preventDefault(),null==(i=l.current[0])||i.focus();return}if("End"===e.key){e.preventDefault(),null==(o=l.current[s1.length-1])||o.focus();return}},[n]);return(0,r.jsxs)("div",{"data-testid":"activity-bar",className:"flex flex-col items-stretch w-12 flex-shrink-0 bg-muted border-r border-border ".concat(a).trim(),children:[(0,r.jsx)(eq.m_,{content:s("activityBar.toggleSidebar"),placement:"right",children:(0,r.jsx)("button",{type:"button","data-testid":"activity-bar-toggle-sidebar",onClick:d,"aria-label":s("activityBar.toggleSidebar"),"aria-expanded":o,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,r.jsx)(s$.A,{size:20,"aria-hidden":"true"})})}),(0,r.jsx)("div",{className:"mx-2 my-1 border-b border-border","aria-hidden":"true"}),(0,r.jsx)("div",{id:"worktree-activity-bar",role:"tablist","aria-orientation":"vertical","aria-label":s("activityBar.label"),className:"flex flex-col items-stretch",children:s1.map((e,a)=>{let i=e.icon,o=t===e.id,c=s(e.labelKey);return(0,r.jsx)(eq.m_,{content:c,placement:"right",children:(0,r.jsx)("button",{ref:e=>{l.current[a]=e},type:"button",role:"tab","aria-selected":o,"aria-label":c,"aria-controls":"worktree-activity-pane",tabIndex:o||null===t&&0===a?0:-1,onClick:()=>n(e.id),onKeyDown:t=>u(t,a,e.id),"data-testid":"activity-bar-button-".concat(e.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,r.jsx)("span",{"aria-hidden":"true",className:"flex items-center justify-center h-9 w-9 rounded-md transition-colors ".concat(o?"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,r.jsx)(i,{size:20,"aria-hidden":"true"})})})},e.id)})})]})}),s9="worktree-activity-pane",s7={files:"FileTreeView",git:"GitPane",notes:"MemoPane",schedules:"ExecutionLogPane",agent:"AgentSettingsPane",timer:"TimerPane",todo:"TodoPane",skills:"WorktreeSkillsPane",verification:"VerificationPane",env:"EnvManagerPane"},le=(0,i.memo)(function(e){let{active:t,activities:n,className:a=""}=e;if(null===t)return(0,r.jsx)("div",{id:s9,"data-testid":"activity-pane","data-active":"none",className:"h-full flex flex-col ".concat(a).trim()});let s=n[t],l=s7[t];return(0,r.jsx)("div",{id:s9,"data-testid":"activity-pane","data-active":t,role:"tabpanel","aria-labelledby":"activity-bar-button-".concat(t),className:"h-full flex flex-col min-h-0 ".concat(a).trim(),children:(0,r.jsx)(T,{componentName:l,children:null!=s?s:null})})}),lt=(0,i.memo)(function(e){let{inputRef:t,searchQuery:n,onQueryChange:a,matchCount:s,currentIdx:l,onNextMatch:i,onPrevMatch:o,onClose:d}=e,u=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border-b border-input flex-shrink-0",children:[(0,r.jsx)("input",{ref:t,type:"text",value:n,onChange:e=>a(e.target.value),onKeyDown:e=>{"Escape"===e.key&&d(),"Enter"===e.key&&(e.shiftKey?o():i())},placeholder:u("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,r.jsx)("span",{className:"text-xs text-muted-foreground min-w-[3rem] text-right",children:s>0?"".concat(l+1,"/").concat(s):"0/0"}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:o,disabled:0===s,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":u("fileSearch.prevMatch"),children:"▲"}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:i,disabled:0===s,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":u("fileSearch.nextMatch"),children:"▼"}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white","aria-label":u("fileSearch.close"),children:(0,r.jsx)(ew.A,{className:"w-4 h-4"})})]})}),ln=[{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"]}],la=ln.map(e=>e.extension),lr=[".md",".html",".htm",".yaml",".yml"];ey.j6,ey.j6;var ls=n(40051);function ll(){return(0,r.jsx)("div",{className:"flex items-center justify-center py-12 bg-surface",children:(0,r.jsx)(u.y,{size:"xl",variant:"accent"})})}let li=(0,o.default)(()=>n.e(530).then(n.bind(n,530)).then(e=>({default:e.HtmlPreview})),{loadableGenerated:{webpack:()=>[530]},ssr:!1,loading:()=>(0,r.jsx)(ll,{})}),lo=(0,o.default)(()=>Promise.resolve().then(n.bind(n,27307)).then(e=>({default:e.PdfPreview})),{loadableGenerated:{webpack:()=>[27307]},ssr:!1,loading:()=>(0,r.jsx)(ll,{})}),lc=(0,o.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(ll,{})}),ld=/^---\s*\nmarp:\s*true/;function lu(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,r.jsx)(u.y,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"ml-3 text-muted-foreground",children:e("fileViewer.loading")})]})}function lm(e){let{error:t}=e;return(0,r.jsx)("div",{className:"bg-danger-subtle border border-danger-border rounded-lg p-4 m-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-5 h-5 text-danger-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsx)("p",{className:"text-sm text-danger-foreground",children:t})]})})}function lh(e){let{filePath:t,isMaximized:n,onToggleMaximize:a,copyableContent:s,onSearch:l}=e,o=(0,c.c)("worktree"),[d,u]=(0,i.useState)(!1),[m,h]=(0,i.useState)(!1),x=(0,i.useRef)(null),f=(0,i.useRef)(null);(0,i.useEffect)(()=>()=>{x.current&&clearTimeout(x.current),f.current&&clearTimeout(f.current)},[]);let p=async()=>{try{await (0,ej.l)(t),u(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>u(!1),er.pX)}catch(e){}},g=async()=>{if(s)try{await (0,ej.l)(s),h(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>h(!1),er.pX)}catch(e){}};return(0,r.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border gap-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)("button",{type:"button",onClick:p,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":o("actions.copyFilePath"),title:o("actions.copyPath"),children:d?(0,r.jsx)(ex.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ep.A,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",title:t,children:t})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[l&&(0,r.jsx)("button",{type:"button",onClick:l,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":o("actions.searchInFile"),title:o("actions.search"),children:(0,r.jsx)(z.A,{className:"w-3.5 h-3.5"})}),s&&(0,r.jsx)("button",{type:"button",onClick:g,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":o("actions.copyFileContent"),title:o("actions.copyContent"),children:m?(0,r.jsx)(ex.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ef.A,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("button",{type:"button",onClick:a,className:"flex-shrink-0 p-1.5 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":o(n?"actions.minimize":"actions.maximize"),title:o(n?"actions.minimize":"actions.maximize"),children:n?(0,r.jsx)(ek.A,{className:"w-4 h-4"}):(0,r.jsx)(eN.A,{className:"w-4 h-4"})})]})]})}function lx(e){var t;let{content:n,extension:a,searchMatches:s,searchCurrentIdx:l,totalLines:o,rangeStart:c,worktreeId:d,filePath:u,onLineRangeFetched:m}=e,h=(0,i.useRef)(null),x=(0,i.useMemo)(()=>n.split("\n"),[n]),f=Math.max(1,null!=c?c:1),p=x.length,g=Math.max(null!=o?o:p,p),b=(0,i.useRef)(new Map);(0,i.useEffect)(()=>{b.current.clear()},[n,a]);let v=(0,i.useCallback)(e=>{var t;let n=Math.floor(e/500),r=b.current,s=r.get(n);if(!s){let e=500*n,t=Math.min(e+500,x.length),l=x.slice(e,t).join("\n"),i="";try{i=eO.A.highlight(l,{language:a,ignoreIllegals:!0}).value}catch(e){i=eO.A.highlightAuto(l).value}s=i.split("\n"),r.set(n,s)}return null!=(t=s[e-500*n])?t:""},[x,a]),y=(0,i.useMemo)(()=>new Set(null!=s?s:[]),[s]),j=(null!=(t=null==s?void 0:s.length)?t:0)>0?s[null!=l?l:0]:-1,w=(0,tz.Te)({count:g,getScrollElement:()=>h.current,estimateSize:()=>24,overscan:100});(0,i.useEffect)(()=>{if(!s||0===s.length)return;let e=s[null!=l?l:0];if(!Number.isFinite(e))return;let t=Math.max(0,Math.min(g-1,e-1));w.scrollToIndex(t,{align:"center"})},[l,s,w,g]);let k=w.getVirtualItems();return!function(e){let{virtualItems:t,worktreeId:n,filePath:a,onLineRangeFetched:r,loadedStart:s,loadedLineCount:l}=e,o=(0,i.useRef)(new Set);(0,i.useEffect)(()=>{if(!n||!a||!r||0===t.length)return;let e=t[0].index+1,i=t[t.length-1].index+1,c=s+l-1;if(e>=s&&i<=c)return;let d=Math.max(1,500*Math.floor((e-1)/500)+1),u=d+500-1;o.current.has(d)||(o.current.add(d),fetch("/api/worktrees/".concat(n,"/files/").concat((0,eE.o)(a),"?startLine=").concat(d,"&endLine=").concat(u)).then(async e=>e.ok?e.json():null).then(e=>{o.current.delete(d),e&&!0===e.success&&r({content:e.content,range:e.range,totalLines:e.totalLines,totalBytes:e.totalBytes})}).catch(()=>{o.current.delete(d)}))},[t,n,a,r,s,l])}({virtualItems:k,worktreeId:d,filePath:u,onLineRangeFetched:m,loadedStart:f,loadedLineCount:p}),(0,r.jsx)("div",{className:"overflow-auto h-full",ref:h,"data-testid":"file-content-code",children:(0,r.jsx)("div",{style:{height:w.getTotalSize(),width:"100%",position:"relative"},children:k.map(e=>{let t=e.index+1,n=t-f,a=n>=0&&n<p,s=t===j,l=y.has(t),i=a?v(n):"";return(0,r.jsxs)("div",{"data-line":t,"data-index":e.index,ref:w.measureElement,className:"absolute left-0 right-0 flex font-mono text-sm ".concat(s?"bg-warning/30":l?"bg-warning/15":""),style:{top:0,transform:"translateY(".concat(e.start,"px)"),height:"".concat(24,"px"),lineHeight:"".concat(24,"px")},children:[(0,r.jsx)("div",{className:"px-3 text-right select-none border-r border-border bg-muted dark:bg-muted/50 whitespace-nowrap ".concat(s||l?"text-warning-foreground":"text-muted-foreground"),style:{minWidth:"4rem"},children:t}),(0,r.jsx)("div",{className:"px-4 text-foreground flex-1 min-w-0 overflow-hidden",children:a?(0,r.jsx)("code",{className:"hljs",style:{padding:0,background:"transparent",whiteSpace:"pre"},dangerouslySetInnerHTML:{__html:i}}):(0,r.jsx)(ls.E,{className:"h-4 w-3/4"})})]},e.key)})})})}function lf(e){let{slides:t,fileName:n}=e,a=(0,c.c)("worktree"),[s,l]=(0,i.useState)(0);return 0===t.length?(0,r.jsx)("div",{className:"p-4 text-muted-foreground",children:a("fileViewer.noSlides",{fileName:n})}):(0,r.jsxs)("div",{className:"h-full flex flex-col","data-testid":"marp-preview",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border bg-muted",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{l(e=>Math.max(0,e-1))},disabled:0===s,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:a("actions.prev")}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground",children:[s+1," / ",t.length]}),(0,r.jsx)("button",{type:"button",onClick:()=>{l(e=>Math.min(t.length-1,e+1))},disabled:s===t.length-1,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:a("actions.next")})]}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,r.jsx)("iframe",{srcDoc:t[s],sandbox:"",title:a("fileViewer.slideTitle",{name:n,number:s+1}),className:"w-full h-full border-0"})})]})}function lp(e){let{marpSlides:t,fileName:n,worktreeId:a,filePath:s,contentText:l,onFileSaved:o,isMaximized:d,onToggleMaximize:u,onDirtyChange:m,onOpenFile:h}=e,x=(0,c.c)("worktree"),[f,p]=(0,i.useState)("slides");return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border bg-muted",children:[(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>p("slides"),className:"px-3 py-1 text-xs font-medium rounded-md transition-colors ".concat("slides"===f?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"),children:x("fileViewer.slides")}),(0,r.jsx)("button",{type:"button",onClick:()=>p("editor"),className:"px-3 py-1 text-xs font-medium rounded-md transition-colors ".concat("editor"===f?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"),children:x("fileViewer.editor")})]}),(0,r.jsx)(lh,{filePath:s,isMaximized:d,onToggleMaximize:u,copyableContent:l})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:"slides"===f?(0,r.jsx)(lf,{slides:t,fileName:n}):(0,r.jsx)(lc,{worktreeId:a,filePath:s,onSave:o,initialViewMode:"split",onDirtyChange:m,onOpenFile:h})})]})}function lg(e){let{children:t,isMaximized:n,onToggle:a,filePath:s}=e;return n?(0,r.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:eT.M.MAXIMIZED_EDITOR},children:[(0,r.jsx)(lh,{filePath:s,isMaximized:n,onToggleMaximize:a}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:t})]}):(0,r.jsx)(r.Fragment,{children:t})}function lb(e){let{tab:t,content:n,worktreeId:a,isMaximized:s,onToggleMaximize:l,onFileSaved:i,onDirtyChange:o,onOpenFile:c}=e,d=eF(n.content);return(0,r.jsxs)(r.Fragment,{children:[!s&&(0,r.jsx)(lh,{filePath:t.path,isMaximized:s,onToggleMaximize:l,copyableContent:n.content,onSearch:d.openSearch}),d.searchOpen&&(0,r.jsx)(lt,{inputRef:d.searchInputRef,searchQuery:d.searchQuery,onQueryChange:d.setSearchQuery,matchCount:d.searchMatches.length,currentIdx:d.searchCurrentIdx,onNextMatch:d.nextMatch,onPrevMatch:d.prevMatch,onClose:d.closeSearch}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:d.searchOpen&&d.searchQuery.length>=2?(0,r.jsx)(lx,{content:n.content,extension:"md",searchMatches:d.searchMatches,searchCurrentIdx:d.searchCurrentIdx}):(0,r.jsx)(lc,{worktreeId:a,filePath:t.path,onSave:i,initialViewMode:"preview",onDirtyChange:o,onOpenFile:c})})]})}function lv(e){var t,n;let{tab:a,content:s,worktreeId:l,isMaximized:o,onToggleMaximize:c,onLoadContent:d}=e,u=eF(s.content),m=(0,i.useCallback)(e=>{var t;d&&d(a.path,{...s,content:e.content,totalLines:e.totalLines,totalBytes:null!=(t=e.totalBytes)?t:s.totalBytes,range:e.range})},[d,a.path,s]),h=void 0!==s.range&&(null!=(n=s.totalLines)?n:0)>s.range.end-s.range.start+1;return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lh,{filePath:a.path,isMaximized:o,onToggleMaximize:c,copyableContent:s.content,onSearch:u.openSearch}),u.searchOpen&&(0,r.jsx)(lt,{inputRef:u.searchInputRef,searchQuery:u.searchQuery,onQueryChange:u.setSearchQuery,matchCount:u.searchMatches.length,currentIdx:u.searchCurrentIdx,onNextMatch:u.nextMatch,onPrevMatch:u.prevMatch,onClose:u.closeSearch}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(lx,{content:s.content,extension:s.extension,searchMatches:u.searchOpen?u.searchMatches:void 0,searchCurrentIdx:u.searchOpen?u.searchCurrentIdx:void 0,totalLines:s.totalLines,rangeStart:null==(t=s.range)?void 0:t.start,worktreeId:h?l:void 0,filePath:h?a.path:void 0,onLineRangeFetched:h?m:void 0})})]})}let ly=(0,i.memo)(function(e){var t,n,a,s;let{tab:l,worktreeId:o,onLoadContent:d,onLoadError:u,onSetLoading:m,onFileSaved:h,onDirtyChange:x,onOpenFile:f}=e,p=(0,c.c)("worktree"),g=(0,i.useRef)(p);g.current=p;let b=(0,i.useRef)(!1),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)(!1);!function(e){let{tab:t,worktreeId:n,onLoadContent:a}=e,r=(0,i.useRef)(null),s=(0,i.useRef)(a);s.current=a;let l=(0,i.useRef)(t.path);l.current=t.path,nV({intervalMs:5e3,enabled:function(e){if(null===e.content||e.loading||e.isDirty||e.content.isPdf)return!1;let{totalBytes:t}=e.content;return void 0===t||!(t>=1048576)}(t),onPoll:async()=>{let e="/api/worktrees/".concat(n,"/files/").concat((0,eE.o)(l.current)),t={};r.current&&(t["If-Modified-Since"]=r.current);try{let n=await fetch(e,{headers:t});if(304===n.status||!n.ok)return;r.current=n.headers.get("Last-Modified");let a=await n.json();s.current(l.current,a)}catch(e){}}})}({tab:l,worktreeId:o,onLoadContent:d});let k=(0,i.useMemo)(()=>x?e=>x(l.path,e):void 0,[x,l.path]),N=(0,i.useCallback)(()=>{w(e=>!e)},[]);(0,i.useEffect)(()=>{if(!j)return;let e=e=>{"Escape"===e.key&&w(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[j]),(0,i.useEffect)(()=>{null!==l.content||l.loading||null!==l.error||b.current||(b.current=!0,m(l.path,!0),(async()=>{try{let t=await fetch("/api/worktrees/".concat(o,"/files/").concat((0,eE.o)(l.path)));if(304===t.status)return;if(!t.ok){var e;let n=await t.json(),a="string"==typeof n.error?n.error:(null==(e=n.error)?void 0:e.message)||g.current("fileViewer.loadError");u(l.path,a);return}let n=await t.json();d(l.path,n)}catch(e){u(l.path,e instanceof Error?e.message:g.current("fileViewer.loadError"))}finally{b.current=!1}})())},[l.content,l.loading,l.error,l.path,o,d,u,m]);let C=null!=(a=null==(t=l.content)?void 0:t.content)?a:null,S=null!=(s=null==(n=l.content)?void 0:n.extension)?s:null;if((0,i.useEffect)(()=>{if(!C||"md"!==S||!ld.test(C)||C.length>1e6)return void y(null);let e=!1;return(async()=>{try{let t=await fetch("/api/worktrees/".concat(o,"/marp-render"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:C})});if(t.ok){let n=await t.json();e||y(Array.isArray(n.slides)?n.slides:null)}}catch(e){}})(),()=>{e=!0}},[C,S,o]),l.loading)return(0,r.jsx)(lu,{});if(l.error)return(0,r.jsx)(lm,{error:l.error});if(!l.content)return null;let{content:T}=l;return T.isImage?(0,r.jsx)(lg,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lh,{filePath:l.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(ed.a,{src:T.content,alt:T.path,mimeType:T.mimeType})})]})}):T.isVideo?(0,r.jsx)(lg,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lh,{filePath:l.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(eu.u,{src:T.content,mimeType:T.mimeType})})]})}):T.isPdf?(0,r.jsx)(lg,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lh,{filePath:l.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(lo,{dataUri:T.content,filePath:l.path})})]})}):T.isHtml?(0,r.jsx)(lg,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lh,{filePath:l.path,isMaximized:j,onToggleMaximize:N,copyableContent:T.content}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(li,{worktreeId:o,filePath:l.path,htmlContent:T.content,onFileSaved:h,onOpenFile:f})})]})}):"md"===T.extension?(0,r.jsx)(lg,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:v?(0,r.jsx)(lp,{marpSlides:v,fileName:l.name,worktreeId:o,filePath:l.path,contentText:T.content,onFileSaved:h,isMaximized:j,onToggleMaximize:N,onDirtyChange:k,onOpenFile:f}):(0,r.jsx)(lb,{tab:l,content:T,worktreeId:o,isMaximized:j,onToggleMaximize:N,onFileSaved:h,onDirtyChange:k,onOpenFile:f})})}):!function(e){if(!e)return!1;let t=e.toLowerCase();return lr.includes(t)}("."+T.extension)?(0,r.jsx)(lg,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)(lv,{tab:l,content:T,worktreeId:o,isMaximized:j,onToggleMaximize:N,onLoadContent:d})}):(0,r.jsx)(lg,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:(0,r.jsx)(lb,{tab:l,content:T,worktreeId:o,isMaximized:j,onToggleMaximize:N,onFileSaved:h,onDirtyChange:k,onOpenFile:f})})})});function lj(e,t,n){if(t<=0||n<=0)return 0;let a=e+t+8-n;return a>0?-Math.min(a,Math.max(0,e-8)):e<8?8-e:0}let lw=(0,i.memo)(function(e){let{tab:t,isActive:n,onActivate:a,onClose:s}=e,l=(0,c.c)("worktree"),o=(0,i.useCallback)(()=>{n||a(t.path)},[n,a,t.path]),d=(0,i.useCallback)(e=>{e.stopPropagation(),s(t.path)},[s,t.path]),u=n?"border-accent-500 text-accent-600 dark:text-accent-400 bg-surface":"border-transparent text-muted-foreground hover:text-foreground";return(0,r.jsxs)("div",{"data-testid":"file-tab-".concat(t.path),"data-active":n,onClick:o,className:"flex items-center gap-1 px-3 py-2 text-sm font-medium border-b-2 cursor-pointer flex-shrink-0 ".concat(u),children:[(0,r.jsx)("span",{className:"truncate max-w-[120px]",title:t.path,children:t.name}),t.isDirty&&(0,r.jsx)("span",{"data-testid":"file-tab-dirty-".concat(t.path),className:"w-2 h-2 rounded-full bg-warning flex-shrink-0",title:l("fileTabs.unsavedChanges")}),(0,r.jsx)("button",{type:"button",onClick:d,className:"ml-1 p-0.5 rounded-sm hover:bg-muted transition-colors","aria-label":l("fileTabs.closeTab",{name:t.name}),children:(0,r.jsx)(ew.A,{className:"w-3 h-3"})})]})}),lk=(0,i.memo)(function(e){let{tabs:t,activeIndex:n,worktreeId:a,onClose:s,onActivate:l,onLoadContent:o,onLoadError:c,onSetLoading:d,onFileSaved:u,onDirtyChange:m,onMoveToFront:h,onOpenFile:x}=e,[f,p]=(0,i.useState)(!1),g=(0,i.useRef)(null),b=(0,i.useRef)(null),v=(0,i.useRef)({x:0,y:0}),[y,j]=(0,i.useState)({x:0,y:0}),w=null!==n&&n>=0&&n<t.length?t[n]:null,k=t.length>5?t.slice(0,5):t,N=t.length>5?t.slice(5):[];(0,i.useEffect)(()=>{if(!f)return;let e=e=>{g.current&&!g.current.contains(e.target)&&p(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[f]),(0,i.useLayoutEffect)(()=>{let e=e=>{v.current=e,j(t=>t.x===e.x&&t.y===e.y?t:e)};if(!f)return void e({x:0,y:0});let t=b.current;if(!t)return;let n=t.getBoundingClientRect();e({x:lj(n.left-v.current.x,n.width,window.innerWidth),y:lj(n.top-v.current.y,n.height,window.innerHeight)})},[f]);let C=(0,i.useCallback)(e=>{p(!1),null==h||h(e)},[h]),S=(0,i.useCallback)(()=>{p(e=>!e)},[]);return(0,r.jsxs)("div",{className:"flex flex-col h-full",children:[(0,r.jsxs)("div",{className:"flex border-b border-border bg-surface dark:bg-surface-2 min-w-0",children:[(0,r.jsx)("div",{className:"flex min-w-0 overflow-hidden flex-1",children:k.map((e,t)=>(0,r.jsx)(lw,{tab:e,isActive:t===n,onActivate:l,onClose:s},e.path))}),N.length>0&&(0,r.jsxs)("div",{className:"relative flex-shrink-0",ref:g,children:[(0,r.jsxs)("button",{type:"button","data-testid":"tab-dropdown-button",onClick:S,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,r.jsx)(tn.A,{className:"w-3 h-3 transition-transform ".concat(f?"rotate-180":"")}),(0,r.jsxs)("span",{children:["+",N.length]})]}),f&&(0,r.jsx)("div",{ref:b,"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!==y.x||0!==y.y?{transform:"translate(".concat(y.x,"px, ").concat(y.y,"px)")}:void 0,children:N.map(e=>(0,r.jsxs)("button",{type:"button","data-testid":"tab-dropdown-item-".concat(e.path),onClick:()=>C(e.path),className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-muted truncate",title:e.path,children:[e.name,e.isDirty&&(0,r.jsx)("span",{className:"ml-1 w-2 h-2 inline-block rounded-full bg-warning"})]},e.path))})]})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:w&&(0,r.jsx)(ly,{tab:w,worktreeId:a,onLoadContent:o,onLoadError:c,onSetLoading:d,onFileSaved:u,onDirtyChange:m,onOpenFile:x},w.path)})]})}),lN=(0,i.memo)(function(e){let{line:t}=e,n="whitespace-pre font-mono text-xs leading-5";return t.startsWith("+")&&!t.startsWith("+++")?n+=" text-success-foreground bg-success-subtle":t.startsWith("-")&&!t.startsWith("---")?n+=" text-danger-foreground bg-danger-subtle":t.startsWith("@@")?n+=" text-info bg-info/10":t.startsWith("diff --git")||t.startsWith("index ")||t.startsWith("---")||t.startsWith("+++")?n+=" text-muted-foreground":n+=" text-foreground",(0,r.jsx)("div",{className:n,children:t})}),lC=(0,i.memo)(function(e){let{diff:t,filePath:n,onClose:a}=e,s=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"h-full flex flex-col bg-surface",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-muted shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-accent-600 dark:text-accent-400 shrink-0",children:s("diffViewer.badge")}),(0,r.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:n})]}),(0,r.jsx)("button",{type:"button",onClick:a,className:"p-1 text-muted-foreground hover:text-foreground rounded shrink-0","aria-label":s("diffViewer.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto p-2",children:(0,r.jsx)("pre",{className:"text-xs",children:(0,r.jsx)("code",{children:t.split("\n").map((e,t)=>(0,r.jsx)(lN,{line:e},t))})})})]})}),lS="commandmate.worktree.filePanelCollapsed",lT="commandmate:filePanelStateChange";function lE(){let[e,t]=(0,i.useState)(!1),n=(0,i.useRef)(e);n.current=e,(0,i.useEffect)(()=>{t(function(){try{let e=window.localStorage.getItem(lS);if("true"===e)return!0}catch(e){}return!1}())},[]),(0,i.useEffect)(()=>{let e=e=>{e.detail&&e.detail.collapsed!==n.current&&t(e.detail.collapsed)};return window.addEventListener(lT,e),()=>window.removeEventListener(lT,e)},[]);let a=(0,i.useCallback)(e=>{t(e);try{window.localStorage.setItem(lS,String(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(lT,{detail:{collapsed:e}}))}catch(e){}},[]);return{collapsed:e,toggle:(0,i.useCallback)(()=>{a(!n.current)},[a]),setCollapsed:a}}let lI=(0,i.memo)(function(e){let{terminal:t,terminalHeader:n,fileTabs:a,worktreeId:s,onCloseTab:l,onActivateTab:o,onLoadContent:d,onLoadError:u,onSetLoading:m,onFileSaved:h,diffContent:x,diffFilePath:f,onCloseDiff:p,onDirtyChange:g,onMoveToFront:b,onOpenFile:v}=e,y=(0,c.c)("worktree"),j=(0,i.useRef)(null),[w,k]=(0,i.useState)(50),{collapsed:N,toggle:C}=lE(),S=(0,i.useCallback)(e=>{let t=j.current;if(!t)return;let n=t.offsetWidth;if(0===n)return;let a=e/n*100;k(e=>Math.min(80,Math.max(20,e+a)))},[]),T=(0,i.useMemo)(()=>({width:"".concat(w,"%")}),[w]),E=(0,i.useMemo)(()=>({width:"".concat(100-w,"%")}),[w]),I=(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[n,(0,r.jsx)("div",{className:"flex-1 min-h-0",children:t})]});return a.tabs.length>0||x&&f?N?(0,r.jsxs)("div",{ref:j,className:"flex h-full min-h-0",children:[(0,r.jsx)("div",{"data-testid":"terminal-pane",style:{width:"calc(100% - ".concat(36,"px)")},className:"flex-shrink-0 overflow-hidden",children:I}),(0,r.jsx)("div",{"data-testid":"file-panel-expand-bar",style:{width:"".concat(36,"px")},className:"flex-shrink-0 flex items-start justify-center bg-muted border-l border-border",children:(0,r.jsxs)("button",{type:"button","aria-label":y("terminal.showFiles"),title:y("terminal.showFiles"),onClick:C,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,r.jsx)("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),(0,r.jsx)("span",{className:"text-xs font-medium tracking-wide select-none",style:{writingMode:"vertical-rl"},"aria-hidden":"true",children:y("terminal.filesLabel")})]})})]}):(0,r.jsxs)("div",{ref:j,className:"flex h-full min-h-0",children:[(0,r.jsx)("div",{"data-testid":"terminal-pane",style:T,className:"flex-shrink-0 overflow-hidden",children:I}),(0,r.jsx)(ns.f,{onResize:S,orientation:"horizontal",ariaValueNow:w}),(0,r.jsxs)("div",{"data-testid":"file-panel-pane",style:E,className:"flex-grow overflow-hidden flex",children:[(0,r.jsx)("button",{type:"button","aria-label":y("terminal.hideFiles"),title:y("terminal.hideFiles"),onClick:C,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,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),(0,r.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:x&&f&&p?(0,r.jsx)(lC,{diff:x,filePath:f,onClose:p}):(0,r.jsx)(lk,{tabs:a.tabs,activeIndex:a.activeIndex,worktreeId:s,onClose:l,onActivate:o,onLoadContent:d,onLoadError:u,onSetLoading:m,onFileSaved:h,onDirtyChange:g,onMoveToFront:b,onOpenFile:v})})]})]}):(0,r.jsx)("div",{className:"h-full",children:I})});var lM=n(7125),lA=n(22509),lL=n(54485),lR=n(70198);let lP={splits:[{cliToolId:"claude",instanceId:"claude"}],widths:[1]},lD=new Set(tt.XH);function lF(e){return"".concat("commandmate:terminalSplits:").concat(e)}function lO(e){return"object"==typeof e&&null!==e}function lz(e){let t=e[0];return t?{splits:[{cliToolId:t.cliTool,instanceId:t.id}],widths:[1]}:{splits:lP.splits.map(e=>({...e})),widths:[...lP.widths]}}function l_(e){let t=e.reduce((e,t)=>e+t,0);return t>0?e.map(e=>e/t):e.map(()=>1/e.length)}function lB(e,t){let n;if(0===t.length)return e;let a=new Map(t.map(e=>[e.id,e.cliTool])),r=new Set,s=Math.min(Math.max(e.splits.length,1),t.length,3),l=[];for(let t of e.splits){if(l.length>=s)break;let e=a.get(t.instanceId);e&&!r.has(t.instanceId)&&(r.add(t.instanceId),l.push({cliToolId:e,instanceId:t.instanceId}))}for(let e of t){if(l.length>=s)break;r.has(e.id)||(r.add(e.id),l.push({cliToolId:e.cliTool,instanceId:e.id}))}return(0===l.length&&l.push({cliToolId:t[0].cliTool,instanceId:t[0].id}),l.length===e.splits.length&&l.every((t,n)=>t.instanceId===e.splits[n].instanceId&&t.cliToolId===e.splits[n].cliToolId))?e:(n=l.length===e.widths.length?l_(e.widths):l.length<e.widths.length?l_(e.widths.slice(0,l.length)):Array.from({length:l.length},()=>1/l.length),{splits:l,widths:n})}function lV(e,t,n){let a=function(e,t){try{let n=window.localStorage.getItem(lF(e));if(!n)return lz(t);let a=JSON.parse(n),r=function(e){if(!lO(e))return null;let{splits:t,widths:n}=e;if(!Array.isArray(t)||!Array.isArray(n)||t.length<1||t.length>3||n.length!==t.length)return null;let a=[];for(let e of t){if(!lO(e))return null;let t=e.cliToolId;if("string"!=typeof t||!lD.has(t))return null;let n=e.instanceId,r="string"==typeof n&&(0,tt.n6)(n)?n:t;a.push({cliToolId:t,instanceId:r})}for(let e of n)if("number"!=typeof e||!Number.isFinite(e)||e<=0)return null;return{splits:a,widths:n}}(a);if(r)return{...r,widths:l_(r.widths)};return console.warn("[useTerminalSplits] stale state for ".concat(e,"; falling back to default")),lz(t)}catch(n){return console.warn("[useTerminalSplits] failed to parse stored state for ".concat(e,"; using default"),n),lz(t)}}(e,t);return n?lB(a,t):a}let lW=(0,i.memo)(function(e){let{worktreeId:t,instances:n,rosterReady:a=!0,renderPane:s,onFocusedSplitChange:l,showToast:o,onActiveInstanceChange:d,headerInstanceSelection:u}=e,{splits:m,widths:h,addSplit:x,removeSplit:f,setSplitInstance:p,setSplitWidth:g,resetWidths:b,availableInstanceIds:v,focusedSplitIndex:y,setFocusedSplitIndex:j}=function(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],[a,r]=(0,i.useState)(()=>lV(e,t,n)),[s,l]=(0,i.useState)(0),o=(0,i.useRef)(a);o.current=a;let c=(0,i.useRef)(t);c.current=t;let d=(0,i.useRef)(n);d.current=n;let u=(0,i.useRef)(e);(0,i.useEffect)(()=>{u.current!==e&&(u.current=e,r(lV(e,c.current,d.current)),l(0))},[e]);let m=(0,i.useMemo)(()=>t.map(e=>"".concat(e.id,":").concat(e.cliTool)).join("|"),[t]);(0,i.useEffect)(()=>{n&&r(e=>lB(e,c.current))},[m,n]);let h=(0,i.useRef)(e);(0,i.useEffect)(()=>{if(h.current!==e){h.current=e;return}try{window.localStorage.setItem(lF(e),JSON.stringify(a))}catch(e){}},[a,e]);let x=(0,i.useCallback)(()=>{r(e=>{if(e.splits.length>=3)return e;let t=new Set(e.splits.map(e=>e.instanceId)),n=function(e,t){for(let n of e)if(!t.has(n.id))return n;return null}(c.current,t);if(!n)return e;let a=e.widths.length-1,r=e.widths[a]/2,s=[...e.widths];return s[a]=r,s.push(r),{splits:[...e.splits,{cliToolId:n.cliTool,instanceId:n.id}],widths:s}})},[]),f=(0,i.useCallback)(()=>{r(e=>e.splits.length<=1?e:{splits:e.splits.slice(0,-1),widths:l_(e.widths.slice(0,-1))})},[]);(0,i.useEffect)(()=>{l(e=>{let t=a.splits.length-1;return e>t?t:e<0?0:e})},[a.splits.length]);let p=(0,i.useCallback)((e,t)=>{let n=o.current,a=c.current;if(e<0||e>=n.splits.length)return!1;let s=a.find(e=>e.id===t);if(!s||n.splits[e].instanceId===t)return!1;for(let a=0;a<n.splits.length;a++)if(a!==e&&n.splits[a].instanceId===t)return!1;return r(n=>{if(e<0||e>=n.splits.length||n.splits[e].instanceId===t)return n;for(let a=0;a<n.splits.length;a++)if(a!==e&&n.splits[a].instanceId===t)return n;let a=n.splits.map((n,a)=>a===e?{cliToolId:s.cliTool,instanceId:t}:n);return{...n,splits:a}}),!0},[]),g=(0,i.useCallback)(e=>{r(t=>e.length!==t.widths.length||!function(e){if(!Array.isArray(e))return!1;for(let t of e)if("number"!=typeof t||!Number.isFinite(t)||t<=0)return!1;return!0}(e)?t:{...t,widths:[...e]})},[]),b=(0,i.useCallback)(()=>{r(e=>{let t=e.splits.length;return 0===t?e:{...e,widths:Array.from({length:t},()=>1/t)}})},[]),v=(0,i.useCallback)(e=>{let n=new Set;for(let t=0;t<a.splits.length;t++)t!==e&&n.add(a.splits[t].instanceId);return t.filter(e=>!n.has(e.id)).map(e=>e.id)},[a.splits,t]),y=(0,i.useCallback)(e=>{l(e)},[]);return{splits:a.splits,widths:a.widths,addSplit:x,removeSplit:f,setSplitInstance:p,setSplitWidth:g,resetWidths:b,availableInstanceIds:v,focusedSplitIndex:s,setFocusedSplitIndex:y}}(t,n,a),w=(0,i.useMemo)(()=>{let e=new Map;for(let t of n)e.set(t.id,t);return e},[n]),k=(0,c.c)("worktree"),{visible:N,toggle:C,setWidth:S}=nr(),{collapsed:T,toggle:E}=lE(),I=!T,M=(0,i.useRef)(null),[A,L]=(0,i.useState)(!1),R=(0,i.useRef)(m.length),[P,D]=(0,i.useState)(null);(0,i.useEffect)(()=>{m.length>R.current&&D(m.length-1),R.current=m.length},[m.length]),(0,i.useEffect)(()=>{null==l||l(y)},[y,l]);let F=(0,i.useRef)(0),O=(0,i.useRef)(m);O.current=m,(0,i.useEffect)(()=>{if(!u||u.token===F.current)return;F.current=u.token;let{instanceId:e}=u,t=O.current.findIndex(t=>t.instanceId===e);if(0!==t){if(t>0)return void j(t);p(0,e)&&j(0)}},[u,p,j]),(0,i.useEffect)(()=>{if(null===P)return;let e=M.current;if(!e)return;let t=e.querySelector('[data-split-index="'.concat(P,'"]'));if(!t)return;let n=t.querySelector("textarea");null==n||n.focus(),j(P),D(null)},[P,j]);let z=(0,i.useCallback)((e,t)=>{let n=M.current;if(!n)return;let a=n.offsetWidth;if(0===a)return;let r=h.reduce((e,t)=>e+t,0),s=t/a*r,l=[...h],i=l[e]+s,o=l[e+1]-s,c=.05*r;i<c||o<c||(l[e]=i,l[e+1]=o,g(l))},[h,g]),_=(0,i.useCallback)(()=>L(!0),[]),B=(0,i.useCallback)(()=>L(!1),[]),V=(0,i.useCallback)(()=>{b(),S(40)},[b,S]),W=m.length<3&&!A,H=m.length>1&&!A,U=m.length>1||N,K=(0,i.useMemo)(()=>m.map((e,t)=>()=>j(t)),[m,j]),$=(0,i.useMemo)(()=>m.map((e,t)=>e=>p(t,e)),[m,p]),q=(0,i.useMemo)(()=>m.map((e,t)=>e=>{var n,a;let r=(0,tt.sw)(null!=(a=w.get(e))?a:{cliTool:"claude",alias:e});if((null==(n=m[t])?void 0:n.instanceId)===e)return;let s=m.findIndex((n,a)=>a!==t&&n.instanceId===e);if(-1!==s){null==o||o("".concat(r," is already in use by split ").concat(s+1),"warning");return}p(t,e)&&(null==d||d(e),null==o||o("Moved ".concat(r," to Split ").concat(t+1),"success"))}),[m,p,o,d,w]);return(0,r.jsxs)("div",{role:"group","aria-label":"Terminal splits","data-testid":"terminal-split-container",className:"flex flex-col h-full min-h-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-surface border-b border-border flex-shrink-0",children:[(0,r.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums mr-1",children:[m.length," / ",3," splits"]}),(0,r.jsx)("button",{type:"button",onClick:x,disabled:!W,"aria-disabled":!W,"aria-label":k("terminal.addSplit"),title:k("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,r.jsx)(aF.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:f,disabled:!H,"aria-disabled":!H,"aria-label":k("terminal.removeSplit"),title:k("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,r.jsx)(lM.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:V,disabled:!U,"aria-disabled":!U,"aria-label":k("terminal.equalizeWidthsHint"),title:k("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,r.jsx)(lA.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})}),(0,r.jsx)("div",{className:"ml-auto h-4 w-px bg-border","aria-hidden":"true"}),(0,r.jsxs)("button",{type:"button",onClick:C,"aria-pressed":N,"aria-label":k(N?"terminal.hideHistory":"terminal.showHistory"),title:k(N?"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 ".concat(N?"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,r.jsx)(lL.A,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("terminal.historyLabel")})]}),(0,r.jsxs)("button",{type:"button",onClick:E,"aria-pressed":I,"aria-label":k(I?"terminal.hideFiles":"terminal.showFiles"),title:k(I?"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 ".concat(I?"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,r.jsx)(lR.A,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("terminal.filesLabel")})]})]}),(0,r.jsx)("div",{ref:M,className:"flex flex-1 min-h-0 w-full",children:m.map((e,t)=>{var n;let a=t===m.length-1;return(0,r.jsxs)(i.Fragment,{children:[(0,r.jsx)("div",{style:{flexGrow:null!=(n=h[t])?n:1,flexShrink:1,flexBasis:0,minWidth:0},className:"h-full",children:s({splitIndex:t,cliToolId:e.cliToolId,instanceId:e.instanceId,instance:w.get(e.instanceId),availableInstances:v(t).map(e=>w.get(e)).filter(e=>void 0!==e),onInstanceChange:$[t],onFocus:K[t],isFocused:y===t,onDropInstance:q[t]})}),a?null:(0,r.jsx)(lH,{resizerIdx:t,ariaValueNow:h.length?h[t]/h.reduce((e,t)=>e+t,0)*100:50,onResize:z,onStart:_,onEnd:B,onDoubleClick:b})]},"split-".concat(t))})})]})});function lH(e){let{resizerIdx:t,ariaValueNow:n,onResize:a,onStart:s,onEnd:l,onDoubleClick:o}=e,c=(0,i.useCallback)(e=>a(t,e),[t,a]);return(0,r.jsx)("div",{"data-testid":"split-resizer-".concat(t),onMouseDownCapture:s,onTouchStartCapture:s,onMouseUpCapture:l,onTouchEndCapture:l,children:(0,r.jsx)(ns.f,{onResize:c,orientation:"horizontal",ariaValueNow:n,onDoubleClick:o})})}let lU="\n px-6 py-2 rounded-lg font-medium transition-all\n disabled:opacity-50 disabled:cursor-not-allowed\n focus:outline-none focus:ring-2 focus:ring-offset-2\n".trim(),lK="bg-accent-600 text-white hover:bg-accent-700 focus:ring-ring",l$="bg-surface border-2 border-input hover:bg-muted text-foreground focus:ring-ring";function lq(e){let{promptData:t,answering:n,onRespond:a,decisionId:s,onDismiss:l,labelId:o,cliToolName:d}=e,u=(0,c.c)("prompt"),[h,x]=(0,i.useState)(()=>{if("multiple_choice"===t.type){var e;let n=t.options.find(e=>e.isDefault);return null!=(e=null==n?void 0:n.number)?e:null}return null}),[f,p]=(0,i.useState)(""),[g,b]=(0,i.useState)(!1),v=(0,i.useMemo)(()=>{var e;return"multiple_choice"!==t.type?null:null!=(e=t.options.find(e=>e.number===h))?e:null},[t,h]),y=(null==v?void 0:v.requiresTextInput)===!0,j=n||g,w=(0,i.useCallback)(async e=>{if(!j){b(!0);try{await a(e,s)}catch(e){}finally{b(!1)}}},[j,a,s]),k=(0,i.useCallback)(async()=>{if(!j&&null!==h){b(!0);try{let e=y&&f.trim()?f.trim():h.toString();await a(e,s)}catch(e){}finally{b(!1)}}},[j,a,s,h,y,f]),N=(0,i.useCallback)(async e=>{if(!j&&s){b(!0);try{await a(e,s)}catch(e){}finally{b(!1)}}},[j,a,s]);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("h3",{id:o,className:"text-lg font-semibold text-warning-foreground flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xl","aria-hidden":"true",children:"?"}),d?u("confirmationFrom",{toolName:d}):u("confirmationFromClaude")]}),l&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:l,"aria-label":"close",className:"p-1 rounded hover:bg-warning-border/50 transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5 text-warning-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),S(t)&&t.instructionText&&(0,r.jsx)("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap text-sm text-muted-foreground bg-muted rounded p-2 border border-border",children:t.instructionText}),"multiple_choice"===t.type&&t.askUserQuestion&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"ask-user-question-progress",children:t.askUserQuestion.questionCount>1?u("askUserQuestionProgress",{index:t.askUserQuestion.questionIndex+1,total:t.askUserQuestion.questionCount}):u("askUserQuestionSource")}),(0,r.jsx)("p",{className:"text-foreground leading-relaxed",children:S(t)?t.question:u("unclassifiedTitle")}),j&&(0,r.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-muted-foreground",role:"status","aria-live":"polite",children:[(0,r.jsx)(m.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{children:u("sending")})]}),"yes_no"===t.type&&(0,r.jsx)(lY,{promptData:t,disabled:j,onYes:()=>w("yes"),onNo:()=>w("no")}),"multiple_choice"===t.type&&(0,r.jsx)(lQ,{promptData:t,disabled:j,selectedOption:h,onSelectOption:x,textInputValue:f,onTextInputChange:p,showTextInput:y,onSubmit:k}),!S(t)&&(0,r.jsx)(lG,{promptData:t,decisionId:s,disabled:j,onRespond:N})]})}function lG(e){var t;let{promptData:n,decisionId:a,disabled:s,onRespond:l}=e,i=(0,c.c)("prompt"),o=a&&null!=(t=n.decisionOptions)?t:null;return(0,r.jsxs)("div",{className:"space-y-2","data-testid":"unclassified-prompt-notice",children:[n.message&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:n.message}),n.askUserQuestion&&(0,r.jsxs)("div",{className:"space-y-1","data-testid":"unclassified-ask-user-question",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:n.askUserQuestion.question}),(0,r.jsx)("ul",{className:"list-disc list-inside text-sm text-muted-foreground",children:n.askUserQuestion.labels.map(e=>(0,r.jsx)("li",{children:e},e))})]}),o&&o.length>0?(0,r.jsx)(lJ,{options:o,disabled:s,onRespond:l}):(0,r.jsx)("p",{className:"text-sm text-foreground",children:i("unclassifiedInstruction",{command:i("unclassifiedRespondCommand")})})]})}function lJ(e){let{options:t,disabled:n,onRespond:a}=e,s=(0,c.c)("prompt");return(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":s("selectAnOption"),"data-testid":"structured-decision-actions",children:t.map(e=>(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",disabled:n,onClick:()=>a(String(e.number)),"data-testid":"structured-decision-option-".concat(e.number),className:"".concat(lU," ").concat(3===e.number?l$:lK),children:[e.number,". ",e.label]},e.number))})}function lY(e){let{promptData:t,disabled:n,onYes:a,onNo:s}=e,l=(0,c.c)("prompt"),i="yes"===t.defaultOption,o="no"===t.defaultOption,d="".concat(lU," ").concat(lK," ").concat(i?"primary default highlighted":""),u="".concat(lU," ").concat(o?"bg-foreground text-background hover:bg-foreground/90 primary default highlighted":l$);return(0,r.jsxs)("div",{className:"flex items-center gap-3",role:"group","aria-label":l("yesNoGroupLabel"),children:[(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:a,disabled:n,className:d,children:l("yes")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:s,disabled:n,className:u,children:l("no")})]})}function lQ(e){let{promptData:t,disabled:n,selectedOption:a,onSelectOption:s,textInputValue:l,onTextInputChange:o,showTextInput:d,onSubmit:u}=e,h=(0,i.useId)(),x=(0,c.c)("prompt"),f=(0,i.useCallback)(e=>{let t=a===e,r=n?"opacity-50 cursor-not-allowed":"";return"".concat("flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all"," ").concat(t?"bg-accent-50 dark:bg-accent-900/30 border-2 border-accent-500":"bg-surface border-2 border-border hover:border-input"," ").concat(r)},[a,n]);return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:x("selectAnOption")}),(0,r.jsx)(m.z6,{name:h,value:null!=a?String(a):"",onValueChange:e=>s(Number(e)),disabled:n,className:"flex flex-col gap-2",children:t.options.map(e=>(0,r.jsxs)("label",{className:f(e.number),children:[(0,r.jsx)(m.CU,{value:String(e.number),className:"mt-1","aria-describedby":e.isDefault?"default-".concat(e.number):void 0}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),e.isDefault&&(0,r.jsx)("span",{id:"default-".concat(e.number),className:"ml-2 text-xs text-accent-600 dark:text-accent-400 bg-accent-100 dark:bg-accent-900/30 px-2 py-0.5 rounded",children:x("default")}),e.description&&(0,r.jsx)("p",{className:"mt-0.5 text-sm text-muted-foreground",children:e.description})]})]},e.number))})]}),d&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"text-input-".concat(h),className:"sr-only",children:x("customValueInput")}),(0,r.jsx)("input",{id:"text-input-".concat(h),type:"text",value:l,onChange:e=>o(e.target.value),disabled:n,placeholder:x("enterValuePlaceholder"),className:"w-full px-4 py-2 border-2 border-input dark:bg-muted dark:text-foreground rounded-lg focus:outline-none focus:border-accent-500 disabled:opacity-50"})]}),(0,r.jsx)("button",{type:"button",onClick:u,disabled:n||null===a,className:"w-full ".concat(lU," ").concat(lK),children:x("submit")})]})}let lX=(0,i.memo)(function(e){let t,{promptData:n,messageId:a,decisionId:s,visible:l,answering:o,onRespond:c,onDismiss:d,cliToolName:u}=e,{shouldRender:m,animationClass:h}=M({visible:l&&null!==n,duration:200}),x=(0,i.useId)();if(!m||!n)return null;let f=(t="opacity-100","animate-fade-in"===h?t="opacity-100 transform translate-y-0":"animate-fade-out"===h&&(t="opacity-0 transform translate-y-2"),"".concat("bg-warning-subtle border-2 border-warning-border rounded-lg p-4 shadow-lg transition-all duration-200 ease-in-out"," ").concat(h," ").concat(t));return(0,r.jsx)(T,{componentName:"PromptPanel",children:(0,r.jsx)("div",{"data-testid":"prompt-panel",role:"dialog","aria-labelledby":x,"aria-modal":"true",className:f,children:(0,r.jsx)(lq,{promptData:n,answering:o,onRespond:c,decisionId:s,onDismiss:d,labelId:x,cliToolName:u})})})});var lZ=n(91758);function l0(e){let{isOpen:t,onConfirm:n,onCancel:a,cliToolName:s}=e,l=(0,c.c)("autoYes"),o=(0,c.c)("common"),[d,u]=(0,i.useState)(36e5),[m,h]=(0,i.useState)(""),[x,f]=(0,i.useState)(null),[p,g]=(0,i.useState)(!1),b=(0,i.useRef)(null),v=e=>l(aH[e].replace("autoYes.",""));return(0,i.useEffect)(()=>{t&&(h(""),f(null),g(!1))},[t]),(0,i.useEffect)(()=>{if(!p)return;let e=e=>{b.current&&!b.current.contains(e.target)&&g(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]),(0,i.useEffect)(()=>{if(!m.trim())return void f(null);let e=aU(m.trim());if(e.valid)f(null);else{var t;f(null!=(t=e.error)?t:l("invalidRegexPattern"))}},[m,l]),(0,r.jsx)(e7.a,{isOpen:t,onClose:a,title:s?l("enableTitleWithTool",{toolName:s}):l("enableTitle"),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"text-sm text-foreground",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:l("featureDescription")}),(0,r.jsxs)("ul",{className:"list-disc list-inside space-y-1",children:[(0,r.jsx)("li",{children:l("yesNoAutoResponse")}),(0,r.jsx)("li",{children:l("multipleChoiceAutoSelect")})]}),(0,r.jsx)("p",{className:"mt-1",children:l("autoDisableAfter",{duration:v(d)})}),s&&(0,r.jsx)("p",{className:"mt-2 text-muted-foreground",children:l("appliesOnlyToCurrent",{toolName:s})})]}),(0,r.jsxs)("div",{className:"text-sm text-foreground",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:l("duration")}),(0,r.jsx)("div",{className:"flex gap-2",children:aW.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>u(e),className:"flex-1 py-2 px-3 text-sm font-medium rounded-md border-2 transition-colors ".concat(d===e?"border-accent-600 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-400":"border-border bg-surface dark:bg-surface-2 text-foreground hover:border-muted-foreground"),style:{minHeight:"44px"},children:v(e)},e))})]}),(0,r.jsxs)("div",{className:"text-sm text-foreground",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)("label",{htmlFor:"stop-pattern-input",className:"font-medium",children:l("stopPatternLabel")}),(0,r.jsxs)("div",{className:"relative",ref:b,children:[(0,r.jsx)("button",{type:"button",onClick:()=>g(!p),className:"inline-flex items-center justify-center w-4 h-4 rounded-full bg-muted text-muted-foreground text-[10px] font-bold hover:bg-muted/80 focus:outline-none","aria-label":l("regexTipsLabel"),"data-testid":"regex-tips-button",children:"?"}),p&&(0,r.jsxs)("div",{className:"absolute left-0 top-6 z-50 w-72 rounded-md border border-border bg-surface p-3 shadow-lg text-xs text-foreground","data-testid":"regex-tips-tooltip",children:[(0,r.jsx)("p",{className:"font-medium mb-1.5",children:l("regexTipsTitle")}),(0,r.jsxs)("ul",{className:"space-y-1",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-muted px-1 rounded",children:"\\bcat\\b"})," ",l("regexTipWordBoundary")]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-muted px-1 rounded",children:"error|fatal"})," ",l("regexTipOr")]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-muted px-1 rounded",children:"(?i)error"})," ",l("regexTipCaseNote")]})]})]})]})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-2",children:l("stopPatternDescription")}),(0,r.jsx)("input",{id:"stop-pattern-input",type:"text",value:m,onChange:e=>h(e.target.value),placeholder:l("stopPatternPlaceholder"),className:"w-full px-3 py-2 border rounded-md text-sm font-mono bg-surface dark:bg-surface-2 text-foreground ".concat(x?"border-danger focus:ring-danger focus:border-danger":"border-input focus:ring-ring focus:border-accent-500"," focus:outline-none focus:ring-1"),"data-testid":"stop-pattern-input"}),x&&(0,r.jsx)("p",{className:"mt-1 text-xs text-danger","data-testid":"stop-pattern-error",children:x})]}),(0,r.jsxs)("div",{className:"text-sm text-foreground",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:l("aboutRisks")}),(0,r.jsx)("p",{children:l("riskWarning")})]}),(0,r.jsx)("div",{className:"bg-warning-subtle border-l-4 border-warning p-3",children:(0,r.jsxs)("p",{className:"text-sm text-warning-foreground",children:[(0,r.jsx)("span",{className:"font-medium",children:l("disclaimer")}),l("disclaimerText")]})}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:a,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:o("cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>{n(d,m.trim()||void 0)},disabled:!!x,className:"px-4 py-2 text-sm font-medium rounded-md text-white ".concat(x?"bg-muted-foreground cursor-not-allowed":"bg-warning hover:bg-warning/90"),"data-testid":"confirm-button",children:l("agreeAndEnable")})]})]})})}let l1=(0,i.memo)(function(e){let{enabled:t,expiresAt:n,onToggle:a,lastAutoResponse:s,cliToolName:l,inline:o=!1,showToolName:d=!0,onExpire:u}=e,m=(0,c.c)("autoYes"),[h,x]=(0,i.useState)(""),[f,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(!1),[j,w]=(0,i.useState)(!1);(0,i.useEffect)(()=>{if(!t||!n){x(""),w(!1);return}w(!1);let e=!1,a=()=>(x(aK(n)),n-Date.now()<=0&&!e&&(e=!0,w(!0),null==u||u(),!0));if(a())return;let r=setInterval(()=>{a()&&clearInterval(r)},1e3);return()=>clearInterval(r)},[t,n,u]),(0,i.useEffect)(()=>{if(!s)return;p('Auto responded: "'.concat(s,'"'));let e=setTimeout(()=>p(null),er.I2);return()=>clearTimeout(e)},[s]);let k=t&&!j,N=(0,i.useCallback)(()=>{k?(b(!0),a({enabled:!1}).finally(()=>b(!1))):y(!0)},[k,a]),C=(0,i.useCallback)((e,t)=>{y(!1),b(!0),a({enabled:!0,duration:e,stopPattern:t}).finally(()=>b(!1))},[a]),S=(0,i.useCallback)(()=>{y(!1)},[]);return(0,r.jsxs)("div",{className:o?"flex items-center gap-2":"flex items-center gap-3 px-4 py-2 bg-surface-2 border-b border-border",children:[(0,r.jsx)(lZ.d,{checked:k,onCheckedChange:N,disabled:g,"aria-label":m("toggleLabel")}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:m("label")}),d&&l&&(0,r.jsxs)("span",{className:"text-xs text-accent-600 dark:text-accent-400 font-medium","aria-label":m("targetLabel"),children:["(",(0,tt.f_)(l,""),")"]}),k&&h&&(0,r.jsx)("span",{className:"text-sm text-muted-foreground","aria-label":m("timeRemaining"),children:h}),f&&(0,r.jsx)("span",{className:"text-sm text-success animate-pulse",children:f}),(0,r.jsx)(l0,{isOpen:v,onConfirm:C,onCancel:S,cliToolName:(0,tt.f_)(l,"")})]})});function l2(e){let t=new Set;for(let n of e)"user"===n.role&&t.add(n.id);return t}function l4(e,t,n){let a=new Set,r=new Set,s=e.filter(e=>"sending"===e.status);if(0===s.length)return{reconciledTempIds:a,consumedServerIds:r};let l=t.filter(e=>"user"===e.role&&!n.has(e.id)).sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()),i=new Set;for(let e of[...s].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime())){let t=l.find(t=>!i.has(t.id)&&!e.baselineUserIds.has(t.id)&&t.content===e.content);t&&(i.add(t.id),a.add(e.tempId),r.add(t.id))}return{reconciledTempIds:a,consumedServerIds:r}}function l5(e,t,n,a){let r={answer:e,cliTool:t};if(a&&a!==t&&(r.instanceId=a),n&&(r.promptType=n.type,"multiple_choice"===n.type)){let e=n.options.find(e=>e.isDefault);e&&(r.defaultOptionNumber=e.number),n.submitMode&&(r.submitMode=n.submitMode)}return r}let l3=(0,i.memo)(function(e){var t,n,a,s,l;let{worktreeId:o,splitIndex:d,cliToolId:u,instanceId:m,instance:h,availableInstances:x,onInstanceChange:f,onFocus:p,disabled:g=!1,pendingInsertText:b,onInsertConsumed:v,onMessageSent:y,cliStatus:j="idle",autoYes:w,history:k,onDropInstance:N,draggedInstanceId:C,onRequestSessionEnd:T,agentModel:E}=e,I=null!=m?m:u,M=null!=(t=w.enabled)&&t,A=null!=(n=w.expiresAt)?n:null,L=null!=(a=w.lastAutoResponse)?a:null,R=w.onToggle,P=null!=(s=null==k?void 0:k.showArchived)&&s,D=null==k?void 0:k.onShowArchivedChange,F=null==k?void 0:k.historyDisplayLimit,O=null==k?void 0:k.onHistoryDisplayLimitChange,z=null!=(l=null==k?void 0:k.historyUserOnly)&&l,_=null==k?void 0:k.onHistoryUserOnlyChange,B=null==k?void 0:k.onInsertToMessage,W=null==k?void 0:k.onFilePathClick,H=null==k?void 0:k.showToast,U=(0,c.c)("worktree"),{terminal:K,prompt:$,setAutoScroll:q,setPromptAnswering:G,clearPrompt:J,refresh:Y}=tF({worktreeId:o,cliToolId:u,instanceId:I,enabled:!g}),{messages:Q,isLoading:X,refresh:Z}=function(e){let{worktreeId:t,cliToolId:n,instanceId:a,limit:r,includeArchived:s=!1,enabled:l=!0}=e,[o,c]=(0,i.useState)([]),[d,u]=(0,i.useState)(!0),{subscribe:m,unsubscribe:h,addListener:x}=(0,tI.xM)(),f=null!=a?a:n,p=(0,i.useRef)(0),g=(0,i.useRef)(n);g.current=n;let b=(0,i.useRef)(f);b.current=f;let v=(0,i.useCallback)(async()=>{let e=++p.current;try{let a=new URLSearchParams({cliTool:n,instance:f,unit:"pairs"});void 0!==r&&a.set("limit",String(r)),s&&a.set("includeArchived","true");let l=await fetch("/api/worktrees/".concat(t,"/messages?").concat(a.toString()));if(!l.ok)return;let i=await l.json();if(p.current!==e||g.current!==n||b.current!==f)return;c(i.map(e=>({...e,timestamp:new Date(e.timestamp)}))),u(!1)}catch(t){if(p.current!==e||g.current!==n||b.current!==f)return;console.error("[useSplitMessages] fetch error:",t),u(!1)}},[t,n,f,r,s]),y="".concat(t,"::").concat(n,"::").concat(f),j=(0,i.useRef)(y);return(0,i.useEffect)(()=>{j.current!==y&&(j.current=y,p.current+=1,c([]),u(!0))},[y]),(0,i.useEffect)(()=>{if(!l)return;let e=!1,t=setInterval(()=>{"hidden"!==document.visibilityState&&v()},5e3);"undefined"!=typeof document&&"hidden"!==document.visibilityState&&v();let n=()=>{"visible"!==document.visibilityState||e||v()};return document.addEventListener("visibilitychange",n),()=>{e=!0,clearInterval(t),document.removeEventListener("visibilitychange",n)}},[l,v]),(0,i.useEffect)(()=>{if(l)return m(t),()=>h(t)},[l,t,m,h]),(0,i.useEffect)(()=>{if(l)return x(e=>{if("session_status_changed"===e.type)e.worktreeId===t&&!1===e.isRunning&&(null==e.instance||e.instance===b.current)&&(null==e.cliTool||e.cliTool===g.current)&&v()})},[l,t,x,v]),{messages:o,isLoading:d,refresh:(0,i.useCallback)(()=>v(),[v])}}({worktreeId:o,cliToolId:u,instanceId:I,limit:F,includeArchived:P,enabled:!g}),ee=(0,i.useCallback)((e,t)=>V.y.sendMessage(o,e,t),[o]),{messages:et,sendOptimistic:en,retry:er,discard:es}=function(e){let{worktreeId:t,serverMessages:n,sendFn:a,onSent:r,timeoutMs:s=3e4}=e,[l,o]=(0,i.useState)([]),c=(0,i.useRef)(n);c.current=n;let d=(0,i.useRef)(l);d.current=l;let u=(0,i.useRef)(r);u.current=r;let m=(0,i.useRef)(a);m.current=a;let h=(0,i.useRef)(0),x=(0,i.useRef)(new Map),f=(0,i.useRef)(new Set),p=(0,i.useCallback)(e=>{let t=x.current.get(e);void 0!==t&&(clearTimeout(t),x.current.delete(e))},[]),g=(0,i.useCallback)(e=>{p(e);let t=setTimeout(()=>{x.current.delete(e),o(t=>t.map(t=>t.tempId===e&&"sending"===t.status?{...t,status:"error"}:t))},s);x.current.set(e,t)},[p,s]),b=(0,i.useCallback)(async e=>{g(e.tempId);try{var t;await m.current(e.content,e.options),null==(t=u.current)||t.call(u)}catch(t){p(e.tempId),o(t=>t.map(t=>t.tempId===e.tempId?{...t,status:"error"}:t))}},[g,p]),v=(0,i.useCallback)((e,t)=>{let n={tempId:"pending-".concat(h.current++),content:e,options:t,timestamp:new Date,status:"sending",baselineUserIds:l2(c.current)};o(e=>[...e,n]),b(n)},[b]),y=(0,i.useCallback)(e=>{let t=d.current.find(t=>t.tempId===e);if(!t)return;let n={...t,status:"sending",timestamp:new Date,baselineUserIds:l2(c.current)};o(t=>t.map(t=>t.tempId===e?n:t)),b(n)},[b]),j=(0,i.useCallback)(e=>{let t=d.current.find(t=>t.tempId===e);return p(e),o(t=>t.filter(t=>t.tempId!==e)),null==t?void 0:t.content},[p]);return(0,i.useEffect)(()=>{let{reconciledTempIds:e,consumedServerIds:t}=l4(d.current,n,f.current),a=new Set(n.map(e=>e.id)),r=new Set;f.current.forEach(e=>{a.has(e)&&r.add(e)}),t.forEach(e=>r.add(e)),f.current=r,0!==e.size&&(e.forEach(p),o(t=>t.filter(t=>!e.has(t.tempId))))},[n,p]),(0,i.useEffect)(()=>{let e=x.current;return()=>{e.forEach(e=>clearTimeout(e)),e.clear()}},[]),{messages:(0,i.useMemo)(()=>{if(0===l.length)return n;let{reconciledTempIds:e}=l4(l,n,f.current),a=l.filter(t=>!e.has(t.tempId)).map(e=>({id:e.tempId,worktreeId:t,role:"user",content:e.content,timestamp:e.timestamp,messageType:"normal",archived:!1,cliToolId:e.options.cliToolId,instanceId:e.options.instanceId,optimisticState:e.status}));return 0===a.length?n:[...n,...a]},[n,l,t]),pending:l,sendOptimistic:v,retry:y,discard:j}}({worktreeId:o,serverMessages:Q,sendFn:ee,onSent:Z}),{visible:el,width:ei,toggle:ec,setWidth:ed}=nr(),eu=i.useRef(null),em=(0,i.useCallback)(e=>{let t=eu.current;if(!t)return;let n=t.offsetWidth;0!==n&&ed(ei+e/n*100)},[ei,ed]),eh="opencode"===u||"copilot"===u,ex="claude"===u||"codex"===u,ef=(0,i.useCallback)(e=>q(e),[q]),ep=(0,i.useCallback)(e=>{Y(),Z(),null==y||y(e)},[Y,Z,y]),eg=(0,i.useCallback)(e=>{let t=es(e);t&&(null==B||B(t))},[es,B]),eb=(0,i.useCallback)(async(e,t)=>{G(!0);try{let n=t?{decisionId:t,answer:e,cliTool:u,...I&&I!==u?{instanceId:I}:{}}:l5(e,u,S($.data)?$.data:null,I),a=await fetch(t?"/api/worktrees/".concat(o,"/respond"):"/api/worktrees/".concat(o,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw Error("Failed to send prompt response: ".concat(a.status));J(),await Y()}catch(e){console.error("[TerminalSplitPaneContent] prompt response error:",e)}finally{G(!1)}},[o,u,I,$.data,G,J,Y]),ev=(0,i.useCallback)(()=>{J()},[J]),ey=K.isSelectionListActive,ej=$.visible&&!M,ek=function(e){if(!e)return null;let t=e.decisionId;return"string"==typeof t&&""!==t?t:null}($.data),eN=K.isUnclassifiedActive&&!ey&&!$.visible,eC=tT(K.composerText),eS=(0,i.useMemo)(()=>(0,r.jsx)(ng,{messages:et,worktreeId:o,onFilePathClick:null!=W?W:()=>{},isLoading:X,className:"h-full",showToast:H,onInsertToMessage:B,onRetryPending:er,onDiscardPending:eg,showArchived:P,onShowArchivedChange:D,historyDisplayLimit:F,onHistoryDisplayLimitChange:O,historyUserOnly:z,onHistoryUserOnlyChange:_,onCollapse:ec,splitIndex:d,cliToolId:u}),[et,er,eg,o,W,X,H,B,P,D,F,O,z,_,ec,d,u]),eT=(0,i.useMemo)(()=>(0,r.jsx)(tw,{output:K.output,isActive:K.isRunning,attaching:K.attaching,isThinking:K.isThinking,autoScroll:K.autoScroll,onScrollChange:ef,disableAutoFollow:eh,compactTuiLayoutPadding:ex}),[K.output,K.isRunning,K.attaching,K.isThinking,K.autoScroll,ef,eh,ex]),eE=(0,i.useMemo)(()=>(0,r.jsxs)("div",{ref:eu,className:"flex h-full min-h-0 w-full",children:[el?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:nh(d),"data-testid":"split-history-slot-".concat(d),"aria-label":"History pane",style:{width:"".concat(ei,"%")},className:"flex-shrink-0 overflow-hidden min-h-0",children:eS}),(0,r.jsx)(ns.f,{onResize:em,orientation:"horizontal",ariaValueNow:ei})]}):(0,r.jsx)("div",{"data-testid":"split-history-expand-bar-".concat(d),className:"flex-shrink-0 flex items-start justify-center w-9 bg-gray-50 dark:bg-gray-800 border-r border-gray-200 dark:border-gray-700",children:(0,r.jsxs)("button",{type:"button","data-testid":"split-history-expand-".concat(d),"aria-label":U("terminal.showHistory"),title:U("terminal.showHistory"),"aria-expanded":"false",onClick:ec,className:"flex flex-col items-center gap-2 w-full pt-2 text-gray-500 dark:text-gray-400 hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,r.jsx)("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,r.jsx)("span",{className:"text-xs font-medium tracking-wide select-none",style:{writingMode:"vertical-rl"},"aria-hidden":"true",children:U("terminal.historyLabel")})]})}),(0,r.jsx)("div",{className:"flex-grow overflow-hidden min-w-0 min-h-0 relative",children:eT})]}),[el,ei,eS,em,ec,eT,d,U]),eI=(0,i.useMemo)(()=>(0,r.jsxs)("div",{className:"space-y-2",children:[ey?(0,r.jsx)(eo,{worktreeId:o,cliToolId:u,instanceId:I,onKeysSent:Y,showPagerKeys:K.isPagerActive}):null,eN?(0,r.jsx)(tS,{worktreeId:o,cliToolId:u,instanceId:I,onKeysSent:Y}):null,eC?(0,r.jsx)(tE,{worktreeId:o,cliToolId:u,instanceId:I,composerText:K.composerText,onActionSent:Y}):null,ej?(0,r.jsx)(lX,{promptData:$.data,messageId:$.messageId,decisionId:ek,visible:$.visible,answering:$.answering,onRespond:eb,onDismiss:ev,cliToolName:(0,tt.oo)(u)}):null,(0,r.jsx)(ea,{worktreeId:o,onMessageSent:ep,onOptimisticSend:en,cliToolId:u,instanceId:I,isSessionRunning:K.isRunning,pendingInsertText:null!=b?b:null,onInsertConsumed:v,splitIndex:d,onFocus:p,isProcessing:K.isRunning,showToast:H,autoYesSlot:(0,r.jsx)(l1,{enabled:M,expiresAt:null!=A?A:null,onToggle:R,lastAutoResponse:null!=L?L:null,cliToolName:u,inline:!0})})]}),[ey,ej,eN,eC,K.composerText,K.isPagerActive,o,u,I,Y,$.data,$.messageId,ek,$.visible,$.answering,eb,ev,ep,en,K.isRunning,b,v,d,p,M,A,L,R,H]),eM=(0,tt.sw)(null!=h?h:{cliTool:u}),eA=(0,i.useCallback)(()=>{null==T||T({cliToolId:u,instanceId:I,label:eM})},[T,u,I,eM]),eL=(0,i.useMemo)(()=>{if(!T||!K.isRunning)return null;let e=U("terminal.endSessionFor",{name:eM});return(0,r.jsx)("button",{type:"button",onClick:eA,"aria-label":e,title:e,"data-testid":"terminal-end-session-button-".concat(d),className:"flex items-center justify-center p-0.5 rounded text-muted-foreground hover:text-danger focus:text-danger hover:bg-danger/10 focus:outline-none focus-visible:ring-2 focus-visible:ring-danger/50 transition-colors",children:(0,r.jsx)(ew.A,{size:14,"aria-hidden":"true"})})},[T,K.isRunning,U,eM,eA,d]);return(0,r.jsx)(tr,{worktreeId:o,splitIndex:d,cliToolId:u,instanceId:I,instance:h,availableInstances:x,onInstanceChange:f,headerExtras:eL,status:j,agentModel:E,onFocus:p,attaching:K.attaching,terminal:eE,footer:eI,onDropInstance:N,draggedInstanceId:C})}),l6=(0,i.memo)(function(e){var t;let{task:n,latestRun:a,latestRunGates:s,onOpen:l,className:o=""}=e,d=(0,c.c)("worktree"),u=(0,i.useMemo)(()=>{if(!n)return"";let e=[d("verification.chip.taskReason",{title:n.title,status:d("task.status.".concat(n.status))})];if(a){if(e.push(d("verification.chip.runReason",{verdict:d("verification.runStatus.".concat(a.status)),runId:a.id})),s&&s.length>0){let t=s.filter(e=>rg.includes(e.status));e.push(t.length>0?d("verification.chip.failingGates",{gates:t.map(e=>e.gateId).join(", ")}):d("verification.chip.gatesPassed",{count:s.length}))}}else e.push(d("verification.chip.noRun"));return e.push(d("verification.chip.openHint")),e.join(" \xb7 ")},[n,a,s,d]);return n?(0,r.jsxs)("button",{type:"button",onClick:l,"data-testid":"verification-status-chip","aria-label":u,title:u,className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border bg-surface-2 px-2 py-1 text-xs text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation ".concat(o).trim(),children:[(0,r.jsx)(rm.A,{size:14,"aria-hidden":"true",className:"flex-shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"truncate font-medium","data-testid":"verification-chip-title",children:(t=n.title,t.length<=36?t:"".concat(t.slice(0,35),"…"))}),(0,r.jsx)(rh.E,{variant:rx[n.status],className:"flex-shrink-0 px-1.5 py-0","data-testid":"verification-chip-task-status",children:d("task.status.".concat(n.status))}),(0,r.jsx)(rh.E,{variant:a?rf[a.status]:"gray",className:"flex-shrink-0 px-1.5 py-0 font-mono","data-testid":"verification-chip-run-status",children:a?d("verification.chip.resultBadge",{verdict:d("verification.runStatus.".concat(a.status))}):d("verification.chip.dash")})]}):null}),l8=(0,i.memo)(function(e){let{isBranchMismatch:t,currentBranch:n,initialBranch:a}=e,s=(0,c.c)("worktree"),[l,o]=(0,i.useState)(!1);return((0,i.useEffect)(()=>{o(!1)},[n]),!t||l||null===a)?null:(0,r.jsxs)("div",{"data-testid":"branch-mismatch-alert",role:"alert",className:"flex items-center gap-3 px-4 py-2 bg-warning-subtle border border-warning-border text-warning-foreground rounded-lg",children:[(0,r.jsx)(rP.A,{className:"w-5 h-5 text-warning flex-shrink-0"}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsxs)("span",{className:"text-sm",children:[s("branchMismatch.changedFrom")," ",(0,r.jsx)("span",{className:"font-medium",children:a})," ",s("branchMismatch.to")," ",(0,r.jsx)("span",{className:"font-medium",children:n})]})}),(0,r.jsx)("button",{type:"button",onClick:()=>o(!0),className:"p-1 rounded hover:bg-warning-subtle transition-colors","aria-label":s("branchMismatch.dismiss"),children:(0,r.jsx)(ew.A,{className:"w-4 h-4"})})]})});var l9=n(58734);let l7=(0,i.memo)(function(e){let{isOpen:t,onClose:n,onConfirm:a,worktreeId:s,sourcePath:l,sourceType:o}=e,d=(0,c.c)("worktree"),u=(0,c.c)("common"),[h,x]=(0,i.useState)(""),[f,p]=(0,i.useState)(new Set([""])),[g,b]=(0,i.useState)([]),[v,j]=(0,i.useState)(!1),[w,k]=(0,i.useState)(new Set),N=l.includes("/")?l.substring(0,l.lastIndexOf("/")):"";(0,i.useEffect)(()=>{t&&(x(N),p(new Set([""])),b([]),C())},[t,s]);let C=(0,i.useCallback)(async()=>{j(!0);try{let e=await fetch("/api/worktrees/".concat(s,"/tree"));if(!e.ok)return;let t=(await e.json()).items.filter(e=>"directory"===e.type).map(e=>({name:e.name,path:e.name,loaded:!1}));b(t)}catch(e){}finally{j(!1)}},[s]),S=(0,i.useCallback)(async e=>{k(t=>new Set(t).add(e));try{let t=await fetch("/api/worktrees/".concat(s,"/tree/").concat(e));if(!t.ok)return;let n=(await t.json()).items.filter(e=>"directory"===e.type).map(t=>({name:t.name,path:"".concat(e,"/").concat(t.name),loaded:!1}));b(t=>(function e(t,n,a){return t.map(t=>t.path===n?{...t,children:a,loaded:!0}:t.children?{...t,children:e(t.children,n,a)}:t)})(t,e,n))}catch(e){}finally{k(t=>{let n=new Set(t);return n.delete(e),n})}},[s]),T=(0,i.useCallback)(async e=>{p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});let t=function e(t,n){for(let a of t){if(a.path===n)return a;if(a.children){let t=e(a.children,n);if(t)return t}}return null}(g,e);t&&!t.loaded&&await S(e)},[g,S]),E=(0,i.useCallback)(e=>!(e===N||"directory"===o&&(e===l||e.startsWith(l+"/")))&&!0,[N,l,o]),I=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=f.has(e.path),a=h===e.path,s=w.has(e.path),l=E(e.path);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 py-1.5 px-2 cursor-pointer rounded text-sm transition-colors ".concat(a?"bg-accent-100 text-accent-800":"hover:bg-muted text-foreground"," ").concat(l?"":"opacity-40 cursor-not-allowed"),style:{paddingLeft:"".concat(.5+1.25*t,"rem")},onClick:()=>{l&&x(e.path)},children:[(0,r.jsx)("button",{className:"w-4 h-4 flex items-center justify-center flex-shrink-0",onClick:t=>{t.stopPropagation(),T(e.path)},children:s?(0,r.jsx)(m.y$,{size:"xs",variant:"muted"}):(0,r.jsx)(tV.A,{className:"w-3 h-3 text-muted-foreground transition-transform ".concat(n?"rotate-90":"")})}),n?(0,r.jsx)(l9.A,{className:"w-4 h-4 text-warning flex-shrink-0"}):(0,r.jsx)(y.A,{className:"w-4 h-4 text-warning flex-shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:e.name})]}),n&&e.children&&(0,r.jsx)("div",{children:e.children.map(e=>I(e,t+1))})]},e.path)},M=E(h);return(0,r.jsx)(e7.a,{isOpen:t,onClose:n,title:d("fileTree.moveDialogTitle"),size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"text-sm text-muted-foreground",children:[d("fileTree.moveTo"),": ",(0,r.jsx)("span",{className:"font-mono text-foreground",children:l})]}),(0,r.jsxs)("div",{className:"border border-border rounded-lg max-h-64 overflow-y-auto p-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 py-1.5 px-2 cursor-pointer rounded text-sm transition-colors ".concat(""===h?"bg-accent-100 text-accent-800":"hover:bg-muted text-foreground"," ").concat(E("")?"":"opacity-40 cursor-not-allowed"),onClick:()=>{E("")&&x("")},children:[(0,r.jsx)("span",{className:"w-4 h-4"}),(0,r.jsx)(y.A,{className:"w-4 h-4 text-warning flex-shrink-0"}),(0,r.jsx)("span",{children:d("fileTree.rootDirectory")})]}),v?(0,r.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,r.jsx)(m.y$,{size:"md",variant:"muted"})}):g.map(e=>I(e,1))]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(m.$n,{variant:"ghost",onClick:n,className:"px-4 py-2 text-sm text-foreground bg-white border border-border rounded-md hover:bg-muted transition-colors",children:u("cancel")}),(0,r.jsx)(m.$n,{variant:"ghost",onClick:()=>a(h),disabled:!M,className:"px-4 py-2 text-sm text-white bg-accent-600 rounded-md hover:bg-accent-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:d("fileTree.moveConfirm")})]})]})})});function ie(e,t){let n=e.trim();return n?0>=n.lastIndexOf(".")?n+t:n:""}let it=(0,i.memo)(function(e){let{isOpen:t,parentPath:n,onConfirm:a,onCancel:s}=e,l=(0,c.c)("worktree"),o=(0,c.c)("common"),[d,u]=(0,i.useState)(""),[m,h]=(0,i.useState)(".md"),x=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(t){u(""),h(".md");let e=setTimeout(()=>{var e;null==(e=x.current)||e.focus()},100);return()=>clearTimeout(e)}},[t]);let f=(0,i.useCallback)(()=>{let e=ie(d,m);e&&a(e)},[d,m,a]),p=(0,i.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),f())},[f]),g=ie(d,m),b=n?"".concat(n,"/").concat(g):g;return(0,r.jsx)(e7.a,{isOpen:t,onClose:s,title:l("newFileDialog.title"),size:"sm",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"new-file-name",className:"block text-sm font-medium text-foreground mb-1",children:l("newFileDialog.fileNameLabel")}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{ref:x,id:"new-file-name","data-testid":"new-file-name-input",type:"text",value:d,onChange:e=>u(e.target.value),onKeyDown:p,placeholder:l("newFileDialog.placeholder"),className:"flex-1 px-3 py-2 border border-input rounded-lg bg-surface text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),(0,r.jsx)("select",{"data-testid":"new-file-ext-select",value:m,onChange:e=>h(e.target.value),className:"px-3 py-2 border border-input rounded-lg bg-surface text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",children:lr.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),g&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground font-mono bg-muted rounded px-2 py-1",children:b}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:s,className:"px-4 py-2 text-sm font-medium text-foreground bg-muted hover:bg-muted/80 rounded-lg transition-colors",children:o("cancel")}),(0,r.jsx)("button",{type:"button","data-testid":"new-file-confirm-button",onClick:f,disabled:!g,className:"px-4 py-2 text-sm font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-lg transition-colors",children:l("newFileDialog.create")})]})]})})}),ia=(0,i.memo)(function(e){var t,n,a,s,l;let{worktreeId:o,worktree:d,worktreeName:u,worktreeStatus:m,instances:h,rosterReady:x,activeInstanceId:f,setActiveInstanceId:p,hasUpdate:g,lastAutoResponse:b,activeActivity:v,onActivityToggle:y,onActivityOpen:j,verification:w,onBackClick:k,onInfoClick:N,onWorktreeStatusChange:C,pendingInsertTextMap:S,setFocusedSplitIndex:E,handleInsertToSplit:I,handleInsertConsumed:M,handleInsertToMessage:A,autoYesStateMap:L,makeAutoYesToggleHandler:R,showArchived:P,onShowArchivedChange:D,historyDisplayLimit:F,onHistoryDisplayLimitChange:O,historyUserOnly:z,onHistoryUserOnlyChange:_,onMessageSent:B,onFilePathClick:V,showToast:W,tabsState:H,tabsActions:U,onLoadContent:K,onLoadError:$,onSetLoading:q,onFilePanelSave:G,onDirtyChange:J,onOpenFile:Y,diffContent:Q,diffFilePath:X,onCloseDiff:Z,fileSearch:ee,fileTreeRefresh:et,onFileSelect:en,onNewFile:ea,onNewDirectory:er,onRename:es,onDelete:el,onUpload:ei,onMove:eo,onFileTreeReset:ec,onDiffSelect:ed,onAgentInstancesChange:eu,vibeLocalModel:em,onVibeLocalModelChange:eh,vibeLocalContextWindow:ex,onVibeLocalContextWindowChange:ef,isInfoModalOpen:ep,onInfoModalClose:eg,onWorktreeUpdate:eb,fileInputRef:ev,onFileInputChange:ey,onKillSession:ej,onRequestSessionEnd:ew,killTarget:ek,isKillPending:eN,onKillCancel:eC,onKillConfirm:eS,moveTarget:eT,isMoveDialogOpen:eE,onMoveCancel:eI,onMoveConfirm:eM,showNewFileDialog:eA,newFileParentPath:eL,onNewFileConfirm:eR,onNewFileCancel:eP,killDialogTitle:eD,killDialogWarning:eF,cancelLabel:eO,endLabel:ez}=e,e_=(0,c.c)("worktree"),[eB,eV]=i.useState(null),eW=(0,i.useCallback)(e=>eV(e),[]),eH=(0,i.useCallback)(()=>eV(null),[]),eU=(0,i.useMemo)(()=>sz(null==d?void 0:d.sessionStatusByInstance),[null==d?void 0:d.sessionStatusByInstance]),[eK,e$]=i.useState(null),eq=i.useRef(0),eG=(0,i.useCallback)(e=>{p(e),eq.current+=1,e$({instanceId:e,token:eq.current})},[p]),eJ=(0,i.useCallback)(()=>{j("verification")},[j]),eY=(0,i.useCallback)(e=>{var t,n,a,s,l,i,c,u,m,h;let{splitIndex:x,cliToolId:f,instanceId:g,instance:v,availableInstances:y,onInstanceChange:j,onFocus:w,onDropInstance:k}=e,N=null!=(c=S.get(x))?c:null,C=L.get(g),T=null!=(u=null==C?void 0:C.enabled)&&u,E=null!=(m=null==C?void 0:C.expiresAt)?m:null,A=(0,te.kA)(null!=(h=null==d||null==(t=d.sessionStatusByInstance)?void 0:t[g])?h:null==d||null==(n=d.sessionStatusByCli)?void 0:n[f]);return(0,r.jsx)(l3,{worktreeId:o,splitIndex:x,cliToolId:f,instanceId:g,instance:v,availableInstances:y,onInstanceChange:e=>{j(e),0===x&&p(e)},onFocus:w,pendingInsertText:N,onInsertConsumed:()=>M(x),onMessageSent:B,cliStatus:A,agentModel:sO(null==d||null==(s=d.sessionStatusByInstance)||null==(a=s[g])?void 0:a.model,null==d||null==(i=d.sessionStatusByInstance)||null==(l=i[g])?void 0:l.reasoningEffort),autoYes:{enabled:T,expiresAt:E,lastAutoResponse:b,onToggle:R(f,g)},history:{showArchived:P,onShowArchivedChange:D,historyDisplayLimit:F,onHistoryDisplayLimitChange:O,historyUserOnly:z,onHistoryUserOnlyChange:_,onInsertToMessage:e=>I(x,e),onFilePathClick:V,showToast:W},onDropInstance:k,draggedInstanceId:eB,onRequestSessionEnd:ew})},[o,S,L,M,B,p,b,R,null==d?void 0:d.sessionStatusByCli,null==d?void 0:d.sessionStatusByInstance,V,W,I,P,D,F,O,z,_,eB,ew]),eQ=(0,i.useMemo)(()=>(0,r.jsx)(lW,{worktreeId:o,instances:h,rosterReady:x,renderPane:eY,onFocusedSplitChange:E,showToast:W,onActiveInstanceChange:p,headerInstanceSelection:eK}),[o,h,x,eY,E,W,p,eK]),eX=(0,i.useMemo)(()=>(0,r.jsx)(lI,{terminal:eQ,terminalHeader:null,fileTabs:H,worktreeId:o,onCloseTab:U.closeTab,onActivateTab:U.activateTab,onLoadContent:K,onLoadError:$,onSetLoading:q,onFileSaved:G,diffContent:Q,diffFilePath:X,onCloseDiff:Z,onDirtyChange:J,onMoveToFront:U.moveToFront,onOpenFile:Y}),[eQ,H,o,U.closeTab,U.activateTab,K,$,q,G,Q,X,Z,J,U.moveToFront,Y]),eZ=(0,i.useMemo)(()=>(0,r.jsx)(s8,{active:v,onToggle:y}),[v,y]),e0=(0,i.useMemo)(()=>{var e;return{files:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(nJ,{query:ee.query,mode:ee.mode,isSearching:ee.isSearching,error:ee.error,onQueryChange:ee.setQuery,onModeChange:ee.setMode,onClear:ee.clearSearch}),(0,r.jsx)(nK,{worktreeId:o,onFileSelect:en,onNewFile:ea,onNewDirectory:er,onRename:es,onDelete:el,onUpload:ei,onMove:eo,onResetView:ec,refreshTrigger:et,pollingEnabled:"files"===v,searchQuery:ee.query,searchMode:ee.mode,searchResults:null==(e=ee.results)?void 0:e.results,className:"flex-1 min-h-0"})]}),git:(0,r.jsx)(sL,{worktreeId:o,onDiffSelect:ed,isMobile:!1,worktree:null!=d?d:void 0,onInsertToMessage:A,className:"h-full"}),notes:(0,r.jsx)(n2,{worktreeId:o,className:"h-full",onInsertToMessage:A}),schedules:(0,r.jsx)(aI,{worktreeId:o,className:"h-full",onInsertToMessage:A,instances:h}),agent:(0,r.jsx)(aO,{worktreeId:o,instances:h,onInstancesChange:eu,vibeLocalModel:em,onVibeLocalModelChange:eh,vibeLocalContextWindow:ex,onVibeLocalContextWindowChange:ef,modelByInstance:eU}),timer:(0,r.jsx)(aQ,{worktreeId:o,instances:h}),todo:(0,r.jsx)(n8,{worktreeId:o,className:"h-full"}),skills:(0,r.jsx)(ru,{worktreeId:o,className:"h-full"}),verification:(0,r.jsx)(rA,{state:w,className:"h-full"}),env:(0,r.jsx)(r5,{worktreeId:o,className:"h-full"})}},[o,d,v,ee.query,ee.mode,ee.isSearching,ee.error,ee.setQuery,ee.setMode,ee.clearSearch,null==(t=ee.results)?void 0:t.results,en,ea,er,es,el,ei,eo,ec,et,ed,A,h,eu,em,eh,ex,ef,eU,w]),e1=(0,i.useMemo)(()=>null===v?null:(0,r.jsx)(le,{active:v,activities:e0}),[v,e0]);return(0,r.jsx)(T,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"flex h-full overflow-hidden relative",children:[eZ,(0,r.jsxs)("div",{className:"flex flex-col flex-1 min-h-0 min-w-0",children:[(0,r.jsx)(sV,{worktreeName:u,repositoryName:null!=(s=null!=(a=null==d?void 0:d.repositoryDisplayName)?a:null==d?void 0:d.repositoryName)?s:e_("detail.unknownRepository"),description:null==d?void 0:d.description,status:m,gitStatus:null==d?void 0:d.gitStatus,onBackClick:k,onInfoClick:N,hasUpdate:g,worktreeStatus:null!=(l=null==d?void 0:d.status)?l:null,onWorktreeStatusChange:C,sessionStatusByCli:null==d?void 0:d.sessionStatusByCli,sessionStatusByInstance:null==d?void 0:d.sessionStatusByInstance,instances:h,activeInstanceId:f,onActiveInstanceChange:eG,onAgentDragStart:eW,onAgentDragEnd:eH,onKillSession:ej,verificationChip:(0,r.jsx)(l6,{task:w.task,latestRun:w.latestRun,latestRunGates:null!==w.selectedRun&&w.selectedRun.id===(null==(n=w.latestRun)?void 0:n.id)?w.selectedRun.gates:null,onOpen:eJ})}),(null==d?void 0:d.gitStatus)&&(0,r.jsx)(l8,{isBranchMismatch:d.gitStatus.isBranchMismatch,currentBranch:d.gitStatus.currentBranch,initialBranch:d.gitStatus.initialBranch}),(0,r.jsx)("div",{className:"flex-1 min-h-0 min-w-0",children:(0,r.jsx)(sK,{activityPane:e1,rightPane:(0,r.jsx)(no,{terminal:eX})})})]}),(0,r.jsx)(sW,{worktreeId:o,worktree:d,isOpen:ep,onClose:eg,onWorktreeUpdate:eb}),(0,r.jsx)("input",{ref:ev,type:"file",accept:la.join(","),onChange:ey,className:"hidden","aria-label":e_("detail.uploadFile")}),(0,r.jsx)(e7.a,{isOpen:null!==ek,onClose:eC,title:eD,size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:eF}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:eC,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:eO}),(0,r.jsx)("button",{type:"button",onClick:eS,disabled:eN,"data-testid":"kill-session-confirm-button",className:"px-4 py-2 text-sm font-medium rounded-md bg-danger hover:bg-danger/90 text-white disabled:opacity-60 disabled:cursor-not-allowed",children:ez})]})]})}),eT&&(0,r.jsx)(l7,{isOpen:eE,onClose:eI,onConfirm:eM,worktreeId:o,sourcePath:eT.path,sourceType:eT.type}),(0,r.jsx)(it,{isOpen:eA,parentPath:eL,onConfirm:eR,onCancel:eP})]})})});tt.oo;var ir=n(51434);let is={data:null,messageId:null,visible:!1,answering:!1},il={mode:"split",mobileActivePane:"terminal",leftPaneTab:"history",splitRatio:.5,leftPaneCollapsed:!1,activityBar:{active:"files"},historyPane:{visible:!0,width:25,collapsed:!1}},ii={type:null,message:null,retryable:!1,retryCount:0};function io(){return{phase:"idle",prompt:{...is},layout:{...il},error:{...ii},messages:[],wsConnected:!1}}function ic(e,t){switch(t.type){case"SET_PHASE":return{...e,phase:t.phase};case"SHOW_PROMPT":return{...e,phase:"prompt",prompt:{data:t.data,messageId:t.messageId,visible:!0,answering:!1}};case"CLEAR_PROMPT":return{...e,prompt:{...is}};case"SET_PROMPT_ANSWERING":return{...e,prompt:{...e.prompt,answering:t.answering}};case"SET_LAYOUT_MODE":return{...e,layout:{...e.layout,mode:t.mode}};case"SET_MOBILE_ACTIVE_PANE":return{...e,layout:{...e.layout,mobileActivePane:t.pane}};case"SET_SPLIT_RATIO":return{...e,layout:{...e.layout,splitRatio:t.ratio}};case"SET_LEFT_PANE_TAB":return{...e,layout:{...e.layout,leftPaneTab:t.tab}};case"TOGGLE_LEFT_PANE":return{...e,layout:{...e.layout,leftPaneCollapsed:!e.layout.leftPaneCollapsed}};case"SET_LEFT_PANE_COLLAPSED":return{...e,layout:{...e.layout,leftPaneCollapsed:t.collapsed}};case"SET_ACTIVE_ACTIVITY":return{...e,layout:{...e.layout,activityBar:{...e.layout.activityBar,active:t.activity}}};case"TOGGLE_ACTIVITY":{let n=e.layout.activityBar.active===t.activity?null:t.activity;return{...e,layout:{...e.layout,activityBar:{...e.layout.activityBar,active:n}}}}case"TOGGLE_HISTORY_PANE":{let t=!e.layout.historyPane.visible;return{...e,layout:{...e.layout,historyPane:{...e.layout.historyPane,visible:t,collapsed:!t}}}}case"SET_HISTORY_PANE_VISIBLE":return{...e,layout:{...e.layout,historyPane:{...e.layout.historyPane,visible:t.visible,collapsed:!t.visible}}};case"SET_HISTORY_WIDTH":return{...e,layout:{...e.layout,historyPane:{...e.layout.historyPane,width:t.width}}};case"SET_ERROR":return{...e,error:t.error};case"CLEAR_ERROR":return{...e,error:{...ii}};case"INCREMENT_RETRY_COUNT":return{...e,error:{...e.error,retryCount:e.error.retryCount+1}};case"SET_MESSAGES":return{...e,messages:t.messages};case"ADD_MESSAGE":return{...e,messages:[...e.messages,t.message]};case"UPDATE_MESSAGE":return{...e,messages:e.messages.map(e=>e.id===t.id?{...e,...t.updates}:e)};case"CLEAR_MESSAGES":return{...e,messages:[]};case"SET_WS_CONNECTED":return{...e,wsConnected:t.connected};default:return e}}var id=n(66966);function iu(e,t){try{window.localStorage.setItem(s3(e),null!=t?t:s5)}catch(e){}}function im(e,t){return e instanceof Error&&e.message?e.message:t}function ih(e){return e instanceof DOMException&&"AbortError"===e.name}let ix="commandmate:file-tabs:";function ip(e){let t=e.split("/");return t[t.length-1]||e}function ig(e,t,n){let a=e.findIndex(e=>e.path===t);if(-1===a)return null;let r=[...e];return r[a]=n(r[a]),r}let ib={tabs:[],activeIndex:null};var iv=n(63001);let iy="commandmate:showArchived",ij="activeCliTab-",iw="activeInstanceId-";function ik(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center justify-center h-full bg-surface text-muted-foreground",children:[(0,r.jsx)(u.y,{size:"lg",className:"mr-2"}),(0,r.jsx)("span",{children:e("detail.loadingEditor")})]})}let iN=(0,o.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(ik,{})}),iC=()=>{},iS=["terminal","history","files","memo","info"],iT=(0,i.memo)(function(e){var t,n,a,l,o,u,m;let{worktreeId:f}=e,{activeActivity:p,activeCliTab:b,activeInstanceId:v,activeTab:y,agentInstances:j,autoYesEnabled:w,autoYesExpiresAt:k,autoYesStateMap:N,diffContent:E,diffFilePath:I,disableAutoFollow:M,displayedInstances:A,editorFilePath:R,error:D,fetchCurrentOutput:F,fileInputRef:O,fileSearch:z,fileTreeRefresh:_,handleActivityOpen:W,handleActivityToggle:H,handleAgentInstancesChange:U,handleAutoYesToggle:K,handleBackClick:$,handleCloseDiff:q,handleDelete:G,handleDiffSelect:J,handleDirtyChange:Y,handleEditorClose:Q,handleEditorSave:Z,handleFileInputChange:ee,handleFilePanelSave:et,handleFilePathClick:en,handleFileSelect:er,handleHistoryDisplayLimitChange:es,handleHistoryUserOnlyChange:el,handleInfoClick:ei,handleInfoModalClose:ed,handleInsertConsumed:eu,handleInsertConsumedSingle:em,handleInsertToMessage:eh,handleInsertToSplit:ex,handleKillCancel:ef,handleKillConfirm:ep,openKillConfirm:eg,openActiveKillConfirm:eb,killTarget:ev,isKillPending:ey,handleLoadContent:ej,handleLoadError:ew,handleMessageSent:ek,handleMobileFileViewerClose:eN,handleMobileTabChange:eC,handleMove:eS,handleMoveCancel:eT,handleMoveConfirm:eI,handleNewDirectory:eM,handleNewFile:eA,handleNewFileCancel:eL,handleNewFileConfirm:eR,handleOpenFile:eP,handlePromptDismiss:eD,handlePromptRespond:eF,handleRename:eO,handleRetry:ez,handleSetLoading:e_,handleShowArchivedChange:eB,handleUpload:eV,handleVibeLocalContextWindowChange:eW,handleVibeLocalModelChange:eH,handleWorktreeStatusChange:eU,hasUpdate:e$,historyDisplayLimit:eq,historySubTab:eG,historyUserOnly:eJ,isEditorMaximized:eQ,isInfoModalOpen:eZ,isMobile:e0,isMoveDialogOpen:e1,isSelectionListActive:e2,isPagerActive:e4,lastAutoResponse:e5,loading:e3,makeAutoYesToggleHandler:e6,mobileFileViewerPath:e8,mobileSelectedAgents:e9,moveTarget:tn,newFileParentPath:ta,openMobileDrawer:tr,pendingInsertText:ts,pendingInsertTextMap:tl,rosterReady:ti,setActiveInstanceId:to,setFocusedSplitIndex:tc,setHistorySubTab:td,setIsEditorMaximized:tu,setWorktree:tm,showArchived:th,showNewFileDialog:tx,showToast:tf,state:tp,tCommon:tg,tWorktree:tb,tabsActions:tv,tabsState:ty,resetFileTreeView:tj,toggleInstanceVisible:tw,verification:tk,vibeLocalContextWindow:tN,vibeLocalModel:tC,visibleInstanceIds:tS,worktree:tT,worktreeName:tE,worktreeStatus:tM}=function(e){var t,n,a,r,l,o,d,u,m,h;let{worktreeId:f}=e,p=(0,s.useRouter)(),g=(0,X.a)(),b=(0,i.useRef)(g);b.current=g;let{openMobileDrawer:v}=(0,s6.VF)(),{state:y,actions:j}=function(){let[e,t]=(0,i.useReducer)(ic,void 0,io),{value:n,setValue:a}=(0,r8.V)({key:"commandmate.worktree.leftPaneCollapsed",defaultValue:!1,validate:e=>"boolean"==typeof e}),r=(0,i.useRef)(e.layout.leftPaneCollapsed);r.current=e.layout.leftPaneCollapsed;let s=(0,i.useRef)(!1);(0,i.useEffect)(()=>{s.current||(s.current=!0,n!==r.current&&t({type:"SET_LEFT_PANE_COLLAPSED",collapsed:n}))},[n]);let l=(0,i.useMemo)(()=>({setPhase:e=>t({type:"SET_PHASE",phase:e}),showPrompt:(e,n)=>t({type:"SHOW_PROMPT",data:e,messageId:n}),clearPrompt:()=>t({type:"CLEAR_PROMPT"}),setPromptAnswering:e=>t({type:"SET_PROMPT_ANSWERING",answering:e}),setError:e=>t({type:"SET_ERROR",error:e}),clearError:()=>t({type:"CLEAR_ERROR"}),setMessages:e=>t({type:"SET_MESSAGES",messages:e}),addMessage:e=>t({type:"ADD_MESSAGE",message:e}),updateMessage:(e,n)=>t({type:"UPDATE_MESSAGE",id:e,updates:n}),clearMessages:()=>t({type:"CLEAR_MESSAGES"}),setMobileActivePane:e=>t({type:"SET_MOBILE_ACTIVE_PANE",pane:e}),setLeftPaneTab:e=>t({type:"SET_LEFT_PANE_TAB",tab:e}),setLayoutMode:e=>t({type:"SET_LAYOUT_MODE",mode:e}),setSplitRatio:e=>t({type:"SET_SPLIT_RATIO",ratio:e}),setWsConnected:e=>t({type:"SET_WS_CONNECTED",connected:e}),toggleLeftPane:()=>{let e=!r.current;t({type:"SET_LEFT_PANE_COLLAPSED",collapsed:e}),a(e)},setActiveActivity:e=>t({type:"SET_ACTIVE_ACTIVITY",activity:e}),toggleActivity:e=>t({type:"TOGGLE_ACTIVITY",activity:e}),toggleHistoryPane:()=>t({type:"TOGGLE_HISTORY_PANE"}),setHistoryPaneVisible:e=>t({type:"SET_HISTORY_PANE_VISIBLE",visible:e}),setHistoryWidth:e=>t({type:"SET_HISTORY_WIDTH",width:e})}),[a]);return{state:e,dispatch:t,actions:l}}(),w=(0,c.c)("worktree"),k=(0,c.c)("error"),N=(0,c.c)("common"),C=(0,c.c)("autoYes"),T=(0,ec.SC)(),E=(0,id.rC)(),I=null!=(l=null==E?void 0:E.worktrees.find(e=>e.id===f))?l:null,[M,A]=(0,i.useState)(I),[L,R]=(0,i.useState)(null===I),[P,D]=(0,i.useState)(null),[F,O]=(0,i.useState)(0),z=(0,i.useRef)(null!==I),[_,B]=(0,i.useState)(!1),[W,H]=function(e){let[t,n]=(0,i.useReducer)(function e(t,n){switch(n.type){case"OPEN_FILE":{let e=t.tabs.findIndex(e=>e.path===n.path);if(-1!==e){if(t.activeIndex===e)return t;return{...t,activeIndex:e}}if(t.tabs.length>=30)return t;let a={path:n.path,name:ip(n.path),content:null,loading:!1,error:null,isDirty:!1},r=[...t.tabs,a];return{tabs:r,activeIndex:r.length-1}}case"CLOSE_TAB":{var a,r;let e=t.tabs.findIndex(e=>e.path===n.path);if(-1===e)return t;let s=t.tabs.filter((t,n)=>n!==e),l=(a=t.activeIndex,0===(r=s.length)||null===a?null:e<a?a-1:e===a?Math.min(e,r-1):a);return{tabs:s,activeIndex:l}}case"ACTIVATE_TAB":{let e=t.tabs.findIndex(e=>e.path===n.path);if(-1===e||t.activeIndex===e)return t;return{...t,activeIndex:e}}case"SET_CONTENT":{let e=ig(t.tabs,n.path,e=>({...e,content:n.content,loading:!1,error:null,isDirty:!1}));if(!e)return t;return{...t,tabs:e}}case"SET_LOADING":{let e=ig(t.tabs,n.path,e=>({...e,loading:n.loading}));if(!e)return t;return{...t,tabs:e}}case"SET_ERROR":{let e=ig(t.tabs,n.path,e=>({...e,error:n.error,loading:!1}));if(!e)return t;return{...t,tabs:e}}case"RENAME_FILE":{let e=t.tabs.findIndex(e=>e.path===n.oldPath);if(-1===e)return t;let a=[...t.tabs];return a[e]={...a[e],path:n.newPath,name:ip(n.newPath)},{...t,tabs:a}}case"DELETE_FILE":return e(t,{type:"CLOSE_TAB",path:n.path});case"RESTORE":{let e=n.paths.slice(0,30).map(e=>({path:e,name:ip(e),content:null,loading:!1,error:null,isDirty:!1}));if(0===e.length)return ib;let t=n.activePath?Math.max(0,e.findIndex(e=>e.path===n.activePath)):0;return{tabs:e,activeIndex:t}}case"SET_DIRTY":{let e=t.tabs.find(e=>e.path===n.path);if(e&&e.isDirty===n.isDirty)return t;let a=ig(t.tabs,n.path,e=>({...e,isDirty:n.isDirty}));if(!a)return t;return{...t,tabs:a}}case"MOVE_TO_FRONT":{let e=t.tabs.findIndex(e=>e.path===n.path);if(-1===e||0===e)return t;return{tabs:[t.tabs[e],...t.tabs.filter((t,n)=>n!==e)],activeIndex:0}}case"CLOSE_ALL":if(0===t.tabs.length)return t;return ib;default:return t}},ib),a=(0,i.useRef)(!1),r=(0,i.useRef)(e);(0,i.useEffect)(()=>{if(r.current!==e&&(r.current=e,a.current=!1),a.current)return;a.current=!0;let t=function(e){try{let t=window.localStorage.getItem(ix+e);if(!t)return null;let n=JSON.parse(t);if("object"==typeof n&&null!==n&&Array.isArray(n.paths)&&n.paths.every(e=>"string"==typeof e)&&(null===n.activePath||"string"==typeof n.activePath))return n}catch(e){}return null}(e);t&&t.paths.length>0&&n({type:"RESTORE",paths:t.paths,activePath:t.activePath})},[e]),(0,i.useEffect)(()=>{if(a.current){var n,r;try{let a={paths:t.tabs.map(e=>e.path),activePath:null!==t.activeIndex&&null!=(r=null==(n=t.tabs[t.activeIndex])?void 0:n.path)?r:null};window.localStorage.setItem(ix+e,JSON.stringify(a))}catch(e){}}},[e,t]);let s=(0,i.useRef)(t);s.current=t;let l=(0,i.useCallback)(e=>{let t=s.current.tabs;return -1!==t.findIndex(t=>t.path===e)?(n({type:"OPEN_FILE",path:e}),"activated"):t.length>=30?"limit_reached":(n({type:"OPEN_FILE",path:e}),"opened")},[]),o=(0,i.useCallback)(e=>{n({type:"CLOSE_TAB",path:e})},[]),c=(0,i.useCallback)(e=>{n({type:"ACTIVATE_TAB",path:e})},[]),d=(0,i.useCallback)((e,t)=>{n({type:"RENAME_FILE",oldPath:e,newPath:t})},[]),u=(0,i.useCallback)(e=>{n({type:"DELETE_FILE",path:e})},[]),m=(0,i.useCallback)(e=>{n({type:"MOVE_TO_FRONT",path:e})},[]),h=(0,i.useCallback)(()=>{n({type:"CLOSE_ALL"})},[]),x=(0,i.useMemo)(()=>({dispatch:n,openFile:l,closeTab:o,activateTab:c,onFileRenamed:d,onFileDeleted:u,moveToFront:m,closeAllTabs:h}),[n,l,o,c,d,u,m,h]);return[t,x]}(f),[U,K]=(0,i.useState)(null),[$,q]=(0,i.useState)(null),[G,J]=(0,i.useState)(!1),[Y,Q]=(0,i.useState)(new Map),[Z,ee]=(0,i.useState)(null),[et,en]=(0,i.useState)(!1),[ea,er]=(0,i.useState)(!1),[es,el]=(0,i.useState)(!1),ei=(0,i.useRef)(!1),[eo,ed]=(0,i.useState)(null),[eu,em]=(0,i.useState)(iv.fJ),eh=(0,i.useRef)(eu);eh.current=eu;let[ex,ef]=(0,i.useState)(()=>(0,tt.lu)(iv.fJ)),ep=(0,i.useRef)(ex);ep.current=ex;let[eg,eb]=(0,i.useState)(null),ev=eg===f,[ey,ej]=(0,i.useState)(null),[ew,ek]=(0,i.useState)(null),[eN,eC]=(0,i.useState)(()=>{try{let e=window.localStorage.getItem(ij+f);if(e&&(0,tt.hR)(e))return e}catch(e){}return iv.fJ[0]}),eS=(0,i.useCallback)(e=>{eC(e);try{window.localStorage.setItem(ij+f,e)}catch(e){}},[f]),eT=(0,i.useRef)(eN);eT.current=eN;let[eI,eM]=(0,i.useState)(()=>{try{let e=window.localStorage.getItem(iw+f);if(e&&(0,tt.n6)(e))return e;let t=window.localStorage.getItem(ij+f);if(t&&(0,tt.hR)(t))return t}catch(e){}return iv.fJ[0]}),eA=(0,i.useCallback)(e=>{eM(e);try{window.localStorage.setItem(iw+f,e)}catch(e){}let t=ep.current.find(t=>t.id===e);t&&eS(t.cliTool)},[f,eS]),eL=(0,i.useRef)(eI);eL.current=eI;let eR=(0,i.useRef)(0),eP=(0,i.useRef)(0),eD=(0,i.useRef)(0),eF=null!=(o=null==(t=Y.get(eI))?void 0:t.enabled)&&o,eO=null!=(d=null==(n=Y.get(eI))?void 0:n.expiresAt)?d:null,[ez,e_]=(0,i.useState)(0),[eB,eV]=(0,i.useState)(!1),[eW,eH]=(0,i.useState)(""),{active:eU,setActive:eK,toggle:e$}=function(e){let[t,n]=(0,i.useState)(s4),a=(0,i.useRef)(t);a.current=t;let r=(0,i.useRef)(e);return r.current=e,(0,i.useEffect)(()=>{let t=function(e){try{let t=window.localStorage.getItem(s3(e));if(t===s5)return null;if(t&&"string"==typeof t&&s2.has(t))return t}catch(e){}return s4}(e);t!==a.current&&n(t)},[e]),{active:t,setActive:(0,i.useCallback)(e=>{n(e),iu(r.current,e)},[]),toggle:(0,i.useCallback)(e=>{if(a.current===e){n(null),iu(r.current,null);return}n(e),iu(r.current,e)},[])}}(f),{historySubTab:eq,setHistorySubTab:eG,showArchived:eJ,handleShowArchivedChange:eQ,historyUserOnly:eZ,handleHistoryUserOnlyChange:e0,historyDisplayLimit:e1,handleHistoryDisplayLimitChange:e2}=function(){let[e,t]=(0,i.useState)("message"),[n,a]=(0,i.useState)(()=>"true"===localStorage.getItem(iy)),r=(0,i.useCallback)(e=>{a(e),localStorage.setItem(iy,String(e))},[]),[s,l]=(0,i.useState)(()=>{try{return"true"===localStorage.getItem(nm)}catch(e){return!1}}),o=(0,i.useCallback)(e=>{l(e);try{localStorage.setItem(nm,String(e))}catch(e){}},[]),[c,d]=(0,i.useState)(()=>{try{let e=localStorage.getItem(nd);if(null===e)return 50;let t=parseInt(e,10);return nu(t)?t:50}catch(e){return 50}});return{historySubTab:e,setHistorySubTab:t,showArchived:n,handleShowArchivedChange:r,historyUserOnly:s,handleHistoryUserOnlyChange:o,historyDisplayLimit:c,handleHistoryDisplayLimitChange:(0,i.useCallback)(e=>{d(e);try{localStorage.setItem(nd,String(e))}catch(e){}},[])}}(),e4=(0,i.useRef)(eJ);(0,i.useEffect)(()=>{e4.current=eJ},[eJ]);let e5=(0,i.useRef)(e1);(0,i.useEffect)(()=>{e5.current=e1},[e1]);let{pendingInsertTextMap:e3,pendingInsertText:e6,setFocusedSplitIndex:e8,handleInsertToMessage:e9,handleInsertToSplit:e7,handleInsertConsumed:te,handleInsertConsumedSingle:tn}=function(){var e;let[t,n]=(0,i.useState)(()=>new Map),[a,r]=(0,i.useState)(0),s=(0,i.useCallback)(e=>{n(t=>{let n=new Map(t);return n.set(a,e),n})},[a]),l=(0,i.useCallback)((e,t)=>{n(n=>{let a=new Map(n);return a.set(e,t),a})},[]),o=(0,i.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),c=null!=(e=t.get(0))?e:null,d=(0,i.useCallback)(()=>o(0),[o]);return{pendingInsertTextMap:t,pendingInsertText:c,focusedSplitIndex:a,setFocusedSplitIndex:r,handleInsertToMessage:s,handleInsertToSplit:l,handleInsertConsumed:o,handleInsertConsumedSingle:d}}(),{diffContent:ta,diffFilePath:tr,handleDiffSelect:ts,handleCloseDiff:tl}=function(e){let[t,n]=(0,i.useState)(null),[a,r]=(0,i.useState)(null);return{diffContent:t,diffFilePath:a,handleDiffSelect:(0,i.useCallback)((t,a)=>{e||(n(t),r(a))},[e]),handleCloseDiff:(0,i.useCallback)(()=>{n(null),r(null)},[])}}(g),ti=function(e){let{worktreeId:t,initialMode:n="name",debounceMs:a=300}=e,[r,s]=(0,i.useState)(""),[l,o]=(0,i.useState)(""),[c,d]=(0,i.useState)(n),[u,m]=(0,i.useState)(!1),[h,f]=(0,i.useState)(null),[p,g]=(0,i.useState)(null),b=(0,i.useRef)(null),v=(0,i.useMemo)(()=>(0,x.sg)(e=>{o(e)},a),[a]),y=(0,i.useCallback)(e=>{s(e),v(e),g(null)},[v]),j=(0,i.useCallback)(()=>{s(""),o(""),f(null),g(null),m(!1),b.current&&(b.current.abort(),b.current=null)},[]),w=(0,i.useCallback)(e=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t))},[l]),k=(0,i.useCallback)(()=>h&&0!==h.results.length?(0,x.q3)(h.results.map(e=>e.filePath)):new Set,[h]);return(0,i.useEffect)(()=>{if("content"!==c||!l.trim())return void f(null);b.current&&b.current.abort();let e=new AbortController;return b.current=e,(async()=>{m(!0),g(null);try{var n,a;let r=await fetch("/api/worktrees/".concat(encodeURIComponent(t),"/search?q=").concat(encodeURIComponent(l),"&mode=content"),{signal:e.signal});if(!r.ok){let e=await r.json();throw Error((null==(n=e.error)?void 0:n.message)||"Search failed: ".concat(r.status))}let s=await r.json();if(s.success)f({mode:"content",query:l,results:s.results,totalMatches:s.totalMatches,truncated:s.truncated,executionTimeMs:s.executionTimeMs});else throw Error((null==(a=s.error)?void 0:a.message)||"Search failed")}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;g(e instanceof Error?e.message:"An error occurred while searching"),f(null)}finally{m(!1)}})(),()=>{e.abort()}},[c,l,t]),(0,i.useEffect)(()=>{"name"===c&&(f(null),m(!1),g(null))},[c]),{query:r,mode:c,isSearching:u,results:h,error:p,setQuery:y,setMode:d,clearSearch:j,filterByName:w,getMatchedPaths:k}}({worktreeId:f}),to=(0,i.useRef)(!1),tc=(0,i.useRef)(f);(0,i.useEffect)(()=>{tc.current!==f&&(j.clearMessages(),to.current=!1,Q(new Map),tc.current=f)},[f,j]);let td=(0,i.useCallback)(async()=>{try{var e,t;let n=await fetch("/api/worktrees/".concat(f));if(!n.ok)throw Error("Failed to fetch worktree: ".concat(n.status));let a=await n.json();if(A(a),a.selectedAgents){let e=eh.current;a.selectedAgents.length===e.length&&a.selectedAgents.every((t,n)=>t===e[n])||em(a.selectedAgents)}if(a.agentInstances){let e=ep.current,t=a.agentInstances;t.length===e.length&&t.every((t,n)=>t.id===e[n].id&&t.cliTool===e[n].cliTool&&t.alias===e[n].alias)||ef(t),eb(f)}return"vibeLocalModel"in a&&ej(null!=(e=a.vibeLocalModel)?e:null),"vibeLocalContextWindow"in a&&ek(null!=(t=a.vibeLocalContextWindow)?t:null),a}catch(e){return D(e instanceof Error?e.message:"Unknown error"),null}},[f]),tu=(0,i.useCallback)(async()=>{let e=eT.current,t=b.current,n=eL.current,a=++eR.current;try{let r=new URLSearchParams({cliTool:e,unit:"pairs"});t&&r.set("instance",n),e4.current&&r.set("includeArchived","true"),r.set("limit",String(e5.current));let s=await fetch("/api/worktrees/".concat(f,"/messages?").concat(r.toString()));if(!s.ok)throw Error("Failed to fetch messages: ".concat(s.status));let l=await s.json();if(eR.current!==a||eT.current!==e||t&&eL.current!==n)return;j.setMessages(l.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(r){if(eR.current!==a||eT.current!==e||t&&eL.current!==n)return;console.error("[WorktreeDetailRefactored] Error fetching messages:",r)}},[f,j]),tm=(0,i.useCallback)(async()=>{let e=eT.current,t=b.current,n=eL.current,a=++eP.current;try{var r,s,l,i;let o=t?"/api/worktrees/".concat(f,"/current-output?cliTool=").concat(e,"&instance=").concat(encodeURIComponent(n)):"/api/worktrees/".concat(f,"/current-output?cliTool=").concat(e),c=await fetch(o);if(!c.ok)return;let d=await c.json();if(eP.current!==a||eT.current!==e||t&&eL.current!==n||d.cliToolId&&d.cliToolId!==e)return;if(d.isPromptWaiting&&d.promptData?j.showPrompt(d.promptData,"prompt-".concat(Date.now())):!d.isPromptWaiting&&y.prompt.visible&&j.clearPrompt(),er(null!=(r=d.isSelectionListActive)&&r),el(null!=(s=d.isPagerActive)&&s),ee(null!=(l=d.lastServerResponseTimestamp)?l:null),en(null!=(i=d.serverPollerActive)&&i),d.autoYes){let a=ei.current,r=d.autoYes,s=t?n:e;Q(e=>{let t=new Map(e);return t.set(s,{enabled:r.enabled,expiresAt:r.expiresAt}),t}),ei.current=r.enabled,a&&!d.autoYes.enabled&&("stop_pattern_matched"===d.autoYes.stopReason||"consecutive_errors"===d.autoYes.stopReason)&&ed(d.autoYes.stopReason)}}catch(r){if(eP.current!==a||eT.current!==e||t&&eL.current!==n)return;console.error("[WorktreeDetailRefactored] Error fetching current output:",r)}},[f,j,y.prompt.visible]),th=(0,i.useCallback)(async()=>{let e=++eD.current;try{let a=await fetch("/api/worktrees/".concat(f,"/auto-yes"));if(!a.ok)return;let r=await a.json();if(eD.current!==e)return;let s=null==r?void 0:r.instances;if(!s||"object"!=typeof s)return;let l=new Map;for(let[e,a]of Object.entries(s))if(a&&"object"==typeof a){var t,n;l.set(e,{enabled:null!=(t=a.enabled)&&t,expiresAt:null!=(n=a.expiresAt)?n:null})}Q(l)}catch(t){if(eD.current!==e)return;console.error("[WorktreeDetailRefactored] Error fetching auto-yes states:",t)}},[f]),{visibleInstances:tx,visibleInstanceIds:tf,toggleInstanceVisible:tp}=function(e){let{worktreeId:t,roster:n}=e,[a,r]=(0,i.useState)(null);(0,i.useEffect)(()=>{r(function(e){try{let t=window.localStorage.getItem(aL(e));if(null===t)return null;let n=JSON.parse(t);if(!Array.isArray(n))return null;let a=n.filter(e=>"string"==typeof e);return a.length>0?a:null}catch(e){return null}}(t))},[t]);let s=(0,i.useMemo)(()=>aR(a,n),[a,n]),l=(0,i.useMemo)(()=>s.map(e=>e.id),[s]),o=(0,i.useMemo)(()=>null!==a&&n.some(e=>a.includes(e.id)),[a,n]),c=(0,i.useCallback)(e=>{let a=new Set(e),s=n.filter(e=>a.has(e.id)).map(e=>e.id);if(!(s.length<1)){r(s);try{window.localStorage.setItem(aL(t),JSON.stringify(s))}catch(e){}}},[n,t]),d=(0,i.useCallback)(e=>c(e),[c]);return{visibleInstances:s,visibleInstanceIds:l,hasStoredPreference:o,toggleInstanceVisible:(0,i.useCallback)(e=>{let t=aR(a,n).map(e=>e.id);if(t.includes(e)){if(t.length<=1)return;c(t.filter(t=>t!==e))}else c([...t,e])},[a,n,c]),setVisibleInstanceIds:d,showInstances:(0,i.useCallback)(e=>{null!==a&&c([...aR(a,n).map(e=>e.id),...e])},[a,n,c])}}({worktreeId:f,roster:ex}),tg=g?tx:ex,tb=(0,i.useMemo)(()=>Array.from(new Set(tx.map(e=>e.cliTool))),[tx]),tv=g?tb:eu;(0,i.useEffect)(()=>{0!==tg.length&&(tg.some(e=>e.id===eI)||eA(tg[0].id))},[tg,eI,eA]),(0,i.useEffect)(()=>{let e=tg.find(e=>e.id===eI);e&&e.cliTool!==eN&&eS(e.cliTool)},[tg,eI,eN,eS]);let ty="opencode"===eN||"copilot"===eN,tj=(0,i.useCallback)(e=>{em(e)},[]),tw=(0,i.useCallback)(e=>{ef(e),eb(f)},[f]),tk=(0,i.useCallback)(e=>{ej(e)},[]),tN=(0,i.useCallback)(e=>{ek(e)},[]),tC=(0,i.useRef)(eN);(0,i.useEffect)(()=>{tC.current!==eN&&(tC.current=eN,j.clearMessages(),j.clearPrompt(),er(!1),tu(),tm())},[eN,j,tu,tm]),(0,i.useEffect)(()=>{tu()},[eJ,tu]),(0,i.useEffect)(()=>{tu()},[e1,tu]);let{showToast:tS}=(0,eY.dj)(),tT=(0,i.useCallback)(()=>{tS("Maximum ".concat(30," file tabs. Close a tab first."),"info")},[tS]),tE=(0,i.useCallback)(e=>{g?K(e):"limit_reached"===H.openFile(e)&&tT()},[g,H,tT]),tI=(0,i.useCallback)(e=>{g?K(e):"limit_reached"===H.openFile(e)&&tT()},[g,H,tT]),tM=(0,i.useCallback)(e=>{"limit_reached"===H.openFile(e)&&tT()},[H,tT]),tA=(0,i.useCallback)(()=>{K(null)},[]),tL=(0,i.useCallback)(e=>{e_(e=>e+1)},[]),tR=(0,i.useCallback)(()=>{q(null)},[]),tP=(0,i.useCallback)(()=>{ti.clearSearch(),H.closeAllTabs(),K(null),q(null)},[ti,H]),tD=(0,i.useCallback)(e=>{e_(e=>e+1)},[]),tF=(0,i.useCallback)(e=>{e$(e)},[e$]),tO=(0,i.useCallback)(e=>{eK(e)},[eK]),tz=(0,i.useCallback)(()=>{p.push("/")},[p]),t_=(0,i.useCallback)(async e=>{try{let t=await fetch("/api/worktrees/".concat(f),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:e})});if(t.ok){let e=await t.json();A(e)}}catch(e){}},[f]),tB=(0,i.useCallback)(()=>{B(!0)},[]),tV=(0,i.useCallback)(()=>{B(!1)},[]),tW=(0,i.useCallback)(async e=>{j.setPromptAnswering(!0);try{let t=l5(e,eN,S(y.prompt.data)?y.prompt.data:null,b.current?eL.current:void 0),n=await fetch("/api/worktrees/".concat(f,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw Error("Failed to send prompt response: ".concat(n.status));j.clearPrompt(),await tm()}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e)}finally{j.setPromptAnswering(!1)}},[f,j,tm,eN,y.prompt.data]),tH=(0,i.useCallback)(()=>{j.clearPrompt()},[j]),tU=(0,i.useCallback)(e=>{j.setMobileActivePane(e)},[j]),tK=(0,i.useCallback)(()=>{tu(),tm()},[tu,tm]),t$=(0,i.useCallback)((e,t)=>async n=>{let a=null!=t?t:e;try{let t=await fetch("/api/worktrees/".concat(f,"/auto-yes"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:n.enabled,cliToolId:e,instanceId:a,duration:n.duration,stopPattern:n.stopPattern})});if(t.ok){let e=await t.json();Q(t=>{let n=new Map(t);return n.set(a,{enabled:e.enabled,expiresAt:e.expiresAt}),n}),a===eL.current&&(ei.current=e.enabled)}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[f]),tq=(0,i.useCallback)(e=>t$(eN,eI)(e),[t$,eN,eI]),[tG,tJ]=(0,i.useState)(null),[tY,tQ]=(0,i.useState)(!1),tX=(0,i.useRef)(!1),tZ=(0,i.useCallback)(e=>{tJ(e)},[]),t0=(0,i.useCallback)(()=>{let e=eL.current,t=eT.current,n=(0,tt.O6)(ep.current,e,t);tJ({cliToolId:t,instanceId:e,label:n})},[]),t1=(0,i.useCallback)(async()=>{if(!tG||tX.current)return;tX.current=!0,tQ(!0);let e=()=>{tG.instanceId===eL.current&&(j.clearMessages(),j.clearPrompt())};try{await V.y.killSession(f,tG.cliToolId,tG.instanceId),e(),await td(),tJ(null)}catch(t){t instanceof V.hD&&404===t.status?(e(),await td(),tJ(null)):tS(w("session.failedToKill"),"error")}finally{tX.current=!1,tQ(!1)}},[tG,f,j,td,tS,w]),t2=(0,i.useCallback)(()=>{tX.current||tJ(null)},[]),t4=(0,i.useCallback)(e=>{eH(e),eV(!0)},[]),t5=(0,i.useCallback)(async e=>{eV(!1);let t=eW?"".concat(eW,"/").concat(e):e;try{if(!(await fetch("/api/worktrees/".concat(f,"/files/").concat((0,eE.o)(t)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:""})})).ok)throw Error("Failed to create file");e_(e=>e+1)}catch(e){window.alert(k("fileOps.failedToCreateFile"))}},[f,eW,k]),t3=(0,i.useCallback)(()=>{eV(!1)},[]),t6=(0,i.useCallback)(async e=>{let t=window.prompt("Enter directory name:");if(!t)return;let n=e?"".concat(e,"/").concat(t):t;try{if(!(await fetch("/api/worktrees/".concat(f,"/files/").concat((0,eE.o)(n)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"directory"})})).ok)throw Error("Failed to create directory");e_(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create directory:",e),window.alert(k("fileOps.failedToCreateDirectory"))}},[f,k]),t8=(0,i.useCallback)(async e=>{let t=e.split("/").pop()||"",n=window.prompt("Enter new name:",t);if(n&&n!==t)try{if(!(await fetch("/api/worktrees/".concat(f,"/files/").concat((0,eE.o)(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"rename",newName:n})})).ok)throw Error("Failed to rename");let t=e.includes("/")?e.substring(0,e.lastIndexOf("/")+1):"";H.onFileRenamed(e,"".concat(t).concat(n)),e_(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to rename:",e),window.alert(k("fileOps.failedToRename"))}},[f,H,k]),t9=(0,i.useCallback)(async e=>{let t=e.split("/").pop()||e;if(await T({description:N("confirmDelete",{name:t}),variant:"danger"}))try{if(!(await fetch("/api/worktrees/".concat(f,"/files/").concat((0,eE.o)(e),"?recursive=true"),{method:"DELETE"})).ok)throw Error("Failed to delete");($===e||(null==$?void 0:$.startsWith("".concat(e,"/"))))&&q(null),H.onFileDeleted(e),e_(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert(k("fileOps.failedToDelete"))}},[f,$,H,N,k,T]);(0,i.useEffect)(()=>{"stop_pattern_matched"===eo?(tS(C("stopPatternMatched"),"info"),ed(null)):"consecutive_errors"===eo&&(tS(C("consecutiveErrorsStopped"),"warning"),ed(null))},[eo,tS,C]);let{moveTarget:t7,isMoveDialogOpen:ne,handleMove:nt,handleMoveConfirm:nn,handleMoveCancel:na}=function(e,t,n,a){let[r,s]=(0,i.useState)(null),[l,o]=(0,i.useState)(!1),c=(0,i.useCallback)((e,t)=>{s({path:e,type:t}),o(!0)},[]),d=(0,i.useCallback)(async l=>{if(r)try{let s=await fetch("/api/worktrees/".concat(e,"/files/").concat(r.path),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"move",destination:l})}),o=await s.json();if(!s.ok||!o.success){var i;let e=(null==(i=o.error)?void 0:i.message)||"Failed to move";null==a||a(e);return}null==n||n("Moved successfully"),t()}catch(e){null==a||a("Failed to move")}finally{s(null),o(!1)}},[r,e,t,n,a]);return{moveTarget:r,isMoveDialogOpen:l,handleMove:c,handleMoveConfirm:d,handleMoveCancel:(0,i.useCallback)(()=>{s(null),o(!1)},[])}}(f,()=>e_(e=>e+1),e=>tS(e,"success"),e=>tS(e,"error")),nr=(0,i.useRef)(null),ns=(0,i.useRef)(""),nl=(0,i.useCallback)(e=>{var t;ns.current=e,null==(t=nr.current)||t.click()},[]),ni=(0,i.useCallback)(async e=>{var t,n,a;let r=null==(t=e.target.files)?void 0:t[0];if(!r)return;e.target.value="";let s=ns.current,l=".".concat(null==(n=r.name.split(".").pop())?void 0:n.toLowerCase());if(!function(e){if(!e)return!1;let t=e.toLowerCase();return la.includes(t)}(l))return void tS("Unsupported file type: ".concat(l,". Allowed: ").concat(la.join(", ")),"error");let i=function(e){var t;let n=function(e){let t=e.toLowerCase();return ln.find(e=>e.extension===t)}(e);return null!=(t=null==n?void 0:n.maxFileSize)?t:0x1400000}(l);if(r.size>i)return void tS("File too large. Maximum size: ".concat((i/1024/1024).toFixed(1),"MB"),"error");let o=new FormData;o.append("file",r);try{let e=await fetch("/api/worktrees/".concat(f,"/upload/").concat((0,eE.o)(s||".")),{method:"POST",body:o});if(!e.ok){let t=await e.json().catch(()=>({})),n=(null==t||null==(a=t.error)?void 0:a.message)||"Failed to upload file";tS(n,"error");return}let t=await e.json();tS("Uploaded: ".concat(t.filename),"success"),e_(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),tS("Upload failed. Please try again.","error")}},[f,tS]),{data:no}=eX(),nc=null!=(u=null==no?void 0:no.hasUpdate)&&u,{lastAutoResponse:nh}=function(e){let{worktreeId:t,cliTool:n,isPromptWaiting:a,promptData:r,autoYesEnabled:s,lastServerResponseTimestamp:l,serverPollerActive:o}=e,c=(0,i.useRef)(null),[d,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{var e;if(!a){c.current=null;return}if(!r||!s||!S(r)||o||l&&Date.now()-l<3e3)return;let i=(e={type:r.type,question:r.question},"".concat(e.type,":").concat(e.question));if(c.current===i)return;let d=function(e,t){let n=function(e){if("yes_no"===e.type)return"y";if("multiple_choice"===e.type){let t=e.options.find(e=>e.isDefault),n=null!=t?t:e.options[0];return!n||n.requiresTextInput?null:n.number.toString()}return null}(e);if(null===n)return{answer:null,suppressedBy:null};let a=function(e,t,n){if(!n)return null;if("off"===n.mode)return{reason:"mode-off"};let a=function(e,t){if(0===t.length)return{outcome:"no-match"};let n=e.map(e=>e.length>2e4?e.slice(0,2e4):e);for(let e of t){if(e.length>200||!aU(e).valid)return{outcome:"unusable",pattern:e};let t=new RegExp(e);for(let a of n){let n=function(e,t){arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{return e.test(t)}catch(e){return null}}(t,a);if(null===n)return{outcome:"unusable",pattern:e};if(n)return{outcome:"match",pattern:e}}}return{outcome:"no-match"}}(t,n.denyPatterns);return"match"===a.outcome?{reason:"deny-pattern",pattern:a.pattern}:"unusable"===a.outcome?{reason:"deny-pattern-unusable",pattern:a.pattern}:"safe"===n.mode?"yes_no"===e?null:{reason:"type-not-allowed"}:"allow-listed"===n.mode?n.allowPromptTypes.includes(e)?null:{reason:"type-not-allowed"}:null}(e.type,function(e){let t=[e.question];if(e.approvalTarget&&t.push(e.approvalTarget),"multiple_choice"===e.type)for(let n of e.options)t.push(n.label);else t.push(...e.options);return t}(e),t);return a?{answer:null,suppressedBy:a.reason,pattern:a.pattern}:{answer:n,suppressedBy:null}}(r,void 0).answer;if(null===d)return;c.current=i,u(d);let m=l5(d,n,r);fetch("/api/worktrees/".concat(t,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)}).catch(e=>{console.error("[useAutoYes] Failed to send auto-response:",e)})},[a,r,s,t,n,l,o]),{lastAutoResponse:d}}({worktreeId:f,cliTool:eN,isPromptWaiting:y.prompt.visible,promptData:y.prompt.data,autoYesEnabled:eF,lastServerResponseTimestamp:Z,serverPollerActive:et}),nx=(0,i.useCallback)(async()=>{D(null),R(!0),await td()&&await Promise.all([tu(),tm()]),R(!1)},[td,tu,tm]);!function(e){let{error:t,handleRetry:n,fetchWorktree:a,fetchMessages:r,fetchCurrentOutput:s,setError:l}=e,o=(0,i.useRef)(0),c=(0,i.useCallback)(async()=>{if("visible"!==document.visibilityState)return;let e=Date.now();if(!(e-o.current<5e3)){if(o.current=e,t)return void n();try{await Promise.all([a(),r(),s()])}finally{l(null)}}},[t,n,a,r,s,l]);(0,i.useEffect)(()=>(document.addEventListener("visibilitychange",c),()=>{document.removeEventListener("visibilitychange",c)}),[c])}({error:P,handleRetry:nx,fetchWorktree:td,fetchMessages:tu,fetchCurrentOutput:tm,setError:D}),(0,i.useEffect)(()=>{if(to.current)return;let e=!0;return(async()=>{z.current||R(!0),await Promise.all([td(),tu(),tm()]),e&&(R(!1),to.current=!0)})(),()=>{e=!1}},[td,tu,tm]);let nf=null!=(m=null==M||null==(r=M.sessionStatusByCli)||null==(a=r[eN])?void 0:a.isRunning)&&m;(0,i.useEffect)(()=>{if(L||P)return;let e=setInterval(async()=>{let e=[tm(),td()];g&&e.push(tu()),await Promise.all(e),O(e=>e+1)},nf?2e3:5e3);return()=>clearInterval(e)},[L,P,tm,td,tu,nf,g]),(0,i.useEffect)(()=>{th()},[f,ev,th]),(0,i.useEffect)(()=>{j.setLayoutMode(g?"tabs":"split")},[g,j]);let np=(0,i.useMemo)(()=>(function(e,t){var n;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"claude";if(t)return"error";if(!e)return"idle";let r=null==(n=e.sessionStatusByCli)?void 0:n[a];if(r){if(r.isWaitingForResponse)return"waiting";if(r.isProcessing)return"running";if(r.isRunning)return"ready"}if("claude"===a){if(e.isWaitingForResponse)return"waiting";if(e.isProcessing)return"running";if(e.isSessionRunning)return"ready"}return"idle"})(M,null!==y.error.type,eN),[M,y.error.type,eN]),ng=(0,i.useMemo)(()=>y.layout.mobileActivePane,[y.layout.mobileActivePane]),nb=null!=(h=null==M?void 0:M.name)?h:"Unknown",nv=(0,i.useCallback)((e,t)=>{H.dispatch({type:"SET_CONTENT",path:e,content:t})},[H]),ny=(0,i.useCallback)((e,t)=>{H.dispatch({type:"SET_ERROR",path:e,error:t})},[H]),nj=(0,i.useCallback)((e,t)=>{H.dispatch({type:"SET_LOADING",path:e,loading:t})},[H]),nw=(0,i.useCallback)((e,t)=>{H.dispatch({type:"SET_DIRTY",path:e,isDirty:t})},[H]),nk=function(e){var t,n,a;let{worktreeId:r,refreshToken:s=0,enabled:l=!0,limit:o=10}=e,[c,d]=(0,i.useState)(null),[u,m]=(0,i.useState)([]),[h,x]=(0,i.useState)(null),[f,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(!0),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)(null),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(!1),[T,E]=(0,i.useState)(null),[I,M]=(0,i.useState)(0),A=(0,i.useRef)(0),L=(0,i.useRef)(0),R=(0,i.useRef)(!1),P=(0,i.useRef)(!1),D=(0,i.useRef)(!1),F=(0,i.useRef)(!1);P.current=(null==c?void 0:c.status)==="verifying"||u.some(e=>"running"===e.status),(0,i.useEffect)(()=>{if(A.current+=1,L.current=0,R.current=!1,!F.current){F.current=!0;return}d(null),m([]),x(null),p(null),b(!0),y(null),w(null),E(null)},[r]),(0,i.useEffect)(()=>{if(!l)return;let e=0===L.current,t=15e3*!P.current;if(!e&&Date.now()-L.current<t||R.current)return;let n=A.current;R.current=!0,L.current=Date.now(),(async()=>{try{let[e,t]=await Promise.all([rj(r),rw(r,o)]);if(n!==A.current)return;d(e),m(t),y(null)}catch(e){if(n!==A.current||ih(e))return;y(im(e,"Failed to load verification data"))}finally{R.current=!1,n===A.current&&b(!1)}})()},[r,s,I,l,o]);let O=null!=(n=null!=h?h:null==(t=u[0])?void 0:t.id)?n:null,z=(0,i.useMemo)(()=>{var e,t;if(null===O)return null;let n=u.find(e=>e.id===O);return(null==n?void 0:n.status)==="running"?"".concat(O,":running:").concat(s,":").concat(I):"".concat(O,":").concat(null!=(e=null==n?void 0:n.status)?e:"unlisted",":").concat(null!=(t=null==n?void 0:n.finishedAt)?t:"")},[O,u,s,I]);(0,i.useEffect)(()=>{if(!l||null===O){p(null),w(null),N(!1);return}let e=new AbortController,t=!1;return N(!0),(async()=>{try{let n=await rk(r,O,e.signal);if(t)return;p(n),w(null===n?"not-found":null)}catch(e){if(t||ih(e))return;p(null),w(im(e,"Failed to load the verification run"))}finally{t||N(!1)}})(),()=>{t=!0,e.abort()}},[r,l,z]);let _=(0,i.useCallback)(()=>{L.current=0,M(e=>e+1)},[]),B=(0,i.useCallback)(e=>{x(e)},[]),V=(0,i.useCallback)(async()=>{if(!D.current){D.current=!0,S(!0),E(null);try{let e=await rN(r);x(e),L.current=0,M(e=>e+1)}catch(t){let e=t instanceof rb&&409===t.status;E({kind:e?"conflict":"error",message:im(t,"Failed to start verification"),runningRunId:t instanceof rb?t.runningRunId:null}),e&&(L.current=0,M(e=>e+1))}finally{D.current=!1,S(!1)}}},[r]);return{task:c,runs:u,latestRun:null!=(a=u[0])?a:null,selectedRunId:O,selectedRun:f,loading:g,error:v,detailError:j,detailLoading:k,rerunPending:C,rerunFailure:T,selectRun:B,refresh:_,rerun:V}}({worktreeId:f,refreshToken:F,enabled:!L&&!P});return{activeActivity:eU,activeCliTab:eN,activeInstanceId:eI,activeTab:ng,agentInstances:ex,autoYesEnabled:eF,autoYesExpiresAt:eO,autoYesStateMap:Y,diffContent:ta,diffFilePath:tr,disableAutoFollow:ty,displayedAgents:tv,displayedInstances:tg,editorFilePath:$,error:P,fetchCurrentOutput:tm,fileInputRef:nr,fileSearch:ti,fileTreeRefresh:ez,handleActivityOpen:tO,handleActivityToggle:tF,handleAgentInstancesChange:tw,handleAutoYesToggle:tq,handleBackClick:tz,handleCloseDiff:tl,handleDelete:t9,handleDiffSelect:ts,handleDirtyChange:nw,handleEditorClose:tR,handleEditorSave:tD,handleFileInputChange:ni,handleFilePanelSave:tL,handleFilePathClick:tE,handleFileSelect:tI,handleHistoryDisplayLimitChange:e2,handleHistoryUserOnlyChange:e0,handleInfoClick:tB,handleInfoModalClose:tV,handleInsertConsumed:te,handleInsertConsumedSingle:tn,handleInsertToMessage:e9,handleInsertToSplit:e7,handleKillCancel:t2,handleKillConfirm:t1,openKillConfirm:tZ,openActiveKillConfirm:t0,killTarget:tG,isKillPending:tY,handleLoadContent:nv,handleLoadError:ny,handleMessageSent:tK,handleMobileFileViewerClose:tA,handleMobileTabChange:tU,handleMove:nt,resetFileTreeView:tP,handleMoveCancel:na,handleMoveConfirm:nn,handleNewDirectory:t6,handleNewFile:t4,handleNewFileCancel:t3,handleNewFileConfirm:t5,handleOpenFile:tM,handlePromptDismiss:tH,handlePromptRespond:tW,handleRename:t8,handleRetry:nx,handleSelectedAgentsChange:tj,handleSetLoading:nj,handleShowArchivedChange:eQ,handleUpload:nl,handleVibeLocalContextWindowChange:tN,rosterReady:ev,handleVibeLocalModelChange:tk,handleWorktreeStatusChange:t_,hasUpdate:nc,historyDisplayLimit:e1,historySubTab:eq,historyUserOnly:eZ,isEditorMaximized:G,isInfoModalOpen:_,isMobile:g,isMoveDialogOpen:ne,isSelectionListActive:ea,isPagerActive:es,lastAutoResponse:nh,loading:L,makeAutoYesToggleHandler:t$,mobileFileViewerPath:U,mobileSelectedAgents:tb,moveTarget:t7,newFileParentPath:eW,openMobileDrawer:v,pendingInsertText:e6,pendingInsertTextMap:e3,selectedAgents:eu,setActiveCliTab:eS,setActiveInstanceId:eA,setEditorFilePath:q,setFocusedSplitIndex:e8,setHistorySubTab:eG,setIsEditorMaximized:J,setWorktree:A,showArchived:eJ,showNewFileDialog:eB,showToast:tS,state:y,tCommon:N,tWorktree:w,tabsActions:H,tabsState:W,toggleInstanceVisible:tp,vibeLocalContextWindow:ew,verification:nk,vibeLocalModel:ey,visibleInstanceIds:tf,worktree:M,worktreeName:nb,worktreeStatus:np}}({worktreeId:f}),[tA,tL]=(0,i.useState)(!1),[tR,tP]=(0,i.useState)(null),tD=(0,i.useCallback)(e=>{"memo"!==e&&tP(null),eC(e)},[eC]),tF=(0,i.useCallback)(()=>{tP(e=>{var t;return{tab:"verification",token:(null!=(t=null==e?void 0:e.token)?t:0)+1}}),eC("memo")},[eC]),tO=function(e){let{worktreeId:t,active:n}=e,{addListener:a}=(0,tI.xM)(),[r,s]=(0,i.useState)(!1),l=(0,i.useRef)(n);return l.current=n,(0,i.useEffect)(()=>{n&&s(!1)},[n]),(0,i.useEffect)(()=>a(e=>{e.worktreeId===t&&("terminal_snapshot"===e.type||"message"===e.type)&&(l.current||s(!0))}),[a,t]),!n&&r}({worktreeId:f,active:"terminal"===y}),{viewportHeight:tz}=(0,ir.C)(),t_=(0,i.useCallback)(e=>{let t=iS.indexOf(y);if(-1===t)return;let n=t+e;n<0||n>=iS.length||tD(iS[n])},[y,tD]),{ref:tB}=(0,L.hU)({axis:"horizontal",threshold:60,edgeStartZone:32*("terminal"===y),onSwipeLeft:()=>t_(1),onSwipeRight:()=>t_(-1)});if(e3)return(0,r.jsx)(sH,{});if(D)return(0,r.jsx)(sU,{message:D,onRetry:ez});let tV=(0,tt.O6)(j,v,b),tW=null!=(o=null==ev?void 0:ev.label)?o:tV,tH=null!=(m=null==(t=null!=(u=null==tT||null==(n=tT.sessionStatusByInstance)?void 0:n[v])?u:null==tT||null==(a=tT.sessionStatusByCli)?void 0:a[b])?void 0:t.isRunning)&&m;return e0?(0,r.jsx)(T,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden",style:{height:null!=tz?"".concat(tz,"px"):"100%"},"data-testid":"mobile-worktree-shell",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(g,{worktreeName:tE,repositoryName:null==tT?void 0:tT.repositoryName,status:tM,gitStatus:null==tT?void 0:tT.gitStatus,onBackClick:$,onMenuClick:tr})}),tk.task&&(0,r.jsx)("div",{className:"flex-shrink-0 border-b border-border bg-surface px-3 py-1.5",children:(0,r.jsx)(l6,{task:tk.task,latestRun:tk.latestRun,latestRunGates:null!==tk.selectedRun&&tk.selectedRun.id===(null==(l=tk.latestRun)?void 0:l.id)?tk.selectedRun.gates:null,onOpen:tF,className:"w-full justify-start"})}),(null==tT?void 0:tT.gitStatus)&&tT.gitStatus.isBranchMismatch&&(0,r.jsx)("div",{className:"z-35 flex-shrink-0",children:(0,r.jsx)(l8,{isBranchMismatch:tT.gitStatus.isBranchMismatch,currentBranch:tT.gitStatus.currentBranch,initialBranch:tT.gitStatus.initialBranch})}),(0,r.jsxs)("div",{className:"flex-shrink-0 z-30 flex items-center gap-2 px-3 py-1.5 bg-surface-2 border-b border-border",children:[(0,r.jsx)("nav",{className:"flex gap-1 flex-1 min-w-0 overflow-x-auto scrollbar-hide","aria-label":tb("detail.agentInstanceSelection"),children:A.map(e=>{var t,n,a;let s=(0,te.kA)(null!=(a=null==tT||null==(t=tT.sessionStatusByInstance)?void 0:t[e.id])?a:null==tT||null==(n=tT.sessionStatusByCli)?void 0:n[e.cliTool]),l=tg("status.".concat(s)),i=v===e.id;return(0,r.jsxs)("button",{onClick:()=>to(e.id),className:"flex-shrink-0 whitespace-nowrap min-h-[44px] px-1.5 py-1 font-medium text-xs transition-colors flex items-center gap-1 border-b-2 touch-manipulation ".concat(i?"text-accent-600 dark:text-accent-400 border-accent-500":"text-muted-foreground hover:text-foreground border-transparent"),"aria-current":i?"page":void 0,children:[(0,r.jsx)(h.m,{status:s,size:"sm",label:tb("detail.statusPill",{label:(0,tt.sw)(e),status:l})}),(0,tt.sw)(e)]},e.id)})}),(0,r.jsx)("button",{type:"button",onClick:()=>tL(!0),className:"flex-shrink-0 flex items-center justify-center min-h-[44px] min-w-[44px] rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors touch-manipulation","aria-label":tb("terminal.moreActions"),"data-testid":"mobile-more-actions-button",children:(0,r.jsx)(d.A,{size:18,"aria-hidden":"true"})})]}),(0,r.jsx)("main",{className:"flex-1 min-h-0 overflow-y-auto",ref:tB,children:(0,r.jsx)(sP,{activeTab:y,worktreeId:f,worktree:tT,messages:tp.messages,cliToolId:b,instanceId:v,onFilePathClick:en,onFileSelect:er,onWorktreeUpdate:tm,onNewFile:eA,onNewDirectory:eM,onRename:eO,onDelete:G,onUpload:eV,onMove:eS,onFileTreeReset:tj,refreshTrigger:_,fileSearch:z,showToast:tf,selectedAgents:e9,onSelectedAgentsChange:iC,useInstanceManagement:!0,instances:j,onInstancesChange:U,visibleInstanceIds:tS,onToggleInstanceVisible:tw,vibeLocalModel:tC,onVibeLocalModelChange:eH,vibeLocalContextWindow:tN,onVibeLocalContextWindowChange:eW,disableAutoFollow:M,historySubTab:eG,onHistorySubTabChange:td,onDiffSelect:J,onInsertToMessage:eh,showArchived:th,onShowArchivedChange:eB,historyDisplayLimit:eq,onHistoryDisplayLimitChange:es,historyUserOnly:eJ,onHistoryUserOnlyChange:el,verification:tk,toolsSubTabRequest:tR})}),(0,r.jsxs)("div",{className:"flex-shrink-0 border-t border-border bg-surface z-30",children:[e2&&(0,r.jsx)("div",{className:"px-2 pt-1 border-b border-border",children:(0,r.jsx)(eo,{worktreeId:f,cliToolId:b,instanceId:v,onKeysSent:F,showPagerKeys:e4})}),(0,r.jsx)("div",{className:"p-2",children:(0,r.jsx)(ea,{worktreeId:f,onMessageSent:ek,cliToolId:b,instanceId:v,isSessionRunning:tH,pendingInsertText:ts,onInsertConsumed:em,autoYesSlot:(0,r.jsx)(l1,{enabled:w,expiresAt:k,onToggle:K,lastAutoResponse:e5,cliToolName:b,inline:!0,showToolName:!1})})})]}),(0,r.jsx)(C,{activeTab:y,onTabChange:tD,hasNewOutput:tO,hasPrompt:tp.prompt.visible,hasUpdate:e$,inFlow:!0}),!w&&(0,r.jsx)(P,{promptData:tp.prompt.data,visible:tp.prompt.visible,answering:tp.prompt.answering,onRespond:eF,onDismiss:eD,cliToolName:(0,tt.oo)(b)}),(0,r.jsx)(B,{open:tA,onClose:()=>tL(!1),onSearch:()=>window.dispatchEvent(new CustomEvent("terminal-search-open")),onEnd:eb,endDisabled:!tH}),(0,r.jsx)(eK,{isOpen:null!==e8,onClose:eN,worktreeId:f,filePath:null!=e8?e8:"",onFileSaved:Z,onOpenFile:en}),(0,r.jsx)("input",{ref:O,type:"file",accept:la.join(","),onChange:ee,className:"hidden","aria-label":tb("detail.uploadFile")}),(0,r.jsx)(e7.a,{isOpen:null!==ev,onClose:ef,title:tb("session.confirmEnd",{tool:tW}),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:tb("session.endWarning")}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:ef,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:tg("cancel")}),(0,r.jsx)("button",{type:"button",onClick:ep,disabled:ey,className:"px-4 py-2 text-sm font-medium rounded-md bg-danger hover:bg-danger/90 text-white disabled:opacity-60 disabled:cursor-not-allowed",children:tg("end")})]})]})}),tn&&(0,r.jsx)(l7,{isOpen:e1,onClose:eT,onConfirm:eI,worktreeId:f,sourcePath:tn.path,sourceType:tn.type}),(0,r.jsx)(it,{isOpen:tx,parentPath:ta,onConfirm:eR,onCancel:eL})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ia,{worktreeId:f,worktree:tT,worktreeName:tE,worktreeStatus:tM,instances:j,rosterReady:ti,activeInstanceId:v,setActiveInstanceId:to,hasUpdate:e$,lastAutoResponse:e5,activeActivity:p,onActivityToggle:H,onActivityOpen:W,verification:tk,onBackClick:$,onInfoClick:ei,onWorktreeStatusChange:eU,pendingInsertTextMap:tl,setFocusedSplitIndex:tc,handleInsertToSplit:ex,handleInsertConsumed:eu,handleInsertToMessage:eh,autoYesStateMap:N,makeAutoYesToggleHandler:e6,showArchived:th,onShowArchivedChange:eB,historyDisplayLimit:eq,onHistoryDisplayLimitChange:es,historyUserOnly:eJ,onHistoryUserOnlyChange:el,onMessageSent:ek,onFilePathClick:en,showToast:tf,tabsState:ty,tabsActions:tv,onLoadContent:ej,onLoadError:ew,onSetLoading:e_,onFilePanelSave:et,onDirtyChange:Y,onOpenFile:eP,diffContent:E,diffFilePath:I,onCloseDiff:q,fileSearch:z,fileTreeRefresh:_,onFileSelect:er,onNewFile:eA,onNewDirectory:eM,onRename:eO,onDelete:G,onUpload:eV,onMove:eS,onFileTreeReset:tj,onDiffSelect:J,onAgentInstancesChange:U,vibeLocalModel:tC,onVibeLocalModelChange:eH,vibeLocalContextWindow:tN,onVibeLocalContextWindowChange:eW,isInfoModalOpen:eZ,onInfoModalClose:ed,onWorktreeUpdate:tm,fileInputRef:O,onFileInputChange:ee,onKillSession:eb,onRequestSessionEnd:eg,killTarget:ev,isKillPending:ey,onKillCancel:ef,onKillConfirm:ep,moveTarget:tn,isMoveDialogOpen:e1,onMoveCancel:eT,onMoveConfirm:eI,showNewFileDialog:tx,newFileParentPath:ta,onNewFileConfirm:eR,onNewFileCancel:eL,killDialogTitle:tb("session.confirmEnd",{tool:tW}),killDialogWarning:tb("session.endWarning"),cancelLabel:tg("cancel"),endLabel:tg("end")}),R&&(0,r.jsx)(e7.a,{isOpen:!0,onClose:Q,title:R.split("/").pop()||tb("fileViewer.editor"),size:"full",disableClose:eQ,children:(0,r.jsx)("div",{className:"h-[80vh]",children:(0,r.jsx)(iN,{worktreeId:f,filePath:R,onClose:Q,onSave:Z,onMaximizedChange:tu})})})]})});function iE(){let e=(0,s.useParams)().id;return(0,r.jsx)(l.GV,{children:(0,r.jsx)(iT,{worktreeId:e})})}},64269:(e,t,n)=>{"use strict";function a(e,t){let n=null;return function(){for(var a=arguments.length,r=Array(a),s=0;s<a;s++)r[s]=arguments[s];n&&clearTimeout(n),n=setTimeout(()=>{e(...r),n=null},t)}}function r(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function s(e){let t=new Set;for(let n of e){t.add(n);let e=n.split("/"),a="";for(let n=0;n<e.length-1;n++)a=a?"".concat(a,"/").concat(e[n]):e[n],t.add(a)}return t}function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30;return e.length<=t?e:"".concat(e.substring(0,t-3),"...")}function i(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}n.d(t,{Nt:()=>r,W5:()=>l,ZD:()=>i,q3:()=>s,sg:()=>a})},69264:(e,t,n)=>{"use strict";n.d(t,{u:()=>i});var a=n(95155),r=n(12115),s=n(18955),l=n(3005);function i(e){let{src:t,onError:n}=e,i=(0,s.c)("worktree"),[o,c]=(0,r.useState)(!0),[d,u]=(0,r.useState)(!1);return d?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,a.jsx)("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),(0,a.jsx)("p",{className:"text-sm",children:i("videoViewer.loadError")})]}):(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center p-4",children:[o&&(0,a.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,a.jsx)(l.y,{size:"xl",variant:"accent"}),(0,a.jsx)("p",{className:"ml-3 text-muted-foreground",children:i("videoViewer.loading")})]}),(0,a.jsx)("video",{controls:!0,src:t,onLoadedData:()=>{c(!1)},onError:()=>{c(!1),u(!0),null==n||n()},style:{maxWidth:"100%",maxHeight:"500px",display:o?"none":"block"},className:"rounded-lg shadow-sm",children:i("videoViewer.unsupported")})]})}},72115:(e,t,n)=>{"use strict";n.d(t,{f:()=>d});var a=n(95155),r=n(12115),s=n(18955);let l=["relative","flex-shrink-0","bg-border","transition-colors","duration-150","hover:bg-accent-500","dark:hover:bg-accent-500","focus:outline-none","focus:ring-2","focus:ring-ring","focus:ring-offset-2","focus:ring-offset-background"],i=["w-1","h-full","cursor-col-resize","before:content-['']","before:absolute","before:inset-y-0","before:-inset-x-1"],o=["h-1","w-full","cursor-row-resize","before:content-['']","before:absolute","before:inset-x-0","before:-inset-y-1"];function c(e,t){return"touches"in e&&e.touches.length>0?t?e.touches[0].clientX:e.touches[0].clientY:"clientX"in e?t?e.clientX:e.clientY:0}let d=(0,r.memo)(function(e){let{onResize:t,orientation:n="horizontal",ariaValueNow:d=50,onDoubleClick:u,minRatio:m=.1}=e,h=(0,s.c)("worktree"),[x,f]=(0,r.useState)(!1),p=(0,r.useRef)(0),g=(0,r.useRef)(null),b="horizontal"===n,v=(0,r.useCallback)(e=>{e.preventDefault(),f(!0),p.current=c(e,b)},[b]),y=(0,r.useCallback)(e=>{1===e.touches.length&&(f(!0),p.current=c(e,b))},[b]),j=(0,r.useCallback)(e=>{if(!x)return;let n=c(e,b);t(n-p.current),p.current=n},[x,b,t]),w=(0,r.useCallback)(e=>{if(!x||1!==e.touches.length)return;let n=c(e,b);t(n-p.current),p.current=n},[x,b,t]),k=(0,r.useCallback)(()=>{f(!1)},[]),N=(0,r.useCallback)(()=>{u&&u()},[u]),C=(0,r.useCallback)(e=>{let n=0;b?"ArrowRight"===e.key?n=10:"ArrowLeft"===e.key&&(n=-10):"ArrowDown"===e.key?n=10:"ArrowUp"===e.key&&(n=-10),0!==n&&(e.preventDefault(),t(n))},[b,t]);(0,r.useEffect)(()=>(x&&(document.addEventListener("mousemove",j),document.addEventListener("mouseup",k),document.addEventListener("touchmove",w),document.addEventListener("touchend",k),document.body.style.userSelect="none",document.body.style.cursor=b?"col-resize":"row-resize"),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",k),document.removeEventListener("touchmove",w),document.removeEventListener("touchend",k),document.body.style.userSelect="",document.body.style.cursor=""}),[x,j,k,w,b]);let S=(0,r.useMemo)(()=>[...l,...b?i:o,...x?["bg-accent-500","dark:bg-accent-500","dragging",b?"w-2":"h-2"]:[]].join(" "),[b,x]);return(0,a.jsx)("div",{ref:g,role:"separator","aria-orientation":n,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100,"aria-label":h("paneResizer.label",{arrows:h(b?"paneResizer.arrowsHorizontal":"paneResizer.arrowsVertical")}),tabIndex:0,className:S,onMouseDown:v,onTouchStart:y,onKeyDown:C,onDoubleClick:N})})},83012:(e,t,n)=>{"use strict";n.d(t,{Fx:()=>l,bg:()=>i,fw:()=>s});var a=n(53298),r=n(73683);function s(e,t){let n=new Date(e);return isNaN(n.getTime())?"":(0,a.m)(n,{addSuffix:!0,...t?{locale:t}:{}})}function l(e){let t=new Date(e);if(isNaN(t.getTime()))return"";let n=Math.round((Date.now()-t.getTime())/1e3);if(n<45)return"now";let a=Math.round(n/60);if(a<60)return"".concat(a,"m ago");let r=Math.round(a/60);if(r<24)return"".concat(r,"h ago");let s=Math.round(r/24);return s<7?"".concat(s,"d ago"):s<30?"".concat(Math.round(s/7),"w ago"):s<365?"".concat(Math.round(s/30),"mo ago"):"".concat(Math.round(s/365),"y ago")}function i(e,t){return!(e instanceof Date)||isNaN(e.getTime())?"":(0,r.GP)(e,"PPp",t?{locale:t}:void 0)}},85872:(e,t,n)=>{"use strict";async function a(e,t){throw Error((await e.json().catch(()=>({}))).error||"".concat(t," (").concat(e.status,")"))}n.d(t,{$C:()=>r,Ar:()=>l,KG:()=>s});let r={async list(e){var t;let n=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos"));return n.ok?null!=(t=(await n.json()).todos)?t:[]:a(n,"Failed to load todos")},async listAll(){var e;let t=await fetch("/api/todos");return t.ok?null!=(e=(await t.json()).todos)?e:[]:a(t,"Failed to load todos")},async create(e,t){let n=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})});return n.ok?(await n.json()).todo:a(n,"Failed to create todo")},async update(e,t,n){let r=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return r.ok?(await r.json()).todo:a(r,"Failed to update todo")},async remove(e,t){let n=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"DELETE"});n.ok||await a(n,"Failed to delete todo")}},s=["todo","doing","done"],l={async list(e){var t;let n=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"));return n.ok?null!=(t=(await n.json()).todos)?t:[]:a(n,"Failed to load todos")},async create(e,t,n){let r=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(void 0!==n?{content:t,detail:n}:{content:t})});return r.ok?(await r.json()).todo:a(r,"Failed to create todo")},async update(e,t,n){let r=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return r.ok?(await r.json()).todo:a(r,"Failed to update todo")},async remove(e,t){let n=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"DELETE"});n.ok||await a(n,"Failed to delete todo")},async reorder(e,t){let n=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({todoIds:t})});n.ok||await a(n,"Failed to reorder todos")}}}},e=>{e.O(0,[6481,6809,4909,2770,790,4974,8566,9948,1191,5542,8521,6402,3361,6381,5229,2751,2053,8441,1255,7358],()=>e(e.s=20252)),_N_E=e.O()}]);