commandmate 0.34.0 → 0.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +136 -136
  3. package/.next/app-path-routes-manifest.json +27 -27
  4. package/.next/build-manifest.json +2 -2
  5. package/.next/prerender-manifest.json +12 -12
  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_client-reference-manifest.js +1 -1
  14. package/.next/server/app/api/assistant/current-output/route_client-reference-manifest.js +1 -1
  15. package/.next/server/app/api/assistant/messages/route_client-reference-manifest.js +1 -1
  16. package/.next/server/app/api/assistant/session/route_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/assistant/start/route_client-reference-manifest.js +1 -1
  18. package/.next/server/app/api/assistant/terminal/route_client-reference-manifest.js +1 -1
  19. package/.next/server/app/api/assistant/tools/route_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  21. package/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  22. package/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  23. package/.next/server/app/api/capabilities/route.js +1 -1
  24. package/.next/server/app/api/capabilities/route_client-reference-manifest.js +1 -1
  25. package/.next/server/app/api/daily-summary/route_client-reference-manifest.js +1 -1
  26. package/.next/server/app/api/daily-summary/status/route_client-reference-manifest.js +1 -1
  27. package/.next/server/app/api/external-apps/[id]/health/route_client-reference-manifest.js +1 -1
  28. package/.next/server/app/api/external-apps/[id]/route_client-reference-manifest.js +1 -1
  29. package/.next/server/app/api/external-apps/route_client-reference-manifest.js +1 -1
  30. package/.next/server/app/api/fs/browse/route_client-reference-manifest.js +1 -1
  31. package/.next/server/app/api/fs/recent-paths/route_client-reference-manifest.js +1 -1
  32. package/.next/server/app/api/hooks/agent-event/route_client-reference-manifest.js +1 -1
  33. package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
  34. package/.next/server/app/api/hooks/permission-request/route_client-reference-manifest.js +1 -1
  35. package/.next/server/app/api/metrics/vibe/route_client-reference-manifest.js +1 -1
  36. package/.next/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
  37. package/.next/server/app/api/push/escalation/route_client-reference-manifest.js +1 -1
  38. package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
  39. package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
  40. package/.next/server/app/api/relays/[relayId]/cancel/route.js +1 -1
  41. package/.next/server/app/api/relays/[relayId]/cancel/route.js.nft.json +1 -1
  42. package/.next/server/app/api/relays/[relayId]/cancel/route_client-reference-manifest.js +1 -1
  43. package/.next/server/app/api/relays/route.js +1 -1
  44. package/.next/server/app/api/relays/route.js.nft.json +1 -1
  45. package/.next/server/app/api/relays/route_client-reference-manifest.js +1 -1
  46. package/.next/server/app/api/remote/pair/route_client-reference-manifest.js +1 -1
  47. package/.next/server/app/api/repositories/[id]/route_client-reference-manifest.js +1 -1
  48. package/.next/server/app/api/repositories/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  49. package/.next/server/app/api/repositories/[id]/todos/route_client-reference-manifest.js +1 -1
  50. package/.next/server/app/api/repositories/clone/[jobId]/route_client-reference-manifest.js +1 -1
  51. package/.next/server/app/api/repositories/clone/route_client-reference-manifest.js +1 -1
  52. package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
  53. package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
  54. package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
  55. package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +1 -1
  56. package/.next/server/app/api/repositories/sync/route_client-reference-manifest.js +1 -1
  57. package/.next/server/app/api/repositories/validate-path/route_client-reference-manifest.js +1 -1
  58. package/.next/server/app/api/settings/default-agents/route_client-reference-manifest.js +1 -1
  59. package/.next/server/app/api/settings/default-surface-mode/route_client-reference-manifest.js +1 -1
  60. package/.next/server/app/api/sidebar/group-order/route_client-reference-manifest.js +1 -1
  61. package/.next/server/app/api/skills/[id]/route_client-reference-manifest.js +1 -1
  62. package/.next/server/app/api/skills/installations/route_client-reference-manifest.js +1 -1
  63. package/.next/server/app/api/skills/operations/route_client-reference-manifest.js +1 -1
  64. package/.next/server/app/api/skills/reindex/route_client-reference-manifest.js +1 -1
  65. package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
  66. package/.next/server/app/api/slash-commands/route_client-reference-manifest.js +1 -1
  67. package/.next/server/app/api/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
  68. package/.next/server/app/api/tasks/[taskId]/route_client-reference-manifest.js +1 -1
  69. package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
  70. package/.next/server/app/api/templates/route_client-reference-manifest.js +1 -1
  71. package/.next/server/app/api/todos/route_client-reference-manifest.js +1 -1
  72. package/.next/server/app/api/verification/runs/[runId]/route_client-reference-manifest.js +1 -1
  73. package/.next/server/app/api/verification/runs/route_client-reference-manifest.js +1 -1
  74. package/.next/server/app/api/worktrees/[id]/auto-yes/route_client-reference-manifest.js +1 -1
  75. package/.next/server/app/api/worktrees/[id]/capture/route_client-reference-manifest.js +1 -1
  76. package/.next/server/app/api/worktrees/[id]/clear-composer/route_client-reference-manifest.js +1 -1
  77. package/.next/server/app/api/worktrees/[id]/cli-reference/route_client-reference-manifest.js +1 -1
  78. package/.next/server/app/api/worktrees/[id]/cli-tool/route_client-reference-manifest.js +1 -1
  79. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route_client-reference-manifest.js +1 -1
  80. package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
  81. package/.next/server/app/api/worktrees/[id]/env/route_client-reference-manifest.js +1 -1
  82. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route_client-reference-manifest.js +1 -1
  83. package/.next/server/app/api/worktrees/[id]/execution-logs/route_client-reference-manifest.js +1 -1
  84. package/.next/server/app/api/worktrees/[id]/files/[...path]/route_client-reference-manifest.js +1 -1
  85. package/.next/server/app/api/worktrees/[id]/git/branch/create/route_client-reference-manifest.js +1 -1
  86. package/.next/server/app/api/worktrees/[id]/git/branch/delete/route_client-reference-manifest.js +1 -1
  87. package/.next/server/app/api/worktrees/[id]/git/branches/route_client-reference-manifest.js +1 -1
  88. package/.next/server/app/api/worktrees/[id]/git/checkout/route_client-reference-manifest.js +1 -1
  89. package/.next/server/app/api/worktrees/[id]/git/commit/route_client-reference-manifest.js +1 -1
  90. package/.next/server/app/api/worktrees/[id]/git/diff/route_client-reference-manifest.js +1 -1
  91. package/.next/server/app/api/worktrees/[id]/git/fetch/route_client-reference-manifest.js +1 -1
  92. package/.next/server/app/api/worktrees/[id]/git/log/route_client-reference-manifest.js +1 -1
  93. package/.next/server/app/api/worktrees/[id]/git/pull/route_client-reference-manifest.js +1 -1
  94. package/.next/server/app/api/worktrees/[id]/git/push/route_client-reference-manifest.js +1 -1
  95. package/.next/server/app/api/worktrees/[id]/git/reset/route_client-reference-manifest.js +1 -1
  96. package/.next/server/app/api/worktrees/[id]/git/revert/route_client-reference-manifest.js +1 -1
  97. package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route_client-reference-manifest.js +1 -1
  98. package/.next/server/app/api/worktrees/[id]/git/stage/route_client-reference-manifest.js +1 -1
  99. package/.next/server/app/api/worktrees/[id]/git/staged/route_client-reference-manifest.js +1 -1
  100. package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route_client-reference-manifest.js +1 -1
  101. package/.next/server/app/api/worktrees/[id]/git/stash/apply/route_client-reference-manifest.js +1 -1
  102. package/.next/server/app/api/worktrees/[id]/git/stash/pop/route_client-reference-manifest.js +1 -1
  103. package/.next/server/app/api/worktrees/[id]/git/stash/push/route_client-reference-manifest.js +1 -1
  104. package/.next/server/app/api/worktrees/[id]/git/stash/route_client-reference-manifest.js +1 -1
  105. package/.next/server/app/api/worktrees/[id]/git/status/route_client-reference-manifest.js +1 -1
  106. package/.next/server/app/api/worktrees/[id]/git/unstage/route_client-reference-manifest.js +1 -1
  107. package/.next/server/app/api/worktrees/[id]/git/working-diff/route_client-reference-manifest.js +1 -1
  108. package/.next/server/app/api/worktrees/[id]/instances/notes/route_client-reference-manifest.js +1 -1
  109. package/.next/server/app/api/worktrees/[id]/instances/opencode/route_client-reference-manifest.js +1 -1
  110. package/.next/server/app/api/worktrees/[id]/interrupt/route_client-reference-manifest.js +1 -1
  111. package/.next/server/app/api/worktrees/[id]/kill-session/route_client-reference-manifest.js +1 -1
  112. package/.next/server/app/api/worktrees/[id]/logs/[filename]/route_client-reference-manifest.js +1 -1
  113. package/.next/server/app/api/worktrees/[id]/logs/route_client-reference-manifest.js +1 -1
  114. package/.next/server/app/api/worktrees/[id]/marp-render/route_client-reference-manifest.js +1 -1
  115. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route_client-reference-manifest.js +1 -1
  116. package/.next/server/app/api/worktrees/[id]/memos/route_client-reference-manifest.js +1 -1
  117. package/.next/server/app/api/worktrees/[id]/messages/route_client-reference-manifest.js +1 -1
  118. package/.next/server/app/api/worktrees/[id]/opencode/diff/route_client-reference-manifest.js +1 -1
  119. package/.next/server/app/api/worktrees/[id]/opencode/session/route_client-reference-manifest.js +1 -1
  120. package/.next/server/app/api/worktrees/[id]/opencode/share/route_client-reference-manifest.js +1 -1
  121. package/.next/server/app/api/worktrees/[id]/prompt-response/route_client-reference-manifest.js +1 -1
  122. package/.next/server/app/api/worktrees/[id]/resolve-target/route_client-reference-manifest.js +1 -1
  123. package/.next/server/app/api/worktrees/[id]/respond/route_client-reference-manifest.js +1 -1
  124. package/.next/server/app/api/worktrees/[id]/route_client-reference-manifest.js +1 -1
  125. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route_client-reference-manifest.js +1 -1
  126. package/.next/server/app/api/worktrees/[id]/schedules/active/route_client-reference-manifest.js +1 -1
  127. package/.next/server/app/api/worktrees/[id]/schedules/route_client-reference-manifest.js +1 -1
  128. package/.next/server/app/api/worktrees/[id]/search/route_client-reference-manifest.js +1 -1
  129. package/.next/server/app/api/worktrees/[id]/send/route.js +1 -1
  130. package/.next/server/app/api/worktrees/[id]/send/route_client-reference-manifest.js +1 -1
  131. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route_client-reference-manifest.js +1 -1
  132. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route_client-reference-manifest.js +1 -1
  133. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route_client-reference-manifest.js +1 -1
  134. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route_client-reference-manifest.js +1 -1
  135. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route_client-reference-manifest.js +1 -1
  136. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update/route_client-reference-manifest.js +1 -1
  137. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update-plan/route_client-reference-manifest.js +1 -1
  138. package/.next/server/app/api/worktrees/[id]/skills/route_client-reference-manifest.js +1 -1
  139. package/.next/server/app/api/worktrees/[id]/slash-commands/route_client-reference-manifest.js +1 -1
  140. package/.next/server/app/api/worktrees/[id]/special-keys/route_client-reference-manifest.js +1 -1
  141. package/.next/server/app/api/worktrees/[id]/tasks/route_client-reference-manifest.js +1 -1
  142. package/.next/server/app/api/worktrees/[id]/terminal/route_client-reference-manifest.js +1 -1
  143. package/.next/server/app/api/worktrees/[id]/timers/history/route_client-reference-manifest.js +1 -1
  144. package/.next/server/app/api/worktrees/[id]/timers/route_client-reference-manifest.js +1 -1
  145. package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  146. package/.next/server/app/api/worktrees/[id]/todos/route_client-reference-manifest.js +1 -1
  147. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route_client-reference-manifest.js +1 -1
  148. package/.next/server/app/api/worktrees/[id]/tree/route_client-reference-manifest.js +1 -1
  149. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route_client-reference-manifest.js +1 -1
  150. package/.next/server/app/api/worktrees/[id]/verify/config/route_client-reference-manifest.js +1 -1
  151. package/.next/server/app/api/worktrees/[id]/verify/route_client-reference-manifest.js +1 -1
  152. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/cancel/route_client-reference-manifest.js +1 -1
  153. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route_client-reference-manifest.js +1 -1
  154. package/.next/server/app/api/worktrees/[id]/verify/runs/route_client-reference-manifest.js +1 -1
  155. package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
  156. package/.next/server/app/api/worktrees/apply-default-agents/route_client-reference-manifest.js +1 -1
  157. package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
  158. package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  159. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  160. package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
  161. package/.next/server/app/more/page_client-reference-manifest.js +1 -1
  162. package/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  163. package/.next/server/app/page_client-reference-manifest.js +1 -1
  164. package/.next/server/app/proxy/[...path]/route_client-reference-manifest.js +1 -1
  165. package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
  166. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  167. package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  168. package/.next/server/app/skills/[skillId]/page_client-reference-manifest.js +1 -1
  169. package/.next/server/app/skills/installed/page_client-reference-manifest.js +1 -1
  170. package/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  171. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
  172. package/.next/server/app/worktrees/[id]/page.js +1 -1
  173. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
  174. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
  175. package/.next/server/app-paths-manifest.json +27 -27
  176. package/.next/server/chunks/3077.js +1 -1
  177. package/.next/server/chunks/434.js +1 -0
  178. package/.next/server/chunks/595.js +3 -3
  179. package/.next/server/chunks/6130.js +1 -1
  180. package/.next/server/chunks/8807.js +10 -10
  181. package/.next/server/middleware-manifest.json +5 -5
  182. package/.next/server/pages/500.html +1 -1
  183. package/.next/server/server-reference-manifest.json +1 -1
  184. package/.next/server/src/middleware.js +1 -1
  185. package/.next/server/src/middleware.js.map +1 -1
  186. package/.next/static/chunks/{4718-2d9f0397a8f931c4.js → 4718-29cfcfb806724d9a.js} +1 -1
  187. package/.next/static/chunks/app/worktrees/[id]/{page-a39ec2a0732d11a6.js → page-60eab4e24c37cb77.js} +1 -1
  188. package/.next/trace +13 -13
  189. package/README.md +141 -24
  190. package/dist/cli/commands/remote.d.ts +93 -3
  191. package/dist/cli/commands/remote.d.ts.map +1 -1
  192. package/dist/cli/commands/remote.js +232 -9
  193. package/dist/cli/types/index.d.ts +9 -0
  194. package/dist/cli/types/index.d.ts.map +1 -1
  195. package/dist/cli/utils/api-client.d.ts.map +1 -1
  196. package/dist/cli/utils/api-client.js +11 -1
  197. package/dist/cli/utils/remote-state.d.ts +32 -0
  198. package/dist/cli/utils/remote-state.d.ts.map +1 -1
  199. package/dist/cli/utils/remote-state.js +12 -0
  200. package/dist/server/server.js +204 -16
  201. package/dist/server/src/lib/db/agent-instances-db.js +11 -0
  202. package/dist/server/src/lib/hooks/sources/opencode/ports.js +6 -0
  203. package/dist/server/src/lib/relay/relay-session-ref.js +15 -8
  204. package/dist/server/src/lib/ws-server.js +74 -5
  205. package/package.json +1 -1
  206. package/.next/server/chunks/1049.js +0 -1
  207. /package/.next/static/{gniPBCKoXtbIOQey8kNcx → oDWX0JcwfhUYrMnnqDWVC}/_buildManifest.js +0 -0
  208. /package/.next/static/{gniPBCKoXtbIOQey8kNcx → oDWX0JcwfhUYrMnnqDWVC}/_ssgManifest.js +0 -0
@@ -38,7 +38,7 @@ ${b[a]}`,e=iV(c,n,0);if(-1===e){d.push({line:g,code:"unterminated-quote",severit
38
38
  ${a("git.aiPrompts.stashCleanupCurrent")}
39
39
  ${d}`}(s,a))}),(0,e.jsx)("button",{type:"button",onClick:j,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":s("git.stash.refresh"),children:(0,e.jsx)(jp,{})})]})]}),u&&(0,e.jsxs)("div",{className:"px-3 pb-3 space-y-2",children:[c&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-stash-error",children:c}),f&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-stash-action-error",children:f}),g&&(0,e.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,e.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-stash-conflict",children:g}),r&&(0,e.jsx)(jq,{className:"shrink-0",testId:"stash-conflict-ask-ai",onClick:()=>r(function(a,b){let c=a("git.aiPrompts.stashConflict");return b&&b.trim().length>0?`${c}
40
40
 
41
- ${b.trim()}`:c}(s,g))})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)("input",{type:"text",value:w,onChange:a=>x(a.target.value),placeholder:s("git.stash.messagePlaceholder"),className:"w-full px-2 py-1 text-xs border border-input rounded bg-surface dark:bg-surface-2 text-foreground","data-testid":"git-stash-push-message"}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,e.jsx)(n.Sc,{checked:y,onCheckedChange:a=>z(!0===a),"data-testid":"git-stash-include-untracked"}),s("git.stash.includeUntracked")]}),(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>{l(w,y),x(""),z(!1)},className:"px-2 py-1 text-xs rounded bg-accent-600 hover:bg-accent-700 text-white disabled:opacity-50","data-testid":"stash-push-button",children:s("git.stash.push")})]})]}),b?(0,e.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",role:"status",children:s("git.stash.loading")}):0===a.length?(0,e.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",children:s("git.stash.empty")}):(0,e.jsx)("ul",{className:"divide-y divide-border",children:a.map(a=>(0,e.jsx)("li",{className:"py-1.5","data-testid":"git-stash-row",children:(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("span",{className:"font-mono text-xs text-accent-600 dark:text-accent-400",children:["stash@","{",a.index,"}"]}),(0,e.jsx)("span",{className:"ml-2 text-xs text-foreground truncate",children:a.message})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>o(a.index),className:"px-1.5 py-0.5 text-xs rounded border border-input hover:bg-muted disabled:opacity-50","data-testid":"stash-apply-button",children:s("git.stash.apply")}),(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>m(a.index),className:"px-1.5 py-0.5 text-xs rounded border border-input hover:bg-muted disabled:opacity-50","data-testid":"stash-pop-button",children:s("git.stash.pop")}),(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>B(a.index),className:"px-1.5 py-0.5 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"stash-drop-button",children:s("git.stash.drop")})]})]})},a.index))})]}),null!==A&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"git-stash-drop-confirm",role:"dialog",children:[(0,e.jsxs)("p",{className:"text-xs text-danger-foreground",children:["stash@","{",A,"}",s("git.stash.dropConfirmSuffix")]}),i&&(0,e.jsx)("p",{className:"mt-1 text-xs text-danger-foreground","data-testid":"git-stash-drop-session-warning",children:s("git.danger.runningSessionWarning")}),(0,e.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>{p(A),B(null)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"git-stash-drop-confirm-button",children:s("git.stash.drop")}),(0,e.jsx)("button",{type:"button",onClick:()=>B(null),className:"px-2 py-1 text-xs rounded border border-input hover:bg-muted",children:t("cancel")})]})]})]})}),jD={soft:"git.danger.modeSoft",mixed:"git.danger.modeMixed",hard:"git.danger.modeHard"},jE=(0,h.memo)(function({selectedCommit:a,busy:b,actionError:c,conflictNotice:d,currentBranch:f,aheadCount:g,hasRunningSession:i,onReset:j,onRevert:l,onForcePush:m}){let{isMobile:o,onInsertToMessage:p}=ji(),q=(0,k.c)("worktree"),r=(0,k.c)("common"),[s,t]=(0,h.useState)(!1),[u,v]=(0,h.useState)("mixed"),[w,x]=(0,h.useState)(!0),[y,z]=(0,h.useState)(""),[A,B]=(0,h.useState)(!1),[C,D]=(0,h.useState)(!1),[E,F]=(0,h.useState)(!1),[G,H]=(0,h.useState)(!1),[I,J]=(0,h.useState)(!0),K=w?"HEAD":a,L=!w&&!a;return(0,e.jsxs)("div",{className:"border-t-2 border-danger-border","data-testid":"git-danger-zone-section",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>t(a=>!a),className:"w-full flex items-center gap-1 px-3 py-2 text-sm font-medium text-danger-foreground bg-danger-subtle cursor-pointer hover:bg-danger-subtle","data-testid":"git-danger-zone-toggle",children:[(0,e.jsx)("span",{className:"text-xs w-4 text-center",children:s?"▼":"▶"}),q("git.danger.title")]}),s&&(0,e.jsxs)("div",{className:"px-3 py-3 space-y-2 bg-danger-subtle",children:[c&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-danger-zone-error",children:c}),d&&(0,e.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-danger-zone-conflict",children:d}),(0,e.jsxs)("div",{className:`flex ${o?"flex-col":"flex-row"} gap-2`,children:[(0,e.jsx)("button",{type:"button",onClick:()=>B(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle","data-testid":"git-danger-zone-reset-open",children:q("git.danger.resetOpen")}),(0,e.jsx)("button",{type:"button",disabled:!a,onClick:()=>D(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"git-danger-zone-revert-open",children:q("git.danger.revertOpen")}),m&&(0,e.jsx)("button",{type:"button",disabled:b,onClick:()=>H(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"git-force-push-open",children:q("git.danger.forcePushOpen")})]}),!a&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:q("git.danger.selectCommitHint")})]}),A&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"reset-confirm",role:"dialog",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:q("git.danger.resetTitle")}),(0,e.jsxs)(n.z6,{value:w?"head":"commit",onValueChange:a=>x("head"===a),name:"reset-target",className:"flex flex-col gap-1 mb-2",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,e.jsx)(n.CU,{value:"head","data-testid":"reset-target-head"}),q("git.danger.resetTargetHead")]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,e.jsx)(n.CU,{value:"commit",disabled:!a,"data-testid":"reset-target-commit"}),q("git.danger.resetTargetSelectedPrefix"),a?q("git.danger.resetTargetSelectedHash",{hash:a.slice(0,7)}):q("git.danger.resetTargetNoneSelected")]})]}),(0,e.jsx)(n.z6,{value:u,onValueChange:a=>v(a),name:"reset-mode",className:"flex flex-col gap-1 mb-2",children:["soft","mixed","hard"].map(a=>(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,e.jsx)(n.CU,{value:a,"data-testid":`reset-mode-${a}`}),q(jD[a])]},a))}),"hard"===u&&(0,e.jsxs)("div",{className:"mb-2 space-y-1",children:[(0,e.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-history-loss-warning",children:q("git.danger.resetHardWarning")}),i&&(0,e.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-session-warning",children:q("git.danger.runningSessionWarning")}),(0,e.jsx)("input",{type:"text",value:y,onChange:a=>z(a.target.value),placeholder:q("git.danger.confirmPlaceholder",{branch:f??""}),className:"w-full px-2 py-1 text-xs border border-danger-border rounded bg-surface dark:bg-surface-2 text-foreground","data-testid":"reset-hard-branch-input"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,e.jsx)(jq,{className:"mr-auto",testId:"reset-ask-ai",disabled:L,onClick:()=>{K&&(p("hard"===u?q("git.aiPrompts.resetHard",{target:jz(K)}):q("git.aiPrompts.reset",{target:jz(K),mode:u})),B(!1),z(""))}}),(0,e.jsx)("button",{type:"button",disabled:b||L||"hard"===u&&y!==(f??""),onClick:()=>{K&&(j(K,u,"hard"===u?y:void 0),B(!1),z(""))},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"reset-confirm-button",children:q("git.danger.reset")}),(0,e.jsx)("button",{type:"button",onClick:()=>{B(!1),z("")},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:r("cancel")})]})]}),C&&a&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"revert-confirm",role:"dialog",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:q("git.danger.revertTitle")}),(0,e.jsxs)("p",{className:"text-xs text-foreground mb-2",children:[q("git.danger.revertBodyPrefix"),(0,e.jsx)("span",{className:"font-mono",children:a.slice(0,7)})]}),i&&(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"revert-session-warning",children:q("git.danger.runningSessionWarning")}),(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,e.jsx)(n.Sc,{checked:E,onCheckedChange:a=>F(!0===a),"data-testid":"revert-no-commit"}),q("git.danger.revertNoCommit")]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,e.jsx)(jq,{className:"mr-auto",testId:"revert-ask-ai",onClick:()=>{p(q("git.aiPrompts.revert",{commit:jz(a.slice(0,7))})),D(!1),F(!1)}}),(0,e.jsx)("button",{type:"button",disabled:b,onClick:()=>{l(a,E),D(!1),F(!1)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"revert-confirm-button",children:q("git.danger.revert")}),(0,e.jsx)("button",{type:"button",onClick:()=>{D(!1),F(!1)},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:r("cancel")})]})]}),G&&m&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"force-push-confirm",role:"dialog",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:q("git.danger.forcePushTitle")}),(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-protected-branch-warning",children:q("git.danger.protectedBranchWarning")}),i&&(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-session-warning",children:q("git.danger.runningSessionWarning")}),(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,e.jsx)(n.Sc,{checked:I,onCheckedChange:a=>J(!0===a),"data-testid":"force-push-with-lease"}),q("git.danger.forceWithLease")]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,e.jsx)(jq,{className:"mr-auto",testId:"force-push-ask-ai",onClick:()=>{p(function(a,{branch:b,ahead:c}){let d=b?jz(b):a("git.aiPrompts.forcePushCurrentBranch");return a("number"==typeof c&&c>0?"git.aiPrompts.forcePushAhead":"git.aiPrompts.forcePush",{branchRef:d,upstream:jz(`origin/${b??"<branch>"}`),ahead:c??0})}(q,{branch:f,ahead:g??null})),H(!1)}}),(0,e.jsx)("button",{type:"button",disabled:b,onClick:()=>{m(I),H(!1)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"force-push-confirm-button",children:q("git.danger.forcePush")}),(0,e.jsx)("button",{type:"button",onClick:()=>H(!1),className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:r("cancel")})]})]})]})}),jF=(0,h.memo)(function({worktreeId:a,onDiffSelect:b,isMobile:c=!1,worktree:d,onInsertToMessage:f,className:g=""}){let i=(0,k.c)("worktree"),{activeTab:j,setActiveTab:l,historyOpen:m,toggleHistory:o,advancedOpen:p,toggleAdvanced:q}=function(){let{value:a,setValue:b,isAvailable:c}=(0,cq.V)({key:ja.activeTab,defaultValue:"status",validate:jb}),{value:d,setValue:e}=(0,cq.V)({key:ja.historyOpen,defaultValue:!0,validate:jc}),{value:f,setValue:g}=(0,cq.V)({key:ja.advancedOpen,defaultValue:!1,validate:jc}),i=(0,h.useCallback)(a=>b(a),[b]);return{activeTab:a,setActiveTab:i,historyOpen:d,toggleHistory:(0,h.useCallback)(()=>e(a=>!a),[e]),advancedOpen:f,toggleAdvanced:(0,h.useCallback)(()=>g(a=>!a),[g]),isPersistent:c}}(),r=Object.values(d?.sessionStatusByCli??{}).some(a=>a?.isRunning===!0),{gitStatus:s,statusLoading:t,statusError:u,fetchStatus:v}=function(a){let[b,c]=(0,h.useState)(null),[d,e]=(0,h.useState)(!0),[f,g]=(0,h.useState)(null);return{gitStatus:b,statusLoading:d,statusError:f,fetchStatus:(0,h.useCallback)(async()=>{g(null);try{let b=await fetch(`/api/worktrees/${a}/git/status`);if(!b.ok){let a=await b.json().catch(()=>({}));g(a.error||"Failed to fetch git status");return}let d=await b.json();c(d)}catch{g("Failed to fetch git status")}finally{e(!1)}},[a])}}(a),{commits:w,selectedCommit:x,changedFiles:y,inlineDiffCommit:z,inlineFiles:A,inlineFilesLoading:B,inlineFilesError:C,selectedFile:D,diffContent:E,isLoading:F,isLoadingFiles:G,isLoadingDiff:H,commitError:I,detailError:J,setDiffContent:K,fetchCommits:L,handleCommitSelect:M,handleFileSelect:N,handleToggleInlineDiff:O,handleInlineDiffFile:P,handleRefresh:Q}=function(a,b){let[c,d]=(0,h.useState)([]),[e,f]=(0,h.useState)(null),[g,i]=(0,h.useState)([]),[j,k]=(0,h.useState)(null),[l,m]=(0,h.useState)([]),[n,o]=(0,h.useState)(!1),[p,q]=(0,h.useState)(null),[r,s]=(0,h.useState)(null),[t,u]=(0,h.useState)(null),[v,w]=(0,h.useState)(!0),[x,y]=(0,h.useState)(!1),[z,A]=(0,h.useState)(!1),[B,C]=(0,h.useState)(null),[D,E]=(0,h.useState)(null),F=(0,h.useCallback)(async()=>{w(!0),C(null);try{let b=await fetch(`/api/worktrees/${a}/git/log`);if(!b.ok){let a=await b.json();C(a.error||"Failed to fetch commit history");return}let c=await b.json();d(c.commits)}catch{C("Failed to fetch commit history")}finally{w(!1)}},[a]),G=(0,h.useCallback)(async b=>{y(!0),i([]),s(null),u(null),E(null);try{let c=await fetch(`/api/worktrees/${a}/git/show/${b}`);if(!c.ok){let a=await c.json();E(a.error||"Failed to fetch commit details");return}let d=await c.json();i(d.files)}catch{E("Failed to fetch commit details")}finally{y(!1)}},[a]),H=(0,h.useCallback)(async(c,d)=>{A(!0),u(null),E(null);try{let e=await fetch(`/api/worktrees/${a}/git/diff?commit=${c}&file=${encodeURIComponent(d)}`);if(!e.ok){let a=await e.json();E(a.error||"Failed to fetch diff");return}let f=await e.json();u(f.diff),b(f.diff,d)}catch{E("Failed to fetch diff")}finally{A(!1)}},[a,b]),I=(0,h.useCallback)(a=>{f(a),G(a)},[G]),J=(0,h.useCallback)(a=>{e&&(s(a),H(e,a))},[e,H]),K=(0,h.useCallback)(async b=>{if(j===b){k(null),m([]),q(null);return}k(b),m([]),q(null),o(!0);try{let c=await fetch(`/api/worktrees/${a}/git/show/${b}`);if(!c.ok){let a=await c.json().catch(()=>({}));q(a.error||"Failed to fetch commit details");return}let d=await c.json();m(Array.isArray(d.files)?d.files:[])}catch{q("Failed to fetch commit details")}finally{o(!1)}},[a,j]),L=(0,h.useCallback)((a,b)=>{f(a),s(b),i(l),H(a,b)},[l,H]),M=(0,h.useCallback)(()=>{f(null),i([]),s(null),u(null),E(null),F()},[F]);return{commits:c,selectedCommit:e,changedFiles:g,inlineDiffCommit:j,inlineFiles:l,inlineFilesLoading:n,inlineFilesError:p,selectedFile:r,diffContent:t,isLoading:v,isLoadingFiles:x,isLoadingDiff:z,commitError:B,detailError:D,setDiffContent:u,fetchCommits:F,handleCommitSelect:I,handleFileSelect:J,handleToggleInlineDiff:K,handleInlineDiffFile:L,handleRefresh:M}}(a,b),R=(0,h.useCallback)(async()=>{await L(),await v()},[L,v]),{staged:S,stagedLoading:T,stagedError:U,opBusy:V,commitMessage:W,setCommitMessage:X,amend:Y,setAmend:Z,committing:$,changesCommitError:_,fetchStaged:aa,handleStage:ab,handleUnstage:ac,handleChangesDiff:ad,fetchWorkingDiffText:ae,commit:af,commitAndPush:ag}=function(a,b){let{onWorkingDiff:c,onCommitted:d}=b,[e,f]=(0,h.useState)(null),[g,i]=(0,h.useState)(!0),[j,k]=(0,h.useState)(null),[l,m]=(0,h.useState)(!1),[n,o]=(0,h.useState)(""),[p,q]=(0,h.useState)(!1),[r,s]=(0,h.useState)(!1),[t,u]=(0,h.useState)(null),v=(0,h.useCallback)(async()=>{k(null);try{let b=await fetch(`/api/worktrees/${a}/git/staged`);if(!b.ok){let a=await b.json().catch(()=>({}));k(a.error||"Failed to fetch changes");return}let c=await b.json();f(c)}catch{k("Failed to fetch changes")}finally{i(!1)}},[a]),w=(0,h.useCallback)(async b=>{m(!0),k(null);try{let c=await fetch(`/api/worktrees/${a}/git/stage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[b]})});if(!c.ok){let a=await c.json().catch(()=>({}));k(a.error||"Failed to stage file");return}await v()}catch{k("Failed to stage file")}finally{m(!1)}},[a,v]),x=(0,h.useCallback)(async b=>{m(!0),k(null);try{let c=await fetch(`/api/worktrees/${a}/git/unstage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[b]})});if(!c.ok){let a=await c.json().catch(()=>({}));k(a.error||"Failed to unstage file");return}await v()}catch{k("Failed to unstage file")}finally{m(!1)}},[a,v]),y=(0,h.useCallback)(async()=>{u(null);try{let b=await fetch(`/api/worktrees/${a}/git/commit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:n,amend:p})});if(!b.ok){let a=await b.json().catch(()=>({}));return u(a.error||"Failed to commit"),!1}return o(""),q(!1),await v(),await d(),!0}catch{return u("Failed to commit"),!1}},[a,n,p,v,d]),z=(0,h.useCallback)(async()=>{s(!0);try{await y()}finally{s(!1)}},[y]),A=(0,h.useCallback)(async a=>{s(!0);try{await y()&&await a()}finally{s(!1)}},[y]);return{staged:e,stagedLoading:g,stagedError:j,opBusy:l,commitMessage:n,setCommitMessage:o,amend:p,setAmend:q,committing:r,changesCommitError:t,fetchStaged:v,handleStage:w,handleUnstage:x,handleChangesDiff:(0,h.useCallback)(async(b,d)=>{try{let e=await fetch(`/api/worktrees/${a}/git/working-diff?file=${encodeURIComponent(b)}&mode=${d}`);if(!e.ok)return;let f=await e.json();"string"==typeof f.diff&&c(f.diff,b)}catch{}},[a,c]),fetchWorkingDiffText:(0,h.useCallback)(async(b,c)=>{try{let d=await fetch(`/api/worktrees/${a}/git/working-diff?file=${encodeURIComponent(b)}&mode=${c}`);if(!d.ok)return null;let e=await d.json();return"string"==typeof e.diff?e.diff:null}catch{return null}},[a]),commit:z,commitAndPush:A}}(a,{onWorkingDiff:(0,h.useCallback)((a,c)=>{K(a),b(a,c)},[K,b]),onCommitted:R}),{branches:ah,branchInclude:ai,branchesLoading:aj,branchesError:ak,branchBusy:al,branchActionError:am,fetchBranches:an,handleBranchIncludeChange:ao,handleBranchesRefresh:ap,handleCheckout:aq,handleBranchCreate:ar,handleBranchDelete:as}=function(a,b){let{onCheckoutCascade:c}=b,[d,e]=(0,h.useState)([]),[f,g]=(0,h.useState)("local"),[i,j]=(0,h.useState)(!0),[k,l]=(0,h.useState)(null),[m,n]=(0,h.useState)(!1),[o,p]=(0,h.useState)(null),q=(0,h.useCallback)(async b=>{l(null);try{let c=await fetch(`/api/worktrees/${a}/git/branches?include=${b}`);if(!c.ok){let a=await c.json().catch(()=>({}));l(a.error||"Failed to fetch branches");return}let d=await c.json();e(Array.isArray(d.branches)?d.branches:[])}catch{l("Failed to fetch branches")}finally{j(!1)}},[a]),r=(0,h.useCallback)(a=>{g(a)},[]),s=(0,h.useCallback)(()=>{q(f)},[q,f]),t=(0,h.useCallback)(async(b,d)=>{n(!0),p(null);try{let e=await fetch(`/api/worktrees/${a}/git/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:b.name,force:d})});if(!e.ok){let a=await e.json().catch(()=>({}));p(a.error||"Failed to checkout branch");return}await Promise.all([c(),q(f)])}catch{p("Failed to checkout branch")}finally{n(!1)}},[a,f,c,q]),u=(0,h.useCallback)(async(b,c)=>{n(!0),p(null);try{let d=await fetch(`/api/worktrees/${a}/git/branch/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,from:c})});if(!d.ok){let a=await d.json().catch(()=>({}));p(a.error||"Failed to create branch");return}await q(f)}catch{p("Failed to create branch")}finally{n(!1)}},[a,f,q]),v=(0,h.useCallback)(async(b,c)=>{n(!0),p(null);try{let d=await fetch(`/api/worktrees/${a}/git/branch/delete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,force:c})});if(!d.ok){let a=await d.json().catch(()=>({}));p(a.error||"Failed to delete branch");return}await q(f)}catch{p("Failed to delete branch")}finally{n(!1)}},[a,f,q]);return{branches:d,branchInclude:f,branchesLoading:i,branchesError:k,branchBusy:m,branchActionError:o,fetchBranches:q,handleBranchIncludeChange:r,handleBranchesRefresh:s,handleCheckout:t,handleBranchCreate:u,handleBranchDelete:v}}(a,{onCheckoutCascade:(0,h.useCallback)(async()=>{await Promise.all([v(),aa(),L()])},[v,aa,L])}),{stashes:at,stashLoading:au,stashError:av,stashBusy:aw,stashActionError:ax,stashConflictNotice:ay,fetchStash:az,handleStashPush:aA,handleStashPop:aB,handleStashApply:aC,handleStashDrop:aD}=function(a,b){let{onStashMutated:c}=b,[d,e]=(0,h.useState)([]),[f,g]=(0,h.useState)(!0),[i,j]=(0,h.useState)(null),[k,l]=(0,h.useState)(!1),[m,n]=(0,h.useState)(null),[o,p]=(0,h.useState)(null),q=(0,h.useCallback)(async()=>{j(null);try{let b=await fetch(`/api/worktrees/${a}/git/stash`);if(!b.ok){let a=await b.json().catch(()=>({}));j(a.error||"Failed to fetch stashes");return}let c=await b.json();e(Array.isArray(c.stashes)?c.stashes:[])}catch{j("Failed to fetch stashes")}finally{g(!1)}},[a]),r=(0,h.useCallback)(async()=>{await Promise.all([q(),c()])},[q,c]),s=(0,h.useCallback)(async(a,b,c)=>{l(!0),n(null),p(null);try{let d=await fetch(a,b),e=await d.json().catch(()=>({}));if(!d.ok)return void n(e.error||c);if(e.conflict){let a=Array.isArray(e.conflictFiles)?e.conflictFiles.join(", "):"",b=e.stashRetained?" (stash retained)":"";p(`Stash operation produced conflicts: ${a}${b}`)}await r()}catch{n(c)}finally{l(!1)}},[r]),t=(0,h.useCallback)((b,c)=>{s(`/api/worktrees/${a}/git/stash/push`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:b||void 0,includeUntracked:c})},"Failed to stash changes")},[a,s]),u=(0,h.useCallback)(b=>{s(`/api/worktrees/${a}/git/stash/pop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:b})},"Failed to pop stash")},[a,s]);return{stashes:d,stashLoading:f,stashError:i,stashBusy:k,stashActionError:m,stashConflictNotice:o,fetchStash:q,handleStashPush:t,handleStashPop:u,handleStashApply:(0,h.useCallback)(b=>{s(`/api/worktrees/${a}/git/stash/apply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:b})},"Failed to apply stash")},[a,s]),handleStashDrop:(0,h.useCallback)(b=>{s(`/api/worktrees/${a}/git/stash/${b}`,{method:"DELETE"},"Failed to drop stash")},[a,s])}}(a,{onStashMutated:(0,h.useCallback)(async()=>{await Promise.all([v(),aa()])},[v,aa])}),{dangerBusy:aE,dangerActionError:aF,dangerConflictNotice:aG,handleReset:aH,handleRevert:aI}=function(a,b){let{onHeadMoved:c}=b,[d,e]=(0,h.useState)(!1),[f,g]=(0,h.useState)(null),[i,j]=(0,h.useState)(null);return{dangerBusy:d,dangerActionError:f,dangerConflictNotice:i,handleReset:(0,h.useCallback)(async(b,d,f)=>{e(!0),g(null),j(null);try{let e=await fetch(`/api/worktrees/${a}/git/reset`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:b,mode:d,confirmBranch:f})});if(!e.ok){let a=await e.json().catch(()=>({}));g(a.error||"Failed to reset");return}await c()}catch{g("Failed to reset")}finally{e(!1)}},[a,c]),handleRevert:(0,h.useCallback)(async(b,d)=>{e(!0),g(null),j(null);try{let e=await fetch(`/api/worktrees/${a}/git/revert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitHash:b,noCommit:d})});if(!e.ok){let a=await e.json().catch(()=>({}));g(a.error||"Failed to revert");return}let f=await e.json().catch(()=>({}));if(f.conflict){let a=Array.isArray(f.conflictFiles)?f.conflictFiles.join(", "):"";j(`Revert produced conflicts: ${a}`)}await c()}catch{g("Failed to revert")}finally{e(!1)}},[a,c])}}(a,{onHeadMoved:(0,h.useCallback)(async()=>{await Promise.all([v(),aa(),an(ai),L()])},[v,aa,an,ai,L])}),{operation:aJ,progressState:aK,error:aL,errorReason:aM,conflict:aN,conflictFiles:aO,runFetch:aP,runPull:aQ,runPush:aR,abort:aS}=function(a,b={}){let{onCascade:c}=b,[d,e]=(0,h.useState)(null),[f,g]=(0,h.useState)("idle"),[i,j]=(0,h.useState)(null),[k,l]=(0,h.useState)(null),[m,n]=(0,h.useState)(!1),[o,p]=(0,h.useState)([]),q=(0,h.useRef)(null),r=(0,h.useRef)(c),s=(0,h.useCallback)(async(b,c,d)=>{j(null),l(null),n(!1),p([]),e(b),g("running");let f=new AbortController;q.current=f;try{let e=await fetch(`/api/worktrees/${a}/git/${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d),signal:f.signal});if(!e.ok){var h,i;let a=await e.json().catch(()=>({}));l((h=a?.reason,"auth_failed"===h?"auth_failed":"protected_branch"===h?"protected_branch":null)),j((i=a?.error,"string"==typeof i&&i.length>0?i:null)),g("error");return}let k=await e.json().catch(()=>({success:!0}));"pull"===b&&k?.conflict&&(n(!0),p(Array.isArray(k.conflictFiles)?k.conflictFiles:[])),g("idle")}catch(a){a instanceof Error&&"AbortError"===a.name?g("idle"):(j(null),l(null),g("error"))}finally{e(null),q.current=null,r.current?.(b)}},[a]),t=(0,h.useCallback)(a=>{let b={prune:!0===a.prune};return void 0!==a.remote&&(b.remote=a.remote),s("fetch","fetch",b)},[s]),u=(0,h.useCallback)(a=>{let b={rebase:!0===a.rebase,ffOnly:!0===a.ffOnly};return void 0!==a.remote&&(b.remote=a.remote),void 0!==a.branch&&(b.branch=a.branch),s("pull","pull",b)},[s]);return{operation:d,progressState:f,error:i,errorReason:k,conflict:m,conflictFiles:o,runFetch:t,runPull:u,runPush:(0,h.useCallback)(a=>{let b={force:!0===a.force,forceWithLease:!0===a.forceWithLease,setUpstream:!0===a.setUpstream};return void 0!==a.remote&&(b.remote=a.remote),void 0!==a.branch&&(b.branch=a.branch),s("push","push",b)},[s]),abort:(0,h.useCallback)(()=>{q.current?.abort()},[])}}(a,{onCascade:(0,h.useCallback)(a=>{v(),an(ai),"pull"===a&&(aa(),L())},[v,an,ai,aa,L])}),aT="auth_failed"===aM?i("git.network.authFailedGuidance"):"protected_branch"===aM?i("git.danger.protectedBranchWarning"):aL,aU="running"===aK&&("push"===aJ||"pull"===aJ),aV=s?.aheadBehind!=null,aW=(0,h.useCallback)(()=>{aP({})},[aP]),aX=(0,h.useCallback)(()=>ag(()=>aR({setUpstream:!aV})),[ag,aR,aV]);gt({intervalMs:5e3,enabled:"running"!==aK,onPoll:v});let aY=(0,h.useMemo)(()=>({isMobile:c,onDiffSelect:b,onInsertToMessage:f}),[c,b,f]),aZ=(0,e.jsx)(ju,{gitStatus:s,statusLoading:t,statusError:u,onRefresh:aW,refreshing:"running"===aK}),a$=(0,e.jsx)(jv,{progressState:aK,operation:aJ,error:aT,conflict:aN,conflictFiles:aO,hasUpstream:aV,onPull:()=>aQ({}),onPush:()=>aR({setUpstream:!aV}),onAbort:aS,extraActions:(0,e.jsx)(je,{branches:ah,busy:al||aU,actionError:am,hasRunningSession:r,isMobile:c,onCheckout:aq})}),a_=(0,e.jsx)(jx,{staged:S,loading:T,error:U,busy:V||aU,commitMessage:W,amend:Y,committing:$,commitError:_,onRefresh:aa,onDiff:ad,onPreview:ae,onStage:ab,onUnstage:ac,onCommitMessageChange:X,onAmendChange:Z,onCommit:af,onCommitAndPush:aX}),a0=(0,e.jsx)(jy,{commits:w,isLoading:F,commitError:I,commitListOpen:m,onToggleCommitList:o,onRefresh:Q,selectedCommit:x,onCommitSelect:M,inlineDiffCommit:z,inlineFiles:A,inlineFilesLoading:B,inlineFilesError:C,onToggleInlineDiff:O,onInlineDiffFile:P,changedFiles:y,isLoadingFiles:G,detailError:J,selectedFile:D,onFileSelect:N,diffContent:E,isLoadingDiff:H}),a1=(0,e.jsxs)(jf,{open:p,onToggle:q,children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-advanced-fetch",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:i("git.remote")}),(0,e.jsx)("div",{children:(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:()=>aP({}),disabled:"running"===aK,className:"px-2 py-1 text-xs rounded border border-input text-foreground hover:bg-muted disabled:opacity-50","data-testid":"git-fetch-button",children:i("git.network.fetch")})})]}),(0,e.jsx)(jB,{branches:ah,include:ai,loading:aj,error:ak,busy:al||aU,actionError:am,onIncludeChange:ao,onRefresh:ap,onCreate:ar,onDelete:as}),(0,e.jsx)(jC,{stashes:at,loading:au,error:av,busy:aw||aU,actionError:ax,conflictNotice:ay,hasRunningSession:r,onRefresh:az,onPush:aA,onPop:aB,onApply:aC,onDrop:aD}),(0,e.jsx)(jE,{selectedCommit:x,busy:aE||aU,actionError:aF,conflictNotice:aG,currentBranch:s?.currentBranch??null,aheadCount:s?.aheadBehind?.ahead??null,hasRunningSession:r,onReset:aH,onRevert:aI,onForcePush:a=>aR(a?{forceWithLease:!0}:{force:!0})})]});return(0,e.jsx)(jh,{value:aY,children:(0,e.jsx)(jn,{activeTab:j,onTabChange:l,className:g,statusSection:aZ,quickActionsSection:a$,changesSection:a_,historySection:a0,advancedSection:a1})})}),jG=(0,h.memo)(function({worktreeId:a,worktree:b,onWorktreeUpdate:c}){let[d,f]=(0,h.useState)(!1),g=(0,k.c)("worktree"),i=(0,h.useRef)(b?.id),j=(0,h.useRef)(!1),l=jP(b,c,b?.id,()=>{let a=b?.id!==i.current;return i.current=b?.id,a&&!j.current});return(j.current=l.isEditing,b)?(0,e.jsx)("div",{className:"p-4 space-y-4 overflow-y-auto h-full",children:(0,e.jsx)(jQ,{worktreeId:a,worktree:b,cardClassName:"bg-surface rounded-lg border border-border p-4",descriptionEditor:l,showLogs:d,onToggleLogs:()=>f(!d),onWorktreeUpdate:c})}):(0,e.jsx)("div",{className:"text-muted-foreground text-center py-8",children:g("detail.loadingInfo")})}),jH=(0,h.memo)(function({activeTab:a,worktreeId:b,worktree:c,messages:d,cliToolId:f,instanceId:g,onFilePathClick:h,onFileSelect:i,onWorktreeUpdate:j,onNewFile:l,onNewDirectory:m,onRename:n,onDelete:o,onUpload:p,onMove:q,onFileTreeReset:r,refreshTrigger:s,fileSearch:t,showToast:u,selectedAgents:v,onSelectedAgentsChange:w,availableAgents:x,maxAgents:y,persistToServer:z,vibeLocalModel:A,onVibeLocalModelChange:B,vibeLocalContextWindow:C,onVibeLocalContextWindowChange:D,disableAutoFollow:E,historySubTab:F,onHistorySubTabChange:G,onDiffSelect:H,onInsertToMessage:J,showArchived:K,onShowArchivedChange:L,historyDisplayLimit:M,onHistoryDisplayLimitChange:N,historyUserOnly:O,onHistoryUserOnlyChange:P,useInstanceManagement:Q,instances:R,onInstancesChange:S,visibleInstanceIds:T,onToggleInstanceVisible:U,verification:V,toolsSubTabRequest:W,onSurfaceModeChange:X}){let Y=(0,k.c)("worktree");switch(a){case"terminal":return(0,e.jsx)(I,{componentName:"TerminalDisplay",children:(0,e.jsx)(fw,{worktreeId:b,cliToolId:f,instanceId:g,disableAutoFollow:E,onSurfaceModeChange:X})});case"history":return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsxs)("div",{className:"flex border-b border-border shrink-0",children:[(0,e.jsx)("button",{type:"button",onClick:()=>G("message"),className:`flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ${"message"===F?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"}`,children:Y("detail.subTabMessage")}),(0,e.jsx)("button",{type:"button",onClick:()=>G("git"),className:`flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ${"git"===F?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"}`,children:Y("detail.subTabGit")})]}),"message"===F?(0,e.jsx)(I,{componentName:"HistoryPane",children:(0,e.jsx)(f6,{messages:d,worktreeId:b,onFilePathClick:h,className:"flex-1 min-h-0",showToast:u,onInsertToMessage:J,showArchived:K,onShowArchivedChange:L,historyDisplayLimit:M,onHistoryDisplayLimitChange:N,historyUserOnly:O,onHistoryUserOnlyChange:P})}):(0,e.jsx)(I,{componentName:"GitPane",children:(0,e.jsx)(jF,{worktreeId:b,onDiffSelect:H,isMobile:!0,worktree:c??void 0,onInsertToMessage:J,className:"flex-1 min-h-0"})})]});case"files":return(0,e.jsx)(I,{componentName:"FileTreeView",children:(0,e.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,e.jsx)(gz,{query:t.query,mode:t.mode,isSearching:t.isSearching,error:t.error,onQueryChange:t.setQuery,onModeChange:t.setMode,onClear:t.clearSearch}),(0,e.jsx)(gv,{worktreeId:b,onFileSelect:i,onNewFile:l,onNewDirectory:m,onRename:n,onDelete:o,onUpload:p,onMove:q,onResetView:r,refreshTrigger:s,pollingEnabled:"files"===a,searchQuery:t.query,searchMode:t.mode,searchResults:t.results?.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,e.jsx)(I,{componentName:"NotesAndLogsPane",children:(0,e.jsx)(i7,{worktreeId:b,className:"h-full",selectedAgents:v,onSelectedAgentsChange:w,availableAgents:x,maxAgents:y,persistToServer:z,vibeLocalModel:A,onVibeLocalModelChange:B,vibeLocalContextWindow:C,onVibeLocalContextWindowChange:D,onInsertToMessage:J,useInstanceManagement:Q,instances:R,onInstancesChange:S,visibleInstanceIds:T,onToggleInstanceVisible:U,modelByInstance:jO(c?.sessionStatusByInstance),composerTargetInstanceId:g,verification:V,requestedSubTab:W})});case"info":return(0,e.jsx)(jG,{worktreeId:b,worktree:c,onWorktreeUpdate:j});default:return null}}),jI=[{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 jJ(a,b,c){if(!a)return null;let d=b?`${a} \xb7 ${b}`:a;return c?`${c} \xb7 ${d}`:d}function jK(a,b){if(!a||!a.liveness&&!a.degradedReason)return null;let c=b("sse"===a.kind?"agentSource.kindSse":"scraper"===a.kind?"agentSource.kindScraper":"agentSource.kindHooks"),d=void 0===a.degradedReason?null:"port_identity_changed"===a.degradedReason?b("agentSource.reasonPortIdentityChanged"):"heartbeat_stale"===a.degradedReason?b("agentSource.reasonHeartbeatStale"):"not_subscribed"===a.degradedReason?b("agentSource.reasonNotSubscribed"):b("agentSource.reasonOther",{reason:a.degradedReason}),e=["stale"===a.liveness?b("agentSource.livenessStale"):"live"===a.liveness?b("agentSource.livenessLive"):null,d].filter(a=>null!==a).join(" \xb7 ");return e?b("agentSource.line",{kind:c,state:e}):b("agentSource.lineBare",{kind:c})}function jL(a,b,c=2){return"number"==typeof a&&Number.isFinite(a)?new Intl.NumberFormat(b,{style:"currency",currency:"USD",minimumFractionDigits:c,maximumFractionDigits:c}).format(a):null}function jM(a,b,c,d){var e;let f=jL(a?.cost,d),g=(e=b?.tokens,"number"==typeof e&&Number.isFinite(e)?new Intl.NumberFormat(d,{notation:"compact",maximumFractionDigits:1}).format(e):null),h=[];return f&&h.push(f),g&&h.push("number"==typeof b?.percent?c("agentSession.context",{tokens:g,percent:b.percent}):g),h.length>0?h.join(" \xb7 "):null}function jN(a,b,c,d){let e=[];a?.title&&e.push(c("agentSession.titleLabel",{title:a.title})),a?.agent&&e.push(c("agentSession.agentLabel",{agent:a.agent}));let f=jL(a?.cost,d,4);f&&e.push(c("agentSession.costLabel",{cost:f}));let g=function(a){if(!a)return null;if(null!==a.total)return a.total;let b=[a.input,a.output,a.reasoning,a.cacheRead,a.cacheWrite].filter(a=>"number"==typeof a&&Number.isFinite(a));return 0===b.length?null:b.reduce((a,b)=>a+b,0)}(a?.tokens);if(null!==g&&e.push(c("agentSession.spentLabel",{tokens:new Intl.NumberFormat(d).format(g)})),"number"==typeof b?.tokens){let a=new Intl.NumberFormat(d).format(b.tokens);e.push("number"==typeof b.limit&&"number"==typeof b.percent?c("agentSession.contextLabel",{tokens:a,limit:new Intl.NumberFormat(d).format(b.limit),percent:b.percent}):c("agentSession.contextUnknownLabel",{tokens:a}))}return e.length>0?e.join("\n"):null}function jO(a){if(!a)return{};let b={};for(let[c,d]of Object.entries(a)){let a=jJ(d?.model,d?.reasoningEffort);a&&(b[c]=a)}return b}function jP(a,b,c,d){let[e,f]=(0,h.useState)(!1),[g,i]=(0,h.useState)(""),[j,k]=(0,h.useState)(!1),l=(0,h.useCallback)(async()=>{if(a){k(!0);try{let c=await al.y.updateDescription(a.id,g);b(c),f(!1)}catch(a){console.error("Failed to save description:",a)}finally{k(!1)}}},[a,g,b]),m=(0,h.useCallback)(()=>{i(a?.description||""),f(!1)},[a]);return{isEditing:e,text:g,setText:i,isSaving:j,handleSave:l,handleCancel:m,startEditing:(0,h.useCallback)(()=>{f(!0)},[])}}let jQ=(0,h.memo)(function({worktreeId:a,worktree:b,cardClassName:c,descriptionEditor:d,showLogs:f,onToggleLogs:g,onWorktreeUpdate:i}){let{isEditing:j,text:l,setText:m,isSaving:o,handleSave:p,handleCancel:q,startEditing:r}=d,s=(0,k.c)("worktree"),t=(0,k.c)("common"),{copied:u,markCopied:v}=(0,bc.q)(),{copied:w,markCopied:x}=(0,bc.q)(),y=(0,h.useCallback)(async()=>{try{await (0,aZ.l)(b.path),v()}catch{}},[b.path,v]),z=(0,h.useCallback)(async()=>{try{await (0,aZ.l)(b.repositoryPath),x()}catch{}},[b.repositoryPath,x]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.worktree")}),(0,e.jsx)("p",{className:"text-lg font-semibold text-foreground",children:b.name})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.repository")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:z,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":s("detail.copyRepositoryPath"),title:w?s("detail.copied"):s("detail.copyRepositoryPath"),children:w?(0,e.jsx)(az.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(aU,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("p",{className:"text-base text-foreground",children:b.repositoryDisplayName??b.repositoryName}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:b.repositoryPath})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.path")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:y,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":s("detail.copyWorktreePath"),title:u?s("detail.copied"):s("detail.copyPath"),children:u?(0,e.jsx)(az.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(aU,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("p",{className:"text-sm text-foreground break-all font-mono",children:b.path})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.status")}),(0,e.jsx)("select",{value:b.status??"",onChange:async a=>{let c=a.target.value;try{let a=await fetch(`/api/worktrees/${b.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:""===c?null:c})});if(a.ok&&i){let b=await a.json();i(b)}}catch{}},className:"text-sm px-3 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent w-full","data-testid":"mobile-status-dropdown","aria-label":s("detail.worktreeStatusLabel"),children:jI.map(a=>(0,e.jsx)("option",{value:a.value??"",children:s(a.labelKey)},a.labelKey))})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.description")}),!j&&(0,e.jsx)("button",{type:"button",onClick:r,className:"text-sm text-accent-600 hover:text-accent-800 dark:text-accent-400 dark:hover:text-accent-300",children:s("actions.edit")})]}),j?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("textarea",{value:l,onChange:a=>m(a.target.value),placeholder:s("detail.addNotesPlaceholder"),className:"w-full min-h-[150px] p-3 border border-input dark:bg-surface dark:text-foreground rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:p,disabled:o,className:"px-4 py-2 bg-accent-600 text-white rounded-lg hover:bg-accent-700 disabled:opacity-50 text-sm font-medium",children:o?s("actions.saving"):s("actions.save")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:q,disabled:o,className:"px-4 py-2 bg-muted text-foreground rounded-lg hover:bg-border disabled:opacity-50 text-sm font-medium",children:t("cancel")})]})]}):(0,e.jsx)("div",{className:"min-h-[50px]",children:b.description?(0,e.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:b.description}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:s("detail.noDescription")})})]}),b.link&&(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.link")}),(0,e.jsx)("a",{href:b.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-600 hover:underline break-all",children:b.link})]}),b.updatedAt&&(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.lastUpdated")}),(0,e.jsx)("p",{className:"text-sm text-foreground",children:new Date(b.updatedAt).toLocaleString()})]}),(0,e.jsx)(bu,{version:"v0.34.0",className:c}),(0,e.jsx)(bB,{className:c}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.logs")}),(0,e.jsx)("button",{type:"button",onClick:g,className:"text-sm text-accent-600 hover:text-accent-800",children:f?s("detail.hide"):s("detail.show")})]}),f&&(0,e.jsx)(bq,{worktreeId:a})]})]})}),jR=(0,h.memo)(function({worktreeName:a,repositoryName:b,description:c,status:d,gitStatus:f,onBackClick:g,onInfoClick:i,hasUpdate:j,worktreeStatus:l,onWorktreeStatusChange:m,sessionStatusByCli:p,sessionStatusByInstance:q,instances:r,activeInstanceId:t,onActiveInstanceChange:u,onAgentDragStart:v,onAgentDragEnd:w,onKillSession:x,verificationChip:y,agentSessionByInstance:z}){let A=(0,k.c)("worktree"),B=(0,bm.Ym)(),C=(0,k.c)("common"),E=bn.sb[d],F=E?A(E):void 0,[G,H]=(0,h.useState)(null),I=r?.find(a=>a.id===t),J=!!t&&(q?.[t]?.isRunning??(I?p?.[I.cliTool]?.isRunning:void 0)??!1),K=(0,h.useCallback)((a,b)=>{a.dataTransfer.setData(ae,b),a.dataTransfer.effectAllowed="move",H(b),v?.(b)},[v]),L=(0,h.useCallback)(()=>{H(null),w?.()},[w]),M=c?s(c,50):null,N=(r??[]).map(a=>({item:a,status:(0,bD.kA)(q?.[a.id]??p?.[a.cliTool]),isActive:a.id===t})),O=(r??[]).some(a=>(q?.[a.id]??p?.[a.cliTool])?.awaitingInstruction===!0),P=!!x&&J,Q=[B,a,b,M??"",f?.currentBranch??"",f?.isDirty?"dirty":"",P?"end":"",O?"awaiting":"",...N.map(a=>`${a.item.id}:${(0,$.sw)(a.item)}:${a.status}:${a.isActive?"active":""}`)].join("\n"),R=(0,h.useRef)(null),S=(0,h.useRef)(null),T=function(a,b,c,d,e){let[f,g]=(0,h.useState)(()=>({key:c,pillBudget:4,squeezed:!1})),i=f;return f.key!==c&&g(i={key:c,pillBudget:4,squeezed:!1}),{pillBudget:i.pillBudget,squeezed:i.squeezed}}(0,0,Q,N.filter(bo.Lm).length,0);return(0,e.jsxs)("div",{ref:R,"data-testid":"desktop-header",className:"flex items-center justify-between gap-3 px-4 py-3 bg-surface border-b border-border",children:[(0,e.jsxs)("div",{ref:S,"data-testid":"desktop-header-identity",className:`flex items-center gap-3 min-w-0${T.squeezed?" overflow-x-clip":""}`,children:[(0,e.jsxs)("button",{type:"button",onClick:g,className:"flex flex-shrink-0 items-center gap-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":A("detail.goBack"),"data-testid":"worktree-back-button",children:[(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1h-2z"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:A("detail.home")})]}),(0,e.jsx)("div",{className:"w-px h-6 flex-shrink-0 bg-border","aria-hidden":"true"}),(0,e.jsx)(o.m,{"data-testid":"desktop-status-indicator",status:d,size:"lg",label:F}),(0,e.jsxs)("div",{className:"flex flex-col min-w-[6rem] shrink-4",children:[(0,e.jsx)("h1",{className:"text-lg font-semibold text-foreground truncate max-w-[200px] leading-tight",children:a}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"truncate max-w-[200px]",children:b}),f&&"(unknown)"!==f.currentBranch&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"/"}),(0,e.jsx)("span",{className:"truncate max-w-[150px] font-mono",title:f.currentBranch,"data-testid":"desktop-branch-name",children:s(f.currentBranch,30)}),f.isDirty&&(0,e.jsx)("span",{className:"text-warning",title:A("git.uncommittedChanges"),children:"*"})]}),M&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"—"}),(0,e.jsx)("span",{className:"truncate max-w-[300px] text-muted-foreground",title:c,children:M})]})]})]}),y&&(0,e.jsx)("div",{className:"min-w-0 w-[360px] max-w-max",children:y})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0 max-w-full","data-testid":"desktop-header-controls",children:[r&&r.length>0&&(()=>{let a=(0,bo.Uw)(N,T.pillBudget),b=a.filter(a=>"overflow"===a.slot),c=b.find(a=>"running"===a.status||"generating"===a.status)?.status??b.find(a=>"waiting"===a.status)?.status??null;return(0,e.jsxs)("div",{className:`flex items-center gap-2 min-w-0${T.squeezed?" overflow-x-clip":""}`,"data-testid":"desktop-agent-status-row",children:[a.map(a=>{if("overflow"===a.slot)return null;let b=a.item,c=(0,$.sw)(b),d=A("detail.statusPill",{label:c,status:C(`status.${a.status}`)}),f=q?.[b.id],g=z?.[b.id],h=jJ(f?.model,f?.reasoningEffort,g?.session?.agent),i=h?A("detail.statusPillWithModel",{label:c,status:C(`status.${a.status}`),model:h}):d,j=jM(g?.session,g?.context,A,B),k=j?A("detail.statusPillWithUsage",{base:i,usage:j}):i,l=jK(f?.eventSource,A),m=l?A("detail.statusPillWithSource",{base:k,source:l}):k,n=a.isActive,p={draggable:!0,onDragStart:a=>K(a,b.id),onDragEnd:L},r=G===b.id?" opacity-50 cursor-grabbing":"";return"pill"===a.slot?(0,e.jsxs)("button",{type:"button","data-testid":`desktop-agent-status-${b.id}`,onClick:()=>u?.(b.id),...p,"aria-label":m,title:m,"aria-pressed":n,className:`flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${n?"bg-accent-100 dark:bg-accent-900/30 text-accent-900 dark:text-accent-100":"hover:bg-muted text-foreground"}${r}`,children:[(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0}),(0,e.jsx)("span",{className:"whitespace-nowrap",children:d})]},b.id):(0,e.jsx)(ab.m_,{content:m,placement:"bottom",children:(0,e.jsx)("button",{type:"button","data-testid":`desktop-agent-status-${b.id}`,onClick:()=>u?.(b.id),...p,"aria-label":m,"aria-pressed":n,className:`flex items-center justify-center w-6 h-6 rounded-full transition-colors ${n?"bg-accent-100 dark:bg-accent-900/30":"hover:bg-muted"}${r}`,children:(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0})})},b.id)}),b.length>0&&(0,e.jsxs)(aa.rI,{children:[(0,e.jsx)(aa.ty,{asChild:!0,children:(0,e.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-overflow","aria-label":A("agentStatus.moreAgents",{count:b.length}),className:"flex items-center gap-1 px-2 py-1 rounded text-xs tabular-nums text-muted-foreground hover:bg-muted transition-colors",children:[c&&(0,e.jsx)(o.m,{status:c,size:"sm","aria-hidden":!0,title:void 0}),"+",b.length]})}),(0,e.jsx)(aa.SQ,{align:"end",children:b.map(a=>{let b=a.item,c=A("detail.statusPill",{label:(0,$.sw)(b),status:C(`status.${a.status}`)});return(0,e.jsxs)(aa._2,{"data-testid":`desktop-agent-overflow-${b.id}`,onSelect:()=>u?.(b.id),children:[(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0}),(0,e.jsx)("span",{className:"whitespace-nowrap",children:c})]},b.id)})})]}),O&&(0,e.jsx)("span",{"data-testid":"desktop-awaiting-instruction-badge",className:"flex-shrink-0 rounded-full bg-success-subtle px-1.5 py-0.5 text-[10px] font-medium leading-4 text-success-foreground",title:A("awaitingInstruction.label"),children:A("awaitingInstruction.badge")})]})})(),P&&(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:x,className:"flex items-center gap-1 px-2 py-1.5 text-xs font-medium rounded-lg text-danger-foreground hover:bg-danger-subtle transition-colors flex-shrink-0","aria-label":A("terminal.endSession"),"data-testid":"desktop-kill-session",children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"✕"}),C("end")]}),m&&(0,e.jsx)("select",{value:l??"",onChange:a=>{let b=a.target.value;m(""===b?null:b)},onClick:a=>a.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":A("detail.worktreeStatusLabel"),children:jI.map(a=>(0,e.jsx)("option",{value:a.value??"",children:A(a.labelKey)},a.labelKey))}),(0,e.jsx)(bE.g,{}),(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:i,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":A("detail.viewInfo"),"data-testid":"desktop-info-button",children:[(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:A("detail.info")}),j&&(0,e.jsx)(D,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":A("tabs.updateAvailable")})]})]})]})}),jS=(0,h.memo)(function({worktreeId:a,worktree:b,isOpen:c,onClose:d,onWorktreeUpdate:f}){let[g,i]=(0,h.useState)(!1),j=(0,k.c)("worktree"),l=(0,h.useRef)(c),m=jP(b,f,c,()=>{let a=c&&!l.current;return l.current=c,a});return b?(0,e.jsx)(bC.a,{isOpen:c,onClose:d,title:j("detail.infoModalTitle"),size:"md",children:(0,e.jsx)("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto","data-testid":"worktree-info-modal",children:(0,e.jsx)(jQ,{worktreeId:a,worktree:b,cardClassName:"bg-muted rounded-lg p-4",descriptionEditor:m,showLogs:g,onToggleLogs:()=>i(!g),onWorktreeUpdate:f})})}):null}),jT=(0,h.memo)(function(){let a=(0,k.c)("worktree");return(0,e.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"status","aria-live":"polite",children:(0,e.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,e.jsx)(n.y$,{size:"xl",variant:"accent"}),(0,e.jsx)("p",{className:"text-muted-foreground",children:a("detail.loading")})]})})}),jU=(0,h.memo)(function({message:a,onRetry:b}){let c=(0,k.c)("worktree"),d=(0,k.c)("common");return(0,e.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"alert","aria-live":"assertive",children:(0,e.jsxs)("div",{className:"text-center p-6 bg-danger-subtle rounded-lg border border-danger-border max-w-md",children:[(0,e.jsx)("svg",{className:"mx-auto h-12 w-12 text-danger-foreground/70 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,e.jsx)("p",{className:"text-danger-foreground font-medium",children:c("detail.errorLoading")}),(0,e.jsx)("p",{className:"text-danger-foreground/80 text-sm mt-2",children:a}),b&&(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:b,className:"mt-4 px-4 py-2 bg-danger-foreground text-danger-subtle rounded-lg hover:opacity-90 transition-opacity focus:outline-none focus:ring-2 focus:ring-danger focus:ring-offset-2 ring-offset-background",children:d("retry")})]})})}),jV=(0,h.memo)(function({activityPane:a,rightPane:b,activityPaneWidth:c=18,minPaneWidth:d=10,maxPaneWidth:f=60,onActivityPaneResize:g,className:i=""}){let j=(0,h.useRef)(null),l=(0,k.c)("worktree"),[m,n]=(0,h.useState)(c),o=g?c:m,p=(0,h.useCallback)(a=>{let b=j.current;if(!b)return;let e=b.offsetWidth;if(0===e)return;let h=Math.min(f,Math.max(d,(g?c:m)+a/e*100));g?g(h):n(h)},[c,m,d,f,g]),q=(0,h.useMemo)(()=>`flex h-full min-h-0 ${i}`.trim(),[i]);return(0,e.jsx)("div",{ref:j,className:"h-full",children:(0,e.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:q,children:[null!==a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{id:"worktree-activity-pane","data-testid":"activity-pane-slot","aria-label":l("desktopLayout.activityPane"),style:{width:`${o}%`},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,e.jsx)(I,{componentName:"ActivityPane",children:a})}),(0,e.jsx)(f_,{onResize:p,orientation:"horizontal",ariaValueNow:o})]}),(0,e.jsx)("div",{id:"worktree-right-pane","data-testid":"right-pane-slot","aria-label":l("desktopLayout.terminalPane"),className:"flex-grow overflow-hidden min-w-0",children:(0,e.jsx)(I,{componentName:"TerminalPane",children:b})})]})})}),jW=(0,y.A)("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),jX=(0,y.A)("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]);var jY=c(57898);let jZ=(0,y.A)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);var j$=c(55056);let j_=(0,y.A)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),j0=(0,y.A)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),j1=(0,y.A)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),j2=[{id:"files",labelKey:"activityBar.files",icon:jX},{id:"git",labelKey:"activityBar.git",icon:jY.A},{id:"notes",labelKey:"activityBar.notes",icon:U},{id:"schedules",labelKey:"activityBar.schedules",icon:jZ},{id:"agent",labelKey:"activityBar.agent",icon:j$.A},{id:"timer",labelKey:"activityBar.timer",icon:j_},{id:"todo",labelKey:"activityBar.todo",icon:j0},{id:"skills",labelKey:"activityBar.skills",icon:gL.A},{id:"verification",labelKey:"activityBar.verification",icon:dR},{id:"env",labelKey:"activityBar.env",icon:j1}];j2.map(a=>a.id);var j3=c(81092);let j4=(0,h.memo)(function({active:a,onToggle:b,className:c=""}){let d=(0,k.c)("worktree"),f=(0,h.useRef)([]),{isOpen:g,toggle:i}=(0,j3.VF)(),j=(0,h.useCallback)((a,c,d)=>{if("Enter"===a.key||" "===a.key){a.preventDefault(),b(d);return}if("ArrowDown"===a.key){a.preventDefault();let b=(c+1)%j2.length;f.current[b]?.focus();return}if("ArrowUp"===a.key){a.preventDefault();let b=(c-1+j2.length)%j2.length;f.current[b]?.focus();return}if("Home"===a.key){a.preventDefault(),f.current[0]?.focus();return}if("End"===a.key){a.preventDefault(),f.current[j2.length-1]?.focus();return}},[b]);return(0,e.jsxs)("div",{"data-testid":"activity-bar",className:`flex flex-col items-stretch w-12 flex-shrink-0 bg-muted border-r border-border ${c}`.trim(),children:[(0,e.jsx)(ab.m_,{content:d("activityBar.toggleSidebar"),placement:"right",children:(0,e.jsx)("button",{type:"button","data-testid":"activity-bar-toggle-sidebar",onClick:i,"aria-label":d("activityBar.toggleSidebar"),"aria-expanded":g,className:"flex items-center justify-center h-12 w-12 text-muted-foreground transition-colors hover:text-surface-foreground hover:bg-muted-foreground/10 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,e.jsx)(jW,{size:20,"aria-hidden":"true"})})}),(0,e.jsx)("div",{className:"mx-2 my-1 border-b border-border","aria-hidden":"true"}),(0,e.jsx)("div",{id:"worktree-activity-bar",role:"tablist","aria-orientation":"vertical","aria-label":d("activityBar.label"),className:"flex flex-col items-stretch",children:j2.map((c,g)=>{let h=c.icon,i=a===c.id,k=d(c.labelKey);return(0,e.jsx)(ab.m_,{content:k,placement:"right",children:(0,e.jsx)("button",{ref:a=>{f.current[g]=a},type:"button",role:"tab","aria-selected":i,"aria-label":k,"aria-controls":"worktree-activity-pane",tabIndex:i||null===a&&0===g?0:-1,onClick:()=>b(c.id),onKeyDown:a=>j(a,g,c.id),"data-testid":`activity-bar-button-${c.id}`,className:"group flex items-center justify-center h-12 w-12 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,e.jsx)("span",{"aria-hidden":"true",className:`flex items-center justify-center h-9 w-9 rounded-md transition-colors ${i?"bg-accent-500/10 text-accent-600 dark:text-accent-400":"text-muted-foreground group-hover:text-surface-foreground group-hover:bg-muted-foreground/10"}`,children:(0,e.jsx)(h,{size:20,"aria-hidden":"true"})})})},c.id)})})]})}),j5="worktree-activity-pane",j6={files:"FileTreeView",git:"GitPane",notes:"MemoPane",schedules:"ExecutionLogPane",agent:"AgentInstancesPane",timer:"TimerPane",todo:"TodoPane",skills:"WorktreeSkillsPane",verification:"VerificationPane",env:"EnvManagerPane"},j7=(0,h.memo)(function({active:a,activities:b,className:c=""}){if(null===a)return(0,e.jsx)("div",{id:j5,"data-testid":"activity-pane","data-active":"none",className:`h-full flex flex-col ${c}`.trim()});let d=b[a],f=j6[a];return(0,e.jsx)("div",{id:j5,"data-testid":"activity-pane","data-active":a,role:"tabpanel","aria-labelledby":`activity-bar-button-${a}`,className:`h-full flex flex-col min-h-0 ${c}`.trim(),children:(0,e.jsx)(I,{componentName:f,children:d??null})})}),j8=(0,y.A)("square-x",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),j9=(0,y.A)("list-x",[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"m15.5 9.5 5 5",key:"ytk86i"}],["path",{d:"m20.5 9.5-5 5",key:"17o44f"}]]),ka=(0,y.A)("chevrons-right",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]),kb=(0,h.memo)(function({inputRef:a,searchQuery:b,onQueryChange:c,matchCount:d,currentIdx:f,onNextMatch:g,onPrevMatch:h,onClose:i}){let j=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border-b border-input flex-shrink-0",children:[(0,e.jsx)("input",{ref:a,type:"text",value:b,onChange:a=>c(a.target.value),onKeyDown:a=>{"Escape"===a.key&&i(),"Enter"!==a.key||a.nativeEvent.isComposing||(a.shiftKey?h():g())},placeholder:j("fileSearch.placeholder"),className:"flex-1 min-w-0 px-2 py-0.5 text-sm bg-surface dark:text-foreground border border-input rounded outline-none focus:ring-1 focus:ring-ring",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground min-w-[3rem] text-right",children:d>0?`${f+1}/${d}`:"0/0"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:h,disabled:0===d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":j("fileSearch.prevMatch"),children:"▲"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:g,disabled:0===d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":j("fileSearch.nextMatch"),children:"▼"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:i,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white","aria-label":j("fileSearch.close"),children:(0,e.jsx)(a$.A,{className:"w-4 h-4"})})]})}),kc=[{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"]}],kd=kc.map(a=>a.extension),ke=[".md",".html",".htm",".yaml",".yml"];var kf=c(79689);function kg(){return(0,e.jsx)("div",{className:"flex items-center justify-center py-12 bg-surface",children:(0,e.jsx)(m.y,{size:"xl",variant:"accent"})})}let kh=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/HtmlPreview"]},ssr:!1,loading:()=>(0,e.jsx)(kg,{})}),ki=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/PdfPreview"]},ssr:!1,loading:()=>(0,e.jsx)(kg,{})}),kj=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/MarkdownEditor"]},ssr:!1,loading:()=>(0,e.jsx)(kg,{})}),kk=/^---\s*\nmarp:\s*true/;function kl(){let a=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,e.jsx)(m.y,{size:"xl",variant:"accent"}),(0,e.jsx)("p",{className:"ml-3 text-muted-foreground",children:a("fileViewer.loading")})]})}function km({error:a}){return(0,e.jsx)("div",{className:"bg-danger-subtle border border-danger-border rounded-lg p-4 m-4",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-5 h-5 text-danger-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,e.jsx)("p",{className:"text-sm text-danger-foreground",children:a})]})})}function kn({filePath:a,isMaximized:b,onToggleMaximize:c,copyableContent:d,onSearch:f}){let g=(0,k.c)("worktree"),{copied:h,markCopied:i}=(0,bc.q)(),{copied:j,markCopied:l}=(0,bc.q)(),m=async()=>{try{await (0,aZ.l)(a),i()}catch{}},n=async()=>{if(d)try{await (0,aZ.l)(d),l()}catch{}};return(0,e.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border gap-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("button",{type:"button",onClick:m,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.copyFilePath"),title:g("actions.copyPath"),children:h?(0,e.jsx)(az.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(aU,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",title:a,children:a})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[f&&(0,e.jsx)("button",{type:"button",onClick:f,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.searchInFile"),title:g("actions.search"),children:(0,e.jsx)(T.A,{className:"w-3.5 h-3.5"})}),d&&(0,e.jsx)("button",{type:"button",onClick:n,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.copyFileContent"),title:g("actions.copyContent"),children:j?(0,e.jsx)(az.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(aA,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{type:"button",onClick:c,className:"flex-shrink-0 p-1.5 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g(b?"actions.minimize":"actions.maximize"),title:g(b?"actions.minimize":"actions.maximize"),children:b?(0,e.jsx)(Y,{className:"w-4 h-4"}):(0,e.jsx)(Z,{className:"w-4 h-4"})})]})]})}function ko({content:a,extension:b,searchMatches:c,searchCurrentIdx:d,totalLines:f,rangeStart:g,worktreeId:i,filePath:j,onLineRangeFetched:k}){let l=(0,h.useRef)(null),m=(0,h.useMemo)(()=>a.split("\n"),[a]),n=Math.max(1,g??1),o=m.length,p=Math.max(f??o,o),q=(0,h.useRef)(new Map),r=(0,h.useCallback)(a=>{let c=Math.floor(a/500),d=q.current,e=d.get(c);if(!e){let a=500*c,f=Math.min(a+500,m.length),g=m.slice(a,f).join("\n"),h="";try{h=bd.highlight(g,{language:b,ignoreIllegals:!0}).value}catch{h=bd.highlightAuto(g).value}e=h.split("\n"),d.set(c,e)}return e[a-500*c]??""},[m,b]),s=(0,h.useMemo)(()=>new Set(c??[]),[c]),t=(c?.length??0)>0?c[d??0]:-1,u=c_({count:p,getScrollElement:()=>l.current,estimateSize:()=>24,overscan:100}),v=u.getVirtualItems();return!function({virtualItems:a,worktreeId:b,filePath:c,onLineRangeFetched:d,loadedStart:e,loadedLineCount:f}){(0,h.useRef)(new Set)}({virtualItems:v,worktreeId:i,filePath:j,onLineRangeFetched:k,loadedStart:n,loadedLineCount:o}),(0,e.jsx)("div",{className:"overflow-auto h-full",ref:l,"data-testid":"file-content-code",children:(0,e.jsx)("div",{style:{height:u.getTotalSize(),width:"100%",position:"relative"},children:v.map(a=>{let b=a.index+1,c=b-n,d=c>=0&&c<o,f=b===t,g=s.has(b),h=d?r(c):"";return(0,e.jsxs)("div",{"data-line":b,"data-index":a.index,ref:u.measureElement,className:`absolute left-0 right-0 flex font-mono text-sm ${f?"bg-warning/30":g?"bg-warning/15":""}`,style:{top:0,transform:`translateY(${a.start}px)`,height:"24px",lineHeight:"24px"},children:[(0,e.jsx)("div",{className:`px-3 text-right select-none border-r border-border bg-muted dark:bg-muted/50 whitespace-nowrap ${f||g?"text-warning-foreground":"text-muted-foreground"}`,style:{minWidth:"4rem"},children:b}),(0,e.jsx)("div",{className:"px-4 text-foreground flex-1 min-w-0 overflow-hidden",children:d?(0,e.jsx)("code",{className:"hljs",style:{padding:0,background:"transparent",whiteSpace:"pre"},dangerouslySetInnerHTML:{__html:h}}):(0,e.jsx)(kf.E,{className:"h-4 w-3/4"})})]},a.key)})})})}function kp({slides:a,fileName:b}){let c=(0,k.c)("worktree"),[d,f]=(0,h.useState)(0);return 0===a.length?(0,e.jsx)("div",{className:"p-4 text-muted-foreground",children:c("fileViewer.noSlides",{fileName:b})}):(0,e.jsxs)("div",{className:"h-full flex flex-col","data-testid":"marp-preview",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border bg-muted",children:[(0,e.jsx)("button",{type:"button",onClick:()=>{f(a=>Math.max(0,a-1))},disabled:0===d,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:c("actions.prev")}),(0,e.jsxs)("span",{className:"text-sm text-muted-foreground",children:[d+1," / ",a.length]}),(0,e.jsx)("button",{type:"button",onClick:()=>{f(b=>Math.min(a.length-1,b+1))},disabled:d===a.length-1,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:c("actions.next")})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,e.jsx)("iframe",{srcDoc:a[d],sandbox:"",title:c("fileViewer.slideTitle",{name:b,number:d+1}),className:"w-full h-full border-0"})})]})}function kq({marpSlides:a,fileName:b,worktreeId:c,filePath:d,contentText:f,onFileSaved:g,isMaximized:i,onToggleMaximize:j,onDirtyChange:l,onOpenFile:m}){let n=(0,k.c)("worktree"),[o,p]=(0,h.useState)("slides");return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border bg-muted",children:[(0,e.jsxs)("div",{className:"flex gap-1",children:[(0,e.jsx)("button",{type:"button",onClick:()=>p("slides"),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${"slides"===o?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"}`,children:n("fileViewer.slides")}),(0,e.jsx)("button",{type:"button",onClick:()=>p("editor"),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${"editor"===o?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"}`,children:n("fileViewer.editor")})]}),(0,e.jsx)(kn,{filePath:d,isMaximized:i,onToggleMaximize:j,copyableContent:f})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:"slides"===o?(0,e.jsx)(kp,{slides:a,fileName:b}):(0,e.jsx)(kj,{worktreeId:c,filePath:d,onSave:g,initialViewMode:"split",onDirtyChange:l,onOpenFile:m})})]})}function kr({children:a,isMaximized:b,onToggle:c,filePath:d}){if(!b)return(0,e.jsx)(e.Fragment,{children:a});let f=(0,e.jsxs)("div",{"data-testid":"maximized-file-overlay",className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:a1.M.MAXIMIZED_EDITOR},children:[(0,e.jsx)(kn,{filePath:d,isMaximized:b,onToggleMaximize:c}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:a})]});return"undefined"==typeof document?f:(0,cK.createPortal)(f,document.body)}function ks({tab:a,content:b,worktreeId:c,isMaximized:d,onToggleMaximize:f,onFileSaved:g,onDirtyChange:h,onOpenFile:i}){let j=bb(b.content);return(0,e.jsxs)(e.Fragment,{children:[!d&&(0,e.jsx)(kn,{filePath:a.path,isMaximized:d,onToggleMaximize:f,copyableContent:b.content,onSearch:j.openSearch}),j.searchOpen&&(0,e.jsx)(kb,{inputRef:j.searchInputRef,searchQuery:j.searchQuery,onQueryChange:j.setSearchQuery,matchCount:j.searchMatches.length,currentIdx:j.searchCurrentIdx,onNextMatch:j.nextMatch,onPrevMatch:j.prevMatch,onClose:j.closeSearch}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:j.searchOpen&&j.searchQuery.length>=2?(0,e.jsx)(ko,{content:b.content,extension:"md",searchMatches:j.searchMatches,searchCurrentIdx:j.searchCurrentIdx}):(0,e.jsx)(kj,{worktreeId:c,filePath:a.path,onSave:g,initialViewMode:"preview",onDirtyChange:h,onOpenFile:i})})]})}function kt({tab:a,content:b,worktreeId:c,isMaximized:d,onToggleMaximize:f,onLoadContent:g}){let i=bb(b.content),j=(0,h.useCallback)(c=>{g&&g(a.path,{...b,content:c.content,totalLines:c.totalLines,totalBytes:c.totalBytes??b.totalBytes,range:c.range})},[g,a.path,b]),k=void 0!==b.range&&(b.totalLines??0)>b.range.end-b.range.start+1;return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(kn,{filePath:a.path,isMaximized:d,onToggleMaximize:f,copyableContent:b.content,onSearch:i.openSearch}),i.searchOpen&&(0,e.jsx)(kb,{inputRef:i.searchInputRef,searchQuery:i.searchQuery,onQueryChange:i.setSearchQuery,matchCount:i.searchMatches.length,currentIdx:i.searchCurrentIdx,onNextMatch:i.nextMatch,onPrevMatch:i.prevMatch,onClose:i.closeSearch}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(ko,{content:b.content,extension:b.extension,searchMatches:i.searchOpen?i.searchMatches:void 0,searchCurrentIdx:i.searchOpen?i.searchCurrentIdx:void 0,totalLines:b.totalLines,rangeStart:b.range?.start,worktreeId:k?c:void 0,filePath:k?a.path:void 0,onLineRangeFetched:k?j:void 0})})]})}let ku=(0,h.memo)(function({tab:a,worktreeId:b,onLoadContent:c,onLoadError:d,onSetLoading:f,onFileSaved:g,onDirtyChange:i,onOpenFile:j}){let l=(0,k.c)("worktree"),m=(0,h.useRef)(l);m.current=l;let n=(0,h.useRef)(!1),[o,p]=(0,h.useState)(null),[q,r]=(0,h.useState)(!1);!function({tab:a,worktreeId:b,onLoadContent:c}){let d=(0,h.useRef)(null),e=(0,h.useRef)(c);e.current=c;let f=(0,h.useRef)(a.path);f.current=a.path,gt({intervalMs:5e3,enabled:function(a){if(null===a.content||a.loading||a.isDirty||a.content.isPdf)return!1;let{totalBytes:b}=a.content;return void 0===b||!(b>=1048576)}(a),onPoll:async()=>{let a=`/api/worktrees/${b}/files/${(0,a2.o)(f.current)}`,c={};d.current&&(c["If-Modified-Since"]=d.current);try{let b=await fetch(a,{headers:c});if(304===b.status||!b.ok)return;d.current=b.headers.get("Last-Modified");let g=await b.json();e.current(f.current,g)}catch{}}})}({tab:a,worktreeId:b,onLoadContent:c});let s=(0,h.useMemo)(()=>i?b=>i(a.path,b):void 0,[i,a.path]),t=(0,h.useCallback)(()=>{r(a=>!a)},[]);(0,h.useEffect)(()=>{if(!q)return;let a=a=>{"Escape"===a.key&&r(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[q]),(0,h.useEffect)(()=>{null!==a.content||a.loading||null!==a.error||n.current||(n.current=!0,f(a.path,!0),(async()=>{try{let e=await fetch(`/api/worktrees/${b}/files/${(0,a2.o)(a.path)}`);if(304===e.status)return;if(!e.ok){let b=await e.json(),c="string"==typeof b.error?b.error:b.error?.message||m.current("fileViewer.loadError");d(a.path,c);return}let f=await e.json();c(a.path,f)}catch(b){d(a.path,b instanceof Error?b.message:m.current("fileViewer.loadError"))}finally{n.current=!1}})())},[a.content,a.loading,a.error,a.path,b,c,d,f]);let u=a.content?.content??null,v=a.content?.extension??null;if((0,h.useEffect)(()=>{if(!u||"md"!==v||!kk.test(u)||u.length>1e6)return void p(null);let a=!1;return(async()=>{try{let c=await fetch(`/api/worktrees/${b}/marp-render`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:u})});if(c.ok){let b=await c.json();a||p(Array.isArray(b.slides)?b.slides:null)}}catch{}})(),()=>{a=!0}},[u,v,b]),a.loading)return(0,e.jsx)(kl,{});if(a.error)return(0,e.jsx)(km,{error:a.error});if(!a.content)return null;let{content:w}=a;return w.isImage?(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(kn,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsx)(aQ.a,{src:w.content,alt:w.path,mimeType:w.mimeType})})]})}):w.isVideo?(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(kn,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsx)(aR.u,{src:w.content,mimeType:w.mimeType})})]})}):w.isPdf?(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(kn,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(ki,{dataUri:w.content,filePath:a.path})})]})}):w.isHtml?(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(kn,{filePath:a.path,isMaximized:q,onToggleMaximize:t,copyableContent:w.content}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(kh,{worktreeId:b,filePath:a.path,htmlContent:w.content,onFileSaved:g,onOpenFile:j})})]})}):"md"===w.extension?(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)("div",{className:"h-full flex flex-col",children:o?(0,e.jsx)(kq,{marpSlides:o,fileName:a.name,worktreeId:b,filePath:a.path,contentText:w.content,onFileSaved:g,isMaximized:q,onToggleMaximize:t,onDirtyChange:s,onOpenFile:j}):(0,e.jsx)(ks,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onFileSaved:g,onDirtyChange:s,onOpenFile:j})})}):!function(a){if(!a)return!1;let b=a.toLowerCase();return ke.includes(b)}("."+w.extension)?(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)(kt,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onLoadContent:c})}):(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)("div",{className:"h-full flex flex-col",children:(0,e.jsx)(ks,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onFileSaved:g,onDirtyChange:s,onOpenFile:j})})})});function kv(a){let b=a.split("/");return b[b.length-1]||a}function kw(a,b,c){let d=a.findIndex(a=>a.path===b);if(-1===d)return null;let e=[...a];return e[d]=c(e[d]),e}function kx(a,b,c){if("all"===c)return a.map(a=>a.path);let d=a.findIndex(a=>a.path===b);return -1===d?[]:"others"===c?a.filter((a,b)=>b!==d).map(a=>a.path):a.slice(d+1).map(a=>a.path)}let ky={tabs:[],activeIndex:null};function kz(a,b,c){if(b<=0||c<=0)return 0;let d=a+b+8-c;return d>0?-Math.min(d,Math.max(0,a-8)):a<8?8-a:0}let kA=(0,h.memo)(function({tab:a,isActive:b,onActivate:c,onClose:d,onOpenMenu:f}){let g=(0,k.c)("worktree"),i=(0,h.useCallback)(()=>{b||c(a.path)},[b,c,a.path]),j=(0,h.useCallback)(b=>{b.stopPropagation(),d(a.path)},[d,a.path]),l=(0,h.useCallback)(b=>{f(b,a.path)},[f,a.path]),m=(0,h.useCallback)(b=>{1===b.button&&(b.preventDefault(),b.stopPropagation(),d(a.path))},[d,a.path]),n=b?"border-accent-500 text-accent-600 dark:text-accent-400 bg-surface":"border-transparent text-muted-foreground hover:text-foreground";return(0,e.jsxs)("div",{"data-testid":`file-tab-${a.path}`,"data-active":b,onClick:i,onAuxClick:m,onContextMenu:l,className:`flex items-center gap-1 px-3 py-2 text-sm font-medium border-b-2 cursor-pointer flex-shrink-0 ${n}`,children:[(0,e.jsx)("span",{className:"truncate max-w-[120px]",title:a.path,children:a.name}),a.isDirty&&(0,e.jsx)("span",{"data-testid":`file-tab-dirty-${a.path}`,className:"w-2 h-2 rounded-full bg-warning flex-shrink-0",title:g("fileTabs.unsavedChanges")}),(0,e.jsx)("button",{type:"button",onClick:j,className:"ml-1 p-0.5 rounded-sm hover:bg-muted transition-colors","aria-label":g("fileTabs.closeTab",{name:a.name}),children:(0,e.jsx)(a$.A,{className:"w-3 h-3"})})]})}),kB=(0,h.memo)(function({tabs:a,activeIndex:b,worktreeId:c,onClose:d,onActivate:f,onLoadContent:g,onLoadError:i,onSetLoading:j,onFileSaved:m,onDirtyChange:n,onMoveToFront:o,onOpenFile:p}){let q=(0,k.c)("worktree"),[r,s]=(0,h.useState)(!1),t=(0,h.useRef)(null),u=(0,h.useRef)(null),v=(0,h.useRef)({x:0,y:0}),[w,x]=(0,h.useState)({x:0,y:0}),{menuState:y,openMenu:z,openMenuAt:A,closeMenu:B}=f8(),[C,D]=(0,h.useState)(null),E=null!==b&&b>=0&&b<a.length?a[b]:null,F=a.length>5?a.slice(0,5):a,G=a.length>5?a.slice(5):[];(0,h.useEffect)(()=>{if(!r)return;let a=a=>{t.current&&!t.current.contains(a.target)&&s(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[r]),(0,h.useLayoutEffect)(()=>{let a=a=>{v.current=a,x(b=>b.x===a.x&&b.y===a.y?b:a)};if(!r)return void a({x:0,y:0});let b=u.current;if(!b)return;let c=b.getBoundingClientRect();a({x:kz(c.left-v.current.x,c.width,window.innerWidth),y:kz(c.top-v.current.y,c.height,window.innerHeight)})},[r]);let H=(0,h.useCallback)(a=>{s(!1),o?.(a)},[o]),I=(0,h.useCallback)(()=>{s(a=>!a)},[]),J=(0,h.useCallback)(a=>{for(let b=a.length-1;b>=0;b--)d(a[b])},[d]),K=(0,h.useCallback)((b,c)=>{let d=kx(a,c,b);if(0===d.length)return;let e=new Set(d);if(a.some(a=>a.isDirty&&e.has(a.path)))return void D({mode:b,anchorPath:c});J(d)},[a,J]),L=y.targetPath,M=(0,h.useMemo)(()=>L?[{id:"close-all-tabs",label:q("fileTabs.closeAll"),icon:(0,e.jsx)(j8,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>K("all",L),disabled:0===a.length},{id:"close-other-tabs",label:q("fileTabs.closeOthers"),icon:(0,e.jsx)(j9,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>K("others",L),disabled:0===kx(a,L,"others").length},{id:"close-tabs-to-right",label:q("fileTabs.closeToRight"),icon:(0,e.jsx)(ka,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>K("right",L),disabled:0===kx(a,L,"right").length}]:[],[L,a,K,q]),N=(0,h.useCallback)((a,b)=>{z(a,b,"file")},[z]),O=E?.path??a[0]?.path??null,P=(0,h.useCallback)(a=>{if(!O)return;let b=a.currentTarget.getBoundingClientRect();A({x:b.left,y:b.bottom},O,"file")},[O,A]),Q=C?kx(a,C.anchorPath,C.mode):[],R=Q.filter(b=>a.find(a=>a.path===b)?.isDirty),S=(0,h.useCallback)(()=>D(null),[]);return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex border-b border-border bg-surface dark:bg-surface-2 min-w-0",children:[(0,e.jsx)("div",{className:"flex min-w-0 overflow-hidden flex-1",children:F.map((a,c)=>(0,e.jsx)(kA,{tab:a,isActive:c===b,onActivate:f,onClose:d,onOpenMenu:N},a.path))}),G.length>0&&(0,e.jsxs)("div",{className:"relative flex-shrink-0",ref:t,children:[(0,e.jsxs)("button",{type:"button","data-testid":"tab-dropdown-button",onClick:I,className:"flex items-center gap-0.5 px-2 py-2 text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-muted border-b-2 border-transparent transition-colors",children:[(0,e.jsx)(X.A,{className:`w-3 h-3 transition-transform ${r?"rotate-180":""}`}),(0,e.jsxs)("span",{children:["+",G.length]})]}),r&&(0,e.jsx)("div",{ref:u,"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!==w.x||0!==w.y?{transform:`translate(${w.x}px, ${w.y}px)`}:void 0,children:G.map(a=>(0,e.jsxs)("button",{type:"button","data-testid":`tab-dropdown-item-${a.path}`,onClick:()=>H(a.path),className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-muted truncate",title:a.path,children:[a.name,a.isDirty&&(0,e.jsx)("span",{className:"ml-1 w-2 h-2 inline-block rounded-full bg-warning"})]},a.path))})]}),a.length>0&&(0,e.jsx)("button",{type:"button","data-testid":"tab-actions-button",onClick:P,"aria-haspopup":"menu","aria-expanded":y.isOpen,"aria-label":q("fileTabs.tabActions"),title:q("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,e.jsx)(l.A,{className:"w-4 h-4"})})]}),(0,e.jsx)(gg,{isOpen:y.isOpen,position:y.position,targetPath:y.targetPath,targetType:y.targetType,onClose:B,items:M,ariaLabel:q("fileTabs.tabActions")}),(0,e.jsxs)(bC.a,{isOpen:null!==C,onClose:S,title:q("fileTabs.confirmCloseTitle"),size:"sm",children:[(0,e.jsx)("p",{"data-testid":"file-tabs-close-confirm-body",className:"text-sm text-foreground",children:q("fileTabs.confirmCloseBody",{count:R.length})}),(0,e.jsx)("ul",{className:"mt-2 max-h-32 overflow-y-auto text-sm text-muted-foreground",children:R.map(a=>(0,e.jsx)("li",{className:"truncate",title:a,children:a},a))}),(0,e.jsxs)("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:[(0,e.jsx)(bs.$,{variant:"ghost",size:"sm","data-testid":"file-tabs-close-cancel",onClick:S,children:q("fileTabs.confirmCancel")}),(0,e.jsx)(bs.$,{variant:"secondary",size:"sm","data-testid":"file-tabs-close-keep-unsaved",onClick:()=>{let a=new Set(R);J(Q.filter(b=>!a.has(b))),D(null)},children:q("fileTabs.confirmKeepUnsaved")}),(0,e.jsx)(bs.$,{variant:"danger",size:"sm","data-testid":"file-tabs-close-discard",onClick:()=>{J(Q),D(null)},children:q("fileTabs.confirmDiscard")})]})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:E&&(0,e.jsx)(ku,{tab:E,worktreeId:c,onLoadContent:g,onLoadError:i,onSetLoading:j,onFileSaved:m,onDirtyChange:n,onOpenFile:p},E.path)})]})}),kC=(0,h.memo)(function({line:a}){let b="whitespace-pre font-mono text-xs leading-5";return a.startsWith("+")&&!a.startsWith("+++")?b+=" text-success-foreground bg-success-subtle":a.startsWith("-")&&!a.startsWith("---")?b+=" text-danger-foreground bg-danger-subtle":a.startsWith("@@")?b+=" text-info bg-info/10":a.startsWith("diff --git")||a.startsWith("index ")||a.startsWith("---")||a.startsWith("+++")?b+=" text-muted-foreground":b+=" text-foreground",(0,e.jsx)("div",{className:b,children:a})}),kD=(0,h.memo)(function({diff:a,filePath:b,onClose:c}){let d=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"h-full flex flex-col bg-surface",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-muted shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-accent-600 dark:text-accent-400 shrink-0",children:d("diffViewer.badge")}),(0,e.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:b})]}),(0,e.jsx)("button",{type:"button",onClick:c,className:"p-1 text-muted-foreground hover:text-foreground rounded shrink-0","aria-label":d("diffViewer.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto p-2",children:(0,e.jsx)("pre",{className:"text-xs",children:(0,e.jsx)("code",{children:a.split("\n").map((a,b)=>(0,e.jsx)(kC,{line:a},b))})})})]})}),kE="worktree-file-panel",kF=(0,h.createContext)({tabCount:0,hasDiff:!1});function kG(){let[a,b]=(0,h.useState)(!1),c=(0,h.useRef)(a);c.current=a;let d=(0,h.useCallback)(a=>{b(a)},[]);return{collapsed:a,toggle:(0,h.useCallback)(()=>{d(!c.current)},[d]),setCollapsed:d}}let kH=(0,h.memo)(function({terminal:a,terminalHeader:b,fileTabs:c,worktreeId:d,onCloseTab:f,onActivateTab:g,onLoadContent:i,onLoadError:j,onSetLoading:k,onFileSaved:l,diffContent:m,diffFilePath:n,onCloseDiff:o,onDirtyChange:p,onMoveToFront:q,onOpenFile:r}){let s=(0,h.useRef)(null),[t,u]=(0,h.useState)(50),{collapsed:v}=kG(),w=(0,h.useCallback)(a=>{let b=s.current;if(!b)return;let c=b.offsetWidth;if(0===c)return;let d=a/c*100;u(a=>Math.min(80,Math.max(20,a+d)))},[]),x=(0,h.useMemo)(()=>({width:`${t}%`}),[t]),y=(0,h.useMemo)(()=>({width:`${100-t}%`}),[t]),z=(0,h.useMemo)(()=>({tabCount:c.tabs.length,hasDiff:!!(m&&n)}),[c.tabs.length,m,n]),A=(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[b,(0,e.jsx)("div",{className:"flex-1 min-h-0",children:a})]});return c.tabs.length>0||m&&n?v?(0,e.jsx)(kF.Provider,{value:z,children:(0,e.jsx)("div",{ref:s,className:"flex h-full min-h-0",children:(0,e.jsx)("div",{"data-testid":"terminal-pane",style:{width:"100%"},className:"flex-shrink-0 overflow-hidden",children:A})})}):(0,e.jsx)(kF.Provider,{value:z,children:(0,e.jsxs)("div",{ref:s,className:"flex h-full min-h-0",children:[(0,e.jsx)("div",{"data-testid":"terminal-pane",style:x,className:"flex-shrink-0 overflow-hidden",children:A}),(0,e.jsx)(f_,{onResize:w,orientation:"horizontal",ariaValueNow:t}),(0,e.jsx)("div",{id:kE,"data-testid":"file-panel-pane",style:y,className:"flex-grow overflow-hidden flex",children:(0,e.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:m&&n&&o?(0,e.jsx)(kD,{diff:m,filePath:n,onClose:o}):(0,e.jsx)(kB,{tabs:c.tabs,activeIndex:c.activeIndex,worktreeId:d,onClose:f,onActivate:g,onLoadContent:i,onLoadError:j,onSetLoading:k,onFileSaved:l,onDirtyChange:p,onMoveToFront:q,onOpenFile:r})})})]})}):(0,e.jsx)(kF.Provider,{value:z,children:(0,e.jsx)("div",{className:"h-full",children:A})})});var kI=c(51881);let kJ=(0,y.A)("align-horizontal-distribute-center",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]]),kK=(0,y.A)("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),kL=[.5,.5],kM={splits:[{cliToolId:"claude",instanceId:"claude"}],widths:[1]};$.XH;function kN(a){return"number"==typeof a&&Number.isFinite(a)&&a>0}function kO(a){return void 0===a||!!Array.isArray(a)&&2===a.length&&a.every(kN)}function kP(a,b){let c=a+b;if(!Number.isFinite(c)||c<=0)return[1,1];let d=Math.min(a,b);return!Number.isFinite(d)||d<=0?[1,1]:[a/d,b/d]}function kQ(a){let b=a.reduce((a,b)=>a+b,0);return b>0?a.map(a=>a/b):a.map(()=>1/a.length)}function kR(a){if(4===a.splits.length)return kO(a.rowHeights)&&void 0!==a.rowHeights?a:{...a,rowHeights:[...kL]};if(void 0===a.rowHeights)return a;let{rowHeights:b,...c}=a;return c}let kS=(0,h.memo)(function({worktreeId:a,instances:b,rosterReady:c=!0,renderPane:d,onFocusedSplitChange:f,showToast:g,onActiveInstanceChange:j,headerInstanceSelection:l}){let{splits:m,widths:n,rowHeights:o,setRowHeights:p,addSplit:q,removeSplit:r,setSplitInstance:s,setSplitWidth:t,resetWidths:u,availableInstanceIds:v,focusedSplitIndex:w,setFocusedSplitIndex:x,maximizedIndex:y,toggleMaximize:z}=function(a,b,c=!0){let[d,e]=(0,h.useState)(()=>(function(a,b,c){let d=function(a,b){let c=b[0];return c?{splits:[{cliToolId:c.cliTool,instanceId:c.id}],widths:[1]}:{splits:kM.splits.map(a=>({...a})),widths:[...kM.widths]}}(0,b);return c?function(a,b){let c;if(0===b.length)return a;let d=new Map(b.map(a=>[a.id,a.cliTool])),e=new Set,f=Math.min(Math.max(a.splits.length,1),b.length,4),g=[];for(let b of a.splits){if(g.length>=f)break;let a=d.get(b.instanceId);a&&!e.has(b.instanceId)&&(e.add(b.instanceId),g.push({cliToolId:a,instanceId:b.instanceId}))}for(let a of b){if(g.length>=f)break;e.has(a.id)||(e.add(a.id),g.push({cliToolId:a.cliTool,instanceId:a.id}))}return(0===g.length&&g.push({cliToolId:b[0].cliTool,instanceId:b[0].id}),g.length===a.splits.length&&g.every((b,c)=>b.instanceId===a.splits[c].instanceId&&b.cliToolId===a.splits[c].cliToolId))?a:(c=g.length===a.widths.length?kQ(a.widths):g.length<a.widths.length?kQ(a.widths.slice(0,g.length)):Array.from({length:g.length},()=>1/g.length),kR({...a,splits:g,widths:c}))}(d,b):d})(0,b,c)),[f,g]=(0,h.useState)(0),[i,j]=(0,h.useState)(null),k=(0,h.useRef)(d);k.current=d;let l=(0,h.useRef)(b);l.current=b,(0,h.useRef)(c).current=c,(0,h.useRef)(a),(0,h.useMemo)(()=>b.map(a=>`${a.id}:${a.cliTool}`).join("|"),[b]),(0,h.useRef)(a);let m=(0,h.useCallback)(()=>{j(null),e(a=>{if(a.splits.length>=4)return a;let b=new Set(a.splits.map(a=>a.instanceId)),c=function(a,b){for(let c of a)if(!b.has(c.id))return c;return null}(l.current,b);if(!c)return a;let d=[...a.splits,{cliToolId:c.cliTool,instanceId:c.id}];if(4===d.length)return kR({...a,splits:d,widths:Array.from({length:4},()=>.25)});let e=a.widths.length-1,f=a.widths[e]/2,g=[...a.widths];return g[e]=f,g.push(f),kR({...a,splits:d,widths:g})})},[]),n=(0,h.useCallback)(()=>{j(null),e(a=>{if(a.splits.length<=1)return a;let b=a.splits.slice(0,-1),c=kQ(a.widths.slice(0,-1));return kR({...a,splits:b,widths:c})})},[]),o=(0,h.useCallback)((a,b)=>{let c=k.current,d=l.current;if(a<0||a>=c.splits.length)return!1;let f=d.find(a=>a.id===b);if(!f||c.splits[a].instanceId===b)return!1;for(let d=0;d<c.splits.length;d++)if(d!==a&&c.splits[d].instanceId===b)return!1;return e(c=>{if(a<0||a>=c.splits.length||c.splits[a].instanceId===b)return c;for(let d=0;d<c.splits.length;d++)if(d!==a&&c.splits[d].instanceId===b)return c;let d=c.splits.map((c,d)=>d===a?{cliToolId:f.cliTool,instanceId:b}:c);return{...c,splits:d}}),!0},[]),p=(0,h.useCallback)(a=>{e(b=>a.length!==b.widths.length||!function(a){if(!Array.isArray(a))return!1;for(let b of a)if("number"!=typeof b||!Number.isFinite(b)||b<=0)return!1;return!0}(a)?b:{...b,widths:[...a]})},[]),q=(0,h.useCallback)(()=>{j(null),e(a=>{let b=a.splits.length;if(0===b)return a;let c=Array.from({length:b},()=>1/b);return 4===b?{...a,widths:c,rowHeights:[...kL]}:kR({...a,widths:c})})},[]),r=(0,h.useCallback)(a=>{e(b=>4!==b.splits.length?b:Array.isArray(a)&&2===a.length&&kO(a)?{...b,rowHeights:[...a]}:b)},[]),s=(0,h.useCallback)(a=>{let c=new Set;for(let b=0;b<d.splits.length;b++)b!==a&&c.add(d.splits[b].instanceId);return b.filter(a=>!c.has(a.id)).map(a=>a.id)},[d.splits,b]),t=(0,h.useCallback)(a=>{g(a)},[]),u=(0,h.useMemo)(()=>{var a;return(a=d.rowHeights)&&kO(a)?[...a]:[...kL]},[d.rowHeights]),v=(0,h.useCallback)(a=>{a<0||a>=k.current.splits.length||j(b=>b===a?null:a)},[]);return{splits:d.splits,widths:d.widths,rowHeights:u,setRowHeights:r,addSplit:m,removeSplit:n,setSplitInstance:o,setSplitWidth:p,resetWidths:q,availableInstanceIds:s,focusedSplitIndex:f,setFocusedSplitIndex:t,maximizedIndex:i,toggleMaximize:v}}(a,b,c),A=(0,h.useMemo)(()=>{let a=new Map;for(let c of b)a.set(c.id,c);return a},[b]),B=(0,k.c)("worktree"),{visible:C,toggle:D,setWidth:E}=fA(),{collapsed:F,toggle:G}=kG(),H=!F,I=(0,h.useRef)(null),[J,K]=(0,h.useState)(!1),L=(0,h.useRef)(m.length),[M,N]=(0,h.useState)(null);(0,h.useEffect)(()=>{m.length>L.current&&N(m.length-1),L.current=m.length},[m.length]),(0,h.useEffect)(()=>{f?.(w)},[w,f]);let O=(0,h.useRef)(0),P=(0,h.useRef)(m);P.current=m,(0,h.useEffect)(()=>{if(!l||l.token===O.current)return;O.current=l.token;let{instanceId:a}=l,b=P.current.findIndex(b=>b.instanceId===a);if(0!==b){if(b>0)return void x(b);s(0,a)&&x(0)}},[l,s,x]),(0,h.useEffect)(()=>{if(null===M)return;let a=I.current;if(!a)return;let b=a.querySelector(`[data-split-index="${M}"]`);if(!b)return;let c=b.querySelector("textarea");c?.focus(),x(M),N(null)},[M,x]);let Q=(0,h.useCallback)((a,b)=>{let c=I.current;if(!c)return;let d=c.offsetWidth;if(0===d)return;let e=n.reduce((a,b)=>a+b,0),f=b/d*e,g=[...n],h=g[a]+f,i=g[a+1]-f,j=.05*e;h<j||i<j||(g[a]=h,g[a+1]=i,t(g))},[n,t]),R=kP(n[0]??1,n[1]??1),S=kP(o[0]??1,o[1]??1),T=(0,h.useCallback)((a,b)=>{let c=I.current;if(!c)return;let d=c.offsetWidth;if(0===d)return;let e=n[0]+n[1];if(!(e>0))return;let f=b/d*e,g=n[0]+f,h=n[1]-f,i=.05*e;g<i||h<i||t([g,h,g,h])},[n,t]),U=(0,h.useCallback)((a,b)=>{let c=I.current;if(!c)return;let d=c.offsetHeight;if(0===d)return;let e=o[0]+o[1];if(!(e>0))return;let f=b/d*e,g=o[0]+f,h=o[1]-f,i=.05*e;g<i||h<i||p([g,h])},[o,p]),V=(0,h.useCallback)(()=>K(!0),[]),W=(0,h.useCallback)(()=>K(!1),[]),X=(0,h.useCallback)(()=>{u(),E(40)},[u,E]),_=m.length<4&&!J,aa=m.length>1&&!J,ac=m.length>1||C,ad=null!==y,ae=m.length>1,af=4===m.length,ag=(0,h.useCallback)(()=>{z(y??w)},[z,y,w]),ah=B(ad?"terminal.restoreSplits":"terminal.maximizeFocusedSplit"),ai=`${ah} — ${B("terminal.maximizeShortcutHint")}`,{tabCount:aj,hasDiff:ak}=(0,h.useContext)(kF),al=0===aj&&!ak,am=`${B(C?"terminal.hideHistory":"terminal.showHistory")} — ${B("terminal.historyAllSplitsHint")}`,an=B(al?"terminal.filesEmptyHint":H?"terminal.hideFiles":"terminal.showFiles"),ao=(0,h.useMemo)(()=>m.map((a,b)=>fB(b)).join(" "),[m]),ap=(0,h.useMemo)(()=>m.map((a,b)=>()=>x(b)),[m,x]),aq=(0,h.useMemo)(()=>m.map((a,b)=>a=>s(b,a)),[m,s]),ar=(0,h.useMemo)(()=>m.map((a,b)=>()=>z(b)),[m,z]),as=(0,h.useMemo)(()=>m.map((a,b)=>a=>{let c=(0,$.sw)(A.get(a)??{cliTool:"claude",alias:a});if(m[b]?.instanceId===a)return;let d=m.findIndex((c,d)=>d!==b&&c.instanceId===a);if(-1!==d)return void g?.(`${c} is already in use by split ${d+1}`,"warning");s(b,a)&&(j?.(a),g?.(`Moved ${c} to Split ${b+1}`,"success"))}),[m,s,g,j,A]);return(0,e.jsxs)("div",{role:"group","aria-label":"Terminal splits","data-testid":"terminal-split-container",className:"flex flex-col h-full min-h-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-surface border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{"data-testid":"split-count-label",className:"text-xs text-muted-foreground tabular-nums mr-1 truncate",children:ad?B("terminal.maximizedStatus",{split:(y??0)+1}):`${m.length} / 4 splits`}),(0,e.jsx)(ab.m_,{content:B("terminal.addSplit"),placement:"bottom",children:(0,e.jsx)("button",{type:"button",onClick:q,disabled:!_,"aria-disabled":!_,"aria-label":B("terminal.addSplit"),"data-testid":"add-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(hr.A,{className:"w-4 h-4","aria-hidden":"true"})})}),(0,e.jsx)(ab.m_,{content:B("terminal.removeSplit"),placement:"bottom",children:(0,e.jsx)("button",{type:"button",onClick:r,disabled:!aa,"aria-disabled":!aa,"aria-label":B("terminal.removeSplit"),"data-testid":"remove-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(kI.A,{className:"w-4 h-4","aria-hidden":"true"})})}),(0,e.jsx)(ab.m_,{content:B("terminal.equalizeWidthsHint"),placement:"bottom",children:(0,e.jsx)("button",{type:"button",onClick:X,disabled:!ac,"aria-disabled":!ac,"aria-label":B("terminal.equalizeWidthsHint"),"data-testid":"equalize-split-widths",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(kJ,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})})}),(0,e.jsx)(ab.m_,{content:ai,placement:"bottom",children:(0,e.jsx)("button",{type:"button",onClick:ag,disabled:!ae,"aria-disabled":!ae,"aria-pressed":ad,"aria-label":ah,"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:ad?(0,e.jsx)(Y,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}):(0,e.jsx)(Z,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})})}),(0,e.jsx)("div",{className:"ml-auto h-4 w-px bg-border","aria-hidden":"true"}),(0,e.jsx)(ab.m_,{content:am,placement:"bottom",className:"flex-shrink-0",children:(0,e.jsxs)("button",{type:"button",onClick:D,"aria-pressed":C,"aria-expanded":C,"aria-controls":ao,"aria-label":B(C?"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 ${C?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[(0,e.jsx)(c1,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:B("terminal.historyLabel")})]})}),(0,e.jsx)(ab.m_,{content:an,placement:"bottom",className:"flex-shrink-0",children:(0,e.jsxs)("button",{type:"button",onClick:G,disabled:al,"aria-disabled":al,"aria-pressed":H,"aria-expanded":H,"aria-controls":kE,"aria-label":B(H?"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 ${H?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[(0,e.jsx)(kK,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:B("terminal.filesLabel")}),aj>0&&(0,e.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:aj})]})})]}),(0,e.jsxs)("div",{ref:I,"data-testid":"terminal-split-layout","data-layout":af?"grid":"row",className:af?"grid flex-1 min-h-0 w-full overflow-y-auto":"flex flex-1 min-h-0 w-full",style:af?{gridTemplateColumns:ad?"1fr":`${R[0]}fr 4px ${R[1]}fr`,gridTemplateRows:ad?"1fr":`minmax(280px, ${S[0]}fr) 4px minmax(280px, ${S[1]}fr)`}:void 0,children:[m.map((a,b)=>{let c=b===m.length-1,f=null!==y&&y!==b,g=y===b;return(0,e.jsxs)(i().Fragment,{children:[(0,e.jsx)("div",{"data-testid":`split-wrapper-${b}`,"data-hidden":f?"true":void 0,style:af?{gridColumn:g||b%2==0?1:3,gridRow:g||b<2?1:3,minWidth:0,minHeight:0,...f?{display:"none"}:null}:{flexGrow:g?1:n[b]??1,flexShrink:1,flexBasis:0,minWidth:0,...f?{display:"none"}:null},className:"h-full",children:d({splitIndex:b,cliToolId:a.cliToolId,instanceId:a.instanceId,instance:A.get(a.instanceId),availableInstances:v(b).map(a=>A.get(a)).filter(a=>void 0!==a),onInstanceChange:aq[b],onFocus:ap[b],isFocused:w===b,onDropInstance:as[b],isMaximized:g,onToggleMaximize:ar[b]})}),af||c?null:(0,e.jsx)(kT,{resizerIdx:b,hidden:null!==y,ariaValueNow:n.length?n[b]/n.reduce((a,b)=>a+b,0)*100:50,onResize:Q,onStart:V,onEnd:W,onDoubleClick:u})]},`split-${b}`)}),af?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(kT,{resizerIdx:0,testId:"split-grid-column-resizer",gridArea:{gridColumn:2,gridRow:"1 / span 3"},hidden:ad,ariaValueNow:n[0]/(n[0]+n[1])*100,onResize:T,onStart:V,onEnd:W,onDoubleClick:u}),(0,e.jsx)(kT,{resizerIdx:0,testId:"split-grid-row-resizer",orientation:"vertical",gridArea:{gridColumn:"1 / span 3",gridRow:2},hidden:ad,ariaValueNow:o[0]/(o[0]+o[1])*100,onResize:U,onStart:V,onEnd:W,onDoubleClick:u})]}):null]})]})});function kT({resizerIdx:a,ariaValueNow:b,onResize:c,onStart:d,onEnd:f,onDoubleClick:g,hidden:i=!1,orientation:j="horizontal",testId:k,gridArea:l}){let m=(0,h.useCallback)(b=>c(a,b),[a,c]);return(0,e.jsx)("div",{"data-testid":k??`split-resizer-${a}`,style:{...l,...i?{display:"none"}:null},onMouseDownCapture:d,onTouchStartCapture:d,onMouseUpCapture:f,onTouchEndCapture:f,children:(0,e.jsx)(f_,{onResize:m,orientation:j,ariaValueNow:b,onDoubleClick:g})})}function kU(a){if(!a)return null;let b=a.decisionId;return"string"==typeof b&&""!==b?b:null}let kV=`
41
+ ${b.trim()}`:c}(s,g))})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)("input",{type:"text",value:w,onChange:a=>x(a.target.value),placeholder:s("git.stash.messagePlaceholder"),className:"w-full px-2 py-1 text-xs border border-input rounded bg-surface dark:bg-surface-2 text-foreground","data-testid":"git-stash-push-message"}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,e.jsx)(n.Sc,{checked:y,onCheckedChange:a=>z(!0===a),"data-testid":"git-stash-include-untracked"}),s("git.stash.includeUntracked")]}),(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>{l(w,y),x(""),z(!1)},className:"px-2 py-1 text-xs rounded bg-accent-600 hover:bg-accent-700 text-white disabled:opacity-50","data-testid":"stash-push-button",children:s("git.stash.push")})]})]}),b?(0,e.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",role:"status",children:s("git.stash.loading")}):0===a.length?(0,e.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",children:s("git.stash.empty")}):(0,e.jsx)("ul",{className:"divide-y divide-border",children:a.map(a=>(0,e.jsx)("li",{className:"py-1.5","data-testid":"git-stash-row",children:(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("span",{className:"font-mono text-xs text-accent-600 dark:text-accent-400",children:["stash@","{",a.index,"}"]}),(0,e.jsx)("span",{className:"ml-2 text-xs text-foreground truncate",children:a.message})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>o(a.index),className:"px-1.5 py-0.5 text-xs rounded border border-input hover:bg-muted disabled:opacity-50","data-testid":"stash-apply-button",children:s("git.stash.apply")}),(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>m(a.index),className:"px-1.5 py-0.5 text-xs rounded border border-input hover:bg-muted disabled:opacity-50","data-testid":"stash-pop-button",children:s("git.stash.pop")}),(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>B(a.index),className:"px-1.5 py-0.5 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"stash-drop-button",children:s("git.stash.drop")})]})]})},a.index))})]}),null!==A&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"git-stash-drop-confirm",role:"dialog",children:[(0,e.jsxs)("p",{className:"text-xs text-danger-foreground",children:["stash@","{",A,"}",s("git.stash.dropConfirmSuffix")]}),i&&(0,e.jsx)("p",{className:"mt-1 text-xs text-danger-foreground","data-testid":"git-stash-drop-session-warning",children:s("git.danger.runningSessionWarning")}),(0,e.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,e.jsx)("button",{type:"button",disabled:d,onClick:()=>{p(A),B(null)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"git-stash-drop-confirm-button",children:s("git.stash.drop")}),(0,e.jsx)("button",{type:"button",onClick:()=>B(null),className:"px-2 py-1 text-xs rounded border border-input hover:bg-muted",children:t("cancel")})]})]})]})}),jD={soft:"git.danger.modeSoft",mixed:"git.danger.modeMixed",hard:"git.danger.modeHard"},jE=(0,h.memo)(function({selectedCommit:a,busy:b,actionError:c,conflictNotice:d,currentBranch:f,aheadCount:g,hasRunningSession:i,onReset:j,onRevert:l,onForcePush:m}){let{isMobile:o,onInsertToMessage:p}=ji(),q=(0,k.c)("worktree"),r=(0,k.c)("common"),[s,t]=(0,h.useState)(!1),[u,v]=(0,h.useState)("mixed"),[w,x]=(0,h.useState)(!0),[y,z]=(0,h.useState)(""),[A,B]=(0,h.useState)(!1),[C,D]=(0,h.useState)(!1),[E,F]=(0,h.useState)(!1),[G,H]=(0,h.useState)(!1),[I,J]=(0,h.useState)(!0),K=w?"HEAD":a,L=!w&&!a;return(0,e.jsxs)("div",{className:"border-t-2 border-danger-border","data-testid":"git-danger-zone-section",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>t(a=>!a),className:"w-full flex items-center gap-1 px-3 py-2 text-sm font-medium text-danger-foreground bg-danger-subtle cursor-pointer hover:bg-danger-subtle","data-testid":"git-danger-zone-toggle",children:[(0,e.jsx)("span",{className:"text-xs w-4 text-center",children:s?"▼":"▶"}),q("git.danger.title")]}),s&&(0,e.jsxs)("div",{className:"px-3 py-3 space-y-2 bg-danger-subtle",children:[c&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-danger-zone-error",children:c}),d&&(0,e.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-danger-zone-conflict",children:d}),(0,e.jsxs)("div",{className:`flex ${o?"flex-col":"flex-row"} gap-2`,children:[(0,e.jsx)("button",{type:"button",onClick:()=>B(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle","data-testid":"git-danger-zone-reset-open",children:q("git.danger.resetOpen")}),(0,e.jsx)("button",{type:"button",disabled:!a,onClick:()=>D(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"git-danger-zone-revert-open",children:q("git.danger.revertOpen")}),m&&(0,e.jsx)("button",{type:"button",disabled:b,onClick:()=>H(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"git-force-push-open",children:q("git.danger.forcePushOpen")})]}),!a&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:q("git.danger.selectCommitHint")})]}),A&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"reset-confirm",role:"dialog",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:q("git.danger.resetTitle")}),(0,e.jsxs)(n.z6,{value:w?"head":"commit",onValueChange:a=>x("head"===a),name:"reset-target",className:"flex flex-col gap-1 mb-2",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,e.jsx)(n.CU,{value:"head","data-testid":"reset-target-head"}),q("git.danger.resetTargetHead")]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,e.jsx)(n.CU,{value:"commit",disabled:!a,"data-testid":"reset-target-commit"}),q("git.danger.resetTargetSelectedPrefix"),a?q("git.danger.resetTargetSelectedHash",{hash:a.slice(0,7)}):q("git.danger.resetTargetNoneSelected")]})]}),(0,e.jsx)(n.z6,{value:u,onValueChange:a=>v(a),name:"reset-mode",className:"flex flex-col gap-1 mb-2",children:["soft","mixed","hard"].map(a=>(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,e.jsx)(n.CU,{value:a,"data-testid":`reset-mode-${a}`}),q(jD[a])]},a))}),"hard"===u&&(0,e.jsxs)("div",{className:"mb-2 space-y-1",children:[(0,e.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-history-loss-warning",children:q("git.danger.resetHardWarning")}),i&&(0,e.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-session-warning",children:q("git.danger.runningSessionWarning")}),(0,e.jsx)("input",{type:"text",value:y,onChange:a=>z(a.target.value),placeholder:q("git.danger.confirmPlaceholder",{branch:f??""}),className:"w-full px-2 py-1 text-xs border border-danger-border rounded bg-surface dark:bg-surface-2 text-foreground","data-testid":"reset-hard-branch-input"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,e.jsx)(jq,{className:"mr-auto",testId:"reset-ask-ai",disabled:L,onClick:()=>{K&&(p("hard"===u?q("git.aiPrompts.resetHard",{target:jz(K)}):q("git.aiPrompts.reset",{target:jz(K),mode:u})),B(!1),z(""))}}),(0,e.jsx)("button",{type:"button",disabled:b||L||"hard"===u&&y!==(f??""),onClick:()=>{K&&(j(K,u,"hard"===u?y:void 0),B(!1),z(""))},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"reset-confirm-button",children:q("git.danger.reset")}),(0,e.jsx)("button",{type:"button",onClick:()=>{B(!1),z("")},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:r("cancel")})]})]}),C&&a&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"revert-confirm",role:"dialog",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:q("git.danger.revertTitle")}),(0,e.jsxs)("p",{className:"text-xs text-foreground mb-2",children:[q("git.danger.revertBodyPrefix"),(0,e.jsx)("span",{className:"font-mono",children:a.slice(0,7)})]}),i&&(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"revert-session-warning",children:q("git.danger.runningSessionWarning")}),(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,e.jsx)(n.Sc,{checked:E,onCheckedChange:a=>F(!0===a),"data-testid":"revert-no-commit"}),q("git.danger.revertNoCommit")]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,e.jsx)(jq,{className:"mr-auto",testId:"revert-ask-ai",onClick:()=>{p(q("git.aiPrompts.revert",{commit:jz(a.slice(0,7))})),D(!1),F(!1)}}),(0,e.jsx)("button",{type:"button",disabled:b,onClick:()=>{l(a,E),D(!1),F(!1)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"revert-confirm-button",children:q("git.danger.revert")}),(0,e.jsx)("button",{type:"button",onClick:()=>{D(!1),F(!1)},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:r("cancel")})]})]}),G&&m&&(0,e.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"force-push-confirm",role:"dialog",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:q("git.danger.forcePushTitle")}),(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-protected-branch-warning",children:q("git.danger.protectedBranchWarning")}),i&&(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-session-warning",children:q("git.danger.runningSessionWarning")}),(0,e.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,e.jsx)(n.Sc,{checked:I,onCheckedChange:a=>J(!0===a),"data-testid":"force-push-with-lease"}),q("git.danger.forceWithLease")]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,e.jsx)(jq,{className:"mr-auto",testId:"force-push-ask-ai",onClick:()=>{p(function(a,{branch:b,ahead:c}){let d=b?jz(b):a("git.aiPrompts.forcePushCurrentBranch");return a("number"==typeof c&&c>0?"git.aiPrompts.forcePushAhead":"git.aiPrompts.forcePush",{branchRef:d,upstream:jz(`origin/${b??"<branch>"}`),ahead:c??0})}(q,{branch:f,ahead:g??null})),H(!1)}}),(0,e.jsx)("button",{type:"button",disabled:b,onClick:()=>{m(I),H(!1)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"force-push-confirm-button",children:q("git.danger.forcePush")}),(0,e.jsx)("button",{type:"button",onClick:()=>H(!1),className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:r("cancel")})]})]})]})}),jF=(0,h.memo)(function({worktreeId:a,onDiffSelect:b,isMobile:c=!1,worktree:d,onInsertToMessage:f,className:g=""}){let i=(0,k.c)("worktree"),{activeTab:j,setActiveTab:l,historyOpen:m,toggleHistory:o,advancedOpen:p,toggleAdvanced:q}=function(){let{value:a,setValue:b,isAvailable:c}=(0,cq.V)({key:ja.activeTab,defaultValue:"status",validate:jb}),{value:d,setValue:e}=(0,cq.V)({key:ja.historyOpen,defaultValue:!0,validate:jc}),{value:f,setValue:g}=(0,cq.V)({key:ja.advancedOpen,defaultValue:!1,validate:jc}),i=(0,h.useCallback)(a=>b(a),[b]);return{activeTab:a,setActiveTab:i,historyOpen:d,toggleHistory:(0,h.useCallback)(()=>e(a=>!a),[e]),advancedOpen:f,toggleAdvanced:(0,h.useCallback)(()=>g(a=>!a),[g]),isPersistent:c}}(),r=Object.values(d?.sessionStatusByCli??{}).some(a=>a?.isRunning===!0),{gitStatus:s,statusLoading:t,statusError:u,fetchStatus:v}=function(a){let[b,c]=(0,h.useState)(null),[d,e]=(0,h.useState)(!0),[f,g]=(0,h.useState)(null);return{gitStatus:b,statusLoading:d,statusError:f,fetchStatus:(0,h.useCallback)(async()=>{g(null);try{let b=await fetch(`/api/worktrees/${a}/git/status`);if(!b.ok){let a=await b.json().catch(()=>({}));g(a.error||"Failed to fetch git status");return}let d=await b.json();c(d)}catch{g("Failed to fetch git status")}finally{e(!1)}},[a])}}(a),{commits:w,selectedCommit:x,changedFiles:y,inlineDiffCommit:z,inlineFiles:A,inlineFilesLoading:B,inlineFilesError:C,selectedFile:D,diffContent:E,isLoading:F,isLoadingFiles:G,isLoadingDiff:H,commitError:I,detailError:J,setDiffContent:K,fetchCommits:L,handleCommitSelect:M,handleFileSelect:N,handleToggleInlineDiff:O,handleInlineDiffFile:P,handleRefresh:Q}=function(a,b){let[c,d]=(0,h.useState)([]),[e,f]=(0,h.useState)(null),[g,i]=(0,h.useState)([]),[j,k]=(0,h.useState)(null),[l,m]=(0,h.useState)([]),[n,o]=(0,h.useState)(!1),[p,q]=(0,h.useState)(null),[r,s]=(0,h.useState)(null),[t,u]=(0,h.useState)(null),[v,w]=(0,h.useState)(!0),[x,y]=(0,h.useState)(!1),[z,A]=(0,h.useState)(!1),[B,C]=(0,h.useState)(null),[D,E]=(0,h.useState)(null),F=(0,h.useCallback)(async()=>{w(!0),C(null);try{let b=await fetch(`/api/worktrees/${a}/git/log`);if(!b.ok){let a=await b.json();C(a.error||"Failed to fetch commit history");return}let c=await b.json();d(c.commits)}catch{C("Failed to fetch commit history")}finally{w(!1)}},[a]),G=(0,h.useCallback)(async b=>{y(!0),i([]),s(null),u(null),E(null);try{let c=await fetch(`/api/worktrees/${a}/git/show/${b}`);if(!c.ok){let a=await c.json();E(a.error||"Failed to fetch commit details");return}let d=await c.json();i(d.files)}catch{E("Failed to fetch commit details")}finally{y(!1)}},[a]),H=(0,h.useCallback)(async(c,d)=>{A(!0),u(null),E(null);try{let e=await fetch(`/api/worktrees/${a}/git/diff?commit=${c}&file=${encodeURIComponent(d)}`);if(!e.ok){let a=await e.json();E(a.error||"Failed to fetch diff");return}let f=await e.json();u(f.diff),b(f.diff,d)}catch{E("Failed to fetch diff")}finally{A(!1)}},[a,b]),I=(0,h.useCallback)(a=>{f(a),G(a)},[G]),J=(0,h.useCallback)(a=>{e&&(s(a),H(e,a))},[e,H]),K=(0,h.useCallback)(async b=>{if(j===b){k(null),m([]),q(null);return}k(b),m([]),q(null),o(!0);try{let c=await fetch(`/api/worktrees/${a}/git/show/${b}`);if(!c.ok){let a=await c.json().catch(()=>({}));q(a.error||"Failed to fetch commit details");return}let d=await c.json();m(Array.isArray(d.files)?d.files:[])}catch{q("Failed to fetch commit details")}finally{o(!1)}},[a,j]),L=(0,h.useCallback)((a,b)=>{f(a),s(b),i(l),H(a,b)},[l,H]),M=(0,h.useCallback)(()=>{f(null),i([]),s(null),u(null),E(null),F()},[F]);return{commits:c,selectedCommit:e,changedFiles:g,inlineDiffCommit:j,inlineFiles:l,inlineFilesLoading:n,inlineFilesError:p,selectedFile:r,diffContent:t,isLoading:v,isLoadingFiles:x,isLoadingDiff:z,commitError:B,detailError:D,setDiffContent:u,fetchCommits:F,handleCommitSelect:I,handleFileSelect:J,handleToggleInlineDiff:K,handleInlineDiffFile:L,handleRefresh:M}}(a,b),R=(0,h.useCallback)(async()=>{await L(),await v()},[L,v]),{staged:S,stagedLoading:T,stagedError:U,opBusy:V,commitMessage:W,setCommitMessage:X,amend:Y,setAmend:Z,committing:$,changesCommitError:_,fetchStaged:aa,handleStage:ab,handleUnstage:ac,handleChangesDiff:ad,fetchWorkingDiffText:ae,commit:af,commitAndPush:ag}=function(a,b){let{onWorkingDiff:c,onCommitted:d}=b,[e,f]=(0,h.useState)(null),[g,i]=(0,h.useState)(!0),[j,k]=(0,h.useState)(null),[l,m]=(0,h.useState)(!1),[n,o]=(0,h.useState)(""),[p,q]=(0,h.useState)(!1),[r,s]=(0,h.useState)(!1),[t,u]=(0,h.useState)(null),v=(0,h.useCallback)(async()=>{k(null);try{let b=await fetch(`/api/worktrees/${a}/git/staged`);if(!b.ok){let a=await b.json().catch(()=>({}));k(a.error||"Failed to fetch changes");return}let c=await b.json();f(c)}catch{k("Failed to fetch changes")}finally{i(!1)}},[a]),w=(0,h.useCallback)(async b=>{m(!0),k(null);try{let c=await fetch(`/api/worktrees/${a}/git/stage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[b]})});if(!c.ok){let a=await c.json().catch(()=>({}));k(a.error||"Failed to stage file");return}await v()}catch{k("Failed to stage file")}finally{m(!1)}},[a,v]),x=(0,h.useCallback)(async b=>{m(!0),k(null);try{let c=await fetch(`/api/worktrees/${a}/git/unstage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[b]})});if(!c.ok){let a=await c.json().catch(()=>({}));k(a.error||"Failed to unstage file");return}await v()}catch{k("Failed to unstage file")}finally{m(!1)}},[a,v]),y=(0,h.useCallback)(async()=>{u(null);try{let b=await fetch(`/api/worktrees/${a}/git/commit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:n,amend:p})});if(!b.ok){let a=await b.json().catch(()=>({}));return u(a.error||"Failed to commit"),!1}return o(""),q(!1),await v(),await d(),!0}catch{return u("Failed to commit"),!1}},[a,n,p,v,d]),z=(0,h.useCallback)(async()=>{s(!0);try{await y()}finally{s(!1)}},[y]),A=(0,h.useCallback)(async a=>{s(!0);try{await y()&&await a()}finally{s(!1)}},[y]);return{staged:e,stagedLoading:g,stagedError:j,opBusy:l,commitMessage:n,setCommitMessage:o,amend:p,setAmend:q,committing:r,changesCommitError:t,fetchStaged:v,handleStage:w,handleUnstage:x,handleChangesDiff:(0,h.useCallback)(async(b,d)=>{try{let e=await fetch(`/api/worktrees/${a}/git/working-diff?file=${encodeURIComponent(b)}&mode=${d}`);if(!e.ok)return;let f=await e.json();"string"==typeof f.diff&&c(f.diff,b)}catch{}},[a,c]),fetchWorkingDiffText:(0,h.useCallback)(async(b,c)=>{try{let d=await fetch(`/api/worktrees/${a}/git/working-diff?file=${encodeURIComponent(b)}&mode=${c}`);if(!d.ok)return null;let e=await d.json();return"string"==typeof e.diff?e.diff:null}catch{return null}},[a]),commit:z,commitAndPush:A}}(a,{onWorkingDiff:(0,h.useCallback)((a,c)=>{K(a),b(a,c)},[K,b]),onCommitted:R}),{branches:ah,branchInclude:ai,branchesLoading:aj,branchesError:ak,branchBusy:al,branchActionError:am,fetchBranches:an,handleBranchIncludeChange:ao,handleBranchesRefresh:ap,handleCheckout:aq,handleBranchCreate:ar,handleBranchDelete:as}=function(a,b){let{onCheckoutCascade:c}=b,[d,e]=(0,h.useState)([]),[f,g]=(0,h.useState)("local"),[i,j]=(0,h.useState)(!0),[k,l]=(0,h.useState)(null),[m,n]=(0,h.useState)(!1),[o,p]=(0,h.useState)(null),q=(0,h.useCallback)(async b=>{l(null);try{let c=await fetch(`/api/worktrees/${a}/git/branches?include=${b}`);if(!c.ok){let a=await c.json().catch(()=>({}));l(a.error||"Failed to fetch branches");return}let d=await c.json();e(Array.isArray(d.branches)?d.branches:[])}catch{l("Failed to fetch branches")}finally{j(!1)}},[a]),r=(0,h.useCallback)(a=>{g(a)},[]),s=(0,h.useCallback)(()=>{q(f)},[q,f]),t=(0,h.useCallback)(async(b,d)=>{n(!0),p(null);try{let e=await fetch(`/api/worktrees/${a}/git/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:b.name,force:d})});if(!e.ok){let a=await e.json().catch(()=>({}));p(a.error||"Failed to checkout branch");return}await Promise.all([c(),q(f)])}catch{p("Failed to checkout branch")}finally{n(!1)}},[a,f,c,q]),u=(0,h.useCallback)(async(b,c)=>{n(!0),p(null);try{let d=await fetch(`/api/worktrees/${a}/git/branch/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,from:c})});if(!d.ok){let a=await d.json().catch(()=>({}));p(a.error||"Failed to create branch");return}await q(f)}catch{p("Failed to create branch")}finally{n(!1)}},[a,f,q]),v=(0,h.useCallback)(async(b,c)=>{n(!0),p(null);try{let d=await fetch(`/api/worktrees/${a}/git/branch/delete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,force:c})});if(!d.ok){let a=await d.json().catch(()=>({}));p(a.error||"Failed to delete branch");return}await q(f)}catch{p("Failed to delete branch")}finally{n(!1)}},[a,f,q]);return{branches:d,branchInclude:f,branchesLoading:i,branchesError:k,branchBusy:m,branchActionError:o,fetchBranches:q,handleBranchIncludeChange:r,handleBranchesRefresh:s,handleCheckout:t,handleBranchCreate:u,handleBranchDelete:v}}(a,{onCheckoutCascade:(0,h.useCallback)(async()=>{await Promise.all([v(),aa(),L()])},[v,aa,L])}),{stashes:at,stashLoading:au,stashError:av,stashBusy:aw,stashActionError:ax,stashConflictNotice:ay,fetchStash:az,handleStashPush:aA,handleStashPop:aB,handleStashApply:aC,handleStashDrop:aD}=function(a,b){let{onStashMutated:c}=b,[d,e]=(0,h.useState)([]),[f,g]=(0,h.useState)(!0),[i,j]=(0,h.useState)(null),[k,l]=(0,h.useState)(!1),[m,n]=(0,h.useState)(null),[o,p]=(0,h.useState)(null),q=(0,h.useCallback)(async()=>{j(null);try{let b=await fetch(`/api/worktrees/${a}/git/stash`);if(!b.ok){let a=await b.json().catch(()=>({}));j(a.error||"Failed to fetch stashes");return}let c=await b.json();e(Array.isArray(c.stashes)?c.stashes:[])}catch{j("Failed to fetch stashes")}finally{g(!1)}},[a]),r=(0,h.useCallback)(async()=>{await Promise.all([q(),c()])},[q,c]),s=(0,h.useCallback)(async(a,b,c)=>{l(!0),n(null),p(null);try{let d=await fetch(a,b),e=await d.json().catch(()=>({}));if(!d.ok)return void n(e.error||c);if(e.conflict){let a=Array.isArray(e.conflictFiles)?e.conflictFiles.join(", "):"",b=e.stashRetained?" (stash retained)":"";p(`Stash operation produced conflicts: ${a}${b}`)}await r()}catch{n(c)}finally{l(!1)}},[r]),t=(0,h.useCallback)((b,c)=>{s(`/api/worktrees/${a}/git/stash/push`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:b||void 0,includeUntracked:c})},"Failed to stash changes")},[a,s]),u=(0,h.useCallback)(b=>{s(`/api/worktrees/${a}/git/stash/pop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:b})},"Failed to pop stash")},[a,s]);return{stashes:d,stashLoading:f,stashError:i,stashBusy:k,stashActionError:m,stashConflictNotice:o,fetchStash:q,handleStashPush:t,handleStashPop:u,handleStashApply:(0,h.useCallback)(b=>{s(`/api/worktrees/${a}/git/stash/apply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:b})},"Failed to apply stash")},[a,s]),handleStashDrop:(0,h.useCallback)(b=>{s(`/api/worktrees/${a}/git/stash/${b}`,{method:"DELETE"},"Failed to drop stash")},[a,s])}}(a,{onStashMutated:(0,h.useCallback)(async()=>{await Promise.all([v(),aa()])},[v,aa])}),{dangerBusy:aE,dangerActionError:aF,dangerConflictNotice:aG,handleReset:aH,handleRevert:aI}=function(a,b){let{onHeadMoved:c}=b,[d,e]=(0,h.useState)(!1),[f,g]=(0,h.useState)(null),[i,j]=(0,h.useState)(null);return{dangerBusy:d,dangerActionError:f,dangerConflictNotice:i,handleReset:(0,h.useCallback)(async(b,d,f)=>{e(!0),g(null),j(null);try{let e=await fetch(`/api/worktrees/${a}/git/reset`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:b,mode:d,confirmBranch:f})});if(!e.ok){let a=await e.json().catch(()=>({}));g(a.error||"Failed to reset");return}await c()}catch{g("Failed to reset")}finally{e(!1)}},[a,c]),handleRevert:(0,h.useCallback)(async(b,d)=>{e(!0),g(null),j(null);try{let e=await fetch(`/api/worktrees/${a}/git/revert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitHash:b,noCommit:d})});if(!e.ok){let a=await e.json().catch(()=>({}));g(a.error||"Failed to revert");return}let f=await e.json().catch(()=>({}));if(f.conflict){let a=Array.isArray(f.conflictFiles)?f.conflictFiles.join(", "):"";j(`Revert produced conflicts: ${a}`)}await c()}catch{g("Failed to revert")}finally{e(!1)}},[a,c])}}(a,{onHeadMoved:(0,h.useCallback)(async()=>{await Promise.all([v(),aa(),an(ai),L()])},[v,aa,an,ai,L])}),{operation:aJ,progressState:aK,error:aL,errorReason:aM,conflict:aN,conflictFiles:aO,runFetch:aP,runPull:aQ,runPush:aR,abort:aS}=function(a,b={}){let{onCascade:c}=b,[d,e]=(0,h.useState)(null),[f,g]=(0,h.useState)("idle"),[i,j]=(0,h.useState)(null),[k,l]=(0,h.useState)(null),[m,n]=(0,h.useState)(!1),[o,p]=(0,h.useState)([]),q=(0,h.useRef)(null),r=(0,h.useRef)(c),s=(0,h.useCallback)(async(b,c,d)=>{j(null),l(null),n(!1),p([]),e(b),g("running");let f=new AbortController;q.current=f;try{let e=await fetch(`/api/worktrees/${a}/git/${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d),signal:f.signal});if(!e.ok){var h,i;let a=await e.json().catch(()=>({}));l((h=a?.reason,"auth_failed"===h?"auth_failed":"protected_branch"===h?"protected_branch":null)),j((i=a?.error,"string"==typeof i&&i.length>0?i:null)),g("error");return}let k=await e.json().catch(()=>({success:!0}));"pull"===b&&k?.conflict&&(n(!0),p(Array.isArray(k.conflictFiles)?k.conflictFiles:[])),g("idle")}catch(a){a instanceof Error&&"AbortError"===a.name?g("idle"):(j(null),l(null),g("error"))}finally{e(null),q.current=null,r.current?.(b)}},[a]),t=(0,h.useCallback)(a=>{let b={prune:!0===a.prune};return void 0!==a.remote&&(b.remote=a.remote),s("fetch","fetch",b)},[s]),u=(0,h.useCallback)(a=>{let b={rebase:!0===a.rebase,ffOnly:!0===a.ffOnly};return void 0!==a.remote&&(b.remote=a.remote),void 0!==a.branch&&(b.branch=a.branch),s("pull","pull",b)},[s]);return{operation:d,progressState:f,error:i,errorReason:k,conflict:m,conflictFiles:o,runFetch:t,runPull:u,runPush:(0,h.useCallback)(a=>{let b={force:!0===a.force,forceWithLease:!0===a.forceWithLease,setUpstream:!0===a.setUpstream};return void 0!==a.remote&&(b.remote=a.remote),void 0!==a.branch&&(b.branch=a.branch),s("push","push",b)},[s]),abort:(0,h.useCallback)(()=>{q.current?.abort()},[])}}(a,{onCascade:(0,h.useCallback)(a=>{v(),an(ai),"pull"===a&&(aa(),L())},[v,an,ai,aa,L])}),aT="auth_failed"===aM?i("git.network.authFailedGuidance"):"protected_branch"===aM?i("git.danger.protectedBranchWarning"):aL,aU="running"===aK&&("push"===aJ||"pull"===aJ),aV=s?.aheadBehind!=null,aW=(0,h.useCallback)(()=>{aP({})},[aP]),aX=(0,h.useCallback)(()=>ag(()=>aR({setUpstream:!aV})),[ag,aR,aV]);gt({intervalMs:5e3,enabled:"running"!==aK,onPoll:v});let aY=(0,h.useMemo)(()=>({isMobile:c,onDiffSelect:b,onInsertToMessage:f}),[c,b,f]),aZ=(0,e.jsx)(ju,{gitStatus:s,statusLoading:t,statusError:u,onRefresh:aW,refreshing:"running"===aK}),a$=(0,e.jsx)(jv,{progressState:aK,operation:aJ,error:aT,conflict:aN,conflictFiles:aO,hasUpstream:aV,onPull:()=>aQ({}),onPush:()=>aR({setUpstream:!aV}),onAbort:aS,extraActions:(0,e.jsx)(je,{branches:ah,busy:al||aU,actionError:am,hasRunningSession:r,isMobile:c,onCheckout:aq})}),a_=(0,e.jsx)(jx,{staged:S,loading:T,error:U,busy:V||aU,commitMessage:W,amend:Y,committing:$,commitError:_,onRefresh:aa,onDiff:ad,onPreview:ae,onStage:ab,onUnstage:ac,onCommitMessageChange:X,onAmendChange:Z,onCommit:af,onCommitAndPush:aX}),a0=(0,e.jsx)(jy,{commits:w,isLoading:F,commitError:I,commitListOpen:m,onToggleCommitList:o,onRefresh:Q,selectedCommit:x,onCommitSelect:M,inlineDiffCommit:z,inlineFiles:A,inlineFilesLoading:B,inlineFilesError:C,onToggleInlineDiff:O,onInlineDiffFile:P,changedFiles:y,isLoadingFiles:G,detailError:J,selectedFile:D,onFileSelect:N,diffContent:E,isLoadingDiff:H}),a1=(0,e.jsxs)(jf,{open:p,onToggle:q,children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-advanced-fetch",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:i("git.remote")}),(0,e.jsx)("div",{children:(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:()=>aP({}),disabled:"running"===aK,className:"px-2 py-1 text-xs rounded border border-input text-foreground hover:bg-muted disabled:opacity-50","data-testid":"git-fetch-button",children:i("git.network.fetch")})})]}),(0,e.jsx)(jB,{branches:ah,include:ai,loading:aj,error:ak,busy:al||aU,actionError:am,onIncludeChange:ao,onRefresh:ap,onCreate:ar,onDelete:as}),(0,e.jsx)(jC,{stashes:at,loading:au,error:av,busy:aw||aU,actionError:ax,conflictNotice:ay,hasRunningSession:r,onRefresh:az,onPush:aA,onPop:aB,onApply:aC,onDrop:aD}),(0,e.jsx)(jE,{selectedCommit:x,busy:aE||aU,actionError:aF,conflictNotice:aG,currentBranch:s?.currentBranch??null,aheadCount:s?.aheadBehind?.ahead??null,hasRunningSession:r,onReset:aH,onRevert:aI,onForcePush:a=>aR(a?{forceWithLease:!0}:{force:!0})})]});return(0,e.jsx)(jh,{value:aY,children:(0,e.jsx)(jn,{activeTab:j,onTabChange:l,className:g,statusSection:aZ,quickActionsSection:a$,changesSection:a_,historySection:a0,advancedSection:a1})})}),jG=(0,h.memo)(function({worktreeId:a,worktree:b,onWorktreeUpdate:c}){let[d,f]=(0,h.useState)(!1),g=(0,k.c)("worktree"),i=(0,h.useRef)(b?.id),j=(0,h.useRef)(!1),l=jP(b,c,b?.id,()=>{let a=b?.id!==i.current;return i.current=b?.id,a&&!j.current});return(j.current=l.isEditing,b)?(0,e.jsx)("div",{className:"p-4 space-y-4 overflow-y-auto h-full",children:(0,e.jsx)(jQ,{worktreeId:a,worktree:b,cardClassName:"bg-surface rounded-lg border border-border p-4",descriptionEditor:l,showLogs:d,onToggleLogs:()=>f(!d),onWorktreeUpdate:c})}):(0,e.jsx)("div",{className:"text-muted-foreground text-center py-8",children:g("detail.loadingInfo")})}),jH=(0,h.memo)(function({activeTab:a,worktreeId:b,worktree:c,messages:d,cliToolId:f,instanceId:g,onFilePathClick:h,onFileSelect:i,onWorktreeUpdate:j,onNewFile:l,onNewDirectory:m,onRename:n,onDelete:o,onUpload:p,onMove:q,onFileTreeReset:r,refreshTrigger:s,fileSearch:t,showToast:u,selectedAgents:v,onSelectedAgentsChange:w,availableAgents:x,maxAgents:y,persistToServer:z,vibeLocalModel:A,onVibeLocalModelChange:B,vibeLocalContextWindow:C,onVibeLocalContextWindowChange:D,disableAutoFollow:E,historySubTab:F,onHistorySubTabChange:G,onDiffSelect:H,onInsertToMessage:J,showArchived:K,onShowArchivedChange:L,historyDisplayLimit:M,onHistoryDisplayLimitChange:N,historyUserOnly:O,onHistoryUserOnlyChange:P,useInstanceManagement:Q,instances:R,onInstancesChange:S,visibleInstanceIds:T,onToggleInstanceVisible:U,verification:V,toolsSubTabRequest:W,onSurfaceModeChange:X}){let Y=(0,k.c)("worktree");switch(a){case"terminal":return(0,e.jsx)(I,{componentName:"TerminalDisplay",children:(0,e.jsx)(fw,{worktreeId:b,cliToolId:f,instanceId:g,disableAutoFollow:E,onSurfaceModeChange:X})});case"history":return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsxs)("div",{className:"flex border-b border-border shrink-0",children:[(0,e.jsx)("button",{type:"button",onClick:()=>G("message"),className:`flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ${"message"===F?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"}`,children:Y("detail.subTabMessage")}),(0,e.jsx)("button",{type:"button",onClick:()=>G("git"),className:`flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ${"git"===F?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"}`,children:Y("detail.subTabGit")})]}),"message"===F?(0,e.jsx)(I,{componentName:"HistoryPane",children:(0,e.jsx)(f6,{messages:d,worktreeId:b,onFilePathClick:h,className:"flex-1 min-h-0",showToast:u,onInsertToMessage:J,showArchived:K,onShowArchivedChange:L,historyDisplayLimit:M,onHistoryDisplayLimitChange:N,historyUserOnly:O,onHistoryUserOnlyChange:P})}):(0,e.jsx)(I,{componentName:"GitPane",children:(0,e.jsx)(jF,{worktreeId:b,onDiffSelect:H,isMobile:!0,worktree:c??void 0,onInsertToMessage:J,className:"flex-1 min-h-0"})})]});case"files":return(0,e.jsx)(I,{componentName:"FileTreeView",children:(0,e.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,e.jsx)(gz,{query:t.query,mode:t.mode,isSearching:t.isSearching,error:t.error,onQueryChange:t.setQuery,onModeChange:t.setMode,onClear:t.clearSearch}),(0,e.jsx)(gv,{worktreeId:b,onFileSelect:i,onNewFile:l,onNewDirectory:m,onRename:n,onDelete:o,onUpload:p,onMove:q,onResetView:r,refreshTrigger:s,pollingEnabled:"files"===a,searchQuery:t.query,searchMode:t.mode,searchResults:t.results?.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,e.jsx)(I,{componentName:"NotesAndLogsPane",children:(0,e.jsx)(i7,{worktreeId:b,className:"h-full",selectedAgents:v,onSelectedAgentsChange:w,availableAgents:x,maxAgents:y,persistToServer:z,vibeLocalModel:A,onVibeLocalModelChange:B,vibeLocalContextWindow:C,onVibeLocalContextWindowChange:D,onInsertToMessage:J,useInstanceManagement:Q,instances:R,onInstancesChange:S,visibleInstanceIds:T,onToggleInstanceVisible:U,modelByInstance:jO(c?.sessionStatusByInstance),composerTargetInstanceId:g,verification:V,requestedSubTab:W})});case"info":return(0,e.jsx)(jG,{worktreeId:b,worktree:c,onWorktreeUpdate:j});default:return null}}),jI=[{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 jJ(a,b,c){if(!a)return null;let d=b?`${a} \xb7 ${b}`:a;return c?`${c} \xb7 ${d}`:d}function jK(a,b){if(!a||!a.liveness&&!a.degradedReason)return null;let c=b("sse"===a.kind?"agentSource.kindSse":"scraper"===a.kind?"agentSource.kindScraper":"agentSource.kindHooks"),d=void 0===a.degradedReason?null:"port_identity_changed"===a.degradedReason?b("agentSource.reasonPortIdentityChanged"):"heartbeat_stale"===a.degradedReason?b("agentSource.reasonHeartbeatStale"):"not_subscribed"===a.degradedReason?b("agentSource.reasonNotSubscribed"):b("agentSource.reasonOther",{reason:a.degradedReason}),e=["stale"===a.liveness?b("agentSource.livenessStale"):"live"===a.liveness?b("agentSource.livenessLive"):null,d].filter(a=>null!==a).join(" \xb7 ");return e?b("agentSource.line",{kind:c,state:e}):b("agentSource.lineBare",{kind:c})}function jL(a,b,c=2){return"number"==typeof a&&Number.isFinite(a)?new Intl.NumberFormat(b,{style:"currency",currency:"USD",minimumFractionDigits:c,maximumFractionDigits:c}).format(a):null}function jM(a,b,c,d){var e;let f=jL(a?.cost,d),g=(e=b?.tokens,"number"==typeof e&&Number.isFinite(e)?new Intl.NumberFormat(d,{notation:"compact",maximumFractionDigits:1}).format(e):null),h=[];return f&&h.push(f),g&&h.push("number"==typeof b?.percent?c("agentSession.context",{tokens:g,percent:b.percent}):g),h.length>0?h.join(" \xb7 "):null}function jN(a,b,c,d){let e=[];a?.title&&e.push(c("agentSession.titleLabel",{title:a.title})),a?.agent&&e.push(c("agentSession.agentLabel",{agent:a.agent}));let f=jL(a?.cost,d,4);f&&e.push(c("agentSession.costLabel",{cost:f}));let g=function(a){if(!a)return null;if(null!==a.total)return a.total;let b=[a.input,a.output,a.reasoning,a.cacheRead,a.cacheWrite].filter(a=>"number"==typeof a&&Number.isFinite(a));return 0===b.length?null:b.reduce((a,b)=>a+b,0)}(a?.tokens);if(null!==g&&e.push(c("agentSession.spentLabel",{tokens:new Intl.NumberFormat(d).format(g)})),"number"==typeof b?.tokens){let a=new Intl.NumberFormat(d).format(b.tokens);e.push("number"==typeof b.limit&&"number"==typeof b.percent?c("agentSession.contextLabel",{tokens:a,limit:new Intl.NumberFormat(d).format(b.limit),percent:b.percent}):c("agentSession.contextUnknownLabel",{tokens:a}))}return e.length>0?e.join("\n"):null}function jO(a){if(!a)return{};let b={};for(let[c,d]of Object.entries(a)){let a=jJ(d?.model,d?.reasoningEffort);a&&(b[c]=a)}return b}function jP(a,b,c,d){let[e,f]=(0,h.useState)(!1),[g,i]=(0,h.useState)(""),[j,k]=(0,h.useState)(!1),l=(0,h.useCallback)(async()=>{if(a){k(!0);try{let c=await al.y.updateDescription(a.id,g);b(c),f(!1)}catch(a){console.error("Failed to save description:",a)}finally{k(!1)}}},[a,g,b]),m=(0,h.useCallback)(()=>{i(a?.description||""),f(!1)},[a]);return{isEditing:e,text:g,setText:i,isSaving:j,handleSave:l,handleCancel:m,startEditing:(0,h.useCallback)(()=>{f(!0)},[])}}let jQ=(0,h.memo)(function({worktreeId:a,worktree:b,cardClassName:c,descriptionEditor:d,showLogs:f,onToggleLogs:g,onWorktreeUpdate:i}){let{isEditing:j,text:l,setText:m,isSaving:o,handleSave:p,handleCancel:q,startEditing:r}=d,s=(0,k.c)("worktree"),t=(0,k.c)("common"),{copied:u,markCopied:v}=(0,bc.q)(),{copied:w,markCopied:x}=(0,bc.q)(),y=(0,h.useCallback)(async()=>{try{await (0,aZ.l)(b.path),v()}catch{}},[b.path,v]),z=(0,h.useCallback)(async()=>{try{await (0,aZ.l)(b.repositoryPath),x()}catch{}},[b.repositoryPath,x]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.worktree")}),(0,e.jsx)("p",{className:"text-lg font-semibold text-foreground",children:b.name})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.repository")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:z,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":s("detail.copyRepositoryPath"),title:w?s("detail.copied"):s("detail.copyRepositoryPath"),children:w?(0,e.jsx)(az.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(aU,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("p",{className:"text-base text-foreground",children:b.repositoryDisplayName??b.repositoryName}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:b.repositoryPath})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.path")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:y,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":s("detail.copyWorktreePath"),title:u?s("detail.copied"):s("detail.copyPath"),children:u?(0,e.jsx)(az.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(aU,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("p",{className:"text-sm text-foreground break-all font-mono",children:b.path})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.status")}),(0,e.jsx)("select",{value:b.status??"",onChange:async a=>{let c=a.target.value;try{let a=await fetch(`/api/worktrees/${b.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:""===c?null:c})});if(a.ok&&i){let b=await a.json();i(b)}}catch{}},className:"text-sm px-3 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent w-full","data-testid":"mobile-status-dropdown","aria-label":s("detail.worktreeStatusLabel"),children:jI.map(a=>(0,e.jsx)("option",{value:a.value??"",children:s(a.labelKey)},a.labelKey))})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.description")}),!j&&(0,e.jsx)("button",{type:"button",onClick:r,className:"text-sm text-accent-600 hover:text-accent-800 dark:text-accent-400 dark:hover:text-accent-300",children:s("actions.edit")})]}),j?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("textarea",{value:l,onChange:a=>m(a.target.value),placeholder:s("detail.addNotesPlaceholder"),className:"w-full min-h-[150px] p-3 border border-input dark:bg-surface dark:text-foreground rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:p,disabled:o,className:"px-4 py-2 bg-accent-600 text-white rounded-lg hover:bg-accent-700 disabled:opacity-50 text-sm font-medium",children:o?s("actions.saving"):s("actions.save")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:q,disabled:o,className:"px-4 py-2 bg-muted text-foreground rounded-lg hover:bg-border disabled:opacity-50 text-sm font-medium",children:t("cancel")})]})]}):(0,e.jsx)("div",{className:"min-h-[50px]",children:b.description?(0,e.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:b.description}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:s("detail.noDescription")})})]}),b.link&&(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.link")}),(0,e.jsx)("a",{href:b.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-600 hover:underline break-all",children:b.link})]}),b.updatedAt&&(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.lastUpdated")}),(0,e.jsx)("p",{className:"text-sm text-foreground",children:new Date(b.updatedAt).toLocaleString()})]}),(0,e.jsx)(bu,{version:"v0.34.1",className:c}),(0,e.jsx)(bB,{className:c}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.logs")}),(0,e.jsx)("button",{type:"button",onClick:g,className:"text-sm text-accent-600 hover:text-accent-800",children:f?s("detail.hide"):s("detail.show")})]}),f&&(0,e.jsx)(bq,{worktreeId:a})]})]})}),jR=(0,h.memo)(function({worktreeName:a,repositoryName:b,description:c,status:d,gitStatus:f,onBackClick:g,onInfoClick:i,hasUpdate:j,worktreeStatus:l,onWorktreeStatusChange:m,sessionStatusByCli:p,sessionStatusByInstance:q,instances:r,activeInstanceId:t,onActiveInstanceChange:u,onAgentDragStart:v,onAgentDragEnd:w,onKillSession:x,verificationChip:y,agentSessionByInstance:z}){let A=(0,k.c)("worktree"),B=(0,bm.Ym)(),C=(0,k.c)("common"),E=bn.sb[d],F=E?A(E):void 0,[G,H]=(0,h.useState)(null),I=r?.find(a=>a.id===t),J=!!t&&(q?.[t]?.isRunning??(I?p?.[I.cliTool]?.isRunning:void 0)??!1),K=(0,h.useCallback)((a,b)=>{a.dataTransfer.setData(ae,b),a.dataTransfer.effectAllowed="move",H(b),v?.(b)},[v]),L=(0,h.useCallback)(()=>{H(null),w?.()},[w]),M=c?s(c,50):null,N=(r??[]).map(a=>({item:a,status:(0,bD.kA)(q?.[a.id]??p?.[a.cliTool]),isActive:a.id===t})),O=(r??[]).some(a=>(q?.[a.id]??p?.[a.cliTool])?.awaitingInstruction===!0),P=!!x&&J,Q=[B,a,b,M??"",f?.currentBranch??"",f?.isDirty?"dirty":"",P?"end":"",O?"awaiting":"",...N.map(a=>`${a.item.id}:${(0,$.sw)(a.item)}:${a.status}:${a.isActive?"active":""}`)].join("\n"),R=(0,h.useRef)(null),S=(0,h.useRef)(null),T=function(a,b,c,d,e){let[f,g]=(0,h.useState)(()=>({key:c,pillBudget:4,squeezed:!1})),i=f;return f.key!==c&&g(i={key:c,pillBudget:4,squeezed:!1}),{pillBudget:i.pillBudget,squeezed:i.squeezed}}(0,0,Q,N.filter(bo.Lm).length,0);return(0,e.jsxs)("div",{ref:R,"data-testid":"desktop-header",className:"flex items-center justify-between gap-3 px-4 py-3 bg-surface border-b border-border",children:[(0,e.jsxs)("div",{ref:S,"data-testid":"desktop-header-identity",className:`flex items-center gap-3 min-w-0${T.squeezed?" overflow-x-clip":""}`,children:[(0,e.jsxs)("button",{type:"button",onClick:g,className:"flex flex-shrink-0 items-center gap-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":A("detail.goBack"),"data-testid":"worktree-back-button",children:[(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1h-2z"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:A("detail.home")})]}),(0,e.jsx)("div",{className:"w-px h-6 flex-shrink-0 bg-border","aria-hidden":"true"}),(0,e.jsx)(o.m,{"data-testid":"desktop-status-indicator",status:d,size:"lg",label:F}),(0,e.jsxs)("div",{className:"flex flex-col min-w-[6rem] shrink-4",children:[(0,e.jsx)("h1",{className:"text-lg font-semibold text-foreground truncate max-w-[200px] leading-tight",children:a}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"truncate max-w-[200px]",children:b}),f&&"(unknown)"!==f.currentBranch&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"/"}),(0,e.jsx)("span",{className:"truncate max-w-[150px] font-mono",title:f.currentBranch,"data-testid":"desktop-branch-name",children:s(f.currentBranch,30)}),f.isDirty&&(0,e.jsx)("span",{className:"text-warning",title:A("git.uncommittedChanges"),children:"*"})]}),M&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"—"}),(0,e.jsx)("span",{className:"truncate max-w-[300px] text-muted-foreground",title:c,children:M})]})]})]}),y&&(0,e.jsx)("div",{className:"min-w-0 w-[360px] max-w-max",children:y})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0 max-w-full","data-testid":"desktop-header-controls",children:[r&&r.length>0&&(()=>{let a=(0,bo.Uw)(N,T.pillBudget),b=a.filter(a=>"overflow"===a.slot),c=b.find(a=>"running"===a.status||"generating"===a.status)?.status??b.find(a=>"waiting"===a.status)?.status??null;return(0,e.jsxs)("div",{className:`flex items-center gap-2 min-w-0${T.squeezed?" overflow-x-clip":""}`,"data-testid":"desktop-agent-status-row",children:[a.map(a=>{if("overflow"===a.slot)return null;let b=a.item,c=(0,$.sw)(b),d=A("detail.statusPill",{label:c,status:C(`status.${a.status}`)}),f=q?.[b.id],g=z?.[b.id],h=jJ(f?.model,f?.reasoningEffort,g?.session?.agent),i=h?A("detail.statusPillWithModel",{label:c,status:C(`status.${a.status}`),model:h}):d,j=jM(g?.session,g?.context,A,B),k=j?A("detail.statusPillWithUsage",{base:i,usage:j}):i,l=jK(f?.eventSource,A),m=l?A("detail.statusPillWithSource",{base:k,source:l}):k,n=a.isActive,p={draggable:!0,onDragStart:a=>K(a,b.id),onDragEnd:L},r=G===b.id?" opacity-50 cursor-grabbing":"";return"pill"===a.slot?(0,e.jsxs)("button",{type:"button","data-testid":`desktop-agent-status-${b.id}`,onClick:()=>u?.(b.id),...p,"aria-label":m,title:m,"aria-pressed":n,className:`flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${n?"bg-accent-100 dark:bg-accent-900/30 text-accent-900 dark:text-accent-100":"hover:bg-muted text-foreground"}${r}`,children:[(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0}),(0,e.jsx)("span",{className:"whitespace-nowrap",children:d})]},b.id):(0,e.jsx)(ab.m_,{content:m,placement:"bottom",children:(0,e.jsx)("button",{type:"button","data-testid":`desktop-agent-status-${b.id}`,onClick:()=>u?.(b.id),...p,"aria-label":m,"aria-pressed":n,className:`flex items-center justify-center w-6 h-6 rounded-full transition-colors ${n?"bg-accent-100 dark:bg-accent-900/30":"hover:bg-muted"}${r}`,children:(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0})})},b.id)}),b.length>0&&(0,e.jsxs)(aa.rI,{children:[(0,e.jsx)(aa.ty,{asChild:!0,children:(0,e.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-overflow","aria-label":A("agentStatus.moreAgents",{count:b.length}),className:"flex items-center gap-1 px-2 py-1 rounded text-xs tabular-nums text-muted-foreground hover:bg-muted transition-colors",children:[c&&(0,e.jsx)(o.m,{status:c,size:"sm","aria-hidden":!0,title:void 0}),"+",b.length]})}),(0,e.jsx)(aa.SQ,{align:"end",children:b.map(a=>{let b=a.item,c=A("detail.statusPill",{label:(0,$.sw)(b),status:C(`status.${a.status}`)});return(0,e.jsxs)(aa._2,{"data-testid":`desktop-agent-overflow-${b.id}`,onSelect:()=>u?.(b.id),children:[(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0}),(0,e.jsx)("span",{className:"whitespace-nowrap",children:c})]},b.id)})})]}),O&&(0,e.jsx)("span",{"data-testid":"desktop-awaiting-instruction-badge",className:"flex-shrink-0 rounded-full bg-success-subtle px-1.5 py-0.5 text-[10px] font-medium leading-4 text-success-foreground",title:A("awaitingInstruction.label"),children:A("awaitingInstruction.badge")})]})})(),P&&(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:x,className:"flex items-center gap-1 px-2 py-1.5 text-xs font-medium rounded-lg text-danger-foreground hover:bg-danger-subtle transition-colors flex-shrink-0","aria-label":A("terminal.endSession"),"data-testid":"desktop-kill-session",children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"✕"}),C("end")]}),m&&(0,e.jsx)("select",{value:l??"",onChange:a=>{let b=a.target.value;m(""===b?null:b)},onClick:a=>a.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":A("detail.worktreeStatusLabel"),children:jI.map(a=>(0,e.jsx)("option",{value:a.value??"",children:A(a.labelKey)},a.labelKey))}),(0,e.jsx)(bE.g,{}),(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:i,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":A("detail.viewInfo"),"data-testid":"desktop-info-button",children:[(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:A("detail.info")}),j&&(0,e.jsx)(D,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":A("tabs.updateAvailable")})]})]})]})}),jS=(0,h.memo)(function({worktreeId:a,worktree:b,isOpen:c,onClose:d,onWorktreeUpdate:f}){let[g,i]=(0,h.useState)(!1),j=(0,k.c)("worktree"),l=(0,h.useRef)(c),m=jP(b,f,c,()=>{let a=c&&!l.current;return l.current=c,a});return b?(0,e.jsx)(bC.a,{isOpen:c,onClose:d,title:j("detail.infoModalTitle"),size:"md",children:(0,e.jsx)("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto","data-testid":"worktree-info-modal",children:(0,e.jsx)(jQ,{worktreeId:a,worktree:b,cardClassName:"bg-muted rounded-lg p-4",descriptionEditor:m,showLogs:g,onToggleLogs:()=>i(!g),onWorktreeUpdate:f})})}):null}),jT=(0,h.memo)(function(){let a=(0,k.c)("worktree");return(0,e.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"status","aria-live":"polite",children:(0,e.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,e.jsx)(n.y$,{size:"xl",variant:"accent"}),(0,e.jsx)("p",{className:"text-muted-foreground",children:a("detail.loading")})]})})}),jU=(0,h.memo)(function({message:a,onRetry:b}){let c=(0,k.c)("worktree"),d=(0,k.c)("common");return(0,e.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"alert","aria-live":"assertive",children:(0,e.jsxs)("div",{className:"text-center p-6 bg-danger-subtle rounded-lg border border-danger-border max-w-md",children:[(0,e.jsx)("svg",{className:"mx-auto h-12 w-12 text-danger-foreground/70 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,e.jsx)("p",{className:"text-danger-foreground font-medium",children:c("detail.errorLoading")}),(0,e.jsx)("p",{className:"text-danger-foreground/80 text-sm mt-2",children:a}),b&&(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:b,className:"mt-4 px-4 py-2 bg-danger-foreground text-danger-subtle rounded-lg hover:opacity-90 transition-opacity focus:outline-none focus:ring-2 focus:ring-danger focus:ring-offset-2 ring-offset-background",children:d("retry")})]})})}),jV=(0,h.memo)(function({activityPane:a,rightPane:b,activityPaneWidth:c=18,minPaneWidth:d=10,maxPaneWidth:f=60,onActivityPaneResize:g,className:i=""}){let j=(0,h.useRef)(null),l=(0,k.c)("worktree"),[m,n]=(0,h.useState)(c),o=g?c:m,p=(0,h.useCallback)(a=>{let b=j.current;if(!b)return;let e=b.offsetWidth;if(0===e)return;let h=Math.min(f,Math.max(d,(g?c:m)+a/e*100));g?g(h):n(h)},[c,m,d,f,g]),q=(0,h.useMemo)(()=>`flex h-full min-h-0 ${i}`.trim(),[i]);return(0,e.jsx)("div",{ref:j,className:"h-full",children:(0,e.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:q,children:[null!==a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{id:"worktree-activity-pane","data-testid":"activity-pane-slot","aria-label":l("desktopLayout.activityPane"),style:{width:`${o}%`},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,e.jsx)(I,{componentName:"ActivityPane",children:a})}),(0,e.jsx)(f_,{onResize:p,orientation:"horizontal",ariaValueNow:o})]}),(0,e.jsx)("div",{id:"worktree-right-pane","data-testid":"right-pane-slot","aria-label":l("desktopLayout.terminalPane"),className:"flex-grow overflow-hidden min-w-0",children:(0,e.jsx)(I,{componentName:"TerminalPane",children:b})})]})})}),jW=(0,y.A)("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),jX=(0,y.A)("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]);var jY=c(57898);let jZ=(0,y.A)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);var j$=c(55056);let j_=(0,y.A)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),j0=(0,y.A)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),j1=(0,y.A)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),j2=[{id:"files",labelKey:"activityBar.files",icon:jX},{id:"git",labelKey:"activityBar.git",icon:jY.A},{id:"notes",labelKey:"activityBar.notes",icon:U},{id:"schedules",labelKey:"activityBar.schedules",icon:jZ},{id:"agent",labelKey:"activityBar.agent",icon:j$.A},{id:"timer",labelKey:"activityBar.timer",icon:j_},{id:"todo",labelKey:"activityBar.todo",icon:j0},{id:"skills",labelKey:"activityBar.skills",icon:gL.A},{id:"verification",labelKey:"activityBar.verification",icon:dR},{id:"env",labelKey:"activityBar.env",icon:j1}];j2.map(a=>a.id);var j3=c(81092);let j4=(0,h.memo)(function({active:a,onToggle:b,className:c=""}){let d=(0,k.c)("worktree"),f=(0,h.useRef)([]),{isOpen:g,toggle:i}=(0,j3.VF)(),j=(0,h.useCallback)((a,c,d)=>{if("Enter"===a.key||" "===a.key){a.preventDefault(),b(d);return}if("ArrowDown"===a.key){a.preventDefault();let b=(c+1)%j2.length;f.current[b]?.focus();return}if("ArrowUp"===a.key){a.preventDefault();let b=(c-1+j2.length)%j2.length;f.current[b]?.focus();return}if("Home"===a.key){a.preventDefault(),f.current[0]?.focus();return}if("End"===a.key){a.preventDefault(),f.current[j2.length-1]?.focus();return}},[b]);return(0,e.jsxs)("div",{"data-testid":"activity-bar",className:`flex flex-col items-stretch w-12 flex-shrink-0 bg-muted border-r border-border ${c}`.trim(),children:[(0,e.jsx)(ab.m_,{content:d("activityBar.toggleSidebar"),placement:"right",children:(0,e.jsx)("button",{type:"button","data-testid":"activity-bar-toggle-sidebar",onClick:i,"aria-label":d("activityBar.toggleSidebar"),"aria-expanded":g,className:"flex items-center justify-center h-12 w-12 text-muted-foreground transition-colors hover:text-surface-foreground hover:bg-muted-foreground/10 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,e.jsx)(jW,{size:20,"aria-hidden":"true"})})}),(0,e.jsx)("div",{className:"mx-2 my-1 border-b border-border","aria-hidden":"true"}),(0,e.jsx)("div",{id:"worktree-activity-bar",role:"tablist","aria-orientation":"vertical","aria-label":d("activityBar.label"),className:"flex flex-col items-stretch",children:j2.map((c,g)=>{let h=c.icon,i=a===c.id,k=d(c.labelKey);return(0,e.jsx)(ab.m_,{content:k,placement:"right",children:(0,e.jsx)("button",{ref:a=>{f.current[g]=a},type:"button",role:"tab","aria-selected":i,"aria-label":k,"aria-controls":"worktree-activity-pane",tabIndex:i||null===a&&0===g?0:-1,onClick:()=>b(c.id),onKeyDown:a=>j(a,g,c.id),"data-testid":`activity-bar-button-${c.id}`,className:"group flex items-center justify-center h-12 w-12 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,e.jsx)("span",{"aria-hidden":"true",className:`flex items-center justify-center h-9 w-9 rounded-md transition-colors ${i?"bg-accent-500/10 text-accent-600 dark:text-accent-400":"text-muted-foreground group-hover:text-surface-foreground group-hover:bg-muted-foreground/10"}`,children:(0,e.jsx)(h,{size:20,"aria-hidden":"true"})})})},c.id)})})]})}),j5="worktree-activity-pane",j6={files:"FileTreeView",git:"GitPane",notes:"MemoPane",schedules:"ExecutionLogPane",agent:"AgentInstancesPane",timer:"TimerPane",todo:"TodoPane",skills:"WorktreeSkillsPane",verification:"VerificationPane",env:"EnvManagerPane"},j7=(0,h.memo)(function({active:a,activities:b,className:c=""}){if(null===a)return(0,e.jsx)("div",{id:j5,"data-testid":"activity-pane","data-active":"none",className:`h-full flex flex-col ${c}`.trim()});let d=b[a],f=j6[a];return(0,e.jsx)("div",{id:j5,"data-testid":"activity-pane","data-active":a,role:"tabpanel","aria-labelledby":`activity-bar-button-${a}`,className:`h-full flex flex-col min-h-0 ${c}`.trim(),children:(0,e.jsx)(I,{componentName:f,children:d??null})})}),j8=(0,y.A)("square-x",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),j9=(0,y.A)("list-x",[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"m15.5 9.5 5 5",key:"ytk86i"}],["path",{d:"m20.5 9.5-5 5",key:"17o44f"}]]),ka=(0,y.A)("chevrons-right",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]),kb=(0,h.memo)(function({inputRef:a,searchQuery:b,onQueryChange:c,matchCount:d,currentIdx:f,onNextMatch:g,onPrevMatch:h,onClose:i}){let j=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border-b border-input flex-shrink-0",children:[(0,e.jsx)("input",{ref:a,type:"text",value:b,onChange:a=>c(a.target.value),onKeyDown:a=>{"Escape"===a.key&&i(),"Enter"!==a.key||a.nativeEvent.isComposing||(a.shiftKey?h():g())},placeholder:j("fileSearch.placeholder"),className:"flex-1 min-w-0 px-2 py-0.5 text-sm bg-surface dark:text-foreground border border-input rounded outline-none focus:ring-1 focus:ring-ring",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground min-w-[3rem] text-right",children:d>0?`${f+1}/${d}`:"0/0"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:h,disabled:0===d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":j("fileSearch.prevMatch"),children:"▲"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:g,disabled:0===d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":j("fileSearch.nextMatch"),children:"▼"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:i,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white","aria-label":j("fileSearch.close"),children:(0,e.jsx)(a$.A,{className:"w-4 h-4"})})]})}),kc=[{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"]}],kd=kc.map(a=>a.extension),ke=[".md",".html",".htm",".yaml",".yml"];var kf=c(79689);function kg(){return(0,e.jsx)("div",{className:"flex items-center justify-center py-12 bg-surface",children:(0,e.jsx)(m.y,{size:"xl",variant:"accent"})})}let kh=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/HtmlPreview"]},ssr:!1,loading:()=>(0,e.jsx)(kg,{})}),ki=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/PdfPreview"]},ssr:!1,loading:()=>(0,e.jsx)(kg,{})}),kj=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/MarkdownEditor"]},ssr:!1,loading:()=>(0,e.jsx)(kg,{})}),kk=/^---\s*\nmarp:\s*true/;function kl(){let a=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,e.jsx)(m.y,{size:"xl",variant:"accent"}),(0,e.jsx)("p",{className:"ml-3 text-muted-foreground",children:a("fileViewer.loading")})]})}function km({error:a}){return(0,e.jsx)("div",{className:"bg-danger-subtle border border-danger-border rounded-lg p-4 m-4",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-5 h-5 text-danger-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,e.jsx)("p",{className:"text-sm text-danger-foreground",children:a})]})})}function kn({filePath:a,isMaximized:b,onToggleMaximize:c,copyableContent:d,onSearch:f}){let g=(0,k.c)("worktree"),{copied:h,markCopied:i}=(0,bc.q)(),{copied:j,markCopied:l}=(0,bc.q)(),m=async()=>{try{await (0,aZ.l)(a),i()}catch{}},n=async()=>{if(d)try{await (0,aZ.l)(d),l()}catch{}};return(0,e.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border gap-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("button",{type:"button",onClick:m,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.copyFilePath"),title:g("actions.copyPath"),children:h?(0,e.jsx)(az.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(aU,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",title:a,children:a})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[f&&(0,e.jsx)("button",{type:"button",onClick:f,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.searchInFile"),title:g("actions.search"),children:(0,e.jsx)(T.A,{className:"w-3.5 h-3.5"})}),d&&(0,e.jsx)("button",{type:"button",onClick:n,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.copyFileContent"),title:g("actions.copyContent"),children:j?(0,e.jsx)(az.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(aA,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{type:"button",onClick:c,className:"flex-shrink-0 p-1.5 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g(b?"actions.minimize":"actions.maximize"),title:g(b?"actions.minimize":"actions.maximize"),children:b?(0,e.jsx)(Y,{className:"w-4 h-4"}):(0,e.jsx)(Z,{className:"w-4 h-4"})})]})]})}function ko({content:a,extension:b,searchMatches:c,searchCurrentIdx:d,totalLines:f,rangeStart:g,worktreeId:i,filePath:j,onLineRangeFetched:k}){let l=(0,h.useRef)(null),m=(0,h.useMemo)(()=>a.split("\n"),[a]),n=Math.max(1,g??1),o=m.length,p=Math.max(f??o,o),q=(0,h.useRef)(new Map),r=(0,h.useCallback)(a=>{let c=Math.floor(a/500),d=q.current,e=d.get(c);if(!e){let a=500*c,f=Math.min(a+500,m.length),g=m.slice(a,f).join("\n"),h="";try{h=bd.highlight(g,{language:b,ignoreIllegals:!0}).value}catch{h=bd.highlightAuto(g).value}e=h.split("\n"),d.set(c,e)}return e[a-500*c]??""},[m,b]),s=(0,h.useMemo)(()=>new Set(c??[]),[c]),t=(c?.length??0)>0?c[d??0]:-1,u=c_({count:p,getScrollElement:()=>l.current,estimateSize:()=>24,overscan:100}),v=u.getVirtualItems();return!function({virtualItems:a,worktreeId:b,filePath:c,onLineRangeFetched:d,loadedStart:e,loadedLineCount:f}){(0,h.useRef)(new Set)}({virtualItems:v,worktreeId:i,filePath:j,onLineRangeFetched:k,loadedStart:n,loadedLineCount:o}),(0,e.jsx)("div",{className:"overflow-auto h-full",ref:l,"data-testid":"file-content-code",children:(0,e.jsx)("div",{style:{height:u.getTotalSize(),width:"100%",position:"relative"},children:v.map(a=>{let b=a.index+1,c=b-n,d=c>=0&&c<o,f=b===t,g=s.has(b),h=d?r(c):"";return(0,e.jsxs)("div",{"data-line":b,"data-index":a.index,ref:u.measureElement,className:`absolute left-0 right-0 flex font-mono text-sm ${f?"bg-warning/30":g?"bg-warning/15":""}`,style:{top:0,transform:`translateY(${a.start}px)`,height:"24px",lineHeight:"24px"},children:[(0,e.jsx)("div",{className:`px-3 text-right select-none border-r border-border bg-muted dark:bg-muted/50 whitespace-nowrap ${f||g?"text-warning-foreground":"text-muted-foreground"}`,style:{minWidth:"4rem"},children:b}),(0,e.jsx)("div",{className:"px-4 text-foreground flex-1 min-w-0 overflow-hidden",children:d?(0,e.jsx)("code",{className:"hljs",style:{padding:0,background:"transparent",whiteSpace:"pre"},dangerouslySetInnerHTML:{__html:h}}):(0,e.jsx)(kf.E,{className:"h-4 w-3/4"})})]},a.key)})})})}function kp({slides:a,fileName:b}){let c=(0,k.c)("worktree"),[d,f]=(0,h.useState)(0);return 0===a.length?(0,e.jsx)("div",{className:"p-4 text-muted-foreground",children:c("fileViewer.noSlides",{fileName:b})}):(0,e.jsxs)("div",{className:"h-full flex flex-col","data-testid":"marp-preview",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border bg-muted",children:[(0,e.jsx)("button",{type:"button",onClick:()=>{f(a=>Math.max(0,a-1))},disabled:0===d,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:c("actions.prev")}),(0,e.jsxs)("span",{className:"text-sm text-muted-foreground",children:[d+1," / ",a.length]}),(0,e.jsx)("button",{type:"button",onClick:()=>{f(b=>Math.min(a.length-1,b+1))},disabled:d===a.length-1,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:c("actions.next")})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,e.jsx)("iframe",{srcDoc:a[d],sandbox:"",title:c("fileViewer.slideTitle",{name:b,number:d+1}),className:"w-full h-full border-0"})})]})}function kq({marpSlides:a,fileName:b,worktreeId:c,filePath:d,contentText:f,onFileSaved:g,isMaximized:i,onToggleMaximize:j,onDirtyChange:l,onOpenFile:m}){let n=(0,k.c)("worktree"),[o,p]=(0,h.useState)("slides");return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border bg-muted",children:[(0,e.jsxs)("div",{className:"flex gap-1",children:[(0,e.jsx)("button",{type:"button",onClick:()=>p("slides"),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${"slides"===o?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"}`,children:n("fileViewer.slides")}),(0,e.jsx)("button",{type:"button",onClick:()=>p("editor"),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${"editor"===o?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"}`,children:n("fileViewer.editor")})]}),(0,e.jsx)(kn,{filePath:d,isMaximized:i,onToggleMaximize:j,copyableContent:f})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:"slides"===o?(0,e.jsx)(kp,{slides:a,fileName:b}):(0,e.jsx)(kj,{worktreeId:c,filePath:d,onSave:g,initialViewMode:"split",onDirtyChange:l,onOpenFile:m})})]})}function kr({children:a,isMaximized:b,onToggle:c,filePath:d}){if(!b)return(0,e.jsx)(e.Fragment,{children:a});let f=(0,e.jsxs)("div",{"data-testid":"maximized-file-overlay",className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:a1.M.MAXIMIZED_EDITOR},children:[(0,e.jsx)(kn,{filePath:d,isMaximized:b,onToggleMaximize:c}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:a})]});return"undefined"==typeof document?f:(0,cK.createPortal)(f,document.body)}function ks({tab:a,content:b,worktreeId:c,isMaximized:d,onToggleMaximize:f,onFileSaved:g,onDirtyChange:h,onOpenFile:i}){let j=bb(b.content);return(0,e.jsxs)(e.Fragment,{children:[!d&&(0,e.jsx)(kn,{filePath:a.path,isMaximized:d,onToggleMaximize:f,copyableContent:b.content,onSearch:j.openSearch}),j.searchOpen&&(0,e.jsx)(kb,{inputRef:j.searchInputRef,searchQuery:j.searchQuery,onQueryChange:j.setSearchQuery,matchCount:j.searchMatches.length,currentIdx:j.searchCurrentIdx,onNextMatch:j.nextMatch,onPrevMatch:j.prevMatch,onClose:j.closeSearch}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:j.searchOpen&&j.searchQuery.length>=2?(0,e.jsx)(ko,{content:b.content,extension:"md",searchMatches:j.searchMatches,searchCurrentIdx:j.searchCurrentIdx}):(0,e.jsx)(kj,{worktreeId:c,filePath:a.path,onSave:g,initialViewMode:"preview",onDirtyChange:h,onOpenFile:i})})]})}function kt({tab:a,content:b,worktreeId:c,isMaximized:d,onToggleMaximize:f,onLoadContent:g}){let i=bb(b.content),j=(0,h.useCallback)(c=>{g&&g(a.path,{...b,content:c.content,totalLines:c.totalLines,totalBytes:c.totalBytes??b.totalBytes,range:c.range})},[g,a.path,b]),k=void 0!==b.range&&(b.totalLines??0)>b.range.end-b.range.start+1;return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(kn,{filePath:a.path,isMaximized:d,onToggleMaximize:f,copyableContent:b.content,onSearch:i.openSearch}),i.searchOpen&&(0,e.jsx)(kb,{inputRef:i.searchInputRef,searchQuery:i.searchQuery,onQueryChange:i.setSearchQuery,matchCount:i.searchMatches.length,currentIdx:i.searchCurrentIdx,onNextMatch:i.nextMatch,onPrevMatch:i.prevMatch,onClose:i.closeSearch}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(ko,{content:b.content,extension:b.extension,searchMatches:i.searchOpen?i.searchMatches:void 0,searchCurrentIdx:i.searchOpen?i.searchCurrentIdx:void 0,totalLines:b.totalLines,rangeStart:b.range?.start,worktreeId:k?c:void 0,filePath:k?a.path:void 0,onLineRangeFetched:k?j:void 0})})]})}let ku=(0,h.memo)(function({tab:a,worktreeId:b,onLoadContent:c,onLoadError:d,onSetLoading:f,onFileSaved:g,onDirtyChange:i,onOpenFile:j}){let l=(0,k.c)("worktree"),m=(0,h.useRef)(l);m.current=l;let n=(0,h.useRef)(!1),[o,p]=(0,h.useState)(null),[q,r]=(0,h.useState)(!1);!function({tab:a,worktreeId:b,onLoadContent:c}){let d=(0,h.useRef)(null),e=(0,h.useRef)(c);e.current=c;let f=(0,h.useRef)(a.path);f.current=a.path,gt({intervalMs:5e3,enabled:function(a){if(null===a.content||a.loading||a.isDirty||a.content.isPdf)return!1;let{totalBytes:b}=a.content;return void 0===b||!(b>=1048576)}(a),onPoll:async()=>{let a=`/api/worktrees/${b}/files/${(0,a2.o)(f.current)}`,c={};d.current&&(c["If-Modified-Since"]=d.current);try{let b=await fetch(a,{headers:c});if(304===b.status||!b.ok)return;d.current=b.headers.get("Last-Modified");let g=await b.json();e.current(f.current,g)}catch{}}})}({tab:a,worktreeId:b,onLoadContent:c});let s=(0,h.useMemo)(()=>i?b=>i(a.path,b):void 0,[i,a.path]),t=(0,h.useCallback)(()=>{r(a=>!a)},[]);(0,h.useEffect)(()=>{if(!q)return;let a=a=>{"Escape"===a.key&&r(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[q]),(0,h.useEffect)(()=>{null!==a.content||a.loading||null!==a.error||n.current||(n.current=!0,f(a.path,!0),(async()=>{try{let e=await fetch(`/api/worktrees/${b}/files/${(0,a2.o)(a.path)}`);if(304===e.status)return;if(!e.ok){let b=await e.json(),c="string"==typeof b.error?b.error:b.error?.message||m.current("fileViewer.loadError");d(a.path,c);return}let f=await e.json();c(a.path,f)}catch(b){d(a.path,b instanceof Error?b.message:m.current("fileViewer.loadError"))}finally{n.current=!1}})())},[a.content,a.loading,a.error,a.path,b,c,d,f]);let u=a.content?.content??null,v=a.content?.extension??null;if((0,h.useEffect)(()=>{if(!u||"md"!==v||!kk.test(u)||u.length>1e6)return void p(null);let a=!1;return(async()=>{try{let c=await fetch(`/api/worktrees/${b}/marp-render`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:u})});if(c.ok){let b=await c.json();a||p(Array.isArray(b.slides)?b.slides:null)}}catch{}})(),()=>{a=!0}},[u,v,b]),a.loading)return(0,e.jsx)(kl,{});if(a.error)return(0,e.jsx)(km,{error:a.error});if(!a.content)return null;let{content:w}=a;return w.isImage?(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(kn,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsx)(aQ.a,{src:w.content,alt:w.path,mimeType:w.mimeType})})]})}):w.isVideo?(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(kn,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsx)(aR.u,{src:w.content,mimeType:w.mimeType})})]})}):w.isPdf?(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(kn,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(ki,{dataUri:w.content,filePath:a.path})})]})}):w.isHtml?(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(kn,{filePath:a.path,isMaximized:q,onToggleMaximize:t,copyableContent:w.content}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(kh,{worktreeId:b,filePath:a.path,htmlContent:w.content,onFileSaved:g,onOpenFile:j})})]})}):"md"===w.extension?(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)("div",{className:"h-full flex flex-col",children:o?(0,e.jsx)(kq,{marpSlides:o,fileName:a.name,worktreeId:b,filePath:a.path,contentText:w.content,onFileSaved:g,isMaximized:q,onToggleMaximize:t,onDirtyChange:s,onOpenFile:j}):(0,e.jsx)(ks,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onFileSaved:g,onDirtyChange:s,onOpenFile:j})})}):!function(a){if(!a)return!1;let b=a.toLowerCase();return ke.includes(b)}("."+w.extension)?(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)(kt,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onLoadContent:c})}):(0,e.jsx)(kr,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)("div",{className:"h-full flex flex-col",children:(0,e.jsx)(ks,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onFileSaved:g,onDirtyChange:s,onOpenFile:j})})})});function kv(a){let b=a.split("/");return b[b.length-1]||a}function kw(a,b,c){let d=a.findIndex(a=>a.path===b);if(-1===d)return null;let e=[...a];return e[d]=c(e[d]),e}function kx(a,b,c){if("all"===c)return a.map(a=>a.path);let d=a.findIndex(a=>a.path===b);return -1===d?[]:"others"===c?a.filter((a,b)=>b!==d).map(a=>a.path):a.slice(d+1).map(a=>a.path)}let ky={tabs:[],activeIndex:null};function kz(a,b,c){if(b<=0||c<=0)return 0;let d=a+b+8-c;return d>0?-Math.min(d,Math.max(0,a-8)):a<8?8-a:0}let kA=(0,h.memo)(function({tab:a,isActive:b,onActivate:c,onClose:d,onOpenMenu:f}){let g=(0,k.c)("worktree"),i=(0,h.useCallback)(()=>{b||c(a.path)},[b,c,a.path]),j=(0,h.useCallback)(b=>{b.stopPropagation(),d(a.path)},[d,a.path]),l=(0,h.useCallback)(b=>{f(b,a.path)},[f,a.path]),m=(0,h.useCallback)(b=>{1===b.button&&(b.preventDefault(),b.stopPropagation(),d(a.path))},[d,a.path]),n=b?"border-accent-500 text-accent-600 dark:text-accent-400 bg-surface":"border-transparent text-muted-foreground hover:text-foreground";return(0,e.jsxs)("div",{"data-testid":`file-tab-${a.path}`,"data-active":b,onClick:i,onAuxClick:m,onContextMenu:l,className:`flex items-center gap-1 px-3 py-2 text-sm font-medium border-b-2 cursor-pointer flex-shrink-0 ${n}`,children:[(0,e.jsx)("span",{className:"truncate max-w-[120px]",title:a.path,children:a.name}),a.isDirty&&(0,e.jsx)("span",{"data-testid":`file-tab-dirty-${a.path}`,className:"w-2 h-2 rounded-full bg-warning flex-shrink-0",title:g("fileTabs.unsavedChanges")}),(0,e.jsx)("button",{type:"button",onClick:j,className:"ml-1 p-0.5 rounded-sm hover:bg-muted transition-colors","aria-label":g("fileTabs.closeTab",{name:a.name}),children:(0,e.jsx)(a$.A,{className:"w-3 h-3"})})]})}),kB=(0,h.memo)(function({tabs:a,activeIndex:b,worktreeId:c,onClose:d,onActivate:f,onLoadContent:g,onLoadError:i,onSetLoading:j,onFileSaved:m,onDirtyChange:n,onMoveToFront:o,onOpenFile:p}){let q=(0,k.c)("worktree"),[r,s]=(0,h.useState)(!1),t=(0,h.useRef)(null),u=(0,h.useRef)(null),v=(0,h.useRef)({x:0,y:0}),[w,x]=(0,h.useState)({x:0,y:0}),{menuState:y,openMenu:z,openMenuAt:A,closeMenu:B}=f8(),[C,D]=(0,h.useState)(null),E=null!==b&&b>=0&&b<a.length?a[b]:null,F=a.length>5?a.slice(0,5):a,G=a.length>5?a.slice(5):[];(0,h.useEffect)(()=>{if(!r)return;let a=a=>{t.current&&!t.current.contains(a.target)&&s(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[r]),(0,h.useLayoutEffect)(()=>{let a=a=>{v.current=a,x(b=>b.x===a.x&&b.y===a.y?b:a)};if(!r)return void a({x:0,y:0});let b=u.current;if(!b)return;let c=b.getBoundingClientRect();a({x:kz(c.left-v.current.x,c.width,window.innerWidth),y:kz(c.top-v.current.y,c.height,window.innerHeight)})},[r]);let H=(0,h.useCallback)(a=>{s(!1),o?.(a)},[o]),I=(0,h.useCallback)(()=>{s(a=>!a)},[]),J=(0,h.useCallback)(a=>{for(let b=a.length-1;b>=0;b--)d(a[b])},[d]),K=(0,h.useCallback)((b,c)=>{let d=kx(a,c,b);if(0===d.length)return;let e=new Set(d);if(a.some(a=>a.isDirty&&e.has(a.path)))return void D({mode:b,anchorPath:c});J(d)},[a,J]),L=y.targetPath,M=(0,h.useMemo)(()=>L?[{id:"close-all-tabs",label:q("fileTabs.closeAll"),icon:(0,e.jsx)(j8,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>K("all",L),disabled:0===a.length},{id:"close-other-tabs",label:q("fileTabs.closeOthers"),icon:(0,e.jsx)(j9,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>K("others",L),disabled:0===kx(a,L,"others").length},{id:"close-tabs-to-right",label:q("fileTabs.closeToRight"),icon:(0,e.jsx)(ka,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>K("right",L),disabled:0===kx(a,L,"right").length}]:[],[L,a,K,q]),N=(0,h.useCallback)((a,b)=>{z(a,b,"file")},[z]),O=E?.path??a[0]?.path??null,P=(0,h.useCallback)(a=>{if(!O)return;let b=a.currentTarget.getBoundingClientRect();A({x:b.left,y:b.bottom},O,"file")},[O,A]),Q=C?kx(a,C.anchorPath,C.mode):[],R=Q.filter(b=>a.find(a=>a.path===b)?.isDirty),S=(0,h.useCallback)(()=>D(null),[]);return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex border-b border-border bg-surface dark:bg-surface-2 min-w-0",children:[(0,e.jsx)("div",{className:"flex min-w-0 overflow-hidden flex-1",children:F.map((a,c)=>(0,e.jsx)(kA,{tab:a,isActive:c===b,onActivate:f,onClose:d,onOpenMenu:N},a.path))}),G.length>0&&(0,e.jsxs)("div",{className:"relative flex-shrink-0",ref:t,children:[(0,e.jsxs)("button",{type:"button","data-testid":"tab-dropdown-button",onClick:I,className:"flex items-center gap-0.5 px-2 py-2 text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-muted border-b-2 border-transparent transition-colors",children:[(0,e.jsx)(X.A,{className:`w-3 h-3 transition-transform ${r?"rotate-180":""}`}),(0,e.jsxs)("span",{children:["+",G.length]})]}),r&&(0,e.jsx)("div",{ref:u,"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!==w.x||0!==w.y?{transform:`translate(${w.x}px, ${w.y}px)`}:void 0,children:G.map(a=>(0,e.jsxs)("button",{type:"button","data-testid":`tab-dropdown-item-${a.path}`,onClick:()=>H(a.path),className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-muted truncate",title:a.path,children:[a.name,a.isDirty&&(0,e.jsx)("span",{className:"ml-1 w-2 h-2 inline-block rounded-full bg-warning"})]},a.path))})]}),a.length>0&&(0,e.jsx)("button",{type:"button","data-testid":"tab-actions-button",onClick:P,"aria-haspopup":"menu","aria-expanded":y.isOpen,"aria-label":q("fileTabs.tabActions"),title:q("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,e.jsx)(l.A,{className:"w-4 h-4"})})]}),(0,e.jsx)(gg,{isOpen:y.isOpen,position:y.position,targetPath:y.targetPath,targetType:y.targetType,onClose:B,items:M,ariaLabel:q("fileTabs.tabActions")}),(0,e.jsxs)(bC.a,{isOpen:null!==C,onClose:S,title:q("fileTabs.confirmCloseTitle"),size:"sm",children:[(0,e.jsx)("p",{"data-testid":"file-tabs-close-confirm-body",className:"text-sm text-foreground",children:q("fileTabs.confirmCloseBody",{count:R.length})}),(0,e.jsx)("ul",{className:"mt-2 max-h-32 overflow-y-auto text-sm text-muted-foreground",children:R.map(a=>(0,e.jsx)("li",{className:"truncate",title:a,children:a},a))}),(0,e.jsxs)("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:[(0,e.jsx)(bs.$,{variant:"ghost",size:"sm","data-testid":"file-tabs-close-cancel",onClick:S,children:q("fileTabs.confirmCancel")}),(0,e.jsx)(bs.$,{variant:"secondary",size:"sm","data-testid":"file-tabs-close-keep-unsaved",onClick:()=>{let a=new Set(R);J(Q.filter(b=>!a.has(b))),D(null)},children:q("fileTabs.confirmKeepUnsaved")}),(0,e.jsx)(bs.$,{variant:"danger",size:"sm","data-testid":"file-tabs-close-discard",onClick:()=>{J(Q),D(null)},children:q("fileTabs.confirmDiscard")})]})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:E&&(0,e.jsx)(ku,{tab:E,worktreeId:c,onLoadContent:g,onLoadError:i,onSetLoading:j,onFileSaved:m,onDirtyChange:n,onOpenFile:p},E.path)})]})}),kC=(0,h.memo)(function({line:a}){let b="whitespace-pre font-mono text-xs leading-5";return a.startsWith("+")&&!a.startsWith("+++")?b+=" text-success-foreground bg-success-subtle":a.startsWith("-")&&!a.startsWith("---")?b+=" text-danger-foreground bg-danger-subtle":a.startsWith("@@")?b+=" text-info bg-info/10":a.startsWith("diff --git")||a.startsWith("index ")||a.startsWith("---")||a.startsWith("+++")?b+=" text-muted-foreground":b+=" text-foreground",(0,e.jsx)("div",{className:b,children:a})}),kD=(0,h.memo)(function({diff:a,filePath:b,onClose:c}){let d=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"h-full flex flex-col bg-surface",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-muted shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-accent-600 dark:text-accent-400 shrink-0",children:d("diffViewer.badge")}),(0,e.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:b})]}),(0,e.jsx)("button",{type:"button",onClick:c,className:"p-1 text-muted-foreground hover:text-foreground rounded shrink-0","aria-label":d("diffViewer.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto p-2",children:(0,e.jsx)("pre",{className:"text-xs",children:(0,e.jsx)("code",{children:a.split("\n").map((a,b)=>(0,e.jsx)(kC,{line:a},b))})})})]})}),kE="worktree-file-panel",kF=(0,h.createContext)({tabCount:0,hasDiff:!1});function kG(){let[a,b]=(0,h.useState)(!1),c=(0,h.useRef)(a);c.current=a;let d=(0,h.useCallback)(a=>{b(a)},[]);return{collapsed:a,toggle:(0,h.useCallback)(()=>{d(!c.current)},[d]),setCollapsed:d}}let kH=(0,h.memo)(function({terminal:a,terminalHeader:b,fileTabs:c,worktreeId:d,onCloseTab:f,onActivateTab:g,onLoadContent:i,onLoadError:j,onSetLoading:k,onFileSaved:l,diffContent:m,diffFilePath:n,onCloseDiff:o,onDirtyChange:p,onMoveToFront:q,onOpenFile:r}){let s=(0,h.useRef)(null),[t,u]=(0,h.useState)(50),{collapsed:v}=kG(),w=(0,h.useCallback)(a=>{let b=s.current;if(!b)return;let c=b.offsetWidth;if(0===c)return;let d=a/c*100;u(a=>Math.min(80,Math.max(20,a+d)))},[]),x=(0,h.useMemo)(()=>({width:`${t}%`}),[t]),y=(0,h.useMemo)(()=>({width:`${100-t}%`}),[t]),z=(0,h.useMemo)(()=>({tabCount:c.tabs.length,hasDiff:!!(m&&n)}),[c.tabs.length,m,n]),A=(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[b,(0,e.jsx)("div",{className:"flex-1 min-h-0",children:a})]});return c.tabs.length>0||m&&n?v?(0,e.jsx)(kF.Provider,{value:z,children:(0,e.jsx)("div",{ref:s,className:"flex h-full min-h-0",children:(0,e.jsx)("div",{"data-testid":"terminal-pane",style:{width:"100%"},className:"flex-shrink-0 overflow-hidden",children:A})})}):(0,e.jsx)(kF.Provider,{value:z,children:(0,e.jsxs)("div",{ref:s,className:"flex h-full min-h-0",children:[(0,e.jsx)("div",{"data-testid":"terminal-pane",style:x,className:"flex-shrink-0 overflow-hidden",children:A}),(0,e.jsx)(f_,{onResize:w,orientation:"horizontal",ariaValueNow:t}),(0,e.jsx)("div",{id:kE,"data-testid":"file-panel-pane",style:y,className:"flex-grow overflow-hidden flex",children:(0,e.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:m&&n&&o?(0,e.jsx)(kD,{diff:m,filePath:n,onClose:o}):(0,e.jsx)(kB,{tabs:c.tabs,activeIndex:c.activeIndex,worktreeId:d,onClose:f,onActivate:g,onLoadContent:i,onLoadError:j,onSetLoading:k,onFileSaved:l,onDirtyChange:p,onMoveToFront:q,onOpenFile:r})})})]})}):(0,e.jsx)(kF.Provider,{value:z,children:(0,e.jsx)("div",{className:"h-full",children:A})})});var kI=c(51881);let kJ=(0,y.A)("align-horizontal-distribute-center",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]]),kK=(0,y.A)("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),kL=[.5,.5],kM={splits:[{cliToolId:"claude",instanceId:"claude"}],widths:[1]};$.XH;function kN(a){return"number"==typeof a&&Number.isFinite(a)&&a>0}function kO(a){return void 0===a||!!Array.isArray(a)&&2===a.length&&a.every(kN)}function kP(a,b){let c=a+b;if(!Number.isFinite(c)||c<=0)return[1,1];let d=Math.min(a,b);return!Number.isFinite(d)||d<=0?[1,1]:[a/d,b/d]}function kQ(a){let b=a.reduce((a,b)=>a+b,0);return b>0?a.map(a=>a/b):a.map(()=>1/a.length)}function kR(a){if(4===a.splits.length)return kO(a.rowHeights)&&void 0!==a.rowHeights?a:{...a,rowHeights:[...kL]};if(void 0===a.rowHeights)return a;let{rowHeights:b,...c}=a;return c}let kS=(0,h.memo)(function({worktreeId:a,instances:b,rosterReady:c=!0,renderPane:d,onFocusedSplitChange:f,showToast:g,onActiveInstanceChange:j,headerInstanceSelection:l}){let{splits:m,widths:n,rowHeights:o,setRowHeights:p,addSplit:q,removeSplit:r,setSplitInstance:s,setSplitWidth:t,resetWidths:u,availableInstanceIds:v,focusedSplitIndex:w,setFocusedSplitIndex:x,maximizedIndex:y,toggleMaximize:z}=function(a,b,c=!0){let[d,e]=(0,h.useState)(()=>(function(a,b,c){let d=function(a,b){let c=b[0];return c?{splits:[{cliToolId:c.cliTool,instanceId:c.id}],widths:[1]}:{splits:kM.splits.map(a=>({...a})),widths:[...kM.widths]}}(0,b);return c?function(a,b){let c;if(0===b.length)return a;let d=new Map(b.map(a=>[a.id,a.cliTool])),e=new Set,f=Math.min(Math.max(a.splits.length,1),b.length,4),g=[];for(let b of a.splits){if(g.length>=f)break;let a=d.get(b.instanceId);a&&!e.has(b.instanceId)&&(e.add(b.instanceId),g.push({cliToolId:a,instanceId:b.instanceId}))}for(let a of b){if(g.length>=f)break;e.has(a.id)||(e.add(a.id),g.push({cliToolId:a.cliTool,instanceId:a.id}))}return(0===g.length&&g.push({cliToolId:b[0].cliTool,instanceId:b[0].id}),g.length===a.splits.length&&g.every((b,c)=>b.instanceId===a.splits[c].instanceId&&b.cliToolId===a.splits[c].cliToolId))?a:(c=g.length===a.widths.length?kQ(a.widths):g.length<a.widths.length?kQ(a.widths.slice(0,g.length)):Array.from({length:g.length},()=>1/g.length),kR({...a,splits:g,widths:c}))}(d,b):d})(0,b,c)),[f,g]=(0,h.useState)(0),[i,j]=(0,h.useState)(null),k=(0,h.useRef)(d);k.current=d;let l=(0,h.useRef)(b);l.current=b,(0,h.useRef)(c).current=c,(0,h.useRef)(a),(0,h.useMemo)(()=>b.map(a=>`${a.id}:${a.cliTool}`).join("|"),[b]),(0,h.useRef)(a);let m=(0,h.useCallback)(()=>{j(null),e(a=>{if(a.splits.length>=4)return a;let b=new Set(a.splits.map(a=>a.instanceId)),c=function(a,b){for(let c of a)if(!b.has(c.id))return c;return null}(l.current,b);if(!c)return a;let d=[...a.splits,{cliToolId:c.cliTool,instanceId:c.id}];if(4===d.length)return kR({...a,splits:d,widths:Array.from({length:4},()=>.25)});let e=a.widths.length-1,f=a.widths[e]/2,g=[...a.widths];return g[e]=f,g.push(f),kR({...a,splits:d,widths:g})})},[]),n=(0,h.useCallback)(()=>{j(null),e(a=>{if(a.splits.length<=1)return a;let b=a.splits.slice(0,-1),c=kQ(a.widths.slice(0,-1));return kR({...a,splits:b,widths:c})})},[]),o=(0,h.useCallback)((a,b)=>{let c=k.current,d=l.current;if(a<0||a>=c.splits.length)return!1;let f=d.find(a=>a.id===b);if(!f||c.splits[a].instanceId===b)return!1;for(let d=0;d<c.splits.length;d++)if(d!==a&&c.splits[d].instanceId===b)return!1;return e(c=>{if(a<0||a>=c.splits.length||c.splits[a].instanceId===b)return c;for(let d=0;d<c.splits.length;d++)if(d!==a&&c.splits[d].instanceId===b)return c;let d=c.splits.map((c,d)=>d===a?{cliToolId:f.cliTool,instanceId:b}:c);return{...c,splits:d}}),!0},[]),p=(0,h.useCallback)(a=>{e(b=>a.length!==b.widths.length||!function(a){if(!Array.isArray(a))return!1;for(let b of a)if("number"!=typeof b||!Number.isFinite(b)||b<=0)return!1;return!0}(a)?b:{...b,widths:[...a]})},[]),q=(0,h.useCallback)(()=>{j(null),e(a=>{let b=a.splits.length;if(0===b)return a;let c=Array.from({length:b},()=>1/b);return 4===b?{...a,widths:c,rowHeights:[...kL]}:kR({...a,widths:c})})},[]),r=(0,h.useCallback)(a=>{e(b=>4!==b.splits.length?b:Array.isArray(a)&&2===a.length&&kO(a)?{...b,rowHeights:[...a]}:b)},[]),s=(0,h.useCallback)(a=>{let c=new Set;for(let b=0;b<d.splits.length;b++)b!==a&&c.add(d.splits[b].instanceId);return b.filter(a=>!c.has(a.id)).map(a=>a.id)},[d.splits,b]),t=(0,h.useCallback)(a=>{g(a)},[]),u=(0,h.useMemo)(()=>{var a;return(a=d.rowHeights)&&kO(a)?[...a]:[...kL]},[d.rowHeights]),v=(0,h.useCallback)(a=>{a<0||a>=k.current.splits.length||j(b=>b===a?null:a)},[]);return{splits:d.splits,widths:d.widths,rowHeights:u,setRowHeights:r,addSplit:m,removeSplit:n,setSplitInstance:o,setSplitWidth:p,resetWidths:q,availableInstanceIds:s,focusedSplitIndex:f,setFocusedSplitIndex:t,maximizedIndex:i,toggleMaximize:v}}(a,b,c),A=(0,h.useMemo)(()=>{let a=new Map;for(let c of b)a.set(c.id,c);return a},[b]),B=(0,k.c)("worktree"),{visible:C,toggle:D,setWidth:E}=fA(),{collapsed:F,toggle:G}=kG(),H=!F,I=(0,h.useRef)(null),[J,K]=(0,h.useState)(!1),L=(0,h.useRef)(m.length),[M,N]=(0,h.useState)(null);(0,h.useEffect)(()=>{m.length>L.current&&N(m.length-1),L.current=m.length},[m.length]),(0,h.useEffect)(()=>{f?.(w)},[w,f]);let O=(0,h.useRef)(0),P=(0,h.useRef)(m);P.current=m,(0,h.useEffect)(()=>{if(!l||l.token===O.current)return;O.current=l.token;let{instanceId:a}=l,b=P.current.findIndex(b=>b.instanceId===a);if(0!==b){if(b>0)return void x(b);s(0,a)&&x(0)}},[l,s,x]),(0,h.useEffect)(()=>{if(null===M)return;let a=I.current;if(!a)return;let b=a.querySelector(`[data-split-index="${M}"]`);if(!b)return;let c=b.querySelector("textarea");c?.focus(),x(M),N(null)},[M,x]);let Q=(0,h.useCallback)((a,b)=>{let c=I.current;if(!c)return;let d=c.offsetWidth;if(0===d)return;let e=n.reduce((a,b)=>a+b,0),f=b/d*e,g=[...n],h=g[a]+f,i=g[a+1]-f,j=.05*e;h<j||i<j||(g[a]=h,g[a+1]=i,t(g))},[n,t]),R=kP(n[0]??1,n[1]??1),S=kP(o[0]??1,o[1]??1),T=(0,h.useCallback)((a,b)=>{let c=I.current;if(!c)return;let d=c.offsetWidth;if(0===d)return;let e=n[0]+n[1];if(!(e>0))return;let f=b/d*e,g=n[0]+f,h=n[1]-f,i=.05*e;g<i||h<i||t([g,h,g,h])},[n,t]),U=(0,h.useCallback)((a,b)=>{let c=I.current;if(!c)return;let d=c.offsetHeight;if(0===d)return;let e=o[0]+o[1];if(!(e>0))return;let f=b/d*e,g=o[0]+f,h=o[1]-f,i=.05*e;g<i||h<i||p([g,h])},[o,p]),V=(0,h.useCallback)(()=>K(!0),[]),W=(0,h.useCallback)(()=>K(!1),[]),X=(0,h.useCallback)(()=>{u(),E(40)},[u,E]),_=m.length<4&&!J,aa=m.length>1&&!J,ac=m.length>1||C,ad=null!==y,ae=m.length>1,af=4===m.length,ag=(0,h.useCallback)(()=>{z(y??w)},[z,y,w]),ah=B(ad?"terminal.restoreSplits":"terminal.maximizeFocusedSplit"),ai=`${ah} — ${B("terminal.maximizeShortcutHint")}`,{tabCount:aj,hasDiff:ak}=(0,h.useContext)(kF),al=0===aj&&!ak,am=`${B(C?"terminal.hideHistory":"terminal.showHistory")} — ${B("terminal.historyAllSplitsHint")}`,an=B(al?"terminal.filesEmptyHint":H?"terminal.hideFiles":"terminal.showFiles"),ao=(0,h.useMemo)(()=>m.map((a,b)=>fB(b)).join(" "),[m]),ap=(0,h.useMemo)(()=>m.map((a,b)=>()=>x(b)),[m,x]),aq=(0,h.useMemo)(()=>m.map((a,b)=>a=>s(b,a)),[m,s]),ar=(0,h.useMemo)(()=>m.map((a,b)=>()=>z(b)),[m,z]),as=(0,h.useMemo)(()=>m.map((a,b)=>a=>{let c=(0,$.sw)(A.get(a)??{cliTool:"claude",alias:a});if(m[b]?.instanceId===a)return;let d=m.findIndex((c,d)=>d!==b&&c.instanceId===a);if(-1!==d)return void g?.(`${c} is already in use by split ${d+1}`,"warning");s(b,a)&&(j?.(a),g?.(`Moved ${c} to Split ${b+1}`,"success"))}),[m,s,g,j,A]);return(0,e.jsxs)("div",{role:"group","aria-label":"Terminal splits","data-testid":"terminal-split-container",className:"flex flex-col h-full min-h-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-surface border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{"data-testid":"split-count-label",className:"text-xs text-muted-foreground tabular-nums mr-1 truncate",children:ad?B("terminal.maximizedStatus",{split:(y??0)+1}):`${m.length} / 4 splits`}),(0,e.jsx)(ab.m_,{content:B("terminal.addSplit"),placement:"bottom",children:(0,e.jsx)("button",{type:"button",onClick:q,disabled:!_,"aria-disabled":!_,"aria-label":B("terminal.addSplit"),"data-testid":"add-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(hr.A,{className:"w-4 h-4","aria-hidden":"true"})})}),(0,e.jsx)(ab.m_,{content:B("terminal.removeSplit"),placement:"bottom",children:(0,e.jsx)("button",{type:"button",onClick:r,disabled:!aa,"aria-disabled":!aa,"aria-label":B("terminal.removeSplit"),"data-testid":"remove-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(kI.A,{className:"w-4 h-4","aria-hidden":"true"})})}),(0,e.jsx)(ab.m_,{content:B("terminal.equalizeWidthsHint"),placement:"bottom",children:(0,e.jsx)("button",{type:"button",onClick:X,disabled:!ac,"aria-disabled":!ac,"aria-label":B("terminal.equalizeWidthsHint"),"data-testid":"equalize-split-widths",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(kJ,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})})}),(0,e.jsx)(ab.m_,{content:ai,placement:"bottom",children:(0,e.jsx)("button",{type:"button",onClick:ag,disabled:!ae,"aria-disabled":!ae,"aria-pressed":ad,"aria-label":ah,"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:ad?(0,e.jsx)(Y,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}):(0,e.jsx)(Z,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})})}),(0,e.jsx)("div",{className:"ml-auto h-4 w-px bg-border","aria-hidden":"true"}),(0,e.jsx)(ab.m_,{content:am,placement:"bottom",className:"flex-shrink-0",children:(0,e.jsxs)("button",{type:"button",onClick:D,"aria-pressed":C,"aria-expanded":C,"aria-controls":ao,"aria-label":B(C?"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 ${C?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[(0,e.jsx)(c1,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:B("terminal.historyLabel")})]})}),(0,e.jsx)(ab.m_,{content:an,placement:"bottom",className:"flex-shrink-0",children:(0,e.jsxs)("button",{type:"button",onClick:G,disabled:al,"aria-disabled":al,"aria-pressed":H,"aria-expanded":H,"aria-controls":kE,"aria-label":B(H?"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 ${H?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[(0,e.jsx)(kK,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:B("terminal.filesLabel")}),aj>0&&(0,e.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:aj})]})})]}),(0,e.jsxs)("div",{ref:I,"data-testid":"terminal-split-layout","data-layout":af?"grid":"row",className:af?"grid flex-1 min-h-0 w-full overflow-y-auto":"flex flex-1 min-h-0 w-full",style:af?{gridTemplateColumns:ad?"1fr":`${R[0]}fr 4px ${R[1]}fr`,gridTemplateRows:ad?"1fr":`minmax(280px, ${S[0]}fr) 4px minmax(280px, ${S[1]}fr)`}:void 0,children:[m.map((a,b)=>{let c=b===m.length-1,f=null!==y&&y!==b,g=y===b;return(0,e.jsxs)(i().Fragment,{children:[(0,e.jsx)("div",{"data-testid":`split-wrapper-${b}`,"data-hidden":f?"true":void 0,style:af?{gridColumn:g||b%2==0?1:3,gridRow:g||b<2?1:3,minWidth:0,minHeight:0,...f?{display:"none"}:null}:{flexGrow:g?1:n[b]??1,flexShrink:1,flexBasis:0,minWidth:0,...f?{display:"none"}:null},className:"h-full",children:d({splitIndex:b,cliToolId:a.cliToolId,instanceId:a.instanceId,instance:A.get(a.instanceId),availableInstances:v(b).map(a=>A.get(a)).filter(a=>void 0!==a),onInstanceChange:aq[b],onFocus:ap[b],isFocused:w===b,onDropInstance:as[b],isMaximized:g,onToggleMaximize:ar[b]})}),af||c?null:(0,e.jsx)(kT,{resizerIdx:b,hidden:null!==y,ariaValueNow:n.length?n[b]/n.reduce((a,b)=>a+b,0)*100:50,onResize:Q,onStart:V,onEnd:W,onDoubleClick:u})]},`split-${b}`)}),af?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(kT,{resizerIdx:0,testId:"split-grid-column-resizer",gridArea:{gridColumn:2,gridRow:"1 / span 3"},hidden:ad,ariaValueNow:n[0]/(n[0]+n[1])*100,onResize:T,onStart:V,onEnd:W,onDoubleClick:u}),(0,e.jsx)(kT,{resizerIdx:0,testId:"split-grid-row-resizer",orientation:"vertical",gridArea:{gridColumn:"1 / span 3",gridRow:2},hidden:ad,ariaValueNow:o[0]/(o[0]+o[1])*100,onResize:U,onStart:V,onEnd:W,onDoubleClick:u})]}):null]})]})});function kT({resizerIdx:a,ariaValueNow:b,onResize:c,onStart:d,onEnd:f,onDoubleClick:g,hidden:i=!1,orientation:j="horizontal",testId:k,gridArea:l}){let m=(0,h.useCallback)(b=>c(a,b),[a,c]);return(0,e.jsx)("div",{"data-testid":k??`split-resizer-${a}`,style:{...l,...i?{display:"none"}:null},onMouseDownCapture:d,onTouchStartCapture:d,onMouseUpCapture:f,onTouchEndCapture:f,children:(0,e.jsx)(f_,{onResize:m,orientation:j,ariaValueNow:b,onDoubleClick:g})})}function kU(a){if(!a)return null;let b=a.decisionId;return"string"==typeof b&&""!==b?b:null}let kV=`
42
42
  px-6 py-2 rounded-lg font-medium transition-all
43
43
  disabled:opacity-50 disabled:cursor-not-allowed
44
44
  focus:outline-none focus:ring-2 focus:ring-offset-2