commandmate 0.36.1 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +172 -172
  3. package/.next/app-path-routes-manifest.json +30 -30
  4. package/.next/build-manifest.json +2 -2
  5. package/.next/prerender-manifest.json +3 -3
  6. package/.next/required-server-files.json +1 -1
  7. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/api/agents/update/route_client-reference-manifest.js +1 -1
  9. package/.next/server/app/api/agents/versions/route_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.nft.json +1 -1
  14. package/.next/server/app/api/assistant/conversation/route_client-reference-manifest.js +1 -1
  15. package/.next/server/app/api/assistant/current-output/route.js.nft.json +1 -1
  16. package/.next/server/app/api/assistant/current-output/route_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/assistant/messages/route.js +1 -1
  18. package/.next/server/app/api/assistant/messages/route.js.nft.json +1 -1
  19. package/.next/server/app/api/assistant/messages/route_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/assistant/session/route.js +1 -1
  21. package/.next/server/app/api/assistant/session/route.js.nft.json +1 -1
  22. package/.next/server/app/api/assistant/session/route_client-reference-manifest.js +1 -1
  23. package/.next/server/app/api/assistant/start/route.js +1 -1
  24. package/.next/server/app/api/assistant/start/route.js.nft.json +1 -1
  25. package/.next/server/app/api/assistant/start/route_client-reference-manifest.js +1 -1
  26. package/.next/server/app/api/assistant/terminal/route.js +1 -1
  27. package/.next/server/app/api/assistant/terminal/route.js.nft.json +1 -1
  28. package/.next/server/app/api/assistant/terminal/route_client-reference-manifest.js +1 -1
  29. package/.next/server/app/api/assistant/tools/route.js.nft.json +1 -1
  30. package/.next/server/app/api/assistant/tools/route_client-reference-manifest.js +1 -1
  31. package/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  32. package/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  33. package/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  34. package/.next/server/app/api/capabilities/route.js +1 -1
  35. package/.next/server/app/api/capabilities/route_client-reference-manifest.js +1 -1
  36. package/.next/server/app/api/daily-summary/route.js +1 -1
  37. package/.next/server/app/api/daily-summary/route.js.nft.json +1 -1
  38. package/.next/server/app/api/daily-summary/route_client-reference-manifest.js +1 -1
  39. package/.next/server/app/api/daily-summary/status/route.js +1 -1
  40. package/.next/server/app/api/daily-summary/status/route.js.nft.json +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_client-reference-manifest.js +1 -1
  46. package/.next/server/app/api/fs/recent-paths/route_client-reference-manifest.js +1 -1
  47. package/.next/server/app/api/hooks/agent-event/route.js +1 -1
  48. package/.next/server/app/api/hooks/agent-event/route.js.nft.json +1 -1
  49. package/.next/server/app/api/hooks/agent-event/route_client-reference-manifest.js +1 -1
  50. package/.next/server/app/api/hooks/claude-done/route.js +1 -1
  51. package/.next/server/app/api/hooks/claude-done/route.js.nft.json +1 -1
  52. package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
  53. package/.next/server/app/api/hooks/permission-request/route.js +1 -1
  54. package/.next/server/app/api/hooks/permission-request/route.js.nft.json +1 -1
  55. package/.next/server/app/api/hooks/permission-request/route_client-reference-manifest.js +1 -1
  56. package/.next/server/app/api/metrics/vibe/route_client-reference-manifest.js +1 -1
  57. package/.next/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
  58. package/.next/server/app/api/push/escalation/route.js +1 -1
  59. package/.next/server/app/api/push/escalation/route.js.nft.json +1 -1
  60. package/.next/server/app/api/push/escalation/route_client-reference-manifest.js +1 -1
  61. package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
  62. package/.next/server/app/api/push/vapid/route.js +1 -1
  63. package/.next/server/app/api/push/vapid/route.js.nft.json +1 -1
  64. package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
  65. package/.next/server/app/api/relays/[relayId]/cancel/route.js.nft.json +1 -1
  66. package/.next/server/app/api/relays/[relayId]/cancel/route_client-reference-manifest.js +1 -1
  67. package/.next/server/app/api/relays/route.js.nft.json +1 -1
  68. package/.next/server/app/api/relays/route_client-reference-manifest.js +1 -1
  69. package/.next/server/app/api/remote/pair/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_client-reference-manifest.js +1 -1
  72. package/.next/server/app/api/repositories/[id]/todos/route_client-reference-manifest.js +1 -1
  73. package/.next/server/app/api/repositories/clone/[jobId]/route.js +1 -1
  74. package/.next/server/app/api/repositories/clone/[jobId]/route.js.nft.json +1 -1
  75. package/.next/server/app/api/repositories/clone/[jobId]/route_client-reference-manifest.js +1 -1
  76. package/.next/server/app/api/repositories/clone/route.js +1 -1
  77. package/.next/server/app/api/repositories/clone/route.js.nft.json +1 -1
  78. package/.next/server/app/api/repositories/clone/route_client-reference-manifest.js +1 -1
  79. package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
  80. package/.next/server/app/api/repositories/restore/route.js +1 -1
  81. package/.next/server/app/api/repositories/restore/route.js.nft.json +1 -1
  82. package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
  83. package/.next/server/app/api/repositories/route.js +1 -1
  84. package/.next/server/app/api/repositories/route.js.nft.json +1 -1
  85. package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
  86. package/.next/server/app/api/repositories/scan/route.js +1 -1
  87. package/.next/server/app/api/repositories/scan/route.js.nft.json +1 -1
  88. package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +1 -1
  89. package/.next/server/app/api/repositories/sync/route.js +1 -1
  90. package/.next/server/app/api/repositories/sync/route.js.nft.json +1 -1
  91. package/.next/server/app/api/repositories/sync/route_client-reference-manifest.js +1 -1
  92. package/.next/server/app/api/repositories/validate-path/route_client-reference-manifest.js +1 -1
  93. package/.next/server/app/api/settings/default-agents/route.js.nft.json +1 -1
  94. package/.next/server/app/api/settings/default-agents/route_client-reference-manifest.js +1 -1
  95. package/.next/server/app/api/settings/default-surface-mode/route_client-reference-manifest.js +1 -1
  96. package/.next/server/app/api/sidebar/group-order/route_client-reference-manifest.js +1 -1
  97. package/.next/server/app/api/skills/[id]/route_client-reference-manifest.js +1 -1
  98. package/.next/server/app/api/skills/installations/route_client-reference-manifest.js +1 -1
  99. package/.next/server/app/api/skills/operations/route_client-reference-manifest.js +1 -1
  100. package/.next/server/app/api/skills/reindex/route_client-reference-manifest.js +1 -1
  101. package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
  102. package/.next/server/app/api/slash-commands/route_client-reference-manifest.js +1 -1
  103. package/.next/server/app/api/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
  104. package/.next/server/app/api/tasks/[taskId]/route_client-reference-manifest.js +1 -1
  105. package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
  106. package/.next/server/app/api/templates/route_client-reference-manifest.js +1 -1
  107. package/.next/server/app/api/todos/route_client-reference-manifest.js +1 -1
  108. package/.next/server/app/api/verification/runs/[runId]/route_client-reference-manifest.js +1 -1
  109. package/.next/server/app/api/verification/runs/route_client-reference-manifest.js +1 -1
  110. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js +1 -1
  111. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js.nft.json +1 -1
  112. package/.next/server/app/api/worktrees/[id]/auto-yes/route_client-reference-manifest.js +1 -1
  113. package/.next/server/app/api/worktrees/[id]/capture/route.js.nft.json +1 -1
  114. package/.next/server/app/api/worktrees/[id]/capture/route_client-reference-manifest.js +1 -1
  115. package/.next/server/app/api/worktrees/[id]/clear-composer/route.js +1 -1
  116. package/.next/server/app/api/worktrees/[id]/clear-composer/route.js.nft.json +1 -1
  117. package/.next/server/app/api/worktrees/[id]/clear-composer/route_client-reference-manifest.js +1 -1
  118. package/.next/server/app/api/worktrees/[id]/cli-reference/route_client-reference-manifest.js +1 -1
  119. package/.next/server/app/api/worktrees/[id]/cli-tool/route_client-reference-manifest.js +1 -1
  120. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route.js +1 -1
  121. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route.js.nft.json +1 -1
  122. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route_client-reference-manifest.js +1 -1
  123. package/.next/server/app/api/worktrees/[id]/current-output/route.js +1 -1
  124. package/.next/server/app/api/worktrees/[id]/current-output/route.js.nft.json +1 -1
  125. package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
  126. package/.next/server/app/api/worktrees/[id]/env/route_client-reference-manifest.js +1 -1
  127. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route_client-reference-manifest.js +1 -1
  128. package/.next/server/app/api/worktrees/[id]/execution-logs/route.js +4 -3
  129. package/.next/server/app/api/worktrees/[id]/execution-logs/route.js.nft.json +1 -1
  130. package/.next/server/app/api/worktrees/[id]/execution-logs/route_client-reference-manifest.js +1 -1
  131. package/.next/server/app/api/worktrees/[id]/files/[...path]/route_client-reference-manifest.js +1 -1
  132. package/.next/server/app/api/worktrees/[id]/git/branch/create/route_client-reference-manifest.js +1 -1
  133. package/.next/server/app/api/worktrees/[id]/git/branch/delete/route_client-reference-manifest.js +1 -1
  134. package/.next/server/app/api/worktrees/[id]/git/branches/route_client-reference-manifest.js +1 -1
  135. package/.next/server/app/api/worktrees/[id]/git/checkout/route_client-reference-manifest.js +1 -1
  136. package/.next/server/app/api/worktrees/[id]/git/commit/route_client-reference-manifest.js +1 -1
  137. package/.next/server/app/api/worktrees/[id]/git/diff/route_client-reference-manifest.js +1 -1
  138. package/.next/server/app/api/worktrees/[id]/git/fetch/route_client-reference-manifest.js +1 -1
  139. package/.next/server/app/api/worktrees/[id]/git/log/route_client-reference-manifest.js +1 -1
  140. package/.next/server/app/api/worktrees/[id]/git/pull/route_client-reference-manifest.js +1 -1
  141. package/.next/server/app/api/worktrees/[id]/git/push/route_client-reference-manifest.js +1 -1
  142. package/.next/server/app/api/worktrees/[id]/git/reset/route_client-reference-manifest.js +1 -1
  143. package/.next/server/app/api/worktrees/[id]/git/revert/route_client-reference-manifest.js +1 -1
  144. package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route_client-reference-manifest.js +1 -1
  145. package/.next/server/app/api/worktrees/[id]/git/stage/route_client-reference-manifest.js +1 -1
  146. package/.next/server/app/api/worktrees/[id]/git/staged/route_client-reference-manifest.js +1 -1
  147. package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route_client-reference-manifest.js +1 -1
  148. package/.next/server/app/api/worktrees/[id]/git/stash/apply/route_client-reference-manifest.js +1 -1
  149. package/.next/server/app/api/worktrees/[id]/git/stash/pop/route_client-reference-manifest.js +1 -1
  150. package/.next/server/app/api/worktrees/[id]/git/stash/push/route_client-reference-manifest.js +1 -1
  151. package/.next/server/app/api/worktrees/[id]/git/stash/route_client-reference-manifest.js +1 -1
  152. package/.next/server/app/api/worktrees/[id]/git/status/route_client-reference-manifest.js +1 -1
  153. package/.next/server/app/api/worktrees/[id]/git/unstage/route_client-reference-manifest.js +1 -1
  154. package/.next/server/app/api/worktrees/[id]/git/working-diff/route_client-reference-manifest.js +1 -1
  155. package/.next/server/app/api/worktrees/[id]/instances/notes/route_client-reference-manifest.js +1 -1
  156. package/.next/server/app/api/worktrees/[id]/instances/opencode/route.js.nft.json +1 -1
  157. package/.next/server/app/api/worktrees/[id]/instances/opencode/route_client-reference-manifest.js +1 -1
  158. package/.next/server/app/api/worktrees/[id]/interrupt/route.js.nft.json +1 -1
  159. package/.next/server/app/api/worktrees/[id]/interrupt/route_client-reference-manifest.js +1 -1
  160. package/.next/server/app/api/worktrees/[id]/kill-session/route.js.nft.json +1 -1
  161. package/.next/server/app/api/worktrees/[id]/kill-session/route_client-reference-manifest.js +1 -1
  162. package/.next/server/app/api/worktrees/[id]/logs/[filename]/route_client-reference-manifest.js +1 -1
  163. package/.next/server/app/api/worktrees/[id]/logs/route_client-reference-manifest.js +1 -1
  164. package/.next/server/app/api/worktrees/[id]/marp-render/route_client-reference-manifest.js +1 -1
  165. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route_client-reference-manifest.js +1 -1
  166. package/.next/server/app/api/worktrees/[id]/memos/route_client-reference-manifest.js +1 -1
  167. package/.next/server/app/api/worktrees/[id]/messages/route_client-reference-manifest.js +1 -1
  168. package/.next/server/app/api/worktrees/[id]/opencode/diff/route_client-reference-manifest.js +1 -1
  169. package/.next/server/app/api/worktrees/[id]/opencode/session/route_client-reference-manifest.js +1 -1
  170. package/.next/server/app/api/worktrees/[id]/opencode/share/route_client-reference-manifest.js +1 -1
  171. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js +1 -1
  172. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js.nft.json +1 -1
  173. package/.next/server/app/api/worktrees/[id]/prompt-response/route_client-reference-manifest.js +1 -1
  174. package/.next/server/app/api/worktrees/[id]/resolve-target/route_client-reference-manifest.js +1 -1
  175. package/.next/server/app/api/worktrees/[id]/respond/route.js +1 -1
  176. package/.next/server/app/api/worktrees/[id]/respond/route.js.nft.json +1 -1
  177. package/.next/server/app/api/worktrees/[id]/respond/route_client-reference-manifest.js +1 -1
  178. package/.next/server/app/api/worktrees/[id]/route.js +1 -1
  179. package/.next/server/app/api/worktrees/[id]/route.js.nft.json +1 -1
  180. package/.next/server/app/api/worktrees/[id]/route_client-reference-manifest.js +1 -1
  181. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js +1 -6
  182. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js.nft.json +1 -1
  183. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route_client-reference-manifest.js +1 -1
  184. package/.next/server/app/api/worktrees/[id]/schedules/active/route.js +1 -1
  185. package/.next/server/app/api/worktrees/[id]/schedules/active/route.js.nft.json +1 -1
  186. package/.next/server/app/api/worktrees/[id]/schedules/active/route_client-reference-manifest.js +1 -1
  187. package/.next/server/app/api/worktrees/[id]/schedules/route.js +2 -7
  188. package/.next/server/app/api/worktrees/[id]/schedules/route.js.nft.json +1 -1
  189. package/.next/server/app/api/worktrees/[id]/schedules/route_client-reference-manifest.js +1 -1
  190. package/.next/server/app/api/worktrees/[id]/search/route_client-reference-manifest.js +1 -1
  191. package/.next/server/app/api/worktrees/[id]/send/route.js +1 -1
  192. package/.next/server/app/api/worktrees/[id]/send/route.js.nft.json +1 -1
  193. package/.next/server/app/api/worktrees/[id]/send/route_client-reference-manifest.js +1 -1
  194. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route.js.nft.json +1 -1
  195. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route_client-reference-manifest.js +1 -1
  196. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route_client-reference-manifest.js +1 -1
  197. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route_client-reference-manifest.js +1 -1
  198. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route_client-reference-manifest.js +1 -1
  199. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route_client-reference-manifest.js +1 -1
  200. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update/route_client-reference-manifest.js +1 -1
  201. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update-plan/route_client-reference-manifest.js +1 -1
  202. package/.next/server/app/api/worktrees/[id]/skills/route_client-reference-manifest.js +1 -1
  203. package/.next/server/app/api/worktrees/[id]/slash-commands/route_client-reference-manifest.js +1 -1
  204. package/.next/server/app/api/worktrees/[id]/special-keys/route.js +1 -1
  205. package/.next/server/app/api/worktrees/[id]/special-keys/route.js.nft.json +1 -1
  206. package/.next/server/app/api/worktrees/[id]/special-keys/route_client-reference-manifest.js +1 -1
  207. package/.next/server/app/api/worktrees/[id]/tasks/route_client-reference-manifest.js +1 -1
  208. package/.next/server/app/api/worktrees/[id]/terminal/route.js.nft.json +1 -1
  209. package/.next/server/app/api/worktrees/[id]/terminal/route_client-reference-manifest.js +1 -1
  210. package/.next/server/app/api/worktrees/[id]/timers/history/route_client-reference-manifest.js +1 -1
  211. package/.next/server/app/api/worktrees/[id]/timers/route.js +1 -1
  212. package/.next/server/app/api/worktrees/[id]/timers/route.js.nft.json +1 -1
  213. package/.next/server/app/api/worktrees/[id]/timers/route_client-reference-manifest.js +1 -1
  214. package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  215. package/.next/server/app/api/worktrees/[id]/todos/route_client-reference-manifest.js +1 -1
  216. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route_client-reference-manifest.js +1 -1
  217. package/.next/server/app/api/worktrees/[id]/tree/route_client-reference-manifest.js +1 -1
  218. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route_client-reference-manifest.js +1 -1
  219. package/.next/server/app/api/worktrees/[id]/verify/config/route_client-reference-manifest.js +1 -1
  220. package/.next/server/app/api/worktrees/[id]/verify/route.js +1 -1
  221. package/.next/server/app/api/worktrees/[id]/verify/route.js.nft.json +1 -1
  222. package/.next/server/app/api/worktrees/[id]/verify/route_client-reference-manifest.js +1 -1
  223. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/cancel/route.js +1 -1
  224. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/cancel/route.js.nft.json +1 -1
  225. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/cancel/route_client-reference-manifest.js +1 -1
  226. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route_client-reference-manifest.js +1 -1
  227. package/.next/server/app/api/worktrees/[id]/verify/runs/route_client-reference-manifest.js +1 -1
  228. package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
  229. package/.next/server/app/api/worktrees/apply-default-agents/route_client-reference-manifest.js +1 -1
  230. package/.next/server/app/api/worktrees/route.js +1 -1
  231. package/.next/server/app/api/worktrees/route.js.nft.json +1 -1
  232. package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
  233. package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  234. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  235. package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
  236. package/.next/server/app/more/page_client-reference-manifest.js +1 -1
  237. package/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  238. package/.next/server/app/page_client-reference-manifest.js +1 -1
  239. package/.next/server/app/proxy/[...path]/route_client-reference-manifest.js +1 -1
  240. package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
  241. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  242. package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  243. package/.next/server/app/skills/[skillId]/page_client-reference-manifest.js +1 -1
  244. package/.next/server/app/skills/installed/page_client-reference-manifest.js +1 -1
  245. package/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  246. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
  247. package/.next/server/app/worktrees/[id]/page.js +11 -9
  248. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
  249. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
  250. package/.next/server/app-paths-manifest.json +30 -30
  251. package/.next/server/chunks/1467.js +1 -1
  252. package/.next/server/chunks/1707.js +1 -1
  253. package/.next/server/chunks/1886.js +2 -2
  254. package/.next/server/chunks/2119.js +1 -1
  255. package/.next/server/chunks/2445.js +1 -1
  256. package/.next/server/chunks/3480.js +1 -18
  257. package/.next/server/chunks/3730.js +1 -1
  258. package/.next/server/chunks/4207.js +5 -0
  259. package/.next/server/chunks/4443.js +1 -1
  260. package/.next/server/chunks/5164.js +1 -1
  261. package/.next/server/chunks/6130.js +1 -1
  262. package/.next/server/chunks/650.js +1 -1
  263. package/.next/server/chunks/6661.js +1 -1
  264. package/.next/server/chunks/6677.js +2 -2
  265. package/.next/server/chunks/6793.js +13 -0
  266. package/.next/server/chunks/7075.js +1 -1
  267. package/.next/server/chunks/8052.js +74 -0
  268. package/.next/server/chunks/8728.js +2 -2
  269. package/.next/server/chunks/9080.js +1 -1
  270. package/.next/server/middleware-manifest.json +5 -5
  271. package/.next/server/pages/500.html +1 -1
  272. package/.next/server/server-reference-manifest.json +1 -1
  273. package/.next/static/chunks/{2407-e738634dab84534c.js → 2407-6fd60b674e20ec06.js} +1 -1
  274. package/.next/static/chunks/4388-a778968d9c4e9327.js +1 -0
  275. package/.next/static/chunks/4949-7dbce1029c6bdbb9.js +1 -0
  276. package/.next/static/chunks/998-292ebcd30f329eb1.js +1 -0
  277. package/.next/static/chunks/app/worktrees/[id]/page-86ef4510c70adefc.js +1 -0
  278. package/.next/trace +14 -14
  279. package/README.md +1 -1
  280. package/dist/cli/commands/ls.d.ts +64 -0
  281. package/dist/cli/commands/ls.d.ts.map +1 -1
  282. package/dist/cli/commands/ls.js +238 -30
  283. package/dist/cli/commands/respond.d.ts.map +1 -1
  284. package/dist/cli/commands/respond.js +14 -0
  285. package/dist/cli/commands/status.d.ts.map +1 -1
  286. package/dist/cli/commands/status.js +154 -15
  287. package/dist/cli/docs/agent-operations.d.ts +1 -1
  288. package/dist/cli/docs/agent-operations.d.ts.map +1 -1
  289. package/dist/cli/docs/agent-operations.js +37 -1
  290. package/dist/cli/types/api-responses.d.ts.map +1 -1
  291. package/dist/cli/utils/server-url.d.ts +27 -0
  292. package/dist/cli/utils/server-url.d.ts.map +1 -1
  293. package/dist/cli/utils/server-url.js +48 -6
  294. package/dist/lib/cli-tools/types.d.ts +22 -1
  295. package/dist/lib/cli-tools/types.d.ts.map +1 -1
  296. package/dist/lib/detection/tools/verified-against.d.ts +8 -0
  297. package/dist/lib/detection/tools/verified-against.d.ts.map +1 -1
  298. package/dist/lib/detection/tools/verified-against.js +8 -0
  299. package/dist/server/locales/en/worktree.json +21 -0
  300. package/dist/server/locales/ja/worktree.json +21 -0
  301. package/dist/server/src/lib/cli-tools/agent-mode-spec.js +327 -0
  302. package/dist/server/src/lib/cli-tools/base.js +22 -0
  303. package/dist/server/src/lib/cmate-parser.js +26 -6
  304. package/dist/server/src/lib/cmate-validator.js +354 -0
  305. package/dist/server/src/lib/detection/cli-patterns.js +40 -2
  306. package/dist/server/src/lib/detection/model-info-extractor.js +40 -3
  307. package/dist/server/src/lib/detection/prompt-detect-multiple-choice.js +44 -0
  308. package/dist/server/src/lib/detection/tools/antigravity/detect.js +9 -0
  309. package/dist/server/src/lib/detection/tools/command-code/detect.js +14 -3
  310. package/dist/server/src/lib/detection/tools/command-code/permission.js +104 -0
  311. package/dist/server/src/lib/detection/tools/verified-against.js +8 -0
  312. package/dist/server/src/lib/polling/auto-yes-dialog-gate.js +20 -2
  313. package/dist/server/src/lib/prompt-answer-sender.js +339 -16
  314. package/dist/server/src/lib/session/claude-executor.js +190 -17
  315. package/dist/server/src/types/cli-tool-contracts.js +75 -1
  316. package/dist/types/cli-tool-contracts.d.ts +162 -0
  317. package/dist/types/cli-tool-contracts.d.ts.map +1 -1
  318. package/dist/types/cli-tool-contracts.js +75 -1
  319. package/package.json +1 -1
  320. package/.next/server/chunks/6337.js +0 -1
  321. package/.next/server/chunks/663.js +0 -79
  322. package/.next/static/chunks/4388-410b1d8ed0d8d98b.js +0 -1
  323. package/.next/static/chunks/4949-f547605bd6078157.js +0 -1
  324. package/.next/static/chunks/998-ac0ded6d5eeb4dc0.js +0 -1
  325. package/.next/static/chunks/app/worktrees/[id]/page-3d147d6dd2fdc101.js +0 -1
  326. /package/.next/static/{OjmwYkJmQbLPFMjXdrB1R → rM1BO5QIz3tynGdyJy0T-}/_buildManifest.js +0 -0
  327. /package/.next/static/{OjmwYkJmQbLPFMjXdrB1R → rM1BO5QIz3tynGdyJy0T-}/_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:x,onSwipeEnd:h}=e,f=null!=c?c:"both"!==o,g="horizontal"===o?"horizontal":"vertical",p="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)},[]),I=(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,g)){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,g,m]),T=(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}}p&&r>s&&r>=l?k(n<0?"left":"right"):b&&s>=l&&k(a<0?"up":"down"),null==x||x({deltaX:n,deltaY:a})},[i,l,o,f,d,p,b,x]),E=(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?p&&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==h||h()},[i,l,f,p,b,t,n,r,s,h]),A=(0,a.useCallback)(()=>{N.current&&(N.current=null,C.current=null,j(!1),null==h||h())},[h]);return(0,a.useEffect)(()=>{let e=v.current;if(e)return e.addEventListener("touchstart",I),e.addEventListener("touchmove",T),e.addEventListener("touchend",E),e.addEventListener("touchcancel",A),()=>{e.removeEventListener("touchstart",I),e.removeEventListener("touchmove",T),e.removeEventListener("touchend",E),e.removeEventListener("touchcancel",A)}},[I,T,E,A]),{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"})})}},20252:(e,t,n)=>{Promise.resolve().then(n.bind(n,51662))},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),x=(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:x("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:x("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:x("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:x("pdfPreview.download")})]})]})}return(0,a.jsx)("iframe",{src:c,sandbox:l,title:x("pdfPreview.title",{path:n}),className:"w-full h-full border-0 bg-white","data-testid":"pdf-preview-iframe"})}let c=o},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}}},51662:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>oe});var a,r=n(95155),s=n(20063),l=n(54388),i=n(12115),o=n(67909),c=n(18955),d=n(37772),u=n(3005),m=n(28019),x=n(48481),h=n(92614),f=n(64269);let g=(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",search:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"};function b(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"),u=(0,c.c)("commandPalette"),{setOpen:b}=(0,h.C)();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)(g,{path:p.back})})}),(0,r.jsxs)("div",{className:"flex-1 flex items-center justify-center min-w-0 px-2",children:[(0,r.jsx)(x.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,f.W5)(s.currentBranch,20)}),s.isDirty&&(0,r.jsx)("span",{className:"text-warning",title:d("git.uncommittedChanges"),children:"*"})]})]})]})]}),(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-end",children:[(0,r.jsx)(m.$n,{variant:"ghost",type:"button","data-testid":"mobile-header-command-palette-trigger",onClick:()=>b(!0),"aria-label":u("mobileTrigger"),title:u("mobileTrigger"),className:"p-2 rounded-full hover:bg-muted transition-colors dark:text-foreground",children:(0,r.jsx)(g,{path:p.search})}),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)(g,{path:p.menu})})]})]})})}var v=n(22479),y=n(26983),j=n(59847),w=n(53842),k=n(23327);function N(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 C=[{id:"terminal",labelKey:"tabs.terminal",icon:(0,r.jsx)(v.A,{size:20,"aria-hidden":"true"})},{id:"history",labelKey:"tabs.history",icon:(0,r.jsx)(y.A,{size:20,"aria-hidden":"true"})},{id:"files",labelKey:"tabs.files",icon:(0,r.jsx)(j.A,{size:20,"aria-hidden":"true"})},{id:"memo",labelKey:"tabs.memo",icon:(0,r.jsx)(w.A,{size:20,"aria-hidden":"true"})},{id:"info",labelKey:"tabs.info",icon:(0,r.jsx)(k.A,{size:20,"aria-hidden":"true"})}];function S(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)([]),x=(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]),h=(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)%C.length;break;case"ArrowLeft":case"ArrowUp":a=(t-1+C.length)%C.length;break;case"Home":a=0;break;case"End":a=C.length-1;break;default:return}e.preventDefault(),null==(n=m.current[a])||n.focus(),h(C[a].id)},[h]),g=(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:C.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:()=>h(e.id),onKeyDown:e=>f(e,n),className:x(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&&g,"info"===e.id&&l&&(0,r.jsx)(N,{"data-testid":"info-update-badge",className:"absolute top-1 right-1","aria-label":u("tabs.updateAvailable")})]},e.id))})}var I=n(68276),T=n(87364);let E={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",none:""};function A(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 E.fadeIn;case"fade-out":return E.fadeOut;default:return E.none}},[a]),isAnimating:c}}var M=n(92539),R=n(8269);let L=[/^[^\S\n]*type\s+something\b/i],P={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"},D=(0,i.memo)(function(e){let{promptData:t,visible:n,answering:a,onRespond:s,onDismiss:l,cliToolName:o}=e,{shouldRender:c,animationClass:d}=A({visible:n&&null!==t,duration:300}),u=(0,i.useId)(),m=n&&null!==t,x=(0,M.r)({active:m}),[h,f]=(0,i.useState)(0);(0,i.useEffect)(()=>{n||f(0)},[n]);let g=(0,i.useCallback)(e=>{let{deltaY:t}=e;f(t>0?t:0)},[]),p=(0,i.useCallback)(()=>{null==l||l()},[l]),b=(0,i.useCallback)(()=>{f(0)},[]),{ref:v}=(0,R.hU)({axis:"vertical",threshold:100,enabled:m,onSwipeMove:g,onSwipeDown:p,onSwipeEnd:b}),y=(0,i.useCallback)(e=>{x.current=e,v.current=e},[x,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.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:h>0?"translateY(".concat(h,"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)(F,{promptData:t,answering:a,onRespond:s,labelId:u,cliToolName:o})})]})]})});function F(e){var t;let{promptData:n,answering:a,onRespond:s,labelId:l,cliToolName:o}=e,d=(0,c.c)("prompt"),[u,x]=(0,i.useState)(()=>{if("multiple_choice"===n.type){var e;let t=n.options.find(e=>e.isDefault);return null!=(e=null==t?void 0:t.number)?e:null}return null}),[h,f]=(0,i.useState)(""),[g,p]=(0,i.useState)(!1),b=(0,i.useMemo)(()=>{var e;return"multiple_choice"!==n.type?null:null!=(e=n.options.find(e=>e.number===u))?e:null},[n,u]),v=null!==b&&!0===(t=b).requiresTextInput&&L.some(e=>e.test(t.label)),y=a||g,j=(0,i.useCallback)(async e=>{if(!y){p(!0);try{await s(e)}catch(e){}finally{p(!1)}}},[y,s]),w=(0,i.useCallback)(async()=>{if(!y&&null!==u){p(!0);try{let e=v&&h.trim()?h.trim():u.toString();await s(e)}catch(e){}finally{p(!1)}}},[y,s,u,v,h]);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h3",{id:l,className:"text-lg font-semibold text-foreground",children:o?d("confirmationFrom",{toolName:o}):d("confirmationFromClaude")}),(0,I.XF)(n)&&n.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:n.instructionText}),(0,r.jsx)("p",{className:"text-foreground leading-relaxed",children:n.question}),y&&(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:d("sending")})]}),"yes_no"===n.type&&(0,r.jsx)(O,{promptData:n,disabled:y,onYes:()=>j("yes"),onNo:()=>j("no")}),"multiple_choice"===n.type&&(0,r.jsx)(z,{promptData:n,disabled:y,selectedOption:u,onSelectOption:x,textInputValue:h,onTextInputChange:f,showTextInput:v,onSubmit:w})]})}let O=(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(P.base," ").concat(P.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(P.base," ").concat(o?P.defaultSelected:P.secondary),children:l("no")})]})}),z=(0,i.memo)(function(e){let{promptData:t,disabled:n,selectedOption:a,onSelectOption:s,textInputValue:l,onTextInputChange:o,showTextInput:d,onSubmit:u}=e,x=(0,i.useId)(),h=(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:h("selectAnOption")}),(0,r.jsx)(m.z6,{name:x,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:h("default")})]})]},e.number)})})]}),d&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"text-input-".concat(x),className:"sr-only",children:h("customValueInput")}),(0,r.jsx)("input",{id:"text-input-".concat(x),type:"text",value:l,onChange:e=>o(e.target.value),disabled:n,placeholder:h("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(P.base," ").concat(P.primary),children:h("submit")})]})});var _=n(86651),B=n(11047),V=n(84926),U=n(37586),W=n(24033),H=n(97624),K=n(37354),$=n(54014),q=n(75676),G=n(26232),J=n(41898),Y=n(66966),Q=n(83012);let X="application/x-commandmate-agent-instance",Z=[{mode:"terminal",labelKey:"surfaceMode.showTerminal",icon:v.A},{mode:"chat",labelKey:"surfaceMode.showChat",icon:U.A}],ee="session-note-open";function et(e,t){let n=(0,Y.rC)(),a=null==n?void 0:n.worktrees,r=null==n?void 0:n.refresh,s=(0,i.useMemo)(()=>(function(e,t,n){var a;let r=null==e?void 0:e.find(e=>e.id===t),s=null==r||null==(a=r.sessionNotes)?void 0:a[n];return s&&"string"==typeof s.text&&0!==s.text.length?{text:s.text,updatedAt:"number"==typeof s.updatedAt?s.updatedAt:0}:null})(a,e,t),[a,e,t]),[l,o]=(0,i.useState)(null);(0,i.useEffect)(()=>{o(null)},[e,t]),(0,i.useEffect)(()=>{var e,t;if(null===l)return;let n=null===l.value?null===s:null!==s&&s.text===l.value.text,a=(null==s?void 0:s.text)!==(null==(e=l.base)?void 0:e.text)||(null==s?void 0:s.updatedAt)!==(null==(t=l.base)?void 0:t.updatedAt);(n||a)&&o(null)},[l,s]);let c=(0,i.useCallback)(n=>{let a=n.replace(/\s+/g," ").trim();Array.from(a).length>100||(o({value:a.length>0?{text:a,updatedAt:Date.now()}:null,base:s}),(async()=>{try{if(!(await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/instances/notes"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({instanceId:t,text:a})})).ok)return void o(null);await (null==r?void 0:r())}catch(e){o(null)}})())},[t,r,s,e]);return{note:l?l.value:s,save:c}}function en(e){let{initialText:t,onCommit:n,onCancel:a,ariaLabel:s,placeholder:l,testId:o}=e,[c,d]=(0,i.useState)(t),u=(0,i.useRef)(null);(0,i.useEffect)(()=>{var e,t;null==(e=u.current)||e.focus(),null==(t=u.current)||t.select()},[]);let m=(0,i.useCallback)(e=>{if("Enter"===e.key){if(e.nativeEvent.isComposing)return;e.preventDefault(),n(c);return}"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),a())},[a,n,c]);return(0,r.jsx)("input",{ref:u,type:"text",value:c,maxLength:100,placeholder:l,"aria-label":s,"data-testid":o,onChange:e=>d(e.target.value),onKeyDown:m,className:"w-full rounded border border-border bg-surface px-2 py-1 text-xs text-surface-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring"})}let ea=(0,i.memo)(function(e){var t;let{worktreeId:n,splitIndex:a,cliToolId:s,instanceId:l,instance:o,availableInstances:d,onInstanceChange:u,status:m="idle",agentModel:h,agentUsage:f,agentUsageDetail:g,onFocus:p,attaching:b=!1,headerExtras:v,surfaceMode:y=q.wf,onSurfaceModeChange:j,isMaximized:w=!1,onToggleMaximize:k,terminal:N,footer:C,style:S,onDropInstance:I,draggedInstanceId:T}=e,E=(0,c.c)("worktree"),[A,M]=(0,i.useState)(null),{note:R,save:L}=et(n,l),[P,D]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(!1)},[n,l]);let F=(0,i.useCallback)(()=>D(!0),[]),O=(0,i.useCallback)(()=>D(!1),[]),z=(0,i.useCallback)(e=>{L(e),D(!1)},[L]),_=(0,i.useCallback)(()=>{setTimeout(()=>D(!0),0)},[]),V=null!=I,U=(0,i.useCallback)(()=>null==T||d.some(e=>e.id===T)?"allowed":"forbidden",[T,d]),Y=(0,i.useCallback)(e=>{if(!V)return;e.preventDefault();let t=U();e.dataTransfer.dropEffect="forbidden"===t?"none":"move",M(e=>e===t?e:t)},[V,U]),ee=(0,i.useCallback)(e=>{if(!V)return;e.preventDefault();let t=U();M(e=>e===t?e:t)},[V,U]),ea=(0,i.useCallback)(()=>{V&&M(null)},[V]),er=(0,i.useCallback)(e=>{if(!V)return;e.preventDefault(),M(null);let t=e.dataTransfer.getData(X);t&&(null==I||I(t))},[V,I]),es=(0,i.useCallback)(()=>{window.dispatchEvent(new CustomEvent("terminal-search-open"))},[]),el=(0,i.useCallback)(()=>{p()},[p]),ei="Terminal split ".concat(a+1),eo=(0,$.sw)(null!=o?o:{cliTool:s}),ec=E("terminal.selectInstance",{split:ei}),ed=E("terminal.searchOutput",{split:ei}),eu=E("sessionNote.editLabel",{split:ei}),em=R?(0,Q.Uq)(new Date(R.updatedAt)):"",ex=R?E("sessionNote.label",{note:R.text,time:em}):"";return(0,r.jsxs)("div",{role:"region","aria-label":ei,"data-testid":"terminal-split-pane-".concat(a),"data-split-index":a,style:S,className:"flex flex-col min-w-0 h-full rounded-lg overflow-hidden border border-border bg-surface".concat(null===A?" focus-within:ring-1 focus-within:ring-accent-500/30":"").concat("allowed"===A?" ring-2 ring-accent-400":"forbidden"===A?" ring-2 ring-red-300 cursor-not-allowed":""),onFocusCapture:el,onMouseDown:p,onDragOver:Y,onDragEnter:ee,onDragLeave:ea,onDrop:er,children:[(0,r.jsxs)("div",{className:"relative px-2 py-1 flex items-center gap-2 bg-surface-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)(G.rI,{children:[(0,r.jsxs)(G.ty,{"data-testid":"cli-selector-".concat(a),"aria-label":ec,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)(x.m,{status:m,size:"sm","aria-hidden":!0,"data-testid":"split-status-indicator-".concat(a)}),(0,r.jsx)("span",{className:"truncate",children:eo}),(0,r.jsx)(W.A,{size:14,"aria-hidden":"true",className:"flex-shrink-0 opacity-70"})]}),(0,r.jsxs)(G.SQ,{align:"start",className:"min-w-[10rem]",children:[(0,r.jsx)(G.Hr,{value:l,onValueChange:u,children:d.map(e=>(0,r.jsx)(G.Ht,{value:e.id,children:(0,$.sw)(e)},e.id))}),(0,r.jsx)(G.mB,{}),(0,r.jsxs)(G._2,{"data-testid":"split-session-note-menu-item-".concat(a),onSelect:_,children:[(0,r.jsx)(B.A,{size:14,"aria-hidden":"true",className:"opacity-70"}),E("sessionNote.menuItem")]})]})]}),j?(0,r.jsx)("div",{role:"group","aria-label":E("surfaceMode.groupLabel",{split:ei}),"data-testid":"surface-mode-toggle-".concat(a),className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-border bg-surface p-0.5",children:Z.map(e=>{let{mode:t,labelKey:n,icon:s}=e,l=y===t,i=E(n);return(0,r.jsx)(J.m_,{content:i,placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:()=>j(t),"aria-pressed":l,"aria-label":i,"data-testid":"surface-mode-".concat(t,"-").concat(a),className:"flex items-center justify-center rounded px-1.5 py-0.5 touch-manipulation transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring ".concat(l?"bg-accent-500/15 text-accent-600 dark:text-accent-400":"text-muted-foreground hover:bg-muted hover:text-surface-foreground"),children:(0,r.jsx)(s,{size:14,"aria-hidden":"true"})})},t)})}):null,h&&(0,r.jsx)("span",{"data-testid":"split-agent-model-".concat(a),title:E("agentModel.modelLabel",{model:h}),className:"min-w-0 truncate text-[11px] leading-none text-muted-foreground ".concat(R?"max-w-[5rem] shrink-[4]":"max-w-[10rem]"),children:h}),f&&(0,r.jsx)("span",{"data-testid":"split-agent-usage-".concat(a),title:null!=g?g:E("agentSession.chipLabel",{usage:f}),className:"min-w-0 max-w-[10rem] truncate text-[11px] leading-none tabular-nums text-muted-foreground",children:f}),R&&(0,r.jsxs)("button",{type:"button",onClick:F,"aria-label":eu,title:ex,"data-testid":"split-session-note-".concat(a),className:"flex min-w-0 max-w-[16rem] shrink items-center gap-1 rounded px-1 py-0.5 text-[11px] leading-none text-muted-foreground hover:bg-muted-foreground/10 hover:text-surface-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsx)(B.A,{size:11,"aria-hidden":"true",className:"shrink-0 opacity-70"}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:R.text}),(0,r.jsx)("span",{"data-testid":"split-session-note-time-".concat(a),className:"shrink-0 tabular-nums opacity-70",children:em})]}),v,(0,r.jsx)(J.m_,{content:ed,placement:"bottom",className:"ml-auto",children:(0,r.jsx)("button",{type:"button",onClick:es,"aria-label":ed,"data-testid":"terminal-search-button-".concat(a),className:"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"})})})}),k?(0,r.jsx)(J.m_,{content:"".concat(w?E("terminal.restoreSplits"):E("terminal.maximizeSplit",{split:ei})," — ").concat(E("terminal.maximizeShortcutHint")),placement:"bottom",className:"flex-shrink-0",children:(0,r.jsx)("button",{type:"button",onClick:k,"aria-pressed":w,"aria-label":w?E("terminal.restoreSplits"):E("terminal.maximizeSplit",{split:ei}),"data-testid":"toggle-maximize-".concat(a),className:"flex flex-shrink-0 items-center justify-center px-1.5 py-0.5 text-muted-foreground hover:text-surface-foreground hover:bg-muted-foreground/10 rounded transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:w?(0,r.jsx)(H.A,{size:14,"aria-hidden":"true"}):(0,r.jsx)(K.A,{size:14,"aria-hidden":"true"})})}):null,P?(0,r.jsxs)("div",{"data-testid":"split-session-note-editor-".concat(a),className:"absolute inset-x-2 top-full z-30 mt-1 rounded-md border border-border bg-surface p-2 shadow-lg",children:[(0,r.jsx)(en,{initialText:null!=(t=null==R?void 0:R.text)?t:"",onCommit:z,onCancel:O,ariaLabel:eu,placeholder:E("sessionNote.placeholder"),testId:"split-session-note-input-".concat(a)}),(0,r.jsx)("p",{className:"mt-1 text-[10px] leading-tight text-muted-foreground",children:E("sessionNote.hint")})]}):null]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[b?(0,r.jsxs)("div",{"data-testid":"terminal-attach-skeleton-".concat(a),className:"absolute inset-0 flex items-center justify-center text-xs text-muted-foreground bg-surface-2/80",role:"status","aria-live":"polite",children:["Attaching ",eo," session..."]}):null,N]}),(0,r.jsx)("div",{className:"flex-shrink-0 border-t border-border p-2 bg-surface-2",children:C})]})});function er(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,M.r)({active:t}),m=(0,i.useCallback)(()=>{a(),n()},[a,n]),x=(0,i.useCallback)(()=>{s(),n()},[s,n]),h=(0,i.useCallback)(()=>{window.dispatchEvent(new CustomEvent(ee)),n()},[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)(_.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),o("terminal.searchTerminal")]}),(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-session-note",onClick:h,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)(B.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),o("sessionNote.menuItem")]}),(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-end",onClick:x,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)(V.A,{size:18,"aria-hidden":"true"}),o("terminal.endSession")]})]})]})]}):null}var es=n(73333),el=n(60734),ei=n(31166),eo=n(36402),ec=n(17846),ed=n(69264),eu=n(27307),em=n(24027),ex=n(5917),eh=n(75426),ef=n(51963),eg=n(39867);let ep="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 eb(e){let{open:t,onClose:n,onSearch:a,onCopyContent:s,onCopyPath:l,downloadUrl:o,downloadName:d,contentCopied:u,pathCopied:m}=e,x=(0,c.c)("worktree"),h=(0,i.useId)(),f=(0,M.r)({active:t}),g=(0,i.useCallback)(()=>{a(),n()},[a,n]),p=(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":h,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:h,className:"px-4 pb-2 text-sm font-medium text-muted-foreground",children:x("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:g,className:ep,children:[(0,r.jsx)(_.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),x("actions.searchInFile")]}),(0,r.jsxs)("button",{type:"button","data-testid":"file-actions-sheet-copy-content",onClick:p,className:ep,children:[u?(0,r.jsx)(ex.A,{size:18,"aria-hidden":"true",className:"text-success"}):(0,r.jsx)(eh.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),x("actions.copyFileContent")]}),(0,r.jsxs)("button",{type:"button","data-testid":"file-actions-sheet-copy-path",onClick:b,className:ep,children:[m?(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"}),x("actions.copyFilePath")]}),(0,r.jsxs)("a",{"data-testid":"download-file-button",href:o,download:d,onClick:n,className:ep,"aria-label":x("actions.downloadFile"),children:[(0,r.jsx)(eg.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),x("actions.downloadFile")]})]})]})]}):null}var ev=n(11063);let ey=[{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"]}],ej=ey.map(e=>e.extension),ew=[".md",".html",".htm",".yaml",".yml",".txt"];function ek(e){if(!e)return!1;let t=e.toLowerCase();return ew.includes(t)}ev.j6,ev.j6;var eN=n(60322),eC=n(65229),eS=n(99708),eI=n(57828),eT=n(18514),eE=n(59854),eA=n(76246),eM=n(78660);function eR(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),x=(0,i.useRef)(null),h=(0,i.useCallback)(()=>{n(!0),setTimeout(()=>{var e;return null==(e=m.current)?void 0:e.focus()},50)},[]),f=(0,i.useCallback)(()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),g=(0,i.useCallback)(()=>{n(!1),r(""),l(""),c([]),u(0),f()},[f]);(0,i.useEffect)(()=>{if(!a||a.length<eM.E2){l(""),f();return}return f(),x.current=setTimeout(()=>{l(a)},eM.e1),f},[a,f]),(0,i.useEffect)(()=>{if(!s||s.length<eM.E2||!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 p=(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:h,closeSearch:g,nextMatch:p,prevMatch:b,setSearchQuery:r}}var eL=n(4138),eP=n(90487);function eD(){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 eF=(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)(eD,{})}),eO="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",ez=/^---\s*\nmarp:\s*true/;function e_(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.nativeEvent.isComposing||(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)(eC.A,{className:"w-4 h-4"})})]})}let eB="\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 eV(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,eo.SC)(),x=(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]),h=(0,i.useMemo)(()=>"interactive"!==l?t:t.includes("</body>")?t.replace("</body>","".concat(eB,"</body>")):t+eB,[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 eP.A.highlight(t,{language:"html",ignoreIllegals:!0}).value}catch(e){return eP.A.highlightAuto(t).value}},[t]),g=(0,i.useMemo)(()=>Array.from({length:t.split("\n").length},(e,t)=>t+1),[t]),p=(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:()=>x(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:g.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=p[n])?t:""}})})})]},e)})})}):(0,r.jsx)("iframe",{srcDoc:h,sandbox:ev.Ko[l],title:u("htmlPreview.title",{path:n}),className:"w-full h-full border-0 bg-white"},"".concat(n,"-").concat(l))})]})}function eU(e){let{reason:t}=e;return(0,r.jsxs)("div",{"data-testid":"file-read-only-notice","data-reason-code":t.code,role:"status",className:"flex items-center gap-2 px-3 py-2 bg-warning-subtle border-b border-warning-border text-xs text-warning-foreground",children:[(0,r.jsx)(eS.A,{className:"w-3.5 h-3.5 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:t.message})]})}let eW=(0,i.memo)(function(e){var t;let{isOpen:n,onClose:a,worktreeId:s,filePath:l,onFileSaved:o,onOpenFile:u}=e,[x,h]=(0,i.useState)(null),[f,g]=(0,i.useState)(!1),[p,b]=(0,i.useState)(null),{copied:v,markCopied:y,reset:j}=(0,eL.q)(),{copied:w,markCopied:k}=(0,eL.q)(),[N,C]=(0,i.useState)(null),[S,I]=(0,i.useState)(0),[T,E]=(0,i.useState)(!1),[A,M]=(0,i.useState)("viewer"),[R,L]=(0,i.useState)(!1),[P,D]=(0,i.useState)(null),[F,O]=(0,i.useState)(!1),z=(0,i.useRef)(null),B=(0,c.c)("worktree"),V=(0,eo.SC)(),U=x?null!=P?P:x.content:void 0,{searchOpen:W,searchQuery:$,searchMatches:q,searchCurrentIdx:G,searchInputRef:J,openSearch:Y,closeSearch:Q,nextMatch:X,prevMatch:Z,setSearchQuery:ee}=eR(U),et=(0,i.useMemo)(()=>!!((null==x?void 0:x.content)&&!x.isImage&&!x.isVideo&&!x.isPdf),[x]),en=null!=(t=null==x?void 0:x.extension.toLowerCase())?t:"",ea="md"===en,er=!!(x&&!x.readOnly&&!x.isHtml&&ek(".".concat(en))),es=ea?A:W?"viewer":"editor",el=(0,i.useCallback)(async()=>{if(et&&U)try{await (0,eN.l)(U),y()}catch(e){}},[et,U,y]),ei=(0,i.useCallback)(async()=>{try{await (0,eN.l)(l),k()}catch(e){}},[l,k]),ep=(0,i.useCallback)(()=>{E(e=>!e)},[]);(0,i.useEffect)(()=>{if(0===q.length||!z.current)return;let e=q[G],t=z.current.querySelector('[data-line="'.concat(e,'"]'));t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"})},[G,q]),(0,i.useEffect)(()=>{if(!T||er)return;let e=e=>{"Escape"===e.key&&E(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[T,er]),(0,i.useEffect)(()=>{if(!n||!l){h(null),b(null),j(),M("viewer"),L(!1),D(null),O(!1),Q();return}M("viewer"),L(!1),D(null),O(!1),(async()=>{g(!0),b(null);try{let t=await fetch("/api/worktrees/".concat(s,"/files/").concat((0,eA.o)(l)));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)||B("fileViewer.loadError");throw Error(a)}let n=await t.json();h(n)}catch(e){b(e instanceof Error?e.message:B("fileViewer.loadError"))}finally{g(!1)}})()},[n,s,l]),(0,i.useEffect)(()=>{C(null),I(0),x&&"md"===x.extension&&ez.test(x.content)&&!(x.content.length>1e6)&&(async()=>{try{let e=await fetch("/api/worktrees/".concat(s,"/marp-render"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:x.content})});if(e.ok){let t=await e.json();C(t.slides)}}catch(e){}})()},[x,s]);let ev=!!(N&&N.length>0),ey=(0,i.useCallback)(e=>{D(e)},[]),ej=(0,i.useCallback)((e,t)=>{h(e=>e?{...e,content:t}:e),D(t),null==o||o(e)},[o]),ew=(0,i.useCallback)(async()=>{(!F||await V({description:B("editor.unsavedCloseConfirm"),variant:"danger"}))&&a()},[F,V,B,a]);(0,i.useEffect)(()=>{if(!er||R)return;let e=e=>{"Escape"===e.key&&(W?Q():T?E(!1):ew())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[er,R,W,T,ew]);let[eS,eM]=(0,i.useState)("");(0,i.useEffect)(()=>{ea&&"viewer"===es&&void 0!==U&&eM(U)},[ea,es,U]),(0,i.useEffect)(()=>{if(!er||!n)return;let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[er,n]);let eD=(0,i.useMemo)(()=>{if(!x||void 0===U||x.isImage||x.isVideo||x.isHtml||x.isPdf)return null;let e=Array.from({length:U.split("\n").length},(e,t)=>t+1);try{return{lineNumbers:e,highlightedHtml:eP.A.highlight(U,{language:x.extension,ignoreIllegals:!0}).value}}catch(t){return{lineNumbers:e,highlightedHtml:eP.A.highlightAuto(U).value}}},[x,U]),eB=()=>x?x.isImage?(0,r.jsx)(ec.a,{src:x.content,alt:x.path,mimeType:x.mimeType}):x.isVideo?(0,r.jsx)(ed.u,{src:x.content,mimeType:x.mimeType}):x.isPdf?(0,r.jsx)("div",{className:"h-full min-h-[40vh]",children:(0,r.jsx)(eu.PdfPreview,{dataUri:x.content,filePath:l,variant:"download"})}):x.isHtml?(0,r.jsx)(eV,{htmlContent:x.content,filePath:l}):eW():null,eW=()=>{if(!eD)return null;let e=new Set(q),t=q.length>0?q[G]:-1,n=eD.highlightedHtml.split("\n");return(0,r.jsx)("div",{ref:z,children:(0,r.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,r.jsx)("tbody",{children:eD.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)})})})})},eH="/api/worktrees/".concat(s,"/files/").concat((0,eA.o)(l),"?download=1"),eK=l?l.split("/").pop()||l:"",e$=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,r.jsxs)("a",{"data-testid":"download-file-button",href:eH,download:eK,className:e,"aria-label":B("actions.downloadFile"),title:B("actions.download"),children:[(0,r.jsx)(eg.A,{className:"w-3.5 h-3.5"}),t&&(0,r.jsx)("span",{children:B("actions.download")})]})},eq=()=>(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:ei,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":B("actions.copyFilePath"),title:B("actions.copyPath"),children:w?(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)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:l})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[et&&(0,r.jsx)("button",{onClick:Y,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":B("actions.searchInFile"),title:B("actions.search"),children:(0,r.jsx)(_.A,{className:"w-3.5 h-3.5"})}),et&&(0,r.jsx)("button",{"data-testid":"copy-content-button",onClick:el,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":B("actions.copyFileContent"),title:B("actions.copyContent"),children:v?(0,r.jsx)(ex.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(eh.A,{className:"w-3.5 h-3.5"})}),e$("p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground"),(0,r.jsx)("button",{onClick:ep,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":T?B("actions.exitFullscreen"):B("actions.fullscreen"),title:T?B("actions.exitFullscreen"):B("actions.fullscreen"),children:T?(0,r.jsx)(H.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(K.A,{className:"w-3.5 h-3.5"})})]})]}),eG=()=>(null==x?void 0:x.readOnly)&&x.readOnlyReason?(0,r.jsx)(eU,{reason:x.readOnlyReason}):null,eJ=()=>(0,r.jsx)(e_,{searchInputRef:J,searchQuery:$,searchMatches:q,searchCurrentIdx:G,onQueryChange:ee,onPrev:Z,onNext:X,onClose:Q});if(er&&x&&!f&&!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":l,className:"fixed inset-0 flex h-[100dvh] flex-col bg-surface",style:{zIndex:eE.M.MAXIMIZED_EDITOR},children:[T?(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:ep,"aria-pressed":!0,"aria-label":B("actions.exitFullscreen"),className:eO,children:(0,r.jsx)(H.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void ew(),"aria-label":B("actions.close"),className:eO,children:(0,r.jsx)(eC.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:l}),ea&&(0,r.jsxs)("div",{"data-testid":"markdown-file-mode-switch",role:"group","aria-label":B("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"===A,onClick:()=>M("viewer"),className:e("viewer"===A),children:[(0,r.jsx)(eI.A,{className:"h-4 w-4"}),B("fileViewer.modeViewer")]}),(0,r.jsxs)("button",{type:"button","data-testid":"markdown-file-mode-editor","aria-pressed":"editor"===A,onClick:()=>M("editor"),className:e("editor"===A),children:[(0,r.jsx)(eT.A,{className:"h-4 w-4"}),B("fileViewer.modeEditor")]})]}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-actions-trigger",onClick:()=>L(!0),"aria-label":B("fileViewer.moreActions"),className:eO,children:(0,r.jsx)(d.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:ep,"aria-pressed":!1,"aria-label":B("actions.fullscreen"),className:eO,children:(0,r.jsx)(K.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void ew(),"aria-label":B("actions.close"),className:eO,children:(0,r.jsx)(eC.A,{className:"h-5 w-5"})})]}),W&&(0,r.jsx)("div",{className:"flex-shrink-0",children:eJ()}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,r.jsx)("div",{className:"viewer"===es?"flex min-h-0 flex-1 flex-col":"hidden",children:W?(0,r.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:eW()}):ev?N?(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:()=>I(e=>Math.max(0,e-1)),disabled:0===S,className:"min-h-[44px] px-3 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors touch-manipulation",children:B("actions.prev")}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground",children:[S+1," / ",N.length]}),(0,r.jsx)("button",{type:"button",onClick:()=>I(e=>Math.min(N.length-1,e+1)),disabled:S===N.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:B("actions.next")})]}),(0,r.jsx)("iframe",{srcDoc:N[S],sandbox:"",title:B("fileViewer.slideTitle",{name:l,number:S+1}),className:"w-full flex-1 border-0"})]}):null:ea?(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)(em.G8,{content:eS,currentFilePath:l,worktreeId:s,onOpenFile:u})}):null}),(0,r.jsx)("div",{"data-testid":"markdown-file-editor",className:"editor"===es?"flex min-h-0 flex-1 flex-col":"hidden",children:(0,r.jsx)(eF,{worktreeId:s,filePath:l,initialContent:x.content,embedded:!0,onSave:ej,onDirtyChange:O,onContentChange:ey,onOpenFile:u},l)})]}),(0,r.jsx)(eb,{open:R,onClose:()=>L(!1),onSearch:()=>{M("viewer"),Y()},onCopyContent:el,onCopyPath:ei,downloadUrl:eH,downloadName:eK,contentCopied:v,pathCopied:w})]})})}return T&&x&&!f&&!p?(0,r.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:eE.M.MAXIMIZED_EDITOR},children:[eq(),eG(),W&&eJ(),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:eB()})]}):(0,r.jsx)(m.Jh,{isOpen:n,onClose:a,title:l,size:"xl",children:(0,r.jsxs)("div",{className:"max-h-[60vh] sm:max-h-[70vh] flex flex-col",children:[f&&(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:B("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:e$("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)})]}),x&&!f&&!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:[eq(),eG(),W&&eJ()]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:eB()})]})]})})});var eH=n(36809),eK=n(46892),e$=n(50857),eq=n(94442),eG=n(80344);function eJ(e){let{worktreeId:t}=e,[n,a]=(0,i.useState)([]),[s,l]=(0,i.useState)(null),[o,d]=(0,i.useState)(null),[u,x]=(0,i.useState)(!0),[h,g]=(0,i.useState)(null),[p,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,eq.dj)(),S=(0,c.c)("worktree");(0,i.useEffect)(()=>{(async()=>{try{x(!0),g(null);let e=await eG.y.getLogs(t);a(e)}catch(e){g((0,eG.hS)(e))}finally{x(!1)}})()},[t]);let I=(0,i.useMemo)(()=>"all"===j?n:n.filter(e=>e.toLowerCase().includes(j)),[n,j]),T=async e=>{try{x(!0),g(null);let n=await eG.y.getLogFile(t,e);d(n.content),l(e),b(""),y(0)}catch(e){g((0,eG.hS)(e))}finally{x(!1)}},E=(0,i.useCallback)(async()=>{if(s)try{N(!0);let e=await eG.y.getLogFile(t,s,{sanitize:!0});await (0,eN.l)(e.content),C(S("logViewer.copied"),"success")}catch(e){C(S("logViewer.exportError",{error:(0,eG.hS)(e)}),"error")}finally{N(!1)}},[t,s,C,S]),A=(0,i.useMemo)(()=>{let e;if(!p||!o)return[];let t=RegExp((0,f.Nt)(p),"gi"),n=[];for(;null!==(e=t.exec(o));)n.push({index:e.index,length:e[0].length});return n},[p,o]);(0,i.useEffect)(()=>{y(0)},[p]);let M=()=>{A.length>0&&y(e=>(e+1)%A.length)},R=()=>{A.length>0&&y(e=>(e-1+A.length)%A.length)},L=(0,i.useMemo)(()=>{if(!o||!p||0===A.length)return o;let e="",t=0;return A.forEach((n,a)=>{e+=(0,f.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,f.ZD)(r),"</mark>"),t=n.index+n.length}),e+=(0,f.ZD)(o.substring(t))},[o,p,A,v]);return(0,i.useEffect)(()=>{A.length>0&&v>=0&&setTimeout(()=>{let e=document.querySelector('mark[data-match-index="'.concat(v,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"})},100)},[v,A.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:I.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"})}),h&&(0,r.jsx)("div",{className:"p-3 bg-danger-subtle border border-danger-border rounded text-sm text-danger-foreground",children:h}),!u&&0===I.length&&!h&&(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})}),I.length>0&&(0,r.jsx)("div",{className:"space-y-2",children:I.map(e=>(0,r.jsx)("button",{onClick:()=>T(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:E,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:p,onChange:e=>b(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),e.shiftKey?R():M())},placeholder:S("logViewer.searchPlaceholder"),className:"w-full pr-20"}),A.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," / ",A.length]})]}),A.length>0&&(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:R,disabled:0===A.length,title:S("logViewer.prevMatch"),children:"↑"}),(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:M,disabled:0===A.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:p&&A.length>0?(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",dangerouslySetInnerHTML:{__html:L||""}}):(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",children:o})}),!u&&p&&0===A.length&&o&&(0,r.jsx)("div",{className:"text-center py-4 text-sm text-muted-foreground",children:S("logViewer.noMatches",{query:p})})]})]})]})}function eY(){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 eG.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}}function eQ(e){let{hasUpdate:t,latestVersion:n,releaseUrl:a,updateCommand:s,installType:l}=e,o=(0,c.c)("worktree"),[d,m]=(0,i.useState)("idle"),[x,h]=(0,i.useState)(null),[f,g]=(0,i.useState)(null),p=(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 eG.GQ.startUpdate();h(e.logPath),m(e.willRestart?"updating":"no-restart")}catch(e){e instanceof eG.hD&&400===e.status?g(o("update.errorNotGlobal")):e instanceof eG.hD&&409===e.status?g(o("update.errorInProgress")):g(o("update.errorGeneric")),m("error")}},[o]);return((0,i.useEffect)(()=>{if("updating"!==d)return;let e=!1,t=Date.now();p.current=!1;let n=setInterval(async()=>{if(e)return;if(Date.now()-t>3e5)return void m("timeout");let n=await eG.GQ.ping();if(!e){if(!n){p.current=!0;return}p.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)(ei.$,{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})]}),x&&("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:x})}),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)(eo.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 eX(e){let{version:t,className:n}=e,a=(0,c.c)("worktree"),{data:s,loading:l}=eY(),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)(eQ,{...o})]})}let eZ="https://github.com/Kewton/CommandMate",e0="".concat(eZ,"/issues"),e1="".concat(eZ,"/issues/new"),e2="".concat(e1,"?template=bug_report.md"),e4="".concat(e1,"?template=feature_request.md"),e5="".concat(e1,"?template=question.md");function e3(e){let{className:t}=e,n=(0,c.c)("worktree"),a=[{href:e2,label:n("feedback.bugReport")},{href:e4,label:n("feedback.featureRequest")},{href:e5,label:n("feedback.question")},{href:e0,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 e6=n(94465),e8=n(38606),e9=n(34681),e7=n(95707),te=n(14006),tt=n(73190),tn=n(56827),ta=n(9900);function tr(e){return""!==(null!=e?e:"").trim()}function ts(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=(0,tn.B)(t,n,a,l),x=(0,i.useCallback)(()=>{m(["Enter"])},[m]),h=(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,ta.LK)}).catch(e=>{console.error("Failed to clear composer:",e)}).finally(()=>{u(!1)})},[t,n,a,l]);if(!tr(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:x,"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:h,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 tl=n(51515),ti=n(813),to=n(16342);let tc=/^([^\S\n]*)╹(▀{4,})/,td=/^([^\S\n]*)[│┃]/;function tu(e,t){return"opencode"===e&&null!==function(e){let t=(0,tl.aJ)(e).split("\n"),n=-1,a=-1,r=-1;for(let e=0;e<t.length;e++){let s=tc.exec(t[e]);s&&(n=e,r=(a=s[1].length)+1+s[2].length)}if(-1===n)return null;let s=0,l="";for(let e=0;e<t.length;e++){let i=t[e];if(e!==n){let e=td.exec(i);if(!e||e[1].length!==a)continue}let o=i.slice((0,to.sh)(i,r)).trim();""!==o&&(s+=1,""===l&&(l=(0,ti.D)(o,200,"…[truncated]")))}return s<2?null:{id:"opencode_sidebar",matchedText:l,boxRight:r,rows:s}}(null!=t?t:"")}function tm(e){let{cliToolId:t,frame:n}=e,a=(0,c.c)("worktree");return(0,i.useMemo)(()=>tu(t,n),[t,n])?(0,r.jsxs)("div",{"data-testid":"opencode-sidebar-notice",role:"status","aria-label":a("opencodeSidebar.regionLabel"),className:"flex flex-wrap items-center gap-2 px-2 py-1.5 bg-warning-subtle border border-warning-border rounded-lg",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-warning-foreground shrink-0",children:a("opencodeSidebar.label")}),(0,r.jsx)("span",{className:"flex-1 min-w-0 text-xs text-foreground",children:a("opencodeSidebar.body")}),(0,r.jsx)("code",{"data-testid":"opencode-sidebar-notice-chord",className:"shrink-0 font-mono text-xs px-1.5 py-0.5 rounded bg-surface border border-warning-border text-warning-foreground",children:"ctrl+x b"})]}):null}var tx=n(40240),th=n(84228),tf=n(62560),tg=n(308),tp=n(80635),tb=n(52407);let tv=(0,i.createContext)({register:()=>{},insertToComposer:()=>{}}),ty=(0,i.createContext)(null);function tj(e){var t;return null!=(t=e.instanceId)?t:e.cliToolId}function tw(e){let{onInsertToComposer:t,children:n}=e,[a,s]=(0,i.useState)(null),l=(0,i.useRef)(t);l.current=t;let o=(0,i.useCallback)(e=>{var t;null==(t=l.current)||t.call(l,e)},[]),c=(0,i.useMemo)(()=>({register:s,insertToComposer:o}),[o]);return(0,r.jsx)(tv.Provider,{value:c,children:(0,r.jsx)(ty.Provider,{value:a,children:n})})}function tk(e){let t=(0,i.useContext)(ty);if(null!==t&&t.target.cliToolId===e.cliToolId&&tj(t.target)===tj(e))return t.send}var tN=n(9708),tC=n(60199),tS=n(52703),tI=n(51021),tT=n(68394),tE=n(17683);let tA=[{mode:"terminal",labelKey:"surfaceMode.terminal",icon:v.A},{mode:"chat",labelKey:"surfaceMode.chat",icon:U.A}],tM=[tI.Mx,"m"],tR="/model",tL=(0,i.memo)(function(e){let{modelLabel:t,usage:n,usageDetail:a,recentChange:s,note:l,onEditNote:i,onOpenPicker:o,onDismissChange:d}=e,u=(0,c.c)("worktree"),m=null!==s,x=u("agentModel.sessionRow",{model:null!=t?t:""}),h=l?(0,Q.Uq)(new Date(l.updatedAt)):"",f=l?u("sessionNote.label",{note:l.text,time:h}):u("sessionNote.menuItem");return(0,r.jsxs)("div",{"data-testid":"mobile-session-row","data-model-changed":m?"true":"false",className:"relative z-20 flex h-7 shrink-0 items-center gap-2 border-b px-3 text-[11px] leading-none ".concat(m?"border-warning-border bg-warning-subtle text-warning-foreground":"border-border bg-surface-2 text-muted-foreground"),children:[t?(0,r.jsxs)("button",{type:"button",onClick:o,"aria-label":x,title:x,"data-testid":"mobile-session-model",className:"relative flex min-w-0 basis-0 grow items-center gap-1.5 truncate text-left touch-manipulation before:absolute before:inset-x-0 before:-inset-y-2 before:content-[''] ".concat(l?"shrink-[4]":"shrink"),children:[(0,r.jsx)(e7.A,{size:12,"aria-hidden":"true",className:"shrink-0"}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:t})]}):null,l?(0,r.jsxs)("button",{type:"button",onClick:i,"aria-label":f,title:f,"data-testid":"mobile-session-note",className:"relative flex min-w-0 shrink basis-0 grow items-center gap-1 text-left touch-manipulation before:absolute before:inset-x-0 before:-inset-y-2 before:content-['']",children:[(0,r.jsx)(B.A,{size:12,"aria-hidden":"true",className:"shrink-0 opacity-70"}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:l.text}),(0,r.jsx)("span",{"data-testid":"mobile-session-note-time",className:"shrink-0 tabular-nums opacity-70",children:h})]}):null,n?(0,r.jsx)("span",{"data-testid":"mobile-session-usage",title:null!=a?a:u("agentSession.chipLabel",{usage:n}),className:"min-w-0 max-w-[10rem] shrink-0 truncate tabular-nums",children:n}):null,s?(0,r.jsx)("button",{type:"button",onClick:d,"aria-label":u("agentModel.changedRecentlyDetail",{from:s.from,to:s.to}),title:u("agentModel.changedRecentlyDetail",{from:s.from,to:s.to}),"data-testid":"mobile-session-model-changed",className:"relative shrink-0 rounded-full border border-warning-border bg-warning/20 px-1.5 py-0.5 font-medium touch-manipulation before:absolute before:inset-x-0 before:-inset-y-2 before:content-['']",children:u("agentModel.changedRecently")}):null]})}),tP=(0,i.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,live:s,frame:l,onKeysSent:o,onSurfaceModeChange:c}=e,{messages:d,isLoading:u,refresh:m}=(0,tg.Md)({worktreeId:t,cliToolId:n,instanceId:a}),x=(0,i.useCallback)((e,n)=>eG.y.sendMessage(t,e,n),[t]),h=(0,tb.Fx)(),f=(0,i.useMemo)(()=>({offline:(0,tb.sV)(h.signals),reachable:(0,tb._X)(h.signals)}),[h.signals]),{messages:g,sendOptimistic:p,retry:b,discard:v}=(0,tp.v4)({worktreeId:t,serverMessages:d,sendFn:x,onSent:m,connectivity:f});!function(e){let{cliToolId:t,instanceId:n,send:a}=e,{register:r}=(0,i.useContext)(tv);(0,i.useEffect)(()=>(r({target:{cliToolId:t,instanceId:n},send:a}),()=>r(null)),[r,t,n,a])}({cliToolId:n,instanceId:a,send:p});let{worktreePath:y,openFile:j}=(0,tN.O)(),w=(0,i.useContext)(tv).insertToComposer,k=(0,i.useCallback)(e=>{let t=v(e);t&&w(t)},[v,w]);return(0,r.jsx)(th.wY,{messages:g,worktreeId:t,worktreePath:y,cliToolId:n,instanceId:a,live:s,onSurfaceModeChange:c,frame:l,onKeysSent:o,compact:!0,history:{onFilePathClick:j,isLoading:u,onRetryPending:b,onDiscardPending:k,onInsertToMessage:w}})}),tD=(0,i.memo)(function(e){var t,n;let{worktreeId:a,cliToolId:s,instanceId:l,disableAutoFollow:o,onSurfaceModeChange:d}=e,{terminal:u,prompt:m,agentSession:x,setAutoScroll:h,refresh:f}=(0,tf.NK)({worktreeId:a,cliToolId:s,instanceId:l}),{compactTuiLayoutPadding:g,preservePaintedPanelRows:p,mobileWrapMode:b}=(0,tT.EK)(s),v=(0,c.c)("worktree"),y=(0,eH.Ym)(),j=null!=l?l:s,w=function(e,t){let n=(0,Y.rC)(),a=null==n?void 0:n.worktrees;return(0,i.useMemo)(()=>{var n;let r=null==a?void 0:a.find(t=>t.id===e);return null!=(n=sQ(null==r?void 0:r.sessionStatusByInstance)[t])?n:null},[a,e,t])}(a,j),k=(0,Y.rC)(),N=s$(w,null,null==(t=x.session)?void 0:t.agent),C=sJ(x.session,x.context,v,y),S=sY(x.session,x.context,v,y),{note:I,save:T}=et(a,j),[E,A]=(0,i.useState)(!1);(0,i.useEffect)(()=>{let e=()=>A(!0);return window.addEventListener(ee,e),()=>window.removeEventListener(ee,e)},[]),(0,i.useEffect)(()=>{A(!1)},[a,j]);let M=(0,i.useCallback)(()=>A(!0),[]),R=(0,i.useCallback)(()=>A(!1),[]),L=(0,i.useCallback)(e=>{T(e),A(!1)},[T]),P=null!==N||null!==I,[D,F]=(0,i.useState)(null);(0,tC.T3)(e=>{e.type===tS.T4&&e.worktreeId===a&&e.instance===j&&(F({from:e.from,to:e.to,at:e.at}),null==k||k.refresh())}),(0,i.useEffect)(()=>{if(null===D)return;let e=D.at+3e5-Date.now();if(e<=0)return void F(null);let t=setTimeout(()=>F(null),e);return()=>clearTimeout(t)},[D]);let O=(0,i.useCallback)(()=>F(null),[]);(0,i.useEffect)(()=>{F(null)},[a,j]);let z=(0,tn.B)(a,s,l,f),_=tk({cliToolId:s,instanceId:l}),B=(0,i.useRef)(null);(0,i.useEffect)(()=>()=>{null!==B.current&&clearTimeout(B.current)},[]);let V=(0,i.useCallback)(()=>{if("opencode"===s)return void z([...tM]);let e={cliToolId:s,instanceId:l};_?_(tR,e):eG.y.sendMessage(a,tR,e).catch(()=>{}),null!==B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{B.current=null,f()},ta.LK)},[s,l,_,f,z,a]),U=(0,tE.NP)(a),[W,H]=(0,i.useState)(q.wf);(0,i.useEffect)(()=>{H((0,tE.TR)(U))},[U]);let K=(0,i.useCallback)(e=>{H(e),(0,tE.If)(U,e)},[U]);(0,i.useEffect)(()=>{null==d||d(W)},[d,W]);let $=u.isUnclassifiedActive&&!m.visible&&"chat"!==W,G=tr(u.composerText),J=tu(s,u.realtimeSnippet||u.output),Q=(0,i.useMemo)(()=>({isRunning:u.isRunning,attaching:u.attaching,sessionStatus:u.sessionStatus,isThinking:u.isThinking,isPromptWaiting:m.visible,promptData:m.data,isSelectionListActive:u.isSelectionListActive,isPagerActive:u.isPagerActive,isDismissablePanelActive:u.isDismissablePanelActive,isUnclassifiedActive:u.isUnclassifiedActive}),[u.isRunning,u.attaching,u.sessionStatus,u.isThinking,u.isSelectionListActive,u.isPagerActive,u.isDismissablePanelActive,u.isUnclassifiedActive,m.visible,m.data]);return(0,r.jsxs)("div",{className:"relative flex flex-col h-full min-h-0",children:[(0,r.jsx)("div",{role:"group","aria-label":v("surfaceMode.groupLabelMobile"),"data-testid":"mobile-surface-mode-toggle",className:"pointer-events-none absolute right-2 z-30 flex items-center gap-0.5 rounded-full border border-border bg-surface-2/95 p-0.5 shadow-lg backdrop-blur ".concat(P?"top-9":"top-2"),children:tA.map(e=>{let{mode:t,labelKey:n,icon:a}=e,s=W===t,l=v(n);return(0,r.jsx)("button",{type:"button",onClick:()=>K(t),"aria-pressed":s,"aria-label":l,title:l,"data-testid":"mobile-surface-mode-".concat(t),className:"pointer-events-auto flex min-h-[44px] min-w-[44px] items-center justify-center rounded-full transition-colors touch-manipulation ".concat(s?"bg-accent-500/20 text-accent-600 dark:text-accent-400":"text-muted-foreground"),children:(0,r.jsx)(a,{size:18,"aria-hidden":"true"})},t)})}),P?(0,r.jsx)(tL,{modelLabel:N,usage:C,usageDetail:S,recentChange:D,note:I,onEditNote:M,onOpenPicker:V,onDismissChange:O}):null,E?(0,r.jsxs)("div",{"data-testid":"mobile-session-note-editor",className:"absolute inset-x-2 z-40 rounded-md border border-border bg-surface p-2 shadow-lg ".concat(P?"top-9":"top-2"),children:[(0,r.jsx)(en,{initialText:null!=(n=null==I?void 0:I.text)?n:"",onCommit:L,onCancel:R,ariaLabel:v("sessionNote.menuItem"),placeholder:v("sessionNote.placeholder"),testId:"mobile-session-note-input"}),(0,r.jsx)("p",{className:"mt-1 text-[10px] leading-tight text-muted-foreground",children:v("sessionNote.hint")})]}):null,(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden","data-testid":"mobile-terminal-region",children:"chat"===W?(0,r.jsx)("div",{className:"h-full min-h-0","data-testid":"mobile-chat-surface",children:(0,r.jsx)(tP,{worktreeId:a,cliToolId:s,instanceId:l,live:Q,frame:u.output,onKeysSent:f,onSurfaceModeChange:K})}):(0,r.jsx)(te.D,{output:u.output,isActive:u.isRunning,isThinking:u.isThinking,autoScroll:u.autoScroll,onScrollChange:h,disableAutoFollow:o,compactTuiLayoutPadding:g,preservePaintedPanelRows:p,wrapMode:b})}),G?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1",children:(0,r.jsx)(ts,{worktreeId:a,cliToolId:s,instanceId:l,composerText:u.composerText,onActionSent:f})}):null,J?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1",children:(0,r.jsx)(tm,{cliToolId:s,frame:u.realtimeSnippet||u.output})}):null,u.isRunning?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1","data-testid":"mobile-quick-keys-slot",children:(0,r.jsx)(tx.XU,{worktreeId:a,cliToolId:s,instanceId:l,hasAgentSession:null!==x.session,onKeysSent:f,compact:!0,collapsible:!0,layout:"mobile"})}):null,$?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1 pb-2",children:(0,r.jsx)(tt.U,{worktreeId:a,cliToolId:s,instanceId:l,onKeysSent:f})}):null]})});var tF=n(83051);let tO={isOpen:!1,position:{x:0,y:0},targetPath:null,targetType:null};function tz(){let[e,t]=(0,i.useState)(tO),n=(0,i.useCallback)((e,n,a)=>{t({isOpen:!0,position:e,targetPath:n,targetType:a})},[]),a=(0,i.useCallback)((e,t,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}n({x:r,y:s},t,a)},[n]),r=(0,i.useCallback)(()=>{t(e=>({...e,isOpen:!1}))},[]),s=(0,i.useCallback)(()=>{t(tO)},[]);return(0,i.useEffect)(()=>{if(!e.isOpen)return;let t=()=>{r()},n=setTimeout(()=>{document.addEventListener("click",t)},0);return()=>{clearTimeout(n),document.removeEventListener("click",t)}},[e.isOpen,r]),(0,i.useEffect)(()=>{if(!e.isOpen)return;let t=e=>{"Escape"===e.key&&r()};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[e.isOpen,r]),{menuState:e,openMenu:a,openMenuAt:n,closeMenu:r,resetMenu:s}}var t_=n(47650),tB=n(7504),tV=n(22198),tU=n(21786),tW=n(26754),tH=n(71360),tK=n(9286);function t$(e,t,n){let a=n-t-8;return a<8?8:Math.min(Math.max(e,8),a)}let tq=(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:x,onMove:h,items:f,ariaLabel:g}=e,p=(0,c.c)("worktree"),b=(0,i.useRef)(null),{shouldRender:v,isExiting:y}=(0,tK.O)(t,ta.$B),j=f?f.map(e=>e.id).join(","):"builtin",w="".concat(n.x,":").concat(n.y,":").concat(s,":").concat(j),[k,N]=(0,i.useState)(null),C=(null==k?void 0:k.key)===w?k:null;(0,i.useLayoutEffect)(()=>{if(!t)return;let e=b.current;if(!e)return;let a=e.getBoundingClientRect();N({key:w,left:t$(n.x,a.width,window.innerWidth),top:t$(n.y,a.height,window.innerHeight)})},[t,w,n.x,n.y]);let S=(0,i.useCallback)(e=>{e&&a&&e(a),l()},[a,l]),I=[{id:"new-file",label:p("fileTree.newFile"),icon:(0,r.jsx)(tB.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(o),showFor:["directory"]},{id:"new-directory",label:p("fileTree.newDirectory"),icon:(0,r.jsx)(tV.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(d),showFor:["directory"]},{id:"upload",label:p("contextMenu.uploadFile"),icon:(0,r.jsx)(tU.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(x),showFor:["directory"],showDividerAfter:!0},{id:"rename",label:p("contextMenu.rename"),icon:(0,r.jsx)(eT.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(u)},{id:"move",label:p("contextMenu.move"),icon:(0,r.jsx)(tW.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>{h&&a&&s&&h(a,s),l()},showDividerAfter:!0},{id:"delete",label:p("contextMenu.delete"),icon:(0,r.jsx)(tH.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(m),variant:"danger"}],T=f?f.map(e=>{var t,n;return{id:e.id,label:e.label,icon:null!=(t=e.icon)?t:null,onClick:()=>{e.onSelect(),l()},variant:e.variant,showDividerAfter:e.showDividerAfter,disabled:null!=(n=e.disabled)&&n}}):I.filter(e=>!e.showFor||s&&e.showFor.includes(s));if((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=b.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&&b.current){let e=b.current.querySelector('[role="menuitem"]');e&&e.focus()}},[t]),!v)return null;let E=(0,r.jsx)("div",{ref:b,"data-testid":"context-menu",role:"menu","aria-label":null!=g?g:p("contextMenu.label"),className:"fixed min-w-[160px] py-1 bg-surface rounded-lg shadow-lg border border-border ".concat(y?"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:eE.M.CONTEXT_MENU,left:"".concat(C?C.left:0,"px"),top:"".concat(C?C.top:0,"px")},children:T.map((e,t)=>{var n;let s=null!=(n=e.disabled)?n:!a;return(0,r.jsxs)(i.Fragment,{children:[(0,r.jsxs)("button",{role:"menuitem","data-testid":"context-menu-".concat(e.id),onClick:e.onClick,disabled:s,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(s?"opacity-50 cursor-not-allowed":""),children:[e.icon,(0,r.jsx)("span",{children:e.label})]}),e.showDividerAfter&&t<T.length-1&&(0,r.jsx)("div",{"data-testid":"context-menu-divider",className:"my-1 border-t border-border"})]},e.id)})});return"undefined"==typeof document?E:(0,t_.createPortal)(E,document.body)});var tG=n(55813),tJ=n(30061);let tY="commandmate.worktree.fileMetadataDisplay",tQ={showSize:!0,showCreated:!1,showModified:!1},tX="commandmate:fileMetadataDisplayChange";function tZ(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 t0=(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"})})}),t1=(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"})})}),t2=(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,f.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))})}),t4=(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"})})}),t5=(0,i.memo)(function e(t){let{item:n,path:a,depth:s,worktreeId:l,expanded:o,cache:d,onToggle:m,onFileSelect:x,onLoadChildren:h,onContextMenu:f,searchQuery:g,searchMode:p,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y=tQ}=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,I=d.get(N),T=(0,i.useMemo)(()=>v?(0,tG.M)(v):void 0,[v]),E=(0,i.useMemo)(()=>{if(S)return;let e=[];if(void 0!==n.size&&e.push("".concat(j("fileTree.metadata.size"),": ").concat(tZ(n.size))),n.birthtime){let t=(0,Q.bg)(new Date(n.birthtime),T);t&&e.push("".concat(j("fileTree.metadata.created"),": ").concat(t))}if(n.mtime){let t=(0,Q.bg)(new Date(n.mtime),T);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,T,j]),A=(0,i.useCallback)(async()=>{S?(C||I||(k(!0),await h(N),k(!1)),m(N)):null==x||x(N)},[S,C,I,N,h,m,x]),M=(0,i.useCallback)(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),A())},[A]),R=(0,i.useCallback)(e=>{e.preventDefault(),null==f||f(e,N,S?"directory":"file")},[N,S,f]),L=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:A,onKeyDown:M,onContextMenu:R,onTouchStart:L.onTouchStart,onTouchMove:L.onTouchMove,onTouchEnd:L.onTouchEnd,onTouchCancel:L.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)(t0,{expanded:C})}):(0,r.jsx)("span",{className:"w-4 h-4"}),S?(0,r.jsx)(t1,{open:C}):(0,r.jsx)(t4,{extension:n.extension}),(0,r.jsx)(tJ.nR,{content:n.name,metadata:E,className:"flex-1 truncate text-sm text-foreground",children:"name"===p&&g?(0,r.jsx)(t2,{text:n.name,query:g}):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}):tZ(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,Q.fw)(n.birthtime,T)}),!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,Q.fw)(n.mtime,T)})]}),S&&C&&I&&(0,r.jsx)("div",{role:"group",children:I.filter(e=>{let t=N?"".concat(N,"/").concat(e.name):e.name;if(!(null==g?void 0:g.trim()))return!0;if("name"===p){let t=g.toLowerCase();return!!e.name.toLowerCase().includes(t)||"directory"===e.type}if("content"===p&&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:x,onLoadChildren:h,onContextMenu:f,searchQuery:g,searchMode:p,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y},t.name))})]})});var t3=n(26989);let t6=[{key:"showSize",labelKey:"fileTree.metadata.showSize"},{key:"showCreated",labelKey:"fileTree.metadata.showCreated"},{key:"showModified",labelKey:"fileTree.metadata.showModified"}];function t8(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 t9=(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}),[x,h]=(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,h(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:t8(n.left-u.current.x,n.width,window.innerWidth),y:t8(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)(t3.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!==x.x||0!==x.y?{transform:"translate(".concat(x.x,"px, ").concat(x.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")}),t6.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 t7(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 ne(e){return"commandmate:file-tree-expanded:"+e}function nt(e){try{let t=window.localStorage.getItem(ne(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 nn=n(89559),na=n(48314),nr=n(6132);let ns=(0,i.memo)(function(e){let{worktreeId:t,onFileSelect:n,onNewFile:a,onNewDirectory:s,onRename:l,onDelete:o,onUpload:d,onMove:u,className:x="",refreshTrigger:h=0,pollingEnabled:g=!1,searchQuery:p,searchMode:b,searchResults:v,onSearchResultSelect:y,onResetView:j}=e,w=(0,eH.Ym)(),k=(0,c.c)("worktree"),{settings:N,toggle:C}=function(){let[e,t]=(0,i.useState)(tQ),n=(0,i.useRef)(e);n.current=e,(0,i.useEffect)(()=>{t(function(){try{var e;let t=window.localStorage.getItem(tY);if(!t)return{...tQ};return e=JSON.parse(t),"object"!=typeof e||null===e?{...tQ}:{showSize:"boolean"==typeof e.showSize?e.showSize:tQ.showSize,showCreated:"boolean"==typeof e.showCreated?e.showCreated:tQ.showCreated,showModified:"boolean"==typeof e.showModified?e.showModified:tQ.showModified}}catch(e){return{...tQ}}}())},[]),(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(tX,e),()=>window.removeEventListener(tX,e)},[]);let a=(0,i.useCallback)(e=>{n.current=e,t(e);try{window.localStorage.setItem(tY,JSON.stringify(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(tX,{detail:{settings:e}}))}catch(e){}},[]);return{settings:e,toggle:(0,i.useCallback)(e=>{a({...n.current,[e]:!n.current[e]})},[a]),setSettings:a}}(),[S,I]=(0,i.useState)(!0),[T,E]=(0,i.useState)(null),[A,M]=(0,i.useState)([]),{expanded:R,setExpanded:L,resetExpanded:P}=function(e){let[t,n]=(0,i.useState)(()=>nt(e)),a=(0,i.useRef)(e);(0,i.useEffect)(()=>{a.current!==e&&(a.current=e,n(nt(e)))},[e]),(0,i.useEffect)(()=>{!function(e,t){try{let n=ne(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)(R);z.current=R;let _=(0,i.useRef)(k);_.current=k;let B=(0,i.useRef)(new Set),{menuState:V,openMenu:U,closeMenu:W}=tz(),H=(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){I(!0),E(null);try{let e=await H();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 H(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;M(e.items),F(n),a.length>0&&L(e=>{let t=new Set(e);for(let e of a)e&&t.delete(e);return t})}catch(e){K.current&&E(e instanceof Error?e.message:_.current("fileTree.loadError"))}finally{K.current&&I(!1)}}},[H,L]);(0,i.useEffect)(()=>{$()},[$,h]);let q=(0,i.useRef)(null),G=(0,i.useRef)(!1);(0,i.useEffect)(()=>{q.current=null},[t]),t7({intervalMs:5e3,enabled:g,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 H(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}}},[H,$])});let J=(0,i.useCallback)(async e=>{if(!(D.has(e)||B.current.has(e))){B.current.add(e);try{let t=await H(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,H]),Y=(0,i.useCallback)(e=>{L(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[L]),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,f.q3)(v.map(e=>e.filePath)):new Set,[b,v]);(0,i.useEffect)(()=>{X.size>0&&L(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,L]);let Z=(0,i.useMemo)(()=>{if(!(null==p?void 0:p.trim()))return A;if("name"===b){let e=p.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(A,"")}return"content"===b&&X.size>0?A.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}):A},[A,p,b,X,D]);if(S&&0===A.length)return(0,r.jsx)("div",{"data-testid":"file-tree-loading",className:"p-2 ".concat(x),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(T&&0===A.length)return(0,r.jsx)("div",{"data-testid":"file-tree-error",className:"p-4 bg-danger-subtle border border-danger-border rounded-lg ".concat(x),children:(0,r.jsx)("p",{className:"text-sm text-danger",children:T})});let ee=S&&A.length>0,et=!!T&&A.length>0;return 0===A.length?(0,r.jsxs)("div",{"data-testid":"file-tree-empty",className:"p-4 text-center text-muted-foreground ".concat(x),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)(tB.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)(tV.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newDirectory")})]})]})]}):(null==p?void 0:p.trim())&&0===Z.length?(0,r.jsx)("div",{"data-testid":"file-tree-no-results",className:"p-4 text-center text-muted-foreground ".concat(x),children:(0,r.jsx)("p",{className:"text-sm",children:k("content"===b?"fileTree.noResultsContaining":"fileTree.noResultsMatching",{query:p})})}):(0,r.jsxs)("div",{ref:O,"data-testid":"file-tree-view",role:"tree","aria-label":k("fileTree.label"),className:"overflow-auto bg-surface ".concat(x),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)(tB.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)(tV.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)(t9,{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)(nn.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)(na.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)(nr.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"flex-1 truncate",children:T}),(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)(t5,{item:e,path:"",depth:0,worktreeId:t,expanded:R,cache:D,onToggle:Y,onFileSelect:y||n,onLoadChildren:J,onContextMenu:U,searchQuery:p,searchMode:b,matchedPaths:X,dateFnsLocaleStr:w,metadataDisplay:N},e.name)),(0,r.jsx)(tq,{isOpen:V.isOpen,position:V.position,targetPath:V.targetPath,targetType:V.targetType,onClose:W,onNewFile:a,onNewDirectory:s,onRename:l,onDelete:o,onUpload:d,onMove:u})]})});var nl=n(38218);let ni=(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"})})}),no=(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"})})}),nc=(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")})}),nd=(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,x=(0,i.useRef)(null),h=(0,c.c)("worktree"),f=(0,i.useCallback)(e=>{l(e.target.value)},[l]),g=(0,i.useCallback)(()=>{var e;d(),null==(e=x.current)||e.focus()},[d]),p=(0,i.useCallback)(e=>{if("Escape"===e.key)if(t)g();else{var n;null==(n=x.current)||n.blur()}},[t,g]);return(0,i.useEffect)(()=>{if(!(window.innerWidth<nl.D)){let e=setTimeout(()=>{var e;null==(e=x.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)(ni,{})}),(0,r.jsx)("input",{ref:x,type:"text","data-testid":"search-input",value:t,onChange:f,onKeyDown:p,placeholder:null!=u?u:h("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":h("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)(nc,{}):t?(0,r.jsx)("button",{type:"button","data-testid":"search-clear",onClick:g,className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors","aria-label":h("search.clear"),children:(0,r.jsx)(no,{})}):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:h("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:h("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:h("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 nu(e){return 0===e.length?"0":e.map(e=>"".concat(e.id,":").concat(e.title.length,":").concat(e.content.length)).join("|")}var nm=n(12108),nx=n(54916),nh=n(60850);let nf=(0,i.memo)(function(e){var t,n;let{memo:a,onUpdate:s,onDelete:l,isSaving:o,error:d,className:u="",onInsertToMessage:m,onMoveUp:x,onMoveDown:h,canMoveUp:f=!0,canMoveDown:g=!0}=e,p=(0,c.c)("schedule"),b=(0,c.c)("worktree"),v=!!(x||h),[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:I,error:T,saveNow:E}=(0,nh.U)({value:y,saveFn:async e=>{await s(a.id,{title:e})}}),{isSaving:A,error:M,saveNow:R}=(0,nh.U)({value:w,saveFn:async e=>{await s(a.id,{content:e})}}),L=null!=(n=null!=(t=null!=d?d:null==T?void 0:T.message)?t:null==M?void 0:M.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)(()=>{E()},[E]),O=(0,i.useCallback)(()=>{R()},[R]),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,eN.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:p("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:I||A)&&(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:x,disabled:!f,"aria-label":p("memoMoveUp"),title:p("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)(nm.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button","data-testid":"memo-move-down-".concat(a.id),onClick:h,disabled:!g,"aria-label":p("memoMoveDown"),title:p("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)(W.A,{className:"w-4 h-4","aria-hidden":"true"})})]}),m&&(0,r.jsx)("button",{type:"button","data-testid":"insert-memo-content",onClick:_,"aria-label":p("memoInsertToMessage"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 transition-colors rounded",title:p("memoInsertToMessage"),children:(0,r.jsx)(nx.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:B,"aria-label":p("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)(eh.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{type:"button",onClick:z,"aria-label":p("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:p("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"}),L&&(0,r.jsx)("div",{className:"text-xs text-danger",children:L})]})}),ng=(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 np(e){let{query:t,onQueryChange:n,matchCount:a,currentIndex:s,onNext:l,onPrev:o,onClose:d,onCompositionStart:u,onCompositionEnd:x}=e,h=(0,c.c)("schedule"),f=(0,i.useRef)(null);(0,i.useEffect)(()=>{var e;null==(e=f.current)||e.focus()},[]);let g=(0,i.useCallback)(e=>{if("Escape"===e.key)return void d();"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),l())},[d,l]),p=(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":h("memoSearchLabel"),children:[(0,r.jsx)("input",{ref:f,type:"text",value:t,onChange:p,onKeyDown:g,onCompositionStart:u,onCompositionEnd:x,placeholder:h("memoSearchPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-foreground text-sm outline-none placeholder-muted-foreground","aria-label":h("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":h("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":h("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":h("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 nb=(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,eo.SC)(),[d,m]=(0,i.useState)([]),[x,h]=(0,i.useState)(!0),[f,g]=(0,i.useState)(!1),[p,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:I,setQuery:T,reset:E,navigateNext:A,navigatePrev:M,onCompositionStart:R,onCompositionEnd:L}=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)(nu(t)),x=(0,i.useRef)(t);x.current=t;let h=r.length,f=(0,i.useCallback)(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),g=(0,i.useCallback)(e=>{let t=function(e,t){if(t.length<eM.E2||0===e.length)return[];let n=t.toLowerCase();return e.filter(e=>-1!==e.title.toLowerCase().indexOf(n)||-1!==e.content.toLowerCase().indexOf(n))}(x.current,e);s(t),o(t.length>0?0:-1)},[]),p=(0,i.useCallback)(e=>{f(),d.current=e,u.current||(c.current=setTimeout(()=>{g(e)},eM.e1))},[f,g]),b=(0,i.useCallback)(e=>{a(e),p(e)},[p]),v=(0,i.useCallback)(()=>{a(""),d.current="",s([]),o(-1),f()},[f]),y=(0,i.useCallback)(()=>{o(e=>0===h?-1:(e+1)%h)},[h]),j=(0,i.useCallback)(()=>{o(e=>0===h?-1:(e-1+h)%h)},[h]),w=(0,i.useCallback)(()=>{u.current=!0,f()},[f]),k=(0,i.useCallback)(()=>{u.current=!1;let e=d.current;e.length>=eM.E2&&(f(),c.current=setTimeout(()=>{g(e)},eM.e1))},[f,g]);return(0,i.useEffect)(()=>{let e=nu(t);if(e===m.current)return;m.current=e;let n=d.current;n.length>=eM.E2&&g(n)},[t,g]),(0,i.useEffect)(()=>()=>{f(),d.current=""},[f]),{query:n,matches:r,currentMatch:l,totalCount:h,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()=>{h(!0),b(null);try{let e=await eG.$T.getAll(t);m(e.sort((e,t)=>e.position-t.position))}catch(e){b((0,eG.hS)(e))}finally{h(!1)}},[t]);(0,i.useEffect)(()=>{F()},[F]);let O=(0,i.useCallback)(async()=>{g(!0),y(null);try{let e=await eG.$T.create(t,{title:s("memoDefaultTitle"),content:""});m(t=>[...t,e])}catch(e){y((0,eG.hS)(e))}finally{g(!1)}},[t,s]),z=(0,i.useCallback)(async(e,n)=>{await eG.$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 eG.$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]),V=(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 eG.$T.reorder(t,r.map(e=>e.id))}catch(e){b((0,eG.hS)(e)),await F()}},[d,t,F]),U=(0,i.useCallback)(()=>{F()},[F]),W=(0,i.useCallback)(()=>{w(e=>(e&&E(),!e))},[E]),H=(0,i.useCallback)(()=>{w(!1),E()},[E]);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]),x)?(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")})]})}):p?(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:p}),(0,r.jsx)("button",{type:"button",onClick:U,"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)(np,{query:N,onQueryChange:T,matchCount:I,currentIndex:S,onNext:A,onPrev:M,onClose:H,onCompositionStart:R,onCompositionEnd:L})}):(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:W,"aria-label":s("memoSearchToggle"),className:"p-1.5 text-muted-foreground hover:text-foreground transition-colors rounded",children:(0,r.jsx)(_.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)(nf,{memo:e,onUpdate:z,onDelete:B,onInsertToMessage:a,onMoveUp:P?void 0:()=>V(t,-1),onMoveDown:P?void 0:()=>V(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)(ng,{currentCount:d.length,maxCount:20,onAdd:O,isLoading:f,className:"mt-2"})]})});var nv=n(85872),ny=n(53292),nj=n(53482);let nw={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"},nk=i.memo(function(e){let{worktreeId:t,className:n=""}=e,a=(0,c.c)("worktree"),s=(0,c.c)("common"),l=(0,eo.SC)(),[o,d]=(0,i.useState)([]),[u,m]=(0,i.useState)(""),[x,h]=(0,i.useState)(!0),[f,g]=(0,i.useState)(!1),[p,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),I=(0,i.useCallback)(e=>{switch(e){case"doing":return a("todo.statusDoing");case"done":return a("todo.statusDone");default:return a("todo.statusTodo")}},[a]),T=(0,i.useCallback)(async()=>{h(!0),b(null);try{let e=await nv.Ar.list(t);d(e)}catch(e){b(e instanceof Error?e.message:a("todo.loadError")),d([])}finally{h(!1)}},[t,a]);(0,i.useEffect)(()=>{T()},[t]);let E=(0,i.useCallback)(async()=>{let e=u.trim();if(e&&!f){g(!0),b(null);try{let n=await nv.Ar.create(t,e);d(e=>[...e,n]),m("")}catch(e){b(e instanceof Error?e.message:a("todo.addError"))}finally{g(!1)}}},[u,f,t,a]),A=(0,i.useCallback)(async e=>{let n=function(e){let t=nv.KG.indexOf(e);return nv.KG[(t+1)%nv.KG.length]}(e.status);d(t=>t.map(t=>t.id===e.id?{...t,status:n,done:"done"===n}:t)),b(null);try{await nv.Ar.update(t,e.id,{status:n})}catch(e){b(e instanceof Error?e.message:a("todo.updateError")),T()}},[t,T,a]),M=(0,i.useCallback)(async e=>{if(await l({description:s("confirmDelete",{name:e.content}),variant:"danger"})){b(null);try{await nv.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]),R=(0,i.useCallback)(e=>{y(e),w(e.content),N(e.detail),b(null)},[]),L=(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 nv.Ar.update(t,v.id,{content:e,detail:k});d(e=>e.map(e=>e.id===v.id?n:e)),L()}catch(e){b(e instanceof Error?e.message:a("todo.updateError")),S(!1)}}},[v,j,k,C,t,L,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 nv.Ar.reorder(t,s.map(e=>e.id))}catch(e){b(e instanceof Error?e.message:a("todo.reorderError")),T()}},[o,t,T,a]),F=(0,i.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),E())},[E]),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:ny.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:E,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:[I("todo")," ",O.todo]}),(0,r.jsxs)("span",{"data-testid":"todo-count-doing",children:[I("doing")," ",O.doing]}),(0,r.jsxs)("span",{"data-testid":"todo-count-done",children:[I("done")," ",O.done]})]}),p&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"todo-error",children:p}),x?(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:()=>A(e),"data-testid":"todo-status","data-status":e.status,"aria-label":a("todo.cycleStatus",{status:I(e.status)}),title:a("todo.cycleStatus",{status:I(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(nw[e.status]),children:I(e.status)}),(0,r.jsxs)("button",{type:"button",onClick:()=>R(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:()=>M(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)(e6.a,{isOpen:null!==v,onClose:L,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:ny.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)(nj.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:ny.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:L,"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 nN=n(95740),nC=n(66630);function nS(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,t_.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:eE.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)(eC.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 nI=["default","acceptEdits","plan","dontAsk","bypassPermissions"],nT=["read-only","workspace-write","danger-full-access"],nE=["allow-all-tools","yolo"],nA=["--dangerously-skip-permissions"],nM=["default","standard","plan","auto-accept","dont-ask"],nR="yolo",nL=[nR,...nM],nP=[],nD=[],nF=[],nO=[],nz={claude:"acceptEdits",codex:"workspace-write",gemini:"","vibe-local":"",opencode:"",copilot:"allow-all-tools",antigravity:"--dangerously-skip-permissions","command-code":nR};function n_(e){switch(e){case"claude":return nI;case"codex":return nT;case"copilot":return nE;case"antigravity":return nA;case"command-code":return nL;case"gemini":return nP;case"vibe-local":return nD;case"opencode":return nF;default:return nO}}let nB=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F\x80-\x9F\u200B-\u200F\u2028-\u202F\uFEFF]/;function nV(e){return e.replace(RegExp(nB.source,"g"),"")}let nU=/^[\w\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\uF900-\uFAFF\s-]{1,100}$/;function nW(e){if(e.length>100)return!1;let t=e.trim().split(/\s+/);return t.length>=5&&t.length<=6}var nH=n(3199);let nK=["edit_file","write_file","shell_command","monitor_command","kill_shell"];function n$(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}function nq(e,t){return"command-code"===e&&nM.includes(t.trim())}var nG=n(26020);let nJ={en:{bannerTitle:"CMATE.md has schedules to check",body:"With a --permission-mode value as Permission (default / standard / plan / auto-accept / dont-ask), command-code print mode (`commandcode -p`) rejects the write tools the agent calls directly (edit_file / write_file / shell_command / monitor_command / kill_shell). This is a warning and does not stop the schedule from being saved or run. Set Permission to `yolo` if the task needs to write."},ja:{bannerTitle:"CMATE.md に確認が必要なスケジュールがあります",body:"Permission が --permission-mode の値(default / standard / plan / auto-accept / dont-ask)のとき、command-code の print モード(`commandcode -p`)は、エージェントが直接呼ぶ書き込み系ツール(edit_file / write_file / shell_command / monitor_command / kill_shell)を拒否します。これは警告で、スケジュールの登録も実行も止めません。書き込みが必要な作業なら Permission を `yolo` にしてください。"}};function nY(e){return nJ[(0,nG.d9)(e)?e:nG.Xn]}let nQ=[{value:"0 */1 * * *",labelKey:"cronPresetHourly"},{value:"0 9 * * *",labelKey:"cronPresetDaily9"},{value:"0 9 * * 1",labelKey:"cronPresetWeeklyMon9"}],nX={name:"",cronExpression:"0 9 * * *",message:"",cliToolId:"claude",enabled:!0,permission:null!=(a=nz.claude)?a:"",model:"",agent:"",variant:"",continueSession:!1,title:""},nZ="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",n0="block text-xs font-semibold text-foreground mb-1",n1="mt-1 text-xs text-danger-foreground";function n2(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)(nN.A,{size:14,"aria-hidden":"true"}),n]})}function n4(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)(W.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 n5(e){var t,n;let{isOpen:a,worktreeId:s,initialValues:l,originalName:o,onInsertToMessage:d,instances:u,onClose:x,onSaved:h}=e,f=(0,c.c)("schedule"),g=(0,eH.Ym)(),p=(0,nl.a)(),b=(0,i.useMemo)(()=>u&&u.length>0?u:(0,$.lu)([...$.XH]),[u]),[v,y]=(0,i.useState)(nX),[j,w]=(0,i.useState)(""),[N,C]=(0,i.useState)(!1),[S,I]=(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,m,x,h,f;if(!a)return;I(null),C(!1);let g=null!=(t=null==l?void 0:l.cliToolId)?t:nX.cliToolId;y({name:null!=(n=null==l?void 0:l.name)?n:nX.name,cronExpression:null!=(r=null==l?void 0:l.cronExpression)?r:nX.cronExpression,message:null!=(s=null==l?void 0:l.message)?s:nX.message,cliToolId:g,enabled:null!=(i=null==l?void 0:l.enabled)?i:nX.enabled,permission:null!=(o=null==l?void 0:l.permission)?o:nX.permission,model:null!=(c=null==l?void 0:l.model)?c:nX.model,agent:null!=(d=null==l?void 0:l.agent)?d:nX.agent,variant:null!=(u=null==l?void 0:l.variant)?u:nX.variant,continueSession:null!=(m=null==l?void 0:l.continueSession)?m:nX.continueSession,title:null!=(x=null==l?void 0:l.title)?x:nX.title});let p=b.find(e=>e.cliTool===g);w(null!=(f=null!=(h=null==p?void 0:p.id)?h:null==(e=b[0])?void 0:e.id)?f:g)},[a,l,b]),(0,i.useEffect)(()=>{a&&E(new Set(p?["basic"]:["basic","advanced","message"]))},[a,p]);let A=(0,i.useCallback)(e=>{E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),M=n_(v.cliToolId),R=M.length>0,L=nq(v.cliToolId,v.permission),P=nH.Vt.has(v.cliToolId),D=nH.aN.has(v.cliToolId),F=!!o,O=(0,i.useMemo)(()=>{let e=v.name.trim();return e?e.length>100?f("edit.errorNameTooLong",{max:100}):nU.test(e)?null:f("edit.errorNameInvalid"):f("edit.errorNameRequired")},[v.name,f]),z=(0,i.useMemo)(()=>nW(v.cronExpression.trim())?null:f("edit.errorCronInvalid"),[v.cronExpression,f]),_=(0,i.useMemo)(()=>v.message.trim()?v.message.length>1e4?f("edit.errorMessageTooLong",{max:1e4}):null:f("edit.errorMessageRequired"),[v.message,f]),B=(0,i.useMemo)(()=>P&&v.model.trim()?(0,nH.JY)(v.model.trim()).valid?null:f("edit.errorModelInvalid"):null,[P,v.model,f]),V=(0,i.useMemo)(()=>D&&v.agent.trim()?(0,nH.sd)(v.agent.trim(),"agent").valid?null:f("edit.errorAgentInvalid"):null,[D,v.agent,f]),W=(0,i.useMemo)(()=>D&&v.variant.trim()?(0,nH.sd)(v.variant.trim(),"variant").valid?null:f("edit.errorVariantInvalid"):null,[D,v.variant,f]),H=(0,i.useMemo)(()=>D&&v.title.trim()?(0,nH.kj)(v.title.trim()).valid?null:f("edit.errorTitleInvalid"):null,[D,v.title,f]),K=!O&&!z&&!_&&!B&&!V&&!W&&!H,q=(0,i.useCallback)(e=>{y(t=>({...t,cliToolId:e,permission:function(e){let t=nz[e];if(void 0!==t)return t;let n=n_(e);return n.length>0?n[0]:""}(e),model:nH.Vt.has(e)?t.model:"",agent:nH.aN.has(e)?t.agent:"",variant:nH.aN.has(e)?t.variant:"",continueSession:!!nH.aN.has(e)&&t.continueSession,title:nH.aN.has(e)?t.title:""}))},[]),G=(0,i.useCallback)(e=>{let t=b.find(t=>t.id===e);t&&(w(e),q(t.cliTool))},[b,q]),J=nQ.some(e=>e.value===v.cronExpression)?v.cronExpression:"custom",Y=(0,i.useCallback)(e=>{"custom"!==e&&y(t=>({...t,cronExpression:e}))},[]),Q=(0,i.useCallback)(e=>{null==d||d(e),x()},[d,x]),X=(0,i.useCallback)(async()=>{if(K&&!N){C(!0),I(null);try{let e=await fetch("/api/worktrees/".concat(s,"/cmate/schedules"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v.name.trim(),cronExpression:v.cronExpression.trim(),message:v.message.trim(),cliToolId:v.cliToolId,enabled:v.enabled,permission:R?v.permission:"",model:P&&v.model.trim()?v.model.trim():void 0,agent:D&&v.agent.trim()?v.agent.trim():void 0,variant:D&&v.variant.trim()?v.variant.trim():void 0,continueSession:!!D&&!!v.continueSession||void 0,title:D&&v.title.trim()?v.title.trim():void 0,originalName:null!=o?o:void 0})});if(!e.ok){let t=await e.json().catch(()=>({}));I(t.error||f("edit.saveError"));return}h(),x()}catch(e){I(f("edit.saveError"))}finally{C(!1)}}},[K,N,s,v,R,P,D,o,h,x,f]),Z=null!=(n=null==(t=b.find(e=>e.id===j))?void 0:t.alias)?n:(0,$.f_)(v.cliToolId),ee=v.name.trim()?"".concat(v.name.trim()," \xb7 ").concat(v.cronExpression):v.cronExpression,et=[Z,R?v.permission:null,P&&v.model.trim()?v.model.trim():null,D&&v.agent.trim()?"--agent ".concat(v.agent.trim()):null,D&&v.variant.trim()?"--variant ".concat(v.variant.trim()):null,D&&v.continueSession?"--continue":null].filter(Boolean).join(" \xb7 "),en=v.message.trim(),ea=en.length>32?"".concat(en.slice(0,32),"…"):en,er=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:n0,htmlFor:"schedule-name-input",children:f("edit.name")}),(0,r.jsx)("input",{id:"schedule-name-input","data-testid":"schedule-name-input",type:"text",value:v.name,maxLength:100,placeholder:f("edit.namePlaceholder"),onChange:e=>y(t=>({...t,name:e.target.value})),className:nZ}),O&&(0,r.jsx)("p",{className:n1,"data-testid":"schedule-name-error",children:O})]}),(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)(n2,{testId:"schedule-cron-ask-ai",label:f("edit.askAiCron"),title:f("edit.askAiHint"),onClick:()=>Q(function(e,t){let n=t.trim();return 0===n.length?e("edit.aiPrompts.cron"):e("edit.aiPrompts.cronRefine",{current:"`"+n+"`"})}(f,v.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:v.cronExpression,placeholder:f("edit.cronPlaceholder"),onChange:e=>y(t=>({...t,cronExpression:e.target.value})),className:"".concat(nZ," font-mono sm:flex-1")}),(0,r.jsxs)("select",{"data-testid":"schedule-cron-preset","aria-label":f("edit.cronPreset"),value:J,onChange:e=>Y(e.target.value),className:"".concat(nZ," sm:w-48"),children:[nQ.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")})]})]}),z&&(0,r.jsx)("p",{className:n1,"data-testid":"schedule-cron-error",children:z})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)(m.Sc,{"data-testid":"schedule-enabled-toggle",checked:v.enabled,onCheckedChange:e=>y(t=>({...t,enabled:!0===e}))}),(0,r.jsx)("span",{className:"text-sm text-foreground",children:f("edit.enabledLabel")})]})]}),es=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:n0,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:j,onChange:e=>G(e.target.value),className:nZ,children:b.map(e=>(0,r.jsx)("option",{value:e.id,children:e.alias},e.id))})]}),P&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:n0,htmlFor:"schedule-model-input",children:f("edit.model")}),(0,r.jsx)("input",{id:"schedule-model-input","data-testid":"schedule-model-input",type:"text",value:v.model,placeholder:f("edit.modelPlaceholder"),onChange:e=>y(t=>({...t,model:e.target.value})),className:nZ}),B&&(0,r.jsx)("p",{className:n1,"data-testid":"schedule-model-error",children:B})]}),D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:n0,htmlFor:"schedule-agent-input",children:f("edit.opencodeAgent")}),(0,r.jsx)("input",{id:"schedule-agent-input","data-testid":"schedule-agent-input",type:"text",value:v.agent,placeholder:f("edit.opencodeAgentPlaceholder"),onChange:e=>y(t=>({...t,agent:e.target.value})),className:nZ}),V&&(0,r.jsx)("p",{className:n1,"data-testid":"schedule-agent-error",children:V})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:n0,htmlFor:"schedule-variant-input",children:f("edit.opencodeVariant")}),(0,r.jsx)("input",{id:"schedule-variant-input","data-testid":"schedule-variant-input",type:"text",value:v.variant,placeholder:f("edit.opencodeVariantPlaceholder"),onChange:e=>y(t=>({...t,variant:e.target.value})),className:nZ}),W&&(0,r.jsx)("p",{className:n1,"data-testid":"schedule-variant-error",children:W})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:n0,htmlFor:"schedule-title-input",children:f("edit.opencodeTitle")}),(0,r.jsx)("input",{id:"schedule-title-input","data-testid":"schedule-title-input",type:"text",value:v.title,placeholder:f("edit.opencodeTitlePlaceholder"),onChange:e=>y(t=>({...t,title:e.target.value})),className:nZ}),H&&(0,r.jsx)("p",{className:n1,"data-testid":"schedule-title-error",children:H})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)(m.Sc,{"data-testid":"schedule-continue-toggle",checked:v.continueSession,onCheckedChange:e=>y(t=>({...t,continueSession:!0===e}))}),(0,r.jsx)("span",{className:"text-sm text-foreground",children:f("edit.opencodeContinue")})]})]}),R&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:n0,htmlFor:"schedule-permission-select",children:f("edit.permission")}),(0,r.jsx)("select",{id:"schedule-permission-select","data-testid":"schedule-permission-select",value:v.permission,onChange:e=>y(t=>({...t,permission:e.target.value})),className:nZ,children:M.map(e=>(0,r.jsx)("option",{value:e,children:e},e))}),L&&(0,r.jsx)("p",{className:"mt-1 text-xs text-warning-foreground","data-testid":"schedule-permission-write-tools-denied-note",children:nY(g).body})]})]}),el=(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)(n2,{testId:"schedule-message-ask-ai",label:f("edit.askAiMessage"),title:f("edit.askAiHint"),onClick:()=>Q(function(e,t){let n=t.trim();return 0===n.length?e("edit.aiPrompts.messageDraft"):e("edit.aiPrompts.messageDraftNamed",{name:"`"+n+"`"})}(f,v.name))})]}),(0,r.jsx)("textarea",{id:"schedule-message-input","data-testid":"schedule-message-input",value:v.message,rows:4,maxLength:1e4,placeholder:f("edit.messagePlaceholder"),onChange:e=>y(t=>({...t,message:e.target.value})),className:"".concat(nZ," resize-none")}),(0,r.jsxs)("div",{className:"mt-1 flex items-center justify-between",children:[_?(0,r.jsx)("p",{className:n1,"data-testid":"schedule-message-error",children:_}):(0,r.jsx)("span",{}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"schedule-message-count",children:f("edit.charCount",{count:v.message.length,max:1e4})})]})]}),ei=(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)(n4,{id:"basic",title:f("edit.sectionBasic"),summary:ee,icon:(0,r.jsx)(k.A,{className:"w-4 h-4"}),isOpen:T.has("basic"),onToggle:A,children:er}),(0,r.jsx)(n4,{id:"advanced",title:f("edit.sectionAdvanced"),summary:et,icon:(0,r.jsx)(nC.A,{className:"w-4 h-4"}),isOpen:T.has("advanced"),onToggle:A,children:es}),(0,r.jsx)(n4,{id:"message",title:f("edit.sectionMessage"),summary:ea,icon:(0,r.jsx)(U.A,{className:"w-4 h-4"}),isOpen:T.has("message"),onToggle:A,children:el}),S&&(0,r.jsx)("div",{className:"text-xs p-2 rounded bg-danger-subtle text-danger-foreground","data-testid":"schedule-submit-error",children:S})]}),eo=(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:x,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 X(),disabled:!K||N,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")})]}),ec=F?f("edit.titleEdit"):f("edit.titleCreate");return p?(0,r.jsx)(nS,{isOpen:a,onClose:x,title:ec,footer:eo,children:ei}):(0,r.jsx)(e6.a,{isOpen:a,onClose:x,title:ec,size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[ei,(0,r.jsx)("div",{className:"pt-2 border-t border-border",children:eo})]})})}function n3(e){return new Date(e).toLocaleString()}function n6(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 n8=(0,i.memo)(function(e){let{worktreeId:t}=e,n=(0,eH.Ym)(),[a,s]=(0,i.useState)([]);if((0,i.useEffect)(()=>{let e=!1,n=t=>{e||s(e=>0===e.length&&0===t.length?e:t)};return(async()=>{try{var e;let a=await fetch("/api/worktrees/".concat(t,"/files/CMATE.md")),r=a.ok?await a.json():null,s="string"==typeof(null==r?void 0:r.content)?r.content:"";n(function(e){let t=[],n=0;for(let r=0;r<e.length;r++){var a;let s=e[r],l=function(e){let t=[];for(let n=0;n<e.length;n++){let a=e[n];if(a.length<3){t.push({row:n,message:"Row ".concat(n+1,": insufficient columns (need at least 3, got ").concat(a.length,")"),field:"columns"});continue}let[r,s,l]=a,i=nV(r);nU.test(i)||t.push({row:n,message:"Row ".concat(n+1,': invalid name "').concat(i,'"'),field:"name"}),nW(s)||t.push({row:n,message:"Row ".concat(n+1,': invalid cron "').concat(s,'"'),field:"cron"}),nV(l).trim()||t.push({row:n,message:"Row ".concat(n+1,": empty message"),field:"message"});let{result:o,errors:c}=(0,nH.zK)(a[3]||"");for(let e of c)t.push({row:n,message:"Row ".concat(n+1,": ").concat(e),field:e.includes("Model")?"model":"cliTool"});o&&!(0,$.hR)(o.cliToolId)&&t.push({row:n,message:"Row ".concat(n+1,': unknown CLI Tool "').concat(o.cliToolId,'"'),field:"cliTool"});let d=a[5];if(void 0!==d&&""!==d.trim()){let e=d.trim(),a=o.cliToolId;("claude"===a?nI:"codex"===a?nT:"copilot"===a?nE:"antigravity"===a?nA:"command-code"===a?nL:[]).includes(e)||t.push({row:n,message:"Row ".concat(n+1,': invalid permission "').concat(e,'" for ').concat(a),field:"permission"})}}return t}([s]);if(l.some(e=>"permission"!==e.field))continue;if(n>=100)break;if(n++,l.length>0)continue;let[i,,,o,c,d]=s;if(a=c,void 0!==a&&""!==a&&"true"!==a.toLowerCase())continue;let{result:u}=(0,nH.zK)(o||""),m=(null!=d?d:"").trim();if(!nq(u.cliToolId,m))continue;let x=nV(i);t.push({row:r,name:x,field:"permission",code:"command-code-direct-write-tools-denied",cliToolId:u.cliToolId,permission:m,message:"Row ".concat(r+1,': schedule "').concat(x,'" runs command-code with the --permission-mode value "').concat(m,'", ')+"so commandcode -p rejects the write tools the agent calls directly "+"(".concat(nK.join(", "),"). ")+'This is a warning, not an error: the schedule still runs. Use "yolo" if it needs to write.'})}return t}(null!=(e=n$(s).get("Schedules"))?e:[]))}catch(e){n([])}})(),()=>{e=!0}},[t]),0===a.length)return null;let l=nY(n);return(0,r.jsxs)("div",{role:"status","data-testid":"schedule-config-warnings",className:"rounded border border-warning-border bg-warning-subtle p-3 text-warning-foreground",children:[(0,r.jsx)("p",{className:"text-sm font-semibold",children:l.bannerTitle}),(0,r.jsx)("ul",{className:"mt-1 space-y-1",children:a.map(e=>(0,r.jsxs)("li",{"data-testid":"schedule-config-warning-".concat(e.name),"data-warning-code":e.code,className:"text-xs",children:[(0,r.jsx)("span",{className:"font-medium",children:e.name}),(0,r.jsxs)("span",{className:"ml-2 font-mono",children:[e.cliToolId," / ",e.permission]})]},"".concat(e.row,"-").concat(e.name)))}),(0,r.jsx)("p",{className:"mt-2 text-xs",children:l.body})]})}),n9=(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]),m=(0,r.jsx)(n8,{worktreeId:t});return 0===n.length?(0,r.jsxs)("div",{className:"space-y-2",children:[m,(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:a("noLogs")})]}):(0,r.jsxs)("div",{className:"space-y-2","data-testid":"execution-logs-view",children:[m,n.map(e=>(0,r.jsxs)("div",{className:"border border-border rounded bg-surface","data-testid":"execution-log-row","data-warning":e.warning?"true":void 0,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.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded ".concat(function(e,t){if(t&&"completed"===e)return"text-warning-foreground bg-warning-subtle";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,!!e.warning)),"data-testid":"execution-log-status",children:[e.warning&&(0,r.jsx)("span",{"aria-hidden":"true",children:"⚠ "}),a("status.".concat(e.status))]})]}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[n3(e.started_at),n6(e.started_at,e.completed_at)&&(0,r.jsxs)("span",{className:"ml-2",children:["(",n6(e.started_at,e.completed_at),")"]}),null!==e.exit_code&&(0,r.jsxs)("span",{className:"ml-2",children:[a("exitCode"),": ",e.exit_code]})]}),e.warning&&(0,r.jsxs)("div",{className:"text-xs text-warning-foreground mt-1 break-words","data-testid":"execution-log-warning",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"⚠ "}),e.warning]})]}),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 n7(){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 at=(0,i.memo)(function(e){let{worktreeId:t,className:n="",onInsertToMessage:a,instances:s}=e,l=(0,c.c)("schedule"),o=(0,eo.SC)(),[d,u]=(0,i.useState)([]),[x,h]=(0,i.useState)([]),[f,g]=(0,i.useState)([]),[p,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),[I,T]=(0,i.useState)(void 0),[E,A]=(0,i.useState)(void 0),M=(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();h(e.schedules||[])}if(a.ok){let e=await a.json();g(e.schedules||[])}else g([])}catch(e){y(e instanceof Error?e.message:"Failed to fetch data")}finally{b(!1)}},[t]);(0,i.useEffect)(()=>{M()},[M]);let R=(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=n$(u).get("Schedules"))?n:[]).find(t=>{var n;return(null!=(n=t[0])?n:"").trim()===e});if(!m)return null;let x=(0,nH.I_)(null!=(a=m[3])?a:"claude"),h=(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:x.cliToolId||"claude",enabled:""===h||"true"===h,permission:(null!=(i=m[5])?i:"").trim(),model:null!=(o=x.model)?o:""}}catch(e){return null}},[t]),L=(0,i.useCallback)(()=>{A(void 0),T(void 0),S(!0)},[]),P=(0,i.useCallback)(async e=>{let t=await R(e.name);A(e.name),T(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)},[R]),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 M()}catch(e){console.error("Failed to delete schedule:",e)}},[t,l,M,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 M()}catch(e){console.error("Failed to toggle schedule:",e)}},[t,M]);return p?(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 M(),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")," (",x.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"),": ",n3(e.nextRunAt)]})]})]},e.scheduleId))})]}),0===x.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:L,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:L,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:x.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)(n7,{})}),(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"),": ",n3(e.last_executed_at)]})]})]},e.id)})})]})]}):(0,r.jsx)(n9,{worktreeId:t,logs:d})}),(0,r.jsx)(n5,{isOpen:C,worktreeId:t,initialValues:I,originalName:E,onInsertToMessage:a,instances:s,onClose:()=>S(!1),onSaved:()=>{M()}})]})}),an=(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)([]),[x,h]=(0,i.useState)(null),[f,g]=(0,i.useState)(!1),[p,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 g(!0),fetch("/api/ollama/models").then(e=>e.json()).then(t=>{e||(m(t.models),h(0===t.models.length&&t.error?t.error:null))}).catch(()=>{e||(m([]),h("Failed to fetch models"))}).finally(()=>{e||g(!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")]}):x&&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:p,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:$.vz,max:$.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=Object.freeze({agent:null,providerId:null,modelId:null,variant:null}),ar=[{id:"opencode",label:(0,$.oo)("opencode")}];function as(e){let t=e.indexOf("/");return t<=0||t===e.length-1?null:{providerId:e.slice(0,t),modelId:e.slice(t+1)}}let al=(0,i.memo)(function(e){let{worktreeId:t,instances:n}=e,a=(0,c.c)("schedule"),[s,l]=(0,i.useState)({}),[o,d]=(0,i.useState)({connected:!1,providers:[],agents:[]}),[u,x]=(0,i.useState)(!0),[h,f]=(0,i.useState)(!1),[g,p]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!1;return x(!0),fetch("/api/worktrees/".concat(t,"/instances/opencode")).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(t=>{var n,a;e||(l(null!=(n=t.settings)?n:{}),d(null!=(a=t.catalog)?a:{connected:!1,providers:[],agents:[]}),p(null))}).catch(()=>{e||p(a("opencodeSettingsLoadError"))}).finally(()=>{e||x(!1)}),()=>{e=!0}},[t,a]);let b=(0,i.useCallback)(async(e,n)=>{l(t=>({...t,[e]:n})),f(!0),p(null);try{let r=await fetch("/api/worktrees/".concat(t,"/instances/opencode"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({instanceId:e,...n})});if(!r.ok)return void p(a("opencodeSettingsSaveError"));let s=await r.json();s.settings&&l(t=>({...t,[e]:s.settings}))}catch(e){p(a("opencodeSettingsSaveError"))}finally{f(!1)}},[t,a]);return(0,r.jsxs)("div",{className:"mt-4 pt-4 border-t border-border","data-testid":"opencode-instance-settings",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-1",children:a("opencodeSettings")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:a("opencodeSettingsDescription")}),u?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(m.y$,{size:"xs",variant:"muted"}),a("loading")]}):(0,r.jsxs)("div",{className:"space-y-4",children:[!o.connected&&(0,r.jsx)("p",{"data-testid":"opencode-settings-offline",className:"text-xs text-muted-foreground",children:a("opencodeSettingsOffline")}),n.map(e=>{var t,l,i,c,d,u;let m=null!=(t=s[e.id])?t:{...aa},x=m.providerId&&m.modelId?"".concat(m.providerId,"/").concat(m.modelId):"",f=function(e,t){var n;if(!t.providerId||!t.modelId)return null;let a=e.providers.find(e=>e.id===t.providerId);return null!=(n=null==a?void 0:a.models.find(e=>e.id===t.modelId))?n:null}(o,m),g=null!=(l=null==f?void 0:f.variants)?l:[],p=o.agents.filter(e=>"primary"===e.mode);return(0,r.jsxs)("div",{className:"space-y-2",children:[n.length>1&&(0,r.jsx)("p",{className:"text-xs font-medium text-foreground",children:e.label}),(0,r.jsxs)("label",{className:"block text-xs text-muted-foreground",children:[a("opencodeAgent"),p.length>0?(0,r.jsxs)("select",{"data-testid":"opencode-agent-select-".concat(e.id),value:null!=(i=m.agent)?i:"",disabled:h,onChange:t=>void b(e.id,{...m,agent:""===t.target.value?null:t.target.value}),className:"mt-1 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:a("opencodeDefault")}),p.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))]}):(0,r.jsx)("input",{type:"text","data-testid":"opencode-agent-input-".concat(e.id),defaultValue:null!=(c=m.agent)?c:"",disabled:h,placeholder:a("opencodeAgentPlaceholder"),onBlur:t=>void b(e.id,{...m,agent:""===t.target.value.trim()?null:t.target.value.trim()}),className:"mt-1 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"})]}),(0,r.jsxs)("label",{className:"block text-xs text-muted-foreground",children:[a("opencodeModel"),o.providers.length>0?(0,r.jsxs)("select",{"data-testid":"opencode-model-select-".concat(e.id),value:x,disabled:h,onChange:t=>{var n,a;let r=as(t.target.value);b(e.id,{...m,providerId:null!=(n=null==r?void 0:r.providerId)?n:null,modelId:null!=(a=null==r?void 0:r.modelId)?a:null,variant:null})},className:"mt-1 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:a("opencodeDefault")}),o.providers.map(e=>(0,r.jsx)("optgroup",{label:e.name,children:e.models.map(t=>(0,r.jsx)("option",{value:"".concat(e.id,"/").concat(t.id),children:t.name},t.id))},e.id))]}):(0,r.jsx)("input",{type:"text","data-testid":"opencode-model-input-".concat(e.id),defaultValue:x,disabled:h,placeholder:a("opencodeModelPlaceholder"),onBlur:t=>{var n,a;let r=as(t.target.value.trim());b(e.id,{...m,providerId:null!=(n=null==r?void 0:r.providerId)?n:null,modelId:null!=(a=null==r?void 0:r.modelId)?a:null})},className:"mt-1 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"})]}),(0,r.jsxs)("label",{className:"block text-xs text-muted-foreground",children:[a("opencodeVariant"),g.length>0?(0,r.jsxs)("select",{"data-testid":"opencode-variant-select-".concat(e.id),value:null!=(d=m.variant)?d:"",disabled:h,onChange:t=>void b(e.id,{...m,variant:""===t.target.value?null:t.target.value}),className:"mt-1 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:a("opencodeDefault")}),g.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}):(0,r.jsx)("input",{type:"text","data-testid":"opencode-variant-input-".concat(e.id),defaultValue:null!=(u=m.variant)?u:"",disabled:h,placeholder:a("opencodeVariantPlaceholder"),onBlur:t=>void b(e.id,{...m,variant:""===t.target.value.trim()?null:t.target.value.trim()}),className:"mt-1 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"})]}),f&&0===g.length&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a("opencodeNoVariants")})]},e.id)}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a("opencodeVariantLaunchNote")}),h&&(0,r.jsxs)("div",{"data-testid":"opencode-settings-loading",className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(m.y$,{size:"xs",variant:"muted"}),a("loading")]}),g&&(0,r.jsx)("p",{"data-testid":"opencode-settings-error",className:"text-xs text-danger-foreground",children:g})]})]})}),ai=(0,i.memo)(function(e){let{worktreeId:t,selectedAgents:n,onSelectedAgentsChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d,maxAgents:u=2,availableAgents:x=$.XH,persistToServer:h=!0}=e,f=(0,c.c)("schedule"),g=n.length>u?n.slice(0,u):n,[p,b]=(0,i.useState)(()=>new Set(g)),[v,y]=(0,i.useState)(!1),[j,w]=(0,i.useState)(!1),k=(0,i.useRef)(p);k.current=p,(0,i.useEffect)(()=>{j||b(new Set(g))},[n,j,u]);let N=p.has("vibe-local"),C=p.has("opencode"),S=(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(!h){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(g))}catch(e){b(new Set(g))}finally{y(!1),w(!1)}}},[t,g,a,h]),I=p.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:x.map(e=>{let t=p.has(e),n=!t&&I;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,$.oo)(e),checked:t,disabled:n||v,onCheckedChange:t=>S(e,!0===t)}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:(0,$.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")]}),C&&(0,r.jsx)(al,{worktreeId:t,instances:ar}),N&&(0,r.jsx)(an,{worktreeId:t,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d})]})});function ao(e){return"".concat("commandmate:worktree:mobileInstances:").concat(e)}function ac(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 ad=n(49476),au=n(52056),am=n(65506),ax=n(7620),ah=n(50803),af=n(20017),ag=n(18085),ap=n(6191),ab=n(27937),av=n(41108),ay=n(95342),aj=n(63001),aw=n(55449);let ak="/api/worktrees/apply-default-agents";var aN=n(18848);let aC=["noteInstanceFlag","noteWaitOnPrompt","noteRespondNumber"];function aS(e){let{worktreeId:t,instance:n,isOpen:a,onClose:s}=e,l=(0,c.c)("worktree"),[o,d]=(0,i.useState)(!1),[m,x]=(0,i.useState)(!1),[h,f]=(0,i.useState)(null),[g,p]=(0,i.useState)(null),[b,v]=(0,i.useState)(null),[y,j]=(0,i.useState)(!1),[w,k]=(0,i.useState)(0);(0,i.useEffect)(()=>{if(!a)return;let e=!1;return d(!0),x(!1),v(null),j(!1),(async()=>{try{let[a,r]=await Promise.all([fetch("/api/worktrees/".concat(t,"/cli-reference")),fetch("/api/worktrees/".concat(t,"/resolve-target?instance=").concat(encodeURIComponent(n.id)))]);if(e)return;if(!a.ok||!r.ok)return void x(!0);let[s,l]=await Promise.all([a.json(),r.json()]);if(e)return;f(s),p(l)}catch(t){e||x(!0)}finally{e||d(!1)}})(),()=>{e=!0}},[a,t,n.id,w]);let N=h&&g?(0,aN.kj)({binary:h.binary,worktreeId:h.worktreeId,instanceId:g.instanceId,portPrefix:h.portPrefix,messagePlaceholder:l("cliCommands.messagePlaceholder")}):null,C=(0,i.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(t),v(e),j(!1)}catch(e){console.error("[InstanceCliCommandsModal] clipboard write failed:",e),v(null),j(!0)}},[]);return(0,r.jsx)(e6.a,{isOpen:a,onClose:s,size:"md",title:l("cliCommands.title",{alias:n.alias}),children:(0,r.jsxs)("div",{className:"space-y-4","data-testid":"cli-commands-panel-".concat(n.id),children:[o&&(0,r.jsxs)("div",{"data-testid":"cli-commands-loading",className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(u.y,{size:"xs",variant:"muted"}),l("cliCommands.loading")]}),m&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{"data-testid":"cli-commands-error",className:"text-xs text-danger-foreground",children:l("cliCommands.loadError")}),(0,r.jsx)("button",{type:"button","data-testid":"cli-commands-retry",onClick:()=>k(e=>e+1),className:"text-xs font-medium px-2 py-1 rounded-md border border-input text-foreground hover:bg-muted",children:l("cliCommands.retry")})]}),N&&g&&h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{"data-testid":"cli-commands-target",className:"text-xs text-muted-foreground break-words",children:l("cliCommands.target",{instance:g.instanceId,tool:(0,$.oo)(g.cliToolId),stage:l("cliCommands.resolvedBy.".concat(g.resolvedBy))})}),g.conflict&&(0,r.jsxs)("p",{"data-testid":"cli-commands-conflict",className:"flex items-start gap-1 text-xs text-warning",children:[(0,r.jsx)(au.A,{className:"w-3 h-3 mt-0.5 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:l("cliCommands.conflict",{instance:g.conflict.instanceId,roster:(0,$.oo)(g.conflict.rosterCliTool),requested:(0,$.oo)(g.conflict.requestedCliTool)})})]}),(0,r.jsx)("ul",{className:"space-y-3",children:aN.wx.map(e=>(0,r.jsxs)("li",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:l("cliCommands.commandLabel.".concat(e))}),(0,r.jsxs)("button",{type:"button","data-testid":"cli-commands-copy-".concat(e),"aria-label":l("cliCommands.copy"),title:l("cliCommands.copy"),onClick:()=>void C(e,N[e]),className:"flex items-center gap-1 shrink-0 text-xs px-2 py-1 rounded-md border border-input text-muted-foreground hover:text-foreground hover:bg-muted",children:[b===e?(0,r.jsx)(ex.A,{className:"w-3 h-3","aria-hidden":"true"}):(0,r.jsx)(eh.A,{className:"w-3 h-3","aria-hidden":"true"}),b===e?l("cliCommands.copied"):l("cliCommands.copy")]})]}),(0,r.jsx)("code",{"data-testid":"cli-commands-command-".concat(e),className:"block whitespace-pre-wrap break-all rounded-md bg-terminal-surface px-2 py-1.5 font-mono text-xs text-terminal-foreground",children:N[e]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:l("cliCommands.commandDescription.".concat(e))})]},e))}),y&&(0,r.jsx)("p",{"data-testid":"cli-commands-copy-error",className:"text-xs text-danger-foreground",children:l("cliCommands.copyFailed")}),null!==h.portPrefix&&(0,r.jsx)("p",{"data-testid":"cli-commands-port-hint",className:"text-xs text-muted-foreground",children:l("cliCommands.portHint",{port:h.portPrefix})}),(0,r.jsxs)("div",{className:"rounded-md border border-border bg-surface-2 p-3",children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-foreground",children:l("cliCommands.notesTitle")}),(0,r.jsx)("ul",{className:"mt-1 space-y-1",children:aC.map(e=>(0,r.jsx)("li",{"data-testid":"cli-commands-".concat(e),className:"text-xs text-muted-foreground",children:l("cliCommands.".concat(e))},e))})]})]})]})})}var aI=n(46022),aT=n(45573);function aE(e){return"prompt"===e.tone?"text-warning":"text-muted-foreground"}let aA=(0,i.memo)(function(e){var t;let{worktreeId:n,instances:a,onInstancesChange:s,vibeLocalModel:l,onVibeLocalModelChange:o,vibeLocalContextWindow:d,onVibeLocalContextWindowChange:m,modelByInstance:x,sourceByInstance:h,composerTargetInstanceId:f,className:g=""}=e,p=(0,c.c)("schedule"),b=(0,eH.Ym)(),{showToast:v}=(0,eq.dj)(),y=(0,c.c)("common"),j=(0,c.c)("worktree"),w=(0,eo.SC)(),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(null),[I,T]=(0,i.useState)({}),[E,A]=(0,i.useState)($.XH[0]),[M,R]=(0,i.useState)(null),[L,P]=(0,i.useState)(!1),[D,F]=(0,i.useState)(!1),[O,z]=(0,i.useState)(null),_=(0,i.useCallback)(async e=>{let t=aT.yW["ja"===b?"ja":"en"];if((null!=f?f:(0,aT.xk)())===e.id)return void v(t.self,"info");let a=await (0,aT.P0)(n,e,b);if(null===a)return void v(t.failed,"error");let r=(0,aT.oQ)(a);v(r?t.inserted:t.noComposer,r?"success":"error")},[f,b,v,n]),B=function(e,t,n){let[a,r]=(0,i.useState)({}),s=t.some(e=>"opencode"===e.cliTool);return(0,i.useEffect)(()=>{if(n)return;if(!s)return void r({});let t=!1,a=async()=>{try{var n;let a=await fetch("/api/worktrees/".concat(e));if(!a.ok)return;let s=await a.json();if(t)return;let l={};for(let[e,t]of Object.entries(null!=(n=s.sessionStatusByInstance)?n:{}))(null==t?void 0:t.eventSource)&&(l[e]=t.eventSource);r(l)}catch(e){}};a();let l=setInterval(()=>void a(),1e4);return()=>{t=!0,clearInterval(l)}},[e,s,n]),null!=n?n:a}(n,a,h),V=(0,av.UI)(n),U=(0,i.useCallback)(e=>{var t,r;return e.worktreeId!==n?"".concat(e.instanceId," @ ").concat(e.worktreeId):null!=(r=null==(t=a.find(t=>t.id===e.instanceId))?void 0:t.alias)?r:e.instanceId},[a,n]),H=a.length>=$.Ab,K=a.length<=1,q=a.some(e=>"vibe-local"===e.cliTool),J=(0,i.useMemo)(()=>{let e=new Set,t=[];for(let n of a)e.has(n.cliTool)||(e.add(n.cliTool),t.push(n.cliTool));return t},[a]),Y=function(e,t){let[n,a]=(0,i.useState)(null),[r,s]=(0,i.useState)(null),[l,o]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[u,m]=(0,i.useState)(!1),[x,h]=(0,i.useState)(null),[f,g]=(0,i.useState)(null),p=(0,i.useCallback)(e=>{s("string"==typeof(null==e?void 0:e.repositoryName)?e.repositoryName:null),o((null==e?void 0:e.repoDeclaresAgents)===!0)},[]),b=(0,i.useCallback)(async()=>{d(!0);try{let t=await fetch("".concat(ak,"?worktreeId=").concat(encodeURIComponent(e)));if(!t.ok)throw Error(String(t.status));let n=await t.json(),r=null==n?void 0:n.eligible;if("number"!=typeof r||!Number.isFinite(r))throw Error("unexpected body");return a(r),p(n),g(null),r}catch(e){return a(null),g("count"),null}finally{d(!1)}},[e,p]),v=(0,i.useCallback)(async()=>{d(!0),g(null),m(!1),h(null);try{let e=await fetch(aw.zk,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({agents:t})}),n=await e.json().catch(()=>null),a=null==n?void 0:n.defaultSelectedAgents;if(!e.ok||!Array.isArray(a))return g("save"),!1;return(0,aw.IK)(a),m(!0),!0}catch(e){return g("save"),!1}finally{d(!1)}},[t]),y=(0,i.useCallback)(async()=>{d(!0),g(null),m(!1);try{let n=await fetch(ak,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:e,agents:t})}),r=await n.json().catch(()=>null),s=null==r?void 0:r.updated;if(!n.ok||"number"!=typeof s||!Number.isFinite(s))return g("apply"),null;h(s),p(r);let l=r.eligible;return"number"==typeof l&&Number.isFinite(l)&&a(l),s}catch(e){return g("apply"),null}finally{d(!1)}},[e,t,p]);return{eligible:n,repositoryName:r,repoDeclaresAgents:l,busy:c,savedDefault:u,appliedCount:x,error:f,refreshEligible:b,saveAsDefault:v,applyToUnchanged:y}}(n,J),Q=J.length>=aj.eu&&J.length<=aj.Wj,X=k||Y.busy,Z=Q&&!Y.repoDeclaresAgents&&null!==Y.eligible&&Y.eligible>0,ee="count"===Y.error?p("agentDefaultsCountError"):"save"===Y.error?p("agentDefaultsSaveError"):"apply"===Y.error?p("agentDefaultsApplyError"):null,et=(0,i.useCallback)(()=>{let e=!D;F(e),e&&Y.refreshEligible()},[D,Y]),en=(0,i.useCallback)(async()=>{if(!Z)return;let e=await Y.refreshEligible();null!==e&&0!==e&&await w({description:p("agentDefaultsApplyConfirm",{count:e,agents:J.map(e=>(0,$.oo)(e)).join(", ")})})&&await Y.applyToUnchanged()},[Z,Y,w,p,J]),ea=(0,i.useCallback)(async e=>{let t=e.map((e,t)=>({...e,order:t}));N(!0),S(null);try{(await fetch("/api/worktrees/".concat(n),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentInstances:t})})).ok?s(t):S(p("agentInstanceSaveError"))}catch(e){S(p("agentInstanceSaveError"))}finally{N(!1)}},[n,s,p]),er=(0,i.useCallback)(()=>{if(a.length>=$.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)}(E,a);ea([...a,{id:e,cliTool:E,alias:function(e,t){let n=(0,$.oo)(e);if(t===e)return n;let a=t.slice(e.length+1);return a?"".concat(n," ").concat(a):n}(E,e),order:a.length}])},[E,a,ea]),es=(0,i.useCallback)(async e=>{var t;if(a.length<=1)return;let n=a.find(t=>t.id===e);await w({description:y("confirmDelete",{name:null!=(t=null==n?void 0:n.alias)?t:""}),variant:"danger"})&&ea(a.filter(t=>t.id!==e))},[a,ea,w,y]),el=(0,i.useCallback)((e,t)=>{let n=e+t;if(n<0||n>=a.length)return;let r=[...a];[r[e],r[n]]=[r[n],r[e]],ea(r)},[a,ea]),ei=(0,i.useCallback)((e,t)=>{T(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n});let n=a.find(t=>t.id===e);n&&t!==n.alias&&ea(a.map(n=>n.id===e?{...n,alias:t}:n))},[a,ea]),ec=(0,i.useCallback)((e,t)=>{if(e===t||e<0||t<0||e>=a.length||t>=a.length)return;let n=[...a],[r]=n.splice(e,1);n.splice(t,0,r),ea(n)},[a,ea]),ed=["flex flex-col p-4",g?"overflow-y-auto":"",g].filter(Boolean).join(" ");return(0,r.jsxs)("div",{className:ed,"data-testid":"agent-instances-pane",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:p("agentInstances")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:p("agentInstancesDescription")}),(0,r.jsx)("div",{className:"space-y-2",children:a.map((e,t)=>{var s,l;let i=e.id in I?I[e.id]:e.alias,o=M===t,c=null!=(s=null==x?void 0:x[e.id])?s:null,d=null==B?void 0:B[e.id],u=sq(d,j),m=!!(l=d)&&("sse"!==l.kind||"live"!==l.liveness),h=(0,ay.g)({owed:V.owedBy(e.id),awaiting:V.awaitedBy(e.id),aliasOf:U}),g=f===e.id;return(0,r.jsxs)("div",{"data-testid":"agent-instance-row-".concat(e.id),draggable:!0,onDragStart:()=>R(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{null!==M&&ec(M,t),R(null)},onDragEnd:()=>R(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(o?"opacity-50":""),children:[(0,r.jsx)("span",{className:"cursor-grab text-muted-foreground shrink-0","aria-hidden":"true",children:(0,r.jsx)(ad.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":p("agentInstanceAliasLabel"),value:i,maxLength:$.pQ,disabled:k,placeholder:p("agentInstanceAliasPlaceholder"),onChange:t=>T(n=>({...n,[e.id]:t.target.value})),onBlur:t=>ei(e.id,t.target.value),onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||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)(tJ.nR,{content:(0,$.oo)(e.cliTool),className:"mt-0.5 block truncate text-xs text-muted-foreground"}),c&&(0,r.jsx)("span",{"data-testid":"agent-instance-model-".concat(e.id),title:j("agentModel.modelLabel",{model:c}),className:"mt-0.5 block truncate text-xs text-muted-foreground",children:c}),u&&(0,r.jsxs)("span",{"data-testid":"agent-instance-source-".concat(e.id),title:j(m?"agentSource.degradedTitle":"agentSource.healthyTitle"),className:"mt-0.5 flex items-center gap-1 truncate text-xs ".concat(m?"text-warning":"text-muted-foreground"),children:[m?(0,r.jsx)(au.A,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}):(0,r.jsx)(am.A,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"truncate",children:u})]}),h.map(t=>(0,r.jsxs)("span",{"data-testid":"agent-instance-relay-".concat(t.tone,"-").concat(e.id),title:j("relay.".concat(t.titleKey)),className:"mt-0.5 flex items-center gap-1 truncate text-xs ".concat(aE(t)),children:[(0,r.jsx)(ax.A,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"truncate",children:j("relay.".concat(t.key),t.params)})]},t.key))]}),(0,r.jsx)("button",{type:"button","data-testid":"agent-instance-cli-".concat(e.id),"aria-label":j("cliCommands.open"),title:j("cliCommands.open"),onClick:()=>z(e.id),className:"shrink-0 p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted",children:(0,r.jsx)(ah.A,{className:"w-4 h-4"})}),O===e.id&&(0,r.jsx)(aS,{worktreeId:n,instance:e,isOpen:!0,onClose:()=>z(null)}),(0,r.jsxs)(G.rI,{children:[(0,r.jsx)(G.ty,{asChild:!0,children:(0,r.jsx)("button",{type:"button","data-testid":"agent-instance-menu-".concat(e.id),"aria-label":p("agentInstanceActions"),title:p("agentInstanceActions"),disabled:k,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)(af.A,{className:"w-4 h-4"})})}),(0,r.jsxs)(G.SQ,{align:"end",children:[!g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(G._2,{"data-testid":"agent-instance-delegate-".concat(e.id),onSelect:()=>{_(e)},children:[(0,r.jsx)(ag.A,{className:"w-4 h-4"}),aT.yW["ja"===b?"ja":"en"].menuItem]}),(0,r.jsx)(G.mB,{})]}),(0,r.jsxs)(G._2,{"data-testid":"agent-instance-move-up-".concat(e.id),disabled:0===t,onSelect:()=>el(t,-1),children:[(0,r.jsx)(nm.A,{className:"w-4 h-4"}),p("agentInstanceMoveUp")]}),(0,r.jsxs)(G._2,{"data-testid":"agent-instance-move-down-".concat(e.id),disabled:t===a.length-1,onSelect:()=>el(t,1),children:[(0,r.jsx)(W.A,{className:"w-4 h-4"}),p("agentInstanceMoveDown")]}),(0,r.jsx)(G.mB,{}),(0,r.jsxs)(G._2,{"data-testid":"agent-instance-delete-".concat(e.id),disabled:K,onSelect:()=>{es(e.id)},className:"text-danger-foreground focus:text-danger-foreground",children:[(0,r.jsx)(tH.A,{className:"w-4 h-4"}),p("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":p("agentInstanceBaseTool"),value:E,disabled:k||H,onChange:e=>A(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:$.XH.map(e=>(0,r.jsx)("option",{value:e,children:(0,$.oo)(e)},e))}),(0,r.jsxs)("button",{type:"button","data-testid":"agent-instance-add",disabled:k||H,onClick:er,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)(ap.A,{className:"w-4 h-4"}),p("agentInstanceAdd")]})]}),H&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:p("agentInstanceMax",{max:$.Ab})}),K&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:p("agentInstanceMin",{min:1})}),k&&(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"}),p("loading")]}),C&&(0,r.jsx)("p",{"data-testid":"agent-instances-error",className:"mt-3 text-xs text-danger-foreground",children:C}),q&&(0,r.jsx)(an,{worktreeId:n,vibeLocalModel:l,onVibeLocalModelChange:o,vibeLocalContextWindow:d,onVibeLocalContextWindowChange:m}),(0,r.jsxs)("div",{className:"mt-6 border-t border-border pt-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"agent-defaults-toggle","aria-expanded":D,onClick:et,className:"flex w-full items-center gap-1 text-left text-sm font-semibold text-foreground hover:text-accent-600 dark:hover:text-accent-400",children:[D?(0,r.jsx)(W.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):(0,r.jsx)(ab.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),p("agentDefaults")]}),D&&(0,r.jsxs)("div",{className:"mt-2 space-y-3","data-testid":"agent-defaults-section",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:p("agentDefaultsDescription")}),(0,r.jsx)("p",{"data-testid":"agent-defaults-roster",className:"text-xs font-medium text-foreground break-words",children:J.map(e=>(0,$.oo)(e)).join(" → ")}),!Q&&(0,r.jsx)("p",{"data-testid":"agent-defaults-invalid",className:"text-xs text-warning-foreground",children:p("agentDefaultsInvalidRoster",{min:aj.eu,max:aj.Wj})}),(0,r.jsx)("button",{type:"button","data-testid":"agent-defaults-set-default",disabled:X||!Q,onClick:()=>{Y.saveAsDefault()},className:"w-full 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",children:p("agentDefaultsSetDefault")}),(0,r.jsxs)("div",{className:"space-y-1",children:[Y.repositoryName&&(0,r.jsx)("p",{"data-testid":"agent-defaults-repository","data-repository":Y.repositoryName,className:"text-xs text-muted-foreground",children:p("agentDefaultsRepositoryLabel",{repository:Y.repositoryName})}),Y.repoDeclaresAgents&&(0,r.jsx)("p",{"data-testid":"agent-defaults-repo-declared",className:"text-xs text-warning-foreground",children:p("agentDefaultsRepoDeclared")}),!Y.repoDeclaresAgents&&(0,r.jsx)("span",{"data-testid":"agent-defaults-eligible","data-count":null!=(t=Y.eligible)?t:void 0,className:"block text-xs text-muted-foreground",children:null===Y.eligible?p("agentDefaultsEligibleUnknown"):p("agentDefaultsEligible",{count:Y.eligible})}),(0,r.jsx)("button",{type:"button","data-testid":"agent-defaults-apply",disabled:X||!Z,onClick:()=>{en()},className:"w-full text-sm font-medium px-3 py-2 rounded-md border border-border bg-surface text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed",children:p("agentDefaultsApply")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:p("agentDefaultsApplyScope")})]}),Y.savedDefault&&(0,r.jsxs)("p",{"data-testid":"agent-defaults-saved",className:"flex items-center gap-1 text-xs text-success-foreground",children:[(0,r.jsx)(ex.A,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),p("agentDefaultsSaved")]}),null!==Y.appliedCount&&(0,r.jsxs)("p",{"data-testid":"agent-defaults-applied","data-count":Y.appliedCount,className:"flex items-center gap-1 text-xs text-success-foreground",children:[(0,r.jsx)(ex.A,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),p("agentDefaultsApplied",{count:Y.appliedCount})]}),ee&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{"data-testid":"agent-defaults-error",className:"text-xs text-danger-foreground",children:ee}),"count"===Y.error&&(0,r.jsx)("button",{type:"button","data-testid":"agent-defaults-retry",disabled:X,onClick:()=>{Y.refreshEligible()},className:"text-xs font-medium underline text-accent-700 dark:text-accent-300 disabled:opacity-40 disabled:cursor-not-allowed",children:p("agentDefaultsRetry")})]})]})]}),(0,r.jsxs)("div",{className:"mt-6 border-t border-border pt-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"agent-updates-toggle","aria-expanded":L,onClick:()=>P(e=>!e),className:"flex w-full items-center gap-1 text-left text-sm font-semibold text-foreground hover:text-accent-600 dark:hover:text-accent-400",children:[L?(0,r.jsx)(W.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):(0,r.jsx)(ab.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),y("agentUpdates.title")]}),L&&(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(aI.uN,{worktreeId:n,instances:a.map(e=>({id:e.id,cliTool:e.cliTool,alias:e.alias})),variant:"plain"})})]})]})}),aM=(0,i.memo)(function(e){let{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d,visibleInstanceIds:u,onToggleInstanceVisible:x,modelByInstance:h,sourceByInstance:f,composerTargetInstanceId:g}=e,p=(0,c.c)("schedule"),b=(0,c.c)("worktree"),v=new Set(u),y=u.length<=1,j=(0,av.UI)(t),w=(0,i.useCallback)(e=>{var a,r;return e.worktreeId!==t?"".concat(e.instanceId," @ ").concat(e.worktreeId):null!=(r=null==(a=n.find(t=>t.id===e.instanceId))?void 0:a.alias)?r:e.instanceId},[n,t]);return(0,r.jsxs)("div",{"data-testid":"mobile-agent-instances-pane",children:[(0,r.jsx)(aA,{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d,modelByInstance:h,sourceByInstance:f,composerTargetInstanceId:g}),(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:p("mobileVisibleInstances")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:p("mobileVisibleInstancesDescription")}),(0,r.jsx)("div",{className:"space-y-1",children:n.map(e=>{var t;let n=v.has(e.id),a=n&&y,s=null!=(t=null==h?void 0:h[e.id])?t:null,l=(0,ay.g)({owed:j.owedBy(e.id),awaiting:j.awaitedBy(e.id),aliasOf:w});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:()=>x(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,$.sw)(e)}),(0,r.jsx)("span",{className:"block text-xs text-muted-foreground truncate",children:(0,$.oo)(e.cliTool)}),s&&(0,r.jsx)("span",{"data-testid":"mobile-visible-instance-model-".concat(e.id),title:b("agentModel.modelLabel",{model:s}),className:"block text-xs text-muted-foreground truncate",children:s}),l.map(t=>(0,r.jsx)("span",{"data-testid":"mobile-visible-instance-relay-".concat(t.tone,"-").concat(e.id),title:b("relay.".concat(t.titleKey)),className:"block text-xs truncate ".concat(aE(t)),children:b("relay.".concat(t.key),t.params)},t.key))]})]},e.id)})}),y&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:p("mobileVisibleInstanceMin")})]})]})}),aR=Array.from({length:Math.floor(104)+1},(e,t)=>3e5+3e5*t);var aL=n(76351);function aP(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 aD="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 aF(e){let{isOpen:t,worktreeId:n,instances:a,onClose:s,onSaved:l}=e,o=(0,c.c)("schedule"),d=(0,nl.a)(),u=(0,i.useMemo)(()=>a&&a.length>0?a:(0,$.lu)([...$.XH]),[a]),[m,x]=(0,i.useState)(""),[h,f]=(0,i.useState)(()=>{var e,t;return null!=(t=null==(e=u[0])?void 0:e.id)?t:$.XH[0]}),[g,p]=(0,i.useState)(aR[0]),[b,v]=(0,i.useState)(!1),[y,j]=(0,i.useState)(null);(0,i.useEffect)(()=>{var e,n;t&&(x(""),p(aR[0]),j(null),v(!1),f(null!=(n=null==(e=u[0])?void 0:e.id)?n:$.XH[0]))},[t,u]),(0,i.useEffect)(()=>{if(!u.some(e=>e.id===h)){var e,t;f(null!=(t=null==(e=u[0])?void 0:e.id)?t:$.XH[0])}},[u,h]);let w=m.trim().length>0&&!b,k=(0,i.useCallback)(async()=>{if(!m.trim()||b)return;let e=u.find(e=>e.id===h);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:g})});if(t.ok){let e=await t.json();l(),"session_not_running"===e.warning?(j("session_not_running"),x("")):s()}}catch(e){}finally{v(!1)}}},[n,u,h,m,g,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:h,onChange:e=>f(e.target.value),className:aD,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=>x(e.target.value),placeholder:o("timer.message"),maxLength:1e4,rows:3,className:"".concat(aD," 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:g,onChange:e=>p(Number(e.target.value)),className:aD,children:aR.map(e=>(0,r.jsx)("option",{value:e,children:aP(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)(nS,{isOpen:t,onClose:s,title:S,footer:C,children:N}):(0,r.jsx)(e6.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 aO(e){return new Date(e).toLocaleString()}function az(e){var t,n;let{timer:a,instances:s,onClose:l}=e,i=(0,c.c)("schedule"),o=(0,nl.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:aP(a.delayMs)}),(0,r.jsx)(u,{label:i("timer.scheduledTime"),children:aO(a.scheduledSendTime)}),(0,r.jsx)(u,{label:i("timer.createdTime"),children:aO(a.createdAt)}),null!==a.sentAt&&(0,r.jsx)(u,{label:i("timer.sentTime"),children:aO(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})]})]}),x=(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")})}),h=i("timer.detailTitle");return o?(0,r.jsx)(nS,{isOpen:!0,title:h,onClose:l,footer:x,children:m}):(0,r.jsx)(e6.a,{isOpen:!0,title:h,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:x})]})})}let a_=(0,i.memo)(function(e){let{worktreeId:t,instances:n}=e,a=(0,c.c)("schedule"),s=(0,eo.SC)(),l=(0,i.useMemo)(()=>n&&n.length>0?n:(0,$.lu)([...$.XH]),[n]),[o,d]=(0,i.useState)([]),[u,m]=(0,i.useState)(!1),[x,h]=(0,i.useState)(!1),[f,g]=(0,i.useState)(null),[,p]=(0,i.useState)(0),b=(0,i.useRef)(null),v=(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),v.current=setInterval(()=>{p(e=>e+1)},1e3),t}function t(){b.current&&clearInterval(b.current),v.current&&clearInterval(v.current),b.current=null,v.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)(y.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:()=>h(!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)(ap.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:()=>h(!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)(ap.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:()=>g(e),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),g(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:(0,aL.$B)(e.scheduledSendTime)}),(0,r.jsx)("span",{className:"text-muted-foreground",children:aP(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)(aF,{isOpen:x,worktreeId:t,instances:n,onClose:()=>h(!1),onSaved:()=>{w()}}),(0,r.jsx)(az,{timer:f,instances:l,onClose:()=>g(null)})]})});var aB=n(35626),aV=n(99648);let aU={verified:"skills.compatibility.axisOutcome.verified",unsupported:"skills.compatibility.axisOutcome.unsupported",unknown:"skills.compatibility.axisOutcome.unknown"},aW={mechanical:"skills.compatibility.evidenceKind.mechanical",self_report:"skills.compatibility.evidenceKind.selfReport",not_measured:"skills.compatibility.evidenceKind.notMeasured"},aH={outcome:"unknown",evidenceKind:"not_measured",labelKey:aU.unknown,evidenceKindKey:aW.not_measured,limitationKey:null},aK={SESSION_RESTART:"skills.compatibility.reload.sessionRestart",SESSION_RESTART_NO_SLASH:"skills.compatibility.reload.sessionRestartNoSlash",UNKNOWN:"skills.compatibility.reload.unknown"},a$={NO_SLASH_COMMAND:"skills.compatibility.limitation.noSlashCommand"};function aq(e){return{agent:e,discoveryRoots:[],discovery:aH,invocation:aH,testedVersion:null,testedDate:null,evidenceSource:null,reloadKey:aK.UNKNOWN,skipReasonKey:"skills.compatibility.skipReason.notMeasured"}}aV.td,aU.verified,aW.mechanical,aU.verified,aW.mechanical,aK.SESSION_RESTART,aV.Co,aU.verified,aW.self_report,aU.unsupported,aW.mechanical,a$.NO_SLASH_COMMAND,aK.SESSION_RESTART_NO_SLASH,aq("gemini"),aq("vibe-local"),aV.Co,aV.td,aU.verified,aW.mechanical,aU.verified,aW.mechanical,a$.NO_SLASH_COMMAND,aK.SESSION_RESTART,aV.Co,aV.td,aU.verified,aW.mechanical,aU.verified,aW.mechanical,aK.UNKNOWN,aq("antigravity"),aV.Co,aU.verified,aW.mechanical,aU.verified,aW.mechanical,aK.SESSION_RESTART;let aG={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"};aG.SATISFIED,aG.HOST_VERSION_OUT_OF_RANGE,aG.HOST_VERSION_UNKNOWN,aG.RANGE_UNSUPPORTED;let aJ={CONFIRMED:"SKILL_AGENT_EVIDENCE_CONFIRMED",RESTRICTED:"SKILL_AGENT_EVIDENCE_RESTRICTED",STALE_DECLARATION:"SKILL_AGENT_EVIDENCE_STALE_DECLARATION",UNVERIFIED:"SKILL_AGENT_EVIDENCE_UNVERIFIED"};aJ.CONFIRMED,aJ.RESTRICTED,aJ.STALE_DECLARATION,aJ.UNVERIFIED;let aY=/^(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 aQ(e){if("string"!=typeof e||e.length>64)return null;let t=aY.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 aX={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 aZ(e,t){let n=function(e,t){let n=aQ(e),a=aQ(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}aX.UP_TO_DATE,aX.HIGHEST_COMPATIBLE,aX.LATEST_UNVERIFIED,aX.NONE_COMPATIBLE,aX.INSTALLED_VERSION_INVALID,aX.RANGE_UNSUPPORTED;var a0=n(75333),a1=n(34380),a2=n(37381),a4=n(95584),a5=n(80130);let a3={open:!1,selectedVersion:null,busy:!1,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applying:!1,applyResult:null,applyFailure:null};function a6(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 a8(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=>aZ(e.version,l)),[o,l]),x=(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]),[h,f]=(0,i.useState)(a3),g=(0,i.useCallback)(()=>{f({...a3,open:!0,selectedVersion:x})},[x]),p=(0,i.useCallback)(()=>{f(a3)},[]),b=(0,i.useCallback)(async()=>{let e=h.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,a5.Sw)(s,n,{version:e});f(e=>({...e,busy:!1,plan:t.ok?t.data.plan:null,failure:t.ok?null:t.failure}))},[n,h.selectedVersion,s]),v=(0,i.useCallback)(async()=>{var e;let t=h.plan;if(!t||!t.updatable)return;f(e=>({...e,applying:!0,applyFailure:null}));let a=await (0,a5.h2)(s,n,{planToken:t.token,version:t.update.toVersion,acknowledgeRisk:h.riskAcknowledged,acknowledgeRiskIncrease:h.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,h.plan,h.riskAcknowledged,h.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=h.plan,j=h.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:g,"data-testid":"skill-update-trigger",children:d("update.open")})]}),(0,r.jsx)(m.Jh,{isOpen:h.open,onClose:p,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=h.selectedVersion)?t:"",onChange:e=>f(t=>({...t,selectedVersion:e.target.value,plan:null,failure:null})),disabled:h.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(a4.OV[e.compatibility.commandmate.status])):""]},e.version))})]}),(0,r.jsx)(m.$n,{variant:"primary",disabled:h.busy||!h.selectedVersion,onClick:b,"data-testid":"skill-update-build",children:h.busy?d("update.building"):d("update.build")}),h.failure&&(0,r.jsxs)(a2.u,{tone:"danger","data-testid":"skill-update-error",children:[(0,r.jsx)("p",{children:d((0,a4.FW)(h.failure.code))}),(0,r.jsx)("p",{className:"mt-1 break-words",children:d("state.errorCode",{code:h.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)(a2.u,{tone:y.updatable?"info":"warning","data-testid":"skill-update-next-action",children:d((0,a4.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,a4.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)(a0.qW,{risk:y.securityDiff.risk.from.effective}),(0,r.jsx)("span",{"aria-hidden":"true",children:"→"}),(0,r.jsx)(a0.qW,{risk:y.securityDiff.risk.to.effective})]}),y.riskIncreased&&y.riskIncreaseMessageKey&&(0,r.jsx)(a2.u,{tone:"danger","data-testid":"skill-update-risk-increase",children:d((0,a4.e5)(y.riskIncreaseMessageKey))}),y.requiresRiskAcknowledgement&&y.riskAcknowledgementMessageKey&&(0,r.jsx)(a2.u,{tone:"warning","data-testid":"skill-update-high-risk",children:d((0,a4.e5)(y.riskAcknowledgementMessageKey))}),y.updatable&&!h.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:h.riskAcknowledged,onChange:e=>f(t=>({...t,riskAcknowledged:e.target.checked})),"data-testid":"skill-update-ack-risk"}),d("update.ackRisk")]}),y.updatable&&!h.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:h.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=a4.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=a4.z2[e])?t:"plan.permissionsNone")},e)})})]}),(0,r.jsx)(a6,{heading:d("update.scriptsAdded"),paths:y.securityDiff.scripts.added,testid:"skill-update-scripts-added"}),(0,r.jsx)(a6,{heading:d("update.scriptsRemoved"),paths:y.securityDiff.scripts.removed,testid:"skill-update-scripts-removed"}),(0,r.jsx)(a6,{heading:d("update.executablesAdded"),paths:y.securityDiff.executables.added,testid:"skill-update-executables-added"}),(0,r.jsx)(a6,{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=a4.JD[e.change])?t:"gray",children:d(null!=(n=a4.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&&!h.applyResult&&(0,r.jsx)(m.$n,{variant:"primary",disabled:h.applying||y.requiresRiskAcknowledgement&&!h.riskAcknowledged||y.riskIncreased&&!h.riskIncreaseAcknowledged,onClick:v,"data-testid":"skill-update-apply",children:h.applying?d("update.applying"):d("update.apply")}),h.applyFailure&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-apply-error",children:[(0,r.jsxs)(a2.u,{tone:"danger",children:[(0,r.jsx)("p",{children:d((0,a4.FW)(h.applyFailure.code))}),(0,r.jsx)("p",{className:"mt-1 break-words",children:d("state.errorCode",{code:h.applyFailure.code})})]}),h.applyFailure.nextActionKey&&(0,r.jsx)(a2.u,{tone:"warning",children:d((0,a4.e5)(h.applyFailure.nextActionKey))}),h.applyFailure.blockers&&h.applyFailure.blockers.length>0&&(0,r.jsx)("ul",{className:"space-y-1","data-testid":"skill-update-apply-error-blockers",children:h.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,a4.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)(a2.u,{tone:"succeeded"===j.operation.result?"info":"warning","data-testid":"skill-update-result-next-action",children:d((0,a4.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,a4.e5)(e.messageKey),{agent:(0,$.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,a4.e5)(j.rollback.messageKey),{version:j.rollback.backup.fromVersion})})]})]})]})})]})}let a9={status:"loading",skills:[],failure:null},a7={status:"loading",skills:[],failure:null};function re(e){var t,n,a,s,l,o,d,u;let{worktreeId:x,className:h=""}=e,f=(0,c.c)("skills"),[g,p]=(0,i.useState)(a9),[b,v]=(0,i.useState)(a7),[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 p(a9),(0,a5.s5)(e.signal).then(t=>{e.signal.aborted||p(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(a7),(0,a5.Gj)(x,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()},[x,N]);let S=(0,i.useMemo)(()=>new Map(b.skills.map(e=>[e.skillId,e.version])),[b.skills]),I=(0,i.useMemo)(()=>new Map(g.skills.map(e=>[e.id,{name:e.name,summary:e.summary,latest:e.latest}])),[g.skills]),T=(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=I.get(r))?void 0:t.latest)?n:null,null!==s&&null!==a&&aZ(a,s)))}return e},[S,I]),E=(0,i.useMemo)(()=>{var e;return null!=(e=g.skills.find(e=>e.id===y))?e:null},[g.skills,y]),A=(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==E?void 0:E.compatibility)?a:null,t=E?E.recommendedVersion:null!=(s=null==A?void 0:A.version)?s:null,n=E?E.recommendedVersion?e&&"compatible"!==e.status?f("detail.install.blockedIncompatible",{reason:f((0,a4.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(h).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)(aB.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==E?void 0:E.name)?o:y})]}),(0,r.jsxs)("div",{className:"min-h-0 flex-1 space-y-3 overflow-auto p-3",children:[A&&E&&(0,r.jsx)(a8,{skillId:y,skillName:E.name,worktreeId:x,installedVersion:A.version,versions:E.versions}),(0,r.jsx)(a1.B,{skillId:y,version:t,blockedReason:n,worktreeId:x})]})]})}return(0,r.jsx)("div",{className:"flex flex-col min-h-0 ".concat(h).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)(a2.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=I.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)(a0.qW,{risk:e.effectiveRisk}),T.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"===g.status?(0,r.jsx)(m.EA,{className:"h-24 w-full rounded-lg","data-testid":"worktree-skills-catalog-loading"}):"error"===g.status?(0,r.jsxs)(m.Zp,{className:"space-y-2","data-testid":"worktree-skills-catalog-error",children:[(0,r.jsxs)(a2.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=g.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===g.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:g.skills.map(e=>{let t=(0,a4.gh)(e),n=S.has(e.id),a=!0===T.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)(a0.Xz,{status:e.compatibility.status}),t&&(0,r.jsx)(a0.qW,{risk:t})]})]})},e.id)})})]})]})})}var rt=n(93499),rn=n(76907),ra=n(52799),rr=n(32209);let rs={pending:"gray",running:"info",waiting_input:"warning",verifying:"info",succeeded:"success",failed:"error",not_started:"warning",cancelled:"gray"},rl={running:"info",passed:"success",failed:"error",not_started:"warning",error:"error",cancelled:"gray"},ri={running:"info",passed:"success",failed:"error",timeout:"error",skipped:"gray",error:"error"},ro=["failed","timeout","error"],rc="".concat(eZ,"/blob/main/docs/design/verification-config.md"),rd=".commandmate/verify.yaml";class ru extends Error{constructor(e,t,n=null){super(e),this.name="VerificationApiError",this.status=t,this.runningRunId=n}}async function rm(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 ru(a,e.status,r)}function rx(e){return"/api/worktrees/".concat(encodeURIComponent(e))}async function rh(e,t){var n,a;let r=await fetch("".concat(rx(e),"/tasks?limit=1"),{signal:t});return r.ok?null!=(a=null==(n=(await r.json()).tasks)?void 0:n[0])?a:null:rm(r,"Failed to load tasks")}async function rf(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(rx(e),"/verify/runs?limit=").concat(n),{signal:a});return r.ok?null!=(t=(await r.json()).runs)?t:[]:rm(r,"Failed to load verification runs")}async function rg(e,t,n){let a=await fetch("".concat(rx(e),"/verify/runs/").concat(t),{signal:n});return 404===a.status?null:a.ok?(await a.json()).run:rm(a,"Failed to load the verification run")}async function rp(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=await fetch("".concat(rx(e),"/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)return rm(n,"Failed to start verification");let a=await n.json();if("number"!=typeof a.runId)throw new ru("Verification response carried no run id",n.status);return a.runId}async function rb(e,t){var n,a,r;let s=await fetch("".concat(rx(e),"/verify/config"),{signal:t});if(!s.ok)return rm(s,"Failed to load the verification config");let l=await s.json();return{exists:!0===l.exists,path:"string"==typeof l.path?l.path:rd,gates:null!=(n=l.gates)?n:[],options:null!=(a=l.options)?a:null,plannedGateIds:null!=(r=l.plannedGateIds)?r:[],error:"string"==typeof l.error?l.error:null}}async function rv(e){var t,n,a;let r=await fetch("".concat(rx(e),"/verify/config"),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!r.ok)return rm(r,"Failed to draft the verification config");let s=await r.json();return{created:!0===s.created,path:"string"==typeof s.path?s.path:rd,gates:null!=(t=s.gates)?t:[],excluded:null!=(n=s.excluded)?n:[],scanned:null!=(a=s.scanned)?a:[]}}async function ry(e,t){var n;let a=await fetch("".concat(rx(e),"/verify/runs/").concat(t,"/cancel"),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!a.ok)return rm(a,"Failed to cancel the verification run");let r=await a.json();return{runId:"number"==typeof r.runId?r.runId:t,status:null!=(n=r.status)?n:"cancelled"}}async function rj(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,a=new URLSearchParams;void 0!==t.worktreeId&&a.set("worktreeId",t.worktreeId),void 0!==t.days&&a.set("days",String(t.days)),void 0!==t.limit&&a.set("limit",String(t.limit));let r=a.toString(),s=await fetch("/api/verification/runs".concat(r?"?".concat(r):""),{signal:n});return s.ok?null!=(e=(await s.json()).runs)?e:[]:rm(s,"Failed to load the verification history")}let rw={running:null,passed:0,failed:20,not_started:21,error:99,cancelled:99},rk=["passed","failed","not_started","error","cancelled"],rN={"work-evidence":"workEvidence",scope:"scope","env-clean":"envClean",config:"config"},rC={mutex:"reason=mutex-wait",detachedContract:"was NOT judged",noContract:"no contract is attached to this run",notRequired:"success.requireScopeClean: false"};function rS(e){if(!e)return"—";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function rI(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)(ra.E,{variant:rs[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:rS(a.updatedAt)})]})]})}function rA(e){let{gate:t}=e;return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 rounded-md border border-border bg-surface px-2 py-1.5","data-testid":"verification-declared-gate-".concat(t.id),children:[(0,r.jsx)("span",{className:"break-all font-mono text-xs font-medium text-foreground",children:t.id}),(0,r.jsx)("span",{className:"break-all font-mono text-[11px] text-muted-foreground",children:t.command})]})}function rM(e){let{children:t,testId:n,tone:a="muted"}=e;return(0,r.jsx)("p",{className:"whitespace-pre-line break-words ".concat("warning"===a?"rounded border border-warning-border bg-warning-subtle px-2 py-1 text-xs text-warning-foreground":"text-xs text-muted-foreground"),"data-testid":n,role:"warning"===a?"alert":void 0,children:t})}function rR(e){var t,n,a,s,l,o;let{state:d}=e,u=(0,c.c)("worktree"),{config:m,configError:x,phase:h,runs:f,selectedRun:g,latestRun:p}=d,b=null!=(n=null==m?void 0:m.path)?n:rd,v=(0,i.useCallback)(()=>{d.draftConfig()},[d]),y=(0,i.useCallback)(()=>{d.rerun()},[d]),j=(0,i.useCallback)(()=>{p&&d.selectRun(p.id)},[p,d]),w=(0,i.useCallback)(()=>{d.cancelRun()},[d]),k=null!=(a=f.find(e=>"running"===e.status))?a:null,N=g&&k&&g.id===k.id?g.gates:[],C=N.filter(e=>"running"!==e.status).length,S=Math.max(null!=(s=null==m?void 0:m.plannedGateIds.length)?s:0,N.length),I=k?Date.now()-new Date(k.startedAt).getTime():0;return(0,r.jsxs)("section",{className:"space-y-2 border-b border-border px-3 py-3","data-testid":"verification-onboarding","data-phase":h,children:[(0,r.jsx)(rM,{testId:"verification-onboarding-what",children:u("verification.onboarding.what",{path:b})}),(0,r.jsx)(rM,{testId:"verification-onboarding-how",children:u("verification.onboarding.how")}),null!==x&&(0,r.jsx)(rM,{tone:"warning",testId:"verification-config-error",children:u("verification.onboarding.configError",{message:x})}),(null==m?void 0:m.error)!=null&&(0,r.jsx)(rM,{tone:"warning",testId:"verification-config-invalid",children:u("verification.onboarding.invalid",{path:b,message:m.error})}),"unknown"===h&&(0,r.jsx)(rM,{testId:"verification-onboarding-unknown",children:u("verification.onboarding.loading")}),"no-config"===h&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-onboarding-no-config",children:[(0,r.jsx)(rM,{children:u("verification.onboarding.noConfig.body",{path:b})}),(0,r.jsx)(rM,{children:u("verification.onboarding.noConfig.hint")}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(ei.$,{type:"button",size:"sm",variant:"primary",onClick:v,disabled:d.draftPending,"data-testid":"verification-draft-button",children:u(d.draftPending?"verification.onboarding.noConfig.pending":"verification.onboarding.noConfig.action")}),(0,r.jsxs)("a",{href:rc,target:"_blank",rel:"noreferrer noopener","data-testid":"verification-docs-link",className:"inline-flex items-center gap-1 rounded text-xs 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:[u("verification.onboarding.noConfig.docs"),(0,r.jsx)(rt.A,{size:12,"aria-hidden":"true"})]})]}),d.draftFailure&&(0,r.jsx)(rM,{tone:"warning",testId:"verification-draft-failure",children:"conflict"===d.draftFailure.kind?u("verification.onboarding.noConfig.conflict",{path:b}):"empty"===d.draftFailure.kind?u("verification.onboarding.noConfig.empty",{path:b}):u("verification.onboarding.noConfig.error",{message:d.draftFailure.message})})]}),"configured"===h&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-onboarding-configured",children:[(0,r.jsx)(rM,{children:u("verification.onboarding.configured.body",{path:b,count:null!=(l=null==m?void 0:m.gates.length)?l:0})}),(null==(t=d.draftResult)?void 0:t.created)&&(0,r.jsx)(rM,{testId:"verification-draft-created",children:u("verification.onboarding.noConfig.created",{path:d.draftResult.path,count:d.draftResult.gates.length})}),(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:u("verification.onboarding.configured.gatesHeading")}),(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-declared-gates",children:(null!=(o=null==m?void 0:m.gates)?o:[]).map(e=>(0,r.jsx)(rA,{gate:e},e.id))}),(0,r.jsx)(rM,{testId:"verification-builtin-gates",children:u("verification.onboarding.configured.builtin",{gates:(function(e){if(null===e)return[];let t=new Set(e.gates.map(e=>e.id));return e.plannedGateIds.filter(e=>!t.has(e))})(m).join(", ")})}),(0,r.jsx)(rM,{testId:"verification-builtin-gates-hint",children:u("verification.onboarding.configured.builtinHint")}),(0,r.jsx)(ei.$,{type:"button",size:"sm",variant:"primary",onClick:y,disabled:d.rerunPending,"data-testid":"verification-run-button",children:u(d.rerunPending?"verification.runs.rerunPending":"verification.onboarding.configured.action")})]}),"running"===h&&null!==k&&(0,r.jsxs)("div",{className:"space-y-1","data-testid":"verification-onboarding-running",children:[(0,r.jsx)(rM,{testId:"verification-running-progress",children:u("verification.onboarding.running.progress",{done:C,total:S})}),(0,r.jsx)(rM,{testId:"verification-running-elapsed",children:u("verification.onboarding.running.elapsed",{elapsed:function(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return"".concat(t,"s");let n=Math.floor(t/60);return"".concat(n,"m ").concat(String(t%60).padStart(2,"0"),"s")}(I)})}),(0,r.jsx)(rM,{children:u("verification.onboarding.running.hint")}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(ei.$,{type:"button",size:"sm",variant:"secondary",onClick:d.refresh,"data-testid":"verification-running-refresh-button",children:u("verification.onboarding.running.action")}),(0,r.jsx)(ei.$,{type:"button",size:"sm",variant:"danger",onClick:w,disabled:d.cancelPending,"data-testid":"verification-cancel-button",children:u(d.cancelPending?"verification.runs.cancelPending":"verification.runs.cancel")})]}),(0,r.jsx)(rM,{testId:"verification-cancel-hint",children:u("verification.runs.cancelHint")}),d.cancelSettling&&(0,r.jsx)(rM,{testId:"verification-cancel-settling",children:u("verification.runs.cancelSettling")}),d.cancelFailure&&(0,r.jsx)(rM,{tone:"warning",testId:"verification-cancel-failure",children:"gone"===d.cancelFailure.kind?u("verification.runs.cancelGone"):u("verification.runs.cancelError",{message:d.cancelFailure.message})})]}),"result"===h&&null!==p&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-onboarding-result",children:[(0,r.jsx)(rM,{testId:"verification-result-body",children:u("verification.onboarding.result.body",{runId:p.id,verdict:u("verification.runStatus.".concat(p.status))})}),(0,r.jsx)(ei.$,{type:"button",size:"sm",variant:"secondary",onClick:j,"data-testid":"verification-show-latest-button",children:u("verification.onboarding.result.action")})]})]})}function rL(e){let{state:t}=e,n=(0,c.c)("worktree"),[a,s]=(0,i.useState)(!1),{availableGateIds:l,selectedGateIds:o,failedGateIds:d,rerunPending:u}=t,m=(0,i.useCallback)(()=>s(e=>!e),[]),x=(0,i.useCallback)(()=>t.setGateSelection(null),[t]),h=(0,i.useCallback)(()=>{t.selectFailedGates(),s(!0)},[t]),f=(0,i.useCallback)(()=>{t.rerun()},[t]);if(0===l.length)return null;let g=null!=o?o:l,p=null===o,b=l.filter(e=>d.includes(e));return(0,r.jsxs)("div",{className:"mb-2 rounded-md border border-border bg-surface-2 px-2 py-2","data-testid":"verification-gate-selector","data-selection":p?"all":g.join(","),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:n("verification.selection.heading")}),(0,r.jsx)("button",{type:"button",onClick:m,"aria-expanded":a,"data-testid":"verification-gate-selector-toggle",className:"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:a?n("verification.selection.close"):n("verification.selection.open")})]}),(0,r.jsx)("p",{className:"mt-0.5 break-words text-[11px] text-muted-foreground","data-testid":"verification-gate-selector-summary",children:p?n("verification.selection.all",{count:l.length}):n("verification.selection.partial",{selected:g.length,total:l.length,gates:g.join(", ")})}),a&&(0,r.jsxs)("div",{className:"mt-2 space-y-2","data-testid":"verification-gate-selector-body",children:[(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-gate-checkboxes",children:l.map(e=>{let a="verification-gate-select-".concat(e),s=d.includes(e);return(0,r.jsxs)("li",{className:"flex items-center gap-2",children:[(0,r.jsx)(rr.S,{id:a,checked:g.includes(e),onCheckedChange:()=>t.toggleGate(e),"data-testid":a,"aria-label":n("verification.selection.gateLabel",{gateId:e})}),(0,r.jsx)("label",{htmlFor:a,className:"min-w-0 flex-1 cursor-pointer break-all font-mono text-[11px] text-foreground touch-manipulation",children:e}),s&&(0,r.jsx)(ra.E,{variant:"error",className:"flex-shrink-0",children:n("verification.gateStatus.failed")})]},e)})}),(0,r.jsx)(ei.$,{type:"button",size:"sm",variant:"primary",onClick:f,disabled:u,"data-testid":"verification-run-selected-button",children:u?n("verification.runs.rerunPending"):p?n("verification.selection.runAll"):n("verification.selection.runSelected",{count:g.length})}),(0,r.jsx)("p",{className:"break-words text-[11px] text-muted-foreground",children:n("verification.selection.hint")})]}),(0,r.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[(0,r.jsx)(ei.$,{type:"button",size:"sm",variant:"secondary",onClick:h,disabled:0===b.length,"data-testid":"verification-failed-only-button",children:n("verification.selection.failedOnly",{count:b.length})}),!p&&(0,r.jsx)(ei.$,{type:"button",size:"sm",variant:"ghost",onClick:x,"data-testid":"verification-select-all-button",children:n("verification.selection.selectAll")})]}),0===b.length&&(0,r.jsx)("p",{className:"mt-1 break-words text-[11px] text-muted-foreground","data-testid":"verification-failed-only-empty",children:n("verification.selection.failedOnlyEmpty")})]})}function rP(e){let{state:t}=e,n=(0,c.c)("worktree"),{repositoryHistoryOpen:a,repositoryHistory:s,repositoryHistoryLoading:l,repositoryHistoryError:o}=t,d=(0,i.useCallback)(()=>{t.toggleRepositoryHistory()},[t]);return(0,r.jsxs)("div",{className:"mt-2","data-testid":"verification-repository-history",children:[(0,r.jsx)("button",{type:"button",onClick:d,"aria-expanded":a,"data-testid":"verification-repository-history-toggle",className:"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(a?"verification.runs.history.close":"verification.runs.history.open")}),a&&(0,r.jsxs)("div",{className:"mt-1 space-y-1","data-testid":"verification-repository-history-body",children:[(0,r.jsx)("p",{className:"break-words text-[11px] text-muted-foreground",children:n("verification.runs.history.hint")}),null!==o?(0,r.jsx)("p",{className:"rounded border border-warning-border bg-warning-subtle px-2 py-1 text-[11px] text-warning-foreground","data-testid":"verification-repository-history-error",role:"alert",children:n("verification.runs.history.error",{message:o})}):l&&0===s.length?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("verification.runs.history.loading")}):0===s.length?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"verification-repository-history-empty",children:n("verification.runs.history.empty")}):(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-repository-history-runs",children:s.map(e=>(0,r.jsx)(rD,{run:e},e.id))})]})]})}function rD(e){let{run:t}=e,n=(0,c.c)("worktree"),a=t.status,s=t.gates.filter(e=>ro.includes(e.status)).map(e=>e.gateId);return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 rounded-md border border-border bg-surface px-2 py-1.5","data-testid":"verification-history-run-".concat(t.id),children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)(ra.E,{variant:rl[a],className:"flex-shrink-0",children:n("verification.runStatus.".concat(a))}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-foreground",children:t.worktreeId})]}),(0,r.jsxs)("span",{className:"flex flex-wrap gap-x-2 font-mono text-[11px] text-muted-foreground",children:[(0,r.jsx)("span",{children:n("verification.runs.runLabel",{runId:t.id})}),(0,r.jsx)("span",{children:rS(t.startedAt)})]}),s.length>0&&(0,r.jsx)("span",{className:"break-words text-[11px] text-muted-foreground",children:n("verification.runs.history.failingGates",{gates:s.join(", ")})})]})}function rF(e){let{gate:t,log:n,onClose:a}=e,s=(0,c.c)("worktree"),[l,o]=(0,i.useState)("idle"),d=(0,i.useRef)(null);(0,i.useEffect)(()=>()=>{null!==d.current&&clearTimeout(d.current)},[]);let u=""===n?0:n.replace(/\n+$/,"").split("\n").length,m=""!==n.trim(),x=(0,i.useCallback)(()=>{(async()=>{try{await (0,eN.l)(n),o("done")}catch(e){o("failed")}null!==d.current&&clearTimeout(d.current),d.current=setTimeout(()=>o("idle"),2e3)})()},[n]);return(0,r.jsx)(e6.a,{isOpen:!0,onClose:a,size:"xl",title:s("verification.gates.fullLogTitle",{gateId:t.gateId,runId:t.runId}),children:(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-gate-full-log-".concat(t.gateId),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)(ei.$,{type:"button",size:"sm",variant:"secondary",onClick:x,disabled:!m,"data-testid":"verification-gate-log-copy-button",children:[(0,r.jsx)(eh.A,{size:12,"aria-hidden":"true",className:"mr-1"}),s("done"===l?"verification.gates.copied":"failed"===l?"verification.gates.copyFailed":"verification.gates.copyLog")]}),(0,r.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground","data-testid":"verification-gate-log-size",children:s("verification.gates.fullLogSize",{lines:u})})]}),(0,r.jsx)("p",{className:"break-words text-[11px] text-muted-foreground",children:s("verification.gates.fullLogStored")}),""===n?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:s("verification.gates.noLog")}):(0,r.jsx)("pre",{className:"max-h-[60vh] overflow-auto rounded bg-terminal-surface p-2 font-mono text-[11px] leading-relaxed text-terminal-foreground",children:n})]})})}function rO(e){let{run:t,selected:n,onSelect:a}=e,s=(0,c.c)("worktree"),l=s("verification.runStatus.".concat(t.status)),i=s("verification.runStatusGloss.".concat(t.status)),o=rw[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,gloss:i}),title:i,"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)(ra.E,{variant:rl[t.status],className:"flex-shrink-0",children:l}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:rS(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})}),null!==o&&(0,r.jsx)("span",{children:s("verification.runs.exitCode",{code:o})})]})]})})}function rz(){let e=(0,c.c)("worktree"),t=rk.map(t=>{var n;return e("verification.runs.cliLegendItem",{label:e("verification.runStatus.".concat(t)),code:null!=(n=rw[t])?n:0})}).join(" / ");return(0,r.jsx)("p",{className:"mb-2 break-words text-[11px] text-muted-foreground","data-testid":"verification-cli-exit-legend",children:e("verification.runs.cliLegend",{items:t})})}function r_(e){let{run:t,plannedGateIds:n}=e,a=(0,c.c)("worktree"),s=rw[t.status],l=t.gates.filter(e=>"skipped"===e.status),i=new Set(t.gates.map(e=>e.gateId)),o=n.filter(e=>!i.has(e));return(0,r.jsxs)("div",{className:"mb-2 space-y-1 rounded-md border border-border bg-surface-2 px-2 py-2","data-testid":"verification-run-verdict",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:a("verification.gates.verdictHeading")}),(0,r.jsx)(ra.E,{variant:rl[t.status],className:"flex-shrink-0",children:a("verification.runStatus.".concat(t.status))}),null!==s&&(0,r.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:a("verification.runs.exitCode",{code:s})})]}),(0,r.jsx)("p",{className:"break-words text-xs text-muted-foreground","data-testid":"verification-run-verdict-gloss",children:a("verification.runStatusGloss.".concat(t.status))}),o.length>0&&(0,r.jsx)("p",{className:"rounded border border-warning-border bg-warning-subtle px-2 py-1 text-xs text-warning-foreground","data-testid":"verification-run-partial",children:a("verification.runs.partial",{ran:i.size,total:n.length,gates:o.join(", ")})}),l.length>0&&(0,r.jsxs)("div",{className:"space-y-0.5 pt-1","data-testid":"verification-run-skip-reasons",children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-foreground",children:a("verification.gates.skipHeading")}),(0,r.jsx)("ul",{className:"space-y-0.5",children:l.map(e=>(0,r.jsx)("li",{className:"break-words text-xs text-muted-foreground",children:a("verification.gates.skipReasonFor",{gateId:e.gateId,reason:a("verification.gates.skipReason.".concat(function(e){let t=null!=e?e:"";return t.includes("skipped: worktreePath is the server process working directory and options.skipInPrimaryCheckout is true.")?"primaryCheckout":t.includes("skipped: the work-evidence gate did not pass.")?"workEvidence":t.includes("skipped: the verification run was cancelled.")?"cancelled":t.includes(rC.mutex)?"mutex":t.includes(rC.detachedContract)?"detachedContract":t.includes(rC.noContract)?"noContract":t.includes(rC.notRequired)?"notRequired":"unknown"}(e.logTail)))})},e.id))})]})]})}function rB(e){var t,n;let{gate:a}=e,s=(0,c.c)("worktree"),l=ro.includes(a.status),[o,d]=(0,i.useState)(null),[u,m]=(0,i.useState)(!1),x=(0,i.useCallback)(()=>m(!1),[]),h=null!=o?o:l,f=(0,tl.aJ)(null!=(t=a.logTail)?t:""),g=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}}(f,40),p=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")}(a.durationMs),b=null!=(n=rN[a.gateId])?n:null;return(0,r.jsxs)("li",{className:"rounded-md border border-border bg-surface p-2","data-testid":"verification-gate-".concat(a.gateId),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(ra.E,{variant:ri[a.status],className:"flex-shrink-0",children:s("verification.gateStatus.".concat(a.status))}),(0,r.jsx)("span",{className:"min-w-0 break-all font-mono text-xs font-medium text-foreground",children:a.gateId}),"contract"===a.source&&(0,r.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground",title:s("verification.gates.contractSourceHint"),children:s("verification.gates.contractSource")}),null!==b&&(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground",children:s("verification.gates.builtinBadge")})]}),null!==b&&(0,r.jsx)("p",{className:"mt-1 break-words text-[11px] text-muted-foreground","data-testid":"verification-gate-about-".concat(a.gateId),children:s("verification.gates.builtin.".concat(b))}),"skipped"===a.status&&(0,r.jsxs)("p",{className:"mt-1 break-words text-[11px] text-muted-foreground","data-testid":"verification-gate-skipped-".concat(a.gateId),children:[s("verification.gateStatus.skipped")," — ",s("verification.gateStatusGloss.skipped")]}),(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!==a.exitCode&&void 0!==a.exitCode&&(0,r.jsx)("span",{children:s("verification.gates.exitCode",{code:a.exitCode})}),p&&(0,r.jsx)("span",{children:s("verification.gates.duration",{duration:p})}),a.command&&(0,r.jsx)("span",{className:"break-all",children:a.command})]}),(0,r.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>d(!h),"aria-expanded":h,"data-testid":"verification-gate-log-toggle-".concat(a.gateId),className:"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:s(h?"verification.gates.hideLog":"verification.gates.showLog")}),""!==f&&(0,r.jsx)("button",{type:"button",onClick:()=>m(!0),"data-testid":"verification-gate-full-log-button-".concat(a.gateId),className:"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:s("verification.gates.showFullLog")})]}),u&&(0,r.jsx)(rF,{gate:a,log:f,onClose:x}),h&&(0,r.jsx)("div",{className:"mt-1","data-testid":"verification-gate-log-".concat(a.gateId),children:0===g.lines.length?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:s("verification.gates.noLog")}):(0,r.jsxs)(r.Fragment,{children:[g.omitted>0&&(0,r.jsx)("p",{className:"mb-1 text-[11px] text-muted-foreground",children:s("verification.gates.logOmitted",{count:g.omitted,runId:a.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:g.lines.join("\n")})]})})]})}let rV=(0,i.memo)(function(e){var t,n;let{state:a,className:s=""}=e,l=(0,c.c)("worktree"),{worktreeId:o,task:d,runs:u,selectedRunId:m,selectedRun:x,loading:h,error:f,detailError:g,detailLoading:p,rerunPending:b,rerunFailure:v,cancelFailure:y,canLoadMore:j,selectRun:w,refresh:k,rerun:N,loadMore:C}=a,S=(0,i.useCallback)(()=>{N()},[N]);return(0,r.jsxs)("div",{className:"flex h-full flex-col overflow-y-auto bg-surface ".concat(s).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)(rn.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:l("verification.title")})]}),(0,r.jsx)("button",{type:"button",onClick:k,"aria-label":l("verification.refresh"),title:l("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)(nn.A,{size:14,"aria-hidden":"true"})})]}),f&&(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:l("verification.loadError",{message:f})}),h?(0,r.jsx)("p",{className:"px-3 py-4 text-xs text-muted-foreground","data-testid":"verification-loading",children:l("verification.loading")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rR,{state:a}),(0,r.jsx)(rI,{heading:l("verification.contract.heading"),testId:"verification-contract-section",children:d?(0,r.jsx)(rE,{task:d}):(0,r.jsx)("p",{className:"whitespace-pre-line text-xs text-muted-foreground","data-testid":"verification-contract-empty",children:l("verification.contract.empty")})}),(0,r.jsxs)(rI,{heading:l("verification.runs.heading"),testId:"verification-runs-section",action:(0,r.jsx)(ei.$,{type:"button",size:"sm",variant:"secondary",onClick:S,disabled:b,"data-testid":"verification-rerun-button",children:l(b?"verification.runs.rerunPending":"verification.runs.rerun")}),children:[v&&(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"===v.kind?null!==v.runningRunId?l("verification.runs.rerunConflict",{runId:v.runningRunId}):l("verification.runs.rerunConflictUnknown"):l("verification.runs.rerunError",{message:v.message})}),y&&(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-runs-cancel-failure",role:"alert",children:"gone"===y.kind?l("verification.runs.cancelGone"):l("verification.runs.cancelError",{message:y.message})}),(0,r.jsx)(rL,{state:a}),(0,r.jsx)(rz,{}),0===u.length?(0,r.jsx)("p",{className:"whitespace-pre-line text-xs text-muted-foreground","data-testid":"verification-runs-empty",children:l("verification.runs.empty",{worktreeId:o})}):(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-runs",children:u.map(e=>(0,r.jsx)(rO,{run:e,selected:e.id===m,onSelect:w},e.id))}),j&&(0,r.jsx)(ei.$,{type:"button",size:"sm",variant:"ghost",onClick:C,className:"mt-1","data-testid":"verification-load-more-button",children:l("verification.runs.loadMore",{count:10})}),(0,r.jsx)(rP,{state:a})]}),null!==m&&(0,r.jsx)(rI,{heading:l("verification.gates.heading",{runId:m}),testId:"verification-gates-section",children:null!==g?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-error",role:"alert",children:"not-found"===g?l("verification.gates.notFound"):l("verification.gates.loadError",{message:g})}):null===x?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-loading",children:l(p?"verification.gates.loading":"verification.gates.empty")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(r_,{run:x,plannedGateIds:null!=(n=null==(t=a.config)?void 0:t.plannedGateIds)?n:[]}),0===x.gates.length?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-empty",children:l("verification.gates.empty")}):(0,r.jsx)("ul",{className:"space-y-1.5","data-testid":"verification-gates",children:x.gates.map(e=>(0,r.jsx)(rB,{gate:e},e.id))}),x.gates.some(e=>"contract"===e.source)&&(0,r.jsx)("p",{className:"mt-2 break-words text-[11px] text-muted-foreground","data-testid":"verification-contract-source-hint",children:l("verification.gates.contractSourceHint")})]})})]})]})});var rU=n(70532),rW=n(46046),rH=n(47972),rK=n(5590),r$=n(25840);class rq extends Error{constructor(e,t,n=[]){super(t),this.name="EnvApiError",this.code=e,this.issues=n}}async function rG(e,t){var n,a,r,s,l,i;let o=await e.json().catch(()=>null);return new rq(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 rJ(e,t){let n="/api/worktrees/".concat(encodeURIComponent(e),"/env");return void 0===t?n:"".concat(n,"?file=").concat(encodeURIComponent(t))}async function rY(e,t){var n,a;let r=await fetch(rJ(e,t),{cache:"no-store"});if(!r.ok)throw await rG(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 rQ(e,t,n){var a;let r=await fetch(rJ(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:t,content:n})});if(!r.ok)throw await rG(r,"Failed to save env file");let s=await r.json();return{file:s.file,issues:null!=(a=s.issues)?a:[]}}let rX=/^[A-Za-z_][A-Za-z0-9_]*$/;function rZ(e){return e.split(/\r\n|\n|\r/)}function r0(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 r1(e){let t=rZ(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(!rX.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]+/,""),x=null,h=l;if(m.startsWith('"')||m.startsWith("'")){x=m[0];let n=m.slice(1),r=r0(n,x,0);for(;-1===r&&e+1<t.length;)e+=1,h=e+1,n+="\n".concat(t[e]),r=r0(n,x,0);if(-1===r){a.push({line:l,code:"unterminated-quote",severity:"error",key:u});continue}let i=n.slice(0,r);s='"'===x?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:h,exported:o,quote:x})}return{entries:n,issues:a}}let r2=/[\s#'"$`\\]/;function r4(e){if(!r2.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 r5(e,t,n){let a=rZ(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(r4(l.value)))}for(let e of(i.length>0&&""===i[i.length-1]&&i.pop(),l))i.push("".concat(e.key,"=").concat(r4(e.value)));return 0===i.length?"":"".concat(i.join("\n"),"\n")}let r3=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/,r6=0;function r8(){return r6+=1,"env-row-".concat(r6)}function r9(e){return e.map(e=>({id:r8(),key:e.key,value:e.value,sourceLine:e.line}))}let r7="••••••••";function se(e){return 0===e.length?"":r7}let st="flex-shrink-0 px-2 opacity-80 transition-opacity hover:opacity-100 [@media(hover:none)]:opacity-100",sn={"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"},sa=(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),[x,h]=(0,i.useState)(null),[f,g]=(0,i.useState)(!1),[p,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)([]),[I,T]=(0,i.useState)(""),[E,A]=(0,i.useState)(new Set),[M,R]=(0,i.useState)(!1),[L,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),h(null),g(!1),rY(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:[];T(i),N(i),S(c),y(r9(c)),w(i),A(new Set),R(!1)}).catch(e=>{var a,r;if(t||D.current!==n)return;let s=e instanceof rq?e:null;h({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,L]);let F=(0,i.useMemo)(()=>"raw"===p?j:r5(k,C,v),[p,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)r3.test(n[e])&&t.push({line:e+1,code:"control-character",severity:"error"});let a=r1(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"===p?j!==I:k!==I||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)}),[p,j,I,k,v,C]),_=(0,i.useCallback)(e=>{if(e!==p){if("raw"===e)w(r5(k,C,v));else{let e=r1(j);N(j),S(e.entries),y(r9(e.entries))}b(e)}},[p,k,C,v,j]),B=(0,i.useCallback)(e=>{s(e),b("kv")},[]),V=(0,i.useCallback)(e=>{w(e),g(!1)},[]),U=(0,i.useCallback)((e,t)=>{y(n=>n.map(n=>n.id===e?{...n,...t}:n)),g(!1)},[]),W=(0,i.useCallback)(e=>{var t,n;let a={id:r8(),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]),g(!1),(null==e?void 0:e.key)&&A(t=>new Set([...t,e.key]))},[]),H=(0,i.useCallback)(e=>{y(t=>t.filter(t=>t.id!==e)),g(!1)},[]),K=(0,i.useCallback)(e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),$=(0,i.useCallback)(()=>R(e=>!e),[]),q=(0,i.useCallback)(()=>{A(new Set(v.map(e=>e.key)))},[v]),G=(0,i.useCallback)(()=>A(new Set),[]),J=(0,i.useCallback)(()=>P(e=>e+1),[]),Y=(0,i.useCallback)(()=>{O.valid&&!u&&(m(!0),h(null),rQ(e,r,F).then(()=>{g(!0),P(e=>e+1)}).catch(e=>{var t,n;let a=e instanceof rq?e:null;h({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:x,saved:f,mode:p,rows:v,rawDraft:j,revealedKeys:E,rawRevealed:M,suggestions:null!=(t=null==l?void 0:l.suggestions)?t:[],issues:O.issues,canSave:O.valid,dirty:z,selectFile:B,setMode:_,setRawDraft:V,updateRow:U,addRow:W,removeRow:H,toggleReveal:K,toggleRawReveal:$,revealAll:q,hideAll:G,reload:J,save:Y}}(t),{mode:l,rows:o,revealedKeys:d,rawRevealed:m}=s,x=(0,i.useMemo)(()=>s.issues.filter(e=>"error"===e.severity),[s.issues]),h=(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)),g=(0,i.useCallback)(()=>{if("raw"===l)return void s.toggleRawReveal();f?s.hideAll():s.revealAll()},[l,f,s]),p=(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(se(l.value)))}return s.join("\n")}(s.rawDraft,r1(s.rawDraft).entries),[l,m,s.rawDraft]),b=(0,i.useCallback)((e,t)=>{var n,s,l;return(0,r.jsx)("li",{children:a(sn[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)(ei.$,{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)(ra.E,{variant:"gray",children:a("envManager.notCreated")}),e.isExample&&(0,r.jsx)(ra.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)(ei.$,{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)(ei.$,{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)(ei.$,{size:"sm",variant:"ghost",onClick:g,"data-testid":"env-toggle-all","aria-pressed":f,className:"min-h-[44px] gap-1.5",children:[f?(0,r.jsx)(rU.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(eI.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)(ei.$,{size:"sm",variant:"ghost",onClick:s.reload,"data-testid":"env-reload","aria-label":a("envManager.reload"),className:"min-h-[44px]",children:(0,r.jsx)(nn.A,{size:16,"aria-hidden":"true"})}),(0,r.jsxs)(ei.$,{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)(rW.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")}),x.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)(au.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:x.map(b)})]}),h.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:h.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)(rK.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)(rK.p,{inputSize:"sm",readOnly:!t,value:t?e.value:se(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)(ei.$,{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(st," min-h-[44px]"),children:t?(0,r.jsx)(rU.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(eI.A,{size:16,"aria-hidden":"true"})}),(0,r.jsx)(ei.$,{size:"sm",variant:"ghost",onClick:()=>s.removeRow(e.id),"aria-label":a("envManager.removeRow",{key:e.key}),"data-testid":"env-row-remove",className:"".concat(st," min-h-[44px] text-danger"),children:(0,r.jsx)(tH.A,{size:16,"aria-hidden":"true"})})]})]},e.id)}),(0,r.jsxs)(ei.$,{size:"sm",variant:"secondary",onClick:()=>s.addRow(),"data-testid":"env-add-row",className:"min-h-[44px] gap-1.5",children:[(0,r.jsx)(ap.A,{size:16,"aria-hidden":"true"}),a("envManager.addRow")]}),s.suggestions.length>0&&(0,r.jsxs)(rH.Zp,{"data-testid":"env-suggestions",className:"mt-3",children:[(0,r.jsxs)(rH.aR,{children:[(0,r.jsx)(rH.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)(rH.Wu,{className:"flex flex-wrap gap-2",children:s.suggestions.map(e=>(0,r.jsxs)(ei.$,{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)(ap.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)(r$.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)(r$.T,{readOnly:!0,value:p,"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:r7})})]})})]})]})}),sr=[{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"}],ss=(0,i.memo)(function(e){var t,n;let{worktreeId:a,className:s="",selectedAgents:l,onSelectedAgentsChange:o,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:x,maxAgents:h,availableAgents:f,persistToServer:g,onInsertToMessage:p,useInstanceManagement:b=!1,instances:v,onInstancesChange:y,visibleInstanceIds:j,onToggleInstanceVisible:w,modelByInstance:k,composerTargetInstanceId:N,verification:C,requestedSubTab:S}=e,I=(0,c.c)("schedule"),[T,E]=(0,i.useState)(null!=(t=null==S?void 0:S.tab)?t:"notes"),A=(0,i.useRef)(null!=(n=null==S?void 0:S.token)?n:null);(0,i.useEffect)(()=>{S&&S.token!==A.current&&(A.current=S.token,E(S.tab))},[S]);let M=(0,i.useCallback)(e=>{E(e)},[]),R=(0,i.useRef)({});return(0,i.useEffect)(()=>{var e,t;null==(t=R.current[T])||null==(e=t.scrollIntoView)||e.call(t,{block:"nearest",inline:"nearest"})},[T]),(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:sr.map(e=>(0,r.jsx)("button",{type:"button",ref:t=>{R.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:I(e.labelKey)},e.id))}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["notes"===T&&(0,r.jsx)(nb,{worktreeId:a,className:"h-full",onInsertToMessage:p}),"logs"===T&&(0,r.jsx)(at,{worktreeId:a,className:"h-full",onInsertToMessage:p,instances:v}),"agent"===T&&(b&&v&&y&&j&&w?(0,r.jsx)("div",{className:"h-full overflow-y-auto",children:(0,r.jsx)(aM,{worktreeId:a,instances:v,onInstancesChange:y,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:x,visibleInstanceIds:j,onToggleInstanceVisible:w,modelByInstance:k,composerTargetInstanceId:N})}):(0,r.jsx)(ai,{worktreeId:a,selectedAgents:l,onSelectedAgentsChange:o,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:x,maxAgents:h,availableAgents:f,persistToServer:g})),"timer"===T&&(0,r.jsx)(a_,{worktreeId:a,instances:v,selectedAgents:l}),"todo"===T&&(0,r.jsx)(nk,{worktreeId:a,className:"h-full"}),"skills"===T&&(0,r.jsx)(re,{worktreeId:a,className:"h-full"}),"verification"===T&&(0,r.jsx)(rV,{state:C,className:"h-full"}),"env"===T&&(0,r.jsx)(sa,{worktreeId:a,className:"h-full"})]})]})});var sl=n(2317);let si=["status","changes","history","advanced"],so="commandmate:gitPane:",sc={activeTab:"".concat(so,"activeTab"),historyOpen:"".concat(so,"historyOpen"),advancedOpen:"".concat(so,"advancedOpen")};function sd(e){return"string"==typeof e&&si.includes(e)}let su=e=>"boolean"==typeof e,sm=i.useLayoutEffect;function sx(e,t,n){return Math.max(8,Math.min(e,n-t-8))}let sh=(0,i.memo)(function(e){var t,n;let{branches:a,busy:s,actionError:l,hasRunningSession:o,isMobile:d,onCheckout:u}=e,x=(0,c.c)("worktree"),h=(0,c.c)("common"),[f,g]=(0,i.useState)(!1),[p,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:sx(r<a.height+4+8&&s>r?n.top-a.height-4:n.bottom+4,a.height,window.innerHeight),left:sx(n.left,a.width,window.innerWidth)})},[]);sm(()=>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 I=(0,i.useCallback)(e=>{y(!1),b({...e}),g(!1)},[]),T=(0,i.useCallback)(()=>{p&&(u(p,v),b(null))},[p,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:()=>g(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":x("git.checkout.ariaLabel"),children:[x("git.checkout.action"),(0,r.jsx)("span",{"aria-hidden":"true",className:"text-[10px]",children:"▾"})]}),f&&"undefined"!=typeof document&&(0,t_.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:x("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:()=>I(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":x("git.checkout.checkoutBranch",{name:e.name}),title:n?x("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:x("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}),p&&(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:[x("git.checkout.confirmTitlePrefix"),(0,r.jsx)("span",{className:"font-mono",children:p.name}),x("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:x("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:x("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"}),x("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:h("cancel")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:T,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:x("git.checkout.action")})]})]})})]})}),sf=(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})]})}),sg=(0,i.createContext)(null);function sp(e){let{value:t,children:n}=e;return(0,r.jsx)(sg.Provider,{value:t,children:n})}function sb(){let e=(0,i.useContext)(sg);if(null===e)throw Error("useGitPaneContext must be used within a GitPaneProvider");return e}let sv=(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})})}),sy={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"},sj={status:"git.tabs.status",changes:"git.tabs.changes",history:"git.tabs.history",advanced:"git.tabs.advanced"},sw=(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:si.map(e=>{let s=e===t,l=a(sj[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)(sv,{path:sy[e]}),(0,r.jsx)("span",{children:l})]},e)})})});function sk(e){let{activeTab:t,onTabChange:n,className:a="",statusSection:s,quickActionsSection:l,changesSection:i,historySection:o,advancedSection:c}=e,{isMobile:d}=sb();return d?(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden ".concat(a),"data-testid":"git-pane-mobile",children:[(0,r.jsx)(sw,{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 sN={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"},sC=(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"})})}),sS=(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)(nN.A,{size:14,"aria-hidden":"true"}),l("git.askAi")]})}),sI=(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})}),sT=(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})}),sE={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"}},sA=(0,i.memo)(function(e){var t;let{gitStatus:n,statusLoading:a,statusError:s,onRefresh:l,refreshing:o=!1}=e,{isMobile:d}=sb(),m=(0,c.c)("worktree"),x=(0,eH.Ym)(),h=(0,i.useMemo)(()=>{let e=null==n?void 0:n.lastFetchAt;if(null==e)return m("git.currentStatus.lastFetchNever");let t=(0,Q.fw)(new Date(e).toISOString(),(0,tG.M)(x));return t?m("git.currentStatus.lastFetch",{relative:t}):m("git.currentStatus.lastFetchNever")},[null==n?void 0:n.lastFetchAt,x,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)(sC,{})})]}),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(sE[f].tooltipKey),children:m(sE[f].badgeKey)})]}),(0,r.jsx)("div",{className:"text-[11px] text-muted-foreground","data-testid":"git-status-last-fetch",title:m("git.currentStatus.lastFetchTooltip"),children:h}),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})]})]})]})]})}),sM=(0,i.memo)(function(e){let{progressState:t,operation:n,error:a,conflict:s,conflictFiles:l,hasUpstream:o,onFetch:d,onPull:m,onPush:x,onAbort:h,extraActions:f}=e,{isMobile:g}=sb(),p=(0,c.c)("worktree"),b="running"===t,v=null!=a?a:p("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:p("git.network.quickActions")}),(0,r.jsxs)("div",{className:"flex items-center ".concat(g?"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:p("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:p("git.network.pull")}),(0,r.jsx)("button",{type:"button",onClick:x,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:p("git.network.noUpstreamTooltip"),children:p("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(g?"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:p("git.network.progress",{operation:p("push"===n?"git.network.pushing":"pull"===n?"git.network.pulling":"git.network.fetching"),elapsed:y})})]}),(0,r.jsx)("button",{type:"button",onClick:h,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:p("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:p("git.network.conflicts",{files:l.join(", ")})})]})}),sR=(0,i.memo)(function(e){let{title:t,testId:n,files:a,actionLabel:s,mode:l,defaultOpen:o,busy:d,onDiff:u,onToggleStage:x,onPreview:h}=e,f=(0,c.c)("worktree"),[g,p]=(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 h(e,l);j(null!=t?t:"")}catch(e){C(f("git.changes.previewFailed"))}finally{k(!1)}},[b,h,l,f]);return(0,r.jsxs)("div",{className:"border-t border-border","data-testid":n,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>p(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:g?"▼":"▶"}),f("git.changes.listHeader",{title:t,count:a.length})]}),g&&0===a.length&&(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:f("git.changes.empty")}),g&&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(sN[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:()=>x(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)(sI,{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))})})]})}),sL=(0,i.memo)(function(e){var t,n,a;let{staged:s,loading:l,error:i,busy:o,commitMessage:d,amend:u,committing:x,commitError:h,onRefresh:f,onDiff:g,onPreview:p,onStage:b,onUnstage:v,onCommitMessageChange:y,onAmendChange:j,onCommit:w,onCommitAndPush:k}=e,{isMobile:N}=sb(),C=(0,c.c)("worktree"),S=null!=(t=null==s?void 0:s.staged)?t:[],I=null!=(n=null==s?void 0:s.unstaged)?n:[],T=null!=(a=null==s?void 0:s.untracked)?a:[],E=!x&&d.trim().length>0&&(S.length>0||u),A=!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)(sC,{})})]}),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)(sR,{title:C("git.changes.staged"),testId:"git-staged-list",files:S,actionLabel:C("git.changes.unstage"),mode:"staged",defaultOpen:A,busy:o,onDiff:g,onPreview:p,onToggleStage:v}),(0,r.jsx)(sR,{title:C("git.changes.unstaged"),testId:"git-unstaged-list",files:I,actionLabel:C("git.changes.stage"),mode:"unstaged",defaultOpen:A,busy:o,onDiff:g,onPreview:p,onToggleStage:b}),(0,r.jsx)(sR,{title:C("git.changes.untracked"),testId:"git-untracked-list",files:T,actionLabel:C("git.changes.stage"),mode:"untracked",defaultOpen:A,busy:o,onDiff:g,onPreview:p,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:!E,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(x?"git.changes.committing":"git.changes.commit")}),(0,r.jsx)("button",{type:"button",onClick:k,disabled:!E||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")})]})]}),h&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-commit-error",children:h})]})]})]})}),sP=(0,i.memo)(function(e){let{commits:t,isLoading:n,commitError:a,commitListOpen:s,onToggleCommitList:l,onRefresh:o,selectedCommit:d,onCommitSelect:m,inlineDiffCommit:x,inlineFiles:h,inlineFilesLoading:f,inlineFilesError:g,onToggleInlineDiff:p,onInlineDiffFile:b,changedFiles:v,isLoadingFiles:y,detailError:j,selectedFile:w,onFileSelect:k,diffContent:N,isLoadingDiff:C}=e,{isMobile:S}=sb(),I=(0,c.c)("worktree"),[T,E]=(0,i.useState)(!0),[A,M]=(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?"▼":"▶"}),I("git.history.title")]}),(0,r.jsx)("button",{type:"button",onClick:o,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":I("git.history.refresh"),children:(0,r.jsx)(sC,{})})]}),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:I("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:I("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=x===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:()=>p(e.hash),className:"shrink-0 px-2 text-xs text-accent-600 dark:text-accent-400 hover:bg-muted hover:underline","aria-label":I("git.history.viewDiffFor",{hash:e.shortHash}),"aria-expanded":t,"data-testid":"git-commit-view-diff-button",children:t?I("git.history.hideDiff"):I("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:I("git.history.loadingChangedFiles")})]}),g&&(0,r.jsx)(sT,{message:g}),!f&&!g&&0===h.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:I("git.history.noChangedFiles")}),!f&&h.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:h.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":I("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(sN[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:()=>E(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:T?"▼":"▶"}),I("git.history.changedFiles")]}),T&&(0,r.jsxs)(r.Fragment,{children:[j&&(0,r.jsx)(sT,{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:I("git.history.loadingChangedFiles")})]}),!y&&!j&&0===v.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:I("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(sN[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:()=>M(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:A?"▼":"▶"}),I("git.history.diffLabel",{file:w})]}),A&&(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:I("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)(sI,{line:e},t))})})}),!C&&!N&&!j&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:I("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?I("git.history.loadingDiff"):I("git.history.diffInFilePanel",{file:w})})]})]})]})});function sD(e){return"`"+e+"`"}let sF={local:"git.branches.filterLocal",remote:"git.branches.filterRemote",all:"git.branches.filterAll"},sO=(0,i.memo)(function(e){let{branches:t,include:n,loading:a,error:s,busy:l,actionError:o,onIncludeChange:d,onRefresh:u,onCreate:x,onDelete:h}=e,{isMobile:f,onInsertToMessage:g}=sb(),p=(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)(""),[I,T]=(0,i.useState)(null),[E,A]=(0,i.useState)(!1),M=(0,i.useCallback)(()=>{0!==k.trim().length&&(x(k.trim(),C.trim()||void 0),w(!1),N(""),S(""))},[k,C,x]),R=(0,i.useCallback)(()=>{I&&(h(I.name,E),T(null),A(!1))},[I,E,h]);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?"▼":"▶"}),p("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:p("git.branches.newButton")}),(0,r.jsx)("button",{type:"button",onClick:u,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":p("git.branches.refresh"),children:(0,r.jsx)(sC,{})})]})]}),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:p(sF[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:p("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:p("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:p("git.branches.defaultBadge")})]}),(0,r.jsx)("button",{type:"button",onClick:()=>{A(!1),T(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":p("git.branches.deleteBranch",{name:e.name}),children:p("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:p("git.branches.createTitle")}),(0,r.jsx)("input",{type:"text",value:k,onChange:e=>N(e.target.value),placeholder:p("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":p("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":p("git.branches.baseLabel"),children:[(0,r.jsx)("option",{value:"",children:p("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:[g&&(0,r.jsx)(sS,{className:"mr-auto",testId:"branch-create-ask-ai",disabled:0===k.trim().length,onClick:()=>{g(function(e,t,n){let a=n&&n.trim().length>0?sD(n.trim()):e("git.aiPrompts.branchCreateBaseHead");return e("git.aiPrompts.branchCreate",{base:a,name:sD(t.trim())})}(p,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:M,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:p("git.branches.create")})]})]})}),I&&(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:[p("git.branches.deleteTitlePrefix"),(0,r.jsx)("span",{className:"font-mono",children:I.name}),p("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:E,onCheckedChange:e=>A(!0===e),"data-testid":"branch-delete-force"}),p("git.branches.forceDeleteLabel")]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[g&&I&&(0,r.jsx)(sS,{className:"mr-auto",testId:"branch-delete-ask-ai",onClick:()=>{g(p(E?"git.aiPrompts.branchDeleteForce":"git.aiPrompts.branchDelete",{name:sD(I.name)})),T(null),A(!1)}}),(0,r.jsx)("button",{type:"button",onClick:()=>T(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:R,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:p("git.branches.delete")})]})]})})]})}),sz=(0,i.memo)(function(e){let{stashes:t,loading:n,error:a,busy:s,actionError:l,conflictNotice:o,hasRunningSession:d,onRefresh:u,onPush:x,onPop:h,onApply:f,onDrop:g}=e,{isMobile:p,onInsertToMessage:b}=sb(),v=(0,c.c)("worktree"),y=(0,c.c)("common"),[j,w]=(0,i.useState)(!p),[k,N]=(0,i.useState)(""),[C,S]=(0,i.useState)(!1),[I,T]=(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)(sS,{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)(sC,{})})]})]}),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)(sS,{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:()=>{x(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:()=>h(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:()=>T(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!==I&&(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@","{",I,"}",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:()=>{g(I),T(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:()=>T(null),className:"px-2 py-1 text-xs rounded border border-input hover:bg-muted",children:y("cancel")})]})]})]})}),s_={soft:"git.danger.modeSoft",mixed:"git.danger.modeMixed",hard:"git.danger.modeHard"},sB=(0,i.memo)(function(e){let{selectedCommit:t,busy:n,actionError:a,conflictNotice:s,currentBranch:l,aheadCount:o,hasRunningSession:d,onReset:u,onRevert:x,onForcePush:h}=e,{isMobile:f,onInsertToMessage:g}=sb(),p=(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)(""),[I,T]=(0,i.useState)(!1),[E,A]=(0,i.useState)(!1),[M,R]=(0,i.useState)(!1),[L,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?"▼":"▶"}),p("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:()=>T(!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:p("git.danger.resetOpen")}),(0,r.jsx)("button",{type:"button",disabled:!t,onClick:()=>A(!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:p("git.danger.revertOpen")}),h&&(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:p("git.danger.forcePushOpen")})]}),!t&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:p("git.danger.selectCommitHint")})]}),I&&(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:p("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"}),p("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"}),p("git.danger.resetTargetSelectedPrefix"),t?p("git.danger.resetTargetSelectedHash",{hash:t.slice(0,7)}):p("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)}),p(s_[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:p("git.danger.resetHardWarning")}),d&&(0,r.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-session-warning",children:p("git.danger.runningSessionWarning")}),(0,r.jsx)("input",{type:"text",value:C,onChange:e=>S(e.target.value),placeholder:p("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:[g&&(0,r.jsx)(sS,{className:"mr-auto",testId:"reset-ask-ai",disabled:z,onClick:()=>{O&&(g("hard"===j?p("git.aiPrompts.resetHard",{target:sD(O)}):p("git.aiPrompts.reset",{target:sD(O),mode:j})),T(!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),T(!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:p("git.danger.reset")}),(0,r.jsx)("button",{type:"button",onClick:()=>{T(!1),S("")},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:b("cancel")})]})]}),E&&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:p("git.danger.revertTitle")}),(0,r.jsxs)("p",{className:"text-xs text-foreground mb-2",children:[p("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:p("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:M,onCheckedChange:e=>R(!0===e),"data-testid":"revert-no-commit"}),p("git.danger.revertNoCommit")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[g&&(0,r.jsx)(sS,{className:"mr-auto",testId:"revert-ask-ai",onClick:()=>{g(p("git.aiPrompts.revert",{commit:sD(t.slice(0,7))})),A(!1),R(!1)}}),(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>{x(t,M),A(!1),R(!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:p("git.danger.revert")}),(0,r.jsx)("button",{type:"button",onClick:()=>{A(!1),R(!1)},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:b("cancel")})]})]}),L&&h&&(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:p("git.danger.forcePushTitle")}),(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-protected-branch-warning",children:p("git.danger.protectedBranchWarning")}),d&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-session-warning",children:p("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"}),p("git.danger.forceWithLease")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[g&&(0,r.jsx)(sS,{className:"mr-auto",testId:"force-push-ask-ai",onClick:()=>{g(function(e,t){let{branch:n,ahead:a}=t,r=n?sD(n):e("git.aiPrompts.forcePushCurrentBranch");return e("number"==typeof a&&a>0?"git.aiPrompts.forcePushAhead":"git.aiPrompts.forcePush",{branchRef:r,upstream:sD("origin/".concat(null!=n?n:"<branch>")),ahead:null!=a?a:0})}(p,{branch:l,ahead:null!=o?o:null})),P(!1)}}),(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>{h(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:p("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")})]})]})]})}),sV=(0,i.memo)(function(e){var t,n,a,s;let{worktreeId:l,onDiffSelect:o,isMobile:d=!1,worktree:u,onInsertToMessage:x,className:h=""}=e,f=(0,c.c)("worktree"),{activeTab:g,setActiveTab:p,historyOpen:b,toggleHistory:v,advancedOpen:y,toggleAdvanced:j}=function(){let{value:e,setValue:t,isAvailable:n}=(0,sl.V)({key:sc.activeTab,defaultValue:"status",validate:sd}),{value:a,setValue:r}=(0,sl.V)({key:sc.historyOpen,defaultValue:!0,validate:su}),{value:s,setValue:l}=(0,sl.V)({key:sc.advancedOpen,defaultValue:!1,validate:su}),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:I,selectedCommit:T,changedFiles:E,inlineDiffCommit:A,inlineFiles:M,inlineFilesLoading:R,inlineFilesError:L,selectedFile:P,diffContent:D,isLoading:F,isLoadingFiles:O,isLoadingDiff:z,commitError:_,detailError:B,setDiffContent:V,fetchCommits:U,handleCommitSelect:W,handleFileSelect:H,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)([]),[x,h]=(0,i.useState)(!1),[f,g]=(0,i.useState)(null),[p,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),[I,T]=(0,i.useState)(null),[E,A]=(0,i.useState)(null),M=(0,i.useCallback)(async()=>{w(!0),T(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/log"));if(!t.ok){let e=await t.json();T(e.error||"Failed to fetch commit history");return}let n=await t.json();a(n.commits)}catch(e){T("Failed to fetch commit history")}finally{w(!1)}},[e]),R=(0,i.useCallback)(async t=>{N(!0),o([]),b(null),y(null),A(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/show/").concat(t));if(!n.ok){let e=await n.json();A(e.error||"Failed to fetch commit details");return}let a=await n.json();o(a.files)}catch(e){A("Failed to fetch commit details")}finally{N(!1)}},[e]),L=(0,i.useCallback)(async(n,a)=>{S(!0),y(null),A(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();A(e.error||"Failed to fetch diff");return}let s=await r.json();y(s.diff),t(s.diff,a)}catch(e){A("Failed to fetch diff")}finally{S(!1)}},[e,t]);(0,i.useEffect)(()=>{M()},[M]);let P=(0,i.useCallback)(e=>{s(e),R(e)},[R]),D=(0,i.useCallback)(e=>{r&&(b(e),L(r,e))},[r,L]),F=(0,i.useCallback)(async t=>{if(c===t){d(null),m([]),g(null);return}d(t),m([]),g(null),h(!0);try{let n=await fetch("/api/worktrees/".concat(e,"/git/show/").concat(t));if(!n.ok){let e=await n.json().catch(()=>({}));g(e.error||"Failed to fetch commit details");return}let a=await n.json();m(Array.isArray(a.files)?a.files:[])}catch(e){g("Failed to fetch commit details")}finally{h(!1)}},[e,c]),O=(0,i.useCallback)((e,t)=>{s(e),b(t),o(u),L(e,t)},[u,L]),z=(0,i.useCallback)(()=>{s(null),o([]),b(null),y(null),A(null),M()},[M]);return{commits:n,selectedCommit:r,changedFiles:l,inlineDiffCommit:c,inlineFiles:u,inlineFilesLoading:x,inlineFilesError:f,selectedFile:p,diffContent:v,isLoading:j,isLoadingFiles:k,isLoadingDiff:C,commitError:I,detailError:E,setDiffContent:y,fetchCommits:M,handleCommitSelect:P,handleFileSelect:D,handleToggleInlineDiff:F,handleInlineDiffFile:O,handleRefresh:z}}(l,o),G=(0,i.useCallback)(async()=>{await U(),await S()},[U,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),[x,h]=(0,i.useState)(""),[f,g]=(0,i.useState)(!1),[p,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:x,amend:f})});if(!t.ok){let e=await t.json().catch(()=>({}));return y(e.error||"Failed to commit"),!1}return h(""),g(!1),await j(),await a(),!0}catch(e){return y("Failed to commit"),!1}},[e,x,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:x,setCommitMessage:h,amend:f,setAmend:g,committing:p,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:ex,branchesLoading:eh,branchesError:ef,branchBusy:eg,branchActionError:ep,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,x]=(0,i.useState)(!1),[h,f]=(0,i.useState)(null),g=(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)(()=>{g(s)},[g,s]);let p=(0,i.useCallback)(e=>{l(e)},[]),b=(0,i.useCallback)(()=>{g(s)},[g,s]),v=(0,i.useCallback)(async(t,a)=>{x(!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(),g(s)])}catch(e){f("Failed to checkout branch")}finally{x(!1)}},[e,s,n,g]),y=(0,i.useCallback)(async(t,n)=>{x(!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 g(s)}catch(e){f("Failed to create branch")}finally{x(!1)}},[e,s,g]),j=(0,i.useCallback)(async(t,n)=>{x(!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 g(s)}catch(e){f("Failed to delete branch")}finally{x(!1)}},[e,s,g]);return{branches:a,branchInclude:s,branchesLoading:o,branchesError:d,branchBusy:m,branchActionError:h,fetchBranches:g,handleBranchIncludeChange:p,handleBranchesRefresh:b,handleCheckout:v,handleBranchCreate:y,handleBranchDelete:j}}(l,{onCheckoutCascade:(0,i.useCallback)(async()=>{await Promise.all([S(),es(),U()])},[S,es,U])}),{stashes:eN,stashLoading:eC,stashError:eS,stashBusy:eI,stashActionError:eT,stashConflictNotice:eE,fetchStash:eA,handleStashPush:eM,handleStashPop:eR,handleStashApply:eL,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,x]=(0,i.useState)(null),[h,f]=(0,i.useState)(null),g=(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)(()=>{g()},[g]);let p=(0,i.useCallback)(async()=>{await Promise.all([g(),n()])},[g,n]),b=(0,i.useCallback)(async(e,t,n)=>{u(!0),x(null),f(null);try{let a=await fetch(e,t),r=await a.json().catch(()=>({}));if(!a.ok)return void x(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 p()}catch(e){x(n)}finally{u(!1)}},[p]),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:h,fetchStash:g,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(ex),U()])},[S,es,eb,ex,U])}),{operation:eB,progressState:eV,error:eU,errorReason:eW,conflict:eH,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,x]=(0,i.useState)(!1),[h,f]=(0,i.useState)([]),g=(0,i.useRef)(null),p=(0,i.useRef)(n);(0,i.useEffect)(()=>{p.current=n},[n]),(0,i.useEffect)(()=>()=>{var e;null==(e=g.current)||e.abort()},[]);let b=(0,i.useCallback)(async(t,n,a)=>{var s,i,o;c(null),u(null),x(!1),f([]),r(t),l("running");let d=new AbortController;g.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)&&(x(!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),g.current=null,null==(o=p.current)||o.call(p,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:h,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=g.current)||e.abort()},[])}}(l,{onCascade:(0,i.useCallback)(e=>{S(),eb(ex),"pull"===e&&(es(),U())},[S,eb,ex,es,U])}),eY="auth_failed"===eW?f("git.network.authFailedGuidance"):"protected_branch"===eW?f("git.danger.protectedBranchWarning"):eU,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]);t7({intervalMs:5e3,enabled:"running"!==eV,onPoll:S});let e1=(0,i.useMemo)(()=>({isMobile:d,onDiffSelect:o,onInsertToMessage:x}),[d,o,x]),e2=(0,r.jsx)(sA,{gitStatus:k,statusLoading:N,statusError:C,onRefresh:eZ,refreshing:"running"===eV}),e4=(0,r.jsx)(sM,{progressState:eV,operation:eB,error:eY,conflict:eH,conflictFiles:eK,hasUpstream:eX,onPull:()=>eq({}),onPush:()=>eG({setUpstream:!eX}),onAbort:eJ,extraActions:(0,r.jsx)(sh,{branches:em,busy:eg||eQ,actionError:ep,hasRunningSession:w,isMobile:d,onCheckout:ej})}),e5=(0,r.jsx)(sL,{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)(sP,{commits:I,isLoading:F,commitError:_,commitListOpen:b,onToggleCommitList:v,onRefresh:q,selectedCommit:T,onCommitSelect:W,inlineDiffCommit:A,inlineFiles:M,inlineFilesLoading:R,inlineFilesError:L,onToggleInlineDiff:K,onInlineDiffFile:$,changedFiles:E,isLoadingFiles:O,detailError:B,selectedFile:P,onFileSelect:H,diffContent:D,isLoadingDiff:z}),e6=(0,r.jsxs)(sf,{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)(sO,{branches:em,include:ex,loading:eh,error:ef,busy:eg||eQ,actionError:ep,onIncludeChange:ev,onRefresh:ey,onCreate:ew,onDelete:ek}),(0,r.jsx)(sz,{stashes:eN,loading:eC,error:eS,busy:eI||eQ,actionError:eT,conflictNotice:eE,hasRunningSession:w,onRefresh:eA,onPush:eM,onPop:eR,onApply:eL,onDrop:eP}),(0,r.jsx)(sB,{selectedCommit:T,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)(sp,{value:e1,children:(0,r.jsx)(sk,{activeTab:g,onTabChange:p,className:h,statusSection:e2,quickActionsSection:e4,changesSection:e5,historySection:e3,advancedSection:e6})})}),sU=(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=sX(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)(sZ,{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")})}),sW=(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:x,onRename:h,onDelete:f,onUpload:g,onMove:p,onFileTreeReset:b,refreshTrigger:v,fileSearch:y,showToast:j,selectedAgents:w,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:S,vibeLocalModel:I,onVibeLocalModelChange:E,vibeLocalContextWindow:A,onVibeLocalContextWindowChange:M,disableAutoFollow:R,historySubTab:L,onHistorySubTabChange:P,onDiffSelect:D,onInsertToMessage:F,showArchived:O,onShowArchivedChange:z,historyDisplayLimit:_,onHistoryDisplayLimitChange:B,historyUserOnly:V,onHistoryUserOnlyChange:U,useInstanceManagement:W,instances:H,onInstancesChange:K,visibleInstanceIds:$,onToggleInstanceVisible:q,verification:G,toolsSubTabRequest:J,onSurfaceModeChange:Y}=e,Q=(0,c.c)("worktree");switch(t){case"terminal":return(0,r.jsx)(T.t,{componentName:"TerminalDisplay",children:(0,r.jsx)(tD,{worktreeId:n,cliToolId:l,instanceId:i,disableAutoFollow:R,onSurfaceModeChange:Y})});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"===L?"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:Q("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"===L?"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:Q("detail.subTabGit")})]}),"message"===L?(0,r.jsx)(T.t,{componentName:"HistoryPane",children:(0,r.jsx)(tF.bl,{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:U})}):(0,r.jsx)(T.t,{componentName:"GitPane",children:(0,r.jsx)(sV,{worktreeId:n,onDiffSelect:D,isMobile:!0,worktree:null!=a?a:void 0,onInsertToMessage:F,className:"flex-1 min-h-0"})})]});case"files":var X;return(0,r.jsx)(T.t,{componentName:"FileTreeView",children:(0,r.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,r.jsx)(nd,{query:y.query,mode:y.mode,isSearching:y.isSearching,error:y.error,onQueryChange:y.setQuery,onModeChange:y.setMode,onClear:y.clearSearch}),(0,r.jsx)(ns,{worktreeId:n,onFileSelect:d,onNewFile:m,onNewDirectory:x,onRename:h,onDelete:f,onUpload:g,onMove:p,onResetView:b,refreshTrigger:v,pollingEnabled:"files"===t,searchQuery:y.query,searchMode:y.mode,searchResults:null==(X=y.results)?void 0:X.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,r.jsx)(T.t,{componentName:"NotesAndLogsPane",children:(0,r.jsx)(ss,{worktreeId:n,className:"h-full",selectedAgents:w,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:S,vibeLocalModel:I,onVibeLocalModelChange:E,vibeLocalContextWindow:A,onVibeLocalContextWindowChange:M,onInsertToMessage:F,useInstanceManagement:W,instances:H,onInstancesChange:K,visibleInstanceIds:$,onToggleInstanceVisible:q,modelByInstance:sQ(null==a?void 0:a.sessionStatusByInstance),composerTargetInstanceId:i,verification:G,requestedSubTab:J})});case"info":return(0,r.jsx)(sU,{worktreeId:n,worktree:a,onWorktreeUpdate:u});default:return null}}),sH="v".concat("0.38.0"),sK=[{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 s$(e,t,n){if(!e)return null;let a=t?"".concat(e," \xb7 ").concat(t):e;return n?"".concat(n," \xb7 ").concat(a):a}function sq(e,t){if(!e||!e.liveness&&!e.degradedReason)return null;let n=t("sse"===e.kind?"agentSource.kindSse":"scraper"===e.kind?"agentSource.kindScraper":"agentSource.kindHooks"),a=void 0===e.degradedReason?null:"port_identity_changed"===e.degradedReason?t("agentSource.reasonPortIdentityChanged"):"heartbeat_stale"===e.degradedReason?t("agentSource.reasonHeartbeatStale"):"not_subscribed"===e.degradedReason?t("agentSource.reasonNotSubscribed"):t("agentSource.reasonOther",{reason:e.degradedReason}),r=["stale"===e.liveness?t("agentSource.livenessStale"):"live"===e.liveness?t("agentSource.livenessLive"):null,a].filter(e=>null!==e).join(" \xb7 ");return r?t("agentSource.line",{kind:n,state:r}):t("agentSource.lineBare",{kind:n})}function sG(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;return"number"==typeof e&&Number.isFinite(e)?new Intl.NumberFormat(t,{style:"currency",currency:"USD",minimumFractionDigits:n,maximumFractionDigits:n}).format(e):null}function sJ(e,t,n,a){var r;let s=sG(null==e?void 0:e.cost,a),l=(r=null==t?void 0:t.tokens,"number"==typeof r&&Number.isFinite(r)?new Intl.NumberFormat(a,{notation:"compact",maximumFractionDigits:1}).format(r):null),i=[];return s&&i.push(s),l&&i.push("number"==typeof(null==t?void 0:t.percent)?n("agentSession.context",{tokens:l,percent:t.percent}):l),i.length>0?i.join(" \xb7 "):null}function sY(e,t,n,a){let r=[];(null==e?void 0:e.title)&&r.push(n("agentSession.titleLabel",{title:e.title})),(null==e?void 0:e.agent)&&r.push(n("agentSession.agentLabel",{agent:e.agent}));let s=sG(null==e?void 0:e.cost,a,4);s&&r.push(n("agentSession.costLabel",{cost:s}));let l=function(e){if(!e)return null;if(null!==e.total)return e.total;let t=[e.input,e.output,e.reasoning,e.cacheRead,e.cacheWrite].filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===t.length?null:t.reduce((e,t)=>e+t,0)}(null==e?void 0:e.tokens);if(null!==l&&r.push(n("agentSession.spentLabel",{tokens:new Intl.NumberFormat(a).format(l)})),"number"==typeof(null==t?void 0:t.tokens)){let e=new Intl.NumberFormat(a).format(t.tokens);r.push("number"==typeof t.limit&&"number"==typeof t.percent?n("agentSession.contextLabel",{tokens:e,limit:new Intl.NumberFormat(a).format(t.limit),percent:t.percent}):n("agentSession.contextUnknownLabel",{tokens:e}))}return r.length>0?r.join("\n"):null}function sQ(e){if(!e)return{};let t={};for(let[n,a]of Object.entries(e)){let e=s$(null==a?void 0:a.model,null==a?void 0:a.reasoningEffort);e&&(t[n]=e)}return t}function sX(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 eG.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 sZ=(0,i.memo)(function(e){var t,n;let{worktreeId:a,worktree:s,cardClassName:l,descriptionEditor:o,showLogs:d,onToggleLogs:u,onWorktreeUpdate:x}=e,{isEditing:h,text:f,setText:g,isSaving:p,handleSave:b,handleCancel:v,startEditing:y}=o,j=(0,c.c)("worktree"),w=(0,c.c)("common"),{copied:k,markCopied:N}=(0,eL.q)(),{copied:C,markCopied:S}=(0,eL.q)(),I=(0,i.useCallback)(async()=>{try{await (0,eN.l)(s.path),N()}catch(e){}},[s.path,N]),T=(0,i.useCallback)(async()=>{try{await (0,eN.l)(s.repositoryPath),S()}catch(e){}},[s.repositoryPath,S]);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:T,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)(ef.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)(ef.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&&x){let t=await e.json();x(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:sK.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")}),!h&&(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")})]}),h?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("textarea",{value:f,onChange:e=>g(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:p,className:"px-4 py-2 bg-accent-600 text-white rounded-lg hover:bg-accent-700 disabled:opacity-50 text-sm font-medium",children:p?j("actions.saving"):j("actions.save")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:v,disabled:p,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)(eX,{version:sH,className:l}),(0,r.jsx)(e3,{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)(eJ,{worktreeId:a})]})]})}),s0=(0,i.memo)(function(e){var t,n,a,s,l;let{worktreeName:o,repositoryName:d,description:u,status:h,gitStatus:g,onBackClick:p,onInfoClick:b,hasUpdate:v,worktreeStatus:y,onWorktreeStatusChange:j,sessionStatusByCli:w,sessionStatusByInstance:k,instances:C,activeInstanceId:S,onActiveInstanceChange:I,onAgentDragStart:T,onAgentDragEnd:E,onKillSession:A,verificationChip:M,agentSessionByInstance:R}=e,L=(0,c.c)("worktree"),P=(0,eH.Ym)(),D=(0,c.c)("common"),F=eK.sb[h],O=F?L(F):void 0,[z,_]=(0,i.useState)(null),B=null==C?void 0:C.find(e=>e.id===S),V=!!S&&null!=(s=null!=(a=null==k||null==(t=k[S])?void 0:t.isRunning)?a:B?null==w||null==(n=w[B.cliTool])?void 0:n.isRunning:void 0)&&s,U=(0,i.useCallback)((e,t)=>{e.dataTransfer.setData(X,t),e.dataTransfer.effectAllowed="move",_(t),null==T||T(t)},[T]),W=(0,i.useCallback)(()=>{_(null),null==E||E()},[E]),H=u?(0,f.W5)(u,50):null,K=(null!=C?C:[]).map(e=>{var t;return{item:e,status:(0,e8.kA)(null!=(t=null==k?void 0:k[e.id])?t:null==w?void 0:w[e.cliTool]),isActive:e.id===S}}),q=(null!=C?C:[]).some(e=>{var t,n;return(null==(t=null!=(n=null==k?void 0:k[e.id])?n:null==w?void 0:w[e.cliTool])?void 0:t.awaitingInstruction)===!0}),Y=!!A&&V,Q=[P,o,d,null!=H?H:"",null!=(l=null==g?void 0:g.currentBranch)?l:"",(null==g?void 0:g.isDirty)?"dirty":"",Y?"end":"",q?"awaiting":"",...K.map(e=>"".concat(e.item.id,":").concat((0,$.sw)(e.item),":").concat(e.status,":").concat(e.isActive?"active":""))].join("\n"),Z=(0,i.useRef)(null),ee=(0,i.useRef)(null),et=function(e,t,n,a,r){let[s,l]=(0,i.useState)(()=>({key:n,pillBudget:4,squeezed:!1})),o=s;return s.key!==n&&l(o={key:n,pillBudget:4,squeezed:!1}),(0,i.useLayoutEffect)(()=>{let e=t.current;e&&!s.squeezed&&function(e){if(e.scrollWidth>e.clientWidth+1)return!0;for(let t of Array.from(e.querySelectorAll("*")))if(!(t.scrollWidth<=t.clientWidth+1)&&"visible"===getComputedStyle(t).overflowX)return!0;return!1}(e)&&l(e=>{if(e.squeezed)return e;let t=Math.min(e.pillBudget,a);return t>0?{...e,pillBudget:t-1}:{...e,squeezed:!0}})},[t,s,a,r]),(0,i.useEffect)(()=>{let t=e.current;if(!t||"undefined"==typeof ResizeObserver)return;let n=null,a=null,r=new ResizeObserver(e=>{var t;let r=null==(t=e[e.length-1])?void 0:t.contentRect;if(!r)return;let s=r.width!==n;(s||r.height!==a)&&(n=r.width,a=r.height,l(e=>s?{key:e.key,pillBudget:4,squeezed:!1}:{...e}))});return r.observe(t),()=>r.disconnect()},[e]),{pillBudget:o.pillBudget,squeezed:o.squeezed}}(Z,ee,Q,K.filter(e$.Lm).length,M);return(0,r.jsxs)("div",{ref:Z,"data-testid":"desktop-header",className:"flex items-center justify-between gap-3 px-4 py-3 bg-surface border-b border-border",children:[(0,r.jsxs)("div",{ref:ee,"data-testid":"desktop-header-identity",className:"flex items-center gap-3 min-w-0".concat(et.squeezed?" overflow-x-clip":""),children:[(0,r.jsxs)("button",{type:"button",onClick:p,className:"flex flex-shrink-0 items-center gap-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":L("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:L("detail.home")})]}),(0,r.jsx)("div",{className:"w-px h-6 flex-shrink-0 bg-border","aria-hidden":"true"}),(0,r.jsx)(x.m,{"data-testid":"desktop-status-indicator",status:h,size:"lg",label:O}),(0,r.jsxs)("div",{className:"flex flex-col min-w-[6rem] shrink-4",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold text-foreground truncate max-w-[200px] leading-tight",children:o}),(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:d}),g&&"(unknown)"!==g.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:g.currentBranch,"data-testid":"desktop-branch-name",children:(0,f.W5)(g.currentBranch,30)}),g.isDirty&&(0,r.jsx)("span",{className:"text-warning",title:L("git.uncommittedChanges"),children:"*"})]}),H&&(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:u,children:H})]})]})]}),M&&(0,r.jsx)("div",{className:"min-w-0 w-[360px] max-w-max",children:M})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0 max-w-full","data-testid":"desktop-header-controls",children:[C&&C.length>0&&(()=>{var e,t,n,a;let s=(0,e$.Uw)(K,et.pillBudget),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;return(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0".concat(et.squeezed?" overflow-x-clip":""),"data-testid":"desktop-agent-status-row",children:[s.map(e=>{var t;if("overflow"===e.slot)return null;let n=e.item,a=(0,$.sw)(n),s=L("detail.statusPill",{label:a,status:D("status.".concat(e.status))}),l=null==k?void 0:k[n.id],i=null==R?void 0:R[n.id],o=s$(null==l?void 0:l.model,null==l?void 0:l.reasoningEffort,null==i||null==(t=i.session)?void 0:t.agent),c=o?L("detail.statusPillWithModel",{label:a,status:D("status.".concat(e.status)),model:o}):s,d=sJ(null==i?void 0:i.session,null==i?void 0:i.context,L,P),u=d?L("detail.statusPillWithUsage",{base:c,usage:d}):c,m=sq(null==l?void 0:l.eventSource,L),h=m?L("detail.statusPillWithSource",{base:u,source:m}):u,f=e.isActive,g={draggable:!0,onDragStart:e=>U(e,n.id),onDragEnd:W},p=z===n.id?" opacity-50 cursor-grabbing":"";return"pill"===e.slot?(0,r.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-".concat(n.id),onClick:()=>null==I?void 0:I(n.id),...g,"aria-label":h,title:h,"aria-pressed":f,className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ".concat(f?"bg-accent-100 dark:bg-accent-900/30 text-accent-900 dark:text-accent-100":"hover:bg-muted text-foreground").concat(p),children:[(0,r.jsx)(x.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:s})]},n.id):(0,r.jsx)(J.m_,{content:h,placement:"bottom",children:(0,r.jsx)("button",{type:"button","data-testid":"desktop-agent-status-".concat(n.id),onClick:()=>null==I?void 0:I(n.id),...g,"aria-label":h,"aria-pressed":f,className:"flex items-center justify-center w-6 h-6 rounded-full transition-colors ".concat(f?"bg-accent-100 dark:bg-accent-900/30":"hover:bg-muted").concat(p),children:(0,r.jsx)(x.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0})})},n.id)}),l.length>0&&(0,r.jsxs)(G.rI,{children:[(0,r.jsx)(G.ty,{asChild:!0,children:(0,r.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-overflow","aria-label":L("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)(x.m,{status:i,size:"sm","aria-hidden":!0,title:void 0}),"+",l.length]})}),(0,r.jsx)(G.SQ,{align:"end",children:l.map(e=>{let t=e.item,n=L("detail.statusPill",{label:(0,$.sw)(t),status:D("status.".concat(e.status))});return(0,r.jsxs)(G._2,{"data-testid":"desktop-agent-overflow-".concat(t.id),onSelect:()=>null==I?void 0:I(t.id),children:[(0,r.jsx)(x.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:n})]},t.id)})})]}),q&&(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:L("awaitingInstruction.label"),children:L("awaitingInstruction.badge")})]})})(),Y&&(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",onClick:A,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":L("terminal.endSession"),"data-testid":"desktop-kill-session",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"✕"}),D("end")]}),j&&(0,r.jsx)("select",{value:null!=y?y:"",onChange:e=>{let t=e.target.value;j(""===t?null:t)},onClick:e=>e.stopPropagation(),className:"flex-shrink-0 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":L("detail.worktreeStatusLabel"),children:sK.map(e=>{var t;return(0,r.jsx)("option",{value:null!=(t=e.value)?t:"",children:L(e.labelKey)},e.labelKey)})}),(0,r.jsx)(e9.g,{}),(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",onClick:b,className:"relative flex flex-shrink-0 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":L("detail.viewInfo"),"data-testid":"desktop-info-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:"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:L("detail.info")}),v&&(0,r.jsx)(N,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":L("tabs.updateAvailable")})]})]})]})}),s1=(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),x=sX(n,l,a,()=>{let e=a&&!m.current;return m.current=a,e});return n?(0,r.jsx)(e6.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)(sZ,{worktreeId:t,worktree:n,cardClassName:"bg-muted rounded-lg p-4",descriptionEditor:x,showLogs:o,onToggleLogs:()=>d(!o),onWorktreeUpdate:l})})}):null}),s2=(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")})]})})}),s4=(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")})]})})});var s5=n(72115);let s3=(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"),[x,h]=(0,i.useState)(a),f=o?a:x,g=(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:x)+e/n*100));o?o(r):h(r)},[a,x,s,l,o]),p=(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:p,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.t,{componentName:"ActivityPane",children:t})}),(0,r.jsx)(s5.f,{onResize:g,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.t,{componentName:"TerminalPane",children:n})})]})})});var s6=n(23570),s8=n(9540),s9=n(92001),s7=n(39332),le=n(16485),lt=n(78192),ln=n(39324),la=n(80298),lr=n(55867);let ls=[{id:"files",labelKey:"activityBar.files",icon:s9.A},{id:"git",labelKey:"activityBar.git",icon:s7.A},{id:"notes",labelKey:"activityBar.notes",icon:B.A},{id:"schedules",labelKey:"activityBar.schedules",icon:le.A},{id:"agent",labelKey:"activityBar.agent",icon:lt.A},{id:"timer",labelKey:"activityBar.timer",icon:ln.A},{id:"todo",labelKey:"activityBar.todo",icon:la.A},{id:"skills",labelKey:"activityBar.skills",icon:nN.A},{id:"verification",labelKey:"activityBar.verification",icon:rn.A},{id:"env",labelKey:"activityBar.env",icon:lr.A}],ll=new Set(ls.map(e=>e.id)),li="files",lo="__closed__";function lc(e){return"".concat("commandmate.worktree.activeActivity-").concat(e)}var ld=n(32916);let lu=(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,ld.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)%ls.length;null==(r=l.current[n])||r.focus();return}if("ArrowUp"===e.key){e.preventDefault();let n=(t-1+ls.length)%ls.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[ls.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)(J.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)(s8.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:ls.map((e,a)=>{let i=e.icon,o=t===e.id,c=s(e.labelKey);return(0,r.jsx)(J.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)})})]})}),lm="worktree-activity-pane",lx={files:"FileTreeView",git:"GitPane",notes:"MemoPane",schedules:"ExecutionLogPane",agent:"AgentInstancesPane",timer:"TimerPane",todo:"TodoPane",skills:"WorktreeSkillsPane",verification:"VerificationPane",env:"EnvManagerPane"},lh=(0,i.memo)(function(e){let{active:t,activities:n,className:a=""}=e;if(null===t)return(0,r.jsx)("div",{id:lm,"data-testid":"activity-pane","data-active":"none",className:"h-full flex flex-col ".concat(a).trim()});let s=n[t],l=lx[t];return(0,r.jsx)("div",{id:lm,"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.t,{componentName:l,children:null!=s?s:null})})});var lf=n(13577),lg=n(72338),lp=n(90088),lb=n(96195),lv=n(56936);let ly=(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.nativeEvent.isComposing||(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)(eC.A,{className:"w-4 h-4"})})]})});var lj=n(40051);function lw(){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 lk=(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)(lw,{})}),lN=(0,o.default)(()=>Promise.resolve().then(n.bind(n,27307)).then(e=>({default:e.PdfPreview})),{loadableGenerated:{webpack:()=>[27307]},ssr:!1,loading:()=>(0,r.jsx)(lw,{})}),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)(lw,{})}),lS=/^---\s*\nmarp:\s*true/;function lI(){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 lT(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 lE(e){let{reason:t}=e;return(0,r.jsxs)("div",{"data-testid":"file-read-only-notice","data-reason-code":t.code,role:"status",className:"flex items-center gap-2 px-3 py-2 bg-warning-subtle border-b border-warning-border text-xs text-warning-foreground",children:[(0,r.jsx)(eS.A,{className:"w-3.5 h-3.5 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:t.message})]})}function lA(e){let{filePath:t,isMaximized:n,onToggleMaximize:a,copyableContent:s,onSearch:l}=e,i=(0,c.c)("worktree"),{copied:o,markCopied:d}=(0,eL.q)(),{copied:u,markCopied:m}=(0,eL.q)(),x=async()=>{try{await (0,eN.l)(t),d()}catch(e){}},h=async()=>{if(s)try{await (0,eN.l)(s),m()}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:x,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":i("actions.copyFilePath"),title:i("actions.copyPath"),children:o?(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)("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":i("actions.searchInFile"),title:i("actions.search"),children:(0,r.jsx)(_.A,{className:"w-3.5 h-3.5"})}),s&&(0,r.jsx)("button",{type:"button",onClick:h,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":i("actions.copyFileContent"),title:i("actions.copyContent"),children:u?(0,r.jsx)(ex.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(eh.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":i(n?"actions.minimize":"actions.maximize"),title:i(n?"actions.minimize":"actions.maximize"),children:n?(0,r.jsx)(H.A,{className:"w-4 h-4"}):(0,r.jsx)(K.A,{className:"w-4 h-4"})})]})]})}function lM(e){var t;let{content:n,extension:a,searchMatches:s,searchCurrentIdx:l,totalLines:o,rangeStart:c,worktreeId:d,filePath:u,onLineRangeFetched:m}=e,x=(0,i.useRef)(null),h=(0,i.useMemo)(()=>n.split("\n"),[n]),f=Math.max(1,null!=c?c:1),g=h.length,p=Math.max(null!=o?o:g,g),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,h.length),l=h.slice(e,t).join("\n"),i="";try{i=eP.A.highlight(l,{language:a,ignoreIllegals:!0}).value}catch(e){i=eP.A.highlightAuto(l).value}s=i.split("\n"),r.set(n,s)}return null!=(t=s[e-500*n])?t:""},[h,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,lb.Te)({count:p,getScrollElement:()=>x.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(p-1,e-1));w.scrollToIndex(t,{align:"center"})},[l,s,w,p]);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;if(o.current.has(d))return;o.current.add(d);let m="/api/worktrees/".concat(n,"/files/").concat((0,eA.o)(a),"?startLine=").concat(d,"&endLine=").concat(u);(0,eG.E)(m).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:g}),(0,r.jsx)("div",{className:"overflow-auto h-full",ref:x,"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<g,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)(lj.E,{className:"h-4 w-3/4"})})]},e.key)})})})}function lR(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 lL(e){let{marpSlides:t,fileName:n,worktreeId:a,filePath:s,contentText:l,onFileSaved:o,isMaximized:d,onToggleMaximize:u,onDirtyChange:m,onOpenFile:x}=e,h=(0,c.c)("worktree"),[f,g]=(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:()=>g("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:h("fileViewer.slides")}),(0,r.jsx)("button",{type:"button",onClick:()=>g("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:h("fileViewer.editor")})]}),(0,r.jsx)(lA,{filePath:s,isMaximized:d,onToggleMaximize:u,copyableContent:l})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:"slides"===f?(0,r.jsx)(lR,{slides:t,fileName:n}):(0,r.jsx)(lC,{worktreeId:a,filePath:s,onSave:o,initialViewMode:"split",onDirtyChange:m,onOpenFile:x})})]})}function lP(e){let{children:t,isMaximized:n,onToggle:a,filePath:s}=e;if(!n)return(0,r.jsx)(r.Fragment,{children:t});let l=(0,r.jsxs)("div",{"data-testid":"maximized-file-overlay",className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:eE.M.MAXIMIZED_EDITOR},children:[(0,r.jsx)(lA,{filePath:s,isMaximized:n,onToggleMaximize:a}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:t})]});return"undefined"==typeof document?l:(0,t_.createPortal)(l,document.body)}function lD(e){let{tab:t,content:n,worktreeId:a,isMaximized:s,onToggleMaximize:l,onFileSaved:i,onDirtyChange:o,onOpenFile:c}=e,d=eR(n.content);return(0,r.jsxs)(r.Fragment,{children:[!s&&(0,r.jsx)(lA,{filePath:t.path,isMaximized:s,onToggleMaximize:l,copyableContent:n.content,onSearch:d.openSearch}),d.searchOpen&&(0,r.jsx)(ly,{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)(lM,{content:n.content,extension:n.extension,searchMatches:d.searchMatches,searchCurrentIdx:d.searchCurrentIdx}):(0,r.jsx)(lC,{worktreeId:a,filePath:t.path,onSave:i,initialViewMode:"preview",onDirtyChange:o,onOpenFile:c})})]})}function lF(e){var t,n;let{tab:a,content:s,worktreeId:l,isMaximized:o,onToggleMaximize:c,onLoadContent:d}=e,u=eR(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]),x=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)(lA,{filePath:a.path,isMaximized:o,onToggleMaximize:c,copyableContent:s.content,onSearch:u.openSearch}),s.readOnly&&s.readOnlyReason&&(0,r.jsx)(lE,{reason:s.readOnlyReason}),u.searchOpen&&(0,r.jsx)(ly,{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)(lM,{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:x?l:void 0,filePath:x?a.path:void 0,onLineRangeFetched:x?m:void 0})})]})}let lO=(0,i.memo)(function(e){var t,n,a,s;let{tab:l,worktreeId:o,onLoadContent:d,onLoadError:u,onSetLoading:m,onFileSaved:x,onDirtyChange:h,onOpenFile:f}=e,g=(0,c.c)("worktree"),p=(0,i.useRef)(g);p.current=g;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,t7({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,eA.o)(l.current)),t={};r.current&&(t["If-Modified-Since"]=r.current);try{let n=await (0,eG.E)(e,{headers:t,timeoutMs:lv.K3,retries:0});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)(()=>h?e=>h(l.path,e):void 0,[h,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 (0,eG.E)("/api/worktrees/".concat(o,"/files/").concat((0,eA.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)||p.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:p.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||!lS.test(C)||C.length>1e6)return void y(null);let e=!1;return(async()=>{try{let t=await (0,eG.E)("/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)(lI,{});if(l.error)return(0,r.jsx)(lT,{error:l.error});if(!l.content)return null;let{content:I}=l;return I.isImage?(0,r.jsx)(lP,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lA,{filePath:l.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(ec.a,{src:I.content,alt:I.path,mimeType:I.mimeType})})]})}):I.isVideo?(0,r.jsx)(lP,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lA,{filePath:l.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(ed.u,{src:I.content,mimeType:I.mimeType})})]})}):I.isPdf?(0,r.jsx)(lP,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lA,{filePath:l.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(lN,{dataUri:I.content,filePath:l.path})})]})}):I.readOnly?(0,r.jsx)(lP,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)(lF,{tab:l,content:I,worktreeId:o,isMaximized:j,onToggleMaximize:N,onLoadContent:d})}):I.isHtml?(0,r.jsx)(lP,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(lA,{filePath:l.path,isMaximized:j,onToggleMaximize:N,copyableContent:I.content}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(lk,{worktreeId:o,filePath:l.path,htmlContent:I.content,onFileSaved:x,onOpenFile:f})})]})}):"md"===I.extension?(0,r.jsx)(lP,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:v?(0,r.jsx)(lL,{marpSlides:v,fileName:l.name,worktreeId:o,filePath:l.path,contentText:I.content,onFileSaved:x,isMaximized:j,onToggleMaximize:N,onDirtyChange:k,onOpenFile:f}):(0,r.jsx)(lD,{tab:l,content:I,worktreeId:o,isMaximized:j,onToggleMaximize:N,onFileSaved:x,onDirtyChange:k,onOpenFile:f})})}):ek("."+I.extension)?(0,r.jsx)(lP,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:(0,r.jsx)(lD,{tab:l,content:I,worktreeId:o,isMaximized:j,onToggleMaximize:N,onFileSaved:x,onDirtyChange:k,onOpenFile:f})})}):(0,r.jsx)(lP,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)(lF,{tab:l,content:I,worktreeId:o,isMaximized:j,onToggleMaximize:N,onLoadContent:d})})}),lz="commandmate:file-tabs:";function l_(e){let t=e.split("/");return t[t.length-1]||e}function lB(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}function lV(e,t,n){if("all"===n)return e.map(e=>e.path);let a=e.findIndex(e=>e.path===t);return -1===a?[]:"others"===n?e.filter((e,t)=>t!==a).map(e=>e.path):e.slice(a+1).map(e=>e.path)}let lU={tabs:[],activeIndex:null};function lW(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 lH=(0,i.memo)(function(e){let{tab:t,isActive:n,onActivate:a,onClose:s,onOpenMenu:l}=e,o=(0,c.c)("worktree"),d=(0,i.useCallback)(()=>{n||a(t.path)},[n,a,t.path]),u=(0,i.useCallback)(e=>{e.stopPropagation(),s(t.path)},[s,t.path]),m=(0,i.useCallback)(e=>{l(e,t.path)},[l,t.path]),x=(0,i.useCallback)(e=>{1===e.button&&(e.preventDefault(),e.stopPropagation(),s(t.path))},[s,t.path]),h=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:d,onAuxClick:x,onContextMenu:m,className:"flex items-center gap-1 px-3 py-2 text-sm font-medium border-b-2 cursor-pointer flex-shrink-0 ".concat(h),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:o("fileTabs.unsavedChanges")}),(0,r.jsx)("button",{type:"button",onClick:u,className:"ml-1 p-0.5 rounded-sm hover:bg-muted transition-colors","aria-label":o("fileTabs.closeTab",{name:t.name}),children:(0,r.jsx)(eC.A,{className:"w-3 h-3"})})]})}),lK=(0,i.memo)(function(e){var t,n,a;let{tabs:s,activeIndex:l,worktreeId:o,onClose:u,onActivate:m,onLoadContent:x,onLoadError:h,onSetLoading:f,onFileSaved:g,onDirtyChange:p,onMoveToFront:b,onOpenFile:v}=e,y=(0,c.c)("worktree"),[j,w]=(0,i.useState)(!1),k=(0,i.useRef)(null),N=(0,i.useRef)(null),C=(0,i.useRef)({x:0,y:0}),[S,I]=(0,i.useState)({x:0,y:0}),{menuState:T,openMenu:E,openMenuAt:A,closeMenu:M}=tz(),[R,L]=(0,i.useState)(null),P=null!==l&&l>=0&&l<s.length?s[l]:null,D=s.length>5?s.slice(0,5):s,F=s.length>5?s.slice(5):[];(0,i.useEffect)(()=>{if(!j)return;let e=e=>{k.current&&!k.current.contains(e.target)&&w(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[j]),(0,i.useLayoutEffect)(()=>{let e=e=>{C.current=e,I(t=>t.x===e.x&&t.y===e.y?t:e)};if(!j)return void e({x:0,y:0});let t=N.current;if(!t)return;let n=t.getBoundingClientRect();e({x:lW(n.left-C.current.x,n.width,window.innerWidth),y:lW(n.top-C.current.y,n.height,window.innerHeight)})},[j]);let O=(0,i.useCallback)(e=>{w(!1),null==b||b(e)},[b]),z=(0,i.useCallback)(()=>{w(e=>!e)},[]),_=(0,i.useCallback)(e=>{for(let t=e.length-1;t>=0;t--)u(e[t])},[u]),B=(0,i.useCallback)((e,t)=>{let n=lV(s,t,e);if(0===n.length)return;let a=new Set(n);if(s.some(e=>e.isDirty&&a.has(e.path)))return void L({mode:e,anchorPath:t});_(n)},[s,_]),V=T.targetPath,U=(0,i.useMemo)(()=>V?[{id:"close-all-tabs",label:y("fileTabs.closeAll"),icon:(0,r.jsx)(lf.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>B("all",V),disabled:0===s.length},{id:"close-other-tabs",label:y("fileTabs.closeOthers"),icon:(0,r.jsx)(lg.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>B("others",V),disabled:0===lV(s,V,"others").length},{id:"close-tabs-to-right",label:y("fileTabs.closeToRight"),icon:(0,r.jsx)(lp.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>B("right",V),disabled:0===lV(s,V,"right").length}]:[],[V,s,B,y]),H=(0,i.useCallback)((e,t)=>{E(e,t,"file")},[E]),K=null!=(a=null!=(n=null==P?void 0:P.path)?n:null==(t=s[0])?void 0:t.path)?a:null,$=(0,i.useCallback)(e=>{if(!K)return;let t=e.currentTarget.getBoundingClientRect();A({x:t.left,y:t.bottom},K,"file")},[K,A]),q=R?lV(s,R.anchorPath,R.mode):[],G=q.filter(e=>{var t;return null==(t=s.find(t=>t.path===e))?void 0:t.isDirty}),J=(0,i.useCallback)(()=>L(null),[]);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:D.map((e,t)=>(0,r.jsx)(lH,{tab:e,isActive:t===l,onActivate:m,onClose:u,onOpenMenu:H},e.path))}),F.length>0&&(0,r.jsxs)("div",{className:"relative flex-shrink-0",ref:k,children:[(0,r.jsxs)("button",{type:"button","data-testid":"tab-dropdown-button",onClick:z,className:"flex items-center gap-0.5 px-2 py-2 text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-muted border-b-2 border-transparent transition-colors",children:[(0,r.jsx)(W.A,{className:"w-3 h-3 transition-transform ".concat(j?"rotate-180":"")}),(0,r.jsxs)("span",{children:["+",F.length]})]}),j&&(0,r.jsx)("div",{ref:N,"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!==S.x||0!==S.y?{transform:"translate(".concat(S.x,"px, ").concat(S.y,"px)")}:void 0,children:F.map(e=>(0,r.jsxs)("button",{type:"button","data-testid":"tab-dropdown-item-".concat(e.path),onClick:()=>O(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))})]}),s.length>0&&(0,r.jsx)("button",{type:"button","data-testid":"tab-actions-button",onClick:$,"aria-haspopup":"menu","aria-expanded":T.isOpen,"aria-label":y("fileTabs.tabActions"),title:y("fileTabs.tabActions"),className:"flex-shrink-0 flex items-center px-2 py-2 text-muted-foreground hover:text-foreground hover:bg-muted border-b-2 border-transparent transition-colors",children:(0,r.jsx)(d.A,{className:"w-4 h-4"})})]}),(0,r.jsx)(tq,{isOpen:T.isOpen,position:T.position,targetPath:T.targetPath,targetType:T.targetType,onClose:M,items:U,ariaLabel:y("fileTabs.tabActions")}),(0,r.jsxs)(e6.a,{isOpen:null!==R,onClose:J,title:y("fileTabs.confirmCloseTitle"),size:"sm",children:[(0,r.jsx)("p",{"data-testid":"file-tabs-close-confirm-body",className:"text-sm text-foreground",children:y("fileTabs.confirmCloseBody",{count:G.length})}),(0,r.jsx)("ul",{className:"mt-2 max-h-32 overflow-y-auto text-sm text-muted-foreground",children:G.map(e=>(0,r.jsx)("li",{className:"truncate",title:e,children:e},e))}),(0,r.jsxs)("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:[(0,r.jsx)(ei.$,{variant:"ghost",size:"sm","data-testid":"file-tabs-close-cancel",onClick:J,children:y("fileTabs.confirmCancel")}),(0,r.jsx)(ei.$,{variant:"secondary",size:"sm","data-testid":"file-tabs-close-keep-unsaved",onClick:()=>{let e=new Set(G);_(q.filter(t=>!e.has(t))),L(null)},children:y("fileTabs.confirmKeepUnsaved")}),(0,r.jsx)(ei.$,{variant:"danger",size:"sm","data-testid":"file-tabs-close-discard",onClick:()=>{_(q),L(null)},children:y("fileTabs.confirmDiscard")})]})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:P&&(0,r.jsx)(lO,{tab:P,worktreeId:o,onLoadContent:x,onLoadError:h,onSetLoading:f,onFileSaved:g,onDirtyChange:p,onOpenFile:v},P.path)})]})}),l$=(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})}),lq=(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)(l$,{line:e},t))})})})]})}),lG="commandmate.worktree.filePanelCollapsed",lJ="worktree-file-panel",lY=(0,i.createContext)({tabCount:0,hasDiff:!1}),lQ="commandmate:filePanelStateChange";function lX(){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(lG);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(lQ,e),()=>window.removeEventListener(lQ,e)},[]);let a=(0,i.useCallback)(e=>{t(e);try{window.localStorage.setItem(lG,String(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(lQ,{detail:{collapsed:e}}))}catch(e){}},[]);return{collapsed:e,toggle:(0,i.useCallback)(()=>{a(!n.current)},[a]),setCollapsed:a}}let lZ=(0,i.memo)(function(e){let{terminal:t,terminalHeader:n,fileTabs:a,worktreeId:s,onCloseTab:l,onActivateTab:o,onLoadContent:c,onLoadError:d,onSetLoading:u,onFileSaved:m,diffContent:x,diffFilePath:h,onCloseDiff:f,onDirtyChange:g,onMoveToFront:p,onOpenFile:b}=e,v=(0,i.useRef)(null),[y,j]=(0,i.useState)(50),{collapsed:w}=lX(),k=(0,i.useCallback)(e=>{let t=v.current;if(!t)return;let n=t.offsetWidth;if(0===n)return;let a=e/n*100;j(e=>Math.min(80,Math.max(20,e+a)))},[]),N=(0,i.useMemo)(()=>({width:"".concat(y,"%")}),[y]),C=(0,i.useMemo)(()=>({width:"".concat(100-y,"%")}),[y]),S=(0,i.useMemo)(()=>({tabCount:a.tabs.length,hasDiff:!!(x&&h)}),[a.tabs.length,x,h]),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&&h?w?(0,r.jsx)(lY.Provider,{value:S,children:(0,r.jsx)("div",{ref:v,className:"flex h-full min-h-0",children:(0,r.jsx)("div",{"data-testid":"terminal-pane",style:{width:"100%"},className:"flex-shrink-0 overflow-hidden",children:I})})}):(0,r.jsx)(lY.Provider,{value:S,children:(0,r.jsxs)("div",{ref:v,className:"flex h-full min-h-0",children:[(0,r.jsx)("div",{"data-testid":"terminal-pane",style:N,className:"flex-shrink-0 overflow-hidden",children:I}),(0,r.jsx)(s5.f,{onResize:k,orientation:"horizontal",ariaValueNow:y}),(0,r.jsx)("div",{id:lJ,"data-testid":"file-panel-pane",style:C,className:"flex-grow overflow-hidden flex",children:(0,r.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:x&&h&&f?(0,r.jsx)(lq,{diff:x,filePath:h,onClose:f}):(0,r.jsx)(lK,{tabs:a.tabs,activeIndex:a.activeIndex,worktreeId:s,onClose:l,onActivate:o,onLoadContent:c,onLoadError:d,onSetLoading:u,onFileSaved:m,onDirtyChange:g,onMoveToFront:p,onOpenFile:b})})})]})}):(0,r.jsx)(lY.Provider,{value:S,children:(0,r.jsx)("div",{className:"h-full",children:I})})});var l0=n(7125),l1=n(22509),l2=n(54485),l4=n(70198);let l5=[.5,.5],l3={splits:[{cliToolId:"claude",instanceId:"claude"}],widths:[1]},l6=new Set($.XH);function l8(e){return"".concat("commandmate:terminalSplits:").concat(e)}function l9(e){return"object"==typeof e&&null!==e}function l7(e){return"number"==typeof e&&Number.isFinite(e)&&e>0}function ie(e){return void 0===e||!!Array.isArray(e)&&2===e.length&&e.every(l7)}function it(e,t){let n=e+t;if(!Number.isFinite(n)||n<=0)return[1,1];let a=Math.min(e,t);return!Number.isFinite(a)||a<=0?[1,1]:[e/a,t/a]}function ia(e){let t=e[0];return t?{splits:[{cliToolId:t.cliTool,instanceId:t.id}],widths:[1]}:{splits:l3.splits.map(e=>({...e})),widths:[...l3.widths]}}function ir(e){let t=e.reduce((e,t)=>e+t,0);return t>0?e.map(e=>e/t):e.map(()=>1/e.length)}function is(e){if(4===e.splits.length)return ie(e.rowHeights)&&void 0!==e.rowHeights?e:{...e,rowHeights:[...l5]};if(void 0===e.rowHeights)return e;let{rowHeights:t,...n}=e;return n}function il(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,4),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?ir(e.widths):l.length<e.widths.length?ir(e.widths.slice(0,l.length)):Array.from({length:l.length},()=>1/l.length),is({...e,splits:l,widths:n}))}function ii(e,t,n){let a=function(e,t){try{let n=window.localStorage.getItem(l8(e));if(!n)return ia(t);let a=JSON.parse(n),r=function(e){if(!l9(e))return null;let{splits:t,widths:n,rowHeights:a}=e;if(!Array.isArray(t)||!Array.isArray(n)||t.length<1||t.length>4||n.length!==t.length)return null;let r=[];for(let e of t){if(!l9(e))return null;let t=e.cliToolId;if("string"!=typeof t||!l6.has(t))return null;let n=e.instanceId,a="string"==typeof n&&(0,$.n6)(n)?n:t;r.push({cliToolId:t,instanceId:a})}for(let e of n)if(!l7(e))return null;let s={splits:r,widths:n};return 4===r.length&&void 0!==a&&ie(a)&&(s.rowHeights=[...a]),s}(a);if(r)return is({...r,widths:ir(r.widths)});return console.warn("[useTerminalSplits] stale state for ".concat(e,"; falling back to default")),ia(t)}catch(n){return console.warn("[useTerminalSplits] failed to parse stored state for ".concat(e,"; using default"),n),ia(t)}}(e,t);return n?il(a,t):a}var io=n(81507);let ic=(0,i.memo)(function(e){var t,n,a,s;let{worktreeId:l,instances:o,rosterReady:d=!0,renderPane:u,onFocusedSplitChange:m,showToast:x,onActiveInstanceChange:h,headerInstanceSelection:f}=e,{splits:g,widths:p,rowHeights:b,setRowHeights:v,addSplit:y,removeSplit:j,setSplitInstance:w,setSplitWidth:k,resetWidths:N,availableInstanceIds:C,focusedSplitIndex:S,setFocusedSplitIndex:I,maximizedIndex:T,toggleMaximize:E}=function(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],[a,r]=(0,i.useState)(()=>ii(e,t,n)),[s,l]=(0,i.useState)(0),[o,c]=(0,i.useState)(null),d=(0,i.useRef)(a);d.current=a;let u=(0,i.useRef)(t);u.current=t;let m=(0,i.useRef)(n);m.current=n;let x=(0,i.useRef)(e);(0,i.useEffect)(()=>{x.current!==e&&(x.current=e,r(ii(e,u.current,m.current)),l(0),c(null))},[e]);let h=(0,i.useMemo)(()=>t.map(e=>"".concat(e.id,":").concat(e.cliTool)).join("|"),[t]);(0,i.useEffect)(()=>{n&&r(e=>il(e,u.current))},[h,n]);let f=(0,i.useRef)(e);(0,i.useEffect)(()=>{if(f.current!==e){f.current=e;return}try{window.localStorage.setItem(l8(e),JSON.stringify(a))}catch(e){}},[a,e]);let g=(0,i.useCallback)(()=>{c(null),r(e=>{if(e.splits.length>=4)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}(u.current,t);if(!n)return e;let a=[...e.splits,{cliToolId:n.cliTool,instanceId:n.id}];if(4===a.length)return is({...e,splits:a,widths:Array.from({length:4},()=>.25)});let r=e.widths.length-1,s=e.widths[r]/2,l=[...e.widths];return l[r]=s,l.push(s),is({...e,splits:a,widths:l})})},[]),p=(0,i.useCallback)(()=>{c(null),r(e=>{if(e.splits.length<=1)return e;let t=e.splits.slice(0,-1),n=ir(e.widths.slice(0,-1));return is({...e,splits:t,widths:n})})},[]);(0,i.useEffect)(()=>{l(e=>{let t=a.splits.length-1;return e>t?t:e<0?0:e}),c(e=>null!==e&&e>a.splits.length-1?null:e)},[a.splits.length]);let b=(0,i.useCallback)((e,t)=>{let n=d.current,a=u.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},[]),v=(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]})},[]),y=(0,i.useCallback)(()=>{c(null),r(e=>{let t=e.splits.length;if(0===t)return e;let n=Array.from({length:t},()=>1/t);return 4===t?{...e,widths:n,rowHeights:[...l5]}:is({...e,widths:n})})},[]),j=(0,i.useCallback)(e=>{r(t=>4!==t.splits.length?t:Array.isArray(e)&&2===e.length&&ie(e)?{...t,rowHeights:[...e]}:t)},[]),w=(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]),k=(0,i.useCallback)(e=>{l(e)},[]),N=(0,i.useMemo)(()=>{var e;return(e=a.rowHeights)&&ie(e)?[...e]:[...l5]},[a.rowHeights]),C=(0,i.useCallback)(e=>{e<0||e>=d.current.splits.length||c(t=>t===e?null:e)},[]);return{splits:a.splits,widths:a.widths,rowHeights:N,setRowHeights:j,addSplit:g,removeSplit:p,setSplitInstance:b,setSplitWidth:v,resetWidths:y,availableInstanceIds:w,focusedSplitIndex:s,setFocusedSplitIndex:k,maximizedIndex:o,toggleMaximize:C}}(l,o,d),A=(0,i.useMemo)(()=>{let e=new Map;for(let t of o)e.set(t.id,t);return e},[o]),M=(0,c.c)("worktree"),{visible:R,toggle:L,setWidth:P}=(0,io.TG)(),{collapsed:D,toggle:F}=lX(),O=!D,z=(0,i.useRef)(null),[_,B]=(0,i.useState)(!1),V=(0,i.useRef)(g.length),[U,W]=(0,i.useState)(null);(0,i.useEffect)(()=>{g.length>V.current&&W(g.length-1),V.current=g.length},[g.length]),(0,i.useEffect)(()=>{null==m||m(S)},[S,m]);let q=(0,i.useRef)(0),G=(0,i.useRef)(g);G.current=g,(0,i.useEffect)(()=>{if(!f||f.token===q.current)return;q.current=f.token;let{instanceId:e}=f,t=G.current.findIndex(t=>t.instanceId===e);if(0!==t){if(t>0)return void I(t);w(0,e)&&I(0)}},[f,w,I]),(0,i.useEffect)(()=>{if(null===U)return;let e=z.current;if(!e)return;let t=e.querySelector('[data-split-index="'.concat(U,'"]'));if(!t)return;let n=t.querySelector("textarea");null==n||n.focus(),I(U),W(null)},[U,I]);let Y=(0,i.useCallback)((e,t)=>{let n=z.current;if(!n)return;let a=n.offsetWidth;if(0===a)return;let r=p.reduce((e,t)=>e+t,0),s=t/a*r,l=[...p],i=l[e]+s,o=l[e+1]-s,c=.05*r;i<c||o<c||(l[e]=i,l[e+1]=o,k(l))},[p,k]),Q=it(null!=(t=p[0])?t:1,null!=(n=p[1])?n:1),X=it(null!=(a=b[0])?a:1,null!=(s=b[1])?s:1),Z=(0,i.useCallback)((e,t)=>{let n=z.current;if(!n)return;let a=n.offsetWidth;if(0===a)return;let r=p[0]+p[1];if(!(r>0))return;let s=t/a*r,l=p[0]+s,i=p[1]-s,o=.05*r;l<o||i<o||k([l,i,l,i])},[p,k]),ee=(0,i.useCallback)((e,t)=>{let n=z.current;if(!n)return;let a=n.offsetHeight;if(0===a)return;let r=b[0]+b[1];if(!(r>0))return;let s=t/a*r,l=b[0]+s,i=b[1]-s,o=.05*r;l<o||i<o||v([l,i])},[b,v]),et=(0,i.useCallback)(()=>B(!0),[]),en=(0,i.useCallback)(()=>B(!1),[]),ea=(0,i.useCallback)(()=>{N(),P(io.sg)},[N,P]),er=g.length<4&&!_,es=g.length>1&&!_,el=g.length>1||R,ei=null!==T,eo=g.length>1,ec=4===g.length,ed=(0,i.useCallback)(()=>{E(null!=T?T:S)},[E,T,S]),eu=M(ei?"terminal.restoreSplits":"terminal.maximizeFocusedSplit"),em="".concat(eu," — ").concat(M("terminal.maximizeShortcutHint")),{tabCount:ex,hasDiff:eh}=(0,i.useContext)(lY),ef=0===ex&&!eh,eg="".concat(M(R?"terminal.hideHistory":"terminal.showHistory")," — ").concat(M("terminal.historyAllSplitsHint")),ep=M(ef?"terminal.filesEmptyHint":O?"terminal.hideFiles":"terminal.showFiles"),eb=(0,i.useMemo)(()=>g.map((e,t)=>(0,io.Ce)(t)).join(" "),[g]),ev=(0,i.useMemo)(()=>g.map((e,t)=>()=>I(t)),[g,I]),ey=(0,i.useMemo)(()=>g.map((e,t)=>e=>w(t,e)),[g,w]),ej=(0,i.useMemo)(()=>g.map((e,t)=>()=>E(t)),[g,E]),ew=(0,i.useMemo)(()=>g.map((e,t)=>e=>{var n,a;let r=(0,$.sw)(null!=(a=A.get(e))?a:{cliTool:"claude",alias:e});if((null==(n=g[t])?void 0:n.instanceId)===e)return;let s=g.findIndex((n,a)=>a!==t&&n.instanceId===e);if(-1!==s){null==x||x("".concat(r," is already in use by split ").concat(s+1),"warning");return}w(t,e)&&(null==h||h(e),null==x||x("Moved ".concat(r," to Split ").concat(t+1),"success"))}),[g,w,x,h,A]);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.jsx)("span",{"data-testid":"split-count-label",className:"text-xs text-muted-foreground tabular-nums mr-1 truncate",children:ei?M("terminal.maximizedStatus",{split:(null!=T?T:0)+1}):"".concat(g.length," / ").concat(4," splits")}),(0,r.jsx)(J.m_,{content:M("terminal.addSplit"),placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:y,disabled:!er,"aria-disabled":!er,"aria-label":M("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)(ap.A,{className:"w-4 h-4","aria-hidden":"true"})})}),(0,r.jsx)(J.m_,{content:M("terminal.removeSplit"),placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:j,disabled:!es,"aria-disabled":!es,"aria-label":M("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)(l0.A,{className:"w-4 h-4","aria-hidden":"true"})})}),(0,r.jsx)(J.m_,{content:M("terminal.equalizeWidthsHint"),placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:ea,disabled:!el,"aria-disabled":!el,"aria-label":M("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)(l1.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})})}),(0,r.jsx)(J.m_,{content:em,placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:ed,disabled:!eo,"aria-disabled":!eo,"aria-pressed":ei,"aria-label":eu,"data-testid":"toggle-maximize-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:ei?(0,r.jsx)(H.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}):(0,r.jsx)(K.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.jsx)(J.m_,{content:eg,placement:"bottom",className:"flex-shrink-0",children:(0,r.jsxs)("button",{type:"button",onClick:L,"aria-pressed":R,"aria-expanded":R,"aria-controls":eb,"aria-label":M(R?"terminal.hideHistory":"terminal.showHistory"),"data-testid":"toggle-history-pane",className:"flex flex-shrink-0 items-center gap-1 whitespace-nowrap text-xs px-2 py-0.5 rounded border transition-colors ".concat(R?"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)(l2.A,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:M("terminal.historyLabel")})]})}),(0,r.jsx)(J.m_,{content:ep,placement:"bottom",className:"flex-shrink-0",children:(0,r.jsxs)("button",{type:"button",onClick:F,disabled:ef,"aria-disabled":ef,"aria-pressed":O,"aria-expanded":O,"aria-controls":lJ,"aria-label":M(O?"terminal.hideFiles":"terminal.showFiles"),"data-testid":"toggle-file-panel",className:"flex flex-shrink-0 items-center gap-1 whitespace-nowrap text-xs px-2 py-0.5 rounded border transition-colors disabled:opacity-40 disabled:cursor-not-allowed ".concat(O?"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)(l4.A,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:M("terminal.filesLabel")}),ex>0&&(0,r.jsx)("span",{"data-testid":"open-files-count",className:"ml-0.5 min-w-[1.25rem] px-1 rounded-full bg-muted text-[10px] leading-4 text-muted-foreground tabular-nums text-center",children:ex})]})})]}),(0,r.jsxs)("div",{ref:z,"data-testid":"terminal-split-layout","data-layout":ec?"grid":"row",className:ec?"grid flex-1 min-h-0 w-full overflow-y-auto":"flex flex-1 min-h-0 w-full",style:ec?{gridTemplateColumns:ei?"1fr":"".concat(Q[0],"fr ").concat(4,"px ").concat(Q[1],"fr"),gridTemplateRows:ei?"1fr":"minmax(".concat(280,"px, ").concat(X[0],"fr) ").concat(4,"px minmax(").concat(280,"px, ").concat(X[1],"fr)")}:void 0,children:[g.map((e,t)=>{var n;let a=t===g.length-1,s=null!==T&&T!==t,l=T===t;return(0,r.jsxs)(i.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"split-wrapper-".concat(t),"data-hidden":s?"true":void 0,style:ec?{gridColumn:l||t%2==0?1:3,gridRow:l||t<2?1:3,minWidth:0,minHeight:0,...s?{display:"none"}:null}:{flexGrow:l?1:null!=(n=p[t])?n:1,flexShrink:1,flexBasis:0,minWidth:0,...s?{display:"none"}:null},className:"h-full",children:u({splitIndex:t,cliToolId:e.cliToolId,instanceId:e.instanceId,instance:A.get(e.instanceId),availableInstances:C(t).map(e=>A.get(e)).filter(e=>void 0!==e),onInstanceChange:ey[t],onFocus:ev[t],isFocused:S===t,onDropInstance:ew[t],isMaximized:l,onToggleMaximize:ej[t]})}),ec||a?null:(0,r.jsx)(id,{resizerIdx:t,hidden:null!==T,ariaValueNow:p.length?p[t]/p.reduce((e,t)=>e+t,0)*100:50,onResize:Y,onStart:et,onEnd:en,onDoubleClick:N})]},"split-".concat(t))}),ec?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(id,{resizerIdx:0,testId:"split-grid-column-resizer",gridArea:{gridColumn:2,gridRow:"1 / span 3"},hidden:ei,ariaValueNow:p[0]/(p[0]+p[1])*100,onResize:Z,onStart:et,onEnd:en,onDoubleClick:N}),(0,r.jsx)(id,{resizerIdx:0,testId:"split-grid-row-resizer",orientation:"vertical",gridArea:{gridColumn:"1 / span 3",gridRow:2},hidden:ei,ariaValueNow:b[0]/(b[0]+b[1])*100,onResize:ee,onStart:et,onEnd:en,onDoubleClick:N})]}):null]})]})});function id(e){let{resizerIdx:t,ariaValueNow:n,onResize:a,onStart:s,onEnd:l,onDoubleClick:o,hidden:c=!1,orientation:d="horizontal",testId:u,gridArea:m}=e,x=(0,i.useCallback)(e=>a(t,e),[t,a]);return(0,r.jsx)("div",{"data-testid":null!=u?u:"split-resizer-".concat(t),style:{...m,...c?{display:"none"}:null},onMouseDownCapture:s,onTouchStartCapture:s,onMouseUpCapture:l,onTouchEndCapture:l,children:(0,r.jsx)(s5.f,{onResize:x,orientation:d,ariaValueNow:n,onDoubleClick:o})})}var iu=n(52771),im=n(88894),ix=n(49509);let ih="BTab",ig=(0,i.memo)(function(e){var t,n;let{worktreeId:a,cliToolId:s,instanceId:l,agentMode:o,sessionStatus:d,isPromptWaiting:u,isSelectionListActive:m,isDismissablePanelActive:x,isUnclassifiedActive:h,onKeysSent:f}=e,g=(0,c.c)("worktree"),p=(0,i.useId)(),{activeKey:b,markPressed:v}=(0,ix.t)(),y=(0,tn.B)(a,s,l,f),j=(0,i.useMemo)(()=>{var e;return"ready"===(e={sessionStatus:d,isPromptWaiting:u,isSelectionListActive:m,isDismissablePanelActive:x,isUnclassifiedActive:h}).sessionStatus&&!e.isPromptWaiting&&!e.isSelectionListActive&&!e.isDismissablePanelActive&&!e.isUnclassifiedActive},[d,u,m,x,h]),w=(0,i.useCallback)(()=>{j&&(v(ih),y([ih]))},[j,v,y]);if(!(s&&iu.AO.includes(s)))return null;let k=(0,iu.PD)(o),N=null!=(n=null==(t=(0,im.h)(s))?void 0:t.noteId)?n:null,C=N?g("agentMode.note.".concat(N)):null,S=N?g("agentMode.noteShort.".concat(N)):null,I=k?g("agentMode.mode.".concat(o)):null;return(0,r.jsxs)("div",{className:"flex items-center gap-1 min-w-0","data-testid":"agent-mode-control",children:[(0,r.jsx)("button",{type:"button",onClick:w,disabled:!j,className:"flex-shrink-0 min-w-[44px] px-2 py-1 rounded-full border text-xs font-medium transition-colors\n disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent\n ".concat(b===ih?"border-accent-500 bg-accent-500 text-white":"border-border text-muted-foreground hover:text-accent-600 hover:border-accent-400 dark:hover:text-accent-400"),"aria-label":k?g("agentMode.cycleFromAria",{mode:I}):g("agentMode.cycleAria"),title:null!=C?C:void 0,"aria-describedby":C?p:void 0,"data-testid":"agent-mode-cycle-button","data-agent-mode":o,"data-enabled":String(j),children:(0,r.jsxs)("span",{className:"flex items-center justify-center gap-1",children:[(0,r.jsx)("span",{children:g("agentMode.label")}),(0,r.jsx)("span",{className:"hidden sm:inline opacity-60",children:"shift+tab"})]})}),k?(0,r.jsx)("span",{className:"min-w-0 truncate px-2 py-1 rounded-full bg-muted text-xs text-muted-foreground","data-testid":"agent-mode-chip","data-agent-mode":o,children:I}):null,C?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{"aria-hidden":"true",title:C,className:"min-w-0 truncate px-2 py-1 rounded-full border border-warning-border bg-warning-subtle text-xs text-warning-foreground","data-testid":"agent-mode-note",children:S}),(0,r.jsx)("span",{id:p,className:"sr-only",children:C})]}):null]})});function ip(e){if(!e)return null;let t=e.decisionId;return"string"==typeof t&&""!==t?t:null}let ib="\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(),iv="bg-accent-600 text-white hover:bg-accent-700 focus:ring-ring",iy="bg-surface border-2 border-input hover:bg-muted text-foreground focus:ring-ring",ij=[/^[^\S\n]*type\s+something\b/i];function iw(e){var t;let{promptData:n,answering:a,onRespond:s,decisionId:l,onDismiss:o,labelId:d,cliToolName:u}=e,x=(0,c.c)("prompt"),[h,f]=(0,i.useState)(()=>{if("multiple_choice"===n.type){var e;let t=n.options.find(e=>e.isDefault);return null!=(e=null==t?void 0:t.number)?e:null}return null}),[g,p]=(0,i.useState)(""),[b,v]=(0,i.useState)(!1),y=(0,i.useMemo)(()=>{var e;return"multiple_choice"!==n.type?null:null!=(e=n.options.find(e=>e.number===h))?e:null},[n,h]),j=null!==y&&!0===(t=y).requiresTextInput&&ij.some(e=>e.test(t.label)),w=a||b,k=(0,i.useCallback)(async e=>{if(!w){v(!0);try{await s(e,l)}catch(e){}finally{v(!1)}}},[w,s,l]),N=(0,i.useCallback)(async()=>{if(!w&&null!==h){v(!0);try{let e=j&&g.trim()?g.trim():h.toString();await s(e,l)}catch(e){}finally{v(!1)}}},[w,s,l,h,j,g]),C=(0,i.useCallback)(async e=>{if(!w&&l){v(!0);try{await s(e,l)}catch(e){}finally{v(!1)}}},[w,s,l]);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:d,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:"?"}),u?x("confirmationFrom",{toolName:u}):x("confirmationFromClaude")]}),o&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:o,"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"})})})]}),(0,I.XF)(n)&&n.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:n.instructionText}),"multiple_choice"===n.type&&n.askUserQuestion&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"ask-user-question-progress",children:n.askUserQuestion.questionCount>1?x("askUserQuestionProgress",{index:n.askUserQuestion.questionIndex+1,total:n.askUserQuestion.questionCount}):x("askUserQuestionSource")}),(0,r.jsx)("p",{className:"text-foreground leading-relaxed",children:(0,I.XF)(n)?n.question:x("unclassifiedTitle")}),w&&(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:x("sending")})]}),"yes_no"===n.type&&(0,r.jsx)(iI,{promptData:n,disabled:w,onYes:()=>k("yes"),onNo:()=>k("no")}),"multiple_choice"===n.type&&(0,r.jsx)(iT,{promptData:n,disabled:w,selectedOption:h,onSelectOption:f,textInputValue:g,onTextInputChange:p,showTextInput:j,onSubmit:N}),!(0,I.XF)(n)&&(0,r.jsx)(ik,{promptData:n,decisionId:l,disabled:w,onRespond:C})]})}function ik(e){var t,n,a,s,l;let{promptData:i,decisionId:o,disabled:d,onRespond:u}=e,m=(0,c.c)("prompt"),x=o&&null!=(n=i.decisionOptions)?n:null,h=function(e){if(null===ip(e)||Array.isArray(e.decisionOptions)&&e.decisionOptions.length>0)return null;let t=e.askUserQuestion;if(!t||"string"!=typeof t.question||""===t.question||!Array.isArray(t.labels)||0===t.labels.length)return null;let n=t.labels.filter(e=>"string"==typeof e&&""!==e);if(n.length!==t.labels.length)return null;let a="number"==typeof t.questionCount?t.questionCount:1;return 1!==a?null:{question:t.question,labels:n,questionCount:a}}(i);return(0,r.jsxs)("div",{className:"space-y-2","data-testid":"unclassified-prompt-notice",children:[i.message&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:i.message}),i.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:i.askUserQuestion.question}),h?(0,r.jsx)(iS,{choices:h,disabled:d,onRespond:u}):(0,r.jsx)("ul",{className:"list-disc list-inside text-sm text-muted-foreground",children:i.askUserQuestion.labels.map(e=>(0,r.jsx)("li",{children:e},e))})]}),h?null:x&&x.length>0?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(iN,{toolName:null!=(a=i.toolName)?a:null,patterns:null!=(s=i.patterns)?s:null,allowAlwaysLabel:null!=(l=null==(t=x.find(e=>"always"===e.reply))?void 0:t.label)?l:null}),(0,r.jsx)(iC,{options:x,disabled:d,onRespond:u})]}):(0,r.jsx)("p",{className:"text-sm text-foreground",children:m("unclassifiedInstruction",{command:m("unclassifiedRespondCommand")})})]})}function iN(e){let{toolName:t,patterns:n,allowAlwaysLabel:a}=e,s=null!==n&&n.length>0;return t||s?(0,r.jsxs)("div",{className:"space-y-1","data-testid":"structured-decision-subject",children:[t&&(0,r.jsx)("p",{className:"text-sm font-medium text-foreground font-mono break-all","data-testid":"structured-decision-tool",children:t}),s&&(0,r.jsxs)("div",{className:"text-xs text-muted-foreground",children:[a&&(0,r.jsx)("span",{"data-testid":"structured-decision-patterns-label",children:a}),(0,r.jsx)("ul",{className:"mt-0.5 flex flex-wrap gap-1","data-testid":"structured-decision-patterns",children:n.map(e=>(0,r.jsx)("li",{className:"font-mono break-all bg-muted border border-border rounded px-1.5 py-0.5",children:e},e))})]})]}):null}function iC(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(ib," ").concat(3===e.number?iy:iv),children:[e.number,". ",e.label]},e.number))})}function iS(e){let{choices:t,disabled:n,onRespond:a}=e,s=(0,c.c)("prompt"),l=(0,i.useId)(),[o,d]=(0,i.useState)(null),u=(0,i.useCallback)(e=>{let t=o===e,a=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(a)},[o,n]);return(0,r.jsxs)("div",{className:"space-y-3","data-testid":"structured-question-actions",children:[(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:s("selectAnOption")}),(0,r.jsx)(m.z6,{name:l,value:null!=o?String(o):"",onValueChange:e=>d(Number(e)),disabled:n,className:"flex flex-col gap-2",children:t.labels.map((e,t)=>(0,r.jsxs)("label",{className:u(t+1),children:[(0,r.jsx)(m.CU,{value:String(t+1),className:"mt-1"}),(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsxs)("span",{className:"font-medium",children:[t+1,". ",e]})})]},"".concat(t+1,"-").concat(e)))})]}),(0,r.jsx)("button",{type:"button","data-testid":"structured-question-submit",onClick:()=>{null!==o&&a(String(o))},disabled:n||null===o,className:"w-full ".concat(ib," ").concat(iv),children:s("submit")})]})}function iI(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(ib," ").concat(iv," ").concat(i?"primary default highlighted":""),u="".concat(ib," ").concat(o?"bg-foreground text-background hover:bg-foreground/90 primary default highlighted":iy);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 iT(e){let{promptData:t,disabled:n,selectedOption:a,onSelectOption:s,textInputValue:l,onTextInputChange:o,showTextInput:d,onSubmit:u}=e,x=(0,i.useId)(),h=(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:h("selectAnOption")}),(0,r.jsx)(m.z6,{name:x,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:h("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(x),className:"sr-only",children:h("customValueInput")}),(0,r.jsx)("input",{id:"text-input-".concat(x),type:"text",value:l,onChange:e=>o(e.target.value),disabled:n,placeholder:h("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(ib," ").concat(iv),children:h("submit")})]})}let iE=(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:x}=A({visible:l&&null!==n,duration:200}),h=(0,i.useId)();if(!m||!n)return null;let f=(t="opacity-100","animate-fade-in"===x?t="opacity-100 transform translate-y-0":"animate-fade-out"===x&&(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(x," ").concat(t));return(0,r.jsx)(T.t,{componentName:"PromptPanel",children:(0,r.jsx)("div",{"data-testid":"prompt-panel",role:"dialog","aria-labelledby":h,"aria-modal":"true",className:f,children:(0,r.jsx)(iw,{promptData:n,answering:o,onRespond:c,decisionId:s,onDismiss:d,labelId:h,cliToolName:u})})})});var iA=n(35619),iM=n(93141);let iR=(0,i.memo)(function(e){var t,n,a;let{worktreeId:s,cliToolId:l,instanceId:o,diff:d,disabled:u=!1}=e,x=(0,c.c)("worktree"),h=(0,m.SC)(),[f,g]=(0,i.useState)(null),[p,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),j=(null==d?void 0:d.revertedMessageId)!=null,w=(0,i.useMemo)(()=>{var e,t;return j?null!=(e=null==d?void 0:d.revertedFiles)?e:[]:null!=(t=null==d?void 0:d.files)?t:[]},[j,d]),k=(0,i.useCallback)(async e=>{b(null),g(e);try{let t=await fetch("/api/worktrees/".concat(s,"/opencode/diff"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,instanceId:null!=o?o:l})}),n=await t.json().catch(()=>({}));if(409===t.status&&"SESSION_BUSY"===n.code)return void b("busy");if(!t.ok)return void b("failed");!1===n.applied&&b("noop")}catch(e){b("failed")}finally{g(null)}},[s,l,o]),N=(0,i.useCallback)(async()=>{await h({title:x("opencodeDiff.revertConfirmTitle"),description:x("opencodeDiff.revertConfirmBody",{count:w.length}),confirmLabel:x("opencodeDiff.revertConfirmLabel"),variant:"danger"})&&await k("revert")},[h,x,w.length,k]),C=(0,i.useCallback)(async()=>{await h({title:x("opencodeDiff.unrevertConfirmTitle"),description:x("opencodeDiff.unrevertConfirmBody",{count:w.length}),confirmLabel:x("opencodeDiff.unrevertConfirmLabel")})&&await k("unrevert")},[h,x,w.length,k]);return"opencode"!==l?null:d&&(d.files.length>0||d.revertedFiles.length>0)?(0,r.jsxs)("div",{className:"border-t border-border bg-muted/30 px-3 py-2 text-xs","data-testid":"opencode-turn-diff-panel",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(iA.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,r.jsx)("span",{className:"font-medium text-foreground",children:j?x("opencodeDiff.revertedTitle"):x("opencodeDiff.title")}),(0,r.jsx)("span",{className:"text-muted-foreground",children:j?x("opencodeDiff.revertedSubtitle",{count:w.length}):x("opencodeDiff.subtitle",{count:w.length})}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-1",children:[null!==f?(0,r.jsx)(m.y$,{size:"sm"}):null,j?(0,r.jsxs)(m.$n,{variant:"ghost",size:"sm",onClick:C,disabled:u||null!==f,children:[(0,r.jsx)(iM.A,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),x("opencodeDiff.unrevert")]}):(0,r.jsxs)(m.$n,{variant:"ghost",size:"sm",onClick:N,disabled:u||null!==f,children:[(0,r.jsx)(na.A,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),x("opencodeDiff.revert")]})]})]}),null!==p?(0,r.jsx)("p",{className:"mt-1 text-danger-foreground",role:"status",children:x("opencodeDiff.".concat(p))}):null,(0,r.jsx)("ul",{className:"mt-1 space-y-0.5",children:w.map((e,t)=>{var n,a;let s=null!=(n=e.file)?n:x("opencodeDiff.unnamedFile"),l=function(e){let t=[];return e.additions>0&&t.push("+".concat(e.additions)),e.deletions>0&&t.push("−".concat(e.deletions)),t.join(" ")}(e);return(0,r.jsxs)("li",{className:"flex items-center gap-2",children:[null!==e.patch&&null!==e.file?(0,r.jsx)("button",{type:"button",className:"truncate text-info underline-offset-2 hover:underline",onClick:()=>y(e),title:x("opencodeDiff.openDiff",{file:s}),children:s}):(0,r.jsx)("span",{className:"truncate text-muted-foreground",children:s}),null!==e.status?(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground",children:x("opencodeDiff.status.".concat(e.status))}):null,""!==l?(0,r.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:l}):null]},"".concat(null!=(a=e.file)?a:"unnamed","-").concat(t))})}),(0,r.jsx)(m.Jh,{isOpen:null!==v,onClose:()=>y(null),title:null!=(t=null==v?void 0:v.file)?t:void 0,size:"xl",children:null!==v?(0,r.jsx)(lq,{diff:null!=(n=v.patch)?n:"",filePath:null!=(a=v.file)?a:"",onClose:()=>y(null)}):null})]}):null});var iL=n(2954);function iP(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 iD=(0,i.memo)(function(e){var t,n,a,s,l,o;let{worktreeId:d,splitIndex:u,cliToolId:m,instanceId:x,instance:h,availableInstances:f,onInstanceChange:g,onFocus:p,disabled:b=!1,pendingInsertText:v,onInsertConsumed:y,onMessageSent:j,cliStatus:w="idle",autoYes:k,history:N,onDropInstance:C,draggedInstanceId:S,onRequestSessionEnd:T,agentModel:E,onAgentSessionChange:A,isMaximized:M=!1,onToggleMaximize:R}=e,L=null!=x?x:m,P=null!=(n=k.enabled)&&n,D=null!=(a=k.expiresAt)?a:null,F=null!=(s=k.lastAutoResponse)?s:null,O=k.onToggle,z=null!=(l=null==N?void 0:N.showArchived)&&l,_=null==N?void 0:N.onShowArchivedChange,B=null==N?void 0:N.historyDisplayLimit,V=null==N?void 0:N.onHistoryDisplayLimitChange,U=null!=(o=null==N?void 0:N.historyUserOnly)&&o,W=null==N?void 0:N.onHistoryUserOnlyChange,H=null==N?void 0:N.onInsertToMessage,K=null==N?void 0:N.onFilePathClick,G=null==N?void 0:N.showToast,Y=(0,c.c)("worktree"),Q=(0,eH.Ym)(),X=(0,i.useMemo)(()=>(0,tE.$2)(d,u),[d,u]),[Z,ee]=(0,i.useState)(q.wf);(0,i.useEffect)(()=>{ee((0,tE.TR)(X))},[X]);let et=(0,i.useCallback)(e=>{ee(e),(0,tE.If)(X,e)},[X]),en=(0,i.useRef)(Z);en.current=Z,(0,i.useEffect)(()=>{function e(e){if(!e.shiftKey||e.altKey||!e.metaKey&&!e.ctrlKey||"m"!==e.key.toLowerCase())return;let t=e.target instanceof Element?e.target:null,n=null==t?void 0:t.closest("[data-split-index]");if(n){if(Number(n.getAttribute("data-split-index"))!==u)return}else if(0!==u||(null==t?void 0:t.closest('input, textarea, select, [contenteditable="true"]')))return;e.preventDefault(),et("chat"===en.current?"terminal":"chat")}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[u,et]);let er=(0,i.useRef)(R);er.current=R,(0,i.useEffect)(()=>{function e(e){if(!e.shiftKey||e.altKey||!e.metaKey&&!e.ctrlKey||"Enter"!==e.key)return;let t=e.target instanceof Element?e.target:null,n=null==t?void 0:t.closest("[data-split-index]");if(n){if(Number(n.getAttribute("data-split-index"))!==u)return}else if(0!==u||(null==t?void 0:t.closest('input, textarea, select, [contenteditable="true"]')))return;let a=er.current;a&&(e.preventDefault(),a())}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[u]);let{terminal:ei,prompt:eo,agentSession:ec,setAutoScroll:ed,setPromptAnswering:eu,clearPrompt:em,refresh:ex}=(0,tf.NK)({worktreeId:d,cliToolId:m,instanceId:L,enabled:!b}),{messages:eh,isLoading:ef,refresh:eg}=(0,tg.Md)({worktreeId:d,cliToolId:m,instanceId:L,limit:B,includeArchived:z,enabled:!b}),ep=(0,i.useCallback)((e,t)=>eG.y.sendMessage(d,e,t),[d]),eb=(0,tb.Fx)(),ev=(0,i.useMemo)(()=>({offline:(0,tb.sV)(eb.signals),reachable:(0,tb._X)(eb.signals)}),[eb.signals]),{messages:ey,sendOptimistic:ej,retry:ew,discard:ek}=(0,tp.v4)({worktreeId:d,serverMessages:eh,sendFn:ep,onSent:eg,connectivity:ev}),{visible:eN,width:eS,toggle:eI,setWidth:eT}=(0,io.TG)(),eE=i.useRef(null),eA=(0,i.useCallback)(e=>{let t=eE.current;if(!t)return;let n=t.offsetWidth;0!==n&&eT(eS+e/n*100)},[eS,eT]),eM="opencode"===m||"copilot"===m,{compactTuiLayoutPadding:eR,preservePaintedPanelRows:eL}=(0,i.useMemo)(()=>(0,tT.EK)(m),[m]),eP=(0,i.useCallback)(e=>ed(e),[ed]),eD=(0,i.useCallback)(e=>{ex(),eg(),null==j||j(e)},[ex,eg,j]),eF=(0,i.useCallback)(e=>{let t=ek(e);t&&(null==H||H(t))},[ek,H]),eO=(0,i.useCallback)(async(e,t)=>{eu(!0);try{let n=t?{decisionId:t,answer:e,cliTool:m,...L&&L!==m?{instanceId:L}:{}}:iP(e,m,(0,I.XF)(eo.data)?eo.data:null,L),a=await fetch(t?"/api/worktrees/".concat(d,"/respond"):"/api/worktrees/".concat(d,"/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));let r=await a.json().catch(()=>null);if((null==r?void 0:r.success)===!1){null==G||G(Y("promptResponse.refused"),"warning"),await ex();return}em(),await ex()}catch(e){console.error("[TerminalSplitPaneContent] prompt response error:",e)}finally{eu(!1)}},[d,m,L,eo.data,eu,em,ex,G,Y]),ez=(0,i.useCallback)(()=>{em()},[em]),e_="chat"===Z,eB=ei.isSelectionListActive,eV=eB&&!e_,eU="running"===ei.sessionStatus,eW=eo.visible&&!P,eK=ip(eo.data),e$=ei.isUnclassifiedActive&&!eB&&!eo.visible&&!e_,eq=tr(ei.composerText),eJ=tu(m,ei.realtimeSnippet||ei.output),eY=(0,i.useMemo)(()=>({messages:ey,worktreeId:d,onFilePathClick:null!=K?K:()=>{},isLoading:ef,className:"h-full",showToast:G,onInsertToMessage:H,onRetryPending:ew,onDiscardPending:eF,showArchived:z,onShowArchivedChange:_,historyDisplayLimit:B,onHistoryDisplayLimitChange:V,historyUserOnly:U,onHistoryUserOnlyChange:W,splitIndex:u,cliToolId:m}),[ey,ew,eF,d,K,ef,G,H,z,_,B,V,U,W,u,m]),eQ=(0,i.useMemo)(()=>(0,r.jsx)(tF.bl,{...eY,onCollapse:eI}),[eY,eI]),eX=(0,i.useMemo)(()=>(0,r.jsx)(te.D,{output:ei.output,isActive:ei.isRunning,attaching:ei.attaching,isThinking:ei.isThinking,autoScroll:ei.autoScroll,onScrollChange:eP,disableAutoFollow:eM,compactTuiLayoutPadding:eR,preservePaintedPanelRows:eL}),[ei.output,ei.isRunning,ei.attaching,ei.isThinking,ei.autoScroll,eP,eM,eR,eL]),eZ=(0,i.useMemo)(()=>(0,r.jsx)("div",{"data-testid":"split-chat-slot-".concat(u),"aria-label":Y("surfaceMode.chatSurfaceLabel"),className:"flex h-full min-h-0 w-full overflow-hidden bg-surface text-surface-foreground",children:(0,r.jsx)("div",{className:"min-w-0 min-h-0 flex-1 overflow-hidden",children:(0,r.jsx)(th.wY,{messages:eY.messages,worktreeId:d,cliToolId:m,instanceId:L,history:eY,live:{isRunning:ei.isRunning,attaching:ei.attaching,sessionStatus:ei.sessionStatus,isThinking:ei.isThinking,isPromptWaiting:eo.visible,promptData:eo.data,isSelectionListActive:ei.isSelectionListActive,isPagerActive:ei.isPagerActive,isDismissablePanelActive:ei.isDismissablePanelActive,isUnclassifiedActive:ei.isUnclassifiedActive},onSurfaceModeChange:et,frame:ei.output,onKeysSent:ex})})}),[eY,u,Y,d,m,L,ei.isRunning,ei.attaching,ei.sessionStatus,ei.isThinking,ei.isSelectionListActive,ei.isPagerActive,ei.isDismissablePanelActive,ei.isUnclassifiedActive,ei.output,ex,eo.visible,eo.data,et]),e0=(0,i.useMemo)(()=>eN?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:(0,tF.Ce)(u),"data-testid":"split-history-slot-".concat(u),"aria-label":"History pane",style:{width:"".concat(eS,"%")},className:"flex-shrink-0 overflow-hidden min-h-0",children:eQ}),(0,r.jsx)(s5.f,{onResize:eA,orientation:"horizontal",ariaValueNow:eS})]}):null,[eN,eS,eQ,eA,u]),e1=(0,i.useMemo)(()=>(0,r.jsxs)("div",{ref:eE,"data-testid":"split-terminal-row-".concat(u),className:"flex h-full min-h-0 w-full",children:[e0,(0,r.jsx)("div",{"data-testid":"split-terminal-slot-".concat(u),style:eN?void 0:{width:"100%"},className:"flex-grow overflow-hidden min-w-0 min-h-0 relative",children:eX})]}),[eN,e0,eX,u]),e2=(0,i.useMemo)(()=>(0,r.jsxs)("div",{ref:eE,"data-testid":"split-chat-row-".concat(u),className:"flex h-full min-h-0 w-full",children:[e0,(0,r.jsx)("div",{"data-testid":"split-chat-output-".concat(u),style:eN?void 0:{width:"100%"},className:"flex-grow overflow-hidden min-w-0 min-h-0",children:eZ})]}),[eN,e0,eZ,u]),e4=(0,i.useMemo)(()=>(0,r.jsxs)("div",{className:"space-y-2","data-testid":"split-footer-".concat(u),children:[eV?(0,r.jsx)(el.y,{worktreeId:d,cliToolId:m,instanceId:L,onKeysSent:ex,showPagerKeys:ei.isPagerActive}):null,e$?(0,r.jsx)(tt.U,{worktreeId:d,cliToolId:m,instanceId:L,onKeysSent:ex}):null,eq?(0,r.jsx)(ts,{worktreeId:d,cliToolId:m,instanceId:L,composerText:ei.composerText,onActionSent:ex}):null,eJ?(0,r.jsx)(tm,{cliToolId:m,frame:ei.realtimeSnippet||ei.output}):null,eW?(0,r.jsx)(iE,{promptData:eo.data,messageId:eo.messageId,decisionId:eK,visible:eo.visible,answering:eo.answering,onRespond:eO,onDismiss:ez,cliToolName:(0,$.oo)(m)}):null,ei.isRunning?(0,r.jsx)(tx.XU,{worktreeId:d,cliToolId:m,instanceId:L,hasAgentSession:null!==ec.session,onKeysSent:ex,collapsible:!0,layout:"desktop"}):null,(0,r.jsx)(iR,{worktreeId:d,cliToolId:m,instanceId:L,diff:ec.diff,disabled:!ei.isRunning}),(0,r.jsx)(es.E,{worktreeId:d,onMessageSent:eD,onOptimisticSend:ej,cliToolId:m,instanceId:L,isSessionRunning:ei.isRunning,pendingInsertText:null!=v?v:null,onInsertConsumed:y,splitIndex:u,onFocus:p,isProcessing:eU,showToast:G,agentModeSlot:(0,r.jsx)(ig,{worktreeId:d,cliToolId:m,instanceId:L,agentMode:ei.agentMode,sessionStatus:ei.sessionStatus,isPromptWaiting:eo.visible,isSelectionListActive:ei.isSelectionListActive,isDismissablePanelActive:ei.isDismissablePanelActive,isUnclassifiedActive:ei.isUnclassifiedActive,onKeysSent:ex}),autoYesSlot:(0,r.jsx)(iL.T,{enabled:P,expiresAt:null!=D?D:null,onToggle:O,lastAutoResponse:null!=F?F:null,cliToolName:m,inline:!0})})]}),[eV,eW,e$,eq,eJ,ei.realtimeSnippet,ei.output,ec.session,ei.composerText,ei.agentMode,ei.sessionStatus,ei.isSelectionListActive,ei.isDismissablePanelActive,ei.isUnclassifiedActive,ei.isPagerActive,d,m,L,ex,eo.data,eo.messageId,eK,eo.visible,eo.answering,eO,ez,eD,ej,ei.isRunning,eU,v,y,u,p,P,D,F,O,G,ec.diff]),e5=(0,$.sw)(null!=h?h:{cliTool:m}),e3=(0,i.useCallback)(()=>{null==T||T({cliToolId:m,instanceId:L,label:e5})},[T,m,L,e5]),e6=(0,i.useMemo)(()=>{if(!T||!ei.isRunning)return null;let e=Y("terminal.endSessionFor",{name:e5});return(0,r.jsx)(J.m_,{content:e,placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:e3,"aria-label":e,"data-testid":"terminal-end-session-button-".concat(u),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)(eC.A,{size:14,"aria-hidden":"true"})})})},[T,ei.isRunning,Y,e5,e3,u]);(0,i.useEffect)(()=>{null==A||A(L,ec)},[A,L,ec]);let e8=s$(E,null,null==(t=ec.session)?void 0:t.agent),e9=sJ(ec.session,ec.context,Y,Q),e7=sY(ec.session,ec.context,Y,Q);return(0,r.jsx)(ea,{worktreeId:d,splitIndex:u,cliToolId:m,instanceId:L,instance:h,availableInstances:f,onInstanceChange:g,headerExtras:e6,status:w,agentModel:e8,agentUsage:e9,agentUsageDetail:e7,onFocus:p,attaching:ei.attaching,surfaceMode:Z,onSurfaceModeChange:et,isMaximized:M,onToggleMaximize:R,terminal:"chat"===Z?e2:e1,footer:e4,onDropInstance:C,draggedInstanceId:S})}),iF=(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,m]=(0,i.useState)(!1),x=(0,i.useRef)(null),h=(0,i.useId)(),f=function(e,t){var n;let a=(0,i.useRef)(null);return(null!==e&&t&&t.length>0&&(a.current={runId:e.id,gates:t}),t&&t.length>0)?t:null!==e&&(null==(n=a.current)?void 0:n.runId)===e.id?a.current.gates:null}(a,s),g=(0,i.useMemo)(()=>{let e=[n?d("verification.chip.taskReason",{title:n.title,status:d("task.status.".concat(n.status))}):d("verification.chip.noTask")];if(a){if(e.push(d("verification.chip.runReason",{verdict:d("verification.runStatus.".concat(a.status)),runId:a.id})),e.push(d("verification.runStatusGloss.".concat(a.status))),f&&f.length>0){let t=f.filter(e=>ro.includes(e.status));e.push(t.length>0?d("verification.chip.failingGates",{gates:t.map(e=>e.gateId).join(", ")}):d("verification.chip.gatesPassed",{count:f.length}))}}else e.push(d("verification.chip.noRun"));return e.push(d("verification.chip.openHint")),e},[n,a,f,d]),p=g.join(" \xb7 "),b=(0,i.useCallback)(()=>{m(!1),l()},[l]),v=(0,i.useCallback)(()=>{m(e=>!e)},[]);return(0,i.useEffect)(()=>{if(!u)return;let e=e=>{var t;null!=(t=x.current)&&t.contains(e.target)||m(!1)},t=e=>{"Escape"===e.key&&m(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[u]),(0,r.jsxs)("div",{ref:x,className:"relative inline-flex max-w-full ".concat(o).trim(),children:[(0,r.jsxs)("div",{className:"inline-flex min-w-0 max-w-full grow items-center gap-1 rounded-full border border-border bg-surface-2 pr-1 text-xs text-foreground",children:[(0,r.jsxs)("button",{type:"button",onClick:b,"data-testid":"verification-status-chip","aria-label":p,title:p,className:"inline-flex min-w-0 flex-1 items-center gap-1.5 rounded-full px-2 py-1 transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation",children:[(0,r.jsx)(rn.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:n?(t=n.title,t.length<=36?t:"".concat(t.slice(0,35),"…")):d("verification.title")}),n&&(0,r.jsx)(ra.E,{variant:rs[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)(ra.E,{variant:a?rl[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.unverified")})]}),(0,r.jsx)("button",{type:"button",onClick:v,"data-testid":"verification-chip-reason-toggle","aria-expanded":u,"aria-controls":h,"aria-label":d(u?"verification.chip.hideReason":"verification.chip.showReason"),className:"inline-flex min-h-[32px] min-w-[32px] flex-shrink-0 items-center justify-center rounded-full 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)(k.A,{size:14,"aria-hidden":"true"})})]}),u&&(0,r.jsxs)("div",{id:h,role:"tooltip","data-testid":"verification-chip-reason-popover",className:"absolute left-0 top-full z-50 mt-1 w-72 max-w-[80vw] rounded-lg border border-border bg-surface p-3 text-xs leading-relaxed text-foreground shadow-lg",children:[(0,r.jsx)("p",{className:"mb-1 font-semibold",children:d("verification.chip.reasonHeading")}),(0,r.jsx)("ul",{className:"space-y-1",children:g.map(e=>(0,r.jsx)("li",{className:"break-words",children:e},e))})]})]})}),iO=(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)(au.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)(eC.A,{className:"w-4 h-4"})})]})});var iz=n(58734);let i_=(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"),[x,h]=(0,i.useState)(""),[f,g]=(0,i.useState)(new Set([""])),[p,b]=(0,i.useState)([]),[v,y]=(0,i.useState)(!1),[w,k]=(0,i.useState)(new Set),N=l.includes("/")?l.substring(0,l.lastIndexOf("/")):"";(0,i.useEffect)(()=>{t&&(h(N),g(new Set([""])),b([]),C())},[t,s]);let C=(0,i.useCallback)(async()=>{y(!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{y(!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]),I=(0,i.useCallback)(async e=>{g(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}(p,e);t&&!t.loaded&&await S(e)},[p,S]),T=(0,i.useCallback)(e=>!(e===N||"directory"===o&&(e===l||e.startsWith(l+"/")))&&!0,[N,l,o]),E=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=f.has(e.path),a=x===e.path,s=w.has(e.path),l=T(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&&h(e.path)},children:[(0,r.jsx)("button",{className:"w-4 h-4 flex items-center justify-center flex-shrink-0",onClick:t=>{t.stopPropagation(),I(e.path)},children:s?(0,r.jsx)(m.y$,{size:"xs",variant:"muted"}):(0,r.jsx)(ab.A,{className:"w-3 h-3 text-muted-foreground transition-transform ".concat(n?"rotate-90":"")})}),n?(0,r.jsx)(iz.A,{className:"w-4 h-4 text-warning flex-shrink-0"}):(0,r.jsx)(j.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=>E(e,t+1))})]},e.path)},A=T(x);return(0,r.jsx)(e6.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(""===x?"bg-accent-100 text-accent-800":"hover:bg-muted text-foreground"," ").concat(T("")?"":"opacity-40 cursor-not-allowed"),onClick:()=>{T("")&&h("")},children:[(0,r.jsx)("span",{className:"w-4 h-4"}),(0,r.jsx)(j.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"})}):p.map(e=>E(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(x),disabled:!A,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 iB(e,t){let n=e.trim();return n?0>=n.lastIndexOf(".")?n+t:n:""}let iV=(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,x]=(0,i.useState)(".md"),h=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(t){u(""),x(".md");let e=setTimeout(()=>{var e;null==(e=h.current)||e.focus()},100);return()=>clearTimeout(e)}},[t]);let f=(0,i.useCallback)(()=>{let e=iB(d,m);e&&a(e)},[d,m,a]),g=(0,i.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),f())},[f]),p=iB(d,m),b=n?"".concat(n,"/").concat(p):p;return(0,r.jsx)(e6.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:h,id:"new-file-name","data-testid":"new-file-name-input",type:"text",value:d,onChange:e=>u(e.target.value),onKeyDown:g,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=>x(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:ew.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),p&&(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:!p,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")})]})]})})}),iU=(0,i.memo)(function(e){var t,n,a,s,l;let{worktreeId:o,worktree:d,worktreeName:u,worktreeStatus:m,instances:x,rosterReady:h,activeInstanceId:f,setActiveInstanceId:g,hasUpdate:p,lastAutoResponse:b,activeActivity:v,onActivityToggle:y,onActivityOpen:j,verification:w,onBackClick:k,onInfoClick:N,onWorktreeStatusChange:C,pendingInsertTextMap:S,setFocusedSplitIndex:I,handleInsertToSplit:E,handleInsertConsumed:A,handleInsertToMessage:M,autoYesStateMap:R,makeAutoYesToggleHandler:L,showArchived:P,onShowArchivedChange:D,historyDisplayLimit:F,onHistoryDisplayLimitChange:O,historyUserOnly:z,onHistoryUserOnlyChange:_,onMessageSent:B,onFilePathClick:V,showToast:U,tabsState:W,tabsActions:H,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:ex,vibeLocalContextWindow:eh,onVibeLocalContextWindowChange:ef,isInfoModalOpen:eg,onInfoModalClose:ep,onWorktreeUpdate:eb,fileInputRef:ev,onFileInputChange:ey,onKillSession:ew,onRequestSessionEnd:ek,killTarget:eN,isKillPending:eC,onKillCancel:eS,onKillConfirm:eI,moveTarget:eT,isMoveDialogOpen:eE,onMoveCancel:eA,onMoveConfirm:eM,showNewFileDialog:eR,newFileParentPath:eL,onNewFileConfirm:eP,onNewFileCancel:eD,killDialogTitle:eF,killDialogWarning:eO,cancelLabel:ez,endLabel:e_}=e,eB=(0,c.c)("worktree"),[eV,eU]=i.useState(null),eW=(0,i.useCallback)(e=>eU(e),[]),eH=(0,i.useCallback)(()=>eU(null),[]),eK=(0,i.useMemo)(()=>sQ(null==d?void 0:d.sessionStatusByInstance),[null==d?void 0:d.sessionStatusByInstance]),[e$,eq]=(0,i.useState)({}),eG=(0,i.useCallback)((e,t)=>{eq(n=>n[e]===t?n:{...n,[e]:t})},[]),[eJ,eY]=i.useState(null),eQ=i.useRef(0),eX=(0,i.useCallback)(e=>{g(e),eQ.current+=1,eY({instanceId:e,token:eQ.current})},[g]),eZ=(0,i.useCallback)(()=>{j("verification")},[j]),e0=(0,i.useCallback)(e=>{var t,n,a,s,l,i,c,u,m,x;let{splitIndex:h,cliToolId:f,instanceId:p,instance:v,availableInstances:y,onInstanceChange:j,onFocus:w,onDropInstance:k,isMaximized:N,onToggleMaximize:C}=e,I=null!=(c=S.get(h))?c:null,T=R.get(p),M=null!=(u=null==T?void 0:T.enabled)&&u,W=null!=(m=null==T?void 0:T.expiresAt)?m:null,H=(0,e8.kA)(null!=(x=null==d||null==(t=d.sessionStatusByInstance)?void 0:t[p])?x:null==d||null==(n=d.sessionStatusByCli)?void 0:n[f]);return(0,r.jsx)(iD,{worktreeId:o,splitIndex:h,cliToolId:f,instanceId:p,instance:v,availableInstances:y,onInstanceChange:e=>{j(e),0===h&&g(e)},onFocus:w,pendingInsertText:I,onInsertConsumed:()=>A(h),onMessageSent:B,cliStatus:H,onAgentSessionChange:eG,agentModel:s$(null==d||null==(s=d.sessionStatusByInstance)||null==(a=s[p])?void 0:a.model,null==d||null==(i=d.sessionStatusByInstance)||null==(l=i[p])?void 0:l.reasoningEffort),autoYes:{enabled:M,expiresAt:W,lastAutoResponse:b,onToggle:L(f,p)},history:{showArchived:P,onShowArchivedChange:D,historyDisplayLimit:F,onHistoryDisplayLimitChange:O,historyUserOnly:z,onHistoryUserOnlyChange:_,onInsertToMessage:e=>E(h,e),onFilePathClick:V,showToast:U},onDropInstance:k,draggedInstanceId:eV,isMaximized:N,onToggleMaximize:C,onRequestSessionEnd:ek})},[o,S,R,A,B,g,b,L,null==d?void 0:d.sessionStatusByCli,null==d?void 0:d.sessionStatusByInstance,V,U,E,P,D,F,O,z,_,eV,ek,eG]),e1=(0,i.useMemo)(()=>(0,r.jsx)(ic,{worktreeId:o,instances:x,rosterReady:h,renderPane:e0,onFocusedSplitChange:I,showToast:U,onActiveInstanceChange:g,headerInstanceSelection:eJ}),[o,x,h,e0,I,U,g,eJ]),e2=(0,i.useMemo)(()=>(0,r.jsx)(lZ,{terminal:e1,terminalHeader:null,fileTabs:W,worktreeId:o,onCloseTab:H.closeTab,onActivateTab:H.activateTab,onLoadContent:K,onLoadError:$,onSetLoading:q,onFileSaved:G,diffContent:Q,diffFilePath:X,onCloseDiff:Z,onDirtyChange:J,onMoveToFront:H.moveToFront,onOpenFile:Y}),[e1,W,o,H.closeTab,H.activateTab,K,$,q,G,Q,X,Z,J,H.moveToFront,Y]),e4=(0,i.useMemo)(()=>(0,r.jsx)(lu,{active:v,onToggle:y}),[v,y]),e5=(0,i.useMemo)(()=>{var e;return{files:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(nd,{query:ee.query,mode:ee.mode,isSearching:ee.isSearching,error:ee.error,onQueryChange:ee.setQuery,onModeChange:ee.setMode,onClear:ee.clearSearch}),(0,r.jsx)(ns,{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)(sV,{worktreeId:o,onDiffSelect:ed,isMobile:!1,worktree:null!=d?d:void 0,onInsertToMessage:M,className:"h-full"}),notes:(0,r.jsx)(nb,{worktreeId:o,className:"h-full",onInsertToMessage:M}),schedules:(0,r.jsx)(at,{worktreeId:o,className:"h-full",onInsertToMessage:M,instances:x}),agent:(0,r.jsx)(aA,{worktreeId:o,instances:x,onInstancesChange:eu,vibeLocalModel:em,onVibeLocalModelChange:ex,vibeLocalContextWindow:eh,onVibeLocalContextWindowChange:ef,modelByInstance:eK,className:"h-full"}),timer:(0,r.jsx)(a_,{worktreeId:o,instances:x}),todo:(0,r.jsx)(nk,{worktreeId:o,className:"h-full"}),skills:(0,r.jsx)(re,{worktreeId:o,className:"h-full"}),verification:(0,r.jsx)(rV,{state:w,className:"h-full"}),env:(0,r.jsx)(sa,{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,M,x,eu,em,ex,eh,ef,eK,w]),e3=(0,i.useMemo)(()=>null===v?null:(0,r.jsx)(lh,{active:v,activities:e5}),[v,e5]);return(0,r.jsx)(T.t,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"flex h-full overflow-hidden relative",children:[e4,(0,r.jsxs)("div",{className:"flex flex-col flex-1 min-h-0 min-w-0",children:[(0,r.jsx)(s0,{worktreeName:u,repositoryName:null!=(s=null!=(a=null==d?void 0:d.repositoryDisplayName)?a:null==d?void 0:d.repositoryName)?s:eB("detail.unknownRepository"),description:null==d?void 0:d.description,status:m,gitStatus:null==d?void 0:d.gitStatus,onBackClick:k,onInfoClick:N,hasUpdate:p,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:x,activeInstanceId:f,onActiveInstanceChange:eX,onAgentDragStart:eW,onAgentDragEnd:eH,onKillSession:ew,agentSessionByInstance:e$,verificationChip:(0,r.jsx)(iF,{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:eZ})}),(null==d?void 0:d.gitStatus)&&(0,r.jsx)(iO,{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)(s3,{activityPane:e3,rightPane:(0,r.jsx)(s6.cV,{terminal:e2})})})]}),(0,r.jsx)(s1,{worktreeId:o,worktree:d,isOpen:eg,onClose:ep,onWorktreeUpdate:eb}),(0,r.jsx)("input",{ref:ev,type:"file",accept:ej.join(","),onChange:ey,className:"hidden","aria-label":eB("detail.uploadFile")}),(0,r.jsx)(e6.a,{isOpen:null!==eN,onClose:eS,title:eF,size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:eO}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:eS,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:ez}),(0,r.jsx)("button",{type:"button",onClick:eI,disabled:eC,"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:e_})]})]})}),eT&&(0,r.jsx)(i_,{isOpen:eE,onClose:eA,onConfirm:eM,worktreeId:o,sourcePath:eT.path,sourceType:eT.type}),(0,r.jsx)(iV,{isOpen:eR,parentPath:eL,onConfirm:eP,onCancel:eD})]})})});$.oo;var iW=n(51434),iH=n(68955);function iK(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:{...q.kQ}};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:{...q.mS}};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}}function i$(e,t){try{window.localStorage.setItem(lc(e),null!=t?t:lo)}catch(e){}}function iq(e,t){if(e.length!==t.length)return!1;let n=new Set(e);return t.every(e=>n.has(e))}function iG(e,t){return e instanceof Error&&e.message?e.message:t}function iJ(e){return e instanceof DOMException&&"AbortError"===e.name}var iY=n(88731);let iQ="commandmate:showArchived",iX="activeCliTab-",iZ="activeInstanceId-",i0=[2e3,5e3,1e4],i1={timeoutMs:lv.K3,retries:0};function i2(){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 i4=(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)(i2,{})}),i5=(0,i.memo)(function(e){let{label:t}=e;return(0,r.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"worktree-detail-reconnecting-banner",className:"fixed top-2 left-1/2 z-50 flex -translate-x-1/2 items-center gap-2 rounded-full border border-warning-border bg-warning-subtle px-3 py-1 text-xs text-warning-foreground shadow-sm",children:[(0,r.jsx)(u.y,{size:"xs"}),(0,r.jsx)("span",{children:t})]})}),i3=(0,i.memo)(function(e){let{message:t,loginLabel:n,onLogin:a}=e;return(0,r.jsx)("div",{className:"flex h-full min-h-[200px] items-center justify-center",role:"alert","aria-live":"assertive","data-testid":"worktree-detail-session-expired",children:(0,r.jsxs)("div",{className:"max-w-md rounded-lg border border-border bg-surface p-6 text-center",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:t}),(0,r.jsx)(ei.$,{variant:"primary",type:"button",onClick:a,className:"mt-4","data-testid":"worktree-detail-relogin",children:n})]})})}),i6=()=>{},i8=["terminal","history","files","memo","info"],i9=(0,i.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,onMessageSent:s,isSessionRunning:l,isProcessing:i,showToast:o,pendingInsertText:c,onInsertConsumed:d,autoYesSlot:u,agentModeSlot:m}=e,x=tk({cliToolId:n,instanceId:a});return(0,r.jsx)(es.E,{worktreeId:t,onMessageSent:s,cliToolId:n,instanceId:a,isSessionRunning:l,isProcessing:i,showToast:o,pendingInsertText:c,onInsertConsumed:d,onOptimisticSend:x,autoYesSlot:u,agentModeSlot:m})}),i7=(0,i.memo)(function(e){var t,n,a,l,o,u,m,h,g,p,v,y;let{worktreeId:j}=e,{activeActivity:w,activeCliTab:k,activeInstanceId:N,activeTab:C,agentInstances:E,autoYesEnabled:A,autoYesExpiresAt:M,autoYesStateMap:L,diffContent:P,diffFilePath:F,disableAutoFollow:O,displayedInstances:z,editorFilePath:_,error:B,fetchCurrentOutput:V,fileInputRef:U,fileSearch:W,fileTreeRefresh:H,handleActivityOpen:K,handleActivityToggle:G,handleAgentInstancesChange:J,handleAutoYesToggle:Q,handleBackClick:X,handleCloseDiff:Z,handleDelete:ee,handleDiffSelect:et,handleDirtyChange:en,handleEditorClose:ea,handleEditorSave:es,handleFileInputChange:ei,handleFilePanelSave:ec,handleFilePathClick:ed,handleFileSelect:eu,handleHistoryDisplayLimitChange:em,handleHistoryUserOnlyChange:ex,handleInfoClick:eh,handleInfoModalClose:ef,handleInsertConsumed:eg,handleInsertConsumedSingle:ep,handleInsertToMessage:eb,handleInsertToSplit:ev,handleKillCancel:ew,handleKillConfirm:ek,openKillConfirm:eN,openActiveKillConfirm:eC,killTarget:eS,isKillPending:eI,handleLoadContent:eT,handleLoadError:eE,handleMessageSent:eM,handleMobileFileViewerClose:eR,handleMobileTabChange:eL,handleMove:eP,handleMoveCancel:eD,handleMoveConfirm:eF,handleNewDirectory:eO,handleNewFile:ez,handleNewFileCancel:e_,handleNewFileConfirm:eB,handleOpenFile:eV,handlePromptDismiss:eU,handlePromptRespond:eH,handleRename:eK,handleReLogin:e$,handleRetry:eJ,handleSetLoading:eQ,handleShowArchivedChange:eX,handleUpload:eZ,handleVibeLocalContextWindowChange:e0,handleVibeLocalModelChange:e1,handleWorktreeStatusChange:e2,hasUpdate:e4,historyDisplayLimit:e5,historySubTab:e3,historyUserOnly:e9,isAuthExpired:e7,isEditorMaximized:te,isInfoModalOpen:tt,isMobile:tn,isMoveDialogOpen:ta,isReconnecting:tr,isSelectionListActive:ts,isPagerActive:tl,isDismissablePanelActive:ti,isUnclassifiedActive:to,sessionStatus:tc,agentMode:td,lastAutoResponse:tu,loading:tm,makeAutoYesToggleHandler:tx,mobileFileViewerPath:th,mobileSelectedAgents:tf,moveTarget:tg,newFileParentPath:tp,openMobileDrawer:tb,pendingInsertText:tv,pendingInsertTextMap:ty,rosterReady:tj,setActiveInstanceId:tk,setFocusedSplitIndex:tS,setHistorySubTab:tI,setIsEditorMaximized:tT,setWorktree:tE,showArchived:tA,showNewFileDialog:tM,showToast:tR,state:tL,tCommon:tP,tWorktree:tD,tabsActions:tF,tabsState:tO,resetFileTreeView:tz,toggleInstanceVisible:t_,verification:tB,vibeLocalContextWindow:tV,vibeLocalModel:tU,visibleInstanceIds:tW,worktree:tH,worktreeName:tK,worktreeStatus:t$}=function(e){var t,n,a,r,l,o,d,u,m,x;let{worktreeId:h}=e,g=(0,s.useRouter)(),p=(0,nl.a)(),b=(0,i.useRef)(p);b.current=p;let{openMobileDrawer:v}=(0,ld.VF)(),{state:y,actions:j}=function(){let[e,t]=(0,i.useReducer)(iK,void 0,q.mR),{value:n,setValue:a}=(0,sl.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"),S=(0,eo.SC)(),T=(0,Y.rC)(),E=null!=(l=null==T?void 0:T.worktrees.find(e=>e.id===h))?l:null,[A,M]=(0,i.useState)(E),[R,L]=(0,i.useState)(null===E),[P,D]=(0,i.useState)(null),[F,O]=(0,i.useState)(!1),[z,_]=(0,i.useState)(!1),[B,V]=(0,i.useState)(0),U=(0,i.useRef)(0),W=(0,i.useRef)(0),H=(0,i.useRef)(null),K=(0,i.useRef)(async()=>null),G=(0,i.useCallback)(()=>{null!==H.current&&(clearTimeout(H.current),H.current=null)},[]),J=(0,i.useRef)(null!==E),[Q,X]=(0,i.useState)(!1),[Z,ee]=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:l_(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=lB(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=lB(t.tabs,n.path,e=>({...e,loading:n.loading}));if(!e)return t;return{...t,tabs:e}}case"SET_ERROR":{let e=lB(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:l_(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:l_(e),content:null,loading:!1,error:null,isDirty:!1}));if(0===e.length)return lU;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=lB(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 lU;case"CLOSE_OTHERS":case"CLOSE_TO_RIGHT":{let e="CLOSE_OTHERS"===n.type?"others":"right",a=new Set(lV(t.tabs,n.path,e));if(0===a.size)return t;let r=t.tabs.filter(e=>!a.has(e.path));return{tabs:r,activeIndex:function(e,t,n){var a;if(0===t.length)return null;let r=null!==e.activeIndex?null==(a=e.tabs[e.activeIndex])?void 0:a.path:void 0;if(void 0!==r){let e=t.findIndex(e=>e.path===r);if(-1!==e)return e}let s=t.findIndex(e=>e.path===n);return -1!==s?s:0}(t,r,n.path)}}default:return t}},lU),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(lz+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(lz+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})},[]),x=(0,i.useCallback)(()=>{n({type:"CLOSE_ALL"})},[]),h=(0,i.useCallback)(e=>{n({type:"CLOSE_OTHERS",path:e})},[]),f=(0,i.useCallback)(e=>{n({type:"CLOSE_TO_RIGHT",path:e})},[]),g=(0,i.useMemo)(()=>({dispatch:n,openFile:l,closeTab:o,activateTab:c,onFileRenamed:d,onFileDeleted:u,moveToFront:m,closeAllTabs:x,closeOtherTabs:h,closeTabsToRight:f}),[n,l,o,c,d,u,m,x,h,f]);return[t,g]}(h),[et,en]=(0,i.useState)(null),[ea,er]=(0,i.useState)(null),[es,el]=(0,i.useState)(!1),[ei,ec]=(0,i.useState)(new Map),[ed,eu]=(0,i.useState)(null),[em,ex]=(0,i.useState)(!1),[eh,ef]=(0,i.useState)(!1),[eg,ep]=(0,i.useState)(!1),[eb,ev]=(0,i.useState)(!1),[ew,ek]=(0,i.useState)(!1),[eN,eC]=(0,i.useState)(""),[eS,eI]=(0,i.useState)(iH.J_),eT=(0,i.useRef)(!1),[eE,eM]=(0,i.useState)(null),[eR,eL]=(0,i.useState)(aw.sA),eP=(0,i.useRef)(eR);eP.current=eR;let eD=(0,i.useRef)(A);eD.current=A;let[eF,eO]=(0,i.useState)(()=>(0,$.lu)((0,aw.sA)())),ez=(0,i.useRef)(eF);ez.current=eF;let[e_,eB]=(0,i.useState)(null),eV=e_===h,[eU,eW]=(0,i.useState)(null),[eH,eK]=(0,i.useState)(null),[e$,eJ]=(0,i.useState)(()=>{try{let e=window.localStorage.getItem(iX+h);if(e&&(0,$.hR)(e))return e}catch(e){}return(0,aw.sA)()[0]}),eQ=(0,i.useCallback)(e=>{eJ(e);try{window.localStorage.setItem(iX+h,e)}catch(e){}},[h]),eX=(0,i.useRef)(e$);eX.current=e$;let[eZ,e0]=(0,i.useState)(()=>{try{let e=window.localStorage.getItem(iZ+h);if(e&&(0,$.n6)(e))return e;let t=window.localStorage.getItem(iX+h);if(t&&(0,$.hR)(t))return t}catch(e){}return(0,aw.sA)()[0]}),e1=(0,i.useCallback)(e=>{e0(e);try{window.localStorage.setItem(iZ+h,e)}catch(e){}let t=ez.current.find(t=>t.id===e);t&&eQ(t.cliTool)},[h,eQ]),e2=(0,i.useRef)(eZ);e2.current=eZ;let e4=(0,i.useRef)(0),e5=(0,i.useRef)(0),e3=(0,i.useRef)(0),e6=null!=(o=null==(t=ei.get(eZ))?void 0:t.enabled)&&o,e8=null!=(d=null==(n=ei.get(eZ))?void 0:n.expiresAt)?d:null,[e9,e7]=(0,i.useState)(0),[te,tt]=(0,i.useState)(!1),[tn,ta]=(0,i.useState)(""),{active:tr,setActive:ts,toggle:tl}=function(e){let[t,n]=(0,i.useState)(li),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(lc(e));if(t===lo)return null;if(t&&"string"==typeof t&&ll.has(t))return t}catch(e){}return li}(e);t!==a.current&&n(t)},[e]),{active:t,setActive:(0,i.useCallback)(e=>{n(e),i$(r.current,e)},[]),toggle:(0,i.useCallback)(e=>{if(a.current===e){n(null),i$(r.current,null);return}n(e),i$(r.current,e)},[])}}(h),{historySubTab:ti,setHistorySubTab:to,showArchived:tc,handleShowArchivedChange:td,historyUserOnly:tu,handleHistoryUserOnlyChange:tm,historyDisplayLimit:tx,handleHistoryDisplayLimitChange:th}=function(){let[e,t]=(0,i.useState)("message"),[n,a]=(0,i.useState)(()=>"true"===localStorage.getItem(iQ)),r=(0,i.useCallback)(e=>{a(e),localStorage.setItem(iQ,String(e))},[]),[s,l]=(0,i.useState)(()=>{try{return"true"===localStorage.getItem(iY.gP)}catch(e){return!1}}),o=(0,i.useCallback)(e=>{l(e);try{localStorage.setItem(iY.gP,String(e))}catch(e){}},[]),[c,d]=(0,i.useState)(()=>{try{let e=localStorage.getItem(iY.wP);if(null===e)return iY.v8;let t=parseInt(e,10);return(0,iY.UK)(t)?t:iY.v8}catch(e){return iY.v8}});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(iY.wP,String(e))}catch(e){}},[])}}(),tf=(0,i.useRef)(tc);(0,i.useEffect)(()=>{tf.current=tc},[tc]);let tg=(0,i.useRef)(tx);(0,i.useEffect)(()=>{tg.current=tx},[tx]),(0,i.useEffect)(()=>{(0,aw.qD)()},[]);let{pendingInsertTextMap:tp,pendingInsertText:tb,setFocusedSplitIndex:tv,handleInsertToMessage:ty,handleInsertToSplit:tj,handleInsertConsumed:tw,handleInsertConsumedSingle:tk}=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:tN,diffFilePath:tC,handleDiffSelect:tS,handleCloseDiff:tI}=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)},[])}}(p),tT=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),[x,h]=(0,i.useState)(null),[g,p]=(0,i.useState)(null),b=(0,i.useRef)(null),v=(0,i.useMemo)(()=>(0,f.sg)(e=>{o(e)},a),[a]),y=(0,i.useCallback)(e=>{s(e),v(e),p(null)},[v]),j=(0,i.useCallback)(()=>{s(""),o(""),h(null),p(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)(()=>x&&0!==x.results.length?(0,f.q3)(x.results.map(e=>e.filePath)):new Set,[x]);return(0,i.useEffect)(()=>{if("content"!==c||!l.trim())return void h(null);b.current&&b.current.abort();let e=new AbortController;return b.current=e,(async()=>{m(!0),p(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)h({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;p(e instanceof Error?e.message:"An error occurred while searching"),h(null)}finally{m(!1)}})(),()=>{e.abort()}},[c,l,t]),(0,i.useEffect)(()=>{"name"===c&&(h(null),m(!1),p(null))},[c]),{query:r,mode:c,isSearching:u,results:x,error:g,setQuery:y,setMode:d,clearSearch:j,filterByName:w,getMatchedPaths:k}}({worktreeId:h}),tE=(0,i.useRef)(!1),tA=(0,i.useRef)(h);(0,i.useEffect)(()=>{tA.current!==h&&(j.clearMessages(),tE.current=!1,ec(new Map),U.current=0,W.current=0,G(),O(!1),tA.current=h)},[h,j,G]);let tM=(0,i.useCallback)(async()=>{try{var e,t;let n=await (0,eG.E)("/api/worktrees/".concat(h),i1),a=(0,eG.O0)(n);if(a)throw a;if(!n.ok)throw new eG.hD("Failed to fetch worktree: ".concat(n.status),n.status);let r=(0,eG.xd)(n);if(r)throw r;let s=await n.json();if(M(s),s.selectedAgents){let e=eP.current;s.selectedAgents.length===e.length&&s.selectedAgents.every((t,n)=>t===e[n])||eL(s.selectedAgents)}if(s.agentInstances){let e=ez.current,t=s.agentInstances;t.length===e.length&&t.every((t,n)=>t.id===e[n].id&&t.cliTool===e[n].cliTool&&t.alias===e[n].alias)||eO(t),eB(h)}return"vibeLocalModel"in s&&eW(null!=(e=s.vibeLocalModel)?e:null),"vibeLocalContextWindow"in s&&eK(null!=(t=s.vibeLocalContextWindow)?t:null),U.current=0,W.current=0,G(),O(!1),_(!1),D(null),s}catch(a){let e=a instanceof Error?a.message:"Unknown error",t=a instanceof eG.hD?a.status:0;if(U.current+=1,401===t)return _(!0),O(!1),D(null),null;if(null!==eD.current)return U.current>=3&&O(!0),console.error("[WorktreeDetailRefactored] Error fetching worktree:",a),null;D(e);let n=W.current;return n<i0.length&&(W.current=n+1,G(),H.current=setTimeout(()=>{H.current=null,K.current()},i0[n])),null}},[h,G]);K.current=tM;let tR=(0,i.useCallback)(async()=>{let e=eX.current,t=b.current,n=e2.current,a=++e4.current;try{let r=new URLSearchParams({cliTool:e,unit:"pairs"});t&&r.set("instance",n),tf.current&&r.set("includeArchived","true"),r.set("limit",String(tg.current));let s=await (0,eG.E)("/api/worktrees/".concat(h,"/messages?").concat(r.toString()),i1);if(!s.ok)throw Error("Failed to fetch messages: ".concat(s.status));let l=await s.json();if(e4.current!==a||eX.current!==e||t&&e2.current!==n)return;j.setMessages(l.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(r){if(e4.current!==a||eX.current!==e||t&&e2.current!==n)return;console.error("[WorktreeDetailRefactored] Error fetching messages:",r)}},[h,j]),tL=(0,i.useCallback)(async()=>{let e=eX.current,t=b.current,n=e2.current,a=++e5.current;try{var r,s,l,i,o,c,d,u;let m=t?"/api/worktrees/".concat(h,"/current-output?cliTool=").concat(e,"&instance=").concat(encodeURIComponent(n)):"/api/worktrees/".concat(h,"/current-output?cliTool=").concat(e),x=await (0,eG.E)(m,i1);if(!x.ok)return;let f=await x.json();if(e5.current!==a||eX.current!==e||t&&e2.current!==n||f.cliToolId&&f.cliToolId!==e)return;if(f.isPromptWaiting&&f.promptData?j.showPrompt(f.promptData,"prompt-".concat(Date.now())):!f.isPromptWaiting&&y.prompt.visible&&j.clearPrompt(),ef(null!=(r=f.isSelectionListActive)&&r),ep(null!=(s=f.isPagerActive)&&s),ev(null!=(l=f.isDismissablePanelActive)&&l),ek(null!=(i=f.isUnclassifiedActive)&&i),eC(null!=(o=f.sessionStatus)?o:""),eI(null!=(c=f.agentMode)?c:iH.J_),eu(null!=(d=f.lastServerResponseTimestamp)?d:null),ex(null!=(u=f.serverPollerActive)&&u),f.autoYes){let a=eT.current,r=f.autoYes,s=t?n:e;ec(e=>{let t=new Map(e);return t.set(s,{enabled:r.enabled,expiresAt:r.expiresAt}),t}),eT.current=r.enabled,a&&!f.autoYes.enabled&&("stop_pattern_matched"===f.autoYes.stopReason||"consecutive_errors"===f.autoYes.stopReason)&&eM(f.autoYes.stopReason)}}catch(r){if(e5.current!==a||eX.current!==e||t&&e2.current!==n)return;console.error("[WorktreeDetailRefactored] Error fetching current output:",r)}},[h,j,y.prompt.visible]),tP=(0,i.useCallback)(async()=>{let e=++e3.current;try{let a=await (0,eG.E)("/api/worktrees/".concat(h,"/auto-yes"),i1);if(!a.ok)return;let r=await a.json();if(e3.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})}ec(l)}catch(t){if(e3.current!==e)return;console.error("[WorktreeDetailRefactored] Error fetching auto-yes states:",t)}},[h]),{visibleInstances:tD,visibleInstanceIds:tF,toggleInstanceVisible:tO}=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(ao(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)(()=>ac(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(ao(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=ac(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([...ac(a,n).map(e=>e.id),...e])},[a,n,c])}}({worktreeId:h,roster:eF}),tz=p?tD:eF,t_=(0,i.useMemo)(()=>Array.from(new Set(tD.map(e=>e.cliTool))),[tD]),tB=p?t_:eR;(0,i.useEffect)(()=>{0!==tz.length&&(tz.some(e=>e.id===eZ)||e1(tz[0].id))},[tz,eZ,e1]),(0,i.useEffect)(()=>{let e=tz.find(e=>e.id===eZ);e&&e.cliTool!==e$&&eQ(e.cliTool)},[tz,eZ,e$,eQ]);let tV="opencode"===e$||"copilot"===e$,tU=(0,i.useCallback)(e=>{eL(e)},[]),tW=(0,i.useCallback)(e=>{eO(e),eB(h)},[h]),tH=(0,i.useCallback)(e=>{eW(e)},[]),tK=(0,i.useCallback)(e=>{eK(e)},[]),t$=(0,i.useRef)(e$);(0,i.useEffect)(()=>{t$.current!==e$&&(t$.current=e$,j.clearMessages(),j.clearPrompt(),ef(!1),tR(),tL())},[e$,j,tR,tL]),(0,i.useEffect)(()=>{tR()},[tc,tR]),(0,i.useEffect)(()=>{tR()},[tx,tR]);let{showToast:tq}=(0,eq.dj)(),tG=(0,i.useCallback)(()=>{tq("Maximum ".concat(30," file tabs. Close a tab first."),"info")},[tq]),tJ=(0,i.useCallback)(e=>{p?en(e):"limit_reached"===ee.openFile(e)&&tG()},[p,ee,tG]),tY=(0,i.useCallback)(e=>{p?en(e):"limit_reached"===ee.openFile(e)&&tG()},[p,ee,tG]),tQ=(0,i.useCallback)(e=>{"limit_reached"===ee.openFile(e)&&tG()},[ee,tG]),tX=(0,i.useCallback)(()=>{en(null)},[]),tZ=(0,i.useCallback)(e=>{e7(e=>e+1)},[]),t0=(0,i.useCallback)(()=>{er(null)},[]),t1=(0,i.useCallback)(()=>{tT.clearSearch(),ee.closeAllTabs(),en(null),er(null)},[tT,ee]),t2=(0,i.useCallback)(e=>{e7(e=>e+1)},[]),t4=(0,i.useCallback)(e=>{tl(e)},[tl]),t5=(0,i.useCallback)(e=>{ts(e)},[ts]),t3=(0,i.useCallback)(()=>{g.push("/")},[g]),t6=(0,i.useCallback)(async e=>{try{let t=await fetch("/api/worktrees/".concat(h),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:e})});if(t.ok){let e=await t.json();M(e)}}catch(e){}},[h]),t8=(0,i.useCallback)(()=>{X(!0)},[]),t9=(0,i.useCallback)(()=>{X(!1)},[]),t7=(0,i.useCallback)(async e=>{j.setPromptAnswering(!0);try{let t=iP(e,e$,(0,I.XF)(y.prompt.data)?y.prompt.data:null,b.current?e2.current:void 0),n=await fetch("/api/worktrees/".concat(h,"/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));let a=await n.json().catch(()=>null);if((null==a?void 0:a.success)===!1){tq(w("promptResponse.refused"),"warning"),await tL();return}j.clearPrompt(),await tL()}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e)}finally{j.setPromptAnswering(!1)}},[h,j,tL,e$,y.prompt.data,tq,w]),ne=(0,i.useCallback)(()=>{j.clearPrompt()},[j]),nt=(0,i.useCallback)(e=>{j.setMobileActivePane(e)},[j]),nn=(0,i.useCallback)(()=>{tR(),tL()},[tR,tL]),na=(0,i.useCallback)((e,t)=>async n=>{let a=null!=t?t:e;try{let t=await fetch("/api/worktrees/".concat(h,"/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();ec(t=>{let n=new Map(t);return n.set(a,{enabled:e.enabled,expiresAt:e.expiresAt}),n}),a===e2.current&&(eT.current=e.enabled)}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[h]),nr=(0,i.useCallback)(e=>na(e$,eZ)(e),[na,e$,eZ]),[ns,ni]=(0,i.useState)(null),[no,nc]=(0,i.useState)(!1),nd=(0,i.useRef)(!1),nu=(0,i.useCallback)(e=>{ni(e)},[]),nm=(0,i.useCallback)(()=>{let e=e2.current,t=eX.current,n=(0,$.O6)(ez.current,e,t);ni({cliToolId:t,instanceId:e,label:n})},[]),nx=(0,i.useCallback)(async()=>{if(!ns||nd.current)return;nd.current=!0,nc(!0);let e=()=>{ns.instanceId===e2.current&&(j.clearMessages(),j.clearPrompt())};try{await eG.y.killSession(h,ns.cliToolId,ns.instanceId),e(),await tM(),ni(null)}catch(t){t instanceof eG.hD&&404===t.status?(e(),await tM(),ni(null)):tq(w("session.failedToKill"),"error")}finally{nd.current=!1,nc(!1)}},[ns,h,j,tM,tq,w]),nh=(0,i.useCallback)(()=>{nd.current||ni(null)},[]),nf=(0,i.useCallback)(e=>{ta(e),tt(!0)},[]),ng=(0,i.useCallback)(async e=>{tt(!1);let t=tn?"".concat(tn,"/").concat(e):e;try{if(!(await fetch("/api/worktrees/".concat(h,"/files/").concat((0,eA.o)(t)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:""})})).ok)throw Error("Failed to create file");e7(e=>e+1)}catch(e){window.alert(k("fileOps.failedToCreateFile"))}},[h,tn,k]),np=(0,i.useCallback)(()=>{tt(!1)},[]),nb=(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(h,"/files/").concat((0,eA.o)(n)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"directory"})})).ok)throw Error("Failed to create directory");e7(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create directory:",e),window.alert(k("fileOps.failedToCreateDirectory"))}},[h,k]),nv=(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(h,"/files/").concat((0,eA.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):"";ee.onFileRenamed(e,"".concat(t).concat(n)),e7(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to rename:",e),window.alert(k("fileOps.failedToRename"))}},[h,ee,k]),ny=(0,i.useCallback)(async e=>{let t=e.split("/").pop()||e;if(await S({description:N("confirmDelete",{name:t}),variant:"danger"}))try{if(!(await fetch("/api/worktrees/".concat(h,"/files/").concat((0,eA.o)(e),"?recursive=true"),{method:"DELETE"})).ok)throw Error("Failed to delete");(ea===e||(null==ea?void 0:ea.startsWith("".concat(e,"/"))))&&er(null),ee.onFileDeleted(e),e7(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert(k("fileOps.failedToDelete"))}},[h,ea,ee,N,k,S]);(0,i.useEffect)(()=>{"stop_pattern_matched"===eE?(tq(C("stopPatternMatched"),"info"),eM(null)):"consecutive_errors"===eE&&(tq(C("consecutiveErrorsStopped"),"warning"),eM(null))},[eE,tq,C]);let{moveTarget:nj,isMoveDialogOpen:nw,handleMove:nk,handleMoveConfirm:nN,handleMoveCancel:nC}=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)},[])}}(h,()=>e7(e=>e+1),e=>tq(e,"success"),e=>tq(e,"error")),nS=(0,i.useRef)(null),nI=(0,i.useRef)(""),nT=(0,i.useCallback)(e=>{var t;nI.current=e,null==(t=nS.current)||t.click()},[]),nE=(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=nI.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 ej.includes(t)}(l))return void tq("Unsupported file type: ".concat(l,". Allowed: ").concat(ej.join(", ")),"error");let i=function(e){var t;let n=function(e){let t=e.toLowerCase();return ey.find(e=>e.extension===t)}(e);return null!=(t=null==n?void 0:n.maxFileSize)?t:0x1400000}(l);if(r.size>i)return void tq("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(h,"/upload/").concat((0,eA.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";tq(n,"error");return}let t=await e.json();tq("Uploaded: ".concat(t.filename),"success"),e7(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),tq("Upload failed. Please try again.","error")}},[h,tq]),{data:nA}=eY(),nM=null!=(u=null==nA?void 0:nA.hasUpdate)&&u,{lastAutoResponse:nR}=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||!(0,I.XF)(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||!(0,aL.P0)(e).valid)return{outcome:"unusable",pattern:e};let t=new RegExp(e);for(let a of n){let n=(0,aL.eJ)(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=iP(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:h,cliTool:e$,isPromptWaiting:y.prompt.visible,promptData:y.prompt.data,autoYesEnabled:e6,lastServerResponseTimestamp:ed,serverPollerActive:em}),nL=(0,i.useCallback)(async()=>{D(null),O(!1),_(!1),U.current=0,W.current=0,G(),L(!0),await tM()&&await Promise.all([tR(),tL()]),L(!1)},[tM,tR,tL,G]),nP=(0,i.useCallback)(()=>{window.location.href="/login"},[]);(0,i.useEffect)(()=>G,[G]),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:nL,fetchWorktree:tM,fetchMessages:tR,fetchCurrentOutput:tL,setError:D}),(0,i.useEffect)(()=>{if(tE.current)return;let e=!0;return(async()=>{J.current||L(!0),await Promise.all([tM(),tR(),tL()]),e&&(L(!1),tE.current=!0)})(),()=>{e=!1}},[tM,tR,tL]);let nD=null!=(m=null==A||null==(r=A.sessionStatusByCli)||null==(a=r[e$])?void 0:a.isRunning)&&m;(0,i.useEffect)(()=>{if(R)return;let e=setInterval(async()=>{let e=[tL(),tM()];p&&e.push(tR()),await Promise.all(e),V(e=>e+1)},nD?2e3:5e3);return()=>clearInterval(e)},[R,tL,tM,tR,nD,p]),(0,i.useEffect)(()=>{tP()},[h,eV,tP]),(0,i.useEffect)(()=>{j.setLayoutMode(p?"tabs":"split")},[p,j]);let nF=(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"})(A,null!==y.error.type,e$),[A,y.error.type,e$]),nO=(0,i.useMemo)(()=>y.layout.mobileActivePane,[y.layout.mobileActivePane]),nz=null!=(x=null==A?void 0:A.name)?x:"Unknown",n_=(0,i.useCallback)((e,t)=>{ee.dispatch({type:"SET_CONTENT",path:e,content:t})},[ee]),nB=(0,i.useCallback)((e,t)=>{ee.dispatch({type:"SET_ERROR",path:e,error:t})},[ee]),nV=(0,i.useCallback)((e,t)=>{ee.dispatch({type:"SET_LOADING",path:e,loading:t})},[ee]),nU=(0,i.useCallback)((e,t)=>{ee.dispatch({type:"SET_DIRTY",path:e,isDirty:t})},[ee]),nW=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)([]),[x,h]=(0,i.useState)(null),[f,g]=(0,i.useState)(null),[p,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),[I,T]=(0,i.useState)(null),[E,A]=(0,i.useState)(null),[M,R]=(0,i.useState)(null),[L,P]=(0,i.useState)(!1),[D,F]=(0,i.useState)(null),[O,z]=(0,i.useState)(null),[_,B]=(0,i.useState)(!1),[V,U]=(0,i.useState)(null),[W,H]=(0,i.useState)(null),[K,$]=(0,i.useState)(null),[q,G]=(0,i.useState)(o),[J,Y]=(0,i.useState)(o),[Q,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)([]),[et,en]=(0,i.useState)(!1),[ea,er]=(0,i.useState)(null),[es,el]=(0,i.useState)(0),ei=(0,i.useRef)(0),eo=(0,i.useRef)(0),ec=(0,i.useRef)(!1),ed=(0,i.useRef)(!1),eu=(0,i.useRef)(!1),em=(0,i.useRef)(!1),ex=(0,i.useRef)(!1),eh=(0,i.useRef)(!1),ef=(0,i.useRef)(null);ef.current=K;let eg=(0,i.useRef)(o);eg.current=q,ed.current=(null==c?void 0:c.status)==="verifying"||u.some(e=>"running"===e.status),(0,i.useEffect)(()=>{if(ei.current+=1,eo.current=0,ec.current=!1,!eh.current){eh.current=!0;return}d(null),m([]),h(null),g(null),b(!0),y(null),w(null),T(null),A(null),R(null),F(null),z(null),U(null),$(null),G(o),Y(o),H(null)},[r]),(0,i.useEffect)(()=>{if(!l)return;let e=new AbortController,t=!1;return(async()=>{try{let n=await rb(r,e.signal);if(t)return;A(n),R(null)}catch(e){if(t||iJ(e))return;A(null),R(iG(e,"Failed to load the verification config"))}})(),()=>{t=!0,e.abort()}},[r,l,es]),(0,i.useEffect)(()=>{if(!l)return;let e=0===eo.current,t=15e3*!ed.current;if(!e&&Date.now()-eo.current<t||ec.current)return;let n=ei.current;ec.current=!0,eo.current=Date.now(),(async()=>{try{let[e,t]=await Promise.all([rh(r),rf(r,q)]);if(n!==ei.current)return;d(e),m(t),Y(q),y(null)}catch(e){if(n!==ei.current||iJ(e))return;y(iG(e,"Failed to load verification data"))}finally{ec.current=!1,n===ei.current&&(b(!1),eg.current!==q&&(eo.current=0,el(e=>e+1)))}})()},[r,s,es,l,q]);let ep=null!=(n=null!=x?x:null==(t=u[0])?void 0:t.id)?n:null,eb=(0,i.useMemo)(()=>{var e,t;if(null===ep)return null;let n=u.find(e=>e.id===ep);return(null==n?void 0:n.status)==="running"?"".concat(ep,":running:").concat(s,":").concat(es):"".concat(ep,":").concat(null!=(e=null==n?void 0:n.status)?e:"unlisted",":").concat(null!=(t=null==n?void 0:n.finishedAt)?t:"")},[ep,u,s,es]);(0,i.useEffect)(()=>{if(!l||null===ep){g(null),w(null),N(!1);return}let e=new AbortController,t=!1;return N(!0),(async()=>{try{let n=await rg(r,ep,e.signal);if(t)return;g(n),w(null===n?"not-found":null)}catch(e){if(t||iJ(e))return;g(null),w(iG(e,"Failed to load the verification run"))}finally{t||N(!1)}})(),()=>{t=!0,e.abort()}},[r,l,eb]),(0,i.useEffect)(()=>{if(!l||!Q)return;let e=new AbortController,t=!1;return en(!0),(async()=>{try{let n=await rj({days:7,limit:20},e.signal);if(t)return;ee(n),er(null)}catch(e){if(t||iJ(e))return;er(iG(e,"Failed to load the verification history"))}finally{t||en(!1)}})(),()=>{t=!0,e.abort()}},[l,Q,es]);let ev=(0,i.useMemo)(()=>{var e;return null!=(e=null==E?void 0:E.plannedGateIds)?e:[]},[E]),ey=(0,i.useMemo)(()=>{var e;return(null!=(e=null==f?void 0:f.gates)?e:[]).filter(e=>ro.includes(e.status)).map(e=>e.gateId)},[f]),ej=(0,i.useMemo)(()=>{var e;return null!=(e=u.find(e=>"running"===e.status))?e:null},[u]),ew=(0,i.useCallback)(e=>{$(null===e||iq(e,ev)?null:e)},[ev]),ek=(0,i.useCallback)(e=>{$(t=>{let n=new Set(null!=t?t:ev);n.has(e)?n.delete(e):n.add(e);let a=ev.filter(e=>n.has(e));return iq(a,ev)?null:a})},[ev]),eN=(0,i.useCallback)(()=>{let e=ev.filter(e=>ey.includes(e));$(0===e.length||iq(e,ev)?null:e)},[ev,ey]),eC=(0,i.useCallback)(()=>{eo.current=0,G(e=>Math.min(e+10,100))},[]),eS=(0,i.useCallback)(()=>{X(e=>!e)},[]),eI=(0,i.useCallback)(()=>{eo.current=0,el(e=>e+1)},[]),eT=(0,i.useCallback)(e=>{h(e)},[]),eE=(0,i.useCallback)(async e=>{if(!eu.current){eu.current=!0,S(!0),T(null),U(null);try{let t=void 0===e?ef.current:e,n=await rp(r,null!==t&&t.length>0?{gateIds:t}:{});h(n),eo.current=0,el(e=>e+1)}catch(t){let e=t instanceof ru&&409===t.status;T({kind:e?"conflict":"error",message:iG(t,"Failed to start verification"),runningRunId:t instanceof ru?t.runningRunId:null}),e&&(eo.current=0,el(e=>e+1))}finally{eu.current=!1,S(!1)}}},[r]),eA=(0,i.useCallback)(async()=>{if(!ex.current&&null!==ej){ex.current=!0,B(!0),U(null);try{let e=await ry(r,ej.id);H("running"===e.status?ej.id:null)}catch(e){U({kind:409===(e instanceof ru?e.status:0)?"gone":"error",message:iG(e,"Failed to cancel the verification run")})}finally{ex.current=!1,B(!1),eo.current=0,el(e=>e+1)}}},[r,ej]),eM=(0,i.useCallback)(async()=>{if(!em.current){em.current=!0,P(!0),F(null);try{let e=await rv(r);z(e),eo.current=0,el(e=>e+1)}catch(t){let e=t instanceof ru?t.status:0;F({kind:409===e?"conflict":422===e?"empty":"error",message:iG(t,"Failed to draft the verification config")}),409===e&&(eo.current=0,el(e=>e+1))}finally{em.current=!1,P(!1)}}},[r]);return{worktreeId:r,task:c,runs:u,latestRun:null!=(a=u[0])?a:null,selectedRunId:ep,selectedRun:f,loading:p,error:v,detailError:j,detailLoading:k,rerunPending:C,rerunFailure:I,config:E,configError:M,phase:u.some(e=>"running"===e.status)?"running":null===E?"unknown":E.exists?0===u.length?"configured":"result":"no-config",draftPending:L,draftFailure:D,draftResult:O,availableGateIds:ev,selectedGateIds:K,failedGateIds:ey,toggleGate:ek,setGateSelection:ew,selectFailedGates:eN,runningRun:ej,cancelPending:_,cancelSettling:null!==W&&(null==ej?void 0:ej.id)===W,cancelFailure:V,historyLimit:q,canLoadMore:u.length>=J&&J<100,repositoryHistoryOpen:Q,repositoryHistory:Z,repositoryHistoryLoading:et,repositoryHistoryError:ea,selectRun:eT,refresh:eI,rerun:eE,cancelRun:eA,loadMore:eC,toggleRepositoryHistory:eS,draftConfig:eM}}({worktreeId:h,refreshToken:B,enabled:!R&&!P});return{activeActivity:tr,activeCliTab:e$,activeInstanceId:eZ,activeTab:nO,agentInstances:eF,autoYesEnabled:e6,autoYesExpiresAt:e8,autoYesStateMap:ei,diffContent:tN,diffFilePath:tC,disableAutoFollow:tV,displayedAgents:tB,displayedInstances:tz,editorFilePath:ea,error:P,fetchCurrentOutput:tL,fileInputRef:nS,fileSearch:tT,fileTreeRefresh:e9,handleActivityOpen:t5,handleActivityToggle:t4,handleAgentInstancesChange:tW,handleAutoYesToggle:nr,handleBackClick:t3,handleCloseDiff:tI,handleDelete:ny,handleDiffSelect:tS,handleDirtyChange:nU,handleEditorClose:t0,handleEditorSave:t2,handleFileInputChange:nE,handleFilePanelSave:tZ,handleFilePathClick:tJ,handleFileSelect:tY,handleHistoryDisplayLimitChange:th,handleHistoryUserOnlyChange:tm,handleInfoClick:t8,handleInfoModalClose:t9,handleInsertConsumed:tw,handleInsertConsumedSingle:tk,handleInsertToMessage:ty,handleInsertToSplit:tj,handleKillCancel:nh,handleKillConfirm:nx,openKillConfirm:nu,openActiveKillConfirm:nm,killTarget:ns,isKillPending:no,handleLoadContent:n_,handleLoadError:nB,handleMessageSent:nn,handleMobileFileViewerClose:tX,handleMobileTabChange:nt,handleMove:nk,resetFileTreeView:t1,handleMoveCancel:nC,handleMoveConfirm:nN,handleNewDirectory:nb,handleNewFile:nf,handleNewFileCancel:np,handleNewFileConfirm:ng,handleOpenFile:tQ,handlePromptDismiss:ne,handlePromptRespond:t7,handleRename:nv,handleReLogin:nP,handleRetry:nL,handleSelectedAgentsChange:tU,handleSetLoading:nV,handleShowArchivedChange:td,handleUpload:nT,handleVibeLocalContextWindowChange:tK,rosterReady:eV,handleVibeLocalModelChange:tH,handleWorktreeStatusChange:t6,hasUpdate:nM,historyDisplayLimit:tx,historySubTab:ti,historyUserOnly:tu,isAuthExpired:z,isEditorMaximized:es,isInfoModalOpen:Q,isMobile:p,isMoveDialogOpen:nw,isReconnecting:F,isSelectionListActive:eh,isPagerActive:eg,isDismissablePanelActive:eb,isUnclassifiedActive:ew,sessionStatus:eN,agentMode:eS,lastAutoResponse:nR,loading:R,makeAutoYesToggleHandler:na,mobileFileViewerPath:et,mobileSelectedAgents:t_,moveTarget:nj,newFileParentPath:tn,openMobileDrawer:v,pendingInsertText:tb,pendingInsertTextMap:tp,selectedAgents:eR,setActiveCliTab:eQ,setActiveInstanceId:e1,setEditorFilePath:er,setFocusedSplitIndex:tv,setHistorySubTab:to,setIsEditorMaximized:el,setWorktree:M,showArchived:tc,showNewFileDialog:te,showToast:tq,state:y,tCommon:N,tWorktree:w,tabsActions:ee,tabsState:Z,toggleInstanceVisible:tO,vibeLocalContextWindow:eH,verification:nW,vibeLocalModel:eU,visibleInstanceIds:tF,worktree:A,worktreeName:nz,worktreeStatus:nF}}({worktreeId:j}),tq=(0,c.c)("auth"),[tG,tJ]=(0,i.useState)(!1),[tY,tQ]=(0,i.useState)(null),[tX,tZ]=(0,i.useState)(q.wf),t0="terminal"===C&&"chat"===tX,t1=(0,i.useCallback)(e=>{"memo"!==e&&tQ(null),eL(e)},[eL]),t2=(0,i.useCallback)(()=>{tQ(e=>{var t;return{tab:"verification",token:(null!=(t=null==e?void 0:e.token)?t:0)+1}}),eL("memo")},[eL]),t4=function(e){let{worktreeId:t,active:n}=e,{addListener:a}=(0,tC.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:j,active:"terminal"===C}),{viewportHeight:t5}=(0,iW.C)(),t3=(0,i.useCallback)(e=>{let t=i8.indexOf(C);if(-1===t)return;let n=t+e;n<0||n>=i8.length||t1(i8[n])},[C,t1]),{ref:t6}=(0,R.hU)({axis:"horizontal",threshold:60,edgeStartZone:32*("terminal"===C),onSwipeLeft:()=>t3(1),onSwipeRight:()=>t3(-1)}),t8=(0,i.useMemo)(()=>({worktreePath:null==tH?void 0:tH.path,openFile:ed}),[null==tH?void 0:tH.path,ed]);if(tm)return(0,r.jsx)(s2,{});if(e7)return(0,r.jsx)(i3,{message:tD("editor.sessionExpired"),loginLabel:tq("login.submitButton"),onLogin:e$});if(B)return(0,r.jsx)(s4,{message:B,onRetry:eJ});let t9=(0,$.O6)(E,N,k),t7=null!=(h=null==eS?void 0:eS.label)?h:t9,ne=null!=(p=null==(t=null!=(g=null==tH||null==(n=tH.sessionStatusByInstance)?void 0:n[N])?g:null==tH||null==(a=tH.sessionStatusByCli)?void 0:a[k])?void 0:t.isRunning)&&p,nt=null!=(y=null==(l=null!=(v=null==tH||null==(o=tH.sessionStatusByInstance)?void 0:o[N])?v:null==tH||null==(u=tH.sessionStatusByCli)?void 0:u[k])?void 0:l.isProcessing)&&y;return tn?(0,r.jsx)(T.t,{componentName:"WorktreeDetailRefactored",children:(0,r.jsx)(tw,{onInsertToComposer:eb,children:(0,r.jsxs)(tN.k,{value:t8,children:[tr&&(0,r.jsx)(i5,{label:tP("connection.reconnecting")}),(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden",style:{height:null!=t5?"".concat(t5,"px"):"100%"},"data-testid":"mobile-worktree-shell",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(b,{worktreeName:tK,repositoryName:null==tH?void 0:tH.repositoryName,status:t$,gitStatus:null==tH?void 0:tH.gitStatus,onBackClick:X,onMenuClick:tb})}),tB.task&&(0,r.jsx)("div",{className:"flex-shrink-0 border-b border-border bg-surface px-3 py-1.5",children:(0,r.jsx)(iF,{task:tB.task,latestRun:tB.latestRun,latestRunGates:null!==tB.selectedRun&&tB.selectedRun.id===(null==(m=tB.latestRun)?void 0:m.id)?tB.selectedRun.gates:null,onOpen:t2,className:"w-full justify-start"})}),(null==tH?void 0:tH.gitStatus)&&tH.gitStatus.isBranchMismatch&&(0,r.jsx)("div",{className:"z-35 flex-shrink-0",children:(0,r.jsx)(iO,{isBranchMismatch:tH.gitStatus.isBranchMismatch,currentBranch:tH.gitStatus.currentBranch,initialBranch:tH.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":tD("detail.agentInstanceSelection"),children:z.map(e=>{var t,n,a;let s=(0,e8.kA)(null!=(a=null==tH||null==(t=tH.sessionStatusByInstance)?void 0:t[e.id])?a:null==tH||null==(n=tH.sessionStatusByCli)?void 0:n[e.cliTool]),l=tP("status.".concat(s)),i=N===e.id;return(0,r.jsxs)("button",{onClick:()=>tk(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)(x.m,{status:s,size:"sm",label:tD("detail.statusPill",{label:(0,$.sw)(e),status:l})}),(0,$.sw)(e)]},e.id)})}),(0,r.jsx)("button",{type:"button",onClick:()=>tJ(!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":tD("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:t6,children:(0,r.jsx)(sW,{activeTab:C,worktreeId:j,worktree:tH,messages:tL.messages,cliToolId:k,instanceId:N,onFilePathClick:ed,onFileSelect:eu,onWorktreeUpdate:tE,onNewFile:ez,onNewDirectory:eO,onRename:eK,onDelete:ee,onUpload:eZ,onMove:eP,onFileTreeReset:tz,refreshTrigger:H,fileSearch:W,showToast:tR,selectedAgents:tf,onSelectedAgentsChange:i6,useInstanceManagement:!0,instances:E,onInstancesChange:J,visibleInstanceIds:tW,onToggleInstanceVisible:t_,vibeLocalModel:tU,onVibeLocalModelChange:e1,vibeLocalContextWindow:tV,onVibeLocalContextWindowChange:e0,disableAutoFollow:O,historySubTab:e3,onHistorySubTabChange:tI,onDiffSelect:et,onInsertToMessage:eb,showArchived:tA,onShowArchivedChange:eX,historyDisplayLimit:e5,onHistoryDisplayLimitChange:em,historyUserOnly:e9,onHistoryUserOnlyChange:ex,verification:tB,toolsSubTabRequest:tY,onSurfaceModeChange:tZ})}),(0,r.jsxs)("div",{className:"flex-shrink-0 border-t border-border bg-surface z-30",children:[ts&&!t0&&(0,r.jsx)("div",{className:"px-2 pt-1 border-b border-border",children:(0,r.jsx)(el.y,{worktreeId:j,cliToolId:k,instanceId:N,onKeysSent:V,showPagerKeys:tl})}),(0,r.jsx)("div",{className:"p-2",children:(0,r.jsx)(i9,{worktreeId:j,onMessageSent:eM,cliToolId:k,instanceId:N,isSessionRunning:ne,isProcessing:nt,showToast:tR,pendingInsertText:tv,onInsertConsumed:ep,agentModeSlot:(0,r.jsx)(ig,{worktreeId:j,cliToolId:k,instanceId:N,agentMode:td,sessionStatus:tc,isPromptWaiting:tL.prompt.visible,isSelectionListActive:ts,isDismissablePanelActive:ti,isUnclassifiedActive:to,onKeysSent:V}),autoYesSlot:(0,r.jsx)(iL.T,{enabled:A,expiresAt:M,onToggle:Q,lastAutoResponse:tu,cliToolName:k,inline:!0,showToolName:!1})})})]}),(0,r.jsx)(S,{activeTab:C,onTabChange:t1,hasNewOutput:t4,hasPrompt:tL.prompt.visible,hasUpdate:e4,inFlow:!0}),!A&&(0,r.jsx)(D,{promptData:tL.prompt.data,visible:tL.prompt.visible,answering:tL.prompt.answering,onRespond:eH,onDismiss:eU,cliToolName:(0,$.oo)(k)}),(0,r.jsx)(er,{open:tG,onClose:()=>tJ(!1),onSearch:()=>window.dispatchEvent(new CustomEvent("terminal-search-open")),onEnd:eC,endDisabled:!ne}),(0,r.jsx)(eW,{isOpen:null!==th,onClose:eR,worktreeId:j,filePath:null!=th?th:"",onFileSaved:es,onOpenFile:ed}),(0,r.jsx)("input",{ref:U,type:"file",accept:ej.join(","),onChange:ei,className:"hidden","aria-label":tD("detail.uploadFile")}),(0,r.jsx)(e6.a,{isOpen:null!==eS,onClose:ew,title:tD("session.confirmEnd",{tool:t7}),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:tD("session.endWarning")}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:ew,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:tP("cancel")}),(0,r.jsx)("button",{type:"button",onClick:ek,disabled:eI,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:tP("end")})]})]})}),tg&&(0,r.jsx)(i_,{isOpen:ta,onClose:eD,onConfirm:eF,worktreeId:j,sourcePath:tg.path,sourceType:tg.type}),(0,r.jsx)(iV,{isOpen:tM,parentPath:tp,onConfirm:eB,onCancel:e_})]})]})})}):(0,r.jsxs)(tN.k,{value:t8,children:[tr&&(0,r.jsx)(i5,{label:tP("connection.reconnecting")}),(0,r.jsx)(iU,{worktreeId:j,worktree:tH,worktreeName:tK,worktreeStatus:t$,instances:E,rosterReady:tj,activeInstanceId:N,setActiveInstanceId:tk,hasUpdate:e4,lastAutoResponse:tu,activeActivity:w,onActivityToggle:G,onActivityOpen:K,verification:tB,onBackClick:X,onInfoClick:eh,onWorktreeStatusChange:e2,pendingInsertTextMap:ty,setFocusedSplitIndex:tS,handleInsertToSplit:ev,handleInsertConsumed:eg,handleInsertToMessage:eb,autoYesStateMap:L,makeAutoYesToggleHandler:tx,showArchived:tA,onShowArchivedChange:eX,historyDisplayLimit:e5,onHistoryDisplayLimitChange:em,historyUserOnly:e9,onHistoryUserOnlyChange:ex,onMessageSent:eM,onFilePathClick:ed,showToast:tR,tabsState:tO,tabsActions:tF,onLoadContent:eT,onLoadError:eE,onSetLoading:eQ,onFilePanelSave:ec,onDirtyChange:en,onOpenFile:eV,diffContent:P,diffFilePath:F,onCloseDiff:Z,fileSearch:W,fileTreeRefresh:H,onFileSelect:eu,onNewFile:ez,onNewDirectory:eO,onRename:eK,onDelete:ee,onUpload:eZ,onMove:eP,onFileTreeReset:tz,onDiffSelect:et,onAgentInstancesChange:J,vibeLocalModel:tU,onVibeLocalModelChange:e1,vibeLocalContextWindow:tV,onVibeLocalContextWindowChange:e0,isInfoModalOpen:tt,onInfoModalClose:ef,onWorktreeUpdate:tE,fileInputRef:U,onFileInputChange:ei,onKillSession:eC,onRequestSessionEnd:eN,killTarget:eS,isKillPending:eI,onKillCancel:ew,onKillConfirm:ek,moveTarget:tg,isMoveDialogOpen:ta,onMoveCancel:eD,onMoveConfirm:eF,showNewFileDialog:tM,newFileParentPath:tp,onNewFileConfirm:eB,onNewFileCancel:e_,killDialogTitle:tD("session.confirmEnd",{tool:t7}),killDialogWarning:tD("session.endWarning"),cancelLabel:tP("cancel"),endLabel:tP("end")}),_&&(0,r.jsx)(e6.a,{isOpen:!0,onClose:ea,title:_.split("/").pop()||tD("fileViewer.editor"),size:"full",disableClose:te,children:(0,r.jsx)("div",{className:"h-[80vh]",children:(0,r.jsx)(i4,{worktreeId:j,filePath:_,onClose:ea,onSave:es,onMaximizedChange:tT})})})]})});function oe(){let e=(0,s.useParams)().id;return(0,r.jsx)(l.GV,{children:(0,r.jsx)(i7,{worktreeId:e})})}},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),x=(0,a.useRef)(n),h=(0,a.useRef)(i),f=(0,a.useRef)(null),g=(0,a.useRef)(!0),p=(0,a.useRef)(t);(0,a.useEffect)(()=>{m.current=t},[t]),(0,a.useEffect)(()=>{x.current=n},[n]),(0,a.useEffect)(()=>{h.current=i},[i]),(0,a.useEffect)(()=>(g.current=!0,()=>{g.current=!1,f.current&&clearTimeout(f.current)}),[]);let b=(0,a.useCallback)(async e=>{if(!g.current)return;c(!0),u(null);let t=null,n=0;for(;n<=l;)try{if(await x.current(e),g.current){var a;c(!1),u(null),null==(a=h.current)||a.call(h)}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))}}g.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!==p.current&&!s)return v(),f.current=setTimeout(()=>{b(m.current)},r),()=>{v()}},[t,s,r,v,b]),{isSaving:o,error:d,saveNow:y}}},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")})]})}},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,5694,8566,934,9948,6983,5520,3160,2407,6402,8019,4718,4388,2751,2039,4949,2053,6022,998,8441,1255,7358],()=>e(e.s=20252)),_N_E=e.O()}]);