commandmate 0.21.3 → 0.21.4

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 (159) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +129 -129
  3. package/.next/app-path-routes-manifest.json +25 -25
  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/app/update/route_client-reference-manifest.js +1 -1
  9. package/.next/server/app/api/app/update-check/route.js +1 -1
  10. package/.next/server/app/api/app/update-check/route_client-reference-manifest.js +1 -1
  11. package/.next/server/app/api/assistant/conversation/route_client-reference-manifest.js +1 -1
  12. package/.next/server/app/api/assistant/current-output/route_client-reference-manifest.js +1 -1
  13. package/.next/server/app/api/assistant/messages/route_client-reference-manifest.js +1 -1
  14. package/.next/server/app/api/assistant/session/route_client-reference-manifest.js +1 -1
  15. package/.next/server/app/api/assistant/start/route_client-reference-manifest.js +1 -1
  16. package/.next/server/app/api/assistant/terminal/route_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/assistant/tools/route_client-reference-manifest.js +1 -1
  18. package/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  19. package/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  21. package/.next/server/app/api/daily-summary/route_client-reference-manifest.js +1 -1
  22. package/.next/server/app/api/daily-summary/status/route_client-reference-manifest.js +1 -1
  23. package/.next/server/app/api/external-apps/[id]/health/route_client-reference-manifest.js +1 -1
  24. package/.next/server/app/api/external-apps/[id]/route_client-reference-manifest.js +1 -1
  25. package/.next/server/app/api/external-apps/route_client-reference-manifest.js +1 -1
  26. package/.next/server/app/api/fs/browse/route_client-reference-manifest.js +1 -1
  27. package/.next/server/app/api/fs/recent-paths/route_client-reference-manifest.js +1 -1
  28. package/.next/server/app/api/hooks/agent-event/route_client-reference-manifest.js +1 -1
  29. package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
  30. package/.next/server/app/api/metrics/vibe/route_client-reference-manifest.js +1 -1
  31. package/.next/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
  32. package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
  33. package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
  34. package/.next/server/app/api/repositories/[id]/route_client-reference-manifest.js +1 -1
  35. package/.next/server/app/api/repositories/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  36. package/.next/server/app/api/repositories/[id]/todos/route_client-reference-manifest.js +1 -1
  37. package/.next/server/app/api/repositories/clone/[jobId]/route_client-reference-manifest.js +1 -1
  38. package/.next/server/app/api/repositories/clone/route_client-reference-manifest.js +1 -1
  39. package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
  40. package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
  41. package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
  42. package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +1 -1
  43. package/.next/server/app/api/repositories/sync/route_client-reference-manifest.js +1 -1
  44. package/.next/server/app/api/repositories/validate-path/route_client-reference-manifest.js +1 -1
  45. package/.next/server/app/api/sidebar/group-order/route_client-reference-manifest.js +1 -1
  46. package/.next/server/app/api/skills/[id]/route_client-reference-manifest.js +1 -1
  47. package/.next/server/app/api/skills/installations/route_client-reference-manifest.js +1 -1
  48. package/.next/server/app/api/skills/operations/route_client-reference-manifest.js +1 -1
  49. package/.next/server/app/api/skills/reindex/route_client-reference-manifest.js +1 -1
  50. package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
  51. package/.next/server/app/api/slash-commands/route_client-reference-manifest.js +1 -1
  52. package/.next/server/app/api/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
  53. package/.next/server/app/api/tasks/[taskId]/route_client-reference-manifest.js +1 -1
  54. package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
  55. package/.next/server/app/api/templates/route_client-reference-manifest.js +1 -1
  56. package/.next/server/app/api/todos/route_client-reference-manifest.js +1 -1
  57. package/.next/server/app/api/verification/runs/[runId]/route_client-reference-manifest.js +1 -1
  58. package/.next/server/app/api/verification/runs/route_client-reference-manifest.js +1 -1
  59. package/.next/server/app/api/worktrees/[id]/auto-yes/route_client-reference-manifest.js +1 -1
  60. package/.next/server/app/api/worktrees/[id]/capture/route_client-reference-manifest.js +1 -1
  61. package/.next/server/app/api/worktrees/[id]/cli-tool/route_client-reference-manifest.js +1 -1
  62. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route_client-reference-manifest.js +1 -1
  63. package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
  64. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route_client-reference-manifest.js +1 -1
  65. package/.next/server/app/api/worktrees/[id]/execution-logs/route_client-reference-manifest.js +1 -1
  66. package/.next/server/app/api/worktrees/[id]/files/[...path]/route_client-reference-manifest.js +1 -1
  67. package/.next/server/app/api/worktrees/[id]/git/branch/create/route_client-reference-manifest.js +1 -1
  68. package/.next/server/app/api/worktrees/[id]/git/branch/delete/route_client-reference-manifest.js +1 -1
  69. package/.next/server/app/api/worktrees/[id]/git/branches/route_client-reference-manifest.js +1 -1
  70. package/.next/server/app/api/worktrees/[id]/git/checkout/route_client-reference-manifest.js +1 -1
  71. package/.next/server/app/api/worktrees/[id]/git/commit/route_client-reference-manifest.js +1 -1
  72. package/.next/server/app/api/worktrees/[id]/git/diff/route_client-reference-manifest.js +1 -1
  73. package/.next/server/app/api/worktrees/[id]/git/fetch/route_client-reference-manifest.js +1 -1
  74. package/.next/server/app/api/worktrees/[id]/git/log/route_client-reference-manifest.js +1 -1
  75. package/.next/server/app/api/worktrees/[id]/git/pull/route_client-reference-manifest.js +1 -1
  76. package/.next/server/app/api/worktrees/[id]/git/push/route_client-reference-manifest.js +1 -1
  77. package/.next/server/app/api/worktrees/[id]/git/reset/route_client-reference-manifest.js +1 -1
  78. package/.next/server/app/api/worktrees/[id]/git/revert/route_client-reference-manifest.js +1 -1
  79. package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route_client-reference-manifest.js +1 -1
  80. package/.next/server/app/api/worktrees/[id]/git/stage/route_client-reference-manifest.js +1 -1
  81. package/.next/server/app/api/worktrees/[id]/git/staged/route_client-reference-manifest.js +1 -1
  82. package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route_client-reference-manifest.js +1 -1
  83. package/.next/server/app/api/worktrees/[id]/git/stash/apply/route_client-reference-manifest.js +1 -1
  84. package/.next/server/app/api/worktrees/[id]/git/stash/pop/route_client-reference-manifest.js +1 -1
  85. package/.next/server/app/api/worktrees/[id]/git/stash/push/route_client-reference-manifest.js +1 -1
  86. package/.next/server/app/api/worktrees/[id]/git/stash/route_client-reference-manifest.js +1 -1
  87. package/.next/server/app/api/worktrees/[id]/git/status/route_client-reference-manifest.js +1 -1
  88. package/.next/server/app/api/worktrees/[id]/git/unstage/route_client-reference-manifest.js +1 -1
  89. package/.next/server/app/api/worktrees/[id]/git/working-diff/route_client-reference-manifest.js +1 -1
  90. package/.next/server/app/api/worktrees/[id]/interrupt/route_client-reference-manifest.js +1 -1
  91. package/.next/server/app/api/worktrees/[id]/kill-session/route_client-reference-manifest.js +1 -1
  92. package/.next/server/app/api/worktrees/[id]/logs/[filename]/route_client-reference-manifest.js +1 -1
  93. package/.next/server/app/api/worktrees/[id]/logs/route_client-reference-manifest.js +1 -1
  94. package/.next/server/app/api/worktrees/[id]/marp-render/route_client-reference-manifest.js +1 -1
  95. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route_client-reference-manifest.js +1 -1
  96. package/.next/server/app/api/worktrees/[id]/memos/route_client-reference-manifest.js +1 -1
  97. package/.next/server/app/api/worktrees/[id]/messages/route_client-reference-manifest.js +1 -1
  98. package/.next/server/app/api/worktrees/[id]/prompt-response/route_client-reference-manifest.js +1 -1
  99. package/.next/server/app/api/worktrees/[id]/respond/route_client-reference-manifest.js +1 -1
  100. package/.next/server/app/api/worktrees/[id]/route_client-reference-manifest.js +1 -1
  101. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route_client-reference-manifest.js +1 -1
  102. package/.next/server/app/api/worktrees/[id]/schedules/active/route_client-reference-manifest.js +1 -1
  103. package/.next/server/app/api/worktrees/[id]/schedules/route_client-reference-manifest.js +1 -1
  104. package/.next/server/app/api/worktrees/[id]/search/route_client-reference-manifest.js +1 -1
  105. package/.next/server/app/api/worktrees/[id]/send/route_client-reference-manifest.js +1 -1
  106. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route_client-reference-manifest.js +1 -1
  107. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route_client-reference-manifest.js +1 -1
  108. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route_client-reference-manifest.js +1 -1
  109. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route_client-reference-manifest.js +1 -1
  110. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route_client-reference-manifest.js +1 -1
  111. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update/route_client-reference-manifest.js +1 -1
  112. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update-plan/route_client-reference-manifest.js +1 -1
  113. package/.next/server/app/api/worktrees/[id]/skills/route_client-reference-manifest.js +1 -1
  114. package/.next/server/app/api/worktrees/[id]/slash-commands/route_client-reference-manifest.js +1 -1
  115. package/.next/server/app/api/worktrees/[id]/special-keys/route_client-reference-manifest.js +1 -1
  116. package/.next/server/app/api/worktrees/[id]/start-polling/route_client-reference-manifest.js +1 -1
  117. package/.next/server/app/api/worktrees/[id]/tasks/route_client-reference-manifest.js +1 -1
  118. package/.next/server/app/api/worktrees/[id]/terminal/route_client-reference-manifest.js +1 -1
  119. package/.next/server/app/api/worktrees/[id]/timers/history/route_client-reference-manifest.js +1 -1
  120. package/.next/server/app/api/worktrees/[id]/timers/route_client-reference-manifest.js +1 -1
  121. package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  122. package/.next/server/app/api/worktrees/[id]/todos/route_client-reference-manifest.js +1 -1
  123. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route_client-reference-manifest.js +1 -1
  124. package/.next/server/app/api/worktrees/[id]/tree/route_client-reference-manifest.js +1 -1
  125. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route_client-reference-manifest.js +1 -1
  126. package/.next/server/app/api/worktrees/[id]/verify/route_client-reference-manifest.js +1 -1
  127. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route_client-reference-manifest.js +1 -1
  128. package/.next/server/app/api/worktrees/[id]/verify/runs/route_client-reference-manifest.js +1 -1
  129. package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
  130. package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
  131. package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  132. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  133. package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
  134. package/.next/server/app/more/page_client-reference-manifest.js +1 -1
  135. package/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  136. package/.next/server/app/page_client-reference-manifest.js +1 -1
  137. package/.next/server/app/proxy/[...path]/route_client-reference-manifest.js +1 -1
  138. package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
  139. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  140. package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  141. package/.next/server/app/skills/[skillId]/page_client-reference-manifest.js +1 -1
  142. package/.next/server/app/skills/installed/page_client-reference-manifest.js +1 -1
  143. package/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  144. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
  145. package/.next/server/app/worktrees/[id]/page.js +2 -2
  146. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
  147. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
  148. package/.next/server/app-paths-manifest.json +25 -25
  149. package/.next/server/chunks/5959.js +1 -1
  150. package/.next/server/chunks/6130.js +1 -1
  151. package/.next/server/middleware-manifest.json +5 -5
  152. package/.next/server/pages/500.html +1 -1
  153. package/.next/server/server-reference-manifest.json +1 -1
  154. package/.next/static/chunks/{6488-9770256ea0450efc.js → 6488-675c07e04e6e5a2e.js} +1 -1
  155. package/.next/static/chunks/app/worktrees/[id]/{page-78962c606869cb6f.js → page-9f78fcce8ee9fe00.js} +1 -1
  156. package/.next/trace +12 -12
  157. package/package.json +1 -1
  158. /package/.next/static/{K-WQBI47y9vO_0p_unBEF → Yr3HhIDgtWJeOPqvqxsug}/_buildManifest.js +0 -0
  159. /package/.next/static/{K-WQBI47y9vO_0p_unBEF → Yr3HhIDgtWJeOPqvqxsug}/_ssgManifest.js +0 -0
@@ -26,12 +26,12 @@ document.addEventListener('click', function(e) {
26
26
  flex items-center gap-2 px-4 py-2 rounded-lg border-2 border-dashed
27
27
  transition-colors focus:outline-none focus:ring-2 focus:ring-ring
28
28
  ${i?"border-border text-muted-foreground cursor-not-allowed opacity-50":"border-border text-muted-foreground hover:border-accent-400 dark:hover:border-accent-500 hover:text-accent-600 dark:hover:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/30"}
29
- `,children:[d?(0,e.jsx)(m.y,{"data-testid":"loading-indicator",size:"md",variant:"accent"}):(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:"M12 4v16m8-8H4"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:g("memoAdd")})]}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:g("memoRemaining",{count:h})})]})});function da({query:a,onQueryChange:b,matchCount:c,currentIndex:d,onNext:f,onPrev:g,onClose:i,onCompositionStart:j,onCompositionEnd:l}){let m=(0,k.c)("schedule"),o=(0,h.useRef)(null),p=(0,h.useCallback)(a=>{"Escape"===a.key?i():"Enter"===a.key&&(a.preventDefault(),f())},[i,f]),q=(0,h.useCallback)(a=>{b(a.target.value)},[b]),r=0===c?"0/0":`${d+1}/${c}`;return(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border border-input rounded",role:"search","aria-label":m("memoSearchLabel"),children:[(0,e.jsx)("input",{ref:o,type:"text",value:a,onChange:q,onKeyDown:p,onCompositionStart:j,onCompositionEnd:l,placeholder:m("memoSearchPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-foreground text-sm outline-none placeholder-muted-foreground","aria-label":m("memoSearchInputLabel"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,e.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"text-muted-foreground text-xs min-w-[3rem] text-right",children:r}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:g,disabled:0===c,"aria-label":m("memoSearchPrev"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▲"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:f,disabled:0===c,"aria-label":m("memoSearchNext"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▼"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:i,"aria-label":m("memoSearchClose"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white min-w-[36px] min-h-[36px] flex items-center justify-center text-base ml-1",children:"✕"})]})}let db=(0,h.memo)(function({worktreeId:a,className:b="",onInsertToMessage:c}){let d=(0,k.c)("schedule"),f=(0,k.c)("common"),g=(0,am.SC)(),[i,j]=(0,h.useState)([]),[l,n]=(0,h.useState)(!0),[o,p]=(0,h.useState)(!1),[q,r]=(0,h.useState)(null),[s,t]=(0,h.useState)(null),[u,v]=(0,h.useState)(!1),w=(0,h.useRef)(null),{query:x,matches:y,currentMatch:z,totalCount:A,setQuery:B,reset:C,navigateNext:D,navigatePrev:E,onCompositionStart:F,onCompositionEnd:G}=function({memos:a}){let[b,c]=(0,h.useState)(""),[d,e]=(0,h.useState)([]),[f,g]=(0,h.useState)(-1),i=(0,h.useRef)(null),j=(0,h.useRef)(""),k=(0,h.useRef)(!1);(0,h.useRef)(0===a.length?"0":a.map(a=>`${a.id}:${a.title.length}:${a.content.length}`).join("|"));let l=(0,h.useRef)(a);l.current=a;let m=d.length,n=(0,h.useCallback)(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),o=(0,h.useCallback)(a=>{let b=function(a,b){if(b.length<2||0===a.length)return[];let c=b.toLowerCase();return a.filter(a=>-1!==a.title.toLowerCase().indexOf(c)||-1!==a.content.toLowerCase().indexOf(c))}(l.current,a);e(b),g(b.length>0?0:-1)},[]),p=(0,h.useCallback)(a=>{n(),j.current=a,k.current||(i.current=setTimeout(()=>{o(a)},300))},[n,o]),q=(0,h.useCallback)(a=>{c(a),p(a)},[p]),r=(0,h.useCallback)(()=>{c(""),j.current="",e([]),g(-1),n()},[n]),s=(0,h.useCallback)(()=>{g(a=>0===m?-1:(a+1)%m)},[m]),t=(0,h.useCallback)(()=>{g(a=>0===m?-1:(a-1+m)%m)},[m]);return{query:b,matches:d,currentMatch:f,totalCount:m,setQuery:q,reset:r,navigateNext:s,navigatePrev:t,onCompositionStart:(0,h.useCallback)(()=>{k.current=!0,n()},[n]),onCompositionEnd:(0,h.useCallback)(()=>{k.current=!1;let a=j.current;a.length>=2&&(n(),i.current=setTimeout(()=>{o(a)},300))},[n,o])}}({memos:i}),H=u&&x.length>0,I=H?y:i,J=(0,h.useCallback)(async()=>{n(!0),r(null);try{let b=await T.$T.getAll(a);j(b.sort((a,b)=>a.position-b.position))}catch(a){r((0,T.hS)(a))}finally{n(!1)}},[a]);(0,h.useEffect)(()=>{J()},[J]);let K=(0,h.useCallback)(async()=>{p(!0),t(null);try{let b=await T.$T.create(a,{title:d("memoDefaultTitle"),content:""});j(a=>[...a,b])}catch(a){t((0,T.hS)(a))}finally{p(!1)}},[a,d]),L=(0,h.useCallback)(async(b,c)=>{await T.$T.update(a,b,c),j(a=>a.map(a=>a.id===b?{...a,...c}:a))},[a]),M=(0,h.useCallback)(async b=>{let c=i.find(a=>a.id===b);if(await g({description:f("confirmDelete",{name:c?.title??""}),variant:"danger"}))try{await T.$T.delete(a,b),j(a=>a.filter(a=>a.id!==b))}catch(a){console.error("Failed to delete memo:",a)}},[a,i,g,f]),N=(0,h.useCallback)(async(b,c)=>{let d=b+c;if(d<0||d>=i.length)return;let e=[...i];[e[b],e[d]]=[e[d],e[b]],j(e);try{await T.$T.reorder(a,e.map(a=>a.id))}catch(a){r((0,T.hS)(a)),await J()}},[i,a,J]),O=(0,h.useCallback)(()=>{J()},[J]),P=(0,h.useCallback)(()=>{v(a=>(a&&C(),!a))},[C]),R=(0,h.useCallback)(()=>{v(!1),C()},[C]);return((0,h.useEffect)(()=>{if(!H||z<0)return;let a=y[z];if(!a)return;let b=w.current?.querySelector(`[data-memo-id="${a.id}"]`);b&&(b.scrollIntoView({block:"nearest"}),b.focus({preventScroll:!0}))},[H,z,y]),l)?(0,e.jsx)("div",{"data-testid":"memo-pane",className:`flex flex-col items-center justify-center h-full p-4 ${b}`,children:(0,e.jsxs)("div",{"data-testid":"memo-loading",className:"flex flex-col items-center gap-3",children:[(0,e.jsx)(m.y,{size:"xl",variant:"accent"}),(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:d("memoLoading")})]})}):q?(0,e.jsx)("div",{"data-testid":"memo-pane",className:`flex flex-col items-center justify-center h-full p-4 ${b}`,children:(0,e.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[(0,e.jsx)("svg",{className:"w-12 h-12 text-danger",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)("span",{className:"text-sm text-danger-foreground",children:q}),(0,e.jsx)("button",{type:"button",onClick:O,"aria-label":f("retry"),className:"px-4 py-2 text-sm font-medium text-white bg-accent-500 rounded-lg hover:bg-accent-600 transition-colors",children:f("retry")})]})}):(0,e.jsxs)("div",{ref:w,"data-testid":"memo-pane",className:`flex flex-col gap-4 p-4 overflow-y-auto ${b}`,children:[(0,e.jsx)("div",{"data-testid":"memo-pane-header",className:"flex items-center gap-2",children:u?(0,e.jsx)("div",{className:"flex-1",children:(0,e.jsx)(da,{query:x,onQueryChange:B,matchCount:A,currentIndex:z,onNext:D,onPrev:E,onClose:R,onCompositionStart:F,onCompositionEnd:G})}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"flex-1"}),(0,e.jsx)("button",{type:"button","data-testid":"memo-search-toggle",onClick:P,"aria-label":d("memoSearchToggle"),className:"p-1.5 text-muted-foreground hover:text-foreground transition-colors rounded",children:(0,e.jsx)(Q.A,{className:"w-4 h-4","aria-hidden":"true"})})]})}),0===i.length&&!H&&!s&&(0,e.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,e.jsx)("p",{children:d("memoEmpty")}),(0,e.jsx)("p",{className:"text-sm",children:d("memoEmptyHint")})]}),H&&0===I.length&&(0,e.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:(0,e.jsx)("p",{children:d("memoNoMatch")})}),I.map((a,b)=>(0,e.jsx)(c8,{memo:a,onUpdate:L,onDelete:M,onInsertToMessage:c,onMoveUp:H?void 0:()=>N(b,-1),onMoveDown:H?void 0:()=>N(b,1),canMoveUp:!H&&b>0,canMoveDown:!H&&b<i.length-1},a.id)),s&&(0,e.jsx)("div",{className:"text-center py-2 text-sm text-danger",children:s}),!H&&(0,e.jsx)(c9,{currentCount:i.length,maxCount:20,onAdd:K,isLoading:o,className:"mt-2"})]})});var dc=c(44872),dd=c(2996),de=c(62484);let df={todo:"border-input text-muted-foreground",doing:"border-warning-border bg-warning-subtle text-warning-foreground",done:"border-success-border bg-success-subtle text-success-foreground"},dg=i().memo(function({worktreeId:a,className:b=""}){let c=(0,k.c)("worktree"),d=(0,k.c)("common"),f=(0,am.SC)(),[g,i]=(0,h.useState)([]),[j,l]=(0,h.useState)(""),[m,n]=(0,h.useState)(!0),[o,p]=(0,h.useState)(!1),[q,r]=(0,h.useState)(null),[s,t]=(0,h.useState)(null),[u,v]=(0,h.useState)(""),[w,x]=(0,h.useState)(""),[y,z]=(0,h.useState)(!1),A=(0,h.useCallback)(a=>{switch(a){case"doing":return c("todo.statusDoing");case"done":return c("todo.statusDone");default:return c("todo.statusTodo")}},[c]),B=(0,h.useCallback)(async()=>{n(!0),r(null);try{let b=await dc.Ar.list(a);i(b)}catch(a){r(a instanceof Error?a.message:c("todo.loadError")),i([])}finally{n(!1)}},[a,c]);(0,h.useEffect)(()=>{B()},[a]);let C=(0,h.useCallback)(async()=>{let b=j.trim();if(b&&!o){p(!0),r(null);try{let c=await dc.Ar.create(a,b);i(a=>[...a,c]),l("")}catch(a){r(a instanceof Error?a.message:c("todo.addError"))}finally{p(!1)}}},[j,o,a,c]),D=(0,h.useCallback)(async b=>{let d=function(a){let b=dc.KG.indexOf(a);return dc.KG[(b+1)%dc.KG.length]}(b.status);i(a=>a.map(a=>a.id===b.id?{...a,status:d,done:"done"===d}:a)),r(null);try{await dc.Ar.update(a,b.id,{status:d})}catch(a){r(a instanceof Error?a.message:c("todo.updateError")),B()}},[a,B,c]),E=(0,h.useCallback)(async b=>{if(await f({description:d("confirmDelete",{name:b.content}),variant:"danger"})){r(null);try{await dc.Ar.remove(a,b.id),i(a=>a.filter(a=>a.id!==b.id))}catch(a){r(a instanceof Error?a.message:c("todo.deleteError"))}}},[a,c,f,d]),F=(0,h.useCallback)(a=>{t(a),v(a.content),x(a.detail),r(null)},[]),G=(0,h.useCallback)(()=>{t(null),z(!1)},[]),H=(0,h.useCallback)(async()=>{if(!s)return;let b=u.trim();if(b&&!y){z(!0),r(null);try{let c=await dc.Ar.update(a,s.id,{content:b,detail:w});i(a=>a.map(a=>a.id===s.id?c:a)),G()}catch(a){r(a instanceof Error?a.message:c("todo.updateError")),z(!1)}}},[s,u,w,y,a,G,c]),I=(0,h.useCallback)(async(b,d)=>{let e=b+d;if(e<0||e>=g.length)return;let f=[...g];[f[b],f[e]]=[f[e],f[b]],i(f),r(null);try{await dc.Ar.reorder(a,f.map(a=>a.id))}catch(a){r(a instanceof Error?a.message:c("todo.reorderError")),B()}},[g,a,B,c]),J=(0,h.useCallback)(a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),C())},[C]),K=(0,h.useMemo)(()=>({todo:g.filter(a=>"todo"===a.status).length,doing:g.filter(a=>"doing"===a.status).length,done:g.filter(a=>"done"===a.status).length}),[g]);return(0,e.jsxs)("div",{"data-testid":"todo-pane",className:`flex flex-col h-full overflow-y-auto p-4 ${b}`.trim(),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,e.jsx)("input",{type:"text",value:j,onChange:a=>l(a.target.value),onKeyDown:J,maxLength:dd.Ll,placeholder:c("todo.addPlaceholder"),"data-testid":"todo-input",className:"flex-1 min-w-0 rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,e.jsx)("button",{type:"button",onClick:C,disabled:o||0===j.trim().length,"data-testid":"todo-add-button",className:"shrink-0 rounded-md bg-accent-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-700 disabled:opacity-50",children:c("todo.add")})]}),(0,e.jsxs)("div",{className:"mb-2 flex justify-end gap-2 text-xs text-muted-foreground",children:[(0,e.jsxs)("span",{"data-testid":"todo-count-todo",children:[A("todo")," ",K.todo]}),(0,e.jsxs)("span",{"data-testid":"todo-count-doing",children:[A("doing")," ",K.doing]}),(0,e.jsxs)("span",{"data-testid":"todo-count-done",children:[A("done")," ",K.done]})]}),q&&(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"todo-error",children:q}),m?(0,e.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"todo-loading",children:c("todo.loading")}):0===g.length?(0,e.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"todo-empty",children:c("todo.empty")}):(0,e.jsx)("ul",{className:"space-y-1","data-testid":"todo-list",children:g.map((a,b)=>(0,e.jsxs)("li",{className:"flex items-center gap-2 rounded-md px-1 py-1 hover:bg-muted group","data-testid":"todo-item",children:[(0,e.jsx)("button",{type:"button",onClick:()=>D(a),"data-testid":"todo-status","data-status":a.status,"aria-label":c("todo.cycleStatus",{status:A(a.status)}),title:c("todo.cycleStatus",{status:A(a.status)}),className:`shrink-0 inline-flex min-h-[44px] items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium sm:min-h-0 ${df[a.status]}`,children:A(a.status)}),(0,e.jsxs)("button",{type:"button",onClick:()=>F(a),"data-testid":"todo-content","aria-label":c("todo.edit"),title:c("todo.edit"),className:"group/content flex min-h-[44px] min-w-0 flex-1 items-center gap-1.5 text-left sm:min-h-0",children:[(0,e.jsx)("span",{className:`min-w-0 break-words text-sm ${"done"===a.status?"line-through text-muted-foreground":"text-foreground group-hover/content:text-accent-700 dark:group-hover/content:text-accent-300"}`,children:a.content}),""!==a.detail.trim()&&(0,e.jsxs)("svg",{"data-testid":"todo-detail-indicator","aria-label":c("todo.hasDetail"),className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("title",{children:c("todo.hasDetail")}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h10"})]})]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,e.jsx)("button",{type:"button",onClick:()=>I(b,-1),disabled:0===b,"aria-label":c("todo.moveUp"),"data-testid":"todo-move-up",className:"p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",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:"M5 15l7-7 7 7"})})}),(0,e.jsx)("button",{type:"button",onClick:()=>I(b,1),disabled:b===g.length-1,"aria-label":c("todo.moveDown"),"data-testid":"todo-move-down",className:"p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",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:"M19 9l-7 7-7-7"})})}),(0,e.jsx)("button",{type:"button",onClick:()=>E(a),"aria-label":c("todo.delete"),"data-testid":"todo-delete",className:"inline-flex min-h-[44px] min-w-[44px] shrink-0 items-center justify-center text-muted-foreground opacity-100 transition-opacity hover:text-danger-foreground sm:min-h-0 sm:min-w-0 sm:opacity-0 sm:group-hover:opacity-100",children:(0,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"})})})]})]},a.id))}),(0,e.jsx)(bc.a,{isOpen:null!==s,onClose:G,title:c("todo.editTitle"),size:"md",children:(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,e.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:c("todo.contentLabel")}),(0,e.jsx)("input",{type:"text",value:u,onChange:a=>v(a.target.value),maxLength:dd.Ll,placeholder:c("todo.contentPlaceholder"),"data-testid":"todo-edit-content",className:"w-full rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,e.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,e.jsxs)("span",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:c("todo.detailLabel")}),""!==w.trim()&&(0,e.jsx)(de.i,{text:w,label:c("todo.copyDetail"),className:"!border-input !bg-surface dark:!bg-surface-2 !text-muted-foreground hover:!bg-muted"})]}),(0,e.jsx)("textarea",{value:w,onChange:a=>x(a.target.value),maxLength:dd.bu,rows:6,placeholder:c("todo.detailPlaceholder"),"data-testid":"todo-edit-detail",className:"w-full resize-y rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:G,"data-testid":"todo-edit-cancel",className:"rounded-md border border-input px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted",children:c("todo.cancel")}),(0,e.jsx)("button",{type:"button",onClick:H,disabled:y||0===u.trim().length,"data-testid":"todo-edit-save",className:"rounded-md bg-accent-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-700 disabled:opacity-50",children:c("todo.save")})]})]})})]})});var dh=c(75234);let di=(0,x.A)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]);var dj=c(44688);function dk({isOpen:a,onClose:b,title:c,children:d,footer:f,showCloseButton:g=!0}){let i=(0,k.c)("common"),[j,l]=(0,h.useState)(null);return a?(0,bG.createPortal)((0,e.jsxs)("div",{"data-testid":"full-screen-modal",role:"dialog","aria-modal":"true",className:"fixed inset-0 flex flex-col bg-surface animate-slide-up",style:{zIndex:aE.M.MODAL,height:j?`${j}px`:"100dvh"},children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsx)("h3",{className:"text-base font-semibold text-foreground truncate pr-2",children:c}),g&&(0,e.jsx)("button",{type:"button",onClick:b,"aria-label":i("close"),"data-testid":"full-screen-modal-close",className:"flex-shrink-0 -mr-1 p-1 text-muted-foreground hover:text-foreground transition-colors",children:(0,e.jsx)(az.A,{className:"w-6 h-6"})})]}),(0,e.jsx)("div",{"data-testid":"full-screen-modal-body",className:"flex-1 min-h-0 overflow-y-auto overscroll-contain px-4 py-4",onFocusCapture:a=>{let b=a.target;b&&"function"==typeof b.scrollIntoView&&window.requestAnimationFrame(()=>{b.scrollIntoView({block:"center",behavior:"smooth"})})},children:d}),f&&(0,e.jsx)("div",{"data-testid":"full-screen-modal-footer",className:"flex-shrink-0 border-t border-border bg-surface px-4 py-3",style:{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom))"},children:f})]}),document.body):null}let dl=["default","acceptEdits","plan","dontAsk","bypassPermissions"],dm=["read-only","workspace-write","danger-full-access"],dn=["allow-all-tools","yolo"],dp=["--dangerously-skip-permissions"],dq=[],dr={claude:"acceptEdits",codex:"workspace-write",gemini:"","vibe-local":"",copilot:"allow-all-tools",antigravity:"--dangerously-skip-permissions"};function ds(a){switch(a){case"codex":return dm;case"copilot":return dn;case"antigravity":return dp;case"claude":return dl;default:return dq}}let dt=/^[\w\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\uF900-\uFAFF\s-]{1,100}$/,du=/^[a-zA-Z0-9][a-zA-Z0-9\-._/:]*$/,dv=new Set(["copilot"]),dw=[{value:"0 */1 * * *",labelKey:"cronPresetHourly"},{value:"0 9 * * *",labelKey:"cronPresetDaily9"},{value:"0 9 * * 1",labelKey:"cronPresetWeeklyMon9"}],dx={name:"",cronExpression:"0 9 * * *",message:"",cliToolId:"claude",enabled:!0,permission:dr.claude??"",model:""},dy="w-full px-3 py-2 text-sm border border-input rounded-md bg-surface dark:bg-surface-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring",dz="block text-xs font-semibold text-foreground mb-1",dA="mt-1 text-xs text-danger-foreground";function dB({onClick:a,label:b,title:c,testId:d}){return(0,e.jsxs)("button",{type:"button","data-testid":d,onClick:a,title:c,className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-info-border text-info-foreground hover:bg-info-subtle transition-colors",children:[(0,e.jsx)(dh.A,{size:14,"aria-hidden":"true"}),b]})}function dC({id:a,title:b,summary:c,icon:d,isOpen:f,onToggle:g,children:h}){let i=`schedule-section-${a}-content`;return(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,e.jsxs)("button",{type:"button","data-testid":`schedule-section-${a}`,"aria-expanded":f,"aria-controls":i,onClick:()=>g(a),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left bg-surface-2 hover:bg-muted transition-colors",children:[(0,e.jsx)("span",{className:"flex-shrink-0 text-accent-600 dark:text-accent-400",children:d}),(0,e.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,e.jsx)("span",{className:"block text-sm font-semibold text-foreground",children:b}),c&&(0,e.jsx)("span",{"data-testid":`schedule-section-${a}-summary`,className:"block truncate text-xs text-muted-foreground",children:c})]}),(0,e.jsx)(bf.A,{className:`flex-shrink-0 w-4 h-4 text-muted-foreground transition-transform ${f?"rotate-180":""}`})]}),f&&(0,e.jsx)("div",{id:i,className:"px-3 py-3 flex flex-col gap-4",children:h})]})}function dD({isOpen:a,worktreeId:b,initialValues:c,originalName:d,onInsertToMessage:f,instances:g,onClose:i,onSaved:j}){let l=(0,k.c)("schedule"),m=(0,ab.a)(),o=(0,h.useMemo)(()=>g&&g.length>0?g:(0,be.lu)([...be.XH]),[g]),[p,q]=(0,h.useState)(dx),[r,s]=(0,h.useState)(""),[t,u]=(0,h.useState)(!1),[v,w]=(0,h.useState)(null),[x,y]=(0,h.useState)(()=>new Set(["basic","advanced","message"])),z=(0,h.useCallback)(a=>{y(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),A=ds(p.cliToolId),C=A.length>0,D="copilot"===p.cliToolId,E=!!d,F=(0,h.useMemo)(()=>{let a=p.name.trim();return a?a.length>100?l("edit.errorNameTooLong",{max:100}):dt.test(a)?null:l("edit.errorNameInvalid"):l("edit.errorNameRequired")},[p.name,l]),G=(0,h.useMemo)(()=>!function(a){if(a.length>100)return!1;let b=a.trim().split(/\s+/);return b.length>=5&&b.length<=6}(p.cronExpression.trim())?l("edit.errorCronInvalid"):null,[p.cronExpression,l]),H=(0,h.useMemo)(()=>p.message.trim()?p.message.length>1e4?l("edit.errorMessageTooLong",{max:1e4}):null:l("edit.errorMessageRequired"),[p.message,l]),I=(0,h.useMemo)(()=>{var a;return D&&p.model.trim()?(a=p.model.trim(),/[\x00-\x1f\x7f]/.test(a)?{valid:!1,reason:"Model name contains control characters"}:""===a.trim()?{valid:!1,reason:"Model name must not be empty"}:!du.test(a)?{valid:!1,reason:"Model name contains invalid characters"}:a.length>128?{valid:!1,reason:"Model name exceeds 128 characters"}:{valid:!0}).valid?null:l("edit.errorModelInvalid"):null},[D,p.model,l]),J=!F&&!G&&!H&&!I,K=(0,h.useCallback)(a=>{q(b=>({...b,cliToolId:a,permission:function(a){let b=dr[a];if(void 0!==b)return b;let c=ds(a);return c.length>0?c[0]:""}(a),model:"copilot"===a?b.model:""}))},[]),L=(0,h.useCallback)(a=>{let b=o.find(b=>b.id===a);b&&(s(a),K(b.cliTool))},[o,K]),M=dw.some(a=>a.value===p.cronExpression)?p.cronExpression:"custom",N=(0,h.useCallback)(a=>{"custom"!==a&&q(b=>({...b,cronExpression:a}))},[]),O=(0,h.useCallback)(a=>{f?.(a),i()},[f,i]),P=(0,h.useCallback)(async()=>{if(J&&!t){u(!0),w(null);try{let a=await fetch(`/api/worktrees/${b}/cmate/schedules`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:p.name.trim(),cronExpression:p.cronExpression.trim(),message:p.message.trim(),cliToolId:p.cliToolId,enabled:p.enabled,permission:C?p.permission:"",model:D&&p.model.trim()?p.model.trim():void 0,originalName:d??void 0})});if(!a.ok){let b=await a.json().catch(()=>({}));w(b.error||l("edit.saveError"));return}j(),i()}catch{w(l("edit.saveError"))}finally{u(!1)}}},[J,t,b,p,C,D,d,j,i,l]),Q=o.find(a=>a.id===r)?.alias??(0,be.f_)(p.cliToolId),R=p.name.trim()?`${p.name.trim()} \xb7 ${p.cronExpression}`:p.cronExpression,S=[Q,C?p.permission:null,D&&p.model.trim()?p.model.trim():null].filter(Boolean).join(" \xb7 "),T=p.message.trim(),U=T.length>32?`${T.slice(0,32)}…`:T,V=(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:dz,htmlFor:"schedule-name-input",children:l("edit.name")}),(0,e.jsx)("input",{id:"schedule-name-input","data-testid":"schedule-name-input",type:"text",value:p.name,maxLength:100,placeholder:l("edit.namePlaceholder"),onChange:a=>q(b=>({...b,name:a.target.value})),className:dy}),F&&(0,e.jsx)("p",{className:dA,"data-testid":"schedule-name-error",children:F})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-foreground",htmlFor:"schedule-cron-input",children:l("edit.cron")}),f&&(0,e.jsx)(dB,{testId:"schedule-cron-ask-ai",label:l("edit.askAiCron"),title:l("edit.askAiHint"),onClick:()=>O(function(a,b){let c=b.trim();return 0===c.length?a("edit.aiPrompts.cron"):a("edit.aiPrompts.cronRefine",{current:"`"+c+"`"})}(l,p.cronExpression))})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,e.jsx)("input",{id:"schedule-cron-input","data-testid":"schedule-cron-input",type:"text",value:p.cronExpression,placeholder:l("edit.cronPlaceholder"),onChange:a=>q(b=>({...b,cronExpression:a.target.value})),className:`${dy} font-mono sm:flex-1`}),(0,e.jsxs)("select",{"data-testid":"schedule-cron-preset","aria-label":l("edit.cronPreset"),value:M,onChange:a=>N(a.target.value),className:`${dy} sm:w-48`,children:[dw.map(a=>(0,e.jsx)("option",{value:a.value,children:l(`edit.${a.labelKey}`)},a.value)),(0,e.jsx)("option",{value:"custom",children:l("edit.cronPresetCustom")})]})]}),G&&(0,e.jsx)("p",{className:dA,"data-testid":"schedule-cron-error",children:G})]}),(0,e.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,e.jsx)(n.Sc,{"data-testid":"schedule-enabled-toggle",checked:p.enabled,onCheckedChange:a=>q(b=>({...b,enabled:!0===a}))}),(0,e.jsx)("span",{className:"text-sm text-foreground",children:l("edit.enabledLabel")})]})]}),W=(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:dz,htmlFor:"schedule-cli-tool-select",children:l("edit.cliTool")}),(0,e.jsx)("select",{id:"schedule-cli-tool-select","data-testid":"schedule-cli-tool-select",value:r,onChange:a=>L(a.target.value),className:dy,children:o.map(a=>(0,e.jsx)("option",{value:a.id,children:a.alias},a.id))})]}),D&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:dz,htmlFor:"schedule-model-input",children:l("edit.model")}),(0,e.jsx)("input",{id:"schedule-model-input","data-testid":"schedule-model-input",type:"text",value:p.model,placeholder:l("edit.modelPlaceholder"),onChange:a=>q(b=>({...b,model:a.target.value})),className:dy}),I&&(0,e.jsx)("p",{className:dA,"data-testid":"schedule-model-error",children:I})]}),C&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:dz,htmlFor:"schedule-permission-select",children:l("edit.permission")}),(0,e.jsx)("select",{id:"schedule-permission-select","data-testid":"schedule-permission-select",value:p.permission,onChange:a=>q(b=>({...b,permission:a.target.value})),className:dy,children:A.map(a=>(0,e.jsx)("option",{value:a,children:a},a))})]})]}),X=(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-foreground",htmlFor:"schedule-message-input",children:l("edit.message")}),f&&(0,e.jsx)(dB,{testId:"schedule-message-ask-ai",label:l("edit.askAiMessage"),title:l("edit.askAiHint"),onClick:()=>O(function(a,b){let c=b.trim();return 0===c.length?a("edit.aiPrompts.messageDraft"):a("edit.aiPrompts.messageDraftNamed",{name:"`"+c+"`"})}(l,p.name))})]}),(0,e.jsx)("textarea",{id:"schedule-message-input","data-testid":"schedule-message-input",value:p.message,rows:4,maxLength:1e4,placeholder:l("edit.messagePlaceholder"),onChange:a=>q(b=>({...b,message:a.target.value})),className:`${dy} resize-none`}),(0,e.jsxs)("div",{className:"mt-1 flex items-center justify-between",children:[H?(0,e.jsx)("p",{className:dA,"data-testid":"schedule-message-error",children:H}):(0,e.jsx)("span",{}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"schedule-message-count",children:l("edit.charCount",{count:p.message.length,max:1e4})})]})]}),Y=(0,e.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,e.jsx)(dC,{id:"basic",title:l("edit.sectionBasic"),summary:R,icon:(0,e.jsx)(B.A,{className:"w-4 h-4"}),isOpen:x.has("basic"),onToggle:z,children:V}),(0,e.jsx)(dC,{id:"advanced",title:l("edit.sectionAdvanced"),summary:S,icon:(0,e.jsx)(di,{className:"w-4 h-4"}),isOpen:x.has("advanced"),onToggle:z,children:W}),(0,e.jsx)(dC,{id:"message",title:l("edit.sectionMessage"),summary:U,icon:(0,e.jsx)(dj.A,{className:"w-4 h-4"}),isOpen:x.has("message"),onToggle:z,children:X}),v&&(0,e.jsx)("div",{className:"text-xs p-2 rounded bg-danger-subtle text-danger-foreground","data-testid":"schedule-submit-error",children:v})]}),Z=(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:i,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:l("edit.cancel")}),(0,e.jsx)("button",{type:"button","data-testid":"schedule-save-button",onClick:()=>void P(),disabled:!J||t,className:"px-4 py-2 text-sm font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-md transition-colors",children:l("edit.save")})]}),$=E?l("edit.titleEdit"):l("edit.titleCreate");return m?(0,e.jsx)(dk,{isOpen:a,onClose:i,title:$,footer:Z,children:Y}):(0,e.jsx)(bc.a,{isOpen:a,onClose:i,title:$,size:"md",children:(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[Y,(0,e.jsx)("div",{className:"pt-2 border-t border-border",children:Z})]})})}function dE(a){return new Date(a).toLocaleString()}function dF(a,b){if(null===b)return null;let c=b-a;if(c<0)return null;let d=Math.floor(c/1e3),e=Math.floor(d/60),f=d%60;return e>0?`${e}m ${f}s`:`${f}s`}let dG=(0,h.memo)(function({worktreeId:a,logs:b}){let c=(0,k.c)("schedule"),[d,f]=(0,h.useState)(null),[g,i]=(0,h.useState)(null),j=(0,h.useCallback)(async b=>{if(d===b){f(null),i(null);return}try{let c=await fetch(`/api/worktrees/${a}/execution-logs/${b}`);if(c.ok){let a=await c.json();i(a.log),f(b)}}catch(a){console.error("Failed to fetch log detail:",a)}},[a,d]);return 0===b.length?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:c("noLogs")}):(0,e.jsx)("div",{className:"space-y-2","data-testid":"execution-logs-view",children:b.map(a=>(0,e.jsxs)("div",{className:"border border-border rounded bg-surface",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>void j(a.id),className:"w-full text-left p-3 hover:bg-muted transition-colors",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("span",{className:"text-sm truncate max-w-[60%]",children:a.schedule_name||c("unknownSchedule")}),(0,e.jsx)("span",{className:`text-xs px-2 py-0.5 rounded ${function(a){switch(a){case"completed":return"text-success-foreground bg-success-subtle";case"failed":return"text-danger-foreground bg-danger-subtle";case"timeout":return"text-warning-foreground bg-warning-subtle";case"running":return"text-accent-600 dark:text-accent-400 bg-accent-50 dark:bg-accent-900/30";case"cancelled":return"text-muted-foreground bg-muted"}}(a.status)}`,children:c(`status.${a.status}`)})]}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[dE(a.started_at),dF(a.started_at,a.completed_at)&&(0,e.jsxs)("span",{className:"ml-2",children:["(",dF(a.started_at,a.completed_at),")"]}),null!==a.exit_code&&(0,e.jsxs)("span",{className:"ml-2",children:[c("exitCode"),": ",a.exit_code]})]})]}),d===a.id&&g&&(0,e.jsxs)("div",{className:"border-t border-border p-3 bg-muted space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:c("message")}),(0,e.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-foreground",children:g.message})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:c("response")}),(0,e.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-foreground max-h-60 overflow-y-auto",children:g.result||c("noOutput")})]})]})]},a.id))})});function dH(){return(0,e.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,e.jsx)("path",{d:"M13.586 3.586a2 2 0 112.828 2.828l-8.5 8.5a1 1 0 01-.43.26l-3 .857a.5.5 0 01-.617-.618l.857-3a1 1 0 01.26-.43l8.5-8.5z"})})}function dI(){return(0,e.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M8 2a1 1 0 00-.894.553L6.382 4H3a1 1 0 000 2h.293l.668 9.357A2 2 0 005.956 17h8.088a2 2 0 001.995-1.643L16.707 6H17a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0012 2H8zm1 5a1 1 0 012 0v6a1 1 0 11-2 0V7zm-3 0a1 1 0 011 1v5a1 1 0 11-2 0V8a1 1 0 011-1z",clipRule:"evenodd"})})}let dJ=(0,h.memo)(function({worktreeId:a,className:b="",onInsertToMessage:c,instances:d}){let f=(0,k.c)("schedule"),g=(0,am.SC)(),[i,j]=(0,h.useState)([]),[l,m]=(0,h.useState)([]),[o,p]=(0,h.useState)([]),[q,r]=(0,h.useState)(!0),[s,t]=(0,h.useState)(null),[u,v]=(0,h.useState)("schedules"),[w,x]=(0,h.useState)(!1),[y,z]=(0,h.useState)(!1),[A,B]=(0,h.useState)(void 0),[C,D]=(0,h.useState)(void 0),E=(0,h.useCallback)(async()=>{r(!0),t(null);try{let[b,c,d]=await Promise.all([fetch(`/api/worktrees/${a}/execution-logs`),fetch(`/api/worktrees/${a}/schedules`),fetch(`/api/worktrees/${a}/schedules/active`)]);if(b.ok){let a=await b.json();j(a.logs||[])}if(c.ok){let a=await c.json();m(a.schedules||[])}if(d.ok){let a=await d.json();p(a.schedules||[])}else p([])}catch(a){t(a instanceof Error?a.message:"Failed to fetch data")}finally{r(!1)}},[a]);(0,h.useEffect)(()=>{E()},[E]);let F=(0,h.useCallback)(async b=>{try{let c=await fetch(`/api/worktrees/${a}/files/CMATE.md`);if(!c.ok)return null;let d=await c.json(),e="string"==typeof d.content?d.content:"",f=((function(a){let b=new Map,c=a.split("\n"),d=null,e=!1,f=!1;for(let a of c){let c=a.trim(),g=c.match(/^##\s+(.+)$/);if(g){d=g[1].trim(),e=!1,f=!1,b.has(d)||b.set(d,[]);continue}if(!c||!c.startsWith("|")||!d)continue;if(!e){e=!0;continue}if(!f){if(c.match(/^\|[\s-:|]+\|$/)){f=!0;continue}f=!0}let h=c.split("|").slice(1,-1).map(a=>a.trim());h.length>0&&b.get(d).push(h)}return b})(e).get("Schedules")??[]).find(a=>(a[0]??"").trim()===b);if(!f)return null;let g=function(a){let b=a.trim();if(!b)return{cliToolId:"claude",model:void 0};let c=b.split(/\s+/),d=c[0];return 1===c.length?{cliToolId:d,model:void 0}:dv.has(d)?3===c.length&&"--model"===c[1]?{cliToolId:d,model:c[2]}:{cliToolId:d,error:`${d} only supports: ${d} --model <modelName>`}:{cliToolId:d,error:`CLI Tool "${d}" does not support additional options`}}(f[3]??"claude"),h=(f[4]??"true").trim().toLowerCase();return{name:b,cronExpression:(f[1]??"").trim(),message:(f[2]??"").trim(),cliToolId:g.cliToolId||"claude",enabled:""===h||"true"===h,permission:(f[5]??"").trim(),model:g.model??""}}catch{return null}},[a]),G=(0,h.useCallback)(()=>{D(void 0),B(void 0),z(!0)},[]),H=(0,h.useCallback)(async a=>{let b=await F(a.name);D(a.name),B(b??{name:a.name,cronExpression:a.cron_expression,message:a.message,cliToolId:a.cli_tool_id,enabled:1===a.enabled,permission:"",model:""}),z(!0)},[F]),I=(0,h.useCallback)(async b=>{if(await g({description:f("edit.confirmDelete",{name:b}),variant:"danger"}))try{(await fetch(`/api/worktrees/${a}/cmate/schedules`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b})})).ok&&await E()}catch(a){console.error("Failed to delete schedule:",a)}},[a,f,E,g]),J=(0,h.useCallback)(async b=>{try{(await fetch(`/api/worktrees/${a}/cmate/schedules`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name,enabled:1!==b.enabled})})).ok&&await E()}catch(a){console.error("Failed to toggle schedule:",a)}},[a,E]);return q?(0,e.jsx)("div",{className:`flex items-center justify-center h-full p-4 ${b}`,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)("span",{className:"text-sm text-muted-foreground",children:f("loading")})]})}):s?(0,e.jsx)("div",{className:`flex items-center justify-center h-full p-4 ${b}`,children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("span",{className:"text-sm text-danger-foreground",children:s}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:()=>void E(),className:"ml-2 px-3 py-1 text-sm text-white bg-accent-500 rounded hover:bg-accent-600",children:f("retry")})]})}):(0,e.jsxs)("div",{className:`flex flex-col h-full ${b}`,children:[(0,e.jsxs)("div",{className:"flex shrink-0 border-b border-border px-4 pt-3",children:[(0,e.jsxs)("button",{type:"button","data-testid":"schedule-tab-schedules",role:"tab","aria-selected":"schedules"===u,onClick:()=>v("schedules"),className:`-mb-px px-3 py-2 text-sm font-medium border-b-2 transition-colors ${"schedules"===u?"border-accent-500 text-accent-700 dark:text-accent-300":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[f("tabs.schedules")," (",l.length,")"]}),(0,e.jsxs)("button",{type:"button","data-testid":"schedule-tab-logs",role:"tab","aria-selected":"logs"===u,onClick:()=>v("logs"),className:`-mb-px px-3 py-2 text-sm font-medium border-b-2 transition-colors ${"logs"===u?"border-accent-500 text-accent-700 dark:text-accent-300":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[f("tabs.logs")," (",i.length,")"]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:"schedules"===u?(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,e.jsxs)("div",{className:"rounded border border-accent-100 bg-accent-50/60 p-3 dark:border-accent-900/40 dark:bg-accent-950/20",children:[(0,e.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"text-sm font-semibold text-accent-900 dark:text-accent-200",children:[f("activeSchedulesTitle")," (",o.length,")"]}),(0,e.jsx)("span",{className:"text-xs text-accent-700 dark:text-accent-300",children:f("activeSchedulesDescription")})]}),0===o.length?(0,e.jsx)("p",{className:"text-xs text-accent-800 dark:text-accent-300",children:f("noActiveSchedules")}):(0,e.jsx)("div",{className:"space-y-2",children:o.map(a=>(0,e.jsxs)("div",{className:"rounded border border-accent-200/80 bg-white/80 p-3 dark:border-accent-900/40 dark:bg-surface/60",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"font-medium text-sm text-foreground",children:a.name}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:`text-xs px-2 py-0.5 rounded ${a.isCronActive?"bg-success-subtle text-success-foreground":"bg-danger-subtle text-danger-foreground"}`,children:a.isCronActive?f("activeState.active"):f("activeState.inactive")}),a.isExecuting&&(0,e.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-accent-100 text-accent-700 dark:bg-accent-900/30 dark:text-accent-300",children:f("activeState.executing")})]})]}),(0,e.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[(0,e.jsxs)("span",{children:[f("cron"),": ",a.cronExpression||"N/A"]}),(0,e.jsxs)("span",{className:"ml-3",children:[f("agentLabel"),": ",a.cliToolId]}),a.model&&(0,e.jsxs)("span",{className:"ml-3",children:["model: ",a.model]}),a.nextRunAt&&(0,e.jsxs)("span",{className:"ml-3",children:[f("nextRun"),": ",dE(a.nextRunAt)]})]})]},a.scheduleId))})]}),0===l.length?(0,e.jsxs)("div",{className:"flex flex-col items-center text-center py-8 px-4",children:[(0,e.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-accent-50 text-accent-600 dark:bg-accent-900/30 dark:text-accent-300",children:(0,e.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",className:"w-7 h-7",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 7.5V12l3 2"})]})}),(0,e.jsx)("p",{className:"font-semibold text-foreground mb-1",children:f("emptyState.title")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-5 max-w-xs",children:f("emptyState.description")}),(0,e.jsxs)(n.$n,{variant:"ghost",type:"button","data-testid":"schedule-empty-cta",onClick:G,className:"inline-flex items-center gap-1.5 px-5 py-2.5 text-sm font-semibold text-white bg-accent-600 hover:bg-accent-700 rounded-lg shadow-sm transition-colors",children:[(0,e.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,e.jsx)("path",{d:"M10 4a1 1 0 011 1v4h4a1 1 0 110 2h-4v4a1 1 0 11-2 0v-4H5a1 1 0 110-2h4V5a1 1 0 011-1z"})}),f("emptyState.createButton")]}),(0,e.jsx)("button",{type:"button","data-testid":"schedule-manual-toggle","aria-expanded":w,onClick:()=>x(a=>!a),className:"mt-5 text-xs text-accent-700 dark:text-accent-300 hover:underline",children:f("emptyState.manualToggle")}),w&&(0,e.jsxs)("ol",{"data-testid":"schedule-manual-steps",className:"mt-3 text-xs text-left inline-block space-y-1.5 list-decimal list-inside text-muted-foreground",children:[(0,e.jsx)("li",{children:f("noSchedulesStep1")}),(0,e.jsx)("li",{children:f("noSchedulesStep2")}),(0,e.jsx)("li",{children:f("noSchedulesStep3")}),(0,e.jsx)("li",{children:f("noSchedulesStep4")})]})]}):(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"mb-2 flex items-center justify-end",children:(0,e.jsxs)(n.$n,{variant:"ghost",type:"button","data-testid":"schedule-new-button",onClick:G,className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-white bg-accent-600 hover:bg-accent-700 rounded transition-colors whitespace-nowrap",children:[(0,e.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-3.5 h-3.5",children:(0,e.jsx)("path",{d:"M10 4a1 1 0 011 1v4h4a1 1 0 110 2h-4v4a1 1 0 11-2 0v-4H5a1 1 0 110-2h4V5a1 1 0 011-1z"})}),f("edit.newSchedule")]})}),(0,e.jsx)("div",{className:"space-y-2",children:l.map(a=>{let b=1===a.enabled;return(0,e.jsxs)("div",{className:"border border-border rounded p-3 bg-white dark:bg-surface",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"font-medium text-sm truncate",children:a.name}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{type:"button",role:"switch","aria-checked":b,"aria-label":b?f("edit.disable"):f("edit.enable"),title:b?f("edit.disable"):f("edit.enable"),"data-testid":`schedule-toggle-${a.name}`,onClick:()=>void J(a),className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors ${b?"bg-success":"bg-input"}`,children:(0,e.jsx)("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform ${b?"translate-x-4":"translate-x-0.5"}`})}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button","data-testid":`schedule-edit-${a.name}`,"aria-label":f("edit.edit"),title:f("edit.edit"),onClick:()=>void H(a),className:"p-1.5 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/20 rounded transition-colors",children:(0,e.jsx)(dH,{})}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button","data-testid":`schedule-delete-${a.name}`,"aria-label":f("edit.delete"),title:f("edit.delete"),onClick:()=>void I(a.name),className:"p-1.5 text-muted-foreground hover:text-danger-foreground hover:bg-danger-subtle rounded transition-colors",children:(0,e.jsx)(dI,{})})]})]}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[(0,e.jsxs)("span",{children:[f("cron"),": ",a.cron_expression||"N/A"]}),a.last_executed_at&&(0,e.jsxs)("span",{className:"ml-3",children:[f("lastRun"),": ",dE(a.last_executed_at)]})]})]},a.id)})})]})]}):(0,e.jsx)(dG,{worktreeId:a,logs:i})}),(0,e.jsx)(dD,{isOpen:y,worktreeId:a,initialValues:A,originalName:C,onInsertToMessage:c,instances:d,onClose:()=>z(!1),onSaved:()=>{E()}})]})}),dK=(0,h.memo)(function({worktreeId:a,vibeLocalModel:b,onVibeLocalModelChange:c,vibeLocalContextWindow:d,onVibeLocalContextWindowChange:f}){let g=(0,k.c)("schedule"),[i,j]=(0,h.useState)([]),[l,n]=(0,h.useState)(null),[o,p]=(0,h.useState)(!1),[q,r]=(0,h.useState)(!1),[s,t]=(0,h.useState)(null!=d?String(d):""),[u,v]=(0,h.useState)(!1);(0,h.useEffect)(()=>{t(null!=d?String(d):"")},[d]),(0,h.useEffect)(()=>{let a=!1;return p(!0),fetch("/api/ollama/models").then(a=>a.json()).then(b=>{a||(j(b.models),n(0===b.models.length&&b.error?b.error:null))}).catch(()=>{a||(j([]),n("Failed to fetch models"))}).finally(()=>{a||p(!1)}),()=>{a=!0}},[]);let w=(0,h.useCallback)(async b=>{let d=b.target.value,e=""===d?null:d;r(!0);try{(await fetch(`/api/worktrees/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({vibeLocalModel:e})})).ok&&c(e)}catch{}finally{r(!1)}},[a,c]),x=(0,h.useCallback)(a=>{t(a.target.value)},[]),y=(0,h.useCallback)(async()=>{let b=s.trim(),c=parseInt(b,10),e=""===b||Number.isNaN(c)?null:c,g=d??null;if(e!==g){v(!0);try{(await fetch(`/api/worktrees/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({vibeLocalContextWindow:e})})).ok?f?.(e):t(null!=g?String(g):"")}catch{t(null!=g?String(g):"")}finally{v(!1)}}},[s,d,a,f]);return(0,e.jsxs)("div",{className:"mt-4 pt-4 border-t border-border",children:[(0,e.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-2",children:g("vibeLocalModel")}),o?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)(m.y,{size:"xs",variant:"muted"}),g("loading")]}):l&&0===i.length?(0,e.jsx)("p",{className:"text-xs text-warning-foreground",children:g("ollamaNotAvailable")}):(0,e.jsxs)("select",{"data-testid":"vibe-local-model-select",value:b??"",onChange:w,disabled:q,className:"w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50",children:[(0,e.jsx)("option",{value:"",children:g("vibeLocalModelDefault")}),i.map(a=>(0,e.jsxs)("option",{value:a.name,children:[a.name,a.parameterSize?` (${a.parameterSize})`:""]},a.name))]}),(0,e.jsxs)("div",{className:"mt-3",children:[(0,e.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-2",children:g("vibeLocalContextWindow")}),(0,e.jsx)("input",{type:"number","data-testid":"vibe-local-context-window-input",step:"1",min:be.vz,max:be.NL,value:s,onChange:x,onBlur:y,placeholder:g("vibeLocalContextWindowDefault"),disabled:u,className:"w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50"})]})]})}),dL=(0,h.memo)(function({worktreeId:a,selectedAgents:b,onSelectedAgentsChange:c,vibeLocalModel:d,onVibeLocalModelChange:f,vibeLocalContextWindow:g,onVibeLocalContextWindowChange:i,maxAgents:j=2,availableAgents:l=be.XH,persistToServer:m=!0}){let o=(0,k.c)("schedule"),p=b.length>j?b.slice(0,j):b,[q,r]=(0,h.useState)(()=>new Set(p)),[s,t]=(0,h.useState)(!1),[u,v]=(0,h.useState)(!1),w=(0,h.useRef)(q);w.current=q,(0,h.useEffect)(()=>{u||r(new Set(p))},[b,u,j]);let x=q.has("vibe-local"),y=(0,h.useCallback)(async(b,d)=>{let e=new Set(w.current);if(d?e.add(b):(e.delete(b),v(!0)),r(e),e.size>=2){let b=Array.from(e);if(!m){r(new Set(b)),c(b),v(!1);return}t(!0);try{(await fetch(`/api/worktrees/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({selectedAgents:b})})).ok?(r(new Set(b)),c(b)):r(new Set(p))}catch{r(new Set(p))}finally{t(!1),v(!1)}}},[a,p,c,m]),z=q.size>=j;return(0,e.jsxs)("div",{className:"p-4",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:o("agentSettings")}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:o("selectAgents")}),(0,e.jsx)("div",{className:"space-y-3",children:l.map(a=>{let b=q.has(a),c=!b&&z;return(0,e.jsxs)("label",{className:`flex items-center gap-3 p-2 rounded-lg border transition-colors ${b?"border-accent-200 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30":c?"border-border bg-muted opacity-50":"border-border hover:border-input hover:bg-muted"}`,children:[(0,e.jsx)(n.Sc,{"data-testid":`agent-checkbox-${a}`,"aria-label":(0,be.oo)(a),checked:b,disabled:c||s,onCheckedChange:b=>y(a,!0===b)}),(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:(0,be.oo)(a)})]},a)})}),s&&(0,e.jsxs)("div",{"data-testid":"agent-settings-loading",className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)(n.y$,{size:"xs",variant:"muted"}),o("loading")]}),x&&(0,e.jsx)(dK,{worktreeId:a,vibeLocalModel:d,onVibeLocalModelChange:f,vibeLocalContextWindow:g,onVibeLocalContextWindowChange:i})]})});function dM(a,b){if(0===b.length)return[];if(null!==a){let c=new Set(a),d=b.filter(a=>c.has(a.id));if(d.length>0)return d}return[...b]}let dN=(0,x.A)("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),dO=(0,x.A)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),dP=(0,x.A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),dQ=(0,h.memo)(function({worktreeId:a,instances:b,onInstancesChange:c,vibeLocalModel:d,onVibeLocalModelChange:f,vibeLocalContextWindow:g,onVibeLocalContextWindowChange:i}){let j=(0,k.c)("schedule"),l=(0,k.c)("common"),n=(0,am.SC)(),[o,p]=(0,h.useState)(!1),[q,r]=(0,h.useState)(null),[s,t]=(0,h.useState)({}),[u,v]=(0,h.useState)(be.XH[0]),[w,x]=(0,h.useState)(null),y=b.length>=be.Ab,z=b.length<=1,A=b.some(a=>"vibe-local"===a.cliTool),B=(0,h.useCallback)(async b=>{let d=b.map((a,b)=>({...a,order:b}));p(!0),r(null);try{(await fetch(`/api/worktrees/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentInstances:d})})).ok?c(d):r(j("agentInstanceSaveError"))}catch{r(j("agentInstanceSaveError"))}finally{p(!1)}},[a,c,j]),C=(0,h.useCallback)(()=>{if(b.length>=be.Ab)return;let a=function(a,b){let c=new Set(b.map(a=>a.id));if(!c.has(a))return a;let d=2;for(;c.has(`${a}-${d}`);)d++;return`${a}-${d}`}(u,b);B([...b,{id:a,cliTool:u,alias:function(a,b){let c=(0,be.oo)(a);if(b===a)return c;let d=b.slice(a.length+1);return d?`${c} ${d}`:c}(u,a),order:b.length}])},[u,b,B]),D=(0,h.useCallback)(async a=>{if(b.length<=1)return;let c=b.find(b=>b.id===a);await n({description:l("confirmDelete",{name:c?.alias??""}),variant:"danger"})&&B(b.filter(b=>b.id!==a))},[b,B,n,l]),E=(0,h.useCallback)((a,c)=>{let d=a+c;if(d<0||d>=b.length)return;let e=[...b];[e[a],e[d]]=[e[d],e[a]],B(e)},[b,B]),F=(0,h.useCallback)((a,c)=>{t(b=>{if(!(a in b))return b;let c={...b};return delete c[a],c});let d=b.find(b=>b.id===a);d&&c!==d.alias&&B(b.map(b=>b.id===a?{...b,alias:c}:b))},[b,B]),G=(0,h.useCallback)((a,c)=>{if(a===c||a<0||c<0||a>=b.length||c>=b.length)return;let d=[...b],[e]=d.splice(a,1);d.splice(c,0,e),B(d)},[b,B]);return(0,e.jsxs)("div",{className:"p-4","data-testid":"agent-instances-pane",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:j("agentInstances")}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:j("agentInstancesDescription")}),(0,e.jsx)("div",{className:"space-y-2",children:b.map((a,c)=>{let d=a.id in s?s[a.id]:a.alias,f=w===c;return(0,e.jsxs)("div",{"data-testid":`agent-instance-row-${a.id}`,draggable:!0,onDragStart:()=>x(c),onDragOver:a=>a.preventDefault(),onDrop:()=>{null!==w&&G(w,c),x(null)},onDragEnd:()=>x(null),className:`flex items-center gap-2 p-2 rounded-lg border border-border bg-surface transition-colors hover:border-accent-300 dark:hover:border-accent-700 focus-within:border-accent-500 ${f?"opacity-50":""}`,children:[(0,e.jsx)("span",{className:"cursor-grab text-muted-foreground shrink-0","aria-hidden":"true",children:(0,e.jsx)(dN,{className:"w-4 h-4"})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("input",{type:"text","data-testid":`agent-instance-alias-${a.id}`,"aria-label":j("agentInstanceAliasLabel"),value:d,maxLength:be.pQ,disabled:o,placeholder:j("agentInstanceAliasPlaceholder"),onChange:b=>t(c=>({...c,[a.id]:b.target.value})),onBlur:b=>F(a.id,b.target.value),onKeyDown:a=>{"Enter"===a.key&&a.currentTarget.blur()},className:"w-full text-sm font-medium border border-input rounded-md px-2 py-1 bg-surface dark:bg-surface-2 text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50"}),(0,e.jsx)(cP.nR,{content:(0,be.oo)(a.cliTool),className:"mt-0.5 block truncate text-xs text-muted-foreground"})]}),(0,e.jsxs)(aZ.rI,{children:[(0,e.jsx)(aZ.ty,{asChild:!0,children:(0,e.jsx)("button",{type:"button","data-testid":`agent-instance-menu-${a.id}`,"aria-label":j("agentInstanceActions"),title:j("agentInstanceActions"),disabled:o,className:"shrink-0 p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted disabled:opacity-30 disabled:cursor-not-allowed",children:(0,e.jsx)(dO,{className:"w-4 h-4"})})}),(0,e.jsxs)(aZ.SQ,{align:"end",children:[(0,e.jsxs)(aZ._2,{"data-testid":`agent-instance-move-up-${a.id}`,disabled:0===c,onSelect:()=>E(c,-1),children:[(0,e.jsx)(c6.A,{className:"w-4 h-4"}),j("agentInstanceMoveUp")]}),(0,e.jsxs)(aZ._2,{"data-testid":`agent-instance-move-down-${a.id}`,disabled:c===b.length-1,onSelect:()=>E(c,1),children:[(0,e.jsx)(bf.A,{className:"w-4 h-4"}),j("agentInstanceMoveDown")]}),(0,e.jsx)(aZ.mB,{}),(0,e.jsxs)(aZ._2,{"data-testid":`agent-instance-delete-${a.id}`,disabled:z,onSelect:()=>{D(a.id)},className:"text-danger-foreground focus:text-danger-foreground",children:[(0,e.jsx)(cL.A,{className:"w-4 h-4"}),j("agentInstanceDelete")]})]})]})]},a.id)})}),(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-2",children:[(0,e.jsx)("select",{"data-testid":"agent-instance-add-tool","aria-label":j("agentInstanceBaseTool"),value:u,disabled:o||y,onChange:a=>v(a.target.value),className:"flex-1 min-w-0 text-sm border border-input rounded-md px-2 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50",children:be.XH.map(a=>(0,e.jsx)("option",{value:a,children:(0,be.oo)(a)},a))}),(0,e.jsxs)("button",{type:"button","data-testid":"agent-instance-add",disabled:o||y,onClick:C,className:"flex items-center gap-1 text-sm font-medium px-3 py-2 rounded-md border border-accent-200 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 hover:bg-accent-100 dark:hover:bg-accent-900/50 disabled:opacity-40 disabled:cursor-not-allowed shrink-0",children:[(0,e.jsx)(dP,{className:"w-4 h-4"}),j("agentInstanceAdd")]})]}),y&&(0,e.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:j("agentInstanceMax",{max:be.Ab})}),z&&(0,e.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:j("agentInstanceMin",{min:1})}),o&&(0,e.jsxs)("div",{"data-testid":"agent-instances-loading",className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)(m.y,{size:"xs",variant:"muted"}),j("loading")]}),q&&(0,e.jsx)("p",{"data-testid":"agent-instances-error",className:"mt-3 text-xs text-danger-foreground",children:q}),A&&(0,e.jsx)(dK,{worktreeId:a,vibeLocalModel:d,onVibeLocalModelChange:f,vibeLocalContextWindow:g,onVibeLocalContextWindowChange:i})]})}),dR=(0,h.memo)(function({worktreeId:a,instances:b,onInstancesChange:c,vibeLocalModel:d,onVibeLocalModelChange:f,vibeLocalContextWindow:g,onVibeLocalContextWindowChange:h,visibleInstanceIds:i,onToggleInstanceVisible:j}){let l=(0,k.c)("schedule"),m=new Set(i),o=i.length<=1;return(0,e.jsxs)("div",{"data-testid":"mobile-agent-instances-pane",children:[(0,e.jsx)(dQ,{worktreeId:a,instances:b,onInstancesChange:c,vibeLocalModel:d,onVibeLocalModelChange:f,vibeLocalContextWindow:g,onVibeLocalContextWindowChange:h}),(0,e.jsxs)("div",{"data-testid":"mobile-visible-instances",className:"px-4 pb-4 border-t border-border mt-2 pt-4",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:l("mobileVisibleInstances")}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:l("mobileVisibleInstancesDescription")}),(0,e.jsx)("div",{className:"space-y-1",children:b.map(a=>{let b=m.has(a.id),c=b&&o;return(0,e.jsxs)("label",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer ${c?"opacity-60 cursor-not-allowed":"hover:bg-muted"}`,children:[(0,e.jsx)(n.Sc,{"data-testid":`mobile-visible-instance-toggle-${a.id}`,checked:b,disabled:c,onCheckedChange:()=>j(a.id)}),(0,e.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground truncate",children:(0,be.sw)(a)}),(0,e.jsx)("span",{className:"block text-xs text-muted-foreground truncate",children:(0,be.oo)(a.cliTool)})]})]},a.id)})}),o&&(0,e.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:l("mobileVisibleInstanceMin")})]})]})}),dS=Array.from({length:Math.floor(104)+1},(a,b)=>3e5+3e5*b);c(30868);let dT=[36e5,108e5,288e5],dU={36e5:"autoYes.durations.1h",108e5:"autoYes.durations.3h",288e5:"autoYes.durations.8h"};function dV(a){let b=Math.max(0,a-Date.now()),c=Math.floor(b/36e5),d=Math.floor(b%36e5/6e4),e=Math.floor(b%6e4/1e3);return c>0?`${c}:${d.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`:`${d.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`}function dW(a){let b=Math.floor(a/6e4),c=Math.floor(b/60),d=b%60;return c>0&&d>0?`${c}h ${d}m`:c>0?`${c}h`:`${d}m`}let dX="w-full px-3 py-2 text-sm border border-input rounded-md bg-surface dark:bg-surface-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring";function dY({isOpen:a,worktreeId:b,instances:c,onClose:d,onSaved:f}){let g=(0,k.c)("schedule"),i=(0,ab.a)(),j=(0,h.useMemo)(()=>c&&c.length>0?c:(0,be.lu)([...be.XH]),[c]),[l,m]=(0,h.useState)(""),[n,o]=(0,h.useState)(()=>j[0]?.id??be.XH[0]),[p,q]=(0,h.useState)(dS[0]),[r,s]=(0,h.useState)(!1),[t,u]=(0,h.useState)(null),v=l.trim().length>0&&!r,w=(0,h.useCallback)(async()=>{if(!l.trim()||r)return;let a=j.find(a=>a.id===n);if(a){u(null),s(!0);try{let c=await fetch(`/api/worktrees/${b}/timers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:a.cliTool,instanceId:a.id,message:l.trim(),delayMs:p})});if(c.ok){let a=await c.json();f(),"session_not_running"===a.warning?(u("session_not_running"),m("")):d()}}catch{}finally{s(!1)}}},[b,j,n,l,p,r,f,d]),x=(0,e.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-instance-select",children:g("timer.agent")}),(0,e.jsx)("select",{id:"timer-instance-select","data-testid":"timer-instance-select",value:n,onChange:a=>o(a.target.value),className:dX,children:j.map(a=>(0,e.jsx)("option",{value:a.id,children:a.alias},a.id))})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-message-input",children:g("timer.message")}),(0,e.jsx)("textarea",{id:"timer-message-input","data-testid":"timer-message-input",value:l,onChange:a=>m(a.target.value),placeholder:g("timer.message"),maxLength:1e4,rows:3,className:`${dX} resize-none`})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-delay-select",children:g("timer.delay")}),(0,e.jsx)("select",{id:"timer-delay-select","data-testid":"timer-delay-select",value:p,onChange:a=>q(Number(a.target.value)),className:dX,children:dS.map(a=>(0,e.jsx)("option",{value:a,children:dW(a)},a))})]}),"session_not_running"===t&&(0,e.jsx)("div",{"data-testid":"timer-session-warning",className:"text-xs p-2 rounded bg-warning-subtle text-warning-foreground",children:g("timer.sessionWarning")})]}),y=(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:d,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:g("timer.close")}),(0,e.jsx)("button",{type:"button","data-testid":"timer-register-button",onClick:()=>void w(),disabled:!v,className:"px-4 py-2 text-sm font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-md transition-colors",children:g("timer.register")})]}),z=g("timer.titleCreate");return i?(0,e.jsx)(dk,{isOpen:a,onClose:d,title:z,footer:y,children:x}):(0,e.jsx)(bc.a,{isOpen:a,onClose:d,title:z,size:"md",children:(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[x,(0,e.jsx)("div",{className:"pt-2 border-t border-border",children:y})]})})}function dZ(a){return new Date(a).toLocaleString()}function d$({timer:a,instances:b,onClose:c}){let d=(0,k.c)("schedule"),f=(0,ab.a)();if(!a)return null;let g=b.find(b=>b.id===a.instanceId)?.alias??a.cliToolId,h=({label:a,children:b})=>(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-0.5",children:a}),(0,e.jsx)("div",{className:"text-sm text-foreground break-words",children:b})]}),i=(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"timer-detail-body",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:d("timer.message")}),(0,e.jsx)("pre",{"data-testid":"timer-detail-message",className:"text-sm whitespace-pre-wrap break-words font-mono text-foreground bg-muted rounded p-2 max-h-60 overflow-y-auto",children:a.message})]}),(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,e.jsx)(h,{label:d("timer.agent"),children:(0,e.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-medium",children:g})}),(0,e.jsx)(h,{label:d("timer.statusLabel"),children:(0,e.jsx)("span",{className:function(a){switch(a){case"pending":return"text-info";case"sending":case"no_session":return"text-warning-foreground";case"sent":return"text-success-foreground";case"failed":return"text-danger-foreground";default:return"text-muted-foreground"}}(a.status),children:d(`timer.status.${a.status}`)})}),(0,e.jsx)(h,{label:d("timer.delay"),children:dW(a.delayMs)}),(0,e.jsx)(h,{label:d("timer.scheduledTime"),children:dZ(a.scheduledSendTime)}),(0,e.jsx)(h,{label:d("timer.createdTime"),children:dZ(a.createdAt)}),null!==a.sentAt&&(0,e.jsx)(h,{label:d("timer.sentTime"),children:dZ(a.sentAt)})]}),"failed"===a.status&&a.error&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-danger-foreground mb-1",children:d("timer.failureReason")}),(0,e.jsx)("pre",{"data-testid":"timer-detail-error",className:"text-xs whitespace-pre-wrap break-words font-mono text-danger-foreground bg-danger-subtle rounded p-2 max-h-40 overflow-y-auto",children:a.error})]})]}),j=(0,e.jsx)("div",{className:"flex items-center justify-end",children:(0,e.jsx)("button",{type:"button","data-testid":"timer-detail-close",onClick:c,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:d("timer.close")})}),l=d("timer.detailTitle");return f?(0,e.jsx)(dk,{isOpen:!0,title:l,onClose:c,footer:j,children:i}):(0,e.jsx)(bc.a,{isOpen:!0,title:l,onClose:c,size:"md",children:(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[i,(0,e.jsx)("div",{className:"pt-2 border-t border-border",children:j})]})})}let d_=(0,h.memo)(function({worktreeId:a,instances:b}){let c=(0,k.c)("schedule"),d=(0,am.SC)(),f=(0,h.useMemo)(()=>b&&b.length>0?b:(0,be.lu)([...be.XH]),[b]),[g,i]=(0,h.useState)([]),[j,l]=(0,h.useState)(!1),[m,n]=(0,h.useState)(!1),[o,p]=(0,h.useState)(null),[,q]=(0,h.useState)(0),r=(0,h.useRef)(null),s=(0,h.useRef)(null),t=(0,h.useRef)(null),u=(0,h.useCallback)(async()=>{try{let b=await fetch(`/api/worktrees/${a}/timers`);if(b.ok){let a=await b.json();i(a.timers),l(a.hasMore??!1),a.timers.length>0?t.current=a.timers[a.timers.length-1].createdAt:t.current=null}}catch{}},[a]),v=(0,h.useCallback)(async()=>{if(null!=t.current)try{let b=new URLSearchParams;b.set("before",String(t.current)),b.set("limit",String(50));let c=await fetch(`/api/worktrees/${a}/timers?${b}`);if(c.ok){let a=await c.json();i(b=>[...b,...a.timers]),l(a.hasMore??!1),a.timers.length>0&&(t.current=a.timers[a.timers.length-1].createdAt)}}catch{}},[a]);(0,h.useEffect)(()=>{function a(){return u(),r.current=setInterval(()=>{u()},1e4),s.current=setInterval(()=>{q(a=>a+1)},1e3),b}function b(){r.current&&clearInterval(r.current),s.current&&clearInterval(s.current),r.current=null,s.current=null}a();let c=()=>{"hidden"===document.visibilityState?b():a()};return document.addEventListener("visibilitychange",c),()=>{b(),document.removeEventListener("visibilitychange",c)}},[u]);let w=(0,h.useCallback)(async b=>{try{(await fetch(`/api/worktrees/${a}/timers?timerId=${b}`,{method:"DELETE"})).ok&&u()}catch{}},[a,u]),x=(0,h.useCallback)(async()=>{if(await d({description:c("timer.clearConfirm"),variant:"danger"}))try{(await fetch(`/api/worktrees/${a}/timers/history`,{method:"DELETE"})).ok&&u()}catch{}},[a,u,c,d]),z=g.filter(a=>"pending"===a.status).length>=5;return(0,e.jsxs)("div",{className:"flex flex-col h-full p-3 gap-3 overflow-auto",children:[0===g.length?(0,e.jsxs)("div",{className:"flex flex-col items-center text-center py-8 px-4",children:[(0,e.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-accent-50 text-accent-600 dark:bg-accent-900/30 dark:text-accent-300",children:(0,e.jsx)(y,{className:"w-7 h-7"})}),(0,e.jsx)("p",{className:"font-semibold text-foreground mb-1",children:c("timer.title")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-5 max-w-xs",children:c("timer.noTimers")}),(0,e.jsxs)("button",{type:"button","data-testid":"timer-empty-cta",onClick:()=>n(!0),className:"inline-flex items-center gap-1.5 px-5 py-2.5 text-sm font-semibold text-white bg-accent-600 hover:bg-accent-700 rounded-lg shadow-sm transition-colors",children:[(0,e.jsx)(dP,{className:"w-4 h-4"}),c("timer.createButton")]})]}):(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[z&&(0,e.jsx)("span",{className:"text-xs text-warning-foreground",children:c("timer.maxReached",{max:5})}),(0,e.jsxs)("button",{type:"button","data-testid":"timer-new-button",onClick:()=>n(!0),disabled:z,className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded transition-colors whitespace-nowrap",children:[(0,e.jsx)(dP,{className:"w-3.5 h-3.5"}),c("timer.newTimer")]})]}),g.map(a=>(0,e.jsxs)("div",{role:"button",tabIndex:0,"data-testid":"timer-row",onClick:()=>p(a),onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),p(a))},className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-surface text-left cursor-pointer hover:bg-muted transition-colors",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("div",{className:"text-sm text-foreground truncate",children:a.message.length>60?a.message.slice(0,60)+"...":a.message}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,e.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-medium",children:f.find(b=>b.id===a.instanceId)?.alias??a.cliToolId}),(0,e.jsx)("span",{className:function(a){switch(a){case"pending":return"text-info";case"sending":case"no_session":return"text-warning-foreground";case"sent":return"text-success-foreground";case"failed":return"text-danger-foreground";default:return"text-muted-foreground"}}(a.status),children:c(`timer.status.${a.status}`)}),"pending"===a.status&&(0,e.jsx)("span",{className:"text-muted-foreground",children:dV(a.scheduledSendTime)}),(0,e.jsx)("span",{className:"text-muted-foreground",children:dW(a.delayMs)})]})]}),"pending"===a.status&&(0,e.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation(),w(a.id)},className:"px-2 py-1 text-xs text-danger-foreground hover:bg-danger-subtle rounded transition-colors",children:c("timer.cancel")})]},a.id)),j&&(0,e.jsx)("button",{type:"button",onClick:v,className:"px-3 py-2 text-sm text-accent-600 dark:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/20 rounded-md transition-colors text-center",children:c("timer.loadMore")}),g.some(a=>"pending"!==a.status)&&(0,e.jsx)("button",{type:"button",onClick:x,className:"px-3 py-2 text-sm text-muted-foreground hover:bg-muted rounded-md transition-colors text-center",children:c("timer.clearHistory")})]}),(0,e.jsx)(dY,{isOpen:m,worktreeId:a,instances:b,onClose:()=>n(!1),onSaved:()=>{u()}}),(0,e.jsx)(d$,{timer:o,instances:f,onClose:()=>p(null)})]})});var d0=c(79944),d1=c(81136);let d2={verified:"skills.compatibility.axisOutcome.verified",unsupported:"skills.compatibility.axisOutcome.unsupported",unknown:"skills.compatibility.axisOutcome.unknown"},d3={mechanical:"skills.compatibility.evidenceKind.mechanical",self_report:"skills.compatibility.evidenceKind.selfReport",not_measured:"skills.compatibility.evidenceKind.notMeasured"},d4={outcome:"unknown",evidenceKind:"not_measured",labelKey:d2.unknown,evidenceKindKey:d3.not_measured,limitationKey:null},d5={SESSION_RESTART:"skills.compatibility.reload.sessionRestart",SESSION_RESTART_NO_SLASH:"skills.compatibility.reload.sessionRestartNoSlash",UNKNOWN:"skills.compatibility.reload.unknown"};function d6(a){return{agent:a,discoveryRoots:[],discovery:d4,invocation:d4,testedVersion:null,testedDate:null,evidenceSource:null,reloadKey:d5.UNKNOWN,skipReasonKey:"skills.compatibility.skipReason.notMeasured"}}d1.td,d2.verified,d3.mechanical,d2.verified,d3.mechanical,d5.SESSION_RESTART,d1.Co,d2.verified,d3.self_report,d2.unsupported,d3.mechanical,d5.SESSION_RESTART_NO_SLASH,d6("gemini"),d6("vibe-local"),d6("opencode"),d6("copilot"),d6("antigravity");let d7={SATISFIED:"SKILL_COMPAT_SATISFIED",HOST_VERSION_OUT_OF_RANGE:"SKILL_COMPAT_HOST_VERSION_OUT_OF_RANGE",HOST_VERSION_UNKNOWN:"SKILL_COMPAT_HOST_VERSION_UNKNOWN",RANGE_UNSUPPORTED:"SKILL_COMPAT_RANGE_UNSUPPORTED"};d7.SATISFIED,d7.HOST_VERSION_OUT_OF_RANGE,d7.HOST_VERSION_UNKNOWN,d7.RANGE_UNSUPPORTED;let d8={CONFIRMED:"SKILL_AGENT_EVIDENCE_CONFIRMED",RESTRICTED:"SKILL_AGENT_EVIDENCE_RESTRICTED",STALE_DECLARATION:"SKILL_AGENT_EVIDENCE_STALE_DECLARATION",UNVERIFIED:"SKILL_AGENT_EVIDENCE_UNVERIFIED"};d8.CONFIRMED,d8.RESTRICTED,d8.STALE_DECLARATION,d8.UNVERIFIED;let d9=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;function ea(a){if("string"!=typeof a||a.length>64)return null;let b=d9.exec(a);return b?{major:Number(b[1]),minor:Number(b[2]),patch:Number(b[3]),prerelease:b[4]?b[4].split("."):[],build:b[5]?b[5].split("."):[]}:null}let eb={UP_TO_DATE:"SKILL_UPDATE_UP_TO_DATE",HIGHEST_COMPATIBLE:"SKILL_UPDATE_RECOMMEND_HIGHEST_COMPATIBLE",LATEST_UNVERIFIED:"SKILL_UPDATE_RECOMMEND_LATEST_UNVERIFIED",NONE_COMPATIBLE:"SKILL_UPDATE_RECOMMEND_NONE_COMPATIBLE",INSTALLED_VERSION_INVALID:"SKILL_UPDATE_INSTALLED_VERSION_INVALID",RANGE_UNSUPPORTED:"SKILL_UPDATE_RANGE_UNSUPPORTED"};function ec(a,b){let c=function(a,b){let c=ea(a),d=ea(b);return c&&d?c.major!==d.major?c.major<d.major?-1:1:c.minor!==d.minor?c.minor<d.minor?-1:1:c.patch!==d.patch?c.patch<d.patch?-1:1:function(a,b){if(0===a.length&&0===b.length)return 0;if(0===a.length)return 1;if(0===b.length)return -1;let c=Math.min(a.length,b.length);for(let d=0;d<c;d++){let c=a[d],e=b[d];if(c===e)continue;let f=/^\d+$/.test(c),g=/^\d+$/.test(e);if(f&&g)return Number(c)<Number(e)?-1:1;if(f)return -1;if(g)return 1;return c<e?-1:1}return a.length===b.length?0:a.length<b.length?-1:1}(c.prerelease,d.prerelease):null}(a,b);return null!==c&&c>0}eb.UP_TO_DATE,eb.HIGHEST_COMPATIBLE,eb.LATEST_UNVERIFIED,eb.NONE_COMPATIBLE,eb.INSTALLED_VERSION_INVALID,eb.RANGE_UNSUPPORTED;var ed=c(28593),ee=c(9815),ef=c(3805),eg=c(27884),eh=c(30156);let ei={open:!1,selectedVersion:null,busy:!1,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applying:!1,applyResult:null,applyFailure:null};function ej({heading:a,paths:b,testid:c}){return 0===b.length?null:(0,e.jsxs)("div",{"data-testid":c,children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a}),(0,e.jsx)("ul",{className:"mt-1 space-y-0.5",children:b.map(a=>(0,e.jsx)("li",{className:"break-all font-mono text-xs text-foreground",children:a},a))})]})}function ek({skillId:a,skillName:b,worktreeId:c,installedVersion:d,versions:f}){let g=(0,k.c)("skills"),i=(0,h.useMemo)(()=>f.filter(a=>ec(a.version,d)),[f,d]),j=(0,h.useMemo)(()=>(i.find(a=>"compatible"===a.compatibility.commandmate.status)??i[0])?.version??null,[i]),[l,m]=(0,h.useState)(ei),o=(0,h.useCallback)(()=>{m({...ei,open:!0,selectedVersion:j})},[j]),p=(0,h.useCallback)(()=>{m(ei)},[]),q=(0,h.useCallback)(async()=>{let b=l.selectedVersion;if(!b)return;m(a=>({...a,busy:!0,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applyResult:null,applyFailure:null}));let d=await (0,eh.Sw)(c,a,{version:b});m(a=>({...a,busy:!1,plan:d.ok?d.data.plan:null,failure:d.ok?null:d.failure}))},[a,l.selectedVersion,c]),r=(0,h.useCallback)(async()=>{var b;let d=l.plan;if(!d||!d.updatable)return;m(a=>({...a,applying:!0,applyFailure:null}));let e=await (0,eh.h2)(c,a,{planToken:d.token,version:d.update.toVersion,acknowledgeRisk:l.riskAcknowledged,acknowledgeRiskIncrease:l.riskIncreaseAcknowledged,idempotencyKey:(b=d.token,`skill-update-${b}`)});m(a=>({...a,applying:!1,applyResult:e.ok?e.data:null,applyFailure:e.ok?null:e.failure}))},[a,l.plan,l.riskAcknowledged,l.riskIncreaseAcknowledged,c]);if(0===i.length)return(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-uptodate",children:g("update.upToDate",{version:d})});let s=l.plan,t=l.applyResult;return(0,e.jsxs)("div",{"data-testid":"skill-update-dialog-host",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(n.Ex,{variant:"info","data-testid":"skill-update-badge",children:g("update.badge")}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:g("update.fromTo",{from:d,to:i[0].version})}),(0,e.jsx)(n.$n,{variant:"secondary",size:"sm",onClick:o,"data-testid":"skill-update-trigger",children:g("update.open")})]}),(0,e.jsx)(n.Jh,{isOpen:l.open,onClose:p,title:g("update.heading"),size:"lg",children:(0,e.jsxs)("div",{className:"space-y-3 p-4","data-testid":"skill-update-dialog",children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:g("update.intro",{skill:b,version:d})}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:g("update.ready")}),(0,e.jsxs)("label",{className:"block text-xs font-medium text-muted-foreground",children:[g("update.versionPicker"),(0,e.jsx)("select",{className:"w-full rounded-md border border-input bg-surface px-3 py-2 text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring mt-1",value:l.selectedVersion??"",onChange:a=>m(b=>({...b,selectedVersion:a.target.value,plan:null,failure:null})),disabled:l.busy,"data-testid":"skill-update-version-select",children:i.map(a=>(0,e.jsxs)("option",{value:a.version,children:[a.version,a.prerelease?` (${g("detail.prerelease")})`:"","compatible"!==a.compatibility.commandmate.status?` — ${g(eg.OV[a.compatibility.commandmate.status])}`:""]},a.version))})]}),(0,e.jsx)(n.$n,{variant:"primary",disabled:l.busy||!l.selectedVersion,onClick:q,"data-testid":"skill-update-build",children:l.busy?g("update.building"):g("update.build")}),l.failure&&(0,e.jsxs)(ef.u,{tone:"danger","data-testid":"skill-update-error",children:[(0,e.jsx)("p",{children:g((0,eg.FW)(l.failure.code))}),(0,e.jsx)("p",{className:"mt-1 break-words",children:g("state.errorCode",{code:l.failure.code})})]}),s&&(0,e.jsxs)("div",{className:"space-y-3","data-testid":"skill-update-plan",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"text-sm font-semibold text-foreground",children:g("update.fromTo",{from:s.update.fromVersion,to:s.update.toVersion})}),null!==s.update.latestVersion&&s.update.latestVersion!==s.update.toVersion&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:g("update.latestAvailable",{version:s.update.latestVersion})})]}),(0,e.jsx)(ef.u,{tone:s.updatable?"info":"warning","data-testid":"skill-update-next-action",children:g((0,eg.e5)(s.nextActionKey))}),s.blockers.length>0&&(0,e.jsx)("ul",{className:"space-y-1","data-testid":"skill-update-blockers",children:s.blockers.map(a=>(0,e.jsxs)("li",{className:"text-xs text-danger-foreground",children:[a.path&&(0,e.jsx)("span",{className:"mr-1 break-all font-mono",children:a.path}),g((0,eg.e5)(a.messageKey))]},`${a.code}:${a.path??""}`))}),(0,e.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-risk",children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g("plan.riskHeading")}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-foreground",children:[(0,e.jsx)(ed.qW,{risk:s.securityDiff.risk.from.effective}),(0,e.jsx)("span",{"aria-hidden":"true",children:"→"}),(0,e.jsx)(ed.qW,{risk:s.securityDiff.risk.to.effective})]}),s.riskIncreased&&s.riskIncreaseMessageKey&&(0,e.jsx)(ef.u,{tone:"danger","data-testid":"skill-update-risk-increase",children:g((0,eg.e5)(s.riskIncreaseMessageKey))}),s.requiresRiskAcknowledgement&&s.riskAcknowledgementMessageKey&&(0,e.jsx)(ef.u,{tone:"warning","data-testid":"skill-update-high-risk",children:g((0,eg.e5)(s.riskAcknowledgementMessageKey))}),s.updatable&&!l.applyResult&&s.requiresRiskAcknowledgement&&(0,e.jsxs)("label",{className:"flex items-start gap-2 text-xs text-foreground",children:[(0,e.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:l.riskAcknowledged,onChange:a=>m(b=>({...b,riskAcknowledged:a.target.checked})),"data-testid":"skill-update-ack-risk"}),g("update.ackRisk")]}),s.updatable&&!l.applyResult&&s.riskIncreased&&(0,e.jsxs)("label",{className:"flex items-start gap-2 text-xs text-foreground",children:[(0,e.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:l.riskIncreaseAcknowledged,onChange:a=>m(b=>({...b,riskIncreaseAcknowledged:a.target.checked})),"data-testid":"skill-update-ack-risk-increase"}),g("update.ackRiskIncrease")]})]}),(0,e.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-security-diff",children:[s.securityDiff.permissions.added.length>0&&(0,e.jsxs)("div",{"data-testid":"skill-update-permissions-added",children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g("update.permissionsAdded")}),(0,e.jsx)("ul",{className:"mt-1 space-y-0.5",children:s.securityDiff.permissions.added.map(a=>(0,e.jsx)("li",{className:"text-xs text-foreground",children:g(eg.z2[a]??"plan.permissionsNone")},a))})]}),s.securityDiff.permissions.removed.length>0&&(0,e.jsxs)("div",{"data-testid":"skill-update-permissions-removed",children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g("update.permissionsRemoved")}),(0,e.jsx)("ul",{className:"mt-1 space-y-0.5",children:s.securityDiff.permissions.removed.map(a=>(0,e.jsx)("li",{className:"text-xs text-foreground",children:g(eg.z2[a]??"plan.permissionsNone")},a))})]}),(0,e.jsx)(ej,{heading:g("update.scriptsAdded"),paths:s.securityDiff.scripts.added,testid:"skill-update-scripts-added"}),(0,e.jsx)(ej,{heading:g("update.scriptsRemoved"),paths:s.securityDiff.scripts.removed,testid:"skill-update-scripts-removed"}),(0,e.jsx)(ej,{heading:g("update.executablesAdded"),paths:s.securityDiff.executables.added,testid:"skill-update-executables-added"}),(0,e.jsx)(ej,{heading:g("update.executablesRemoved"),paths:s.securityDiff.executables.removed,testid:"skill-update-executables-removed"})]}),s.securityDiff.changelogs.length>0&&(0,e.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-changelogs",children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g("detail.changelogHeading")}),s.securityDiff.changelogs.map(a=>(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-foreground",children:a.version}),(0,e.jsx)("p",{className:"whitespace-pre-wrap text-xs text-muted-foreground",children:a.changelog})]},a.version))]}),(0,e.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-files",children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g("update.filesHeading")}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-stats",children:g("update.stats",{added:s.stats.added,updated:s.stats.updated,removed:s.stats.removed,unchanged:s.stats.unchanged})}),(0,e.jsx)("ul",{className:"space-y-1",children:s.files.filter(a=>"unchanged"!==a.change).map(a=>(0,e.jsxs)("li",{"data-testid":"skill-update-file",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(n.Ex,{variant:eg.JD[a.change]??"gray",children:g(eg.KS[a.change]??"update.change.update")}),(0,e.jsx)("span",{className:"break-all font-mono text-xs text-foreground",children:a.path})]}),a.diff&&(0,e.jsxs)("details",{className:"mt-1",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:g("update.showDiff")}),(0,e.jsx)("pre",{className:"mt-1 overflow-x-auto rounded-md bg-muted p-2 text-xs text-foreground",children:a.diff})]})]},a.path))})]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-expiry",children:g("plan.expiresAt",{timestamp:s.expiresAt})}),s.updatable&&!l.applyResult&&(0,e.jsx)(n.$n,{variant:"primary",disabled:l.applying||s.requiresRiskAcknowledgement&&!l.riskAcknowledged||s.riskIncreased&&!l.riskIncreaseAcknowledged,onClick:r,"data-testid":"skill-update-apply",children:l.applying?g("update.applying"):g("update.apply")}),l.applyFailure&&(0,e.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-apply-error",children:[(0,e.jsxs)(ef.u,{tone:"danger",children:[(0,e.jsx)("p",{children:g((0,eg.FW)(l.applyFailure.code))}),(0,e.jsx)("p",{className:"mt-1 break-words",children:g("state.errorCode",{code:l.applyFailure.code})})]}),l.applyFailure.nextActionKey&&(0,e.jsx)(ef.u,{tone:"warning",children:g((0,eg.e5)(l.applyFailure.nextActionKey))}),l.applyFailure.blockers&&l.applyFailure.blockers.length>0&&(0,e.jsx)("ul",{className:"space-y-1","data-testid":"skill-update-apply-error-blockers",children:l.applyFailure.blockers.map(a=>(0,e.jsxs)("li",{className:"text-xs text-danger-foreground",children:[a.path&&(0,e.jsx)("span",{className:"mr-1 break-all font-mono",children:a.path}),g((0,eg.e5)(a.messageKey))]},`${a.code}:${a.path??""}`))})]})]}),t&&(0,e.jsxs)("div",{className:"space-y-3","data-testid":"skill-update-result",children:[(0,e.jsx)(ef.u,{tone:"succeeded"===t.operation.result?"info":"warning","data-testid":"skill-update-result-next-action",children:g((0,eg.e5)(t.operation.nextActionKey))}),"reload"in t&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-sm font-semibold text-foreground",children:g("update.fromTo",{from:t.update.fromVersion,to:t.update.toVersion})}),(0,e.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-result-reload",children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g("operation.reloadHeading")}),(0,e.jsx)("ul",{className:"space-y-1",children:t.reload.agents.map(a=>(0,e.jsx)("li",{className:"text-xs text-muted-foreground",children:g((0,eg.e5)(a.messageKey),{agent:(0,be.f_)(a.agent),skillId:t.reload.skillId,version:t.reload.version})},a.agent))})]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-result-rollback",children:g((0,eg.e5)(t.rollback.messageKey),{version:t.rollback.backup.fromVersion})})]})]})]})})]})}let el={status:"loading",skills:[],failure:null},em={status:"loading",skills:[],failure:null};function en({worktreeId:a,className:b=""}){let c=(0,k.c)("skills"),[d,f]=(0,h.useState)(el),[g,i]=(0,h.useState)(em),[j,l]=(0,h.useState)(null),[m,o]=(0,h.useState)(0),[p,q]=(0,h.useState)(0),r=(0,h.useMemo)(()=>new Set(g.skills.map(a=>a.skillId)),[g.skills]),s=(0,h.useMemo)(()=>new Map(d.skills.map(a=>[a.id,{name:a.name,summary:a.summary,latest:a.latest}])),[d.skills]),t=(0,h.useMemo)(()=>d.skills.find(a=>a.id===j)??null,[d.skills,j]),u=(0,h.useMemo)(()=>g.skills.find(a=>a.skillId===j)??null,[g.skills,j]);if(j){let d=t?.compatibility??null,f=t?t.recommendedVersion:u?.version??null,g=t?t.recommendedVersion?d&&"compatible"!==d.status?c("detail.install.blockedIncompatible",{reason:c((0,eg.e5)(d.messageKey),{range:d.requiredRange,currentVersion:d.currentVersion??""})}):null:c("detail.install.blockedNoVersion"):null;return(0,e.jsxs)("div",{className:`flex flex-col min-h-0 ${b}`.trim(),"data-testid":"worktree-skills-pane",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 border-b border-border p-3",children:[(0,e.jsxs)(n.$n,{variant:"ghost",size:"sm",onClick:()=>{l(null),q(a=>a+1)},"data-testid":"worktree-skills-back",children:[(0,e.jsx)(d0.A,{size:14,"aria-hidden":"true",className:"mr-1"}),c("worktreePane.back")]}),(0,e.jsx)("h2",{className:"min-w-0 truncate text-sm font-semibold text-foreground",children:t?.name??j})]}),(0,e.jsxs)("div",{className:"min-h-0 flex-1 space-y-3 overflow-auto p-3",children:[u&&t&&(0,e.jsx)(ek,{skillId:j,skillName:t.name,worktreeId:a,installedVersion:u.version,versions:t.versions}),(0,e.jsx)(ee.B,{skillId:j,version:f,blockedReason:g,worktreeId:a})]})]})}return(0,e.jsx)("div",{className:`flex flex-col min-h-0 ${b}`.trim(),"data-testid":"worktree-skills-pane",children:(0,e.jsxs)("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-3",children:[(0,e.jsxs)("section",{className:"space-y-2","data-testid":"worktree-skills-installed",children:[(0,e.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:c("worktreePane.installedHeading")}),"loading"===g.status?(0,e.jsx)(n.EA,{className:"h-16 w-full rounded-lg","data-testid":"worktree-skills-installed-loading"}):"error"===g.status?(0,e.jsxs)(n.Zp,{className:"space-y-2","data-testid":"worktree-skills-installed-error",children:[(0,e.jsxs)(ef.u,{tone:"danger",children:[(0,e.jsx)("p",{children:c("worktreePane.installedError")}),(0,e.jsx)("p",{className:"mt-1 break-words",children:c("state.errorCode",{code:g.failure?.code??""})})]}),(0,e.jsx)(n.$n,{variant:"secondary",size:"sm",onClick:()=>q(a=>a+1),"data-testid":"worktree-skills-installed-retry",children:c("state.retry")})]}):0===g.skills.length?(0,e.jsx)(n.Zp,{"data-testid":"worktree-skills-installed-empty",children:(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:c("worktreePane.installedEmpty")})}):(0,e.jsx)("ul",{className:"space-y-2",children:g.skills.map(a=>{var b,d;let f=s.get(a.skillId);return(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",onClick:()=>l(a.skillId),"data-testid":`worktree-skills-installed-${a.skillId}`,className:"w-full rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"break-all text-sm font-semibold text-foreground",children:f?.name??a.skillId}),(0,e.jsx)(ed.qW,{risk:a.effectiveRisk}),(b=a.version,d=f?.latest??null,null!==b&&null!==d&&ec(d,b)&&(0,e.jsx)(n.Ex,{variant:"info","data-testid":`worktree-skills-update-badge-${a.skillId}`,children:c("worktreePane.updateBadge")}))]}),f?.summary&&(0,e.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground line-clamp-2","data-testid":`worktree-skills-installed-summary-${a.skillId}`,children:f.summary}),(0,e.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:c("worktreePane.version",{version:a.version})})]})},a.skillId)})})]}),(0,e.jsxs)("section",{className:"space-y-2","data-testid":"worktree-skills-catalog",children:[(0,e.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:c("worktreePane.catalogHeading")}),"loading"===d.status?(0,e.jsx)(n.EA,{className:"h-24 w-full rounded-lg","data-testid":"worktree-skills-catalog-loading"}):"error"===d.status?(0,e.jsxs)(n.Zp,{className:"space-y-2","data-testid":"worktree-skills-catalog-error",children:[(0,e.jsxs)(ef.u,{tone:"danger",children:[(0,e.jsx)("p",{children:c("state.errorNotice")}),(0,e.jsx)("p",{className:"mt-1 break-words",children:c("state.errorCode",{code:d.failure?.code??""})})]}),(0,e.jsx)(n.$n,{variant:"secondary",size:"sm",onClick:()=>o(a=>a+1),"data-testid":"worktree-skills-catalog-retry",children:c("state.retry")})]}):0===d.skills.length?(0,e.jsx)(n.Zp,{"data-testid":"worktree-skills-catalog-empty",children:(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:c("state.empty")})}):(0,e.jsx)("ul",{className:"space-y-2",children:d.skills.map(a=>{let b=(0,eg.gh)(a);return(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",onClick:()=>l(a.id),"data-testid":`worktree-skills-catalog-${a.id}`,className:"w-full rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"min-w-0 break-all text-sm font-semibold text-foreground",children:a.name}),r.has(a.id)&&(0,e.jsx)(n.Ex,{variant:"info","data-testid":`worktree-skills-installed-badge-${a.id}`,children:c("worktreePane.installedBadge")})]}),(0,e.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:c("card.provider",{provider:a.provider.name})}),a.summary&&(0,e.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2","data-testid":`worktree-skills-catalog-summary-${a.id}`,children:a.summary}),(0,e.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[a.compatibility&&(0,e.jsx)(ed.Xz,{status:a.compatibility.status}),b&&(0,e.jsx)(ed.qW,{risk:b})]})]})},a.id)})})]})]})})}let eo=[{id:"notes",labelKey:"notes"},{id:"logs",labelKey:"logs"},{id:"agent",labelKey:"agentTab"},{id:"timer",labelKey:"timerTab"},{id:"todo",labelKey:"todoTab"},{id:"skills",labelKey:"skillsTab"}],ep=(0,h.memo)(function({worktreeId:a,className:b="",selectedAgents:c,onSelectedAgentsChange:d,vibeLocalModel:f,onVibeLocalModelChange:g,vibeLocalContextWindow:i,onVibeLocalContextWindowChange:j,maxAgents:l,availableAgents:m,persistToServer:n,onInsertToMessage:o,useInstanceManagement:p=!1,instances:q,onInstancesChange:r,visibleInstanceIds:s,onToggleInstanceVisible:t}){let u=(0,k.c)("schedule"),[v,w]=(0,h.useState)("notes"),x=(0,h.useCallback)(a=>{w(a)},[]);return(0,e.jsxs)("div",{className:`flex flex-col h-full ${b}`,children:[(0,e.jsx)("div",{className:"flex overflow-x-auto scrollbar-hide border-b border-border bg-surface dark:bg-surface-2 flex-shrink-0",children:eo.map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>x(a.id),className:`flex-shrink-0 whitespace-nowrap px-3 py-2 text-sm font-medium transition-colors ${v===a.id?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:u(a.labelKey)},a.id))}),(0,e.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["notes"===v&&(0,e.jsx)(db,{worktreeId:a,className:"h-full",onInsertToMessage:o}),"logs"===v&&(0,e.jsx)(dJ,{worktreeId:a,className:"h-full",onInsertToMessage:o,instances:q}),"agent"===v&&(p&&q&&r&&s&&t?(0,e.jsx)("div",{className:"h-full overflow-y-auto",children:(0,e.jsx)(dR,{worktreeId:a,instances:q,onInstancesChange:r,vibeLocalModel:f,onVibeLocalModelChange:g,vibeLocalContextWindow:i,onVibeLocalContextWindowChange:j,visibleInstanceIds:s,onToggleInstanceVisible:t})}):(0,e.jsx)(dL,{worktreeId:a,selectedAgents:c,onSelectedAgentsChange:d,vibeLocalModel:f,onVibeLocalModelChange:g,vibeLocalContextWindow:i,onVibeLocalContextWindowChange:j,maxAgents:l,availableAgents:m,persistToServer:n})),"timer"===v&&(0,e.jsx)(d_,{worktreeId:a,instances:q,selectedAgents:c}),"todo"===v&&(0,e.jsx)(dg,{worktreeId:a,className:"h-full"}),"skills"===v&&(0,e.jsx)(en,{worktreeId:a,className:"h-full"})]})]})});var eq=c(53237);let er=["status","changes","history","advanced"],es="commandmate:gitPane:",et={activeTab:`${es}activeTab`,historyOpen:`${es}historyOpen`,advancedOpen:`${es}advancedOpen`};function eu(a){return"string"==typeof a&&er.includes(a)}let ev=a=>"boolean"==typeof a,ew=h.useEffect,ex=(0,h.memo)(function({branches:a,busy:b,actionError:c,hasRunningSession:d,isMobile:f,onCheckout:g}){let i=(0,k.c)("worktree"),j=(0,k.c)("common"),[l,m]=(0,h.useState)(!1),[o,p]=(0,h.useState)(null),[q,r]=(0,h.useState)(!1),s=(0,h.useRef)(null),t=(0,h.useRef)(null),[u,v]=(0,h.useState)(null),w=a.filter(a=>!a.isCurrent),x=(0,h.useCallback)(()=>{s.current,t.current},[]);ew(()=>l?(x(),window.addEventListener("resize",x),window.addEventListener("scroll",x,!0),()=>{window.removeEventListener("resize",x),window.removeEventListener("scroll",x,!0)}):void v(null),[l,w.length,x]);let y=(0,h.useCallback)(a=>{r(!1),p({...a}),m(!1)},[]),z=(0,h.useCallback)(()=>{o&&(g(o,q),p(null))},[o,q,g]);return(0,e.jsxs)("div",{className:"relative",ref:s,"data-testid":"branch-checkout-dropdown",children:[(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:()=>m(a=>!a),disabled:b||0===w.length,className:"flex items-center gap-1 px-2 py-1 text-xs rounded border border-input text-accent-700 dark:text-accent-300 hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"branch-checkout-dropdown-toggle","aria-haspopup":"menu","aria-expanded":l,"aria-label":i("git.checkout.ariaLabel"),children:[i("git.checkout.action"),(0,e.jsx)("span",{"aria-hidden":"true",className:"text-[10px]",children:"▾"})]}),l&&"undefined"!=typeof document&&(0,bG.createPortal)((0,e.jsx)("div",{ref:t,className:"fixed z-50 min-w-[12rem] max-w-[calc(100vw-1rem)] max-h-64 overflow-y-auto rounded border border-border bg-surface shadow-lg",style:{top:u?.top??-9999,left:u?.left??-9999},role:"menu","data-testid":"branch-checkout-menu",children:0===w.length?(0,e.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:i("git.checkout.noBranches")}):(0,e.jsx)("ul",{className:"divide-y divide-border",children:w.map(a=>{let c=null!==a.checkedOutWorktreePath;return(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>y(a),disabled:b||c,className:"w-full text-left px-3 py-1.5 font-mono text-xs text-foreground hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","aria-label":i("git.checkout.checkoutBranch",{name:a.name}),title:c?i("git.checkout.checkedOutElsewhere",{path:a.checkedOutWorktreePath??""}):void 0,children:[a.name,a.isDefault&&(0,e.jsx)("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:i("git.checkout.defaultBadge")})]})},`${a.isRemote?"r":"l"}:${a.name}`)})})}),document.body),c&&(0,e.jsx)("div",{className:"mt-1 text-xs text-danger-foreground",role:"alert","data-testid":"branch-checkout-error",children:c}),o&&(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-checkout-confirm",children:(0,e.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,e.jsxs)("h3",{className:"text-sm font-medium text-foreground",children:[i("git.checkout.confirmTitlePrefix"),(0,e.jsx)("span",{className:"font-mono",children:o.name}),i("git.checkout.confirmTitleSuffix")]}),(0,e.jsx)("div",{className:"rounded border border-warning-border bg-warning-subtle px-3 py-2 text-xs text-warning-foreground",role:"alert","data-testid":"branch-history-loss-warning",children:i("git.checkout.historyLossWarning")}),d&&(0,e.jsx)("div",{className:"rounded border border-danger-border bg-danger-subtle px-3 py-2 text-xs text-danger-foreground",role:"alert","data-testid":"branch-session-warning",children:i("git.checkout.runningSessionWarning")}),(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(n.Sc,{checked:q,onCheckedChange:a=>r(!0===a),"data-testid":"branch-checkout-force"}),i("git.checkout.forceLabel")]}),(0,e.jsxs)("div",{className:`flex items-center justify-end gap-2 ${f?"flex-wrap":""}`,children:[(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:()=>p(null),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:j("cancel")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:z,disabled:b,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50","data-testid":"branch-checkout-confirm-button",children:i("git.checkout.action")})]})]})})]})}),ey=(0,h.memo)(function({open:a,onToggle:b,children:c}){let d=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"flex flex-col border-t border-border","data-testid":"git-advanced-section",children:[(0,e.jsxs)("button",{type:"button",onClick:b,className:"w-full flex items-center gap-1 px-3 py-2 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground","data-testid":"git-advanced-toggle","aria-expanded":a,children:[(0,e.jsx)("span",{className:"text-xs w-4 text-center",children:a?"▼":"▶"}),d("git.advancedOperations")]}),a&&(0,e.jsx)("div",{className:"flex flex-col","data-testid":"git-advanced-content",children:c})]})}),ez=(0,h.createContext)(null);function eA({value:a,children:b}){return(0,e.jsx)(ez.Provider,{value:a,children:b})}function eB(){let a=(0,h.useContext)(ez);if(null===a)throw Error("useGitPaneContext must be used within a GitPaneProvider");return a}let eC=(0,h.memo)(function({path:a}){return(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:a})})}),eD={status:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",changes:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",history:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z",advanced:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"},eE={status:"git.tabs.status",changes:"git.tabs.changes",history:"git.tabs.history",advanced:"git.tabs.advanced"},eF=(0,h.memo)(function({activeTab:a,onTabChange:b}){let c=(0,k.c)("worktree");return(0,e.jsx)("div",{role:"tablist","aria-label":c("git.paneSections"),"data-testid":"git-pane-mobile-tabs",className:"flex shrink-0 border-b border-border bg-surface sticky top-0 z-30",children:er.map(d=>{let f=d===a,g=c(eE[d]);return(0,e.jsxs)("button",{type:"button",role:"tab","aria-selected":f,"aria-label":g,"data-testid":`git-tab-${d}`,onClick:()=>b(d),className:`flex flex-1 flex-col items-center justify-center gap-1 py-2 px-1 text-xs transition-colors border-b-2 ${f?"text-accent-600 dark:text-accent-400 border-accent-500 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground border-transparent hover:text-foreground hover:bg-muted"}`,children:[(0,e.jsx)(eC,{path:eD[d]}),(0,e.jsx)("span",{children:g})]},d)})})});function eG({activeTab:a,onTabChange:b,className:c="",statusSection:d,quickActionsSection:f,changesSection:g,historySection:h,advancedSection:i}){let{isMobile:j}=eB();return j?(0,e.jsxs)("div",{className:`flex flex-col overflow-hidden ${c}`,"data-testid":"git-pane-mobile",children:[(0,e.jsx)(eF,{activeTab:a,onTabChange:b}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col min-h-0","data-testid":"git-pane-mobile-panel","data-active-tab":a,children:["status"===a&&(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0",children:[d,f]}),"changes"===a&&(0,e.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:g}),"history"===a&&h,"advanced"===a&&(0,e.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:i})]})]}):(0,e.jsxs)("div",{className:`flex flex-col overflow-hidden ${c}`,"data-testid":"git-pane-desktop",children:[(0,e.jsx)("div",{"data-testid":"git-group-read","data-git-group":"read",className:"border-l-2 border-info-border bg-info-subtle",children:d}),(0,e.jsxs)("div",{"data-testid":"git-group-write","data-git-group":"write",className:"border-l-2 border-input bg-muted/70 dark:bg-muted/30",children:[f,g]}),(0,e.jsx)("div",{"data-testid":"git-group-history","data-git-group":"read",className:"flex-1 flex flex-col min-h-0 border-l-2 border-info-border bg-info-subtle",children:h}),(0,e.jsx)("div",{"data-testid":"git-group-advanced","data-git-group":"advanced",className:"border-l-2 border-t-2 border-input bg-muted/50 dark:bg-muted/40",children:i})]})}let eH={added:"text-success-foreground",modified:"text-warning-foreground",deleted:"text-danger-foreground",renamed:"text-info",untracked:"text-teal-600 dark:text-teal-400",unmerged:"text-warning-foreground"},eI=(0,h.memo)(function(){return(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:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),eJ=(0,h.memo)(function({onClick:a,disabled:b=!1,testId:c,className:d=""}){let f=(0,k.c)("worktree");return(0,e.jsxs)("button",{type:"button",disabled:b,onClick:a,className:`inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-info-border text-info-foreground hover:bg-info-subtle disabled:opacity-50 disabled:cursor-not-allowed ${d}`,"data-testid":c,title:f("git.askAiTooltip"),children:[(0,e.jsx)(dh.A,{size:14,"aria-hidden":"true"}),f("git.askAi")]})}),eK=(0,h.memo)(function({line:a}){let b="whitespace-pre font-mono text-xs";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":b+=" text-foreground",(0,e.jsx)("div",{className:b,children:a})}),eL=(0,h.memo)(function({message:a}){return(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-danger-foreground",role:"alert",children:a})}),eM={no_upstream:{badgeKey:"git.currentStatus.noUpstreamBadge",tooltipKey:"git.currentStatus.noUpstreamTooltip"},upstream_gone:{badgeKey:"git.currentStatus.upstreamGoneBadge",tooltipKey:"git.currentStatus.upstreamGoneTooltip"},detached:{badgeKey:"git.currentStatus.detachedBadge",tooltipKey:"git.currentStatus.detachedTooltip"},error:{badgeKey:"git.currentStatus.aheadBehindErrorBadge",tooltipKey:"git.currentStatus.aheadBehindErrorTooltip"}},eN=(0,h.memo)(function({gitStatus:a,statusLoading:b,statusError:c,onRefresh:d,refreshing:f=!1}){let{isMobile:g}=eB(),i=(0,k.c)("worktree"),j=(0,b3.Ym)(),l=(0,h.useMemo)(()=>{let b=a?.lastFetchAt;if(null==b)return i("git.currentStatus.lastFetchNever");let c=(0,cg.fw)(new Date(b).toISOString(),cf(j));return c?i("git.currentStatus.lastFetch",{relative:c}):i("git.currentStatus.lastFetchNever")},[a?.lastFetchAt,j,i]),n=a&&!a.aheadBehind?a.aheadBehindReason??null:null;return(0,e.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-status-section",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:i("git.currentStatus.title")}),(0,e.jsx)("button",{type:"button",onClick:d,disabled:f,className:"p-1 text-muted-foreground hover:text-foreground rounded disabled:opacity-50","aria-label":f?i("git.currentStatus.refreshing"):i("git.currentStatus.refresh"),"aria-busy":f,"data-testid":"git-status-refresh-button",children:f?(0,e.jsx)(m.y,{size:"sm",variant:"accent"}):(0,e.jsx)(eI,{})})]}),b&&!a&&(0,e.jsxs)("div",{className:"flex items-center gap-2 py-1",role:"status",children:[(0,e.jsx)(m.y,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:i("git.currentStatus.loading")})]}),c&&!a&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-status-error",children:c}),a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:`flex items-center flex-wrap ${g?"gap-1.5":"gap-2"}`,children:[(0,e.jsx)("span",{className:"inline-flex items-center max-w-full truncate rounded px-2 py-0.5 text-xs font-mono bg-accent-50 text-accent-700 dark:bg-accent-900/30 dark:text-accent-300","data-testid":"git-status-branch-chip",title:a.currentBranch,children:a.currentBranch}),a.isDirty&&(0,e.jsx)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium bg-warning-subtle text-warning-foreground","data-testid":"git-status-dirty-badge",children:i("git.currentStatus.uncommitted")}),a.aheadBehind&&(0,e.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs font-mono bg-muted text-foreground","data-testid":"git-status-ahead-behind",children:[(0,e.jsxs)("span",{title:i("git.currentStatus.aheadTooltip"),children:["↑",a.aheadBehind.ahead]}),(0,e.jsxs)("span",{title:i("git.currentStatus.behindTooltip"),children:["↓",a.aheadBehind.behind]})]}),n&&(0,e.jsx)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium bg-muted text-muted-foreground border border-border","data-testid":"git-status-ahead-behind-reason","data-reason":n,title:i(eM[n].tooltipKey),children:i(eM[n].badgeKey)})]}),(0,e.jsx)("div",{className:"text-[11px] text-muted-foreground","data-testid":"git-status-last-fetch",title:i("git.currentStatus.lastFetchTooltip"),children:l}),a.isBranchMismatch&&(0,e.jsxs)("div",{className:"flex items-center gap-1.5 rounded px-2 py-1 text-xs bg-warning-subtle text-warning-foreground border border-warning-border",role:"alert","data-testid":"git-status-mismatch-warning",children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"⚠"}),(0,e.jsxs)("span",{children:[i("branchMismatch.changedFrom")," ",(0,e.jsx)("span",{className:"font-medium",children:a.initialBranch})," ",i("branchMismatch.to")," ",(0,e.jsx)("span",{className:"font-medium",children:a.currentBranch})]})]})]})]})}),eO=(0,h.memo)(function({progressState:a,operation:b,error:c,conflict:d,conflictFiles:f,hasUpstream:g,onFetch:i,onPull:j,onPush:l,onAbort:n,extraActions:o}){let{isMobile:p}=eB(),q=(0,k.c)("worktree"),r="running"===a,s=c??q("git.network.failed"),[t,u]=(0,h.useState)(0);return(0,h.useEffect)(()=>{if(!r)return void u(0);let a=setInterval(()=>u(a=>a+1),1e3);return()=>clearInterval(a)},[r]),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-network-section",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:q("git.network.quickActions")}),(0,e.jsxs)("div",{className:`flex items-center ${p?"flex-wrap gap-1.5":"gap-2"}`,children:[i&&(0,e.jsx)("button",{type:"button",onClick:i,disabled:r,className:"px-2 py-1 text-xs rounded border border-border text-foreground hover:bg-muted disabled:opacity-50","data-testid":"git-fetch-button",children:q("git.network.fetch")}),(0,e.jsx)("button",{type:"button",onClick:j,disabled:r,className:"px-2 py-1 text-xs rounded border border-accent-300 dark:border-accent-700 text-accent-700 dark:text-accent-300 hover:bg-accent-50 dark:hover:bg-accent-900/30 disabled:opacity-50","data-testid":"git-pull-button",children:q("git.network.pull")}),(0,e.jsx)("button",{type:"button",onClick:l,disabled:r,className:"px-2 py-1 text-xs rounded border border-success-border text-success-foreground hover:bg-success-subtle disabled:opacity-50","data-testid":"git-push-button",title:g?void 0:q("git.network.noUpstreamTooltip"),children:q("git.network.push")}),o]}),r&&(0,e.jsxs)("div",{className:`flex items-center gap-2 rounded px-2 py-1 text-xs bg-accent-50 text-accent-800 dark:bg-accent-900/20 dark:text-accent-300 ${p?"sticky top-0 z-40":""}`,"data-testid":"git-network-progress-bar",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2",role:"status","data-testid":"git-network-operation-spinner",children:[(0,e.jsx)(m.y,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{children:q("git.network.progress",{operation:q("push"===b?"git.network.pushing":"pull"===b?"git.network.pulling":"git.network.fetching"),elapsed:t})})]}),(0,e.jsx)("button",{type:"button",onClick:n,className:"ml-auto px-1.5 py-0.5 rounded border border-accent-400 dark:border-accent-600 hover:bg-accent-100 dark:hover:bg-accent-900/40","data-testid":"git-network-abort-button",children:q("git.network.abort")})]}),"error"===a&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-network-operation-error",children:s}),d&&(0,e.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-network-conflict",children:q("git.network.conflicts",{files:f.join(", ")})})]})}),eP=(0,h.memo)(function({title:a,testId:b,files:c,actionLabel:d,mode:f,defaultOpen:g,busy:i,onDiff:j,onToggleStage:l,onPreview:m}){let o=(0,k.c)("worktree"),[p,q]=(0,h.useState)(g),[r,s]=(0,h.useState)(null),[t,u]=(0,h.useState)(null),[v,w]=(0,h.useState)(!1),[x,y]=(0,h.useState)(null),z=(0,h.useCallback)(async a=>{if(r===a){s(null),u(null),y(null);return}s(a),u(null),y(null),w(!0);try{let b=await m(a,f);u(b??"")}catch{y(o("git.changes.previewFailed"))}finally{w(!1)}},[r,m,f,o]);return(0,e.jsxs)("div",{className:"border-t border-border","data-testid":b,children:[(0,e.jsxs)("button",{type:"button",onClick:()=>q(a=>!a),className:"w-full flex items-center gap-1 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground",children:[(0,e.jsx)("span",{className:"w-4 text-center",children:p?"▼":"▶"}),o("git.changes.listHeader",{title:a,count:c.length})]}),p&&0===c.length&&(0,e.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:o("git.changes.empty")}),p&&c.length>0&&(0,e.jsx)("ul",{className:"divide-y divide-border",children:c.map(a=>{let b=r===a.path;return(0,e.jsxs)("li",{className:"flex flex-col",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[(0,e.jsx)("span",{className:`inline-block w-16 shrink-0 text-xs font-medium ${eH[a.status]}`,children:a.status}),(0,e.jsx)("span",{className:"flex-1 truncate font-mono text-xs text-foreground",title:a.path,children:a.path}),(0,e.jsx)("button",{type:"button",onClick:()=>z(a.path),className:"shrink-0 w-5 text-center text-xs text-muted-foreground hover:text-foreground","aria-label":o("git.changes.togglePreview",{path:a.path}),"aria-expanded":b,"data-testid":"git-changes-preview-toggle",children:b?"▼":"▶"}),(0,e.jsx)("button",{type:"button",onClick:()=>j(a.path,f),className:"shrink-0 px-1.5 py-0.5 text-xs text-accent-600 dark:text-accent-400 hover:underline","aria-label":o("git.changes.showDiff",{path:a.path}),"data-testid":"git-changes-diff-button",children:o("git.changes.diff")}),(0,e.jsx)("button",{type:"button",onClick:()=>l(a.path),disabled:i,className:"shrink-0 px-1.5 py-0.5 text-xs rounded border border-input text-foreground hover:bg-muted disabled:opacity-50","aria-label":o("git.changes.fileAction",{action:d,path:a.path}),"data-testid":"git-changes-toggle-button",children:d})]}),b&&(0,e.jsxs)("div",{className:"px-3 pb-2 bg-muted/40","data-testid":"git-changes-inline-preview",children:[v&&(0,e.jsxs)("div",{className:"flex items-center gap-2 py-2",role:"status",children:[(0,e.jsx)(n.y$,{size:"xs",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:o("git.changes.loadingPreview")})]}),x&&(0,e.jsx)("div",{className:"py-2 text-xs text-danger-foreground",role:"alert",children:x}),!v&&!x&&null!==t&&(""===t.trim()?(0,e.jsx)("div",{className:"py-2 text-xs text-muted-foreground",children:o("git.changes.noDiff")}):(0,e.jsxs)("div",{className:"overflow-x-auto",children:[(0,e.jsx)("pre",{className:"text-xs",children:(0,e.jsx)("code",{children:t.split("\n").slice(0,20).map((a,b)=>(0,e.jsx)(eK,{line:a},b))})}),t.split("\n").length>20&&(0,e.jsx)("button",{type:"button",onClick:()=>j(a.path,f),className:"mt-1 text-xs text-accent-600 dark:text-accent-400 hover:underline","data-testid":"git-changes-preview-more",children:o("git.changes.truncated")})]}))]})]},`${a.status}:${a.path}`)})})]})}),eQ=(0,h.memo)(function({staged:a,loading:b,error:c,busy:d,commitMessage:f,amend:g,committing:h,commitError:i,onRefresh:j,onDiff:l,onPreview:m,onStage:o,onUnstage:p,onCommitMessageChange:q,onAmendChange:r,onCommit:s,onCommitAndPush:t}){let{isMobile:u}=eB(),v=(0,k.c)("worktree"),w=a?.staged??[],x=a?.unstaged??[],y=a?.untracked??[],z=!h&&f.trim().length>0&&(w.length>0||g),A=!u;return(0,e.jsxs)("div",{className:"flex flex-col border-b border-border","data-testid":"git-changes-section",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:v("git.changes.title")}),(0,e.jsx)("button",{type:"button",onClick:j,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":v("git.changes.refresh"),children:(0,e.jsx)(eI,{})})]}),b&&!a&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2",role:"status",children:[(0,e.jsx)(n.y$,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:v("git.changes.loading")})]}),c&&!a&&(0,e.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-changes-error",children:c}),a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(eP,{title:v("git.changes.staged"),testId:"git-staged-list",files:w,actionLabel:v("git.changes.unstage"),mode:"staged",defaultOpen:A,busy:d,onDiff:l,onPreview:m,onToggleStage:p}),(0,e.jsx)(eP,{title:v("git.changes.unstaged"),testId:"git-unstaged-list",files:x,actionLabel:v("git.changes.stage"),mode:"unstaged",defaultOpen:A,busy:d,onDiff:l,onPreview:m,onToggleStage:o}),(0,e.jsx)(eP,{title:v("git.changes.untracked"),testId:"git-untracked-list",files:y,actionLabel:v("git.changes.stage"),mode:"untracked",defaultOpen:A,busy:d,onDiff:l,onPreview:m,onToggleStage:o}),(0,e.jsxs)("div",{className:"flex flex-col gap-2 px-3 py-2 border-t border-border",children:[(0,e.jsx)("textarea",{value:f,onChange:a=>q(a.target.value),placeholder:v("git.changes.commitMessage"),rows:u?2:3,className:"w-full resize-y rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"git-commit-message","aria-label":v("git.changes.commitMessage")}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(n.Sc,{checked:g,onCheckedChange:a=>r(!0===a),"data-testid":"git-amend-checkbox"}),v("git.changes.amend")]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:s,disabled:!z,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"git-commit-button",children:v(h?"git.changes.committing":"git.changes.commit")}),(0,e.jsx)("button",{type:"button",onClick:t,disabled:!z||d,title:v("git.changes.commitAndPushTooltip"),className:"px-3 py-1 text-xs font-medium rounded border border-accent-600 text-accent-700 dark:text-accent-300 hover:bg-accent-50 dark:hover:bg-accent-900/30 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"git-commit-push-button",children:v("git.changes.commitAndPush")})]})]}),i&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-commit-error",children:i})]})]})]})}),eR=(0,h.memo)(function({commits:a,isLoading:b,commitError:c,commitListOpen:d,onToggleCommitList:f,onRefresh:g,selectedCommit:i,onCommitSelect:j,inlineDiffCommit:l,inlineFiles:n,inlineFilesLoading:o,inlineFilesError:p,onToggleInlineDiff:q,onInlineDiffFile:r,changedFiles:s,isLoadingFiles:t,detailError:u,selectedFile:v,onFileSelect:w,diffContent:x,isLoadingDiff:y}){let{isMobile:z}=eB(),A=(0,k.c)("worktree"),[B,C]=(0,h.useState)(!0),[D,E]=(0,h.useState)(!0);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,e.jsxs)("button",{type:"button",onClick:f,className:"flex items-center gap-1 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground",children:[(0,e.jsx)("span",{className:"text-xs w-4 text-center",children:d?"▼":"▶"}),A("git.history.title")]}),(0,e.jsx)("button",{type:"button",onClick:g,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":A("git.history.refresh"),children:(0,e.jsx)(eI,{})})]}),d&&b&&(0,e.jsxs)("div",{className:"flex items-center justify-center py-8",role:"status",children:[(0,e.jsx)(m.y,{size:"lg",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:A("git.history.loading")})]}),d&&c&&!b&&(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-danger-foreground",role:"alert",children:c}),d&&!b&&!c&&0===a.length&&(0,e.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:A("git.history.empty")}),!b&&!c&&a.length>0&&(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[d&&(0,e.jsx)("div",{className:`overflow-y-auto ${i?"max-h-[40%] shrink-0":"flex-1"}`,children:(0,e.jsx)("ul",{className:"divide-y divide-border",children:a.map(a=>{let b=l===a.hash;return(0,e.jsxs)("li",{children:[(0,e.jsxs)("div",{className:"flex items-stretch",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>j(a.hash),className:`flex-1 min-w-0 text-left px-3 py-2 text-sm hover:bg-muted transition-colors ${i===a.hash?"bg-accent-50 dark:bg-accent-900/30":""}`,children:[(0,e.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,e.jsx)("span",{className:"font-mono text-xs text-accent-600 dark:text-accent-400 shrink-0",children:a.shortHash}),(0,e.jsx)("span",{className:"truncate text-foreground",children:a.message})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{children:a.author}),(0,e.jsx)("span",{children:new Date(a.date).toLocaleDateString()})]})]}),(0,e.jsx)("button",{type:"button",onClick:()=>q(a.hash),className:"shrink-0 px-2 text-xs text-accent-600 dark:text-accent-400 hover:bg-muted hover:underline","aria-label":A("git.history.viewDiffFor",{hash:a.shortHash}),"aria-expanded":b,"data-testid":"git-commit-view-diff-button",children:b?A("git.history.hideDiff"):A("git.history.viewDiff")})]}),b&&(0,e.jsxs)("div",{className:"border-t border-border bg-muted/40","data-testid":"git-commit-inline-files",children:[o&&(0,e.jsxs)("div",{className:"flex items-center justify-center py-3",role:"status",children:[(0,e.jsx)(m.y,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:A("git.history.loadingChangedFiles")})]}),p&&(0,e.jsx)(eL,{message:p}),!o&&!p&&0===n.length&&(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:A("git.history.noChangedFiles")}),!o&&n.length>0&&(0,e.jsx)("ul",{className:"divide-y divide-border",children:n.map(b=>(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",onClick:()=>r(a.hash,b.path),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${v===b.path&&i===a.hash?"bg-accent-50 dark:bg-accent-900/30":""}`,"aria-label":A("git.history.showCommitDiff",{path:b.path}),"data-testid":"git-commit-inline-file",children:[(0,e.jsx)("span",{className:`inline-block w-14 font-medium ${eH[b.status]}`,children:b.status}),(0,e.jsx)("span",{className:"font-mono text-foreground",children:b.path})]})},b.path))})]})]},a.hash)})})}),i&&(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0 border-t border-border",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>C(a=>!a),className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground bg-surface-2 sticky top-0 z-10 cursor-pointer hover:text-foreground",children:[(0,e.jsx)("span",{className:"w-4 text-center",children:B?"▼":"▶"}),A("git.history.changedFiles")]}),B&&(0,e.jsxs)(e.Fragment,{children:[u&&(0,e.jsx)(eL,{message:u}),t&&(0,e.jsxs)("div",{className:"flex items-center justify-center py-4",role:"status",children:[(0,e.jsx)(m.y,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:A("git.history.loadingChangedFiles")})]}),!t&&!u&&0===s.length&&(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:A("git.history.noChangedFiles")}),!t&&s.length>0&&(0,e.jsx)("ul",{className:"divide-y divide-border",children:s.map(a=>(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",onClick:()=>w(a.path),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${v===a.path?"bg-accent-50 dark:bg-accent-900/30":""}`,children:[(0,e.jsx)("span",{className:`inline-block w-14 font-medium ${eH[a.status]}`,children:a.status}),(0,e.jsx)("span",{className:"font-mono text-foreground",children:a.path})]})},a.path))})]}),z&&v&&(0,e.jsxs)("div",{className:"border-t border-border",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>E(a=>!a),className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground bg-surface-2 sticky top-0 z-10 cursor-pointer hover:text-foreground",children:[(0,e.jsx)("span",{className:"w-4 text-center",children:D?"▼":"▶"}),A("git.history.diffLabel",{file:v})]}),D&&(0,e.jsxs)(e.Fragment,{children:[y&&(0,e.jsxs)("div",{className:"flex items-center justify-center py-4",role:"status",children:[(0,e.jsx)(m.y,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:A("git.history.loadingDiff")})]}),!y&&x&&(0,e.jsx)("div",{className:"overflow-x-auto p-2",children:(0,e.jsx)("pre",{className:"text-xs",children:(0,e.jsx)("code",{children:x.split("\n").map((a,b)=>(0,e.jsx)(eK,{line:a},b))})})}),!y&&!x&&!u&&(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:A("git.history.noDiff")})]})]}),!z&&v&&!u&&(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground border-t border-border",children:y?A("git.history.loadingDiff"):A("git.history.diffInFilePanel",{file:v})})]})]})]})});function eS(a){return"`"+a+"`"}let eT={local:"git.branches.filterLocal",remote:"git.branches.filterRemote",all:"git.branches.filterAll"},eU=(0,h.memo)(function({branches:a,include:b,loading:c,error:d,busy:f,actionError:g,onIncludeChange:i,onRefresh:j,onCreate:l,onDelete:m}){let{isMobile:o,onInsertToMessage:p}=eB(),q=(0,k.c)("worktree"),r=(0,k.c)("common"),[s,t]=(0,h.useState)(!o),[u,v]=(0,h.useState)(!1),[w,x]=(0,h.useState)(""),[y,z]=(0,h.useState)(""),[A,B]=(0,h.useState)(null),[C,D]=(0,h.useState)(!1),E=(0,h.useCallback)(()=>{0!==w.trim().length&&(l(w.trim(),y.trim()||void 0),v(!1),x(""),z(""))},[w,y,l]),F=(0,h.useCallback)(()=>{A&&(m(A.name,C),B(null),D(!1))},[A,C,m]);return(0,e.jsxs)("div",{className:"flex flex-col border-b border-border","data-testid":"git-branches-section",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>t(a=>!a),className:"flex items-center gap-1 text-sm font-medium text-muted-foreground hover:text-foreground",children:[(0,e.jsx)("span",{className:"text-xs w-4 text-center",children:s?"▼":"▶"}),q("git.branches.title")]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{type:"button",onClick:()=>v(!0),className:"px-2 py-0.5 text-xs rounded border border-input text-foreground hover:bg-muted","data-testid":"git-branch-create-open",children:q("git.branches.newButton")}),(0,e.jsx)("button",{type:"button",onClick:j,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":q("git.branches.refresh"),children:(0,e.jsx)(eI,{})})]})]}),s&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"flex items-center gap-1 px-3 pb-2",children:["local","remote","all"].map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>i(a),className:`px-2 py-0.5 text-xs rounded ${b===a?"bg-accent-100 text-accent-800 dark:bg-accent-900/40 dark:text-accent-200":"text-muted-foreground hover:bg-muted"}`,"data-testid":`git-branches-tab-${a}`,children:q(eT[a])},a))}),c&&0===a.length&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2",role:"status",children:[(0,e.jsx)(n.y$,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:q("git.branches.loading")})]}),d&&(0,e.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-error",children:d}),g&&(0,e.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-action-error",children:g}),!c&&!d&&0===a.length&&(0,e.jsx)("div",{className:"px-3 pb-2 text-xs text-muted-foreground",children:q("git.branches.empty")}),a.length>0&&(0,e.jsx)("ul",{className:"divide-y divide-border max-h-64 overflow-y-auto",children:a.map(a=>{let b=f||a.isCurrent||a.isDefault;return(0,e.jsxs)("li",{className:"flex items-center gap-2 px-3 py-1.5","data-testid":"git-branch-row",children:[(0,e.jsxs)("span",{className:"flex-1 truncate font-mono text-xs text-foreground",title:a.name,children:[a.isCurrent&&(0,e.jsx)("span",{className:"text-accent-600 dark:text-accent-400 mr-1",children:"●"}),a.name,a.isDefault&&(0,e.jsx)("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:q("git.branches.defaultBadge")})]}),(0,e.jsx)("button",{type:"button",onClick:()=>{D(!1),B(a)},disabled:b,className:"shrink-0 px-1.5 py-0.5 text-xs rounded border border-input text-danger-foreground hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","aria-label":q("git.branches.deleteBranch",{name:a.name}),children:q("git.branches.delete")})]},`${a.isRemote?"r":"l"}:${a.name}`)})})]}),u&&(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-create-modal",children:(0,e.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:q("git.branches.createTitle")}),(0,e.jsx)("input",{type:"text",value:w,onChange:a=>x(a.target.value),placeholder:q("git.branches.namePlaceholder"),className:"w-full rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"branch-create-name-input","aria-label":q("git.branches.nameLabel")}),(0,e.jsxs)("select",{value:y,onChange:a=>z(a.target.value),className:"w-full rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"branch-create-from-select","aria-label":q("git.branches.baseLabel"),children:[(0,e.jsx)("option",{value:"",children:q("git.branches.currentHead")}),a.map(a=>(0,e.jsx)("option",{value:a.name,children:a.name},`from:${a.isRemote?"r":"l"}:${a.name}`))]}),(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[p&&(0,e.jsx)(eJ,{className:"mr-auto",testId:"branch-create-ask-ai",disabled:0===w.trim().length,onClick:()=>{p(function(a,b,c){let d=c&&c.trim().length>0?eS(c.trim()):a("git.aiPrompts.branchCreateBaseHead");return a("git.aiPrompts.branchCreate",{base:d,name:eS(b.trim())})}(q,w,y)),v(!1)}}),(0,e.jsx)("button",{type:"button",onClick:()=>v(!1),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:r("cancel")}),(0,e.jsx)("button",{type:"button",onClick:E,disabled:f||0===w.trim().length,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"branch-create-submit",children:q("git.branches.create")})]})]})}),A&&(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-delete-confirm",children:(0,e.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,e.jsxs)("h3",{className:"text-sm font-medium text-foreground",children:[q("git.branches.deleteTitlePrefix"),(0,e.jsx)("span",{className:"font-mono",children:A.name}),q("git.branches.deleteTitleSuffix")]}),(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(n.Sc,{checked:C,onCheckedChange:a=>D(!0===a),"data-testid":"branch-delete-force"}),q("git.branches.forceDeleteLabel")]}),(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[p&&A&&(0,e.jsx)(eJ,{className:"mr-auto",testId:"branch-delete-ask-ai",onClick:()=>{p(q(C?"git.aiPrompts.branchDeleteForce":"git.aiPrompts.branchDelete",{name:eS(A.name)})),B(null),D(!1)}}),(0,e.jsx)("button",{type:"button",onClick:()=>B(null),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:r("cancel")}),(0,e.jsx)("button",{type:"button",onClick:F,disabled:f,className:"px-3 py-1 text-xs font-medium rounded bg-danger text-white hover:bg-danger/90 disabled:opacity-50","data-testid":"branch-delete-confirm-button",children:q("git.branches.delete")})]})]})})]})}),eV=(0,h.memo)(function({stashes:a,loading:b,error:c,busy:d,actionError:f,conflictNotice:g,hasRunningSession:i,onRefresh:j,onPush:l,onPop:m,onApply:o,onDrop:p}){let{isMobile:q,onInsertToMessage:r}=eB(),s=(0,k.c)("worktree"),t=(0,k.c)("common"),[u,v]=(0,h.useState)(!q),[w,x]=(0,h.useState)(""),[y,z]=(0,h.useState)(!1),[A,B]=(0,h.useState)(null);return(0,e.jsxs)("div",{className:"border-b border-border","data-testid":"git-stash-section",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>v(a=>!a),className:"flex items-center gap-1 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground",children:[(0,e.jsx)("span",{className:"text-xs w-4 text-center",children:u?"▼":"▶"}),s("git.stash.titlePrefix"),a.length>0&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:s("git.stash.count",{count:a.length})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[u&&r&&a.length>0&&(0,e.jsx)(eJ,{testId:"stash-cleanup-ask-ai",onClick:()=>r(function(a,b){let c=a("git.aiPrompts.stashCleanup");if(0===b.length)return c;let d=b.map(a=>`- stash@{${a.index}}: ${a.message}`).join("\n");return`${c}
29
+ `,children:[d?(0,e.jsx)(m.y,{"data-testid":"loading-indicator",size:"md",variant:"accent"}):(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:"M12 4v16m8-8H4"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:g("memoAdd")})]}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:g("memoRemaining",{count:h})})]})});function da({query:a,onQueryChange:b,matchCount:c,currentIndex:d,onNext:f,onPrev:g,onClose:i,onCompositionStart:j,onCompositionEnd:l}){let m=(0,k.c)("schedule"),o=(0,h.useRef)(null),p=(0,h.useCallback)(a=>{"Escape"===a.key?i():"Enter"===a.key&&(a.preventDefault(),f())},[i,f]),q=(0,h.useCallback)(a=>{b(a.target.value)},[b]),r=0===c?"0/0":`${d+1}/${c}`;return(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border border-input rounded",role:"search","aria-label":m("memoSearchLabel"),children:[(0,e.jsx)("input",{ref:o,type:"text",value:a,onChange:q,onKeyDown:p,onCompositionStart:j,onCompositionEnd:l,placeholder:m("memoSearchPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-foreground text-sm outline-none placeholder-muted-foreground","aria-label":m("memoSearchInputLabel"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,e.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"text-muted-foreground text-xs min-w-[3rem] text-right",children:r}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:g,disabled:0===c,"aria-label":m("memoSearchPrev"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▲"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:f,disabled:0===c,"aria-label":m("memoSearchNext"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▼"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:i,"aria-label":m("memoSearchClose"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white min-w-[36px] min-h-[36px] flex items-center justify-center text-base ml-1",children:"✕"})]})}let db=(0,h.memo)(function({worktreeId:a,className:b="",onInsertToMessage:c}){let d=(0,k.c)("schedule"),f=(0,k.c)("common"),g=(0,am.SC)(),[i,j]=(0,h.useState)([]),[l,n]=(0,h.useState)(!0),[o,p]=(0,h.useState)(!1),[q,r]=(0,h.useState)(null),[s,t]=(0,h.useState)(null),[u,v]=(0,h.useState)(!1),w=(0,h.useRef)(null),{query:x,matches:y,currentMatch:z,totalCount:A,setQuery:B,reset:C,navigateNext:D,navigatePrev:E,onCompositionStart:F,onCompositionEnd:G}=function({memos:a}){let[b,c]=(0,h.useState)(""),[d,e]=(0,h.useState)([]),[f,g]=(0,h.useState)(-1),i=(0,h.useRef)(null),j=(0,h.useRef)(""),k=(0,h.useRef)(!1);(0,h.useRef)(0===a.length?"0":a.map(a=>`${a.id}:${a.title.length}:${a.content.length}`).join("|"));let l=(0,h.useRef)(a);l.current=a;let m=d.length,n=(0,h.useCallback)(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),o=(0,h.useCallback)(a=>{let b=function(a,b){if(b.length<2||0===a.length)return[];let c=b.toLowerCase();return a.filter(a=>-1!==a.title.toLowerCase().indexOf(c)||-1!==a.content.toLowerCase().indexOf(c))}(l.current,a);e(b),g(b.length>0?0:-1)},[]),p=(0,h.useCallback)(a=>{n(),j.current=a,k.current||(i.current=setTimeout(()=>{o(a)},300))},[n,o]),q=(0,h.useCallback)(a=>{c(a),p(a)},[p]),r=(0,h.useCallback)(()=>{c(""),j.current="",e([]),g(-1),n()},[n]),s=(0,h.useCallback)(()=>{g(a=>0===m?-1:(a+1)%m)},[m]),t=(0,h.useCallback)(()=>{g(a=>0===m?-1:(a-1+m)%m)},[m]);return{query:b,matches:d,currentMatch:f,totalCount:m,setQuery:q,reset:r,navigateNext:s,navigatePrev:t,onCompositionStart:(0,h.useCallback)(()=>{k.current=!0,n()},[n]),onCompositionEnd:(0,h.useCallback)(()=>{k.current=!1;let a=j.current;a.length>=2&&(n(),i.current=setTimeout(()=>{o(a)},300))},[n,o])}}({memos:i}),H=u&&x.length>0,I=H?y:i,J=(0,h.useCallback)(async()=>{n(!0),r(null);try{let b=await T.$T.getAll(a);j(b.sort((a,b)=>a.position-b.position))}catch(a){r((0,T.hS)(a))}finally{n(!1)}},[a]);(0,h.useEffect)(()=>{J()},[J]);let K=(0,h.useCallback)(async()=>{p(!0),t(null);try{let b=await T.$T.create(a,{title:d("memoDefaultTitle"),content:""});j(a=>[...a,b])}catch(a){t((0,T.hS)(a))}finally{p(!1)}},[a,d]),L=(0,h.useCallback)(async(b,c)=>{await T.$T.update(a,b,c),j(a=>a.map(a=>a.id===b?{...a,...c}:a))},[a]),M=(0,h.useCallback)(async b=>{let c=i.find(a=>a.id===b);if(await g({description:f("confirmDelete",{name:c?.title??""}),variant:"danger"}))try{await T.$T.delete(a,b),j(a=>a.filter(a=>a.id!==b))}catch(a){console.error("Failed to delete memo:",a)}},[a,i,g,f]),N=(0,h.useCallback)(async(b,c)=>{let d=b+c;if(d<0||d>=i.length)return;let e=[...i];[e[b],e[d]]=[e[d],e[b]],j(e);try{await T.$T.reorder(a,e.map(a=>a.id))}catch(a){r((0,T.hS)(a)),await J()}},[i,a,J]),O=(0,h.useCallback)(()=>{J()},[J]),P=(0,h.useCallback)(()=>{v(a=>(a&&C(),!a))},[C]),R=(0,h.useCallback)(()=>{v(!1),C()},[C]);return((0,h.useEffect)(()=>{if(!H||z<0)return;let a=y[z];if(!a)return;let b=w.current?.querySelector(`[data-memo-id="${a.id}"]`);b&&(b.scrollIntoView({block:"nearest"}),b.focus({preventScroll:!0}))},[H,z,y]),l)?(0,e.jsx)("div",{"data-testid":"memo-pane",className:`flex flex-col items-center justify-center h-full p-4 ${b}`,children:(0,e.jsxs)("div",{"data-testid":"memo-loading",className:"flex flex-col items-center gap-3",children:[(0,e.jsx)(m.y,{size:"xl",variant:"accent"}),(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:d("memoLoading")})]})}):q?(0,e.jsx)("div",{"data-testid":"memo-pane",className:`flex flex-col items-center justify-center h-full p-4 ${b}`,children:(0,e.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[(0,e.jsx)("svg",{className:"w-12 h-12 text-danger",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)("span",{className:"text-sm text-danger-foreground",children:q}),(0,e.jsx)("button",{type:"button",onClick:O,"aria-label":f("retry"),className:"px-4 py-2 text-sm font-medium text-white bg-accent-500 rounded-lg hover:bg-accent-600 transition-colors",children:f("retry")})]})}):(0,e.jsxs)("div",{ref:w,"data-testid":"memo-pane",className:`flex flex-col gap-4 p-4 overflow-y-auto ${b}`,children:[(0,e.jsx)("div",{"data-testid":"memo-pane-header",className:"flex items-center gap-2",children:u?(0,e.jsx)("div",{className:"flex-1",children:(0,e.jsx)(da,{query:x,onQueryChange:B,matchCount:A,currentIndex:z,onNext:D,onPrev:E,onClose:R,onCompositionStart:F,onCompositionEnd:G})}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"flex-1"}),(0,e.jsx)("button",{type:"button","data-testid":"memo-search-toggle",onClick:P,"aria-label":d("memoSearchToggle"),className:"p-1.5 text-muted-foreground hover:text-foreground transition-colors rounded",children:(0,e.jsx)(Q.A,{className:"w-4 h-4","aria-hidden":"true"})})]})}),0===i.length&&!H&&!s&&(0,e.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,e.jsx)("p",{children:d("memoEmpty")}),(0,e.jsx)("p",{className:"text-sm",children:d("memoEmptyHint")})]}),H&&0===I.length&&(0,e.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:(0,e.jsx)("p",{children:d("memoNoMatch")})}),I.map((a,b)=>(0,e.jsx)(c8,{memo:a,onUpdate:L,onDelete:M,onInsertToMessage:c,onMoveUp:H?void 0:()=>N(b,-1),onMoveDown:H?void 0:()=>N(b,1),canMoveUp:!H&&b>0,canMoveDown:!H&&b<i.length-1},a.id)),s&&(0,e.jsx)("div",{className:"text-center py-2 text-sm text-danger",children:s}),!H&&(0,e.jsx)(c9,{currentCount:i.length,maxCount:20,onAdd:K,isLoading:o,className:"mt-2"})]})});var dc=c(44872),dd=c(2996),de=c(62484);let df={todo:"border-input text-muted-foreground",doing:"border-warning-border bg-warning-subtle text-warning-foreground",done:"border-success-border bg-success-subtle text-success-foreground"},dg=i().memo(function({worktreeId:a,className:b=""}){let c=(0,k.c)("worktree"),d=(0,k.c)("common"),f=(0,am.SC)(),[g,i]=(0,h.useState)([]),[j,l]=(0,h.useState)(""),[m,n]=(0,h.useState)(!0),[o,p]=(0,h.useState)(!1),[q,r]=(0,h.useState)(null),[s,t]=(0,h.useState)(null),[u,v]=(0,h.useState)(""),[w,x]=(0,h.useState)(""),[y,z]=(0,h.useState)(!1),A=(0,h.useCallback)(a=>{switch(a){case"doing":return c("todo.statusDoing");case"done":return c("todo.statusDone");default:return c("todo.statusTodo")}},[c]),B=(0,h.useCallback)(async()=>{n(!0),r(null);try{let b=await dc.Ar.list(a);i(b)}catch(a){r(a instanceof Error?a.message:c("todo.loadError")),i([])}finally{n(!1)}},[a,c]);(0,h.useEffect)(()=>{B()},[a]);let C=(0,h.useCallback)(async()=>{let b=j.trim();if(b&&!o){p(!0),r(null);try{let c=await dc.Ar.create(a,b);i(a=>[...a,c]),l("")}catch(a){r(a instanceof Error?a.message:c("todo.addError"))}finally{p(!1)}}},[j,o,a,c]),D=(0,h.useCallback)(async b=>{let d=function(a){let b=dc.KG.indexOf(a);return dc.KG[(b+1)%dc.KG.length]}(b.status);i(a=>a.map(a=>a.id===b.id?{...a,status:d,done:"done"===d}:a)),r(null);try{await dc.Ar.update(a,b.id,{status:d})}catch(a){r(a instanceof Error?a.message:c("todo.updateError")),B()}},[a,B,c]),E=(0,h.useCallback)(async b=>{if(await f({description:d("confirmDelete",{name:b.content}),variant:"danger"})){r(null);try{await dc.Ar.remove(a,b.id),i(a=>a.filter(a=>a.id!==b.id))}catch(a){r(a instanceof Error?a.message:c("todo.deleteError"))}}},[a,c,f,d]),F=(0,h.useCallback)(a=>{t(a),v(a.content),x(a.detail),r(null)},[]),G=(0,h.useCallback)(()=>{t(null),z(!1)},[]),H=(0,h.useCallback)(async()=>{if(!s)return;let b=u.trim();if(b&&!y){z(!0),r(null);try{let c=await dc.Ar.update(a,s.id,{content:b,detail:w});i(a=>a.map(a=>a.id===s.id?c:a)),G()}catch(a){r(a instanceof Error?a.message:c("todo.updateError")),z(!1)}}},[s,u,w,y,a,G,c]),I=(0,h.useCallback)(async(b,d)=>{let e=b+d;if(e<0||e>=g.length)return;let f=[...g];[f[b],f[e]]=[f[e],f[b]],i(f),r(null);try{await dc.Ar.reorder(a,f.map(a=>a.id))}catch(a){r(a instanceof Error?a.message:c("todo.reorderError")),B()}},[g,a,B,c]),J=(0,h.useCallback)(a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),C())},[C]),K=(0,h.useMemo)(()=>({todo:g.filter(a=>"todo"===a.status).length,doing:g.filter(a=>"doing"===a.status).length,done:g.filter(a=>"done"===a.status).length}),[g]);return(0,e.jsxs)("div",{"data-testid":"todo-pane",className:`flex flex-col h-full overflow-y-auto p-4 ${b}`.trim(),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,e.jsx)("input",{type:"text",value:j,onChange:a=>l(a.target.value),onKeyDown:J,maxLength:dd.Ll,placeholder:c("todo.addPlaceholder"),"data-testid":"todo-input",className:"flex-1 min-w-0 rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,e.jsx)("button",{type:"button",onClick:C,disabled:o||0===j.trim().length,"data-testid":"todo-add-button",className:"shrink-0 rounded-md bg-accent-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-700 disabled:opacity-50",children:c("todo.add")})]}),(0,e.jsxs)("div",{className:"mb-2 flex justify-end gap-2 text-xs text-muted-foreground",children:[(0,e.jsxs)("span",{"data-testid":"todo-count-todo",children:[A("todo")," ",K.todo]}),(0,e.jsxs)("span",{"data-testid":"todo-count-doing",children:[A("doing")," ",K.doing]}),(0,e.jsxs)("span",{"data-testid":"todo-count-done",children:[A("done")," ",K.done]})]}),q&&(0,e.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"todo-error",children:q}),m?(0,e.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"todo-loading",children:c("todo.loading")}):0===g.length?(0,e.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"todo-empty",children:c("todo.empty")}):(0,e.jsx)("ul",{className:"space-y-1","data-testid":"todo-list",children:g.map((a,b)=>(0,e.jsxs)("li",{className:"flex items-center gap-2 rounded-md px-1 py-1 hover:bg-muted group","data-testid":"todo-item",children:[(0,e.jsx)("button",{type:"button",onClick:()=>D(a),"data-testid":"todo-status","data-status":a.status,"aria-label":c("todo.cycleStatus",{status:A(a.status)}),title:c("todo.cycleStatus",{status:A(a.status)}),className:`shrink-0 inline-flex min-h-[44px] items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium sm:min-h-0 ${df[a.status]}`,children:A(a.status)}),(0,e.jsxs)("button",{type:"button",onClick:()=>F(a),"data-testid":"todo-content","aria-label":c("todo.edit"),title:c("todo.edit"),className:"group/content flex min-h-[44px] min-w-0 flex-1 items-center gap-1.5 text-left sm:min-h-0",children:[(0,e.jsx)("span",{className:`min-w-0 break-words text-sm ${"done"===a.status?"line-through text-muted-foreground":"text-foreground group-hover/content:text-accent-700 dark:group-hover/content:text-accent-300"}`,children:a.content}),""!==a.detail.trim()&&(0,e.jsxs)("svg",{"data-testid":"todo-detail-indicator","aria-label":c("todo.hasDetail"),className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("title",{children:c("todo.hasDetail")}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h10"})]})]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,e.jsx)("button",{type:"button",onClick:()=>I(b,-1),disabled:0===b,"aria-label":c("todo.moveUp"),"data-testid":"todo-move-up",className:"p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",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:"M5 15l7-7 7 7"})})}),(0,e.jsx)("button",{type:"button",onClick:()=>I(b,1),disabled:b===g.length-1,"aria-label":c("todo.moveDown"),"data-testid":"todo-move-down",className:"p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",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:"M19 9l-7 7-7-7"})})}),(0,e.jsx)("button",{type:"button",onClick:()=>E(a),"aria-label":c("todo.delete"),"data-testid":"todo-delete",className:"inline-flex min-h-[44px] min-w-[44px] shrink-0 items-center justify-center text-muted-foreground opacity-100 transition-opacity hover:text-danger-foreground sm:min-h-0 sm:min-w-0 sm:opacity-0 sm:group-hover:opacity-100",children:(0,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"})})})]})]},a.id))}),(0,e.jsx)(bc.a,{isOpen:null!==s,onClose:G,title:c("todo.editTitle"),size:"md",children:(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,e.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:c("todo.contentLabel")}),(0,e.jsx)("input",{type:"text",value:u,onChange:a=>v(a.target.value),maxLength:dd.Ll,placeholder:c("todo.contentPlaceholder"),"data-testid":"todo-edit-content",className:"w-full rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,e.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,e.jsxs)("span",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:c("todo.detailLabel")}),""!==w.trim()&&(0,e.jsx)(de.i,{text:w,label:c("todo.copyDetail"),className:"!border-input !bg-surface dark:!bg-surface-2 !text-muted-foreground hover:!bg-muted"})]}),(0,e.jsx)("textarea",{value:w,onChange:a=>x(a.target.value),maxLength:dd.bu,rows:6,placeholder:c("todo.detailPlaceholder"),"data-testid":"todo-edit-detail",className:"w-full resize-y rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:G,"data-testid":"todo-edit-cancel",className:"rounded-md border border-input px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted",children:c("todo.cancel")}),(0,e.jsx)("button",{type:"button",onClick:H,disabled:y||0===u.trim().length,"data-testid":"todo-edit-save",className:"rounded-md bg-accent-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-700 disabled:opacity-50",children:c("todo.save")})]})]})})]})});var dh=c(75234);let di=(0,x.A)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]);var dj=c(44688);function dk({isOpen:a,onClose:b,title:c,children:d,footer:f,showCloseButton:g=!0}){let i=(0,k.c)("common"),[j,l]=(0,h.useState)(null);return a?(0,bG.createPortal)((0,e.jsxs)("div",{"data-testid":"full-screen-modal",role:"dialog","aria-modal":"true",className:"fixed inset-0 flex flex-col bg-surface animate-slide-up",style:{zIndex:aE.M.MODAL,height:j?`${j}px`:"100dvh"},children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsx)("h3",{className:"text-base font-semibold text-foreground truncate pr-2",children:c}),g&&(0,e.jsx)("button",{type:"button",onClick:b,"aria-label":i("close"),"data-testid":"full-screen-modal-close",className:"flex-shrink-0 -mr-1 p-1 text-muted-foreground hover:text-foreground transition-colors",children:(0,e.jsx)(az.A,{className:"w-6 h-6"})})]}),(0,e.jsx)("div",{"data-testid":"full-screen-modal-body",className:"flex-1 min-h-0 overflow-y-auto overscroll-contain px-4 py-4",onFocusCapture:a=>{let b=a.target;b&&"function"==typeof b.scrollIntoView&&window.requestAnimationFrame(()=>{b.scrollIntoView({block:"center",behavior:"smooth"})})},children:d}),f&&(0,e.jsx)("div",{"data-testid":"full-screen-modal-footer",className:"flex-shrink-0 border-t border-border bg-surface px-4 py-3",style:{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom))"},children:f})]}),document.body):null}let dl=["default","acceptEdits","plan","dontAsk","bypassPermissions"],dm=["read-only","workspace-write","danger-full-access"],dn=["allow-all-tools","yolo"],dp=["--dangerously-skip-permissions"],dq=[],dr={claude:"acceptEdits",codex:"workspace-write",gemini:"","vibe-local":"",copilot:"allow-all-tools",antigravity:"--dangerously-skip-permissions"};function ds(a){switch(a){case"codex":return dm;case"copilot":return dn;case"antigravity":return dp;case"claude":return dl;default:return dq}}let dt=/^[\w\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\uF900-\uFAFF\s-]{1,100}$/,du=/^[a-zA-Z0-9][a-zA-Z0-9\-._/:]*$/,dv=new Set(["copilot"]),dw=[{value:"0 */1 * * *",labelKey:"cronPresetHourly"},{value:"0 9 * * *",labelKey:"cronPresetDaily9"},{value:"0 9 * * 1",labelKey:"cronPresetWeeklyMon9"}],dx={name:"",cronExpression:"0 9 * * *",message:"",cliToolId:"claude",enabled:!0,permission:dr.claude??"",model:""},dy="w-full px-3 py-2 text-sm border border-input rounded-md bg-surface dark:bg-surface-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring",dz="block text-xs font-semibold text-foreground mb-1",dA="mt-1 text-xs text-danger-foreground";function dB({onClick:a,label:b,title:c,testId:d}){return(0,e.jsxs)("button",{type:"button","data-testid":d,onClick:a,title:c,className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-info-border text-info-foreground hover:bg-info-subtle transition-colors",children:[(0,e.jsx)(dh.A,{size:14,"aria-hidden":"true"}),b]})}function dC({id:a,title:b,summary:c,icon:d,isOpen:f,onToggle:g,children:h}){let i=`schedule-section-${a}-content`;return(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,e.jsxs)("button",{type:"button","data-testid":`schedule-section-${a}`,"aria-expanded":f,"aria-controls":i,onClick:()=>g(a),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left bg-surface-2 hover:bg-muted transition-colors",children:[(0,e.jsx)("span",{className:"flex-shrink-0 text-accent-600 dark:text-accent-400",children:d}),(0,e.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,e.jsx)("span",{className:"block text-sm font-semibold text-foreground",children:b}),c&&(0,e.jsx)("span",{"data-testid":`schedule-section-${a}-summary`,className:"block truncate text-xs text-muted-foreground",children:c})]}),(0,e.jsx)(bf.A,{className:`flex-shrink-0 w-4 h-4 text-muted-foreground transition-transform ${f?"rotate-180":""}`})]}),f&&(0,e.jsx)("div",{id:i,className:"px-3 py-3 flex flex-col gap-4",children:h})]})}function dD({isOpen:a,worktreeId:b,initialValues:c,originalName:d,onInsertToMessage:f,instances:g,onClose:i,onSaved:j}){let l=(0,k.c)("schedule"),m=(0,ab.a)(),o=(0,h.useMemo)(()=>g&&g.length>0?g:(0,be.lu)([...be.XH]),[g]),[p,q]=(0,h.useState)(dx),[r,s]=(0,h.useState)(""),[t,u]=(0,h.useState)(!1),[v,w]=(0,h.useState)(null),[x,y]=(0,h.useState)(()=>new Set(["basic","advanced","message"])),z=(0,h.useCallback)(a=>{y(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),A=ds(p.cliToolId),C=A.length>0,D="copilot"===p.cliToolId,E=!!d,F=(0,h.useMemo)(()=>{let a=p.name.trim();return a?a.length>100?l("edit.errorNameTooLong",{max:100}):dt.test(a)?null:l("edit.errorNameInvalid"):l("edit.errorNameRequired")},[p.name,l]),G=(0,h.useMemo)(()=>!function(a){if(a.length>100)return!1;let b=a.trim().split(/\s+/);return b.length>=5&&b.length<=6}(p.cronExpression.trim())?l("edit.errorCronInvalid"):null,[p.cronExpression,l]),H=(0,h.useMemo)(()=>p.message.trim()?p.message.length>1e4?l("edit.errorMessageTooLong",{max:1e4}):null:l("edit.errorMessageRequired"),[p.message,l]),I=(0,h.useMemo)(()=>{var a;return D&&p.model.trim()?(a=p.model.trim(),/[\x00-\x1f\x7f]/.test(a)?{valid:!1,reason:"Model name contains control characters"}:""===a.trim()?{valid:!1,reason:"Model name must not be empty"}:!du.test(a)?{valid:!1,reason:"Model name contains invalid characters"}:a.length>128?{valid:!1,reason:"Model name exceeds 128 characters"}:{valid:!0}).valid?null:l("edit.errorModelInvalid"):null},[D,p.model,l]),J=!F&&!G&&!H&&!I,K=(0,h.useCallback)(a=>{q(b=>({...b,cliToolId:a,permission:function(a){let b=dr[a];if(void 0!==b)return b;let c=ds(a);return c.length>0?c[0]:""}(a),model:"copilot"===a?b.model:""}))},[]),L=(0,h.useCallback)(a=>{let b=o.find(b=>b.id===a);b&&(s(a),K(b.cliTool))},[o,K]),M=dw.some(a=>a.value===p.cronExpression)?p.cronExpression:"custom",N=(0,h.useCallback)(a=>{"custom"!==a&&q(b=>({...b,cronExpression:a}))},[]),O=(0,h.useCallback)(a=>{f?.(a),i()},[f,i]),P=(0,h.useCallback)(async()=>{if(J&&!t){u(!0),w(null);try{let a=await fetch(`/api/worktrees/${b}/cmate/schedules`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:p.name.trim(),cronExpression:p.cronExpression.trim(),message:p.message.trim(),cliToolId:p.cliToolId,enabled:p.enabled,permission:C?p.permission:"",model:D&&p.model.trim()?p.model.trim():void 0,originalName:d??void 0})});if(!a.ok){let b=await a.json().catch(()=>({}));w(b.error||l("edit.saveError"));return}j(),i()}catch{w(l("edit.saveError"))}finally{u(!1)}}},[J,t,b,p,C,D,d,j,i,l]),Q=o.find(a=>a.id===r)?.alias??(0,be.f_)(p.cliToolId),R=p.name.trim()?`${p.name.trim()} \xb7 ${p.cronExpression}`:p.cronExpression,S=[Q,C?p.permission:null,D&&p.model.trim()?p.model.trim():null].filter(Boolean).join(" \xb7 "),T=p.message.trim(),U=T.length>32?`${T.slice(0,32)}…`:T,V=(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:dz,htmlFor:"schedule-name-input",children:l("edit.name")}),(0,e.jsx)("input",{id:"schedule-name-input","data-testid":"schedule-name-input",type:"text",value:p.name,maxLength:100,placeholder:l("edit.namePlaceholder"),onChange:a=>q(b=>({...b,name:a.target.value})),className:dy}),F&&(0,e.jsx)("p",{className:dA,"data-testid":"schedule-name-error",children:F})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-foreground",htmlFor:"schedule-cron-input",children:l("edit.cron")}),f&&(0,e.jsx)(dB,{testId:"schedule-cron-ask-ai",label:l("edit.askAiCron"),title:l("edit.askAiHint"),onClick:()=>O(function(a,b){let c=b.trim();return 0===c.length?a("edit.aiPrompts.cron"):a("edit.aiPrompts.cronRefine",{current:"`"+c+"`"})}(l,p.cronExpression))})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,e.jsx)("input",{id:"schedule-cron-input","data-testid":"schedule-cron-input",type:"text",value:p.cronExpression,placeholder:l("edit.cronPlaceholder"),onChange:a=>q(b=>({...b,cronExpression:a.target.value})),className:`${dy} font-mono sm:flex-1`}),(0,e.jsxs)("select",{"data-testid":"schedule-cron-preset","aria-label":l("edit.cronPreset"),value:M,onChange:a=>N(a.target.value),className:`${dy} sm:w-48`,children:[dw.map(a=>(0,e.jsx)("option",{value:a.value,children:l(`edit.${a.labelKey}`)},a.value)),(0,e.jsx)("option",{value:"custom",children:l("edit.cronPresetCustom")})]})]}),G&&(0,e.jsx)("p",{className:dA,"data-testid":"schedule-cron-error",children:G})]}),(0,e.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,e.jsx)(n.Sc,{"data-testid":"schedule-enabled-toggle",checked:p.enabled,onCheckedChange:a=>q(b=>({...b,enabled:!0===a}))}),(0,e.jsx)("span",{className:"text-sm text-foreground",children:l("edit.enabledLabel")})]})]}),W=(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:dz,htmlFor:"schedule-cli-tool-select",children:l("edit.cliTool")}),(0,e.jsx)("select",{id:"schedule-cli-tool-select","data-testid":"schedule-cli-tool-select",value:r,onChange:a=>L(a.target.value),className:dy,children:o.map(a=>(0,e.jsx)("option",{value:a.id,children:a.alias},a.id))})]}),D&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:dz,htmlFor:"schedule-model-input",children:l("edit.model")}),(0,e.jsx)("input",{id:"schedule-model-input","data-testid":"schedule-model-input",type:"text",value:p.model,placeholder:l("edit.modelPlaceholder"),onChange:a=>q(b=>({...b,model:a.target.value})),className:dy}),I&&(0,e.jsx)("p",{className:dA,"data-testid":"schedule-model-error",children:I})]}),C&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:dz,htmlFor:"schedule-permission-select",children:l("edit.permission")}),(0,e.jsx)("select",{id:"schedule-permission-select","data-testid":"schedule-permission-select",value:p.permission,onChange:a=>q(b=>({...b,permission:a.target.value})),className:dy,children:A.map(a=>(0,e.jsx)("option",{value:a,children:a},a))})]})]}),X=(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-foreground",htmlFor:"schedule-message-input",children:l("edit.message")}),f&&(0,e.jsx)(dB,{testId:"schedule-message-ask-ai",label:l("edit.askAiMessage"),title:l("edit.askAiHint"),onClick:()=>O(function(a,b){let c=b.trim();return 0===c.length?a("edit.aiPrompts.messageDraft"):a("edit.aiPrompts.messageDraftNamed",{name:"`"+c+"`"})}(l,p.name))})]}),(0,e.jsx)("textarea",{id:"schedule-message-input","data-testid":"schedule-message-input",value:p.message,rows:4,maxLength:1e4,placeholder:l("edit.messagePlaceholder"),onChange:a=>q(b=>({...b,message:a.target.value})),className:`${dy} resize-none`}),(0,e.jsxs)("div",{className:"mt-1 flex items-center justify-between",children:[H?(0,e.jsx)("p",{className:dA,"data-testid":"schedule-message-error",children:H}):(0,e.jsx)("span",{}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"schedule-message-count",children:l("edit.charCount",{count:p.message.length,max:1e4})})]})]}),Y=(0,e.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,e.jsx)(dC,{id:"basic",title:l("edit.sectionBasic"),summary:R,icon:(0,e.jsx)(B.A,{className:"w-4 h-4"}),isOpen:x.has("basic"),onToggle:z,children:V}),(0,e.jsx)(dC,{id:"advanced",title:l("edit.sectionAdvanced"),summary:S,icon:(0,e.jsx)(di,{className:"w-4 h-4"}),isOpen:x.has("advanced"),onToggle:z,children:W}),(0,e.jsx)(dC,{id:"message",title:l("edit.sectionMessage"),summary:U,icon:(0,e.jsx)(dj.A,{className:"w-4 h-4"}),isOpen:x.has("message"),onToggle:z,children:X}),v&&(0,e.jsx)("div",{className:"text-xs p-2 rounded bg-danger-subtle text-danger-foreground","data-testid":"schedule-submit-error",children:v})]}),Z=(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:i,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:l("edit.cancel")}),(0,e.jsx)("button",{type:"button","data-testid":"schedule-save-button",onClick:()=>void P(),disabled:!J||t,className:"px-4 py-2 text-sm font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-md transition-colors",children:l("edit.save")})]}),$=E?l("edit.titleEdit"):l("edit.titleCreate");return m?(0,e.jsx)(dk,{isOpen:a,onClose:i,title:$,footer:Z,children:Y}):(0,e.jsx)(bc.a,{isOpen:a,onClose:i,title:$,size:"md",children:(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[Y,(0,e.jsx)("div",{className:"pt-2 border-t border-border",children:Z})]})})}function dE(a){return new Date(a).toLocaleString()}function dF(a,b){if(null===b)return null;let c=b-a;if(c<0)return null;let d=Math.floor(c/1e3),e=Math.floor(d/60),f=d%60;return e>0?`${e}m ${f}s`:`${f}s`}let dG=(0,h.memo)(function({worktreeId:a,logs:b}){let c=(0,k.c)("schedule"),[d,f]=(0,h.useState)(null),[g,i]=(0,h.useState)(null),j=(0,h.useCallback)(async b=>{if(d===b){f(null),i(null);return}try{let c=await fetch(`/api/worktrees/${a}/execution-logs/${b}`);if(c.ok){let a=await c.json();i(a.log),f(b)}}catch(a){console.error("Failed to fetch log detail:",a)}},[a,d]);return 0===b.length?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:c("noLogs")}):(0,e.jsx)("div",{className:"space-y-2","data-testid":"execution-logs-view",children:b.map(a=>(0,e.jsxs)("div",{className:"border border-border rounded bg-surface",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>void j(a.id),className:"w-full text-left p-3 hover:bg-muted transition-colors",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("span",{className:"text-sm truncate max-w-[60%]",children:a.schedule_name||c("unknownSchedule")}),(0,e.jsx)("span",{className:`text-xs px-2 py-0.5 rounded ${function(a){switch(a){case"completed":return"text-success-foreground bg-success-subtle";case"failed":return"text-danger-foreground bg-danger-subtle";case"timeout":return"text-warning-foreground bg-warning-subtle";case"running":return"text-accent-600 dark:text-accent-400 bg-accent-50 dark:bg-accent-900/30";case"cancelled":return"text-muted-foreground bg-muted"}}(a.status)}`,children:c(`status.${a.status}`)})]}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[dE(a.started_at),dF(a.started_at,a.completed_at)&&(0,e.jsxs)("span",{className:"ml-2",children:["(",dF(a.started_at,a.completed_at),")"]}),null!==a.exit_code&&(0,e.jsxs)("span",{className:"ml-2",children:[c("exitCode"),": ",a.exit_code]})]})]}),d===a.id&&g&&(0,e.jsxs)("div",{className:"border-t border-border p-3 bg-muted space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:c("message")}),(0,e.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-foreground",children:g.message})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:c("response")}),(0,e.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-foreground max-h-60 overflow-y-auto",children:g.result||c("noOutput")})]})]})]},a.id))})});function dH(){return(0,e.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,e.jsx)("path",{d:"M13.586 3.586a2 2 0 112.828 2.828l-8.5 8.5a1 1 0 01-.43.26l-3 .857a.5.5 0 01-.617-.618l.857-3a1 1 0 01.26-.43l8.5-8.5z"})})}function dI(){return(0,e.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M8 2a1 1 0 00-.894.553L6.382 4H3a1 1 0 000 2h.293l.668 9.357A2 2 0 005.956 17h8.088a2 2 0 001.995-1.643L16.707 6H17a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0012 2H8zm1 5a1 1 0 012 0v6a1 1 0 11-2 0V7zm-3 0a1 1 0 011 1v5a1 1 0 11-2 0V8a1 1 0 011-1z",clipRule:"evenodd"})})}let dJ=(0,h.memo)(function({worktreeId:a,className:b="",onInsertToMessage:c,instances:d}){let f=(0,k.c)("schedule"),g=(0,am.SC)(),[i,j]=(0,h.useState)([]),[l,m]=(0,h.useState)([]),[o,p]=(0,h.useState)([]),[q,r]=(0,h.useState)(!0),[s,t]=(0,h.useState)(null),[u,v]=(0,h.useState)("schedules"),[w,x]=(0,h.useState)(!1),[y,z]=(0,h.useState)(!1),[A,B]=(0,h.useState)(void 0),[C,D]=(0,h.useState)(void 0),E=(0,h.useCallback)(async()=>{r(!0),t(null);try{let[b,c,d]=await Promise.all([fetch(`/api/worktrees/${a}/execution-logs`),fetch(`/api/worktrees/${a}/schedules`),fetch(`/api/worktrees/${a}/schedules/active`)]);if(b.ok){let a=await b.json();j(a.logs||[])}if(c.ok){let a=await c.json();m(a.schedules||[])}if(d.ok){let a=await d.json();p(a.schedules||[])}else p([])}catch(a){t(a instanceof Error?a.message:"Failed to fetch data")}finally{r(!1)}},[a]);(0,h.useEffect)(()=>{E()},[E]);let F=(0,h.useCallback)(async b=>{try{let c=await fetch(`/api/worktrees/${a}/files/CMATE.md`);if(!c.ok)return null;let d=await c.json(),e="string"==typeof d.content?d.content:"",f=((function(a){let b=new Map,c=a.split("\n"),d=null,e=!1,f=!1;for(let a of c){let c=a.trim(),g=c.match(/^##\s+(.+)$/);if(g){d=g[1].trim(),e=!1,f=!1,b.has(d)||b.set(d,[]);continue}if(!c||!c.startsWith("|")||!d)continue;if(!e){e=!0;continue}if(!f){if(c.match(/^\|[\s-:|]+\|$/)){f=!0;continue}f=!0}let h=c.split("|").slice(1,-1).map(a=>a.trim());h.length>0&&b.get(d).push(h)}return b})(e).get("Schedules")??[]).find(a=>(a[0]??"").trim()===b);if(!f)return null;let g=function(a){let b=a.trim();if(!b)return{cliToolId:"claude",model:void 0};let c=b.split(/\s+/),d=c[0];return 1===c.length?{cliToolId:d,model:void 0}:dv.has(d)?3===c.length&&"--model"===c[1]?{cliToolId:d,model:c[2]}:{cliToolId:d,error:`${d} only supports: ${d} --model <modelName>`}:{cliToolId:d,error:`CLI Tool "${d}" does not support additional options`}}(f[3]??"claude"),h=(f[4]??"true").trim().toLowerCase();return{name:b,cronExpression:(f[1]??"").trim(),message:(f[2]??"").trim(),cliToolId:g.cliToolId||"claude",enabled:""===h||"true"===h,permission:(f[5]??"").trim(),model:g.model??""}}catch{return null}},[a]),G=(0,h.useCallback)(()=>{D(void 0),B(void 0),z(!0)},[]),H=(0,h.useCallback)(async a=>{let b=await F(a.name);D(a.name),B(b??{name:a.name,cronExpression:a.cron_expression,message:a.message,cliToolId:a.cli_tool_id,enabled:1===a.enabled,permission:"",model:""}),z(!0)},[F]),I=(0,h.useCallback)(async b=>{if(await g({description:f("edit.confirmDelete",{name:b}),variant:"danger"}))try{(await fetch(`/api/worktrees/${a}/cmate/schedules`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b})})).ok&&await E()}catch(a){console.error("Failed to delete schedule:",a)}},[a,f,E,g]),J=(0,h.useCallback)(async b=>{try{(await fetch(`/api/worktrees/${a}/cmate/schedules`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name,enabled:1!==b.enabled})})).ok&&await E()}catch(a){console.error("Failed to toggle schedule:",a)}},[a,E]);return q?(0,e.jsx)("div",{className:`flex items-center justify-center h-full p-4 ${b}`,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)("span",{className:"text-sm text-muted-foreground",children:f("loading")})]})}):s?(0,e.jsx)("div",{className:`flex items-center justify-center h-full p-4 ${b}`,children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("span",{className:"text-sm text-danger-foreground",children:s}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:()=>void E(),className:"ml-2 px-3 py-1 text-sm text-white bg-accent-500 rounded hover:bg-accent-600",children:f("retry")})]})}):(0,e.jsxs)("div",{className:`flex flex-col h-full ${b}`,children:[(0,e.jsxs)("div",{className:"flex shrink-0 border-b border-border px-4 pt-3",children:[(0,e.jsxs)("button",{type:"button","data-testid":"schedule-tab-schedules",role:"tab","aria-selected":"schedules"===u,onClick:()=>v("schedules"),className:`-mb-px px-3 py-2 text-sm font-medium border-b-2 transition-colors ${"schedules"===u?"border-accent-500 text-accent-700 dark:text-accent-300":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[f("tabs.schedules")," (",l.length,")"]}),(0,e.jsxs)("button",{type:"button","data-testid":"schedule-tab-logs",role:"tab","aria-selected":"logs"===u,onClick:()=>v("logs"),className:`-mb-px px-3 py-2 text-sm font-medium border-b-2 transition-colors ${"logs"===u?"border-accent-500 text-accent-700 dark:text-accent-300":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[f("tabs.logs")," (",i.length,")"]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:"schedules"===u?(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,e.jsxs)("div",{className:"rounded border border-accent-100 bg-accent-50/60 p-3 dark:border-accent-900/40 dark:bg-accent-950/20",children:[(0,e.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"text-sm font-semibold text-accent-900 dark:text-accent-200",children:[f("activeSchedulesTitle")," (",o.length,")"]}),(0,e.jsx)("span",{className:"text-xs text-accent-700 dark:text-accent-300",children:f("activeSchedulesDescription")})]}),0===o.length?(0,e.jsx)("p",{className:"text-xs text-accent-800 dark:text-accent-300",children:f("noActiveSchedules")}):(0,e.jsx)("div",{className:"space-y-2",children:o.map(a=>(0,e.jsxs)("div",{className:"rounded border border-accent-200/80 bg-white/80 p-3 dark:border-accent-900/40 dark:bg-surface/60",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"font-medium text-sm text-foreground",children:a.name}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:`text-xs px-2 py-0.5 rounded ${a.isCronActive?"bg-success-subtle text-success-foreground":"bg-danger-subtle text-danger-foreground"}`,children:a.isCronActive?f("activeState.active"):f("activeState.inactive")}),a.isExecuting&&(0,e.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-accent-100 text-accent-700 dark:bg-accent-900/30 dark:text-accent-300",children:f("activeState.executing")})]})]}),(0,e.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[(0,e.jsxs)("span",{children:[f("cron"),": ",a.cronExpression||"N/A"]}),(0,e.jsxs)("span",{className:"ml-3",children:[f("agentLabel"),": ",a.cliToolId]}),a.model&&(0,e.jsxs)("span",{className:"ml-3",children:["model: ",a.model]}),a.nextRunAt&&(0,e.jsxs)("span",{className:"ml-3",children:[f("nextRun"),": ",dE(a.nextRunAt)]})]})]},a.scheduleId))})]}),0===l.length?(0,e.jsxs)("div",{className:"flex flex-col items-center text-center py-8 px-4",children:[(0,e.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-accent-50 text-accent-600 dark:bg-accent-900/30 dark:text-accent-300",children:(0,e.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",className:"w-7 h-7",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 7.5V12l3 2"})]})}),(0,e.jsx)("p",{className:"font-semibold text-foreground mb-1",children:f("emptyState.title")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-5 max-w-xs",children:f("emptyState.description")}),(0,e.jsxs)(n.$n,{variant:"ghost",type:"button","data-testid":"schedule-empty-cta",onClick:G,className:"inline-flex items-center gap-1.5 px-5 py-2.5 text-sm font-semibold text-white bg-accent-600 hover:bg-accent-700 rounded-lg shadow-sm transition-colors",children:[(0,e.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,e.jsx)("path",{d:"M10 4a1 1 0 011 1v4h4a1 1 0 110 2h-4v4a1 1 0 11-2 0v-4H5a1 1 0 110-2h4V5a1 1 0 011-1z"})}),f("emptyState.createButton")]}),(0,e.jsx)("button",{type:"button","data-testid":"schedule-manual-toggle","aria-expanded":w,onClick:()=>x(a=>!a),className:"mt-5 text-xs text-accent-700 dark:text-accent-300 hover:underline",children:f("emptyState.manualToggle")}),w&&(0,e.jsxs)("ol",{"data-testid":"schedule-manual-steps",className:"mt-3 text-xs text-left inline-block space-y-1.5 list-decimal list-inside text-muted-foreground",children:[(0,e.jsx)("li",{children:f("noSchedulesStep1")}),(0,e.jsx)("li",{children:f("noSchedulesStep2")}),(0,e.jsx)("li",{children:f("noSchedulesStep3")}),(0,e.jsx)("li",{children:f("noSchedulesStep4")})]})]}):(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"mb-2 flex items-center justify-end",children:(0,e.jsxs)(n.$n,{variant:"ghost",type:"button","data-testid":"schedule-new-button",onClick:G,className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-white bg-accent-600 hover:bg-accent-700 rounded transition-colors whitespace-nowrap",children:[(0,e.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-3.5 h-3.5",children:(0,e.jsx)("path",{d:"M10 4a1 1 0 011 1v4h4a1 1 0 110 2h-4v4a1 1 0 11-2 0v-4H5a1 1 0 110-2h4V5a1 1 0 011-1z"})}),f("edit.newSchedule")]})}),(0,e.jsx)("div",{className:"space-y-2",children:l.map(a=>{let b=1===a.enabled;return(0,e.jsxs)("div",{className:"border border-border rounded p-3 bg-white dark:bg-surface",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"font-medium text-sm truncate",children:a.name}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{type:"button",role:"switch","aria-checked":b,"aria-label":b?f("edit.disable"):f("edit.enable"),title:b?f("edit.disable"):f("edit.enable"),"data-testid":`schedule-toggle-${a.name}`,onClick:()=>void J(a),className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors ${b?"bg-success":"bg-input"}`,children:(0,e.jsx)("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform ${b?"translate-x-4":"translate-x-0.5"}`})}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button","data-testid":`schedule-edit-${a.name}`,"aria-label":f("edit.edit"),title:f("edit.edit"),onClick:()=>void H(a),className:"p-1.5 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/20 rounded transition-colors",children:(0,e.jsx)(dH,{})}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button","data-testid":`schedule-delete-${a.name}`,"aria-label":f("edit.delete"),title:f("edit.delete"),onClick:()=>void I(a.name),className:"p-1.5 text-muted-foreground hover:text-danger-foreground hover:bg-danger-subtle rounded transition-colors",children:(0,e.jsx)(dI,{})})]})]}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[(0,e.jsxs)("span",{children:[f("cron"),": ",a.cron_expression||"N/A"]}),a.last_executed_at&&(0,e.jsxs)("span",{className:"ml-3",children:[f("lastRun"),": ",dE(a.last_executed_at)]})]})]},a.id)})})]})]}):(0,e.jsx)(dG,{worktreeId:a,logs:i})}),(0,e.jsx)(dD,{isOpen:y,worktreeId:a,initialValues:A,originalName:C,onInsertToMessage:c,instances:d,onClose:()=>z(!1),onSaved:()=>{E()}})]})}),dK=(0,h.memo)(function({worktreeId:a,vibeLocalModel:b,onVibeLocalModelChange:c,vibeLocalContextWindow:d,onVibeLocalContextWindowChange:f}){let g=(0,k.c)("schedule"),[i,j]=(0,h.useState)([]),[l,n]=(0,h.useState)(null),[o,p]=(0,h.useState)(!1),[q,r]=(0,h.useState)(!1),[s,t]=(0,h.useState)(null!=d?String(d):""),[u,v]=(0,h.useState)(!1);(0,h.useEffect)(()=>{t(null!=d?String(d):"")},[d]),(0,h.useEffect)(()=>{let a=!1;return p(!0),fetch("/api/ollama/models").then(a=>a.json()).then(b=>{a||(j(b.models),n(0===b.models.length&&b.error?b.error:null))}).catch(()=>{a||(j([]),n("Failed to fetch models"))}).finally(()=>{a||p(!1)}),()=>{a=!0}},[]);let w=(0,h.useCallback)(async b=>{let d=b.target.value,e=""===d?null:d;r(!0);try{(await fetch(`/api/worktrees/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({vibeLocalModel:e})})).ok&&c(e)}catch{}finally{r(!1)}},[a,c]),x=(0,h.useCallback)(a=>{t(a.target.value)},[]),y=(0,h.useCallback)(async()=>{let b=s.trim(),c=parseInt(b,10),e=""===b||Number.isNaN(c)?null:c,g=d??null;if(e!==g){v(!0);try{(await fetch(`/api/worktrees/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({vibeLocalContextWindow:e})})).ok?f?.(e):t(null!=g?String(g):"")}catch{t(null!=g?String(g):"")}finally{v(!1)}}},[s,d,a,f]);return(0,e.jsxs)("div",{className:"mt-4 pt-4 border-t border-border",children:[(0,e.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-2",children:g("vibeLocalModel")}),o?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)(m.y,{size:"xs",variant:"muted"}),g("loading")]}):l&&0===i.length?(0,e.jsx)("p",{className:"text-xs text-warning-foreground",children:g("ollamaNotAvailable")}):(0,e.jsxs)("select",{"data-testid":"vibe-local-model-select",value:b??"",onChange:w,disabled:q,className:"w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50",children:[(0,e.jsx)("option",{value:"",children:g("vibeLocalModelDefault")}),i.map(a=>(0,e.jsxs)("option",{value:a.name,children:[a.name,a.parameterSize?` (${a.parameterSize})`:""]},a.name))]}),(0,e.jsxs)("div",{className:"mt-3",children:[(0,e.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-2",children:g("vibeLocalContextWindow")}),(0,e.jsx)("input",{type:"number","data-testid":"vibe-local-context-window-input",step:"1",min:be.vz,max:be.NL,value:s,onChange:x,onBlur:y,placeholder:g("vibeLocalContextWindowDefault"),disabled:u,className:"w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50"})]})]})}),dL=(0,h.memo)(function({worktreeId:a,selectedAgents:b,onSelectedAgentsChange:c,vibeLocalModel:d,onVibeLocalModelChange:f,vibeLocalContextWindow:g,onVibeLocalContextWindowChange:i,maxAgents:j=2,availableAgents:l=be.XH,persistToServer:m=!0}){let o=(0,k.c)("schedule"),p=b.length>j?b.slice(0,j):b,[q,r]=(0,h.useState)(()=>new Set(p)),[s,t]=(0,h.useState)(!1),[u,v]=(0,h.useState)(!1),w=(0,h.useRef)(q);w.current=q,(0,h.useEffect)(()=>{u||r(new Set(p))},[b,u,j]);let x=q.has("vibe-local"),y=(0,h.useCallback)(async(b,d)=>{let e=new Set(w.current);if(d?e.add(b):(e.delete(b),v(!0)),r(e),e.size>=2){let b=Array.from(e);if(!m){r(new Set(b)),c(b),v(!1);return}t(!0);try{(await fetch(`/api/worktrees/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({selectedAgents:b})})).ok?(r(new Set(b)),c(b)):r(new Set(p))}catch{r(new Set(p))}finally{t(!1),v(!1)}}},[a,p,c,m]),z=q.size>=j;return(0,e.jsxs)("div",{className:"p-4",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:o("agentSettings")}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:o("selectAgents")}),(0,e.jsx)("div",{className:"space-y-3",children:l.map(a=>{let b=q.has(a),c=!b&&z;return(0,e.jsxs)("label",{className:`flex items-center gap-3 p-2 rounded-lg border transition-colors ${b?"border-accent-200 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30":c?"border-border bg-muted opacity-50":"border-border hover:border-input hover:bg-muted"}`,children:[(0,e.jsx)(n.Sc,{"data-testid":`agent-checkbox-${a}`,"aria-label":(0,be.oo)(a),checked:b,disabled:c||s,onCheckedChange:b=>y(a,!0===b)}),(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:(0,be.oo)(a)})]},a)})}),s&&(0,e.jsxs)("div",{"data-testid":"agent-settings-loading",className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)(n.y$,{size:"xs",variant:"muted"}),o("loading")]}),x&&(0,e.jsx)(dK,{worktreeId:a,vibeLocalModel:d,onVibeLocalModelChange:f,vibeLocalContextWindow:g,onVibeLocalContextWindowChange:i})]})});function dM(a,b){if(0===b.length)return[];if(null!==a){let c=new Set(a),d=b.filter(a=>c.has(a.id));if(d.length>0)return d}return[...b]}let dN=(0,x.A)("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),dO=(0,x.A)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),dP=(0,x.A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),dQ=(0,h.memo)(function({worktreeId:a,instances:b,onInstancesChange:c,vibeLocalModel:d,onVibeLocalModelChange:f,vibeLocalContextWindow:g,onVibeLocalContextWindowChange:i}){let j=(0,k.c)("schedule"),l=(0,k.c)("common"),n=(0,am.SC)(),[o,p]=(0,h.useState)(!1),[q,r]=(0,h.useState)(null),[s,t]=(0,h.useState)({}),[u,v]=(0,h.useState)(be.XH[0]),[w,x]=(0,h.useState)(null),y=b.length>=be.Ab,z=b.length<=1,A=b.some(a=>"vibe-local"===a.cliTool),B=(0,h.useCallback)(async b=>{let d=b.map((a,b)=>({...a,order:b}));p(!0),r(null);try{(await fetch(`/api/worktrees/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentInstances:d})})).ok?c(d):r(j("agentInstanceSaveError"))}catch{r(j("agentInstanceSaveError"))}finally{p(!1)}},[a,c,j]),C=(0,h.useCallback)(()=>{if(b.length>=be.Ab)return;let a=function(a,b){let c=new Set(b.map(a=>a.id));if(!c.has(a))return a;let d=2;for(;c.has(`${a}-${d}`);)d++;return`${a}-${d}`}(u,b);B([...b,{id:a,cliTool:u,alias:function(a,b){let c=(0,be.oo)(a);if(b===a)return c;let d=b.slice(a.length+1);return d?`${c} ${d}`:c}(u,a),order:b.length}])},[u,b,B]),D=(0,h.useCallback)(async a=>{if(b.length<=1)return;let c=b.find(b=>b.id===a);await n({description:l("confirmDelete",{name:c?.alias??""}),variant:"danger"})&&B(b.filter(b=>b.id!==a))},[b,B,n,l]),E=(0,h.useCallback)((a,c)=>{let d=a+c;if(d<0||d>=b.length)return;let e=[...b];[e[a],e[d]]=[e[d],e[a]],B(e)},[b,B]),F=(0,h.useCallback)((a,c)=>{t(b=>{if(!(a in b))return b;let c={...b};return delete c[a],c});let d=b.find(b=>b.id===a);d&&c!==d.alias&&B(b.map(b=>b.id===a?{...b,alias:c}:b))},[b,B]),G=(0,h.useCallback)((a,c)=>{if(a===c||a<0||c<0||a>=b.length||c>=b.length)return;let d=[...b],[e]=d.splice(a,1);d.splice(c,0,e),B(d)},[b,B]);return(0,e.jsxs)("div",{className:"p-4","data-testid":"agent-instances-pane",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:j("agentInstances")}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:j("agentInstancesDescription")}),(0,e.jsx)("div",{className:"space-y-2",children:b.map((a,c)=>{let d=a.id in s?s[a.id]:a.alias,f=w===c;return(0,e.jsxs)("div",{"data-testid":`agent-instance-row-${a.id}`,draggable:!0,onDragStart:()=>x(c),onDragOver:a=>a.preventDefault(),onDrop:()=>{null!==w&&G(w,c),x(null)},onDragEnd:()=>x(null),className:`flex items-center gap-2 p-2 rounded-lg border border-border bg-surface transition-colors hover:border-accent-300 dark:hover:border-accent-700 focus-within:border-accent-500 ${f?"opacity-50":""}`,children:[(0,e.jsx)("span",{className:"cursor-grab text-muted-foreground shrink-0","aria-hidden":"true",children:(0,e.jsx)(dN,{className:"w-4 h-4"})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("input",{type:"text","data-testid":`agent-instance-alias-${a.id}`,"aria-label":j("agentInstanceAliasLabel"),value:d,maxLength:be.pQ,disabled:o,placeholder:j("agentInstanceAliasPlaceholder"),onChange:b=>t(c=>({...c,[a.id]:b.target.value})),onBlur:b=>F(a.id,b.target.value),onKeyDown:a=>{"Enter"===a.key&&a.currentTarget.blur()},className:"w-full text-sm font-medium border border-input rounded-md px-2 py-1 bg-surface dark:bg-surface-2 text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50"}),(0,e.jsx)(cP.nR,{content:(0,be.oo)(a.cliTool),className:"mt-0.5 block truncate text-xs text-muted-foreground"})]}),(0,e.jsxs)(aZ.rI,{children:[(0,e.jsx)(aZ.ty,{asChild:!0,children:(0,e.jsx)("button",{type:"button","data-testid":`agent-instance-menu-${a.id}`,"aria-label":j("agentInstanceActions"),title:j("agentInstanceActions"),disabled:o,className:"shrink-0 p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted disabled:opacity-30 disabled:cursor-not-allowed",children:(0,e.jsx)(dO,{className:"w-4 h-4"})})}),(0,e.jsxs)(aZ.SQ,{align:"end",children:[(0,e.jsxs)(aZ._2,{"data-testid":`agent-instance-move-up-${a.id}`,disabled:0===c,onSelect:()=>E(c,-1),children:[(0,e.jsx)(c6.A,{className:"w-4 h-4"}),j("agentInstanceMoveUp")]}),(0,e.jsxs)(aZ._2,{"data-testid":`agent-instance-move-down-${a.id}`,disabled:c===b.length-1,onSelect:()=>E(c,1),children:[(0,e.jsx)(bf.A,{className:"w-4 h-4"}),j("agentInstanceMoveDown")]}),(0,e.jsx)(aZ.mB,{}),(0,e.jsxs)(aZ._2,{"data-testid":`agent-instance-delete-${a.id}`,disabled:z,onSelect:()=>{D(a.id)},className:"text-danger-foreground focus:text-danger-foreground",children:[(0,e.jsx)(cL.A,{className:"w-4 h-4"}),j("agentInstanceDelete")]})]})]})]},a.id)})}),(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-2",children:[(0,e.jsx)("select",{"data-testid":"agent-instance-add-tool","aria-label":j("agentInstanceBaseTool"),value:u,disabled:o||y,onChange:a=>v(a.target.value),className:"flex-1 min-w-0 text-sm border border-input rounded-md px-2 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50",children:be.XH.map(a=>(0,e.jsx)("option",{value:a,children:(0,be.oo)(a)},a))}),(0,e.jsxs)("button",{type:"button","data-testid":"agent-instance-add",disabled:o||y,onClick:C,className:"flex items-center gap-1 text-sm font-medium px-3 py-2 rounded-md border border-accent-200 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 hover:bg-accent-100 dark:hover:bg-accent-900/50 disabled:opacity-40 disabled:cursor-not-allowed shrink-0",children:[(0,e.jsx)(dP,{className:"w-4 h-4"}),j("agentInstanceAdd")]})]}),y&&(0,e.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:j("agentInstanceMax",{max:be.Ab})}),z&&(0,e.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:j("agentInstanceMin",{min:1})}),o&&(0,e.jsxs)("div",{"data-testid":"agent-instances-loading",className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)(m.y,{size:"xs",variant:"muted"}),j("loading")]}),q&&(0,e.jsx)("p",{"data-testid":"agent-instances-error",className:"mt-3 text-xs text-danger-foreground",children:q}),A&&(0,e.jsx)(dK,{worktreeId:a,vibeLocalModel:d,onVibeLocalModelChange:f,vibeLocalContextWindow:g,onVibeLocalContextWindowChange:i})]})}),dR=(0,h.memo)(function({worktreeId:a,instances:b,onInstancesChange:c,vibeLocalModel:d,onVibeLocalModelChange:f,vibeLocalContextWindow:g,onVibeLocalContextWindowChange:h,visibleInstanceIds:i,onToggleInstanceVisible:j}){let l=(0,k.c)("schedule"),m=new Set(i),o=i.length<=1;return(0,e.jsxs)("div",{"data-testid":"mobile-agent-instances-pane",children:[(0,e.jsx)(dQ,{worktreeId:a,instances:b,onInstancesChange:c,vibeLocalModel:d,onVibeLocalModelChange:f,vibeLocalContextWindow:g,onVibeLocalContextWindowChange:h}),(0,e.jsxs)("div",{"data-testid":"mobile-visible-instances",className:"px-4 pb-4 border-t border-border mt-2 pt-4",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:l("mobileVisibleInstances")}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:l("mobileVisibleInstancesDescription")}),(0,e.jsx)("div",{className:"space-y-1",children:b.map(a=>{let b=m.has(a.id),c=b&&o;return(0,e.jsxs)("label",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer ${c?"opacity-60 cursor-not-allowed":"hover:bg-muted"}`,children:[(0,e.jsx)(n.Sc,{"data-testid":`mobile-visible-instance-toggle-${a.id}`,checked:b,disabled:c,onCheckedChange:()=>j(a.id)}),(0,e.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground truncate",children:(0,be.sw)(a)}),(0,e.jsx)("span",{className:"block text-xs text-muted-foreground truncate",children:(0,be.oo)(a.cliTool)})]})]},a.id)})}),o&&(0,e.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:l("mobileVisibleInstanceMin")})]})]})}),dS=Array.from({length:Math.floor(104)+1},(a,b)=>3e5+3e5*b);c(30868);let dT=[36e5,108e5,288e5],dU={36e5:"autoYes.durations.1h",108e5:"autoYes.durations.3h",288e5:"autoYes.durations.8h"};function dV(a){let b=Math.max(0,a-Date.now()),c=Math.floor(b/36e5),d=Math.floor(b%36e5/6e4),e=Math.floor(b%6e4/1e3);return c>0?`${c}:${d.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`:`${d.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`}function dW(a){let b=Math.floor(a/6e4),c=Math.floor(b/60),d=b%60;return c>0&&d>0?`${c}h ${d}m`:c>0?`${c}h`:`${d}m`}let dX="w-full px-3 py-2 text-sm border border-input rounded-md bg-surface dark:bg-surface-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring";function dY({isOpen:a,worktreeId:b,instances:c,onClose:d,onSaved:f}){let g=(0,k.c)("schedule"),i=(0,ab.a)(),j=(0,h.useMemo)(()=>c&&c.length>0?c:(0,be.lu)([...be.XH]),[c]),[l,m]=(0,h.useState)(""),[n,o]=(0,h.useState)(()=>j[0]?.id??be.XH[0]),[p,q]=(0,h.useState)(dS[0]),[r,s]=(0,h.useState)(!1),[t,u]=(0,h.useState)(null),v=l.trim().length>0&&!r,w=(0,h.useCallback)(async()=>{if(!l.trim()||r)return;let a=j.find(a=>a.id===n);if(a){u(null),s(!0);try{let c=await fetch(`/api/worktrees/${b}/timers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:a.cliTool,instanceId:a.id,message:l.trim(),delayMs:p})});if(c.ok){let a=await c.json();f(),"session_not_running"===a.warning?(u("session_not_running"),m("")):d()}}catch{}finally{s(!1)}}},[b,j,n,l,p,r,f,d]),x=(0,e.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-instance-select",children:g("timer.agent")}),(0,e.jsx)("select",{id:"timer-instance-select","data-testid":"timer-instance-select",value:n,onChange:a=>o(a.target.value),className:dX,children:j.map(a=>(0,e.jsx)("option",{value:a.id,children:a.alias},a.id))})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-message-input",children:g("timer.message")}),(0,e.jsx)("textarea",{id:"timer-message-input","data-testid":"timer-message-input",value:l,onChange:a=>m(a.target.value),placeholder:g("timer.message"),maxLength:1e4,rows:3,className:`${dX} resize-none`})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-delay-select",children:g("timer.delay")}),(0,e.jsx)("select",{id:"timer-delay-select","data-testid":"timer-delay-select",value:p,onChange:a=>q(Number(a.target.value)),className:dX,children:dS.map(a=>(0,e.jsx)("option",{value:a,children:dW(a)},a))})]}),"session_not_running"===t&&(0,e.jsx)("div",{"data-testid":"timer-session-warning",className:"text-xs p-2 rounded bg-warning-subtle text-warning-foreground",children:g("timer.sessionWarning")})]}),y=(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:d,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:g("timer.close")}),(0,e.jsx)("button",{type:"button","data-testid":"timer-register-button",onClick:()=>void w(),disabled:!v,className:"px-4 py-2 text-sm font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-md transition-colors",children:g("timer.register")})]}),z=g("timer.titleCreate");return i?(0,e.jsx)(dk,{isOpen:a,onClose:d,title:z,footer:y,children:x}):(0,e.jsx)(bc.a,{isOpen:a,onClose:d,title:z,size:"md",children:(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[x,(0,e.jsx)("div",{className:"pt-2 border-t border-border",children:y})]})})}function dZ(a){return new Date(a).toLocaleString()}function d$({timer:a,instances:b,onClose:c}){let d=(0,k.c)("schedule"),f=(0,ab.a)();if(!a)return null;let g=b.find(b=>b.id===a.instanceId)?.alias??a.cliToolId,h=({label:a,children:b})=>(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-0.5",children:a}),(0,e.jsx)("div",{className:"text-sm text-foreground break-words",children:b})]}),i=(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"timer-detail-body",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:d("timer.message")}),(0,e.jsx)("pre",{"data-testid":"timer-detail-message",className:"text-sm whitespace-pre-wrap break-words font-mono text-foreground bg-muted rounded p-2 max-h-60 overflow-y-auto",children:a.message})]}),(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,e.jsx)(h,{label:d("timer.agent"),children:(0,e.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-medium",children:g})}),(0,e.jsx)(h,{label:d("timer.statusLabel"),children:(0,e.jsx)("span",{className:function(a){switch(a){case"pending":return"text-info";case"sending":case"no_session":return"text-warning-foreground";case"sent":return"text-success-foreground";case"failed":return"text-danger-foreground";default:return"text-muted-foreground"}}(a.status),children:d(`timer.status.${a.status}`)})}),(0,e.jsx)(h,{label:d("timer.delay"),children:dW(a.delayMs)}),(0,e.jsx)(h,{label:d("timer.scheduledTime"),children:dZ(a.scheduledSendTime)}),(0,e.jsx)(h,{label:d("timer.createdTime"),children:dZ(a.createdAt)}),null!==a.sentAt&&(0,e.jsx)(h,{label:d("timer.sentTime"),children:dZ(a.sentAt)})]}),"failed"===a.status&&a.error&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-danger-foreground mb-1",children:d("timer.failureReason")}),(0,e.jsx)("pre",{"data-testid":"timer-detail-error",className:"text-xs whitespace-pre-wrap break-words font-mono text-danger-foreground bg-danger-subtle rounded p-2 max-h-40 overflow-y-auto",children:a.error})]})]}),j=(0,e.jsx)("div",{className:"flex items-center justify-end",children:(0,e.jsx)("button",{type:"button","data-testid":"timer-detail-close",onClick:c,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:d("timer.close")})}),l=d("timer.detailTitle");return f?(0,e.jsx)(dk,{isOpen:!0,title:l,onClose:c,footer:j,children:i}):(0,e.jsx)(bc.a,{isOpen:!0,title:l,onClose:c,size:"md",children:(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[i,(0,e.jsx)("div",{className:"pt-2 border-t border-border",children:j})]})})}let d_=(0,h.memo)(function({worktreeId:a,instances:b}){let c=(0,k.c)("schedule"),d=(0,am.SC)(),f=(0,h.useMemo)(()=>b&&b.length>0?b:(0,be.lu)([...be.XH]),[b]),[g,i]=(0,h.useState)([]),[j,l]=(0,h.useState)(!1),[m,n]=(0,h.useState)(!1),[o,p]=(0,h.useState)(null),[,q]=(0,h.useState)(0),r=(0,h.useRef)(null),s=(0,h.useRef)(null),t=(0,h.useRef)(null),u=(0,h.useCallback)(async()=>{try{let b=await fetch(`/api/worktrees/${a}/timers`);if(b.ok){let a=await b.json();i(a.timers),l(a.hasMore??!1),a.timers.length>0?t.current=a.timers[a.timers.length-1].createdAt:t.current=null}}catch{}},[a]),v=(0,h.useCallback)(async()=>{if(null!=t.current)try{let b=new URLSearchParams;b.set("before",String(t.current)),b.set("limit",String(50));let c=await fetch(`/api/worktrees/${a}/timers?${b}`);if(c.ok){let a=await c.json();i(b=>[...b,...a.timers]),l(a.hasMore??!1),a.timers.length>0&&(t.current=a.timers[a.timers.length-1].createdAt)}}catch{}},[a]);(0,h.useEffect)(()=>{function a(){return u(),r.current=setInterval(()=>{u()},1e4),s.current=setInterval(()=>{q(a=>a+1)},1e3),b}function b(){r.current&&clearInterval(r.current),s.current&&clearInterval(s.current),r.current=null,s.current=null}a();let c=()=>{"hidden"===document.visibilityState?b():a()};return document.addEventListener("visibilitychange",c),()=>{b(),document.removeEventListener("visibilitychange",c)}},[u]);let w=(0,h.useCallback)(async b=>{try{(await fetch(`/api/worktrees/${a}/timers?timerId=${b}`,{method:"DELETE"})).ok&&u()}catch{}},[a,u]),x=(0,h.useCallback)(async()=>{if(await d({description:c("timer.clearConfirm"),variant:"danger"}))try{(await fetch(`/api/worktrees/${a}/timers/history`,{method:"DELETE"})).ok&&u()}catch{}},[a,u,c,d]),z=g.filter(a=>"pending"===a.status).length>=5;return(0,e.jsxs)("div",{className:"flex flex-col h-full p-3 gap-3 overflow-auto",children:[0===g.length?(0,e.jsxs)("div",{className:"flex flex-col items-center text-center py-8 px-4",children:[(0,e.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-accent-50 text-accent-600 dark:bg-accent-900/30 dark:text-accent-300",children:(0,e.jsx)(y,{className:"w-7 h-7"})}),(0,e.jsx)("p",{className:"font-semibold text-foreground mb-1",children:c("timer.title")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-5 max-w-xs",children:c("timer.noTimers")}),(0,e.jsxs)("button",{type:"button","data-testid":"timer-empty-cta",onClick:()=>n(!0),className:"inline-flex items-center gap-1.5 px-5 py-2.5 text-sm font-semibold text-white bg-accent-600 hover:bg-accent-700 rounded-lg shadow-sm transition-colors",children:[(0,e.jsx)(dP,{className:"w-4 h-4"}),c("timer.createButton")]})]}):(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[z&&(0,e.jsx)("span",{className:"text-xs text-warning-foreground",children:c("timer.maxReached",{max:5})}),(0,e.jsxs)("button",{type:"button","data-testid":"timer-new-button",onClick:()=>n(!0),disabled:z,className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded transition-colors whitespace-nowrap",children:[(0,e.jsx)(dP,{className:"w-3.5 h-3.5"}),c("timer.newTimer")]})]}),g.map(a=>(0,e.jsxs)("div",{role:"button",tabIndex:0,"data-testid":"timer-row",onClick:()=>p(a),onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),p(a))},className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-surface text-left cursor-pointer hover:bg-muted transition-colors",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("div",{className:"text-sm text-foreground truncate",children:a.message.length>60?a.message.slice(0,60)+"...":a.message}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,e.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-medium",children:f.find(b=>b.id===a.instanceId)?.alias??a.cliToolId}),(0,e.jsx)("span",{className:function(a){switch(a){case"pending":return"text-info";case"sending":case"no_session":return"text-warning-foreground";case"sent":return"text-success-foreground";case"failed":return"text-danger-foreground";default:return"text-muted-foreground"}}(a.status),children:c(`timer.status.${a.status}`)}),"pending"===a.status&&(0,e.jsx)("span",{className:"text-muted-foreground",children:dV(a.scheduledSendTime)}),(0,e.jsx)("span",{className:"text-muted-foreground",children:dW(a.delayMs)})]})]}),"pending"===a.status&&(0,e.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation(),w(a.id)},className:"px-2 py-1 text-xs text-danger-foreground hover:bg-danger-subtle rounded transition-colors",children:c("timer.cancel")})]},a.id)),j&&(0,e.jsx)("button",{type:"button",onClick:v,className:"px-3 py-2 text-sm text-accent-600 dark:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/20 rounded-md transition-colors text-center",children:c("timer.loadMore")}),g.some(a=>"pending"!==a.status)&&(0,e.jsx)("button",{type:"button",onClick:x,className:"px-3 py-2 text-sm text-muted-foreground hover:bg-muted rounded-md transition-colors text-center",children:c("timer.clearHistory")})]}),(0,e.jsx)(dY,{isOpen:m,worktreeId:a,instances:b,onClose:()=>n(!1),onSaved:()=>{u()}}),(0,e.jsx)(d$,{timer:o,instances:f,onClose:()=>p(null)})]})});var d0=c(79944),d1=c(81136);let d2={verified:"skills.compatibility.axisOutcome.verified",unsupported:"skills.compatibility.axisOutcome.unsupported",unknown:"skills.compatibility.axisOutcome.unknown"},d3={mechanical:"skills.compatibility.evidenceKind.mechanical",self_report:"skills.compatibility.evidenceKind.selfReport",not_measured:"skills.compatibility.evidenceKind.notMeasured"},d4={outcome:"unknown",evidenceKind:"not_measured",labelKey:d2.unknown,evidenceKindKey:d3.not_measured,limitationKey:null},d5={SESSION_RESTART:"skills.compatibility.reload.sessionRestart",SESSION_RESTART_NO_SLASH:"skills.compatibility.reload.sessionRestartNoSlash",UNKNOWN:"skills.compatibility.reload.unknown"};function d6(a){return{agent:a,discoveryRoots:[],discovery:d4,invocation:d4,testedVersion:null,testedDate:null,evidenceSource:null,reloadKey:d5.UNKNOWN,skipReasonKey:"skills.compatibility.skipReason.notMeasured"}}d1.td,d2.verified,d3.mechanical,d2.verified,d3.mechanical,d5.SESSION_RESTART,d1.Co,d2.verified,d3.self_report,d2.unsupported,d3.mechanical,d5.SESSION_RESTART_NO_SLASH,d6("gemini"),d6("vibe-local"),d6("opencode"),d6("copilot"),d6("antigravity");let d7={SATISFIED:"SKILL_COMPAT_SATISFIED",HOST_VERSION_OUT_OF_RANGE:"SKILL_COMPAT_HOST_VERSION_OUT_OF_RANGE",HOST_VERSION_UNKNOWN:"SKILL_COMPAT_HOST_VERSION_UNKNOWN",RANGE_UNSUPPORTED:"SKILL_COMPAT_RANGE_UNSUPPORTED"};d7.SATISFIED,d7.HOST_VERSION_OUT_OF_RANGE,d7.HOST_VERSION_UNKNOWN,d7.RANGE_UNSUPPORTED;let d8={CONFIRMED:"SKILL_AGENT_EVIDENCE_CONFIRMED",RESTRICTED:"SKILL_AGENT_EVIDENCE_RESTRICTED",STALE_DECLARATION:"SKILL_AGENT_EVIDENCE_STALE_DECLARATION",UNVERIFIED:"SKILL_AGENT_EVIDENCE_UNVERIFIED"};d8.CONFIRMED,d8.RESTRICTED,d8.STALE_DECLARATION,d8.UNVERIFIED;let d9=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;function ea(a){if("string"!=typeof a||a.length>64)return null;let b=d9.exec(a);return b?{major:Number(b[1]),minor:Number(b[2]),patch:Number(b[3]),prerelease:b[4]?b[4].split("."):[],build:b[5]?b[5].split("."):[]}:null}let eb={UP_TO_DATE:"SKILL_UPDATE_UP_TO_DATE",HIGHEST_COMPATIBLE:"SKILL_UPDATE_RECOMMEND_HIGHEST_COMPATIBLE",LATEST_UNVERIFIED:"SKILL_UPDATE_RECOMMEND_LATEST_UNVERIFIED",NONE_COMPATIBLE:"SKILL_UPDATE_RECOMMEND_NONE_COMPATIBLE",INSTALLED_VERSION_INVALID:"SKILL_UPDATE_INSTALLED_VERSION_INVALID",RANGE_UNSUPPORTED:"SKILL_UPDATE_RANGE_UNSUPPORTED"};function ec(a,b){let c=function(a,b){let c=ea(a),d=ea(b);return c&&d?c.major!==d.major?c.major<d.major?-1:1:c.minor!==d.minor?c.minor<d.minor?-1:1:c.patch!==d.patch?c.patch<d.patch?-1:1:function(a,b){if(0===a.length&&0===b.length)return 0;if(0===a.length)return 1;if(0===b.length)return -1;let c=Math.min(a.length,b.length);for(let d=0;d<c;d++){let c=a[d],e=b[d];if(c===e)continue;let f=/^\d+$/.test(c),g=/^\d+$/.test(e);if(f&&g)return Number(c)<Number(e)?-1:1;if(f)return -1;if(g)return 1;return c<e?-1:1}return a.length===b.length?0:a.length<b.length?-1:1}(c.prerelease,d.prerelease):null}(a,b);return null!==c&&c>0}eb.UP_TO_DATE,eb.HIGHEST_COMPATIBLE,eb.LATEST_UNVERIFIED,eb.NONE_COMPATIBLE,eb.INSTALLED_VERSION_INVALID,eb.RANGE_UNSUPPORTED;var ed=c(28593),ee=c(9815),ef=c(3805),eg=c(27884),eh=c(30156);let ei={open:!1,selectedVersion:null,busy:!1,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applying:!1,applyResult:null,applyFailure:null};function ej({heading:a,paths:b,testid:c}){return 0===b.length?null:(0,e.jsxs)("div",{"data-testid":c,children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a}),(0,e.jsx)("ul",{className:"mt-1 space-y-0.5",children:b.map(a=>(0,e.jsx)("li",{className:"break-all font-mono text-xs text-foreground",children:a},a))})]})}function ek({skillId:a,skillName:b,worktreeId:c,installedVersion:d,versions:f}){let g=(0,k.c)("skills"),i=(0,h.useMemo)(()=>f.filter(a=>ec(a.version,d)),[f,d]),j=(0,h.useMemo)(()=>(i.find(a=>"compatible"===a.compatibility.commandmate.status)??i[0])?.version??null,[i]),[l,m]=(0,h.useState)(ei),o=(0,h.useCallback)(()=>{m({...ei,open:!0,selectedVersion:j})},[j]),p=(0,h.useCallback)(()=>{m(ei)},[]),q=(0,h.useCallback)(async()=>{let b=l.selectedVersion;if(!b)return;m(a=>({...a,busy:!0,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applyResult:null,applyFailure:null}));let d=await (0,eh.Sw)(c,a,{version:b});m(a=>({...a,busy:!1,plan:d.ok?d.data.plan:null,failure:d.ok?null:d.failure}))},[a,l.selectedVersion,c]),r=(0,h.useCallback)(async()=>{var b;let d=l.plan;if(!d||!d.updatable)return;m(a=>({...a,applying:!0,applyFailure:null}));let e=await (0,eh.h2)(c,a,{planToken:d.token,version:d.update.toVersion,acknowledgeRisk:l.riskAcknowledged,acknowledgeRiskIncrease:l.riskIncreaseAcknowledged,idempotencyKey:(b=d.token,`skill-update-${b}`)});m(a=>({...a,applying:!1,applyResult:e.ok?e.data:null,applyFailure:e.ok?null:e.failure}))},[a,l.plan,l.riskAcknowledged,l.riskIncreaseAcknowledged,c]);if(0===i.length)return(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-uptodate",children:g("update.upToDate",{version:d})});let s=l.plan,t=l.applyResult;return(0,e.jsxs)("div",{"data-testid":"skill-update-dialog-host",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(n.Ex,{variant:"info","data-testid":"skill-update-badge",children:g("update.badge")}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:g("update.fromTo",{from:d,to:i[0].version})}),(0,e.jsx)(n.$n,{variant:"secondary",size:"sm",onClick:o,"data-testid":"skill-update-trigger",children:g("update.open")})]}),(0,e.jsx)(n.Jh,{isOpen:l.open,onClose:p,title:g("update.heading"),size:"lg",children:(0,e.jsxs)("div",{className:"space-y-3 p-4","data-testid":"skill-update-dialog",children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:g("update.intro",{skill:b,version:d})}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:g("update.ready")}),(0,e.jsxs)("label",{className:"block text-xs font-medium text-muted-foreground",children:[g("update.versionPicker"),(0,e.jsx)("select",{className:"w-full rounded-md border border-input bg-surface px-3 py-2 text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring mt-1",value:l.selectedVersion??"",onChange:a=>m(b=>({...b,selectedVersion:a.target.value,plan:null,failure:null})),disabled:l.busy,"data-testid":"skill-update-version-select",children:i.map(a=>(0,e.jsxs)("option",{value:a.version,children:[a.version,a.prerelease?` (${g("detail.prerelease")})`:"","compatible"!==a.compatibility.commandmate.status?` — ${g(eg.OV[a.compatibility.commandmate.status])}`:""]},a.version))})]}),(0,e.jsx)(n.$n,{variant:"primary",disabled:l.busy||!l.selectedVersion,onClick:q,"data-testid":"skill-update-build",children:l.busy?g("update.building"):g("update.build")}),l.failure&&(0,e.jsxs)(ef.u,{tone:"danger","data-testid":"skill-update-error",children:[(0,e.jsx)("p",{children:g((0,eg.FW)(l.failure.code))}),(0,e.jsx)("p",{className:"mt-1 break-words",children:g("state.errorCode",{code:l.failure.code})})]}),s&&(0,e.jsxs)("div",{className:"space-y-3","data-testid":"skill-update-plan",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"text-sm font-semibold text-foreground",children:g("update.fromTo",{from:s.update.fromVersion,to:s.update.toVersion})}),null!==s.update.latestVersion&&s.update.latestVersion!==s.update.toVersion&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:g("update.latestAvailable",{version:s.update.latestVersion})})]}),(0,e.jsx)(ef.u,{tone:s.updatable?"info":"warning","data-testid":"skill-update-next-action",children:g((0,eg.e5)(s.nextActionKey))}),s.blockers.length>0&&(0,e.jsx)("ul",{className:"space-y-1","data-testid":"skill-update-blockers",children:s.blockers.map(a=>(0,e.jsxs)("li",{className:"text-xs text-danger-foreground",children:[a.path&&(0,e.jsx)("span",{className:"mr-1 break-all font-mono",children:a.path}),g((0,eg.e5)(a.messageKey))]},`${a.code}:${a.path??""}`))}),(0,e.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-risk",children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g("plan.riskHeading")}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-foreground",children:[(0,e.jsx)(ed.qW,{risk:s.securityDiff.risk.from.effective}),(0,e.jsx)("span",{"aria-hidden":"true",children:"→"}),(0,e.jsx)(ed.qW,{risk:s.securityDiff.risk.to.effective})]}),s.riskIncreased&&s.riskIncreaseMessageKey&&(0,e.jsx)(ef.u,{tone:"danger","data-testid":"skill-update-risk-increase",children:g((0,eg.e5)(s.riskIncreaseMessageKey))}),s.requiresRiskAcknowledgement&&s.riskAcknowledgementMessageKey&&(0,e.jsx)(ef.u,{tone:"warning","data-testid":"skill-update-high-risk",children:g((0,eg.e5)(s.riskAcknowledgementMessageKey))}),s.updatable&&!l.applyResult&&s.requiresRiskAcknowledgement&&(0,e.jsxs)("label",{className:"flex items-start gap-2 text-xs text-foreground",children:[(0,e.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:l.riskAcknowledged,onChange:a=>m(b=>({...b,riskAcknowledged:a.target.checked})),"data-testid":"skill-update-ack-risk"}),g("update.ackRisk")]}),s.updatable&&!l.applyResult&&s.riskIncreased&&(0,e.jsxs)("label",{className:"flex items-start gap-2 text-xs text-foreground",children:[(0,e.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:l.riskIncreaseAcknowledged,onChange:a=>m(b=>({...b,riskIncreaseAcknowledged:a.target.checked})),"data-testid":"skill-update-ack-risk-increase"}),g("update.ackRiskIncrease")]})]}),(0,e.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-security-diff",children:[s.securityDiff.permissions.added.length>0&&(0,e.jsxs)("div",{"data-testid":"skill-update-permissions-added",children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g("update.permissionsAdded")}),(0,e.jsx)("ul",{className:"mt-1 space-y-0.5",children:s.securityDiff.permissions.added.map(a=>(0,e.jsx)("li",{className:"text-xs text-foreground",children:g(eg.z2[a]??"plan.permissionsNone")},a))})]}),s.securityDiff.permissions.removed.length>0&&(0,e.jsxs)("div",{"data-testid":"skill-update-permissions-removed",children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g("update.permissionsRemoved")}),(0,e.jsx)("ul",{className:"mt-1 space-y-0.5",children:s.securityDiff.permissions.removed.map(a=>(0,e.jsx)("li",{className:"text-xs text-foreground",children:g(eg.z2[a]??"plan.permissionsNone")},a))})]}),(0,e.jsx)(ej,{heading:g("update.scriptsAdded"),paths:s.securityDiff.scripts.added,testid:"skill-update-scripts-added"}),(0,e.jsx)(ej,{heading:g("update.scriptsRemoved"),paths:s.securityDiff.scripts.removed,testid:"skill-update-scripts-removed"}),(0,e.jsx)(ej,{heading:g("update.executablesAdded"),paths:s.securityDiff.executables.added,testid:"skill-update-executables-added"}),(0,e.jsx)(ej,{heading:g("update.executablesRemoved"),paths:s.securityDiff.executables.removed,testid:"skill-update-executables-removed"})]}),s.securityDiff.changelogs.length>0&&(0,e.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-changelogs",children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g("detail.changelogHeading")}),s.securityDiff.changelogs.map(a=>(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-foreground",children:a.version}),(0,e.jsx)("p",{className:"whitespace-pre-wrap text-xs text-muted-foreground",children:a.changelog})]},a.version))]}),(0,e.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-files",children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g("update.filesHeading")}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-stats",children:g("update.stats",{added:s.stats.added,updated:s.stats.updated,removed:s.stats.removed,unchanged:s.stats.unchanged})}),(0,e.jsx)("ul",{className:"space-y-1",children:s.files.filter(a=>"unchanged"!==a.change).map(a=>(0,e.jsxs)("li",{"data-testid":"skill-update-file",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(n.Ex,{variant:eg.JD[a.change]??"gray",children:g(eg.KS[a.change]??"update.change.update")}),(0,e.jsx)("span",{className:"break-all font-mono text-xs text-foreground",children:a.path})]}),a.diff&&(0,e.jsxs)("details",{className:"mt-1",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:g("update.showDiff")}),(0,e.jsx)("pre",{className:"mt-1 overflow-x-auto rounded-md bg-muted p-2 text-xs text-foreground",children:a.diff})]})]},a.path))})]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-expiry",children:g("plan.expiresAt",{timestamp:s.expiresAt})}),s.updatable&&!l.applyResult&&(0,e.jsx)(n.$n,{variant:"primary",disabled:l.applying||s.requiresRiskAcknowledgement&&!l.riskAcknowledged||s.riskIncreased&&!l.riskIncreaseAcknowledged,onClick:r,"data-testid":"skill-update-apply",children:l.applying?g("update.applying"):g("update.apply")}),l.applyFailure&&(0,e.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-apply-error",children:[(0,e.jsxs)(ef.u,{tone:"danger",children:[(0,e.jsx)("p",{children:g((0,eg.FW)(l.applyFailure.code))}),(0,e.jsx)("p",{className:"mt-1 break-words",children:g("state.errorCode",{code:l.applyFailure.code})})]}),l.applyFailure.nextActionKey&&(0,e.jsx)(ef.u,{tone:"warning",children:g((0,eg.e5)(l.applyFailure.nextActionKey))}),l.applyFailure.blockers&&l.applyFailure.blockers.length>0&&(0,e.jsx)("ul",{className:"space-y-1","data-testid":"skill-update-apply-error-blockers",children:l.applyFailure.blockers.map(a=>(0,e.jsxs)("li",{className:"text-xs text-danger-foreground",children:[a.path&&(0,e.jsx)("span",{className:"mr-1 break-all font-mono",children:a.path}),g((0,eg.e5)(a.messageKey))]},`${a.code}:${a.path??""}`))})]})]}),t&&(0,e.jsxs)("div",{className:"space-y-3","data-testid":"skill-update-result",children:[(0,e.jsx)(ef.u,{tone:"succeeded"===t.operation.result?"info":"warning","data-testid":"skill-update-result-next-action",children:g((0,eg.e5)(t.operation.nextActionKey))}),"reload"in t&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-sm font-semibold text-foreground",children:g("update.fromTo",{from:t.update.fromVersion,to:t.update.toVersion})}),(0,e.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-result-reload",children:[(0,e.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g("operation.reloadHeading")}),(0,e.jsx)("ul",{className:"space-y-1",children:t.reload.agents.map(a=>(0,e.jsx)("li",{className:"text-xs text-muted-foreground",children:g((0,eg.e5)(a.messageKey),{agent:(0,be.f_)(a.agent),skillId:t.reload.skillId,version:t.reload.version})},a.agent))})]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-result-rollback",children:g((0,eg.e5)(t.rollback.messageKey),{version:t.rollback.backup.fromVersion})})]})]})]})})]})}let el={status:"loading",skills:[],failure:null},em={status:"loading",skills:[],failure:null};function en({worktreeId:a,className:b=""}){let c=(0,k.c)("skills"),[d,f]=(0,h.useState)(el),[g,i]=(0,h.useState)(em),[j,l]=(0,h.useState)(null),[m,o]=(0,h.useState)(0),[p,q]=(0,h.useState)(0),r=(0,h.useMemo)(()=>new Map(g.skills.map(a=>[a.skillId,a.version])),[g.skills]),s=(0,h.useMemo)(()=>new Map(d.skills.map(a=>[a.id,{name:a.name,summary:a.summary,latest:a.latest}])),[d.skills]),t=(0,h.useMemo)(()=>{let a=new Map;for(let[c,d]of r){var b;a.set(c,(b=s.get(c)?.latest??null,null!==d&&null!==b&&ec(b,d)))}return a},[r,s]),u=(0,h.useMemo)(()=>d.skills.find(a=>a.id===j)??null,[d.skills,j]),v=(0,h.useMemo)(()=>g.skills.find(a=>a.skillId===j)??null,[g.skills,j]);if(j){let d=u?.compatibility??null,f=u?u.recommendedVersion:v?.version??null,g=u?u.recommendedVersion?d&&"compatible"!==d.status?c("detail.install.blockedIncompatible",{reason:c((0,eg.e5)(d.messageKey),{range:d.requiredRange,currentVersion:d.currentVersion??""})}):null:c("detail.install.blockedNoVersion"):null;return(0,e.jsxs)("div",{className:`flex flex-col min-h-0 ${b}`.trim(),"data-testid":"worktree-skills-pane",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 border-b border-border p-3",children:[(0,e.jsxs)(n.$n,{variant:"ghost",size:"sm",onClick:()=>{l(null),q(a=>a+1)},"data-testid":"worktree-skills-back",children:[(0,e.jsx)(d0.A,{size:14,"aria-hidden":"true",className:"mr-1"}),c("worktreePane.back")]}),(0,e.jsx)("h2",{className:"min-w-0 truncate text-sm font-semibold text-foreground",children:u?.name??j})]}),(0,e.jsxs)("div",{className:"min-h-0 flex-1 space-y-3 overflow-auto p-3",children:[v&&u&&(0,e.jsx)(ek,{skillId:j,skillName:u.name,worktreeId:a,installedVersion:v.version,versions:u.versions}),(0,e.jsx)(ee.B,{skillId:j,version:f,blockedReason:g,worktreeId:a})]})]})}return(0,e.jsx)("div",{className:`flex flex-col min-h-0 ${b}`.trim(),"data-testid":"worktree-skills-pane",children:(0,e.jsxs)("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-3",children:[(0,e.jsxs)("section",{className:"space-y-2","data-testid":"worktree-skills-installed",children:[(0,e.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:c("worktreePane.installedHeading")}),"loading"===g.status?(0,e.jsx)(n.EA,{className:"h-16 w-full rounded-lg","data-testid":"worktree-skills-installed-loading"}):"error"===g.status?(0,e.jsxs)(n.Zp,{className:"space-y-2","data-testid":"worktree-skills-installed-error",children:[(0,e.jsxs)(ef.u,{tone:"danger",children:[(0,e.jsx)("p",{children:c("worktreePane.installedError")}),(0,e.jsx)("p",{className:"mt-1 break-words",children:c("state.errorCode",{code:g.failure?.code??""})})]}),(0,e.jsx)(n.$n,{variant:"secondary",size:"sm",onClick:()=>q(a=>a+1),"data-testid":"worktree-skills-installed-retry",children:c("state.retry")})]}):0===g.skills.length?(0,e.jsx)(n.Zp,{"data-testid":"worktree-skills-installed-empty",children:(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:c("worktreePane.installedEmpty")})}):(0,e.jsx)("ul",{className:"space-y-2",children:g.skills.map(a=>{let b=s.get(a.skillId);return(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",onClick:()=>l(a.skillId),"data-testid":`worktree-skills-installed-${a.skillId}`,className:"w-full rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"break-all text-sm font-semibold text-foreground",children:b?.name??a.skillId}),(0,e.jsx)(ed.qW,{risk:a.effectiveRisk}),t.get(a.skillId)&&(0,e.jsx)(n.Ex,{variant:"info","data-testid":`worktree-skills-update-badge-${a.skillId}`,children:c("worktreePane.updateBadge")})]}),b?.summary&&(0,e.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground line-clamp-2","data-testid":`worktree-skills-installed-summary-${a.skillId}`,children:b.summary}),(0,e.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:c("worktreePane.version",{version:a.version})})]})},a.skillId)})})]}),(0,e.jsxs)("section",{className:"space-y-2","data-testid":"worktree-skills-catalog",children:[(0,e.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:c("worktreePane.catalogHeading")}),"loading"===d.status?(0,e.jsx)(n.EA,{className:"h-24 w-full rounded-lg","data-testid":"worktree-skills-catalog-loading"}):"error"===d.status?(0,e.jsxs)(n.Zp,{className:"space-y-2","data-testid":"worktree-skills-catalog-error",children:[(0,e.jsxs)(ef.u,{tone:"danger",children:[(0,e.jsx)("p",{children:c("state.errorNotice")}),(0,e.jsx)("p",{className:"mt-1 break-words",children:c("state.errorCode",{code:d.failure?.code??""})})]}),(0,e.jsx)(n.$n,{variant:"secondary",size:"sm",onClick:()=>o(a=>a+1),"data-testid":"worktree-skills-catalog-retry",children:c("state.retry")})]}):0===d.skills.length?(0,e.jsx)(n.Zp,{"data-testid":"worktree-skills-catalog-empty",children:(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:c("state.empty")})}):(0,e.jsx)("ul",{className:"space-y-2",children:d.skills.map(a=>{let b=(0,eg.gh)(a),d=r.has(a.id),f=!0===t.get(a.id);return(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",onClick:()=>l(a.id),"data-testid":`worktree-skills-catalog-${a.id}`,className:"w-full rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"min-w-0 break-all text-sm font-semibold text-foreground",children:a.name}),d&&(f?(0,e.jsx)(n.Ex,{variant:"info","data-testid":`worktree-skills-catalog-update-badge-${a.id}`,children:c("worktreePane.updateBadge")}):(0,e.jsx)(n.Ex,{variant:"info","data-testid":`worktree-skills-installed-badge-${a.id}`,children:c("worktreePane.installedBadge")}))]}),(0,e.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:c("card.provider",{provider:a.provider.name})}),(0,e.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground","data-testid":`worktree-skills-catalog-version-${a.id}`,children:c("worktreePane.version",{version:a.latest})}),a.summary&&(0,e.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2","data-testid":`worktree-skills-catalog-summary-${a.id}`,children:a.summary}),(0,e.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[a.compatibility&&(0,e.jsx)(ed.Xz,{status:a.compatibility.status}),b&&(0,e.jsx)(ed.qW,{risk:b})]})]})},a.id)})})]})]})})}let eo=[{id:"notes",labelKey:"notes"},{id:"logs",labelKey:"logs"},{id:"agent",labelKey:"agentTab"},{id:"timer",labelKey:"timerTab"},{id:"todo",labelKey:"todoTab"},{id:"skills",labelKey:"skillsTab"}],ep=(0,h.memo)(function({worktreeId:a,className:b="",selectedAgents:c,onSelectedAgentsChange:d,vibeLocalModel:f,onVibeLocalModelChange:g,vibeLocalContextWindow:i,onVibeLocalContextWindowChange:j,maxAgents:l,availableAgents:m,persistToServer:n,onInsertToMessage:o,useInstanceManagement:p=!1,instances:q,onInstancesChange:r,visibleInstanceIds:s,onToggleInstanceVisible:t}){let u=(0,k.c)("schedule"),[v,w]=(0,h.useState)("notes"),x=(0,h.useCallback)(a=>{w(a)},[]);return(0,e.jsxs)("div",{className:`flex flex-col h-full ${b}`,children:[(0,e.jsx)("div",{className:"flex overflow-x-auto scrollbar-hide border-b border-border bg-surface dark:bg-surface-2 flex-shrink-0",children:eo.map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>x(a.id),className:`flex-shrink-0 whitespace-nowrap px-3 py-2 text-sm font-medium transition-colors ${v===a.id?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:u(a.labelKey)},a.id))}),(0,e.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["notes"===v&&(0,e.jsx)(db,{worktreeId:a,className:"h-full",onInsertToMessage:o}),"logs"===v&&(0,e.jsx)(dJ,{worktreeId:a,className:"h-full",onInsertToMessage:o,instances:q}),"agent"===v&&(p&&q&&r&&s&&t?(0,e.jsx)("div",{className:"h-full overflow-y-auto",children:(0,e.jsx)(dR,{worktreeId:a,instances:q,onInstancesChange:r,vibeLocalModel:f,onVibeLocalModelChange:g,vibeLocalContextWindow:i,onVibeLocalContextWindowChange:j,visibleInstanceIds:s,onToggleInstanceVisible:t})}):(0,e.jsx)(dL,{worktreeId:a,selectedAgents:c,onSelectedAgentsChange:d,vibeLocalModel:f,onVibeLocalModelChange:g,vibeLocalContextWindow:i,onVibeLocalContextWindowChange:j,maxAgents:l,availableAgents:m,persistToServer:n})),"timer"===v&&(0,e.jsx)(d_,{worktreeId:a,instances:q,selectedAgents:c}),"todo"===v&&(0,e.jsx)(dg,{worktreeId:a,className:"h-full"}),"skills"===v&&(0,e.jsx)(en,{worktreeId:a,className:"h-full"})]})]})});var eq=c(53237);let er=["status","changes","history","advanced"],es="commandmate:gitPane:",et={activeTab:`${es}activeTab`,historyOpen:`${es}historyOpen`,advancedOpen:`${es}advancedOpen`};function eu(a){return"string"==typeof a&&er.includes(a)}let ev=a=>"boolean"==typeof a,ew=h.useEffect,ex=(0,h.memo)(function({branches:a,busy:b,actionError:c,hasRunningSession:d,isMobile:f,onCheckout:g}){let i=(0,k.c)("worktree"),j=(0,k.c)("common"),[l,m]=(0,h.useState)(!1),[o,p]=(0,h.useState)(null),[q,r]=(0,h.useState)(!1),s=(0,h.useRef)(null),t=(0,h.useRef)(null),[u,v]=(0,h.useState)(null),w=a.filter(a=>!a.isCurrent),x=(0,h.useCallback)(()=>{s.current,t.current},[]);ew(()=>l?(x(),window.addEventListener("resize",x),window.addEventListener("scroll",x,!0),()=>{window.removeEventListener("resize",x),window.removeEventListener("scroll",x,!0)}):void v(null),[l,w.length,x]);let y=(0,h.useCallback)(a=>{r(!1),p({...a}),m(!1)},[]),z=(0,h.useCallback)(()=>{o&&(g(o,q),p(null))},[o,q,g]);return(0,e.jsxs)("div",{className:"relative",ref:s,"data-testid":"branch-checkout-dropdown",children:[(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:()=>m(a=>!a),disabled:b||0===w.length,className:"flex items-center gap-1 px-2 py-1 text-xs rounded border border-input text-accent-700 dark:text-accent-300 hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"branch-checkout-dropdown-toggle","aria-haspopup":"menu","aria-expanded":l,"aria-label":i("git.checkout.ariaLabel"),children:[i("git.checkout.action"),(0,e.jsx)("span",{"aria-hidden":"true",className:"text-[10px]",children:"▾"})]}),l&&"undefined"!=typeof document&&(0,bG.createPortal)((0,e.jsx)("div",{ref:t,className:"fixed z-50 min-w-[12rem] max-w-[calc(100vw-1rem)] max-h-64 overflow-y-auto rounded border border-border bg-surface shadow-lg",style:{top:u?.top??-9999,left:u?.left??-9999},role:"menu","data-testid":"branch-checkout-menu",children:0===w.length?(0,e.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:i("git.checkout.noBranches")}):(0,e.jsx)("ul",{className:"divide-y divide-border",children:w.map(a=>{let c=null!==a.checkedOutWorktreePath;return(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>y(a),disabled:b||c,className:"w-full text-left px-3 py-1.5 font-mono text-xs text-foreground hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","aria-label":i("git.checkout.checkoutBranch",{name:a.name}),title:c?i("git.checkout.checkedOutElsewhere",{path:a.checkedOutWorktreePath??""}):void 0,children:[a.name,a.isDefault&&(0,e.jsx)("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:i("git.checkout.defaultBadge")})]})},`${a.isRemote?"r":"l"}:${a.name}`)})})}),document.body),c&&(0,e.jsx)("div",{className:"mt-1 text-xs text-danger-foreground",role:"alert","data-testid":"branch-checkout-error",children:c}),o&&(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-checkout-confirm",children:(0,e.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,e.jsxs)("h3",{className:"text-sm font-medium text-foreground",children:[i("git.checkout.confirmTitlePrefix"),(0,e.jsx)("span",{className:"font-mono",children:o.name}),i("git.checkout.confirmTitleSuffix")]}),(0,e.jsx)("div",{className:"rounded border border-warning-border bg-warning-subtle px-3 py-2 text-xs text-warning-foreground",role:"alert","data-testid":"branch-history-loss-warning",children:i("git.checkout.historyLossWarning")}),d&&(0,e.jsx)("div",{className:"rounded border border-danger-border bg-danger-subtle px-3 py-2 text-xs text-danger-foreground",role:"alert","data-testid":"branch-session-warning",children:i("git.checkout.runningSessionWarning")}),(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(n.Sc,{checked:q,onCheckedChange:a=>r(!0===a),"data-testid":"branch-checkout-force"}),i("git.checkout.forceLabel")]}),(0,e.jsxs)("div",{className:`flex items-center justify-end gap-2 ${f?"flex-wrap":""}`,children:[(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:()=>p(null),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:j("cancel")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:z,disabled:b,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50","data-testid":"branch-checkout-confirm-button",children:i("git.checkout.action")})]})]})})]})}),ey=(0,h.memo)(function({open:a,onToggle:b,children:c}){let d=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"flex flex-col border-t border-border","data-testid":"git-advanced-section",children:[(0,e.jsxs)("button",{type:"button",onClick:b,className:"w-full flex items-center gap-1 px-3 py-2 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground","data-testid":"git-advanced-toggle","aria-expanded":a,children:[(0,e.jsx)("span",{className:"text-xs w-4 text-center",children:a?"▼":"▶"}),d("git.advancedOperations")]}),a&&(0,e.jsx)("div",{className:"flex flex-col","data-testid":"git-advanced-content",children:c})]})}),ez=(0,h.createContext)(null);function eA({value:a,children:b}){return(0,e.jsx)(ez.Provider,{value:a,children:b})}function eB(){let a=(0,h.useContext)(ez);if(null===a)throw Error("useGitPaneContext must be used within a GitPaneProvider");return a}let eC=(0,h.memo)(function({path:a}){return(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:a})})}),eD={status:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",changes:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",history:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z",advanced:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"},eE={status:"git.tabs.status",changes:"git.tabs.changes",history:"git.tabs.history",advanced:"git.tabs.advanced"},eF=(0,h.memo)(function({activeTab:a,onTabChange:b}){let c=(0,k.c)("worktree");return(0,e.jsx)("div",{role:"tablist","aria-label":c("git.paneSections"),"data-testid":"git-pane-mobile-tabs",className:"flex shrink-0 border-b border-border bg-surface sticky top-0 z-30",children:er.map(d=>{let f=d===a,g=c(eE[d]);return(0,e.jsxs)("button",{type:"button",role:"tab","aria-selected":f,"aria-label":g,"data-testid":`git-tab-${d}`,onClick:()=>b(d),className:`flex flex-1 flex-col items-center justify-center gap-1 py-2 px-1 text-xs transition-colors border-b-2 ${f?"text-accent-600 dark:text-accent-400 border-accent-500 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground border-transparent hover:text-foreground hover:bg-muted"}`,children:[(0,e.jsx)(eC,{path:eD[d]}),(0,e.jsx)("span",{children:g})]},d)})})});function eG({activeTab:a,onTabChange:b,className:c="",statusSection:d,quickActionsSection:f,changesSection:g,historySection:h,advancedSection:i}){let{isMobile:j}=eB();return j?(0,e.jsxs)("div",{className:`flex flex-col overflow-hidden ${c}`,"data-testid":"git-pane-mobile",children:[(0,e.jsx)(eF,{activeTab:a,onTabChange:b}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col min-h-0","data-testid":"git-pane-mobile-panel","data-active-tab":a,children:["status"===a&&(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0",children:[d,f]}),"changes"===a&&(0,e.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:g}),"history"===a&&h,"advanced"===a&&(0,e.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:i})]})]}):(0,e.jsxs)("div",{className:`flex flex-col overflow-hidden ${c}`,"data-testid":"git-pane-desktop",children:[(0,e.jsx)("div",{"data-testid":"git-group-read","data-git-group":"read",className:"border-l-2 border-info-border bg-info-subtle",children:d}),(0,e.jsxs)("div",{"data-testid":"git-group-write","data-git-group":"write",className:"border-l-2 border-input bg-muted/70 dark:bg-muted/30",children:[f,g]}),(0,e.jsx)("div",{"data-testid":"git-group-history","data-git-group":"read",className:"flex-1 flex flex-col min-h-0 border-l-2 border-info-border bg-info-subtle",children:h}),(0,e.jsx)("div",{"data-testid":"git-group-advanced","data-git-group":"advanced",className:"border-l-2 border-t-2 border-input bg-muted/50 dark:bg-muted/40",children:i})]})}let eH={added:"text-success-foreground",modified:"text-warning-foreground",deleted:"text-danger-foreground",renamed:"text-info",untracked:"text-teal-600 dark:text-teal-400",unmerged:"text-warning-foreground"},eI=(0,h.memo)(function(){return(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:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),eJ=(0,h.memo)(function({onClick:a,disabled:b=!1,testId:c,className:d=""}){let f=(0,k.c)("worktree");return(0,e.jsxs)("button",{type:"button",disabled:b,onClick:a,className:`inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-info-border text-info-foreground hover:bg-info-subtle disabled:opacity-50 disabled:cursor-not-allowed ${d}`,"data-testid":c,title:f("git.askAiTooltip"),children:[(0,e.jsx)(dh.A,{size:14,"aria-hidden":"true"}),f("git.askAi")]})}),eK=(0,h.memo)(function({line:a}){let b="whitespace-pre font-mono text-xs";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":b+=" text-foreground",(0,e.jsx)("div",{className:b,children:a})}),eL=(0,h.memo)(function({message:a}){return(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-danger-foreground",role:"alert",children:a})}),eM={no_upstream:{badgeKey:"git.currentStatus.noUpstreamBadge",tooltipKey:"git.currentStatus.noUpstreamTooltip"},upstream_gone:{badgeKey:"git.currentStatus.upstreamGoneBadge",tooltipKey:"git.currentStatus.upstreamGoneTooltip"},detached:{badgeKey:"git.currentStatus.detachedBadge",tooltipKey:"git.currentStatus.detachedTooltip"},error:{badgeKey:"git.currentStatus.aheadBehindErrorBadge",tooltipKey:"git.currentStatus.aheadBehindErrorTooltip"}},eN=(0,h.memo)(function({gitStatus:a,statusLoading:b,statusError:c,onRefresh:d,refreshing:f=!1}){let{isMobile:g}=eB(),i=(0,k.c)("worktree"),j=(0,b3.Ym)(),l=(0,h.useMemo)(()=>{let b=a?.lastFetchAt;if(null==b)return i("git.currentStatus.lastFetchNever");let c=(0,cg.fw)(new Date(b).toISOString(),cf(j));return c?i("git.currentStatus.lastFetch",{relative:c}):i("git.currentStatus.lastFetchNever")},[a?.lastFetchAt,j,i]),n=a&&!a.aheadBehind?a.aheadBehindReason??null:null;return(0,e.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-status-section",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:i("git.currentStatus.title")}),(0,e.jsx)("button",{type:"button",onClick:d,disabled:f,className:"p-1 text-muted-foreground hover:text-foreground rounded disabled:opacity-50","aria-label":f?i("git.currentStatus.refreshing"):i("git.currentStatus.refresh"),"aria-busy":f,"data-testid":"git-status-refresh-button",children:f?(0,e.jsx)(m.y,{size:"sm",variant:"accent"}):(0,e.jsx)(eI,{})})]}),b&&!a&&(0,e.jsxs)("div",{className:"flex items-center gap-2 py-1",role:"status",children:[(0,e.jsx)(m.y,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:i("git.currentStatus.loading")})]}),c&&!a&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-status-error",children:c}),a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:`flex items-center flex-wrap ${g?"gap-1.5":"gap-2"}`,children:[(0,e.jsx)("span",{className:"inline-flex items-center max-w-full truncate rounded px-2 py-0.5 text-xs font-mono bg-accent-50 text-accent-700 dark:bg-accent-900/30 dark:text-accent-300","data-testid":"git-status-branch-chip",title:a.currentBranch,children:a.currentBranch}),a.isDirty&&(0,e.jsx)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium bg-warning-subtle text-warning-foreground","data-testid":"git-status-dirty-badge",children:i("git.currentStatus.uncommitted")}),a.aheadBehind&&(0,e.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs font-mono bg-muted text-foreground","data-testid":"git-status-ahead-behind",children:[(0,e.jsxs)("span",{title:i("git.currentStatus.aheadTooltip"),children:["↑",a.aheadBehind.ahead]}),(0,e.jsxs)("span",{title:i("git.currentStatus.behindTooltip"),children:["↓",a.aheadBehind.behind]})]}),n&&(0,e.jsx)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium bg-muted text-muted-foreground border border-border","data-testid":"git-status-ahead-behind-reason","data-reason":n,title:i(eM[n].tooltipKey),children:i(eM[n].badgeKey)})]}),(0,e.jsx)("div",{className:"text-[11px] text-muted-foreground","data-testid":"git-status-last-fetch",title:i("git.currentStatus.lastFetchTooltip"),children:l}),a.isBranchMismatch&&(0,e.jsxs)("div",{className:"flex items-center gap-1.5 rounded px-2 py-1 text-xs bg-warning-subtle text-warning-foreground border border-warning-border",role:"alert","data-testid":"git-status-mismatch-warning",children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"⚠"}),(0,e.jsxs)("span",{children:[i("branchMismatch.changedFrom")," ",(0,e.jsx)("span",{className:"font-medium",children:a.initialBranch})," ",i("branchMismatch.to")," ",(0,e.jsx)("span",{className:"font-medium",children:a.currentBranch})]})]})]})]})}),eO=(0,h.memo)(function({progressState:a,operation:b,error:c,conflict:d,conflictFiles:f,hasUpstream:g,onFetch:i,onPull:j,onPush:l,onAbort:n,extraActions:o}){let{isMobile:p}=eB(),q=(0,k.c)("worktree"),r="running"===a,s=c??q("git.network.failed"),[t,u]=(0,h.useState)(0);return(0,h.useEffect)(()=>{if(!r)return void u(0);let a=setInterval(()=>u(a=>a+1),1e3);return()=>clearInterval(a)},[r]),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-network-section",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:q("git.network.quickActions")}),(0,e.jsxs)("div",{className:`flex items-center ${p?"flex-wrap gap-1.5":"gap-2"}`,children:[i&&(0,e.jsx)("button",{type:"button",onClick:i,disabled:r,className:"px-2 py-1 text-xs rounded border border-border text-foreground hover:bg-muted disabled:opacity-50","data-testid":"git-fetch-button",children:q("git.network.fetch")}),(0,e.jsx)("button",{type:"button",onClick:j,disabled:r,className:"px-2 py-1 text-xs rounded border border-accent-300 dark:border-accent-700 text-accent-700 dark:text-accent-300 hover:bg-accent-50 dark:hover:bg-accent-900/30 disabled:opacity-50","data-testid":"git-pull-button",children:q("git.network.pull")}),(0,e.jsx)("button",{type:"button",onClick:l,disabled:r,className:"px-2 py-1 text-xs rounded border border-success-border text-success-foreground hover:bg-success-subtle disabled:opacity-50","data-testid":"git-push-button",title:g?void 0:q("git.network.noUpstreamTooltip"),children:q("git.network.push")}),o]}),r&&(0,e.jsxs)("div",{className:`flex items-center gap-2 rounded px-2 py-1 text-xs bg-accent-50 text-accent-800 dark:bg-accent-900/20 dark:text-accent-300 ${p?"sticky top-0 z-40":""}`,"data-testid":"git-network-progress-bar",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2",role:"status","data-testid":"git-network-operation-spinner",children:[(0,e.jsx)(m.y,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{children:q("git.network.progress",{operation:q("push"===b?"git.network.pushing":"pull"===b?"git.network.pulling":"git.network.fetching"),elapsed:t})})]}),(0,e.jsx)("button",{type:"button",onClick:n,className:"ml-auto px-1.5 py-0.5 rounded border border-accent-400 dark:border-accent-600 hover:bg-accent-100 dark:hover:bg-accent-900/40","data-testid":"git-network-abort-button",children:q("git.network.abort")})]}),"error"===a&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-network-operation-error",children:s}),d&&(0,e.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-network-conflict",children:q("git.network.conflicts",{files:f.join(", ")})})]})}),eP=(0,h.memo)(function({title:a,testId:b,files:c,actionLabel:d,mode:f,defaultOpen:g,busy:i,onDiff:j,onToggleStage:l,onPreview:m}){let o=(0,k.c)("worktree"),[p,q]=(0,h.useState)(g),[r,s]=(0,h.useState)(null),[t,u]=(0,h.useState)(null),[v,w]=(0,h.useState)(!1),[x,y]=(0,h.useState)(null),z=(0,h.useCallback)(async a=>{if(r===a){s(null),u(null),y(null);return}s(a),u(null),y(null),w(!0);try{let b=await m(a,f);u(b??"")}catch{y(o("git.changes.previewFailed"))}finally{w(!1)}},[r,m,f,o]);return(0,e.jsxs)("div",{className:"border-t border-border","data-testid":b,children:[(0,e.jsxs)("button",{type:"button",onClick:()=>q(a=>!a),className:"w-full flex items-center gap-1 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground",children:[(0,e.jsx)("span",{className:"w-4 text-center",children:p?"▼":"▶"}),o("git.changes.listHeader",{title:a,count:c.length})]}),p&&0===c.length&&(0,e.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:o("git.changes.empty")}),p&&c.length>0&&(0,e.jsx)("ul",{className:"divide-y divide-border",children:c.map(a=>{let b=r===a.path;return(0,e.jsxs)("li",{className:"flex flex-col",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[(0,e.jsx)("span",{className:`inline-block w-16 shrink-0 text-xs font-medium ${eH[a.status]}`,children:a.status}),(0,e.jsx)("span",{className:"flex-1 truncate font-mono text-xs text-foreground",title:a.path,children:a.path}),(0,e.jsx)("button",{type:"button",onClick:()=>z(a.path),className:"shrink-0 w-5 text-center text-xs text-muted-foreground hover:text-foreground","aria-label":o("git.changes.togglePreview",{path:a.path}),"aria-expanded":b,"data-testid":"git-changes-preview-toggle",children:b?"▼":"▶"}),(0,e.jsx)("button",{type:"button",onClick:()=>j(a.path,f),className:"shrink-0 px-1.5 py-0.5 text-xs text-accent-600 dark:text-accent-400 hover:underline","aria-label":o("git.changes.showDiff",{path:a.path}),"data-testid":"git-changes-diff-button",children:o("git.changes.diff")}),(0,e.jsx)("button",{type:"button",onClick:()=>l(a.path),disabled:i,className:"shrink-0 px-1.5 py-0.5 text-xs rounded border border-input text-foreground hover:bg-muted disabled:opacity-50","aria-label":o("git.changes.fileAction",{action:d,path:a.path}),"data-testid":"git-changes-toggle-button",children:d})]}),b&&(0,e.jsxs)("div",{className:"px-3 pb-2 bg-muted/40","data-testid":"git-changes-inline-preview",children:[v&&(0,e.jsxs)("div",{className:"flex items-center gap-2 py-2",role:"status",children:[(0,e.jsx)(n.y$,{size:"xs",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:o("git.changes.loadingPreview")})]}),x&&(0,e.jsx)("div",{className:"py-2 text-xs text-danger-foreground",role:"alert",children:x}),!v&&!x&&null!==t&&(""===t.trim()?(0,e.jsx)("div",{className:"py-2 text-xs text-muted-foreground",children:o("git.changes.noDiff")}):(0,e.jsxs)("div",{className:"overflow-x-auto",children:[(0,e.jsx)("pre",{className:"text-xs",children:(0,e.jsx)("code",{children:t.split("\n").slice(0,20).map((a,b)=>(0,e.jsx)(eK,{line:a},b))})}),t.split("\n").length>20&&(0,e.jsx)("button",{type:"button",onClick:()=>j(a.path,f),className:"mt-1 text-xs text-accent-600 dark:text-accent-400 hover:underline","data-testid":"git-changes-preview-more",children:o("git.changes.truncated")})]}))]})]},`${a.status}:${a.path}`)})})]})}),eQ=(0,h.memo)(function({staged:a,loading:b,error:c,busy:d,commitMessage:f,amend:g,committing:h,commitError:i,onRefresh:j,onDiff:l,onPreview:m,onStage:o,onUnstage:p,onCommitMessageChange:q,onAmendChange:r,onCommit:s,onCommitAndPush:t}){let{isMobile:u}=eB(),v=(0,k.c)("worktree"),w=a?.staged??[],x=a?.unstaged??[],y=a?.untracked??[],z=!h&&f.trim().length>0&&(w.length>0||g),A=!u;return(0,e.jsxs)("div",{className:"flex flex-col border-b border-border","data-testid":"git-changes-section",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:v("git.changes.title")}),(0,e.jsx)("button",{type:"button",onClick:j,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":v("git.changes.refresh"),children:(0,e.jsx)(eI,{})})]}),b&&!a&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2",role:"status",children:[(0,e.jsx)(n.y$,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:v("git.changes.loading")})]}),c&&!a&&(0,e.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-changes-error",children:c}),a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(eP,{title:v("git.changes.staged"),testId:"git-staged-list",files:w,actionLabel:v("git.changes.unstage"),mode:"staged",defaultOpen:A,busy:d,onDiff:l,onPreview:m,onToggleStage:p}),(0,e.jsx)(eP,{title:v("git.changes.unstaged"),testId:"git-unstaged-list",files:x,actionLabel:v("git.changes.stage"),mode:"unstaged",defaultOpen:A,busy:d,onDiff:l,onPreview:m,onToggleStage:o}),(0,e.jsx)(eP,{title:v("git.changes.untracked"),testId:"git-untracked-list",files:y,actionLabel:v("git.changes.stage"),mode:"untracked",defaultOpen:A,busy:d,onDiff:l,onPreview:m,onToggleStage:o}),(0,e.jsxs)("div",{className:"flex flex-col gap-2 px-3 py-2 border-t border-border",children:[(0,e.jsx)("textarea",{value:f,onChange:a=>q(a.target.value),placeholder:v("git.changes.commitMessage"),rows:u?2:3,className:"w-full resize-y rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"git-commit-message","aria-label":v("git.changes.commitMessage")}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(n.Sc,{checked:g,onCheckedChange:a=>r(!0===a),"data-testid":"git-amend-checkbox"}),v("git.changes.amend")]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:s,disabled:!z,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"git-commit-button",children:v(h?"git.changes.committing":"git.changes.commit")}),(0,e.jsx)("button",{type:"button",onClick:t,disabled:!z||d,title:v("git.changes.commitAndPushTooltip"),className:"px-3 py-1 text-xs font-medium rounded border border-accent-600 text-accent-700 dark:text-accent-300 hover:bg-accent-50 dark:hover:bg-accent-900/30 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"git-commit-push-button",children:v("git.changes.commitAndPush")})]})]}),i&&(0,e.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-commit-error",children:i})]})]})]})}),eR=(0,h.memo)(function({commits:a,isLoading:b,commitError:c,commitListOpen:d,onToggleCommitList:f,onRefresh:g,selectedCommit:i,onCommitSelect:j,inlineDiffCommit:l,inlineFiles:n,inlineFilesLoading:o,inlineFilesError:p,onToggleInlineDiff:q,onInlineDiffFile:r,changedFiles:s,isLoadingFiles:t,detailError:u,selectedFile:v,onFileSelect:w,diffContent:x,isLoadingDiff:y}){let{isMobile:z}=eB(),A=(0,k.c)("worktree"),[B,C]=(0,h.useState)(!0),[D,E]=(0,h.useState)(!0);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,e.jsxs)("button",{type:"button",onClick:f,className:"flex items-center gap-1 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground",children:[(0,e.jsx)("span",{className:"text-xs w-4 text-center",children:d?"▼":"▶"}),A("git.history.title")]}),(0,e.jsx)("button",{type:"button",onClick:g,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":A("git.history.refresh"),children:(0,e.jsx)(eI,{})})]}),d&&b&&(0,e.jsxs)("div",{className:"flex items-center justify-center py-8",role:"status",children:[(0,e.jsx)(m.y,{size:"lg",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:A("git.history.loading")})]}),d&&c&&!b&&(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-danger-foreground",role:"alert",children:c}),d&&!b&&!c&&0===a.length&&(0,e.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:A("git.history.empty")}),!b&&!c&&a.length>0&&(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[d&&(0,e.jsx)("div",{className:`overflow-y-auto ${i?"max-h-[40%] shrink-0":"flex-1"}`,children:(0,e.jsx)("ul",{className:"divide-y divide-border",children:a.map(a=>{let b=l===a.hash;return(0,e.jsxs)("li",{children:[(0,e.jsxs)("div",{className:"flex items-stretch",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>j(a.hash),className:`flex-1 min-w-0 text-left px-3 py-2 text-sm hover:bg-muted transition-colors ${i===a.hash?"bg-accent-50 dark:bg-accent-900/30":""}`,children:[(0,e.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,e.jsx)("span",{className:"font-mono text-xs text-accent-600 dark:text-accent-400 shrink-0",children:a.shortHash}),(0,e.jsx)("span",{className:"truncate text-foreground",children:a.message})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{children:a.author}),(0,e.jsx)("span",{children:new Date(a.date).toLocaleDateString()})]})]}),(0,e.jsx)("button",{type:"button",onClick:()=>q(a.hash),className:"shrink-0 px-2 text-xs text-accent-600 dark:text-accent-400 hover:bg-muted hover:underline","aria-label":A("git.history.viewDiffFor",{hash:a.shortHash}),"aria-expanded":b,"data-testid":"git-commit-view-diff-button",children:b?A("git.history.hideDiff"):A("git.history.viewDiff")})]}),b&&(0,e.jsxs)("div",{className:"border-t border-border bg-muted/40","data-testid":"git-commit-inline-files",children:[o&&(0,e.jsxs)("div",{className:"flex items-center justify-center py-3",role:"status",children:[(0,e.jsx)(m.y,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:A("git.history.loadingChangedFiles")})]}),p&&(0,e.jsx)(eL,{message:p}),!o&&!p&&0===n.length&&(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:A("git.history.noChangedFiles")}),!o&&n.length>0&&(0,e.jsx)("ul",{className:"divide-y divide-border",children:n.map(b=>(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",onClick:()=>r(a.hash,b.path),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${v===b.path&&i===a.hash?"bg-accent-50 dark:bg-accent-900/30":""}`,"aria-label":A("git.history.showCommitDiff",{path:b.path}),"data-testid":"git-commit-inline-file",children:[(0,e.jsx)("span",{className:`inline-block w-14 font-medium ${eH[b.status]}`,children:b.status}),(0,e.jsx)("span",{className:"font-mono text-foreground",children:b.path})]})},b.path))})]})]},a.hash)})})}),i&&(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0 border-t border-border",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>C(a=>!a),className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground bg-surface-2 sticky top-0 z-10 cursor-pointer hover:text-foreground",children:[(0,e.jsx)("span",{className:"w-4 text-center",children:B?"▼":"▶"}),A("git.history.changedFiles")]}),B&&(0,e.jsxs)(e.Fragment,{children:[u&&(0,e.jsx)(eL,{message:u}),t&&(0,e.jsxs)("div",{className:"flex items-center justify-center py-4",role:"status",children:[(0,e.jsx)(m.y,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:A("git.history.loadingChangedFiles")})]}),!t&&!u&&0===s.length&&(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:A("git.history.noChangedFiles")}),!t&&s.length>0&&(0,e.jsx)("ul",{className:"divide-y divide-border",children:s.map(a=>(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",onClick:()=>w(a.path),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ${v===a.path?"bg-accent-50 dark:bg-accent-900/30":""}`,children:[(0,e.jsx)("span",{className:`inline-block w-14 font-medium ${eH[a.status]}`,children:a.status}),(0,e.jsx)("span",{className:"font-mono text-foreground",children:a.path})]})},a.path))})]}),z&&v&&(0,e.jsxs)("div",{className:"border-t border-border",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>E(a=>!a),className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground bg-surface-2 sticky top-0 z-10 cursor-pointer hover:text-foreground",children:[(0,e.jsx)("span",{className:"w-4 text-center",children:D?"▼":"▶"}),A("git.history.diffLabel",{file:v})]}),D&&(0,e.jsxs)(e.Fragment,{children:[y&&(0,e.jsxs)("div",{className:"flex items-center justify-center py-4",role:"status",children:[(0,e.jsx)(m.y,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:A("git.history.loadingDiff")})]}),!y&&x&&(0,e.jsx)("div",{className:"overflow-x-auto p-2",children:(0,e.jsx)("pre",{className:"text-xs",children:(0,e.jsx)("code",{children:x.split("\n").map((a,b)=>(0,e.jsx)(eK,{line:a},b))})})}),!y&&!x&&!u&&(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:A("git.history.noDiff")})]})]}),!z&&v&&!u&&(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground border-t border-border",children:y?A("git.history.loadingDiff"):A("git.history.diffInFilePanel",{file:v})})]})]})]})});function eS(a){return"`"+a+"`"}let eT={local:"git.branches.filterLocal",remote:"git.branches.filterRemote",all:"git.branches.filterAll"},eU=(0,h.memo)(function({branches:a,include:b,loading:c,error:d,busy:f,actionError:g,onIncludeChange:i,onRefresh:j,onCreate:l,onDelete:m}){let{isMobile:o,onInsertToMessage:p}=eB(),q=(0,k.c)("worktree"),r=(0,k.c)("common"),[s,t]=(0,h.useState)(!o),[u,v]=(0,h.useState)(!1),[w,x]=(0,h.useState)(""),[y,z]=(0,h.useState)(""),[A,B]=(0,h.useState)(null),[C,D]=(0,h.useState)(!1),E=(0,h.useCallback)(()=>{0!==w.trim().length&&(l(w.trim(),y.trim()||void 0),v(!1),x(""),z(""))},[w,y,l]),F=(0,h.useCallback)(()=>{A&&(m(A.name,C),B(null),D(!1))},[A,C,m]);return(0,e.jsxs)("div",{className:"flex flex-col border-b border-border","data-testid":"git-branches-section",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>t(a=>!a),className:"flex items-center gap-1 text-sm font-medium text-muted-foreground hover:text-foreground",children:[(0,e.jsx)("span",{className:"text-xs w-4 text-center",children:s?"▼":"▶"}),q("git.branches.title")]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{type:"button",onClick:()=>v(!0),className:"px-2 py-0.5 text-xs rounded border border-input text-foreground hover:bg-muted","data-testid":"git-branch-create-open",children:q("git.branches.newButton")}),(0,e.jsx)("button",{type:"button",onClick:j,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":q("git.branches.refresh"),children:(0,e.jsx)(eI,{})})]})]}),s&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"flex items-center gap-1 px-3 pb-2",children:["local","remote","all"].map(a=>(0,e.jsx)("button",{type:"button",onClick:()=>i(a),className:`px-2 py-0.5 text-xs rounded ${b===a?"bg-accent-100 text-accent-800 dark:bg-accent-900/40 dark:text-accent-200":"text-muted-foreground hover:bg-muted"}`,"data-testid":`git-branches-tab-${a}`,children:q(eT[a])},a))}),c&&0===a.length&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2",role:"status",children:[(0,e.jsx)(n.y$,{size:"sm",variant:"accent"}),(0,e.jsx)("span",{className:"sr-only",children:q("git.branches.loading")})]}),d&&(0,e.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-error",children:d}),g&&(0,e.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-action-error",children:g}),!c&&!d&&0===a.length&&(0,e.jsx)("div",{className:"px-3 pb-2 text-xs text-muted-foreground",children:q("git.branches.empty")}),a.length>0&&(0,e.jsx)("ul",{className:"divide-y divide-border max-h-64 overflow-y-auto",children:a.map(a=>{let b=f||a.isCurrent||a.isDefault;return(0,e.jsxs)("li",{className:"flex items-center gap-2 px-3 py-1.5","data-testid":"git-branch-row",children:[(0,e.jsxs)("span",{className:"flex-1 truncate font-mono text-xs text-foreground",title:a.name,children:[a.isCurrent&&(0,e.jsx)("span",{className:"text-accent-600 dark:text-accent-400 mr-1",children:"●"}),a.name,a.isDefault&&(0,e.jsx)("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:q("git.branches.defaultBadge")})]}),(0,e.jsx)("button",{type:"button",onClick:()=>{D(!1),B(a)},disabled:b,className:"shrink-0 px-1.5 py-0.5 text-xs rounded border border-input text-danger-foreground hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","aria-label":q("git.branches.deleteBranch",{name:a.name}),children:q("git.branches.delete")})]},`${a.isRemote?"r":"l"}:${a.name}`)})})]}),u&&(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-create-modal",children:(0,e.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:q("git.branches.createTitle")}),(0,e.jsx)("input",{type:"text",value:w,onChange:a=>x(a.target.value),placeholder:q("git.branches.namePlaceholder"),className:"w-full rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"branch-create-name-input","aria-label":q("git.branches.nameLabel")}),(0,e.jsxs)("select",{value:y,onChange:a=>z(a.target.value),className:"w-full rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"branch-create-from-select","aria-label":q("git.branches.baseLabel"),children:[(0,e.jsx)("option",{value:"",children:q("git.branches.currentHead")}),a.map(a=>(0,e.jsx)("option",{value:a.name,children:a.name},`from:${a.isRemote?"r":"l"}:${a.name}`))]}),(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[p&&(0,e.jsx)(eJ,{className:"mr-auto",testId:"branch-create-ask-ai",disabled:0===w.trim().length,onClick:()=>{p(function(a,b,c){let d=c&&c.trim().length>0?eS(c.trim()):a("git.aiPrompts.branchCreateBaseHead");return a("git.aiPrompts.branchCreate",{base:d,name:eS(b.trim())})}(q,w,y)),v(!1)}}),(0,e.jsx)("button",{type:"button",onClick:()=>v(!1),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:r("cancel")}),(0,e.jsx)("button",{type:"button",onClick:E,disabled:f||0===w.trim().length,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"branch-create-submit",children:q("git.branches.create")})]})]})}),A&&(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-delete-confirm",children:(0,e.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,e.jsxs)("h3",{className:"text-sm font-medium text-foreground",children:[q("git.branches.deleteTitlePrefix"),(0,e.jsx)("span",{className:"font-mono",children:A.name}),q("git.branches.deleteTitleSuffix")]}),(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(n.Sc,{checked:C,onCheckedChange:a=>D(!0===a),"data-testid":"branch-delete-force"}),q("git.branches.forceDeleteLabel")]}),(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[p&&A&&(0,e.jsx)(eJ,{className:"mr-auto",testId:"branch-delete-ask-ai",onClick:()=>{p(q(C?"git.aiPrompts.branchDeleteForce":"git.aiPrompts.branchDelete",{name:eS(A.name)})),B(null),D(!1)}}),(0,e.jsx)("button",{type:"button",onClick:()=>B(null),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:r("cancel")}),(0,e.jsx)("button",{type:"button",onClick:F,disabled:f,className:"px-3 py-1 text-xs font-medium rounded bg-danger text-white hover:bg-danger/90 disabled:opacity-50","data-testid":"branch-delete-confirm-button",children:q("git.branches.delete")})]})]})})]})}),eV=(0,h.memo)(function({stashes:a,loading:b,error:c,busy:d,actionError:f,conflictNotice:g,hasRunningSession:i,onRefresh:j,onPush:l,onPop:m,onApply:o,onDrop:p}){let{isMobile:q,onInsertToMessage:r}=eB(),s=(0,k.c)("worktree"),t=(0,k.c)("common"),[u,v]=(0,h.useState)(!q),[w,x]=(0,h.useState)(""),[y,z]=(0,h.useState)(!1),[A,B]=(0,h.useState)(null);return(0,e.jsxs)("div",{className:"border-b border-border","data-testid":"git-stash-section",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>v(a=>!a),className:"flex items-center gap-1 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground",children:[(0,e.jsx)("span",{className:"text-xs w-4 text-center",children:u?"▼":"▶"}),s("git.stash.titlePrefix"),a.length>0&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:s("git.stash.count",{count:a.length})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[u&&r&&a.length>0&&(0,e.jsx)(eJ,{testId:"stash-cleanup-ask-ai",onClick:()=>r(function(a,b){let c=a("git.aiPrompts.stashCleanup");if(0===b.length)return c;let d=b.map(a=>`- stash@{${a.index}}: ${a.message}`).join("\n");return`${c}
30
30
 
31
31
  ${a("git.aiPrompts.stashCleanupCurrent")}
32
32
  ${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)(eI,{})})]})]}),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)(eJ,{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}
33
33
 
34
- ${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")})]})]})]})}),eW={soft:"git.danger.modeSoft",mixed:"git.danger.modeMixed",hard:"git.danger.modeHard"},eX=(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}=eB(),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(eW[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)(eJ,{className:"mr-auto",testId:"reset-ask-ai",disabled:L,onClick:()=>{K&&(p("hard"===u?q("git.aiPrompts.resetHard",{target:eS(K)}):q("git.aiPrompts.reset",{target:eS(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)(eJ,{className:"mr-auto",testId:"revert-ask-ai",onClick:()=>{p(q("git.aiPrompts.revert",{commit:eS(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)(eJ,{className:"mr-auto",testId:"force-push-ask-ai",onClick:()=>{p(function(a,{branch:b,ahead:c}){let d=b?eS(b):a("git.aiPrompts.forcePushCurrentBranch");return a("number"==typeof c&&c>0?"git.aiPrompts.forcePushAhead":"git.aiPrompts.forcePush",{branchRef:d,upstream:eS(`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")})]})]})]})}),eY=(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,eq.V)({key:et.activeTab,defaultValue:"status",validate:eu}),{value:d,setValue:e}=(0,eq.V)({key:et.historyOpen,defaultValue:!0,validate:ev}),{value:f,setValue:g}=(0,eq.V)({key:et.advancedOpen,defaultValue:!1,validate:ev}),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]);c_({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)(eN,{gitStatus:s,statusLoading:t,statusError:u,onRefresh:aW,refreshing:"running"===aK}),a$=(0,e.jsx)(eO,{progressState:aK,operation:aJ,error:aT,conflict:aN,conflictFiles:aO,hasUpstream:aV,onPull:()=>aQ({}),onPush:()=>aR({setUpstream:!aV}),onAbort:aS,extraActions:(0,e.jsx)(ex,{branches:ah,busy:al||aU,actionError:am,hasRunningSession:r,isMobile:c,onCheckout:aq})}),a_=(0,e.jsx)(eQ,{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)(eR,{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)(ey,{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)(eU,{branches:ah,include:ai,loading:aj,error:ak,busy:al||aU,actionError:am,onIncludeChange:ao,onRefresh:ap,onCreate:ar,onDelete:as}),(0,e.jsx)(eV,{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)(eX,{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)(eA,{value:aY,children:(0,e.jsx)(eG,{activeTab:j,onTabChange:l,className:g,statusSection:aZ,quickActionsSection:a$,changesSection:a_,historySection:a0,advancedSection:a1})})}),eZ=(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=e0(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)(e1,{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")})}),e$=(0,h.memo)(function({activeTab:a,worktreeId:b,worktree:c,messages:d,cliToolId:f,instanceId:g,onFilePathClick:h,onFileSelect:i,onWorktreeUpdate:j,onNewFile:l,onNewDirectory:m,onRename:n,onDelete:o,onUpload:p,onMove:q,onFileTreeReset:r,refreshTrigger:s,fileSearch:t,showToast:u,selectedAgents:v,onSelectedAgentsChange:w,availableAgents:x,maxAgents:y,persistToServer:z,vibeLocalModel:A,onVibeLocalModelChange:B,vibeLocalContextWindow:C,onVibeLocalContextWindowChange:D,disableAutoFollow:E,historySubTab:G,onHistorySubTabChange:H,onDiffSelect:I,onInsertToMessage:J,showArchived:K,onShowArchivedChange:L,historyDisplayLimit:M,onHistoryDisplayLimitChange:N,historyUserOnly:O,onHistoryUserOnlyChange:P,useInstanceManagement:Q,instances:R,onInstancesChange:S,visibleInstanceIds:T,onToggleInstanceVisible:U}){let V=(0,k.c)("worktree");switch(a){case"terminal":return(0,e.jsx)(F,{componentName:"TerminalDisplay",children:(0,e.jsx)(bF,{worktreeId:b,cliToolId:f,instanceId:g,disableAutoFollow:E})});case"history":return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsxs)("div",{className:"flex border-b border-border shrink-0",children:[(0,e.jsx)("button",{type:"button",onClick:()=>H("message"),className:`flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ${"message"===G?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"}`,children:V("detail.subTabMessage")}),(0,e.jsx)("button",{type:"button",onClick:()=>H("git"),className:`flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ${"git"===G?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"}`,children:V("detail.subTabGit")})]}),"message"===G?(0,e.jsx)(F,{componentName:"HistoryPane",children:(0,e.jsx)(cF,{messages:d,worktreeId:b,onFilePathClick:h,className:"flex-1 min-h-0",showToast:u,onInsertToMessage:J,showArchived:K,onShowArchivedChange:L,historyDisplayLimit:M,onHistoryDisplayLimitChange:N,historyUserOnly:O,onHistoryUserOnlyChange:P})}):(0,e.jsx)(F,{componentName:"GitPane",children:(0,e.jsx)(eY,{worktreeId:b,onDiffSelect:I,isMobile:!0,worktree:c??void 0,onInsertToMessage:J,className:"flex-1 min-h-0"})})]});case"files":return(0,e.jsx)(F,{componentName:"FileTreeView",children:(0,e.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,e.jsx)(c5,{query:t.query,mode:t.mode,isSearching:t.isSearching,error:t.error,onQueryChange:t.setQuery,onModeChange:t.setMode,onClear:t.clearSearch}),(0,e.jsx)(c1,{worktreeId:b,onFileSelect:i,onNewFile:l,onNewDirectory:m,onRename:n,onDelete:o,onUpload:p,onMove:q,onResetView:r,refreshTrigger:s,pollingEnabled:"files"===a,searchQuery:t.query,searchMode:t.mode,searchResults:t.results?.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,e.jsx)(F,{componentName:"NotesAndLogsPane",children:(0,e.jsx)(ep,{worktreeId:b,className:"h-full",selectedAgents:v,onSelectedAgentsChange:w,availableAgents:x,maxAgents:y,persistToServer:z,vibeLocalModel:A,onVibeLocalModelChange:B,vibeLocalContextWindow:C,onVibeLocalContextWindowChange:D,onInsertToMessage:J,useInstanceManagement:Q,instances:R,onInstancesChange:S,visibleInstanceIds:T,onToggleInstanceVisible:U})});case"info":return(0,e.jsx)(eZ,{worktreeId:b,worktree:c,onWorktreeUpdate:j});default:return null}}),e_=[{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 e0(a,b,c,d){let[e,f]=(0,h.useState)(!1),[g,i]=(0,h.useState)(""),[j,k]=(0,h.useState)(!1),l=(0,h.useCallback)(async()=>{if(a){k(!0);try{let c=await T.y.updateDescription(a.id,g);b(c),f(!1)}catch(a){console.error("Failed to save description:",a)}finally{k(!1)}}},[a,g,b]),m=(0,h.useCallback)(()=>{i(a?.description||""),f(!1)},[a]);return{isEditing:e,text:g,setText:i,isSaving:j,handleSave:l,handleCancel:m,startEditing:(0,h.useCallback)(()=>{f(!0)},[])}}let e1=(0,h.memo)(function({worktreeId:a,worktree:b,cardClassName:c,descriptionEditor:d,showLogs:f,onToggleLogs:g,onWorktreeUpdate:i}){let{isEditing:j,text:l,setText:m,isSaving:o,handleSave:p,handleCancel:q,startEditing:r}=d,s=(0,k.c)("worktree"),t=(0,k.c)("common"),[u,v]=(0,h.useState)(!1),[w,x]=(0,h.useState)(!1),y=(0,h.useRef)(void 0),z=(0,h.useRef)(void 0);(0,h.useEffect)(()=>()=>{y.current&&clearTimeout(y.current),z.current&&clearTimeout(z.current)},[]);let A=(0,h.useCallback)(async()=>{try{await (0,ay.l)(b.path),v(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>v(!1),ah.pX)}catch{}},[b.path]),B=(0,h.useCallback)(async()=>{try{await (0,ay.l)(b.repositoryPath),x(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>x(!1),ah.pX)}catch{}},[b.repositoryPath]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.worktree")}),(0,e.jsx)("p",{className:"text-lg font-semibold text-foreground",children:b.name})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.repository")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:B,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":s("detail.copyRepositoryPath"),title:w?s("detail.copied"):s("detail.copyRepositoryPath"),children:w?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("p",{className:"text-base text-foreground",children:b.repositoryDisplayName??b.repositoryName}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:b.repositoryPath})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.path")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:A,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":s("detail.copyWorktreePath"),title:u?s("detail.copied"):s("detail.copyPath"),children:u?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("p",{className:"text-sm text-foreground break-all font-mono",children:b.path})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.status")}),(0,e.jsx)("select",{value:b.status??"",onChange:async a=>{let c=a.target.value;try{let a=await fetch(`/api/worktrees/${b.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:""===c?null:c})});if(a.ok&&i){let b=await a.json();i(b)}}catch{}},className:"text-sm px-3 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent w-full","data-testid":"mobile-status-dropdown","aria-label":s("detail.worktreeStatusLabel"),children:e_.map(a=>(0,e.jsx)("option",{value:a.value??"",children:s(a.labelKey)},a.labelKey))})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.description")}),!j&&(0,e.jsx)("button",{type:"button",onClick:r,className:"text-sm text-accent-600 hover:text-accent-800 dark:text-accent-400 dark:hover:text-accent-300",children:s("actions.edit")})]}),j?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("textarea",{value:l,onChange:a=>m(a.target.value),placeholder:s("detail.addNotesPlaceholder"),className:"w-full min-h-[150px] p-3 border border-input dark:bg-surface dark:text-foreground rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:p,disabled:o,className:"px-4 py-2 bg-accent-600 text-white rounded-lg hover:bg-accent-700 disabled:opacity-50 text-sm font-medium",children:o?s("actions.saving"):s("actions.save")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:q,disabled:o,className:"px-4 py-2 bg-muted text-foreground rounded-lg hover:bg-border disabled:opacity-50 text-sm font-medium",children:t("cancel")})]})]}):(0,e.jsx)("div",{className:"min-h-[50px]",children:b.description?(0,e.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:b.description}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:s("detail.noDescription")})})]}),b.link&&(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.link")}),(0,e.jsx)("a",{href:b.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-600 hover:underline break-all",children:b.link})]}),b.updatedAt&&(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.lastUpdated")}),(0,e.jsx)("p",{className:"text-sm text-foreground",children:new Date(b.updatedAt).toLocaleString()})]}),(0,e.jsx)(a4,{version:"v0.21.3",className:c}),(0,e.jsx)(bb,{className:c}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.logs")}),(0,e.jsx)("button",{type:"button",onClick:g,className:"text-sm text-accent-600 hover:text-accent-800",children:f?s("detail.hide"):s("detail.show")})]}),f&&(0,e.jsx)(a0,{worktreeId:a})]})]})}),e2=(0,h.memo)(function({worktreeName:a,repositoryName:b,description:c,status:d,gitStatus:f,onBackClick:g,onInfoClick:i,hasUpdate:j,worktreeStatus:l,onWorktreeStatusChange:m,sessionStatusByCli:p,sessionStatusByInstance:q,instances:s,activeInstanceId:t,onActiveInstanceChange:u,onAgentDragStart:v,onAgentDragEnd:w,onKillSession:x}){let y=(0,k.c)("worktree"),z=(0,k.c)("common"),A=aX.sb[d],B=A?y(A):void 0,[D,E]=(0,h.useState)(null),F=s?.find(a=>a.id===t),G=!!t&&(q?.[t]?.isRunning??(F?p?.[F.cliTool]?.isRunning:void 0)??!1),H=(0,h.useCallback)((a,b)=>{a.dataTransfer.setData(bg,b),a.dataTransfer.effectAllowed="move",E(b),v?.(b)},[v]),I=(0,h.useCallback)(()=>{E(null),w?.()},[w]),J=c?r(c,50):null;return(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-surface border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("button",{type:"button",onClick:g,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":y("detail.goBack"),"data-testid":"worktree-back-button",children:[(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1h-2z"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:y("detail.home")})]}),(0,e.jsx)("div",{className:"w-px h-6 bg-border","aria-hidden":"true"}),(0,e.jsx)(o.m,{"data-testid":"desktop-status-indicator",status:d,size:"lg",label:B}),(0,e.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,e.jsx)("h1",{className:"text-lg font-semibold text-foreground truncate max-w-[200px] leading-tight",children:a}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"truncate max-w-[200px]",children:b}),f&&"(unknown)"!==f.currentBranch&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"/"}),(0,e.jsx)("span",{className:"truncate max-w-[150px] font-mono",title:f.currentBranch,"data-testid":"desktop-branch-name",children:r(f.currentBranch,30)}),f.isDirty&&(0,e.jsx)("span",{className:"text-warning",title:y("git.uncommittedChanges"),children:"*"})]}),J&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"—"}),(0,e.jsx)("span",{className:"truncate max-w-[300px] text-muted-foreground",title:c,children:J})]})]})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[s&&s.length>0&&(()=>{let a=(0,a$.Uw)(s.map(a=>({item:a,status:(0,bd.kA)(q?.[a.id]??p?.[a.cliTool]),isActive:a.id===t})),4),b=a.filter(a=>"overflow"===a.slot),c=b.find(a=>"running"===a.status||"generating"===a.status)?.status??b.find(a=>"waiting"===a.status)?.status??null;return(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0","data-testid":"desktop-agent-status-row",children:[a.map(a=>{if("overflow"===a.slot)return null;let b=a.item,c=y("detail.statusPill",{label:(0,be.sw)(b),status:z(`status.${a.status}`)}),d=a.isActive,f={draggable:!0,onDragStart:a=>H(a,b.id),onDragEnd:I},g=D===b.id?" opacity-50 cursor-grabbing":"";return"pill"===a.slot?(0,e.jsxs)("button",{type:"button","data-testid":`desktop-agent-status-${b.id}`,onClick:()=>u?.(b.id),...f,"aria-label":c,"aria-pressed":d,className:`flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${d?"bg-accent-100 dark:bg-accent-900/30 text-accent-900 dark:text-accent-100":"hover:bg-muted text-foreground"}${g}`,children:[(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0}),(0,e.jsx)("span",{className:"whitespace-nowrap",children:c})]},b.id):(0,e.jsx)(aY.m_,{content:c,placement:"bottom",children:(0,e.jsx)("button",{type:"button","data-testid":`desktop-agent-status-${b.id}`,onClick:()=>u?.(b.id),...f,"aria-label":c,"aria-pressed":d,className:`flex items-center justify-center w-6 h-6 rounded-full transition-colors ${d?"bg-accent-100 dark:bg-accent-900/30":"hover:bg-muted"}${g}`,children:(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0})})},b.id)}),b.length>0&&(0,e.jsxs)(aZ.rI,{children:[(0,e.jsx)(aZ.ty,{asChild:!0,children:(0,e.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-overflow","aria-label":y("agentStatus.moreAgents",{count:b.length}),className:"flex items-center gap-1 px-2 py-1 rounded text-xs tabular-nums text-muted-foreground hover:bg-muted transition-colors",children:[c&&(0,e.jsx)(o.m,{status:c,size:"sm","aria-hidden":!0,title:void 0}),"+",b.length]})}),(0,e.jsx)(aZ.SQ,{align:"end",children:b.map(a=>{let b=a.item,c=y("detail.statusPill",{label:(0,be.sw)(b),status:z(`status.${a.status}`)});return(0,e.jsxs)(aZ._2,{"data-testid":`desktop-agent-overflow-${b.id}`,onSelect:()=>u?.(b.id),children:[(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0}),(0,e.jsx)("span",{className:"whitespace-nowrap",children:c})]},b.id)})})]})]})})(),x&&G&&(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:x,className:"flex items-center gap-1 px-2 py-1.5 text-xs font-medium rounded-lg text-danger-foreground hover:bg-danger-subtle transition-colors flex-shrink-0","aria-label":y("terminal.endSession"),"data-testid":"desktop-kill-session",children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"✕"}),z("end")]}),m&&(0,e.jsx)("select",{value:l??"",onChange:a=>{let b=a.target.value;m(""===b?null:b)},onClick:a=>a.stopPropagation(),className:"text-xs px-2 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent cursor-pointer","data-testid":"desktop-status-dropdown","aria-label":y("detail.worktreeStatusLabel"),children:e_.map(a=>(0,e.jsx)("option",{value:a.value??"",children:y(a.labelKey)},a.labelKey))}),(0,e.jsx)(bi.g,{}),(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:i,className:"relative flex items-center gap-1.5 px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors","aria-label":y("detail.viewInfo"),children:[(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:y("detail.info")}),j&&(0,e.jsx)(C,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":y("tabs.updateAvailable")})]})]})]})}),e3=(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=e0(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)(e1,{worktreeId:a,worktree:b,cardClassName:"bg-muted rounded-lg p-4",descriptionEditor:m,showLogs:g,onToggleLogs:()=>i(!g),onWorktreeUpdate:f})})}):null}),e4=(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")})]})})}),e5=(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")})]})})}),e6=(0,h.memo)(function({activityPane:a,rightPane:b,activityPaneWidth:c=18,minPaneWidth:d=10,maxPaneWidth:f=60,onActivityPaneResize:g,className:i=""}){let j=(0,h.useRef)(null),l=(0,k.c)("worktree"),[m,n]=(0,h.useState)(c),o=g?c:m,p=(0,h.useCallback)(a=>{let b=j.current;if(!b)return;let e=b.offsetWidth;if(0===e)return;let h=Math.min(f,Math.max(d,(g?c:m)+a/e*100));g?g(h):n(h)},[c,m,d,f,g]),q=(0,h.useMemo)(()=>`flex h-full min-h-0 ${i}`.trim(),[i]);return(0,e.jsx)("div",{ref:j,className:"h-full",children:(0,e.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:q,children:[null!==a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{id:"worktree-activity-pane","data-testid":"activity-pane-slot","aria-label":l("desktopLayout.activityPane"),style:{width:`${o}%`},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,e.jsx)(F,{componentName:"ActivityPane",children:a})}),(0,e.jsx)(cw,{onResize:p,orientation:"horizontal",ariaValueNow:o})]}),(0,e.jsx)("div",{id:"worktree-right-pane","data-testid":"right-pane-slot","aria-label":l("desktopLayout.terminalPane"),className:"flex-grow overflow-hidden min-w-0",children:(0,e.jsx)(F,{componentName:"TerminalPane",children:b})})]})})}),e7=(0,x.A)("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),e8=(0,x.A)("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]);var e9=c(57898);let fa=(0,x.A)("sticky-note",[["path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",key:"1dfntj"}],["path",{d:"M15 3v5a1 1 0 0 0 1 1h5",key:"6s6qgf"}]]),fb=(0,x.A)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);var fc=c(55056);let fd=(0,x.A)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),fe=(0,x.A)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),ff=[{id:"files",labelKey:"activityBar.files",icon:e8},{id:"git",labelKey:"activityBar.git",icon:e9.A},{id:"notes",labelKey:"activityBar.notes",icon:fa},{id:"schedules",labelKey:"activityBar.schedules",icon:fb},{id:"agent",labelKey:"activityBar.agent",icon:fc.A},{id:"timer",labelKey:"activityBar.timer",icon:fd},{id:"todo",labelKey:"activityBar.todo",icon:fe},{id:"skills",labelKey:"activityBar.skills",icon:dh.A}];ff.map(a=>a.id);var fg=c(81092);let fh=(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,fg.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)%ff.length;f.current[b]?.focus();return}if("ArrowUp"===a.key){a.preventDefault();let b=(c-1+ff.length)%ff.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[ff.length-1]?.focus();return}},[b]);return(0,e.jsxs)("div",{"data-testid":"activity-bar",className:`flex flex-col items-stretch w-12 flex-shrink-0 bg-muted border-r border-border ${c}`.trim(),children:[(0,e.jsx)(aY.m_,{content:d("activityBar.toggleSidebar"),placement:"right",children:(0,e.jsx)("button",{type:"button","data-testid":"activity-bar-toggle-sidebar",onClick:i,"aria-label":d("activityBar.toggleSidebar"),"aria-expanded":g,className:"flex items-center justify-center h-12 w-12 text-muted-foreground transition-colors hover:text-surface-foreground hover:bg-muted-foreground/10 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,e.jsx)(e7,{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:ff.map((c,g)=>{let h=c.icon,i=a===c.id,k=d(c.labelKey);return(0,e.jsx)(aY.m_,{content:k,placement:"right",children:(0,e.jsx)("button",{ref:a=>{f.current[g]=a},type:"button",role:"tab","aria-selected":i,"aria-label":k,"aria-controls":"worktree-activity-pane",tabIndex:i||null===a&&0===g?0:-1,onClick:()=>b(c.id),onKeyDown:a=>j(a,g,c.id),"data-testid":`activity-bar-button-${c.id}`,className:"group flex items-center justify-center h-12 w-12 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,e.jsx)("span",{"aria-hidden":"true",className:`flex items-center justify-center h-9 w-9 rounded-md transition-colors ${i?"bg-accent-500/10 text-accent-600 dark:text-accent-400":"text-muted-foreground group-hover:text-surface-foreground group-hover:bg-muted-foreground/10"}`,children:(0,e.jsx)(h,{size:20,"aria-hidden":"true"})})})},c.id)})})]})}),fi="worktree-activity-pane",fj={files:"FileTreeView",git:"GitPane",notes:"MemoPane",schedules:"ExecutionLogPane",agent:"AgentSettingsPane",timer:"TimerPane",todo:"TodoPane",skills:"WorktreeSkillsPane"},fk=(0,h.memo)(function({active:a,activities:b,className:c=""}){if(null===a)return(0,e.jsx)("div",{id:fi,"data-testid":"activity-pane","data-active":"none",className:`h-full flex flex-col ${c}`.trim()});let d=b[a],f=fj[a];return(0,e.jsx)("div",{id:fi,"data-testid":"activity-pane","data-active":a,role:"tabpanel","aria-labelledby":`activity-bar-button-${a}`,className:`h-full flex flex-col min-h-0 ${c}`.trim(),children:(0,e.jsx)(F,{componentName:f,children:d??null})})}),fl=(0,h.memo)(function({inputRef:a,searchQuery:b,onQueryChange:c,matchCount:d,currentIdx:f,onNextMatch:g,onPrevMatch:h,onClose:i}){let j=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border-b border-input flex-shrink-0",children:[(0,e.jsx)("input",{ref:a,type:"text",value:b,onChange:a=>c(a.target.value),onKeyDown:a=>{"Escape"===a.key&&i(),"Enter"===a.key&&(a.shiftKey?h():g())},placeholder:j("fileSearch.placeholder"),className:"flex-1 min-w-0 px-2 py-0.5 text-sm bg-surface dark:text-foreground border border-input rounded outline-none focus:ring-1 focus:ring-ring",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground min-w-[3rem] text-right",children:d>0?`${f+1}/${d}`:"0/0"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:h,disabled:0===d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":j("fileSearch.prevMatch"),children:"▲"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:g,disabled:0===d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":j("fileSearch.nextMatch"),children:"▼"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:i,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white","aria-label":j("fileSearch.close"),children:(0,e.jsx)(az.A,{className:"w-4 h-4"})})]})}),fm=[{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"]}],fn=fm.map(a=>a.extension),fo=[".md",".html",".htm",".yaml",".yml"];var fp=c(79689);function fq(){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 fr=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/HtmlPreview"]},ssr:!1,loading:()=>(0,e.jsx)(fq,{})}),fs=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/PdfPreview"]},ssr:!1,loading:()=>(0,e.jsx)(fq,{})}),ft=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/MarkdownEditor"]},ssr:!1,loading:()=>(0,e.jsx)(fq,{})}),fu=/^---\s*\nmarp:\s*true/;function fv(){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 fw({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 fx({filePath:a,isMaximized:b,onToggleMaximize:c,copyableContent:d,onSearch:f}){let g=(0,k.c)("worktree"),[i,j]=(0,h.useState)(!1),[l,m]=(0,h.useState)(!1),n=(0,h.useRef)(null),o=(0,h.useRef)(null),p=async()=>{try{await (0,ay.l)(a),j(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>j(!1),ah.pX)}catch{}},q=async()=>{if(d)try{await (0,ay.l)(d),m(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>m(!1),ah.pX)}catch{}};return(0,e.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border gap-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("button",{type:"button",onClick:p,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.copyFilePath"),title:g("actions.copyPath"),children:i?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",title:a,children:a})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[f&&(0,e.jsx)("button",{type:"button",onClick:f,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.searchInFile"),title:g("actions.search"),children:(0,e.jsx)(Q.A,{className:"w-3.5 h-3.5"})}),d&&(0,e.jsx)("button",{type:"button",onClick:q,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.copyFileContent"),title:g("actions.copyContent"),children:l?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(as,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{type:"button",onClick:c,className:"flex-shrink-0 p-1.5 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g(b?"actions.minimize":"actions.maximize"),title:g(b?"actions.minimize":"actions.maximize"),children:b?(0,e.jsx)(aA,{className:"w-4 h-4"}):(0,e.jsx)(aB,{className:"w-4 h-4"})})]})]})}function fy({content:a,extension:b,searchMatches:c,searchCurrentIdx:d,totalLines:f,rangeStart:g,worktreeId:i,filePath:j,onLineRangeFetched:k}){let l=(0,h.useRef)(null),m=(0,h.useMemo)(()=>a.split("\n"),[a]),n=Math.max(1,g??1),o=m.length,p=Math.max(f??o,o),q=(0,h.useRef)(new Map),r=(0,h.useCallback)(a=>{let c=Math.floor(a/500),d=q.current,e=d.get(c);if(!e){let a=500*c,f=Math.min(a+500,m.length),g=m.slice(a,f).join("\n"),h="";try{h=aO.highlight(g,{language:b,ignoreIllegals:!0}).value}catch{h=aO.highlightAuto(g).value}e=h.split("\n"),d.set(c,e)}return e[a-500*c]??""},[m,b]),s=(0,h.useMemo)(()=>new Set(c??[]),[c]),t=(c?.length??0)>0?c[d??0]:-1,u=bX({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)(fp.E,{className:"h-4 w-3/4"})})]},a.key)})})})}function fz({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 fA({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)(fx,{filePath:d,isMaximized:i,onToggleMaximize:j,copyableContent:f})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:"slides"===o?(0,e.jsx)(fz,{slides:a,fileName:b}):(0,e.jsx)(ft,{worktreeId:c,filePath:d,onSave:g,initialViewMode:"split",onDirtyChange:l,onOpenFile:m})})]})}function fB({children:a,isMaximized:b,onToggle:c,filePath:d}){return b?(0,e.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:aE.M.MAXIMIZED_EDITOR},children:[(0,e.jsx)(fx,{filePath:d,isMaximized:b,onToggleMaximize:c}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:a})]}):(0,e.jsx)(e.Fragment,{children:a})}function fC({tab:a,content:b,worktreeId:c,isMaximized:d,onToggleMaximize:f,onFileSaved:g,onDirtyChange:h,onOpenFile:i}){let j=aN(b.content);return(0,e.jsxs)(e.Fragment,{children:[!d&&(0,e.jsx)(fx,{filePath:a.path,isMaximized:d,onToggleMaximize:f,copyableContent:b.content,onSearch:j.openSearch}),j.searchOpen&&(0,e.jsx)(fl,{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)(fy,{content:b.content,extension:"md",searchMatches:j.searchMatches,searchCurrentIdx:j.searchCurrentIdx}):(0,e.jsx)(ft,{worktreeId:c,filePath:a.path,onSave:g,initialViewMode:"preview",onDirtyChange:h,onOpenFile:i})})]})}function fD({tab:a,content:b,worktreeId:c,isMaximized:d,onToggleMaximize:f,onLoadContent:g}){let i=aN(b.content),j=(0,h.useCallback)(c=>{g&&g(a.path,{...b,content:c.content,totalLines:c.totalLines,totalBytes:c.totalBytes??b.totalBytes,range:c.range})},[g,a.path,b]),k=void 0!==b.range&&(b.totalLines??0)>b.range.end-b.range.start+1;return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fx,{filePath:a.path,isMaximized:d,onToggleMaximize:f,copyableContent:b.content,onSearch:i.openSearch}),i.searchOpen&&(0,e.jsx)(fl,{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)(fy,{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 fE=(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,c_({intervalMs:5e3,enabled:function(a){if(null===a.content||a.loading||a.isDirty||a.content.isPdf)return!1;let{totalBytes:b}=a.content;return void 0===b||!(b>=1048576)}(a),onPoll:async()=>{let a=`/api/worktrees/${b}/files/${(0,aF.o)(f.current)}`,c={};d.current&&(c["If-Modified-Since"]=d.current);try{let b=await fetch(a,{headers:c});if(304===b.status||!b.ok)return;d.current=b.headers.get("Last-Modified");let g=await b.json();e.current(f.current,g)}catch{}}})}({tab:a,worktreeId:b,onLoadContent:c});let s=(0,h.useMemo)(()=>i?b=>i(a.path,b):void 0,[i,a.path]),t=(0,h.useCallback)(()=>{r(a=>!a)},[]);(0,h.useEffect)(()=>{if(!q)return;let a=a=>{"Escape"===a.key&&r(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[q]),(0,h.useEffect)(()=>{null!==a.content||a.loading||null!==a.error||n.current||(n.current=!0,f(a.path,!0),(async()=>{try{let e=await fetch(`/api/worktrees/${b}/files/${(0,aF.o)(a.path)}`);if(304===e.status)return;if(!e.ok){let b=await e.json(),c="string"==typeof b.error?b.error:b.error?.message||m.current("fileViewer.loadError");d(a.path,c);return}let f=await e.json();c(a.path,f)}catch(b){d(a.path,b instanceof Error?b.message:m.current("fileViewer.loadError"))}finally{n.current=!1}})())},[a.content,a.loading,a.error,a.path,b,c,d,f]);let u=a.content?.content??null,v=a.content?.extension??null;if((0,h.useEffect)(()=>{if(!u||"md"!==v||!fu.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)(fv,{});if(a.error)return(0,e.jsx)(fw,{error:a.error});if(!a.content)return null;let{content:w}=a;return w.isImage?(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fx,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsx)(an.a,{src:w.content,alt:w.path,mimeType:w.mimeType})})]})}):w.isVideo?(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fx,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsx)(ao.u,{src:w.content,mimeType:w.mimeType})})]})}):w.isPdf?(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fx,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(fs,{dataUri:w.content,filePath:a.path})})]})}):w.isHtml?(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fx,{filePath:a.path,isMaximized:q,onToggleMaximize:t,copyableContent:w.content}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(fr,{worktreeId:b,filePath:a.path,htmlContent:w.content,onFileSaved:g,onOpenFile:j})})]})}):"md"===w.extension?(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)("div",{className:"h-full flex flex-col",children:o?(0,e.jsx)(fA,{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)(fC,{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 fo.includes(b)}("."+w.extension)?(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)(fD,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onLoadContent:c})}):(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)("div",{className:"h-full flex flex-col",children:(0,e.jsx)(fC,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onFileSaved:g,onDirtyChange:s,onOpenFile:j})})})});function fF(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 fG=(0,h.memo)(function({tab:a,isActive:b,onActivate:c,onClose:d}){let f=(0,k.c)("worktree"),g=(0,h.useCallback)(()=>{b||c(a.path)},[b,c,a.path]),i=(0,h.useCallback)(b=>{b.stopPropagation(),d(a.path)},[d,a.path]),j=b?"border-accent-500 text-accent-600 dark:text-accent-400 bg-surface":"border-transparent text-muted-foreground hover:text-foreground";return(0,e.jsxs)("div",{"data-testid":`file-tab-${a.path}`,"data-active":b,onClick:g,className:`flex items-center gap-1 px-3 py-2 text-sm font-medium border-b-2 cursor-pointer flex-shrink-0 ${j}`,children:[(0,e.jsx)("span",{className:"truncate max-w-[120px]",title:a.path,children:a.name}),a.isDirty&&(0,e.jsx)("span",{"data-testid":`file-tab-dirty-${a.path}`,className:"w-2 h-2 rounded-full bg-warning flex-shrink-0",title:f("fileTabs.unsavedChanges")}),(0,e.jsx)("button",{type:"button",onClick:i,className:"ml-1 p-0.5 rounded-sm hover:bg-muted transition-colors","aria-label":f("fileTabs.closeTab",{name:a.name}),children:(0,e.jsx)(az.A,{className:"w-3 h-3"})})]})}),fH=(0,h.memo)(function({tabs:a,activeIndex:b,worktreeId:c,onClose:d,onActivate:f,onLoadContent:g,onLoadError:i,onSetLoading:j,onFileSaved:k,onDirtyChange:l,onMoveToFront:m,onOpenFile:n}){let[o,p]=(0,h.useState)(!1),q=(0,h.useRef)(null),r=(0,h.useRef)(null),s=(0,h.useRef)({x:0,y:0}),[t,u]=(0,h.useState)({x:0,y:0}),v=null!==b&&b>=0&&b<a.length?a[b]:null,w=a.length>5?a.slice(0,5):a,x=a.length>5?a.slice(5):[];(0,h.useEffect)(()=>{if(!o)return;let a=a=>{q.current&&!q.current.contains(a.target)&&p(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[o]),(0,h.useLayoutEffect)(()=>{let a=a=>{s.current=a,u(b=>b.x===a.x&&b.y===a.y?b:a)};if(!o)return void a({x:0,y:0});let b=r.current;if(!b)return;let c=b.getBoundingClientRect();a({x:fF(c.left-s.current.x,c.width,window.innerWidth),y:fF(c.top-s.current.y,c.height,window.innerHeight)})},[o]);let y=(0,h.useCallback)(a=>{p(!1),m?.(a)},[m]),z=(0,h.useCallback)(()=>{p(a=>!a)},[]);return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex border-b border-border bg-surface dark:bg-surface-2 min-w-0",children:[(0,e.jsx)("div",{className:"flex min-w-0 overflow-hidden flex-1",children:w.map((a,c)=>(0,e.jsx)(fG,{tab:a,isActive:c===b,onActivate:f,onClose:d},a.path))}),x.length>0&&(0,e.jsxs)("div",{className:"relative flex-shrink-0",ref:q,children:[(0,e.jsxs)("button",{type:"button","data-testid":"tab-dropdown-button",onClick:z,className:"flex items-center gap-0.5 px-2 py-2 text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-muted border-b-2 border-transparent transition-colors",children:[(0,e.jsx)(bf.A,{className:`w-3 h-3 transition-transform ${o?"rotate-180":""}`}),(0,e.jsxs)("span",{children:["+",x.length]})]}),o&&(0,e.jsx)("div",{ref:r,"data-testid":"tab-dropdown-menu",className:"absolute right-0 top-full mt-1 bg-surface border border-border rounded-md shadow-lg z-50 min-w-[200px] max-h-[300px] overflow-y-auto",style:0!==t.x||0!==t.y?{transform:`translate(${t.x}px, ${t.y}px)`}:void 0,children:x.map(a=>(0,e.jsxs)("button",{type:"button","data-testid":`tab-dropdown-item-${a.path}`,onClick:()=>y(a.path),className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-muted truncate",title:a.path,children:[a.name,a.isDirty&&(0,e.jsx)("span",{className:"ml-1 w-2 h-2 inline-block rounded-full bg-warning"})]},a.path))})]})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:v&&(0,e.jsx)(fE,{tab:v,worktreeId:c,onLoadContent:g,onLoadError:i,onSetLoading:j,onFileSaved:k,onDirtyChange:l,onOpenFile:n},v.path)})]})}),fI=(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})}),fJ=(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)(fI,{line:a},b))})})})]})});function fK(){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 fL=(0,h.memo)(function({terminal:a,terminalHeader:b,fileTabs:c,worktreeId:d,onCloseTab:f,onActivateTab:g,onLoadContent:i,onLoadError:j,onSetLoading:l,onFileSaved:m,diffContent:n,diffFilePath:o,onCloseDiff:p,onDirtyChange:q,onMoveToFront:r,onOpenFile:s}){let t=(0,k.c)("worktree"),u=(0,h.useRef)(null),[v,w]=(0,h.useState)(50),{collapsed:x,toggle:y}=fK(),z=(0,h.useCallback)(a=>{let b=u.current;if(!b)return;let c=b.offsetWidth;if(0===c)return;let d=a/c*100;w(a=>Math.min(80,Math.max(20,a+d)))},[]),A=(0,h.useMemo)(()=>({width:`${v}%`}),[v]),B=(0,h.useMemo)(()=>({width:`${100-v}%`}),[v]),C=(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[b,(0,e.jsx)("div",{className:"flex-1 min-h-0",children:a})]});return c.tabs.length>0||n&&o?x?(0,e.jsxs)("div",{ref:u,className:"flex h-full min-h-0",children:[(0,e.jsx)("div",{"data-testid":"terminal-pane",style:{width:"calc(100% - 36px)"},className:"flex-shrink-0 overflow-hidden",children:C}),(0,e.jsx)("div",{"data-testid":"file-panel-expand-bar",style:{width:"36px"},className:"flex-shrink-0 flex items-start justify-center bg-muted border-l border-border",children:(0,e.jsxs)("button",{type:"button","aria-label":t("terminal.showFiles"),title:t("terminal.showFiles"),onClick:y,className:"flex flex-col items-center gap-2 w-full pt-2 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,e.jsx)("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),(0,e.jsx)("span",{className:"text-xs font-medium tracking-wide select-none",style:{writingMode:"vertical-rl"},"aria-hidden":"true",children:t("terminal.filesLabel")})]})})]}):(0,e.jsxs)("div",{ref:u,className:"flex h-full min-h-0",children:[(0,e.jsx)("div",{"data-testid":"terminal-pane",style:A,className:"flex-shrink-0 overflow-hidden",children:C}),(0,e.jsx)(cw,{onResize:z,orientation:"horizontal",ariaValueNow:v}),(0,e.jsxs)("div",{"data-testid":"file-panel-pane",style:B,className:"flex-grow overflow-hidden flex",children:[(0,e.jsx)("button",{type:"button","aria-label":t("terminal.hideFiles"),title:t("terminal.hideFiles"),onClick:y,className:"flex-shrink-0 flex items-center justify-center w-5 h-full bg-muted border-r border-border text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),(0,e.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:n&&o&&p?(0,e.jsx)(fJ,{diff:n,filePath:o,onClose:p}):(0,e.jsx)(fH,{tabs:c.tabs,activeIndex:c.activeIndex,worktreeId:d,onClose:f,onActivate:g,onLoadContent:i,onLoadError:j,onSetLoading:l,onFileSaved:m,onDirtyChange:q,onMoveToFront:r,onOpenFile:s})})]})]}):(0,e.jsx)("div",{className:"h-full",children:C})});var fM=c(51881);let fN=(0,x.A)("align-horizontal-distribute-center",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]]),fO=(0,x.A)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),fP=(0,x.A)("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),fQ={splits:[{cliToolId:"claude",instanceId:"claude"}],widths:[1]};be.XH;function fR(a){let b=a.reduce((a,b)=>a+b,0);return b>0?a.map(a=>a/b):a.map(()=>1/a.length)}let fS=(0,h.memo)(function({worktreeId:a,instances:b,rosterReady:c=!0,renderPane:d,onFocusedSplitChange:f,showToast:g,onActiveInstanceChange:j,headerInstanceSelection:l}){let{splits:m,widths:n,addSplit:o,removeSplit:p,setSplitInstance:q,setSplitWidth:r,resetWidths:s,availableInstanceIds:t,focusedSplitIndex:u,setFocusedSplitIndex:v}=function(a,b,c=!0){let[d,e]=(0,h.useState)(()=>(function(a,b,c){let d=function(a,b){let c=b[0];return c?{splits:[{cliToolId:c.cliTool,instanceId:c.id}],widths:[1]}:{splits:fQ.splits.map(a=>({...a})),widths:[...fQ.widths]}}(0,b);return c?function(a,b){let c;if(0===b.length)return a;let d=new Map(b.map(a=>[a.id,a.cliTool])),e=new Set,f=Math.min(Math.max(a.splits.length,1),b.length,3),g=[];for(let b of a.splits){if(g.length>=f)break;let a=d.get(b.instanceId);a&&!e.has(b.instanceId)&&(e.add(b.instanceId),g.push({cliToolId:a,instanceId:b.instanceId}))}for(let a of b){if(g.length>=f)break;e.has(a.id)||(e.add(a.id),g.push({cliToolId:a.cliTool,instanceId:a.id}))}return(0===g.length&&g.push({cliToolId:b[0].cliTool,instanceId:b[0].id}),g.length===a.splits.length&&g.every((b,c)=>b.instanceId===a.splits[c].instanceId&&b.cliToolId===a.splits[c].cliToolId))?a:(c=g.length===a.widths.length?fR(a.widths):g.length<a.widths.length?fR(a.widths.slice(0,g.length)):Array.from({length:g.length},()=>1/g.length),{splits:g,widths:c})}(d,b):d})(0,b,c)),[f,g]=(0,h.useState)(0),i=(0,h.useRef)(d);i.current=d;let j=(0,h.useRef)(b);j.current=b,(0,h.useRef)(c).current=c,(0,h.useRef)(a),(0,h.useMemo)(()=>b.map(a=>`${a.id}:${a.cliTool}`).join("|"),[b]),(0,h.useRef)(a);let k=(0,h.useCallback)(()=>{e(a=>{if(a.splits.length>=3)return a;let b=new Set(a.splits.map(a=>a.instanceId)),c=function(a,b){for(let c of a)if(!b.has(c.id))return c;return null}(j.current,b);if(!c)return a;let d=a.widths.length-1,e=a.widths[d]/2,f=[...a.widths];return f[d]=e,f.push(e),{splits:[...a.splits,{cliToolId:c.cliTool,instanceId:c.id}],widths:f}})},[]),l=(0,h.useCallback)(()=>{e(a=>a.splits.length<=1?a:{splits:a.splits.slice(0,-1),widths:fR(a.widths.slice(0,-1))})},[]),m=(0,h.useCallback)((a,b)=>{let c=i.current,d=j.current;if(a<0||a>=c.splits.length)return!1;let f=d.find(a=>a.id===b);if(!f||c.splits[a].instanceId===b)return!1;for(let d=0;d<c.splits.length;d++)if(d!==a&&c.splits[d].instanceId===b)return!1;return e(c=>{if(a<0||a>=c.splits.length||c.splits[a].instanceId===b)return c;for(let d=0;d<c.splits.length;d++)if(d!==a&&c.splits[d].instanceId===b)return c;let d=c.splits.map((c,d)=>d===a?{cliToolId:f.cliTool,instanceId:b}:c);return{...c,splits:d}}),!0},[]),n=(0,h.useCallback)(a=>{e(b=>a.length!==b.widths.length||!function(a){if(!Array.isArray(a))return!1;for(let b of a)if("number"!=typeof b||!Number.isFinite(b)||b<=0)return!1;return!0}(a)?b:{...b,widths:[...a]})},[]),o=(0,h.useCallback)(()=>{e(a=>{let b=a.splits.length;return 0===b?a:{...a,widths:Array.from({length:b},()=>1/b)}})},[]),p=(0,h.useCallback)(a=>{let c=new Set;for(let b=0;b<d.splits.length;b++)b!==a&&c.add(d.splits[b].instanceId);return b.filter(a=>!c.has(a.id)).map(a=>a.id)},[d.splits,b]),q=(0,h.useCallback)(a=>{g(a)},[]);return{splits:d.splits,widths:d.widths,addSplit:k,removeSplit:l,setSplitInstance:m,setSplitWidth:n,resetWidths:o,availableInstanceIds:p,focusedSplitIndex:f,setFocusedSplitIndex:q}}(a,b,c),w=(0,h.useMemo)(()=>{let a=new Map;for(let c of b)a.set(c.id,c);return a},[b]),x=(0,k.c)("worktree"),{visible:y,toggle:z,setWidth:A}=cr(),{collapsed:B,toggle:C}=fK(),D=!B,E=(0,h.useRef)(null),[F,G]=(0,h.useState)(!1),H=(0,h.useRef)(m.length),[I,J]=(0,h.useState)(null);(0,h.useEffect)(()=>{m.length>H.current&&J(m.length-1),H.current=m.length},[m.length]),(0,h.useEffect)(()=>{f?.(u)},[u,f]);let K=(0,h.useRef)(0),L=(0,h.useRef)(m);L.current=m,(0,h.useEffect)(()=>{if(!l||l.token===K.current)return;K.current=l.token;let{instanceId:a}=l,b=L.current.findIndex(b=>b.instanceId===a);if(0!==b){if(b>0)return void v(b);q(0,a)&&v(0)}},[l,q,v]),(0,h.useEffect)(()=>{if(null===I)return;let a=E.current;if(!a)return;let b=a.querySelector(`[data-split-index="${I}"]`);if(!b)return;let c=b.querySelector("textarea");c?.focus(),v(I),J(null)},[I,v]);let M=(0,h.useCallback)((a,b)=>{let c=E.current;if(!c)return;let d=c.offsetWidth;if(0===d)return;let e=n.reduce((a,b)=>a+b,0),f=b/d*e,g=[...n],h=g[a]+f,i=g[a+1]-f,j=.05*e;h<j||i<j||(g[a]=h,g[a+1]=i,r(g))},[n,r]),N=(0,h.useCallback)(()=>G(!0),[]),O=(0,h.useCallback)(()=>G(!1),[]),P=(0,h.useCallback)(()=>{s(),A(40)},[s,A]),Q=m.length<3&&!F,R=m.length>1&&!F,S=m.length>1||y,T=(0,h.useMemo)(()=>m.map((a,b)=>()=>v(b)),[m,v]),U=(0,h.useMemo)(()=>m.map((a,b)=>a=>q(b,a)),[m,q]),V=(0,h.useMemo)(()=>m.map((a,b)=>a=>{let c=(0,be.sw)(w.get(a)??{cliTool:"claude",alias:a});if(m[b]?.instanceId===a)return;let d=m.findIndex((c,d)=>d!==b&&c.instanceId===a);if(-1!==d)return void g?.(`${c} is already in use by split ${d+1}`,"warning");q(b,a)&&(j?.(a),g?.(`Moved ${c} to Split ${b+1}`,"success"))}),[m,q,g,j,w]);return(0,e.jsxs)("div",{role:"group","aria-label":"Terminal splits","data-testid":"terminal-split-container",className:"flex flex-col h-full min-h-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-surface border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums mr-1",children:[m.length," / ",3," splits"]}),(0,e.jsx)("button",{type:"button",onClick:o,disabled:!Q,"aria-disabled":!Q,"aria-label":x("terminal.addSplit"),title:x("terminal.addSplit"),"data-testid":"add-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(dP,{className:"w-4 h-4","aria-hidden":"true"})}),(0,e.jsx)("button",{type:"button",onClick:p,disabled:!R,"aria-disabled":!R,"aria-label":x("terminal.removeSplit"),title:x("terminal.removeSplit"),"data-testid":"remove-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(fM.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,e.jsx)("button",{type:"button",onClick:P,disabled:!S,"aria-disabled":!S,"aria-label":x("terminal.equalizeWidthsHint"),title:x("terminal.equalizeWidthsHint"),"data-testid":"equalize-split-widths",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(fN,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})}),(0,e.jsx)("div",{className:"ml-auto h-4 w-px bg-border","aria-hidden":"true"}),(0,e.jsxs)("button",{type:"button",onClick:z,"aria-pressed":y,"aria-label":x(y?"terminal.hideHistory":"terminal.showHistory"),title:x(y?"terminal.hideHistory":"terminal.showHistory"),"data-testid":"toggle-history-pane",className:`flex items-center gap-1 text-xs px-2 py-0.5 rounded border transition-colors ${y?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[(0,e.jsx)(fO,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:x("terminal.historyLabel")})]}),(0,e.jsxs)("button",{type:"button",onClick:C,"aria-pressed":D,"aria-label":x(D?"terminal.hideFiles":"terminal.showFiles"),title:x(D?"terminal.hideFiles":"terminal.showFiles"),"data-testid":"toggle-file-panel",className:`flex items-center gap-1 text-xs px-2 py-0.5 rounded border transition-colors ${D?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[(0,e.jsx)(fP,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:x("terminal.filesLabel")})]})]}),(0,e.jsx)("div",{ref:E,className:"flex flex-1 min-h-0 w-full",children:m.map((a,b)=>{let c=b===m.length-1;return(0,e.jsxs)(i().Fragment,{children:[(0,e.jsx)("div",{style:{flexGrow:n[b]??1,flexShrink:1,flexBasis:0,minWidth:0},className:"h-full",children:d({splitIndex:b,cliToolId:a.cliToolId,instanceId:a.instanceId,instance:w.get(a.instanceId),availableInstances:t(b).map(a=>w.get(a)).filter(a=>void 0!==a),onInstanceChange:U[b],onFocus:T[b],isFocused:u===b,onDropInstance:V[b]})}),c?null:(0,e.jsx)(fT,{resizerIdx:b,ariaValueNow:n.length?n[b]/n.reduce((a,b)=>a+b,0)*100:50,onResize:M,onStart:N,onEnd:O,onDoubleClick:s})]},`split-${b}`)})})]})});function fT({resizerIdx:a,ariaValueNow:b,onResize:c,onStart:d,onEnd:f,onDoubleClick:g}){let i=(0,h.useCallback)(b=>c(a,b),[a,c]);return(0,e.jsx)("div",{"data-testid":`split-resizer-${a}`,onMouseDownCapture:d,onTouchStartCapture:d,onMouseUpCapture:f,onTouchEndCapture:f,children:(0,e.jsx)(cw,{onResize:i,orientation:"horizontal",ariaValueNow:b,onDoubleClick:g})})}let fU=`
34
+ ${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")})]})]})]})}),eW={soft:"git.danger.modeSoft",mixed:"git.danger.modeMixed",hard:"git.danger.modeHard"},eX=(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}=eB(),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(eW[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)(eJ,{className:"mr-auto",testId:"reset-ask-ai",disabled:L,onClick:()=>{K&&(p("hard"===u?q("git.aiPrompts.resetHard",{target:eS(K)}):q("git.aiPrompts.reset",{target:eS(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)(eJ,{className:"mr-auto",testId:"revert-ask-ai",onClick:()=>{p(q("git.aiPrompts.revert",{commit:eS(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)(eJ,{className:"mr-auto",testId:"force-push-ask-ai",onClick:()=>{p(function(a,{branch:b,ahead:c}){let d=b?eS(b):a("git.aiPrompts.forcePushCurrentBranch");return a("number"==typeof c&&c>0?"git.aiPrompts.forcePushAhead":"git.aiPrompts.forcePush",{branchRef:d,upstream:eS(`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")})]})]})]})}),eY=(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,eq.V)({key:et.activeTab,defaultValue:"status",validate:eu}),{value:d,setValue:e}=(0,eq.V)({key:et.historyOpen,defaultValue:!0,validate:ev}),{value:f,setValue:g}=(0,eq.V)({key:et.advancedOpen,defaultValue:!1,validate:ev}),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]);c_({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)(eN,{gitStatus:s,statusLoading:t,statusError:u,onRefresh:aW,refreshing:"running"===aK}),a$=(0,e.jsx)(eO,{progressState:aK,operation:aJ,error:aT,conflict:aN,conflictFiles:aO,hasUpstream:aV,onPull:()=>aQ({}),onPush:()=>aR({setUpstream:!aV}),onAbort:aS,extraActions:(0,e.jsx)(ex,{branches:ah,busy:al||aU,actionError:am,hasRunningSession:r,isMobile:c,onCheckout:aq})}),a_=(0,e.jsx)(eQ,{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)(eR,{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)(ey,{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)(eU,{branches:ah,include:ai,loading:aj,error:ak,busy:al||aU,actionError:am,onIncludeChange:ao,onRefresh:ap,onCreate:ar,onDelete:as}),(0,e.jsx)(eV,{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)(eX,{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)(eA,{value:aY,children:(0,e.jsx)(eG,{activeTab:j,onTabChange:l,className:g,statusSection:aZ,quickActionsSection:a$,changesSection:a_,historySection:a0,advancedSection:a1})})}),eZ=(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=e0(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)(e1,{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")})}),e$=(0,h.memo)(function({activeTab:a,worktreeId:b,worktree:c,messages:d,cliToolId:f,instanceId:g,onFilePathClick:h,onFileSelect:i,onWorktreeUpdate:j,onNewFile:l,onNewDirectory:m,onRename:n,onDelete:o,onUpload:p,onMove:q,onFileTreeReset:r,refreshTrigger:s,fileSearch:t,showToast:u,selectedAgents:v,onSelectedAgentsChange:w,availableAgents:x,maxAgents:y,persistToServer:z,vibeLocalModel:A,onVibeLocalModelChange:B,vibeLocalContextWindow:C,onVibeLocalContextWindowChange:D,disableAutoFollow:E,historySubTab:G,onHistorySubTabChange:H,onDiffSelect:I,onInsertToMessage:J,showArchived:K,onShowArchivedChange:L,historyDisplayLimit:M,onHistoryDisplayLimitChange:N,historyUserOnly:O,onHistoryUserOnlyChange:P,useInstanceManagement:Q,instances:R,onInstancesChange:S,visibleInstanceIds:T,onToggleInstanceVisible:U}){let V=(0,k.c)("worktree");switch(a){case"terminal":return(0,e.jsx)(F,{componentName:"TerminalDisplay",children:(0,e.jsx)(bF,{worktreeId:b,cliToolId:f,instanceId:g,disableAutoFollow:E})});case"history":return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsxs)("div",{className:"flex border-b border-border shrink-0",children:[(0,e.jsx)("button",{type:"button",onClick:()=>H("message"),className:`flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ${"message"===G?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"}`,children:V("detail.subTabMessage")}),(0,e.jsx)("button",{type:"button",onClick:()=>H("git"),className:`flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ${"git"===G?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"}`,children:V("detail.subTabGit")})]}),"message"===G?(0,e.jsx)(F,{componentName:"HistoryPane",children:(0,e.jsx)(cF,{messages:d,worktreeId:b,onFilePathClick:h,className:"flex-1 min-h-0",showToast:u,onInsertToMessage:J,showArchived:K,onShowArchivedChange:L,historyDisplayLimit:M,onHistoryDisplayLimitChange:N,historyUserOnly:O,onHistoryUserOnlyChange:P})}):(0,e.jsx)(F,{componentName:"GitPane",children:(0,e.jsx)(eY,{worktreeId:b,onDiffSelect:I,isMobile:!0,worktree:c??void 0,onInsertToMessage:J,className:"flex-1 min-h-0"})})]});case"files":return(0,e.jsx)(F,{componentName:"FileTreeView",children:(0,e.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,e.jsx)(c5,{query:t.query,mode:t.mode,isSearching:t.isSearching,error:t.error,onQueryChange:t.setQuery,onModeChange:t.setMode,onClear:t.clearSearch}),(0,e.jsx)(c1,{worktreeId:b,onFileSelect:i,onNewFile:l,onNewDirectory:m,onRename:n,onDelete:o,onUpload:p,onMove:q,onResetView:r,refreshTrigger:s,pollingEnabled:"files"===a,searchQuery:t.query,searchMode:t.mode,searchResults:t.results?.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,e.jsx)(F,{componentName:"NotesAndLogsPane",children:(0,e.jsx)(ep,{worktreeId:b,className:"h-full",selectedAgents:v,onSelectedAgentsChange:w,availableAgents:x,maxAgents:y,persistToServer:z,vibeLocalModel:A,onVibeLocalModelChange:B,vibeLocalContextWindow:C,onVibeLocalContextWindowChange:D,onInsertToMessage:J,useInstanceManagement:Q,instances:R,onInstancesChange:S,visibleInstanceIds:T,onToggleInstanceVisible:U})});case"info":return(0,e.jsx)(eZ,{worktreeId:b,worktree:c,onWorktreeUpdate:j});default:return null}}),e_=[{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 e0(a,b,c,d){let[e,f]=(0,h.useState)(!1),[g,i]=(0,h.useState)(""),[j,k]=(0,h.useState)(!1),l=(0,h.useCallback)(async()=>{if(a){k(!0);try{let c=await T.y.updateDescription(a.id,g);b(c),f(!1)}catch(a){console.error("Failed to save description:",a)}finally{k(!1)}}},[a,g,b]),m=(0,h.useCallback)(()=>{i(a?.description||""),f(!1)},[a]);return{isEditing:e,text:g,setText:i,isSaving:j,handleSave:l,handleCancel:m,startEditing:(0,h.useCallback)(()=>{f(!0)},[])}}let e1=(0,h.memo)(function({worktreeId:a,worktree:b,cardClassName:c,descriptionEditor:d,showLogs:f,onToggleLogs:g,onWorktreeUpdate:i}){let{isEditing:j,text:l,setText:m,isSaving:o,handleSave:p,handleCancel:q,startEditing:r}=d,s=(0,k.c)("worktree"),t=(0,k.c)("common"),[u,v]=(0,h.useState)(!1),[w,x]=(0,h.useState)(!1),y=(0,h.useRef)(void 0),z=(0,h.useRef)(void 0);(0,h.useEffect)(()=>()=>{y.current&&clearTimeout(y.current),z.current&&clearTimeout(z.current)},[]);let A=(0,h.useCallback)(async()=>{try{await (0,ay.l)(b.path),v(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>v(!1),ah.pX)}catch{}},[b.path]),B=(0,h.useCallback)(async()=>{try{await (0,ay.l)(b.repositoryPath),x(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>x(!1),ah.pX)}catch{}},[b.repositoryPath]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.worktree")}),(0,e.jsx)("p",{className:"text-lg font-semibold text-foreground",children:b.name})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.repository")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:B,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":s("detail.copyRepositoryPath"),title:w?s("detail.copied"):s("detail.copyRepositoryPath"),children:w?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("p",{className:"text-base text-foreground",children:b.repositoryDisplayName??b.repositoryName}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:b.repositoryPath})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.path")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:A,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":s("detail.copyWorktreePath"),title:u?s("detail.copied"):s("detail.copyPath"),children:u?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("p",{className:"text-sm text-foreground break-all font-mono",children:b.path})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.status")}),(0,e.jsx)("select",{value:b.status??"",onChange:async a=>{let c=a.target.value;try{let a=await fetch(`/api/worktrees/${b.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:""===c?null:c})});if(a.ok&&i){let b=await a.json();i(b)}}catch{}},className:"text-sm px-3 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent w-full","data-testid":"mobile-status-dropdown","aria-label":s("detail.worktreeStatusLabel"),children:e_.map(a=>(0,e.jsx)("option",{value:a.value??"",children:s(a.labelKey)},a.labelKey))})]}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.description")}),!j&&(0,e.jsx)("button",{type:"button",onClick:r,className:"text-sm text-accent-600 hover:text-accent-800 dark:text-accent-400 dark:hover:text-accent-300",children:s("actions.edit")})]}),j?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("textarea",{value:l,onChange:a=>m(a.target.value),placeholder:s("detail.addNotesPlaceholder"),className:"w-full min-h-[150px] p-3 border border-input dark:bg-surface dark:text-foreground rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:p,disabled:o,className:"px-4 py-2 bg-accent-600 text-white rounded-lg hover:bg-accent-700 disabled:opacity-50 text-sm font-medium",children:o?s("actions.saving"):s("actions.save")}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:q,disabled:o,className:"px-4 py-2 bg-muted text-foreground rounded-lg hover:bg-border disabled:opacity-50 text-sm font-medium",children:t("cancel")})]})]}):(0,e.jsx)("div",{className:"min-h-[50px]",children:b.description?(0,e.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:b.description}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:s("detail.noDescription")})})]}),b.link&&(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.link")}),(0,e.jsx)("a",{href:b.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-600 hover:underline break-all",children:b.link})]}),b.updatedAt&&(0,e.jsxs)("div",{className:c,children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:s("detail.lastUpdated")}),(0,e.jsx)("p",{className:"text-sm text-foreground",children:new Date(b.updatedAt).toLocaleString()})]}),(0,e.jsx)(a4,{version:"v0.21.4",className:c}),(0,e.jsx)(bb,{className:c}),(0,e.jsxs)("div",{className:c,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("detail.logs")}),(0,e.jsx)("button",{type:"button",onClick:g,className:"text-sm text-accent-600 hover:text-accent-800",children:f?s("detail.hide"):s("detail.show")})]}),f&&(0,e.jsx)(a0,{worktreeId:a})]})]})}),e2=(0,h.memo)(function({worktreeName:a,repositoryName:b,description:c,status:d,gitStatus:f,onBackClick:g,onInfoClick:i,hasUpdate:j,worktreeStatus:l,onWorktreeStatusChange:m,sessionStatusByCli:p,sessionStatusByInstance:q,instances:s,activeInstanceId:t,onActiveInstanceChange:u,onAgentDragStart:v,onAgentDragEnd:w,onKillSession:x}){let y=(0,k.c)("worktree"),z=(0,k.c)("common"),A=aX.sb[d],B=A?y(A):void 0,[D,E]=(0,h.useState)(null),F=s?.find(a=>a.id===t),G=!!t&&(q?.[t]?.isRunning??(F?p?.[F.cliTool]?.isRunning:void 0)??!1),H=(0,h.useCallback)((a,b)=>{a.dataTransfer.setData(bg,b),a.dataTransfer.effectAllowed="move",E(b),v?.(b)},[v]),I=(0,h.useCallback)(()=>{E(null),w?.()},[w]),J=c?r(c,50):null;return(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-surface border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("button",{type:"button",onClick:g,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":y("detail.goBack"),"data-testid":"worktree-back-button",children:[(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1h-2z"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:y("detail.home")})]}),(0,e.jsx)("div",{className:"w-px h-6 bg-border","aria-hidden":"true"}),(0,e.jsx)(o.m,{"data-testid":"desktop-status-indicator",status:d,size:"lg",label:B}),(0,e.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,e.jsx)("h1",{className:"text-lg font-semibold text-foreground truncate max-w-[200px] leading-tight",children:a}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"truncate max-w-[200px]",children:b}),f&&"(unknown)"!==f.currentBranch&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"/"}),(0,e.jsx)("span",{className:"truncate max-w-[150px] font-mono",title:f.currentBranch,"data-testid":"desktop-branch-name",children:r(f.currentBranch,30)}),f.isDirty&&(0,e.jsx)("span",{className:"text-warning",title:y("git.uncommittedChanges"),children:"*"})]}),J&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"—"}),(0,e.jsx)("span",{className:"truncate max-w-[300px] text-muted-foreground",title:c,children:J})]})]})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[s&&s.length>0&&(()=>{let a=(0,a$.Uw)(s.map(a=>({item:a,status:(0,bd.kA)(q?.[a.id]??p?.[a.cliTool]),isActive:a.id===t})),4),b=a.filter(a=>"overflow"===a.slot),c=b.find(a=>"running"===a.status||"generating"===a.status)?.status??b.find(a=>"waiting"===a.status)?.status??null;return(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0","data-testid":"desktop-agent-status-row",children:[a.map(a=>{if("overflow"===a.slot)return null;let b=a.item,c=y("detail.statusPill",{label:(0,be.sw)(b),status:z(`status.${a.status}`)}),d=a.isActive,f={draggable:!0,onDragStart:a=>H(a,b.id),onDragEnd:I},g=D===b.id?" opacity-50 cursor-grabbing":"";return"pill"===a.slot?(0,e.jsxs)("button",{type:"button","data-testid":`desktop-agent-status-${b.id}`,onClick:()=>u?.(b.id),...f,"aria-label":c,"aria-pressed":d,className:`flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${d?"bg-accent-100 dark:bg-accent-900/30 text-accent-900 dark:text-accent-100":"hover:bg-muted text-foreground"}${g}`,children:[(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0}),(0,e.jsx)("span",{className:"whitespace-nowrap",children:c})]},b.id):(0,e.jsx)(aY.m_,{content:c,placement:"bottom",children:(0,e.jsx)("button",{type:"button","data-testid":`desktop-agent-status-${b.id}`,onClick:()=>u?.(b.id),...f,"aria-label":c,"aria-pressed":d,className:`flex items-center justify-center w-6 h-6 rounded-full transition-colors ${d?"bg-accent-100 dark:bg-accent-900/30":"hover:bg-muted"}${g}`,children:(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0})})},b.id)}),b.length>0&&(0,e.jsxs)(aZ.rI,{children:[(0,e.jsx)(aZ.ty,{asChild:!0,children:(0,e.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-overflow","aria-label":y("agentStatus.moreAgents",{count:b.length}),className:"flex items-center gap-1 px-2 py-1 rounded text-xs tabular-nums text-muted-foreground hover:bg-muted transition-colors",children:[c&&(0,e.jsx)(o.m,{status:c,size:"sm","aria-hidden":!0,title:void 0}),"+",b.length]})}),(0,e.jsx)(aZ.SQ,{align:"end",children:b.map(a=>{let b=a.item,c=y("detail.statusPill",{label:(0,be.sw)(b),status:z(`status.${a.status}`)});return(0,e.jsxs)(aZ._2,{"data-testid":`desktop-agent-overflow-${b.id}`,onSelect:()=>u?.(b.id),children:[(0,e.jsx)(o.m,{status:a.status,size:"sm","aria-hidden":!0,title:void 0}),(0,e.jsx)("span",{className:"whitespace-nowrap",children:c})]},b.id)})})]})]})})(),x&&G&&(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:x,className:"flex items-center gap-1 px-2 py-1.5 text-xs font-medium rounded-lg text-danger-foreground hover:bg-danger-subtle transition-colors flex-shrink-0","aria-label":y("terminal.endSession"),"data-testid":"desktop-kill-session",children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"✕"}),z("end")]}),m&&(0,e.jsx)("select",{value:l??"",onChange:a=>{let b=a.target.value;m(""===b?null:b)},onClick:a=>a.stopPropagation(),className:"text-xs px-2 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent cursor-pointer","data-testid":"desktop-status-dropdown","aria-label":y("detail.worktreeStatusLabel"),children:e_.map(a=>(0,e.jsx)("option",{value:a.value??"",children:y(a.labelKey)},a.labelKey))}),(0,e.jsx)(bi.g,{}),(0,e.jsxs)(n.$n,{variant:"ghost",type:"button",onClick:i,className:"relative flex items-center gap-1.5 px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors","aria-label":y("detail.viewInfo"),children:[(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,e.jsx)("span",{className:"text-sm font-medium",children:y("detail.info")}),j&&(0,e.jsx)(C,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":y("tabs.updateAvailable")})]})]})]})}),e3=(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=e0(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)(e1,{worktreeId:a,worktree:b,cardClassName:"bg-muted rounded-lg p-4",descriptionEditor:m,showLogs:g,onToggleLogs:()=>i(!g),onWorktreeUpdate:f})})}):null}),e4=(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")})]})})}),e5=(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")})]})})}),e6=(0,h.memo)(function({activityPane:a,rightPane:b,activityPaneWidth:c=18,minPaneWidth:d=10,maxPaneWidth:f=60,onActivityPaneResize:g,className:i=""}){let j=(0,h.useRef)(null),l=(0,k.c)("worktree"),[m,n]=(0,h.useState)(c),o=g?c:m,p=(0,h.useCallback)(a=>{let b=j.current;if(!b)return;let e=b.offsetWidth;if(0===e)return;let h=Math.min(f,Math.max(d,(g?c:m)+a/e*100));g?g(h):n(h)},[c,m,d,f,g]),q=(0,h.useMemo)(()=>`flex h-full min-h-0 ${i}`.trim(),[i]);return(0,e.jsx)("div",{ref:j,className:"h-full",children:(0,e.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:q,children:[null!==a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{id:"worktree-activity-pane","data-testid":"activity-pane-slot","aria-label":l("desktopLayout.activityPane"),style:{width:`${o}%`},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,e.jsx)(F,{componentName:"ActivityPane",children:a})}),(0,e.jsx)(cw,{onResize:p,orientation:"horizontal",ariaValueNow:o})]}),(0,e.jsx)("div",{id:"worktree-right-pane","data-testid":"right-pane-slot","aria-label":l("desktopLayout.terminalPane"),className:"flex-grow overflow-hidden min-w-0",children:(0,e.jsx)(F,{componentName:"TerminalPane",children:b})})]})})}),e7=(0,x.A)("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),e8=(0,x.A)("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]);var e9=c(57898);let fa=(0,x.A)("sticky-note",[["path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",key:"1dfntj"}],["path",{d:"M15 3v5a1 1 0 0 0 1 1h5",key:"6s6qgf"}]]),fb=(0,x.A)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);var fc=c(55056);let fd=(0,x.A)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),fe=(0,x.A)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),ff=[{id:"files",labelKey:"activityBar.files",icon:e8},{id:"git",labelKey:"activityBar.git",icon:e9.A},{id:"notes",labelKey:"activityBar.notes",icon:fa},{id:"schedules",labelKey:"activityBar.schedules",icon:fb},{id:"agent",labelKey:"activityBar.agent",icon:fc.A},{id:"timer",labelKey:"activityBar.timer",icon:fd},{id:"todo",labelKey:"activityBar.todo",icon:fe},{id:"skills",labelKey:"activityBar.skills",icon:dh.A}];ff.map(a=>a.id);var fg=c(81092);let fh=(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,fg.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)%ff.length;f.current[b]?.focus();return}if("ArrowUp"===a.key){a.preventDefault();let b=(c-1+ff.length)%ff.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[ff.length-1]?.focus();return}},[b]);return(0,e.jsxs)("div",{"data-testid":"activity-bar",className:`flex flex-col items-stretch w-12 flex-shrink-0 bg-muted border-r border-border ${c}`.trim(),children:[(0,e.jsx)(aY.m_,{content:d("activityBar.toggleSidebar"),placement:"right",children:(0,e.jsx)("button",{type:"button","data-testid":"activity-bar-toggle-sidebar",onClick:i,"aria-label":d("activityBar.toggleSidebar"),"aria-expanded":g,className:"flex items-center justify-center h-12 w-12 text-muted-foreground transition-colors hover:text-surface-foreground hover:bg-muted-foreground/10 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,e.jsx)(e7,{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:ff.map((c,g)=>{let h=c.icon,i=a===c.id,k=d(c.labelKey);return(0,e.jsx)(aY.m_,{content:k,placement:"right",children:(0,e.jsx)("button",{ref:a=>{f.current[g]=a},type:"button",role:"tab","aria-selected":i,"aria-label":k,"aria-controls":"worktree-activity-pane",tabIndex:i||null===a&&0===g?0:-1,onClick:()=>b(c.id),onKeyDown:a=>j(a,g,c.id),"data-testid":`activity-bar-button-${c.id}`,className:"group flex items-center justify-center h-12 w-12 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,e.jsx)("span",{"aria-hidden":"true",className:`flex items-center justify-center h-9 w-9 rounded-md transition-colors ${i?"bg-accent-500/10 text-accent-600 dark:text-accent-400":"text-muted-foreground group-hover:text-surface-foreground group-hover:bg-muted-foreground/10"}`,children:(0,e.jsx)(h,{size:20,"aria-hidden":"true"})})})},c.id)})})]})}),fi="worktree-activity-pane",fj={files:"FileTreeView",git:"GitPane",notes:"MemoPane",schedules:"ExecutionLogPane",agent:"AgentSettingsPane",timer:"TimerPane",todo:"TodoPane",skills:"WorktreeSkillsPane"},fk=(0,h.memo)(function({active:a,activities:b,className:c=""}){if(null===a)return(0,e.jsx)("div",{id:fi,"data-testid":"activity-pane","data-active":"none",className:`h-full flex flex-col ${c}`.trim()});let d=b[a],f=fj[a];return(0,e.jsx)("div",{id:fi,"data-testid":"activity-pane","data-active":a,role:"tabpanel","aria-labelledby":`activity-bar-button-${a}`,className:`h-full flex flex-col min-h-0 ${c}`.trim(),children:(0,e.jsx)(F,{componentName:f,children:d??null})})}),fl=(0,h.memo)(function({inputRef:a,searchQuery:b,onQueryChange:c,matchCount:d,currentIdx:f,onNextMatch:g,onPrevMatch:h,onClose:i}){let j=(0,k.c)("worktree");return(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border-b border-input flex-shrink-0",children:[(0,e.jsx)("input",{ref:a,type:"text",value:b,onChange:a=>c(a.target.value),onKeyDown:a=>{"Escape"===a.key&&i(),"Enter"===a.key&&(a.shiftKey?h():g())},placeholder:j("fileSearch.placeholder"),className:"flex-1 min-w-0 px-2 py-0.5 text-sm bg-surface dark:text-foreground border border-input rounded outline-none focus:ring-1 focus:ring-ring",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground min-w-[3rem] text-right",children:d>0?`${f+1}/${d}`:"0/0"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:h,disabled:0===d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":j("fileSearch.prevMatch"),children:"▲"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:g,disabled:0===d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":j("fileSearch.nextMatch"),children:"▼"}),(0,e.jsx)(n.$n,{variant:"ghost",type:"button",onClick:i,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white","aria-label":j("fileSearch.close"),children:(0,e.jsx)(az.A,{className:"w-4 h-4"})})]})}),fm=[{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"]}],fn=fm.map(a=>a.extension),fo=[".md",".html",".htm",".yaml",".yml"];var fp=c(79689);function fq(){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 fr=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/HtmlPreview"]},ssr:!1,loading:()=>(0,e.jsx)(fq,{})}),fs=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/PdfPreview"]},ssr:!1,loading:()=>(0,e.jsx)(fq,{})}),ft=(0,j.default)(async()=>{},{loadableGenerated:{modules:["components/worktree/FilePanelContent.tsx -> @/components/worktree/MarkdownEditor"]},ssr:!1,loading:()=>(0,e.jsx)(fq,{})}),fu=/^---\s*\nmarp:\s*true/;function fv(){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 fw({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 fx({filePath:a,isMaximized:b,onToggleMaximize:c,copyableContent:d,onSearch:f}){let g=(0,k.c)("worktree"),[i,j]=(0,h.useState)(!1),[l,m]=(0,h.useState)(!1),n=(0,h.useRef)(null),o=(0,h.useRef)(null),p=async()=>{try{await (0,ay.l)(a),j(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>j(!1),ah.pX)}catch{}},q=async()=>{if(d)try{await (0,ay.l)(d),m(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>m(!1),ah.pX)}catch{}};return(0,e.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border gap-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("button",{type:"button",onClick:p,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.copyFilePath"),title:g("actions.copyPath"),children:i?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(at,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",title:a,children:a})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[f&&(0,e.jsx)("button",{type:"button",onClick:f,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.searchInFile"),title:g("actions.search"),children:(0,e.jsx)(Q.A,{className:"w-3.5 h-3.5"})}),d&&(0,e.jsx)("button",{type:"button",onClick:q,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g("actions.copyFileContent"),title:g("actions.copyContent"),children:l?(0,e.jsx)(ar.A,{className:"w-3.5 h-3.5 text-success"}):(0,e.jsx)(as,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{type:"button",onClick:c,className:"flex-shrink-0 p-1.5 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":g(b?"actions.minimize":"actions.maximize"),title:g(b?"actions.minimize":"actions.maximize"),children:b?(0,e.jsx)(aA,{className:"w-4 h-4"}):(0,e.jsx)(aB,{className:"w-4 h-4"})})]})]})}function fy({content:a,extension:b,searchMatches:c,searchCurrentIdx:d,totalLines:f,rangeStart:g,worktreeId:i,filePath:j,onLineRangeFetched:k}){let l=(0,h.useRef)(null),m=(0,h.useMemo)(()=>a.split("\n"),[a]),n=Math.max(1,g??1),o=m.length,p=Math.max(f??o,o),q=(0,h.useRef)(new Map),r=(0,h.useCallback)(a=>{let c=Math.floor(a/500),d=q.current,e=d.get(c);if(!e){let a=500*c,f=Math.min(a+500,m.length),g=m.slice(a,f).join("\n"),h="";try{h=aO.highlight(g,{language:b,ignoreIllegals:!0}).value}catch{h=aO.highlightAuto(g).value}e=h.split("\n"),d.set(c,e)}return e[a-500*c]??""},[m,b]),s=(0,h.useMemo)(()=>new Set(c??[]),[c]),t=(c?.length??0)>0?c[d??0]:-1,u=bX({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)(fp.E,{className:"h-4 w-3/4"})})]},a.key)})})})}function fz({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 fA({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)(fx,{filePath:d,isMaximized:i,onToggleMaximize:j,copyableContent:f})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:"slides"===o?(0,e.jsx)(fz,{slides:a,fileName:b}):(0,e.jsx)(ft,{worktreeId:c,filePath:d,onSave:g,initialViewMode:"split",onDirtyChange:l,onOpenFile:m})})]})}function fB({children:a,isMaximized:b,onToggle:c,filePath:d}){return b?(0,e.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:aE.M.MAXIMIZED_EDITOR},children:[(0,e.jsx)(fx,{filePath:d,isMaximized:b,onToggleMaximize:c}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:a})]}):(0,e.jsx)(e.Fragment,{children:a})}function fC({tab:a,content:b,worktreeId:c,isMaximized:d,onToggleMaximize:f,onFileSaved:g,onDirtyChange:h,onOpenFile:i}){let j=aN(b.content);return(0,e.jsxs)(e.Fragment,{children:[!d&&(0,e.jsx)(fx,{filePath:a.path,isMaximized:d,onToggleMaximize:f,copyableContent:b.content,onSearch:j.openSearch}),j.searchOpen&&(0,e.jsx)(fl,{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)(fy,{content:b.content,extension:"md",searchMatches:j.searchMatches,searchCurrentIdx:j.searchCurrentIdx}):(0,e.jsx)(ft,{worktreeId:c,filePath:a.path,onSave:g,initialViewMode:"preview",onDirtyChange:h,onOpenFile:i})})]})}function fD({tab:a,content:b,worktreeId:c,isMaximized:d,onToggleMaximize:f,onLoadContent:g}){let i=aN(b.content),j=(0,h.useCallback)(c=>{g&&g(a.path,{...b,content:c.content,totalLines:c.totalLines,totalBytes:c.totalBytes??b.totalBytes,range:c.range})},[g,a.path,b]),k=void 0!==b.range&&(b.totalLines??0)>b.range.end-b.range.start+1;return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fx,{filePath:a.path,isMaximized:d,onToggleMaximize:f,copyableContent:b.content,onSearch:i.openSearch}),i.searchOpen&&(0,e.jsx)(fl,{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)(fy,{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 fE=(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,c_({intervalMs:5e3,enabled:function(a){if(null===a.content||a.loading||a.isDirty||a.content.isPdf)return!1;let{totalBytes:b}=a.content;return void 0===b||!(b>=1048576)}(a),onPoll:async()=>{let a=`/api/worktrees/${b}/files/${(0,aF.o)(f.current)}`,c={};d.current&&(c["If-Modified-Since"]=d.current);try{let b=await fetch(a,{headers:c});if(304===b.status||!b.ok)return;d.current=b.headers.get("Last-Modified");let g=await b.json();e.current(f.current,g)}catch{}}})}({tab:a,worktreeId:b,onLoadContent:c});let s=(0,h.useMemo)(()=>i?b=>i(a.path,b):void 0,[i,a.path]),t=(0,h.useCallback)(()=>{r(a=>!a)},[]);(0,h.useEffect)(()=>{if(!q)return;let a=a=>{"Escape"===a.key&&r(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[q]),(0,h.useEffect)(()=>{null!==a.content||a.loading||null!==a.error||n.current||(n.current=!0,f(a.path,!0),(async()=>{try{let e=await fetch(`/api/worktrees/${b}/files/${(0,aF.o)(a.path)}`);if(304===e.status)return;if(!e.ok){let b=await e.json(),c="string"==typeof b.error?b.error:b.error?.message||m.current("fileViewer.loadError");d(a.path,c);return}let f=await e.json();c(a.path,f)}catch(b){d(a.path,b instanceof Error?b.message:m.current("fileViewer.loadError"))}finally{n.current=!1}})())},[a.content,a.loading,a.error,a.path,b,c,d,f]);let u=a.content?.content??null,v=a.content?.extension??null;if((0,h.useEffect)(()=>{if(!u||"md"!==v||!fu.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)(fv,{});if(a.error)return(0,e.jsx)(fw,{error:a.error});if(!a.content)return null;let{content:w}=a;return w.isImage?(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fx,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsx)(an.a,{src:w.content,alt:w.path,mimeType:w.mimeType})})]})}):w.isVideo?(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fx,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsx)(ao.u,{src:w.content,mimeType:w.mimeType})})]})}):w.isPdf?(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fx,{filePath:a.path,isMaximized:q,onToggleMaximize:t}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(fs,{dataUri:w.content,filePath:a.path})})]})}):w.isHtml?(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(fx,{filePath:a.path,isMaximized:q,onToggleMaximize:t,copyableContent:w.content}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(fr,{worktreeId:b,filePath:a.path,htmlContent:w.content,onFileSaved:g,onOpenFile:j})})]})}):"md"===w.extension?(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)("div",{className:"h-full flex flex-col",children:o?(0,e.jsx)(fA,{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)(fC,{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 fo.includes(b)}("."+w.extension)?(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)(fD,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onLoadContent:c})}):(0,e.jsx)(fB,{isMaximized:q,onToggle:t,filePath:a.path,children:(0,e.jsx)("div",{className:"h-full flex flex-col",children:(0,e.jsx)(fC,{tab:a,content:w,worktreeId:b,isMaximized:q,onToggleMaximize:t,onFileSaved:g,onDirtyChange:s,onOpenFile:j})})})});function fF(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 fG=(0,h.memo)(function({tab:a,isActive:b,onActivate:c,onClose:d}){let f=(0,k.c)("worktree"),g=(0,h.useCallback)(()=>{b||c(a.path)},[b,c,a.path]),i=(0,h.useCallback)(b=>{b.stopPropagation(),d(a.path)},[d,a.path]),j=b?"border-accent-500 text-accent-600 dark:text-accent-400 bg-surface":"border-transparent text-muted-foreground hover:text-foreground";return(0,e.jsxs)("div",{"data-testid":`file-tab-${a.path}`,"data-active":b,onClick:g,className:`flex items-center gap-1 px-3 py-2 text-sm font-medium border-b-2 cursor-pointer flex-shrink-0 ${j}`,children:[(0,e.jsx)("span",{className:"truncate max-w-[120px]",title:a.path,children:a.name}),a.isDirty&&(0,e.jsx)("span",{"data-testid":`file-tab-dirty-${a.path}`,className:"w-2 h-2 rounded-full bg-warning flex-shrink-0",title:f("fileTabs.unsavedChanges")}),(0,e.jsx)("button",{type:"button",onClick:i,className:"ml-1 p-0.5 rounded-sm hover:bg-muted transition-colors","aria-label":f("fileTabs.closeTab",{name:a.name}),children:(0,e.jsx)(az.A,{className:"w-3 h-3"})})]})}),fH=(0,h.memo)(function({tabs:a,activeIndex:b,worktreeId:c,onClose:d,onActivate:f,onLoadContent:g,onLoadError:i,onSetLoading:j,onFileSaved:k,onDirtyChange:l,onMoveToFront:m,onOpenFile:n}){let[o,p]=(0,h.useState)(!1),q=(0,h.useRef)(null),r=(0,h.useRef)(null),s=(0,h.useRef)({x:0,y:0}),[t,u]=(0,h.useState)({x:0,y:0}),v=null!==b&&b>=0&&b<a.length?a[b]:null,w=a.length>5?a.slice(0,5):a,x=a.length>5?a.slice(5):[];(0,h.useEffect)(()=>{if(!o)return;let a=a=>{q.current&&!q.current.contains(a.target)&&p(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[o]),(0,h.useLayoutEffect)(()=>{let a=a=>{s.current=a,u(b=>b.x===a.x&&b.y===a.y?b:a)};if(!o)return void a({x:0,y:0});let b=r.current;if(!b)return;let c=b.getBoundingClientRect();a({x:fF(c.left-s.current.x,c.width,window.innerWidth),y:fF(c.top-s.current.y,c.height,window.innerHeight)})},[o]);let y=(0,h.useCallback)(a=>{p(!1),m?.(a)},[m]),z=(0,h.useCallback)(()=>{p(a=>!a)},[]);return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex border-b border-border bg-surface dark:bg-surface-2 min-w-0",children:[(0,e.jsx)("div",{className:"flex min-w-0 overflow-hidden flex-1",children:w.map((a,c)=>(0,e.jsx)(fG,{tab:a,isActive:c===b,onActivate:f,onClose:d},a.path))}),x.length>0&&(0,e.jsxs)("div",{className:"relative flex-shrink-0",ref:q,children:[(0,e.jsxs)("button",{type:"button","data-testid":"tab-dropdown-button",onClick:z,className:"flex items-center gap-0.5 px-2 py-2 text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-muted border-b-2 border-transparent transition-colors",children:[(0,e.jsx)(bf.A,{className:`w-3 h-3 transition-transform ${o?"rotate-180":""}`}),(0,e.jsxs)("span",{children:["+",x.length]})]}),o&&(0,e.jsx)("div",{ref:r,"data-testid":"tab-dropdown-menu",className:"absolute right-0 top-full mt-1 bg-surface border border-border rounded-md shadow-lg z-50 min-w-[200px] max-h-[300px] overflow-y-auto",style:0!==t.x||0!==t.y?{transform:`translate(${t.x}px, ${t.y}px)`}:void 0,children:x.map(a=>(0,e.jsxs)("button",{type:"button","data-testid":`tab-dropdown-item-${a.path}`,onClick:()=>y(a.path),className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-muted truncate",title:a.path,children:[a.name,a.isDirty&&(0,e.jsx)("span",{className:"ml-1 w-2 h-2 inline-block rounded-full bg-warning"})]},a.path))})]})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:v&&(0,e.jsx)(fE,{tab:v,worktreeId:c,onLoadContent:g,onLoadError:i,onSetLoading:j,onFileSaved:k,onDirtyChange:l,onOpenFile:n},v.path)})]})}),fI=(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})}),fJ=(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)(fI,{line:a},b))})})})]})});function fK(){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 fL=(0,h.memo)(function({terminal:a,terminalHeader:b,fileTabs:c,worktreeId:d,onCloseTab:f,onActivateTab:g,onLoadContent:i,onLoadError:j,onSetLoading:l,onFileSaved:m,diffContent:n,diffFilePath:o,onCloseDiff:p,onDirtyChange:q,onMoveToFront:r,onOpenFile:s}){let t=(0,k.c)("worktree"),u=(0,h.useRef)(null),[v,w]=(0,h.useState)(50),{collapsed:x,toggle:y}=fK(),z=(0,h.useCallback)(a=>{let b=u.current;if(!b)return;let c=b.offsetWidth;if(0===c)return;let d=a/c*100;w(a=>Math.min(80,Math.max(20,a+d)))},[]),A=(0,h.useMemo)(()=>({width:`${v}%`}),[v]),B=(0,h.useMemo)(()=>({width:`${100-v}%`}),[v]),C=(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[b,(0,e.jsx)("div",{className:"flex-1 min-h-0",children:a})]});return c.tabs.length>0||n&&o?x?(0,e.jsxs)("div",{ref:u,className:"flex h-full min-h-0",children:[(0,e.jsx)("div",{"data-testid":"terminal-pane",style:{width:"calc(100% - 36px)"},className:"flex-shrink-0 overflow-hidden",children:C}),(0,e.jsx)("div",{"data-testid":"file-panel-expand-bar",style:{width:"36px"},className:"flex-shrink-0 flex items-start justify-center bg-muted border-l border-border",children:(0,e.jsxs)("button",{type:"button","aria-label":t("terminal.showFiles"),title:t("terminal.showFiles"),onClick:y,className:"flex flex-col items-center gap-2 w-full pt-2 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,e.jsx)("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),(0,e.jsx)("span",{className:"text-xs font-medium tracking-wide select-none",style:{writingMode:"vertical-rl"},"aria-hidden":"true",children:t("terminal.filesLabel")})]})})]}):(0,e.jsxs)("div",{ref:u,className:"flex h-full min-h-0",children:[(0,e.jsx)("div",{"data-testid":"terminal-pane",style:A,className:"flex-shrink-0 overflow-hidden",children:C}),(0,e.jsx)(cw,{onResize:z,orientation:"horizontal",ariaValueNow:v}),(0,e.jsxs)("div",{"data-testid":"file-panel-pane",style:B,className:"flex-grow overflow-hidden flex",children:[(0,e.jsx)("button",{type:"button","aria-label":t("terminal.hideFiles"),title:t("terminal.hideFiles"),onClick:y,className:"flex-shrink-0 flex items-center justify-center w-5 h-full bg-muted border-r border-border text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),(0,e.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:n&&o&&p?(0,e.jsx)(fJ,{diff:n,filePath:o,onClose:p}):(0,e.jsx)(fH,{tabs:c.tabs,activeIndex:c.activeIndex,worktreeId:d,onClose:f,onActivate:g,onLoadContent:i,onLoadError:j,onSetLoading:l,onFileSaved:m,onDirtyChange:q,onMoveToFront:r,onOpenFile:s})})]})]}):(0,e.jsx)("div",{className:"h-full",children:C})});var fM=c(51881);let fN=(0,x.A)("align-horizontal-distribute-center",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]]),fO=(0,x.A)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),fP=(0,x.A)("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),fQ={splits:[{cliToolId:"claude",instanceId:"claude"}],widths:[1]};be.XH;function fR(a){let b=a.reduce((a,b)=>a+b,0);return b>0?a.map(a=>a/b):a.map(()=>1/a.length)}let fS=(0,h.memo)(function({worktreeId:a,instances:b,rosterReady:c=!0,renderPane:d,onFocusedSplitChange:f,showToast:g,onActiveInstanceChange:j,headerInstanceSelection:l}){let{splits:m,widths:n,addSplit:o,removeSplit:p,setSplitInstance:q,setSplitWidth:r,resetWidths:s,availableInstanceIds:t,focusedSplitIndex:u,setFocusedSplitIndex:v}=function(a,b,c=!0){let[d,e]=(0,h.useState)(()=>(function(a,b,c){let d=function(a,b){let c=b[0];return c?{splits:[{cliToolId:c.cliTool,instanceId:c.id}],widths:[1]}:{splits:fQ.splits.map(a=>({...a})),widths:[...fQ.widths]}}(0,b);return c?function(a,b){let c;if(0===b.length)return a;let d=new Map(b.map(a=>[a.id,a.cliTool])),e=new Set,f=Math.min(Math.max(a.splits.length,1),b.length,3),g=[];for(let b of a.splits){if(g.length>=f)break;let a=d.get(b.instanceId);a&&!e.has(b.instanceId)&&(e.add(b.instanceId),g.push({cliToolId:a,instanceId:b.instanceId}))}for(let a of b){if(g.length>=f)break;e.has(a.id)||(e.add(a.id),g.push({cliToolId:a.cliTool,instanceId:a.id}))}return(0===g.length&&g.push({cliToolId:b[0].cliTool,instanceId:b[0].id}),g.length===a.splits.length&&g.every((b,c)=>b.instanceId===a.splits[c].instanceId&&b.cliToolId===a.splits[c].cliToolId))?a:(c=g.length===a.widths.length?fR(a.widths):g.length<a.widths.length?fR(a.widths.slice(0,g.length)):Array.from({length:g.length},()=>1/g.length),{splits:g,widths:c})}(d,b):d})(0,b,c)),[f,g]=(0,h.useState)(0),i=(0,h.useRef)(d);i.current=d;let j=(0,h.useRef)(b);j.current=b,(0,h.useRef)(c).current=c,(0,h.useRef)(a),(0,h.useMemo)(()=>b.map(a=>`${a.id}:${a.cliTool}`).join("|"),[b]),(0,h.useRef)(a);let k=(0,h.useCallback)(()=>{e(a=>{if(a.splits.length>=3)return a;let b=new Set(a.splits.map(a=>a.instanceId)),c=function(a,b){for(let c of a)if(!b.has(c.id))return c;return null}(j.current,b);if(!c)return a;let d=a.widths.length-1,e=a.widths[d]/2,f=[...a.widths];return f[d]=e,f.push(e),{splits:[...a.splits,{cliToolId:c.cliTool,instanceId:c.id}],widths:f}})},[]),l=(0,h.useCallback)(()=>{e(a=>a.splits.length<=1?a:{splits:a.splits.slice(0,-1),widths:fR(a.widths.slice(0,-1))})},[]),m=(0,h.useCallback)((a,b)=>{let c=i.current,d=j.current;if(a<0||a>=c.splits.length)return!1;let f=d.find(a=>a.id===b);if(!f||c.splits[a].instanceId===b)return!1;for(let d=0;d<c.splits.length;d++)if(d!==a&&c.splits[d].instanceId===b)return!1;return e(c=>{if(a<0||a>=c.splits.length||c.splits[a].instanceId===b)return c;for(let d=0;d<c.splits.length;d++)if(d!==a&&c.splits[d].instanceId===b)return c;let d=c.splits.map((c,d)=>d===a?{cliToolId:f.cliTool,instanceId:b}:c);return{...c,splits:d}}),!0},[]),n=(0,h.useCallback)(a=>{e(b=>a.length!==b.widths.length||!function(a){if(!Array.isArray(a))return!1;for(let b of a)if("number"!=typeof b||!Number.isFinite(b)||b<=0)return!1;return!0}(a)?b:{...b,widths:[...a]})},[]),o=(0,h.useCallback)(()=>{e(a=>{let b=a.splits.length;return 0===b?a:{...a,widths:Array.from({length:b},()=>1/b)}})},[]),p=(0,h.useCallback)(a=>{let c=new Set;for(let b=0;b<d.splits.length;b++)b!==a&&c.add(d.splits[b].instanceId);return b.filter(a=>!c.has(a.id)).map(a=>a.id)},[d.splits,b]),q=(0,h.useCallback)(a=>{g(a)},[]);return{splits:d.splits,widths:d.widths,addSplit:k,removeSplit:l,setSplitInstance:m,setSplitWidth:n,resetWidths:o,availableInstanceIds:p,focusedSplitIndex:f,setFocusedSplitIndex:q}}(a,b,c),w=(0,h.useMemo)(()=>{let a=new Map;for(let c of b)a.set(c.id,c);return a},[b]),x=(0,k.c)("worktree"),{visible:y,toggle:z,setWidth:A}=cr(),{collapsed:B,toggle:C}=fK(),D=!B,E=(0,h.useRef)(null),[F,G]=(0,h.useState)(!1),H=(0,h.useRef)(m.length),[I,J]=(0,h.useState)(null);(0,h.useEffect)(()=>{m.length>H.current&&J(m.length-1),H.current=m.length},[m.length]),(0,h.useEffect)(()=>{f?.(u)},[u,f]);let K=(0,h.useRef)(0),L=(0,h.useRef)(m);L.current=m,(0,h.useEffect)(()=>{if(!l||l.token===K.current)return;K.current=l.token;let{instanceId:a}=l,b=L.current.findIndex(b=>b.instanceId===a);if(0!==b){if(b>0)return void v(b);q(0,a)&&v(0)}},[l,q,v]),(0,h.useEffect)(()=>{if(null===I)return;let a=E.current;if(!a)return;let b=a.querySelector(`[data-split-index="${I}"]`);if(!b)return;let c=b.querySelector("textarea");c?.focus(),v(I),J(null)},[I,v]);let M=(0,h.useCallback)((a,b)=>{let c=E.current;if(!c)return;let d=c.offsetWidth;if(0===d)return;let e=n.reduce((a,b)=>a+b,0),f=b/d*e,g=[...n],h=g[a]+f,i=g[a+1]-f,j=.05*e;h<j||i<j||(g[a]=h,g[a+1]=i,r(g))},[n,r]),N=(0,h.useCallback)(()=>G(!0),[]),O=(0,h.useCallback)(()=>G(!1),[]),P=(0,h.useCallback)(()=>{s(),A(40)},[s,A]),Q=m.length<3&&!F,R=m.length>1&&!F,S=m.length>1||y,T=(0,h.useMemo)(()=>m.map((a,b)=>()=>v(b)),[m,v]),U=(0,h.useMemo)(()=>m.map((a,b)=>a=>q(b,a)),[m,q]),V=(0,h.useMemo)(()=>m.map((a,b)=>a=>{let c=(0,be.sw)(w.get(a)??{cliTool:"claude",alias:a});if(m[b]?.instanceId===a)return;let d=m.findIndex((c,d)=>d!==b&&c.instanceId===a);if(-1!==d)return void g?.(`${c} is already in use by split ${d+1}`,"warning");q(b,a)&&(j?.(a),g?.(`Moved ${c} to Split ${b+1}`,"success"))}),[m,q,g,j,w]);return(0,e.jsxs)("div",{role:"group","aria-label":"Terminal splits","data-testid":"terminal-split-container",className:"flex flex-col h-full min-h-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-surface border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums mr-1",children:[m.length," / ",3," splits"]}),(0,e.jsx)("button",{type:"button",onClick:o,disabled:!Q,"aria-disabled":!Q,"aria-label":x("terminal.addSplit"),title:x("terminal.addSplit"),"data-testid":"add-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(dP,{className:"w-4 h-4","aria-hidden":"true"})}),(0,e.jsx)("button",{type:"button",onClick:p,disabled:!R,"aria-disabled":!R,"aria-label":x("terminal.removeSplit"),title:x("terminal.removeSplit"),"data-testid":"remove-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(fM.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,e.jsx)("button",{type:"button",onClick:P,disabled:!S,"aria-disabled":!S,"aria-label":x("terminal.equalizeWidthsHint"),title:x("terminal.equalizeWidthsHint"),"data-testid":"equalize-split-widths",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,e.jsx)(fN,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})}),(0,e.jsx)("div",{className:"ml-auto h-4 w-px bg-border","aria-hidden":"true"}),(0,e.jsxs)("button",{type:"button",onClick:z,"aria-pressed":y,"aria-label":x(y?"terminal.hideHistory":"terminal.showHistory"),title:x(y?"terminal.hideHistory":"terminal.showHistory"),"data-testid":"toggle-history-pane",className:`flex items-center gap-1 text-xs px-2 py-0.5 rounded border transition-colors ${y?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[(0,e.jsx)(fO,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:x("terminal.historyLabel")})]}),(0,e.jsxs)("button",{type:"button",onClick:C,"aria-pressed":D,"aria-label":x(D?"terminal.hideFiles":"terminal.showFiles"),title:x(D?"terminal.hideFiles":"terminal.showFiles"),"data-testid":"toggle-file-panel",className:`flex items-center gap-1 text-xs px-2 py-0.5 rounded border transition-colors ${D?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[(0,e.jsx)(fP,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:x("terminal.filesLabel")})]})]}),(0,e.jsx)("div",{ref:E,className:"flex flex-1 min-h-0 w-full",children:m.map((a,b)=>{let c=b===m.length-1;return(0,e.jsxs)(i().Fragment,{children:[(0,e.jsx)("div",{style:{flexGrow:n[b]??1,flexShrink:1,flexBasis:0,minWidth:0},className:"h-full",children:d({splitIndex:b,cliToolId:a.cliToolId,instanceId:a.instanceId,instance:w.get(a.instanceId),availableInstances:t(b).map(a=>w.get(a)).filter(a=>void 0!==a),onInstanceChange:U[b],onFocus:T[b],isFocused:u===b,onDropInstance:V[b]})}),c?null:(0,e.jsx)(fT,{resizerIdx:b,ariaValueNow:n.length?n[b]/n.reduce((a,b)=>a+b,0)*100:50,onResize:M,onStart:N,onEnd:O,onDoubleClick:s})]},`split-${b}`)})})]})});function fT({resizerIdx:a,ariaValueNow:b,onResize:c,onStart:d,onEnd:f,onDoubleClick:g}){let i=(0,h.useCallback)(b=>c(a,b),[a,c]);return(0,e.jsx)("div",{"data-testid":`split-resizer-${a}`,onMouseDownCapture:d,onTouchStartCapture:d,onMouseUpCapture:f,onTouchEndCapture:f,children:(0,e.jsx)(cw,{onResize:i,orientation:"horizontal",ariaValueNow:b,onDoubleClick:g})})}let fU=`
35
35
  px-6 py-2 rounded-lg font-medium transition-all
36
36
  disabled:opacity-50 disabled:cursor-not-allowed
37
37
  focus:outline-none focus:ring-2 focus:ring-offset-2