commandmate 0.3.5 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +19 -23
  3. package/.next/app-path-routes-manifest.json +1 -1
  4. package/.next/build-manifest.json +5 -5
  5. package/.next/cache/.tsbuildinfo +1 -1
  6. package/.next/cache/config.json +3 -3
  7. package/.next/cache/webpack/client-production/0.pack +0 -0
  8. package/.next/cache/webpack/client-production/1.pack +0 -0
  9. package/.next/cache/webpack/client-production/2.pack +0 -0
  10. package/.next/cache/webpack/client-production/index.pack +0 -0
  11. package/.next/cache/webpack/client-production/index.pack.old +0 -0
  12. package/.next/cache/webpack/edge-server-production/0.pack +0 -0
  13. package/.next/cache/webpack/edge-server-production/index.pack +0 -0
  14. package/.next/cache/webpack/server-production/0.pack +0 -0
  15. package/.next/cache/webpack/server-production/index.pack +0 -0
  16. package/.next/next-server.js.nft.json +1 -1
  17. package/.next/prerender-manifest.json +1 -1
  18. package/.next/react-loadable-manifest.json +69 -55
  19. package/.next/required-server-files.json +1 -1
  20. package/.next/server/app/_not-found/page.js +1 -1
  21. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  22. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  23. package/.next/server/app/api/app/update-check/route.js +1 -1
  24. package/.next/server/app/api/repositories/clone/route.js +1 -1
  25. package/.next/server/app/api/repositories/route.js +8 -8
  26. package/.next/server/app/api/repositories/scan/route.js +1 -1
  27. package/.next/server/app/api/worktrees/[id]/capture/route.js +1 -2
  28. package/.next/server/app/api/worktrees/[id]/capture/route.js.nft.json +1 -1
  29. package/.next/server/app/api/worktrees/[id]/current-output/route.js +1 -1
  30. package/.next/server/app/api/worktrees/[id]/files/[...path]/route.js +1 -1
  31. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js +1 -1
  32. package/.next/server/app/api/worktrees/[id]/respond/route.js +1 -1
  33. package/.next/server/app/api/worktrees/[id]/route.js +1 -1
  34. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js +1 -1
  35. package/.next/server/app/api/worktrees/[id]/schedules/route.js +2 -2
  36. package/.next/server/app/api/worktrees/[id]/search/route.js +1 -1
  37. package/.next/server/app/api/worktrees/[id]/terminal/route.js +1 -1
  38. package/.next/server/app/api/worktrees/[id]/terminal/route.js.nft.json +1 -1
  39. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route.js +1 -1
  40. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route.js +1 -1
  41. package/.next/server/app/api/worktrees/route.js +1 -1
  42. package/.next/server/app/login/page.js +1 -1
  43. package/.next/server/app/login/page.js.nft.json +1 -1
  44. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  45. package/.next/server/app/page.js +3 -3
  46. package/.next/server/app/page.js.nft.json +1 -1
  47. package/.next/server/app/page_client-reference-manifest.js +1 -1
  48. package/.next/server/app/proxy/[...path]/route.js +4 -4
  49. package/.next/server/app/worktrees/[id]/files/[...path]/page.js +1 -1
  50. package/.next/server/app/worktrees/[id]/files/[...path]/page.js.nft.json +1 -1
  51. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
  52. package/.next/server/app/worktrees/[id]/page.js +6 -6
  53. package/.next/server/app/worktrees/[id]/page.js.nft.json +1 -1
  54. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
  55. package/.next/server/app/worktrees/[id]/terminal/page.js +2 -4
  56. package/.next/server/app/worktrees/[id]/terminal/page.js.nft.json +1 -1
  57. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
  58. package/.next/server/app-paths-manifest.json +8 -8
  59. package/.next/server/chunks/{3294.js → 1628.js} +3 -3
  60. package/.next/server/chunks/185.js +36 -0
  61. package/.next/server/chunks/3860.js +1 -1
  62. package/.next/server/chunks/4893.js +2 -2
  63. package/.next/server/chunks/4952.js +1 -1
  64. package/.next/server/chunks/5488.js +6 -6
  65. package/.next/server/chunks/7425.js +34 -31
  66. package/.next/server/chunks/7566.js +2 -2
  67. package/.next/server/chunks/8199.js +1 -0
  68. package/.next/server/chunks/8585.js +1 -1
  69. package/.next/server/chunks/8693.js +1 -1
  70. package/.next/server/middleware-build-manifest.js +1 -1
  71. package/.next/server/middleware-manifest.json +5 -5
  72. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  73. package/.next/server/pages/500.html +1 -1
  74. package/.next/server/server-reference-manifest.json +1 -1
  75. package/.next/static/chunks/12-00c528d46a0a0a1d.js +1 -0
  76. package/.next/static/chunks/{13.feeafc7cc620f8c4.js → 13.b9521543496f4468.js} +1 -1
  77. package/.next/static/chunks/1334.bfedf44ee9fe2761.js +1 -0
  78. package/.next/static/chunks/143.eb6b4671490cd223.js +1 -0
  79. package/.next/static/chunks/{3574.7a94c27e6a496a56.js → 1442.74b5f4de9a4b4e1b.js} +1 -1
  80. package/.next/static/chunks/2083-b5bed0c77cc53281.js +1 -0
  81. package/.next/static/chunks/2725.eb2d236c8030711c.js +1 -0
  82. package/.next/static/chunks/3398-3d40a17387bd554b.js +1 -0
  83. package/.next/static/chunks/3516.3c576047408cae6b.js +1 -0
  84. package/.next/static/chunks/3559.422c6ca760b85750.js +1 -0
  85. package/.next/static/chunks/3956.52c5b9a0071a641d.js +1 -0
  86. package/.next/static/chunks/4012.32b576a4fa621774.js +1 -0
  87. package/.next/static/chunks/4212.e7ba1009bc1da62d.js +131 -0
  88. package/.next/static/chunks/4303.caf91e86105d5e70.js +1 -0
  89. package/.next/static/chunks/4327.4dcda9b6fab6a385.js +82 -0
  90. package/.next/static/chunks/4671.d86d21d0dfdace41.js +1 -0
  91. package/.next/static/chunks/5518.ec88dcb5a27b17fe.js +1 -0
  92. package/.next/static/chunks/6434.08d262283371d333.js +1 -0
  93. package/.next/static/chunks/{656.5e2de0173f5a06bd.js → 656.dc26b973d07d9627.js} +5 -5
  94. package/.next/static/chunks/7119.01777af21b55740c.js +1 -0
  95. package/.next/static/chunks/7293.fb88bb102af4aa04.js +1 -0
  96. package/.next/static/chunks/8913-40625650292eb3d0.js +1 -0
  97. package/.next/static/chunks/8977.fc18b8260cd8bc1f.js +1 -0
  98. package/.next/static/chunks/9552.d959149efd41e84b.js +1 -0
  99. package/.next/static/chunks/app/layout-7198a7a49aa21a97.js +1 -0
  100. package/.next/static/chunks/app/page-7498cf75e69d9227.js +1 -0
  101. package/.next/static/chunks/app/worktrees/[id]/files/[...path]/page-0599f64a8e80d255.js +1 -0
  102. package/.next/static/chunks/app/worktrees/[id]/page-94ad7a1ce1f0c440.js +1 -0
  103. package/.next/static/chunks/app/worktrees/[id]/terminal/page-175b618c047bc992.js +1 -0
  104. package/.next/static/chunks/d3ac728e.daf595a898e9b720.js +1 -0
  105. package/.next/static/chunks/webpack-f7111aab807d73b9.js +1 -0
  106. package/.next/static/css/f7dc01350168df01.css +3 -0
  107. package/.next/trace +5 -5
  108. package/README.md +66 -56
  109. package/dist/server/server.js +5 -0
  110. package/dist/server/src/lib/auto-yes-manager.js +58 -18
  111. package/dist/server/src/lib/claude-session.js +9 -3
  112. package/dist/server/src/lib/cli-session.js +60 -10
  113. package/dist/server/src/lib/cli-tools/codex.js +7 -7
  114. package/dist/server/src/lib/cli-tools/gemini.js +3 -0
  115. package/dist/server/src/lib/cli-tools/opencode-config.js +179 -33
  116. package/dist/server/src/lib/cli-tools/opencode.js +5 -0
  117. package/dist/server/src/lib/cli-tools/vibe-local.js +3 -0
  118. package/dist/server/src/lib/cmate-parser.js +7 -7
  119. package/dist/server/src/lib/db-migrations.js +18 -1
  120. package/dist/server/src/lib/errors.js +153 -0
  121. package/dist/server/src/lib/prompt-answer-sender.js +3 -0
  122. package/dist/server/src/lib/prompt-detector.js +49 -7
  123. package/dist/server/src/lib/resource-cleanup.js +257 -0
  124. package/dist/server/src/lib/schedule-manager.js +269 -83
  125. package/dist/server/src/lib/tmux-capture-cache.js +221 -0
  126. package/dist/server/src/lib/tmux.js +41 -20
  127. package/dist/server/src/types/markdown-editor.js +9 -1
  128. package/package.json +11 -8
  129. package/.next/server/chunks/539.js +0 -35
  130. package/.next/server/chunks/7458.js +0 -1
  131. package/.next/server/chunks/7808.js +0 -1
  132. package/.next/static/chunks/1038-3509435b68c0967e.js +0 -1
  133. package/.next/static/chunks/1098.49268c9fe1b028fa.js +0 -1
  134. package/.next/static/chunks/2335-98a211e00b94c7ac.js +0 -1
  135. package/.next/static/chunks/3559.f073f72c4466ce0e.js +0 -1
  136. package/.next/static/chunks/3843.3fdda732987f7bb8.js +0 -1
  137. package/.next/static/chunks/4212.52c1bb34fc97d0d0.js +0 -131
  138. package/.next/static/chunks/4327.157a4c226d919531.js +0 -60
  139. package/.next/static/chunks/4362.7bd6f0282e49d79b.js +0 -1
  140. package/.next/static/chunks/4721.40615a5f4f32b5fb.js +0 -1
  141. package/.next/static/chunks/5112.17318d1c6b28044b.js +0 -1
  142. package/.next/static/chunks/6406.9653f0d41ab85059.js +0 -1
  143. package/.next/static/chunks/6792.3c01ac4dda4b5c6d.js +0 -1
  144. package/.next/static/chunks/8091-d65d2ab6daed23c6.js +0 -1
  145. package/.next/static/chunks/8125.245a9df052d274fb.js +0 -1
  146. package/.next/static/chunks/8522.1607e96011c66877.js +0 -1
  147. package/.next/static/chunks/8841.dadeb1ece8e46004.js +0 -1
  148. package/.next/static/chunks/8885.f8d9912b40d74811.js +0 -1
  149. package/.next/static/chunks/9178-88850a7c48deea07.js +0 -1
  150. package/.next/static/chunks/9552.b7dfb7903ead934b.js +0 -1
  151. package/.next/static/chunks/app/layout-9110f9a5e41c6bf4.js +0 -1
  152. package/.next/static/chunks/app/page-9e523a8f415bc707.js +0 -1
  153. package/.next/static/chunks/app/worktrees/[id]/files/[...path]/page-4a3c0861367e0391.js +0 -1
  154. package/.next/static/chunks/app/worktrees/[id]/page-8fb4dc30b58a5681.js +0 -1
  155. package/.next/static/chunks/app/worktrees/[id]/terminal/page-5d85a7e508ce36d3.js +0 -1
  156. package/.next/static/chunks/d3ac728e.6c9c508274d4d2d5.js +0 -1
  157. package/.next/static/chunks/webpack-81c97591dd5567ac.js +0 -1
  158. package/.next/static/css/45b3a41370668314.css +0 -3
  159. /package/.next/static/chunks/{30d07d85-393352a92199f695.js → 30d07d85.1dc99a921fc18e34.js} +0 -0
  160. /package/.next/static/{p3hosTZoJ22r35fWwUoLr → dwGMLEU53HOvFOWqiZOT0}/_buildManifest.js +0 -0
  161. /package/.next/static/{p3hosTZoJ22r35fWwUoLr → dwGMLEU53HOvFOWqiZOT0}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[130],{5635:function(e,t,a){Promise.resolve().then(a.bind(a,26514))},26514:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return tK}});var r=a(57437),s=a(99376),n=a(98704),l=a(2265),o=a(30166),i=a(51817);let c={output:"",realtimeSnippet:"",isActive:!1,isThinking:!1,autoScroll:!0,lastUpdated:null},d={data:null,messageId:null,visible:!1,answering:!1},u={mode:"split",mobileActivePane:"terminal",leftPaneTab:"history",splitRatio:.5},m={type:null,message:null,retryable:!1,retryCount:0};function x(){return{phase:"idle",terminal:{...c},prompt:{...d},layout:{...u},error:{...m},messages:[],wsConnected:!1}}function h(e,t){switch(t.type){case"SET_PHASE":return{...e,phase:t.phase};case"SET_TERMINAL_OUTPUT":return{...e,terminal:{...e.terminal,output:t.output,realtimeSnippet:t.realtimeSnippet,lastUpdated:new Date}};case"SET_TERMINAL_ACTIVE":return{...e,terminal:{...e.terminal,isActive:t.isActive}};case"SET_TERMINAL_THINKING":return{...e,terminal:{...e.terminal,isThinking:t.isThinking}};case"SET_AUTO_SCROLL":return{...e,terminal:{...e.terminal,autoScroll:t.enabled}};case"SHOW_PROMPT":return{...e,phase:"prompt",prompt:{data:t.data,messageId:t.messageId,visible:!0,answering:!1}};case"CLEAR_PROMPT":return{...e,prompt:{...d}};case"SET_PROMPT_ANSWERING":return{...e,prompt:{...e.prompt,answering:t.answering}};case"SET_LAYOUT_MODE":return{...e,layout:{...e.layout,mode:t.mode}};case"SET_MOBILE_ACTIVE_PANE":return{...e,layout:{...e.layout,mobileActivePane:t.pane}};case"SET_SPLIT_RATIO":return{...e,layout:{...e.layout,splitRatio:t.ratio}};case"SET_LEFT_PANE_TAB":return{...e,layout:{...e.layout,leftPaneTab:t.tab}};case"SET_ERROR":return{...e,error:t.error};case"CLEAR_ERROR":return{...e,error:{...m}};case"INCREMENT_RETRY_COUNT":return{...e,error:{...e.error,retryCount:e.error.retryCount+1}};case"SET_MESSAGES":return{...e,messages:t.messages};case"ADD_MESSAGE":return{...e,messages:[...e.messages,t.message]};case"UPDATE_MESSAGE":return{...e,messages:e.messages.map(e=>e.id===t.id?{...e,...t.updates}:e)};case"CLEAR_MESSAGES":return{...e,messages:[]};case"SET_WS_CONNECTED":return{...e,wsConnected:t.connected};case"START_WAITING_FOR_RESPONSE":return{...e,phase:"waiting",terminal:{...e.terminal,isActive:!0,output:"",realtimeSnippet:""},prompt:{...d}};case"RESPONSE_RECEIVED":return{...e,phase:"complete",messages:[...e.messages,t.message],terminal:{...e.terminal,isActive:!1,isThinking:!1}};case"SESSION_ENDED":return{...e,phase:"idle",terminal:{...c},prompt:{...d}};default:return e}}var g=a(58819),p=a(43241),y=a(38706);class b extends l.Component{static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){var a,r;console.error("[ErrorBoundary:".concat(this.props.componentName||"unknown","]"),e,t),null===(a=(r=this.props).onError)||void 0===a||a.call(r,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,r.jsx)(f,{componentName:this.props.componentName,error:this.state.error,onRetry:this.handleRetry}):this.props.children}constructor(e){super(e),this.handleRetry=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}}function f(e){let{componentName:t,error:a,onRetry:s}=e,n=(0,y.T)("error"),l=(0,y.T)("common");return(0,r.jsxs)("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-red-800 mb-2",children:[(0,r.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),(0,r.jsx)("span",{className:"font-medium",children:t?n("boundary.errorOccurredIn",{componentName:t}):n("boundary.errorOccurred")})]}),a&&(0,r.jsx)("p",{className:"text-sm text-red-600 mb-3",children:a.message}),s&&(0,r.jsx)("button",{onClick:s,className:"px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 transition-colors text-sm",children:l("retry")})]})}var k=a(37979);let v={left:"History",right:"Terminal"},j={left:"HistoryPane",right:"TerminalPane"},w=(0,l.memo)(function(e){let{pane:t,isActive:a,onClick:s}=e;return(0,r.jsx)("button",{type:"button",role:"tab","aria-selected":a,"aria-controls":"".concat(t,"-panel"),onClick:s,className:"".concat("flex-1 py-2 px-4 text-sm font-medium transition-colors"," ").concat(a?"text-blue-400 border-b-2 border-blue-400 bg-gray-900":"text-gray-400 hover:text-gray-300"),children:v[t]})}),N=(0,l.memo)(function(e){let{leftPane:t,rightPane:a}=e,[s,n]=(0,l.useState)("right"),o=(0,l.useCallback)(()=>n("left"),[]),i=(0,l.useCallback)(()=>n("right"),[]);return(0,r.jsxs)("div",{"data-testid":"mobile-layout",className:"flex flex-col h-full",children:[(0,r.jsxs)("div",{className:"flex border-b border-gray-700 bg-gray-800",role:"tablist",children:[(0,r.jsx)(w,{pane:"left",isActive:"left"===s,onClick:o}),(0,r.jsx)(w,{pane:"right",isActive:"right"===s,onClick:i})]}),(0,r.jsx)("div",{id:"".concat(s,"-panel"),role:"tabpanel",className:"flex-1 overflow-hidden",children:(0,r.jsx)(b,{componentName:j[s],children:"left"===s?t:a})})]})}),C=(0,l.memo)(function(e){let{leftPane:t,rightPane:a,leftWidth:s,onResize:n,className:o}=e,i=(0,l.useMemo)(()=>({width:"".concat(s,"%")}),[s]),c=(0,l.useMemo)(()=>({width:"".concat(100-s,"%")}),[s]),d=(0,l.useMemo)(()=>"flex h-full min-h-0 ".concat(o).trim(),[o]);return(0,r.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:d,children:[(0,r.jsx)("div",{"data-testid":"left-pane","aria-label":"History pane",style:i,className:"flex-shrink-0 overflow-hidden",children:(0,r.jsx)(b,{componentName:j.left,children:t})}),(0,r.jsx)(k.m,{onResize:n,orientation:"horizontal",ariaValueNow:s}),(0,r.jsx)("div",{"data-testid":"right-pane","aria-label":"Terminal pane",style:c,className:"flex-grow overflow-hidden",children:(0,r.jsx)(b,{componentName:j.right,children:a})})]})}),S=(0,l.memo)(function(e){let{leftPane:t,rightPane:a,initialLeftWidth:s=50,minLeftWidth:n=20,maxLeftWidth:o=80,className:i=""}=e,c=(0,g.d)(),d=(0,l.useRef)(null),[u,m]=(0,l.useState)(s),x=(0,l.useCallback)(e=>{let t=d.current;if(!t)return;let a=t.offsetWidth;if(0===a)return;let r=e/a*100;m(e=>Math.min(o,Math.max(n,e+r)))},[n,o]);return c?(0,r.jsx)(N,{leftPane:t,rightPane:a}):(0,r.jsx)("div",{ref:d,className:"h-full",children:(0,r.jsx)(C,{leftPane:t,rightPane:a,leftWidth:u,onResize:x,className:i})})});var T=a(47835),E=a.n(T),M=a(34343);let L=new(a.n(M)())({fg:"#d1d5db",bg:"#1f2937",newline:!0,escapeXML:!0});function R(){return(0,r.jsxs)("div",{"data-testid":"thinking-indicator",className:"flex items-center gap-2 py-2 px-1 text-gray-400",children:[(0,r.jsxs)("span",{className:"flex gap-1",children:[(0,r.jsx)("span",{className:"animate-pulse delay-0",children:"."}),(0,r.jsx)("span",{className:"animate-pulse delay-150",children:"."}),(0,r.jsx)("span",{className:"animate-pulse delay-300",children:"."})]}),(0,r.jsx)("span",{className:"text-sm",children:"Thinking"})]})}let A=(0,l.memo)(function(e){let{output:t,isActive:a,isThinking:s=!1,autoScroll:n=!0,onScrollChange:o,disableAutoFollow:i=!1,className:c=""}=e,{scrollRef:d,autoScroll:u,handleScroll:m,scrollToBottom:x,scrollToTop:h}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{initialAutoScroll:t=!0,onAutoScrollChange:a}=e,r=(0,l.useRef)(null),[s,n]=(0,l.useState)(t),o=(0,l.useRef)(!1),i=(0,l.useRef)(null);(0,l.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]);let c=(0,l.useCallback)(e=>{n(e),null==a||a(e)},[a]),d=(0,l.useCallback)(()=>{let e=r.current;if(!e)return!0;let{scrollTop:t,scrollHeight:a,clientHeight:s}=e;return a-s-t<=50},[]),u=(0,l.useCallback)(()=>{if(o.current)return;let e=d();e&&!s?c(!0):!e&&s&&c(!1)},[s,d,c]),m=(0,l.useCallback)(()=>{let e=r.current;e&&(o.current=!0,e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),s||c(!0),i.current=setTimeout(()=>{o.current=!1,i.current=null},500))},[s,c]),x=(0,l.useCallback)(()=>{let e=r.current;e&&(o.current=!0,e.scrollTo({top:0,behavior:"smooth"}),s&&c(!1),i.current=setTimeout(()=>{o.current=!1,i.current=null},500))},[s,c]);return{scrollRef:r,autoScroll:s,setAutoScroll:c,scrollToBottom:m,scrollToTop:x,handleScroll:u}}({initialAutoScroll:n,onAutoScrollChange:o}),g=function(e){let t=L.toHtml(e);return E().sanitize(t,{ALLOWED_TAGS:["span","br"],ALLOWED_ATTR:["style"],ALLOW_DATA_ATTR:!1})}(t||""),p=(0,l.useRef)(!1);(0,l.useEffect)(()=>{i&&(p.current=!0)},[i]),(0,l.useEffect)(()=>{if(d.current){if(p.current&&i&&g){d.current.scrollTo({top:0,behavior:"instant"}),p.current=!1;return}!i&&u&&d.current.scrollTo({top:d.current.scrollHeight,behavior:"instant"})}},[g,u,i,d]);let y=(0,l.useMemo)(()=>["terminal","font-mono","text-sm","p-4","rounded-lg","overflow-y-auto","overflow-x-hidden","bg-gray-900","text-gray-300","border","border-gray-700","h-full",a?"active":"",a?"border-blue-500":"",c].filter(Boolean).join(" "),[a,c]);return(0,r.jsxs)("div",{className:"relative h-full flex flex-col",children:[(0,r.jsxs)("div",{ref:d,role:"log","aria-live":"polite","aria-label":"Terminal output",className:y,onScroll:m,children:[(0,r.jsx)("div",{className:"whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:g}}),a&&s&&(0,r.jsx)(R,{})]}),u?(0,r.jsx)("button",{onClick:h,className:"absolute bottom-4 right-4 bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded-md text-sm shadow-lg transition-colors","aria-label":"Scroll to top",children:"Scroll to top"}):(0,r.jsx)("button",{onClick:x,className:"absolute bottom-4 right-4 bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded-md text-sm shadow-lg transition-colors","aria-label":"Scroll to bottom",children:"Scroll to bottom"})]})});var F=a(78867);let P=/(\/[^\s\n<>"']+\.[a-zA-Z0-9]+)/g;function D(e){let t=e.split("\n");if(t.length<=5&&e.length<=300)return{text:e,isTruncated:!1};let a=t.slice(0,5).join("\n");return a.length>300&&(a=a.slice(0,300)),{text:a,isTruncated:!0}}let O=(0,l.memo)(function(e){let{content:t,onFilePathClick:a}=e,s=(0,l.useMemo)(()=>(function(e){let t=e.match(P);if(!t||0===t.length)return[{type:"text",content:e}];let a=[],r=0;return t.forEach(t=>{let s=e.indexOf(t,r);s>r&&a.push({type:"text",content:e.slice(r,s)}),a.push({type:"path",content:t}),r=s+t.length}),r<e.length&&a.push({type:"text",content:e.slice(r)}),a})(t),[t]),n=(0,l.useCallback)(e=>()=>a(e),[a]);return(0,r.jsx)("span",{children:s.map((e,t)=>"path"===e.type?(0,r.jsx)("button",{type:"button",onClick:n(e.content),className:"text-blue-400 hover:text-blue-300 hover:underline cursor-pointer font-mono text-sm","aria-label":"Open file: ".concat(e.content),children:e.content},t):(0,r.jsx)("span",{children:e.content},t))})});function I(){return(0,r.jsxs)("div",{"data-testid":"pending-indicator",className:"flex items-center gap-2 text-gray-400 py-2",children:[(0,r.jsxs)("div",{className:"flex gap-1","aria-hidden":"true",children:[(0,r.jsx)("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse"}),(0,r.jsx)("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",style:{animationDelay:"150ms"}}),(0,r.jsx)("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",style:{animationDelay:"300ms"}})]}),(0,r.jsx)("span",{className:"text-sm",children:"Waiting for response..."})]})}let _=(0,l.memo)(function(e){let{message:t,onFilePathClick:a,onCopy:s}=e,n=(0,l.useMemo)(()=>t.timestamp.toLocaleTimeString(),[t.timestamp]);return(0,r.jsxs)("div",{className:"relative bg-blue-900/30 border-l-4 border-blue-500 p-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-blue-400",children:"You"}),(0,r.jsx)("span",{className:"text-xs text-gray-500",children:n})]}),(0,r.jsx)("div",{className:"text-sm text-gray-200 whitespace-pre-wrap break-words",children:(0,r.jsx)(O,{content:t.content,onFilePathClick:a})}),s&&(0,r.jsx)("button",{type:"button","data-testid":"copy-user-message",onClick:()=>s(t.content),className:"absolute top-2 right-2 p-1 text-gray-400 hover:text-gray-200 bg-gray-800/80 rounded transition-colors","aria-label":"Copy message",title:"Copy",children:(0,r.jsx)(F.Z,{size:14,"aria-hidden":"true"})})]})}),W=(0,l.memo)(function(e){let{message:t,index:a,total:s,isExpanded:n,onFilePathClick:o,onCopy:i}=e,c=(0,l.useMemo)(()=>t.timestamp.toLocaleTimeString(),[t.timestamp]),{text:d,isTruncated:u}=(0,l.useMemo)(()=>D(t.content),[t.content]),m=n||!u?t.content:d;return(0,r.jsxs)("div",{className:"assistant-message-item relative",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-gray-400",children:"Assistant"}),(0,r.jsx)("span",{className:"text-xs text-gray-500",children:c}),s>1&&(0,r.jsxs)("span",{className:"text-xs text-gray-500",children:["(",a+1,"/",s,")"]})]}),(0,r.jsxs)("div",{className:"text-sm text-gray-200 whitespace-pre-wrap break-words [word-break:break-word] max-w-full overflow-x-hidden",children:[(0,r.jsx)(O,{content:m,onFilePathClick:o}),!n&&u&&(0,r.jsx)("span",{className:"text-gray-500",children:"..."})]}),i&&(0,r.jsx)("button",{type:"button","data-testid":"copy-assistant-message",onClick:()=>i(t.content),className:"absolute top-2 right-2 p-1 text-gray-400 hover:text-gray-200 bg-gray-800/80 rounded transition-colors","aria-label":"Copy message",title:"Copy",children:(0,r.jsx)(F.Z,{size:14,"aria-hidden":"true"})})]})}),z=(0,l.memo)(function(e){let{messages:t,isExpanded:a,onFilePathClick:s,onCopy:n}=e;return(0,r.jsx)("div",{className:"bg-gray-800/50 border-l-4 border-gray-600 p-3 border-t border-gray-700 space-y-3",children:t.map((e,o)=>(0,r.jsxs)(l.Fragment,{children:[o>0&&(0,r.jsx)("div",{"data-testid":"assistant-message-divider",className:"border-t border-dashed border-gray-600"}),(0,r.jsx)(W,{message:e,index:o,total:t.length,isExpanded:a,onFilePathClick:s,onCopy:n})]},e.id))})});function B(){return(0,r.jsxs)("div",{"data-testid":"orphan-indicator",className:"bg-yellow-900/20 text-yellow-400 text-xs px-3 py-1 flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("span",{children:"System Message"})]})}let U=(0,l.memo)(function(e){let{pair:t,onFilePathClick:a,isExpanded:s=!1,onToggleExpand:n,onCopy:o}=e,i=(0,l.useMemo)(()=>t.assistantMessages.some(e=>{let{isTruncated:t}=D(e.content);return t}),[t.assistantMessages]),c=(0,l.useCallback)(()=>{n&&n()},[n]),d=(0,l.useMemo)(()=>{let e="pending"===t.status?"pending":"orphan"===t.status?"orphan border-l-4 border-yellow-600":"";return"".concat("border border-gray-700 rounded-lg overflow-hidden mb-4 transition-colors"," ").concat(e).trim()},[t.status]),u=(0,l.useMemo)(()=>{if(t.userMessage){let e=t.userMessage.content.substring(0,50);return"Conversation: ".concat(e).concat(t.userMessage.content.length>50?"...":"")}return"System message"},[t.userMessage]);return(0,r.jsxs)("div",{"data-testid":"conversation-pair-card",role:"article","aria-label":u,className:d,children:["orphan"===t.status&&(0,r.jsx)(B,{}),t.userMessage&&(0,r.jsx)(_,{message:t.userMessage,onFilePathClick:a,onCopy:o}),"pending"===t.status?(0,r.jsx)("div",{className:"bg-gray-800/30 border-l-4 border-gray-600 p-3 border-t border-gray-700",children:(0,r.jsx)(I,{})}):t.assistantMessages.length>0?(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(z,{messages:t.assistantMessages,isExpanded:s,onFilePathClick:a,onCopy:o}),i&&(0,r.jsx)("div",{className:"absolute top-2 right-2",children:(0,r.jsxs)("button",{type:"button",onClick:c,className:"text-xs text-blue-400 hover:text-blue-300 flex items-center gap-1 transition-colors bg-gray-800/80 px-2 py-1 rounded","aria-expanded":s,"aria-label":s?"Collapse message":"Expand message",children:[(0,r.jsx)("svg",{className:"w-3 h-3 transition-transform ".concat(s?"rotate-180":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),s?"Collapse":"Expand"]})})]}):null]})});var V=a(32636);function H(){return(0,r.jsxs)("div",{"data-testid":"loading-indicator",className:"flex items-center justify-center py-4",role:"status","aria-label":"Loading messages",children:[(0,r.jsxs)("div",{className:"flex gap-1","aria-hidden":"true",children:[(0,r.jsx)("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse"}),(0,r.jsx)("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse delay-100"}),(0,r.jsx)("span",{className:"w-2 h-2 bg-gray-400 rounded-full animate-pulse delay-200"})]}),(0,r.jsx)("span",{className:"ml-2 text-sm text-gray-400",children:"Loading..."})]})}function Y(){return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[(0,r.jsx)("svg",{className:"w-12 h-12 mb-2 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),(0,r.jsx)("p",{className:"text-sm",children:"No messages yet"})]})}let q=["h-full","flex","flex-col","overflow-y-auto","overflow-x-hidden","bg-gray-900","rounded-lg","border","border-gray-700"],Z=(0,l.memo)(function(e){let{messages:t,worktreeId:a,onFilePathClick:s,isLoading:n=!1,className:o="",showToast:i}=e,c=(0,l.useRef)(null),d=(0,l.useRef)(0),u=(0,l.useRef)(t.length);(0,l.useLayoutEffect)(()=>{let e=c.current;e&&(d.current=e.scrollTop)}),(0,l.useLayoutEffect)(()=>{let e=c.current,a=u.current;e&&t.length===a&&requestAnimationFrame(()=>{e.scrollTop=d.current}),u.current=t.length},[t.length]);let{pairs:m,isExpanded:x,toggleExpand:h}=function(e){let t=(0,l.useMemo)(()=>(function(e){if(0===e.length)return[];let t=[...e].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()),a=[],r=null;for(let e of t)if("user"===e.role)r={id:e.id,userMessage:e,assistantMessages:[],status:"pending"},a.push(r);else if("assistant"===e.role){if(r&&null!==r.userMessage)r.assistantMessages.push(e),r.status="completed";else if(r&&null===r.userMessage)r.assistantMessages.push(e);else{let t={id:"orphan-".concat(e.id),userMessage:null,assistantMessages:[e],status:"orphan"};a.push(t),r=t}}return a})(e),[e]),[a,r]=(0,l.useState)(new Set),s=(0,l.useCallback)(e=>{r(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),n=(0,l.useCallback)(e=>a.has(e),[a]),o=(0,l.useCallback)(()=>{r(new Set(t.map(e=>e.id)))},[t]);return{pairs:t,expandedPairs:a,toggleExpand:s,isExpanded:n,expandAll:o,collapseAll:(0,l.useCallback)(()=>{r(new Set)},[])}}(t),g=(0,l.useMemo)(()=>[...q,o].filter(Boolean).join(" "),[o]),p=(0,l.useCallback)(e=>s(e),[s]),y=(0,l.useCallback)(e=>()=>h(e),[h]),b=(0,l.useCallback)(async e=>{try{await (0,V.v)(e),null==i||i("Copied to clipboard","success")}catch(e){console.error("[HistoryPane] Failed to copy to clipboard"),null==i||i("Failed to copy","error")}},[i]);return(0,r.jsxs)("div",{ref:c,role:"region","aria-label":"Message history",className:g,children:[(0,r.jsx)("div",{className:"sticky top-0 bg-gray-900 border-b border-gray-700 px-4 py-2 z-10",children:(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-300",children:"Message History"})}),(0,r.jsx)("div",{className:"flex-1 p-4 min-h-0",children:n?(0,r.jsx)(H,{}):0===t.length?(0,r.jsx)(Y,{}):m.map(e=>(0,r.jsx)(U,{pair:e,onFilePathClick:p,isExpanded:x(e.id),onToggleExpand:y(e.id),onCopy:b},e.id))})]})}),G={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",none:""};function K(e){let{visible:t,duration:a=200}=e,[r,s]=(0,l.useState)(t?"visible":"hidden"),n=(0,l.useRef)(null),o=(0,l.useRef)(t);(0,l.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]),(0,l.useEffect)(()=>{let e=o.current;o.current=t,n.current&&(clearTimeout(n.current),n.current=null);let r=e=>{n.current=setTimeout(()=>{s(e),n.current=null},a)};t&&!e?(s("fade-in"),r("visible")):!t&&e?(s("fade-out"),r("hidden")):t?s(e=>"fade-out"===e?(r("visible"),"fade-in"):e):s(e=>"fade-in"===e?(r("hidden"),"fade-out"):e)},[t,a]);let i="hidden"!==r,c="fade-in"===r||"fade-out"===r;return{shouldRender:i,animationClass:(0,l.useMemo)(()=>{switch(r){case"fade-in":return G.fadeIn;case"fade-out":return G.fadeOut;default:return G.none}},[r]),isAnimating:c}}let Q="\n px-6 py-2 rounded-lg font-medium transition-all\n disabled:opacity-50 disabled:cursor-not-allowed\n focus:outline-none focus:ring-2 focus:ring-offset-2\n".trim(),J="bg-cyan-600 text-white hover:bg-cyan-700 focus:ring-cyan-500";function X(e){let{promptData:t,answering:a,onRespond:s,onDismiss:n,labelId:o,cliToolName:i}=e,c=(0,y.T)("prompt"),[d,u]=(0,l.useState)(()=>{if("multiple_choice"===t.type){var e;let a=t.options.find(e=>e.isDefault);return null!==(e=null==a?void 0:a.number)&&void 0!==e?e:null}return null}),[m,x]=(0,l.useState)(""),[h,g]=(0,l.useState)(!1),p=(0,l.useMemo)(()=>{var e;return"multiple_choice"!==t.type?null:null!==(e=t.options.find(e=>e.number===d))&&void 0!==e?e:null},[t,d]),b=(null==p?void 0:p.requiresTextInput)===!0,f=a||h,k=(0,l.useCallback)(async e=>{if(!f){g(!0);try{await s(e)}catch(e){}finally{g(!1)}}},[f,s]),v=(0,l.useCallback)(async()=>{if(!f&&null!==d){g(!0);try{let e=b&&m.trim()?m.trim():d.toString();await s(e)}catch(e){}finally{g(!1)}}},[f,s,d,b,m]);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("h3",{id:o,className:"text-lg font-semibold text-yellow-800 dark:text-yellow-300 flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xl","aria-hidden":"true",children:"?"}),i?c("confirmationFrom",{toolName:i}):c("confirmationFromClaude")]}),n&&(0,r.jsx)("button",{type:"button",onClick:n,"aria-label":"close",className:"p-1 rounded hover:bg-yellow-200 dark:hover:bg-gray-700 transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5 text-yellow-700 dark:text-yellow-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.instructionText&&(0,r.jsx)("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap text-sm text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-800 rounded p-2 border border-gray-200 dark:border-gray-700",children:t.instructionText}),(0,r.jsx)("p",{className:"text-gray-800 dark:text-gray-200 leading-relaxed",children:t.question}),f&&(0,r.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400",role:"status","aria-live":"polite",children:[(0,r.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-blue-600","aria-hidden":"true"}),(0,r.jsx)("span",{children:c("sending")})]}),"yes_no"===t.type&&(0,r.jsx)($,{promptData:t,disabled:f,onYes:()=>k("yes"),onNo:()=>k("no")}),"multiple_choice"===t.type&&(0,r.jsx)(ee,{promptData:t,disabled:f,selectedOption:d,onSelectOption:u,textInputValue:m,onTextInputChange:x,showTextInput:b,onSubmit:v})]})}function $(e){let{promptData:t,disabled:a,onYes:s,onNo:n}=e,l=(0,y.T)("prompt"),o="yes"===t.defaultOption,i="no"===t.defaultOption,c="".concat(Q," ").concat(J," ").concat(o?"primary default highlighted":""),d="".concat(Q," ").concat(i?"bg-gray-600 text-white hover:bg-gray-700 primary default highlighted":"bg-white dark:bg-gray-700 border-2 border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200 focus:ring-gray-500");return(0,r.jsxs)("div",{className:"flex items-center gap-3",role:"group","aria-label":"Yes or No options",children:[(0,r.jsx)("button",{type:"button",onClick:s,disabled:a,className:c,children:l("yes")}),(0,r.jsx)("button",{type:"button",onClick:n,disabled:a,className:d,children:l("no")})]})}function ee(e){let{promptData:t,disabled:a,selectedOption:s,onSelectOption:n,textInputValue:o,onTextInputChange:i,showTextInput:c,onSubmit:d}=e,u=(0,l.useId)(),m=(0,y.T)("prompt"),x=(0,l.useCallback)(e=>{let t=s===e,r=a?"opacity-50 cursor-not-allowed":"";return"".concat("flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all"," ").concat(t?"bg-cyan-50 dark:bg-cyan-900/30 border-2 border-cyan-500":"bg-white dark:bg-gray-800 border-2 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"," ").concat(r)},[s,a]);return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:"Select an option"}),(0,r.jsx)("div",{className:"space-y-2",children:t.options.map(e=>(0,r.jsxs)("label",{className:x(e.number),children:[(0,r.jsx)("input",{type:"radio",name:u,value:e.number,checked:s===e.number,onChange:()=>n(e.number),disabled:a,className:"mt-1","aria-describedby":e.isDefault?"default-".concat(e.number):void 0}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),e.isDefault&&(0,r.jsx)("span",{id:"default-".concat(e.number),className:"ml-2 text-xs text-cyan-600 dark:text-cyan-400 bg-cyan-100 dark:bg-cyan-900/30 px-2 py-0.5 rounded",children:m("default")})]})]},e.number))})]}),c&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"text-input-".concat(u),className:"sr-only",children:"Custom value input"}),(0,r.jsx)("input",{id:"text-input-".concat(u),type:"text",value:o,onChange:e=>i(e.target.value),disabled:a,placeholder:m("enterValuePlaceholder"),className:"w-full px-4 py-2 border-2 border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100 rounded-lg focus:outline-none focus:border-cyan-500 disabled:opacity-50"})]}),(0,r.jsx)("button",{type:"button",onClick:d,disabled:a||null===s,className:"w-full ".concat(Q," ").concat(J),children:m("submit")})]})}let et=(0,l.memo)(function(e){let t,{promptData:a,messageId:s,visible:n,answering:o,onRespond:i,onDismiss:c,cliToolName:d}=e,{shouldRender:u,animationClass:m}=K({visible:n&&null!==a,duration:200}),x=(0,l.useId)();if(!u||!a)return null;let h=(t="opacity-100","animate-fade-in"===m?t="opacity-100 transform translate-y-0":"animate-fade-out"===m&&(t="opacity-0 transform translate-y-2"),"".concat("bg-yellow-50 dark:bg-gray-800 border-2 border-yellow-300 dark:border-yellow-600 rounded-lg p-4 shadow-lg transition-all duration-200 ease-in-out"," ").concat(m," ").concat(t));return(0,r.jsx)(b,{componentName:"PromptPanel",children:(0,r.jsx)("div",{"data-testid":"prompt-panel",role:"dialog","aria-labelledby":x,"aria-modal":"true",className:h,children:(0,r.jsx)(X,{promptData:a,answering:o,onRespond:i,onDismiss:c,labelId:x,cliToolName:d})})})});var ea=a(8672),er=a(93448);let es=(0,l.memo)(function(e){let{path:t,className:a="w-6 h-6"}=e;return(0,r.jsx)("svg",{className:a,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:t})})}),en={back:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1h-2z",menu:"M4 6h16M4 12h16M4 18h16"};function el(e){let{worktreeName:t,repositoryName:a,status:s,gitStatus:n,onBackClick:o,onMenuClick:i}=e,c=(0,l.useMemo)(()=>ea.xh[s],[s]);return(0,r.jsx)("header",{"data-testid":"mobile-header",role:"banner",className:"sticky top-0 inset-x-0 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700 shadow-sm pt-safe z-40",children:(0,r.jsxs)("div",{className:"flex items-center justify-between h-14 px-4",children:[(0,r.jsx)("div",{className:"w-10 flex-shrink-0",children:o&&(0,r.jsx)("button",{type:"button",onClick:o,"aria-label":"Back",className:"p-2 -ml-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors dark:text-gray-300",children:(0,r.jsx)(es,{path:en.back})})}),(0,r.jsxs)("div",{className:"flex-1 flex items-center justify-center min-w-0 px-2",children:["spinner"===c.type?(0,r.jsx)("span",{"data-testid":"status-indicator","aria-label":c.label,className:"w-2.5 h-2.5 rounded-full mr-2 flex-shrink-0 border-2 border-t-transparent animate-spin ".concat(c.className)}):(0,r.jsx)("span",{"data-testid":"status-indicator","aria-label":c.label,className:"w-2.5 h-2.5 rounded-full mr-2 flex-shrink-0 ".concat(c.className)}),(0,r.jsxs)("div",{className:"flex flex-col items-center min-w-0",children:[(0,r.jsx)("h1",{role:"heading","data-testid":"worktree-name",title:t,className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate text-center leading-tight",children:t}),(0,r.jsxs)("div",{className:"flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400",children:[a&&(0,r.jsx)("span",{className:"truncate max-w-[100px] text-center",children:a}),n&&"(unknown)"!==n.currentBranch&&(0,r.jsxs)(r.Fragment,{children:[a&&(0,r.jsx)("span",{className:"text-gray-300 dark:text-gray-600",children:"/"}),(0,r.jsx)("span",{className:"truncate max-w-[80px] font-mono",title:n.currentBranch,"data-testid":"mobile-branch-name",children:(0,er.aS)(n.currentBranch,20)}),n.isDirty&&(0,r.jsx)("span",{className:"text-amber-500",title:"Uncommitted changes",children:"*"})]})]})]})]}),(0,r.jsx)("div",{className:"w-10 flex-shrink-0 flex justify-end",children:i&&(0,r.jsx)("button",{type:"button",onClick:i,"aria-label":"Menu",className:"p-2 -mr-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors dark:text-gray-300",children:(0,r.jsx)(es,{path:en.menu})})})]})})}function eo(e){let{"data-testid":t,"aria-label":a,className:s=""}=e;return(0,r.jsx)("span",{"data-testid":t,className:"w-2 h-2 rounded-full bg-cyan-500 ".concat(s).trim(),"aria-label":a})}let ei=(0,l.memo)(function(e){let{path:t,className:a="w-5 h-5"}=e;return(0,r.jsx)("svg",{className:a,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:t})})}),ec=[{id:"terminal",label:"Terminal",icon:(0,r.jsx)(ei,{path:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})},{id:"history",label:"History",icon:(0,r.jsx)(ei,{path:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})},{id:"files",label:"Files",icon:(0,r.jsx)(ei,{path:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})},{id:"memo",label:"CMATE",icon:(0,r.jsx)(ei,{path:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})},{id:"info",label:"Info",icon:(0,r.jsx)(ei,{path:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}];function ed(e){let{activeTab:t,onTabChange:a,hasNewOutput:s=!1,hasPrompt:n=!1,hasUpdate:o=!1}=e,i=(0,l.useCallback)(e=>{let a=e===t;return"".concat("flex flex-col items-center justify-center flex-1 py-2 px-1 transition-colors relative"," ").concat(a?"text-cyan-600 dark:text-cyan-400 bg-cyan-50 dark:bg-cyan-900/30":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800")},[t]),c=(0,l.useMemo)(()=>(0,r.jsxs)(r.Fragment,{children:[s&&(0,r.jsx)("span",{"data-testid":"new-output-badge",className:"absolute top-1 right-1 w-2 h-2 bg-green-500 rounded-full","aria-label":"New output available"}),n&&(0,r.jsx)("span",{"data-testid":"prompt-badge",className:"absolute top-1 right-3 w-2 h-2 bg-yellow-500 rounded-full","aria-label":"Prompt waiting"})]}),[s,n]);return(0,r.jsx)("nav",{"data-testid":"mobile-tab-bar",role:"tablist","aria-label":"Mobile navigation",className:"fixed bottom-0 inset-x-0 bg-white dark:bg-gray-900 border-t border-gray-200 dark:border-gray-700 flex pb-safe z-40",children:ec.map(e=>(0,r.jsxs)("button",{type:"button","data-testid":"mobile-tab-".concat(e.id),role:"tab","aria-selected":t===e.id,"aria-label":e.label,onClick:()=>a(e.id),className:i(e.id),children:[e.icon,(0,r.jsx)("span",{className:"text-xs mt-1",children:e.label}),"terminal"===e.id&&c,"info"===e.id&&o&&(0,r.jsx)(eo,{"data-testid":"info-update-badge",className:"absolute top-1 right-1","aria-label":"Update available"})]},e.id))})}let eu={base:"px-6 py-3 rounded-lg font-medium transition-all disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-offset-2",primary:"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500",secondary:"bg-white dark:bg-gray-700 border-2 border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200 focus:ring-gray-500",defaultSelected:"bg-gray-600 text-white hover:bg-gray-700"},em=(0,l.memo)(function(e){let{promptData:t,visible:a,answering:s,onRespond:n,onDismiss:o,cliToolName:i}=e,{shouldRender:c,animationClass:d}=K({visible:a&&null!==t,duration:300}),u=(0,l.useId)(),[m,x]=(0,l.useState)(null),[h,g]=(0,l.useState)(0),p=(0,l.useRef)(null);(0,l.useEffect)(()=>{a||g(0)},[a]);let y=(0,l.useCallback)(e=>{x(e.touches[0].clientY)},[]),f=(0,l.useCallback)(e=>{if(null===m)return;let t=e.touches[0].clientY-m;t>0&&g(t)},[m]),k=(0,l.useCallback)(()=>{h>100&&o&&o(),g(0),x(null)},[h,o]),v=(0,l.useCallback)(()=>{o&&o()},[o]),j=(0,l.useCallback)(e=>{e.stopPropagation()},[]);if(!c||!t)return null;let w="animate-fade-out"===d,N=h>0?"translateY(".concat(h,"px)"):void 0;return(0,r.jsxs)(b,{componentName:"MobilePromptSheet",children:[(0,r.jsx)("div",{"data-testid":"prompt-overlay",onClick:v,className:"fixed inset-0 bg-black/50 z-50 transition-opacity duration-300 ".concat(w?"opacity-0":"opacity-100"," ").concat(w?"pointer-events-none":""),"aria-hidden":"true"}),(0,r.jsxs)("div",{ref:p,"data-testid":"mobile-prompt-sheet",role:"dialog","aria-modal":"true","aria-labelledby":u,onClick:j,onTouchStart:y,onTouchMove:f,onTouchEnd:k,style:{transform:N},className:"fixed bottom-0 inset-x-0 bg-white dark:bg-gray-800 rounded-t-2xl z-50 pb-safe transform transition-transform duration-300 ".concat(w?"translate-y-full":"translate-y-0"),children:[(0,r.jsx)("div",{className:"flex justify-center pt-3 pb-2",children:(0,r.jsx)("div",{"data-testid":"drag-handle",className:"w-10 h-1 bg-gray-300 dark:bg-gray-600 rounded-full","aria-hidden":"true"})}),(0,r.jsx)("div",{className:"px-4 pb-6",children:(0,r.jsx)(ex,{promptData:t,answering:s,onRespond:n,labelId:u,cliToolName:i})})]})]})});function ex(e){let{promptData:t,answering:a,onRespond:s,labelId:n,cliToolName:o}=e,i=(0,y.T)("prompt"),[c,d]=(0,l.useState)(()=>{if("multiple_choice"===t.type){var e;let a=t.options.find(e=>e.isDefault);return null!==(e=null==a?void 0:a.number)&&void 0!==e?e:null}return null}),[u,m]=(0,l.useState)(""),[x,h]=(0,l.useState)(!1),g=(0,l.useMemo)(()=>{var e;return"multiple_choice"!==t.type?null:null!==(e=t.options.find(e=>e.number===c))&&void 0!==e?e:null},[t,c]),p=(null==g?void 0:g.requiresTextInput)===!0,b=a||x,f=(0,l.useCallback)(async e=>{if(!b){h(!0);try{await s(e)}catch(e){}finally{h(!1)}}},[b,s]),k=(0,l.useCallback)(async()=>{if(!b&&null!==c){h(!0);try{let e=p&&u.trim()?u.trim():c.toString();await s(e)}catch(e){}finally{h(!1)}}},[b,s,c,p,u]);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h3",{id:n,className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:o?i("confirmationFrom",{toolName:o}):i("confirmationFromClaude")}),t.instructionText&&(0,r.jsx)("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap text-sm text-gray-600 dark:text-gray-300 bg-gray-50 dark:bg-gray-700 rounded p-2 border border-gray-200 dark:border-gray-600",children:t.instructionText}),(0,r.jsx)("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed",children:t.question}),b&&(0,r.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400",role:"status","aria-live":"polite",children:[(0,r.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-gray-300 dark:border-gray-600 border-t-blue-600","aria-hidden":"true"}),(0,r.jsx)("span",{children:i("sending")})]}),"yes_no"===t.type&&(0,r.jsx)(eh,{promptData:t,disabled:b,onYes:()=>f("yes"),onNo:()=>f("no")}),"multiple_choice"===t.type&&(0,r.jsx)(eg,{promptData:t,disabled:b,selectedOption:c,onSelectOption:d,textInputValue:u,onTextInputChange:m,showTextInput:p,onSubmit:k})]})}let eh=(0,l.memo)(function(e){let{promptData:t,disabled:a,onYes:s,onNo:n}=e,l=(0,y.T)("prompt"),o="yes"===t.defaultOption,i="no"===t.defaultOption;return(0,r.jsxs)("div",{className:"flex gap-3",role:"group","aria-label":"Yes or No options",children:[(0,r.jsx)("button",{type:"button",onClick:s,disabled:a,className:"flex-1 ".concat(eu.base," ").concat(eu.primary," ").concat(o?"ring-2 ring-blue-300":""),children:l("yes")}),(0,r.jsx)("button",{type:"button",onClick:n,disabled:a,className:"flex-1 ".concat(eu.base," ").concat(i?eu.defaultSelected:eu.secondary),children:l("no")})]})}),eg=(0,l.memo)(function(e){let{promptData:t,disabled:a,selectedOption:s,onSelectOption:n,textInputValue:o,onTextInputChange:i,showTextInput:c,onSubmit:d}=e,u=(0,l.useId)(),m=(0,y.T)("prompt");return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:"Select an option"}),(0,r.jsx)("div",{className:"space-y-2",children:t.options.map(e=>{let t=s===e.number;return(0,r.jsxs)("label",{className:"flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ".concat(t?"bg-blue-50 dark:bg-blue-900/30 border-2 border-blue-500":"bg-white dark:bg-gray-700 border-2 border-gray-200 dark:border-gray-600 hover:border-gray-300 dark:hover:border-gray-500"," ").concat(a?"opacity-50 cursor-not-allowed":""),children:[(0,r.jsx)("input",{type:"radio",name:u,value:e.number,checked:t,onChange:()=>n(e.number),disabled:a,className:"mt-1"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("span",{className:"font-medium dark:text-gray-200",children:[e.number,". ",e.label]}),e.isDefault&&(0,r.jsx)("span",{className:"ml-2 text-xs text-blue-600 bg-blue-100 px-2 py-0.5 rounded",children:m("default")})]})]},e.number)})})]}),c&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"text-input-".concat(u),className:"sr-only",children:"Custom value input"}),(0,r.jsx)("input",{id:"text-input-".concat(u),type:"text",value:o,onChange:e=>i(e.target.value),disabled:a,placeholder:m("enterValuePlaceholder"),className:"w-full px-4 py-3 border-2 border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:border-blue-500 disabled:opacity-50"})]}),(0,r.jsx)("button",{type:"button",onClick:d,disabled:a||null===s,className:"w-full ".concat(eu.base," ").concat(eu.primary),children:m("submit")})]})});var ep=a(6940);let ey={isOpen:!1,position:{x:0,y:0},targetPath:null,targetType:null};var eb=a(88964),ef=a(49465),ek=a(17689),ev=a(45675),ej=a(79548),ew=a(18930),eN=a(3468);let eC=(0,l.memo)(function(e){let{isOpen:t,position:a,targetPath:s,targetType:n,onClose:o,onNewFile:i,onNewDirectory:c,onRename:d,onDelete:u,onUpload:m,onMove:x}=e,h=(0,l.useRef)(null),g=(0,l.useCallback)(e=>{e&&s&&e(s),o()},[s,o]),p=[{id:"new-file",label:"New File",icon:(0,r.jsx)(eb.Z,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>g(i),showFor:["directory"]},{id:"new-directory",label:"New Directory",icon:(0,r.jsx)(ef.Z,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>g(c),showFor:["directory"]},{id:"upload",label:"Upload File",icon:(0,r.jsx)(ek.Z,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>g(m),showFor:["directory"],showDividerAfter:!0},{id:"rename",label:"Rename",icon:(0,r.jsx)(ev.Z,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>g(d)},{id:"move",label:"Move",icon:(0,r.jsx)(ej.Z,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>{x&&s&&n&&x(s,n),o()},showDividerAfter:!0},{id:"delete",label:"Delete",icon:(0,r.jsx)(ew.Z,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>g(u),variant:"danger"}].filter(e=>!e.showFor||n&&e.showFor.includes(n));return((0,l.useEffect)(()=>{if(!t)return;let e=e=>{if("Escape"===e.key){o();return}if("ArrowDown"===e.key||"ArrowUp"===e.key){var t;let a;e.preventDefault();let r=null===(t=h.current)||void 0===t?void 0:t.querySelectorAll('[role="menuitem"]');if(!(null==r?void 0:r.length))return;let s=Array.from(r).findIndex(e=>e===document.activeElement);a="ArrowDown"===e.key?s<r.length-1?s+1:0:s>0?s-1:r.length-1,r[a].focus()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,o]),(0,l.useEffect)(()=>{if(t&&h.current){let e=h.current.querySelector('[role="menuitem"]');e&&e.focus()}},[t]),t)?(0,r.jsx)("div",{ref:h,"data-testid":"context-menu",role:"menu","aria-label":"File actions",className:"fixed min-w-[160px] py-1 bg-white rounded-lg shadow-lg border border-gray-200 animate-in fade-in-0 zoom-in-95 duration-100",style:{zIndex:eN.k.CONTEXT_MENU,left:"".concat(a.x,"px"),top:"".concat(a.y,"px")},children:p.map((e,t)=>(0,r.jsxs)(l.Fragment,{children:[(0,r.jsxs)("button",{role:"menuitem",onClick:e.onClick,disabled:!s,className:"w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors focus:outline-none focus:bg-gray-100 ".concat("danger"===e.variant?"text-red-600 hover:bg-red-50 focus:bg-red-50":"text-gray-700 hover:bg-gray-100"," ").concat(s?"":"opacity-50 cursor-not-allowed"),children:[e.icon,(0,r.jsx)("span",{children:e.label})]}),e.showDividerAfter&&t<p.length-1&&(0,r.jsx)("div",{"data-testid":"context-menu-divider",className:"my-1 border-t border-gray-200"})]},e.id))}):null});var eS=a(45306),eT=a(98408),eE=a(69234),eM=a(48736);let eL=(0,l.memo)(function(e){let{expanded:t}=e;return(0,r.jsx)("svg",{"data-testid":"chevron-icon",className:"w-4 h-4 text-gray-500 dark:text-gray-400 transition-transform ".concat(t?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),eR=(0,l.memo)(function(e){let{open:t}=e;return(0,r.jsx)("svg",{"data-testid":"folder-icon",className:"w-5 h-5 text-yellow-500",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:t?(0,r.jsx)("path",{d:"M19 20H5c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h6l2 2h6c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2zM5 6v12h14V8h-7l-2-2H5z"}):(0,r.jsx)("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}),eA=(0,l.memo)(function(e){let{text:t,query:a}=e;if(!a||!a.trim())return(0,r.jsx)(r.Fragment,{children:t});let s=(0,er.hr)(a),n=t.split(RegExp("(".concat(s,")"),"gi"));return(0,r.jsx)(r.Fragment,{children:n.map((e,t)=>e.toLowerCase()===a.toLowerCase()?(0,r.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 text-gray-900 dark:text-gray-100 px-0.5 rounded",children:e},t):(0,r.jsx)("span",{children:e},t))})}),eF=(0,l.memo)(function(e){let{extension:t}=e,a=(0,l.useMemo)(()=>t&&({ts:"text-blue-500",tsx:"text-blue-500",js:"text-yellow-400",jsx:"text-yellow-400",json:"text-yellow-600",md:"text-gray-500",css:"text-pink-500",scss:"text-pink-500",html:"text-orange-500",py:"text-green-500"})[t]||"text-gray-400",[t]);return(0,r.jsx)("svg",{"data-testid":"file-icon",className:"w-5 h-5 ".concat(a),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),eP=(0,l.memo)(function e(t){var a;let{item:s,path:n,depth:o,worktreeId:i,expanded:c,cache:d,onToggle:u,onFileSelect:m,onLoadChildren:x,onContextMenu:h,searchQuery:g,searchMode:p,matchedPaths:y,dateFnsLocaleStr:b}=t,[f,k]=(0,l.useState)(!1),v=n?"".concat(n,"/").concat(s.name):s.name,j=c.has(v),w="directory"===s.type,N=d.get(v),C=(0,l.useCallback)(async()=>{w?(j||N||(k(!0),await x(v),k(!1)),u(v)):null==m||m(v)},[w,j,N,v,x,u,m]),S=(0,l.useCallback)(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),C())},[C]),T=(0,l.useCallback)(e=>{e.preventDefault(),null==h||h(e,v,w?"directory":"file")},[v,w,h]),E=function(e){let{delay:t=500,moveThreshold:a=10,onLongPress:r}=e,s=(0,l.useRef)(null),n=(0,l.useRef)(null),o=(0,l.useRef)(null),i=(0,l.useCallback)(()=>{s.current&&(clearTimeout(s.current),s.current=null),n.current=null,o.current=null},[]);(0,l.useEffect)(()=>()=>i(),[i]);let c=(0,l.useCallback)(e=>{if(1!==e.touches.length)return;let a=e.touches[0];n.current={x:a.clientX,y:a.clientY},o.current=e,s.current=setTimeout(()=>{o.current&&r(o.current),i()},t)},[t,r,i]);return{onTouchStart:c,onTouchMove:(0,l.useCallback)(e=>{if(!n.current||1!==e.touches.length)return;let t=e.touches[0],r=t.clientX-n.current.x,s=t.clientY-n.current.y;Math.sqrt(r*r+s*s)>a&&i()},[a,i]),onTouchEnd:(0,l.useCallback)(()=>{i()},[i]),onTouchCancel:(0,l.useCallback)(()=>{i()},[i])}}({onLongPress:(0,l.useCallback)(e=>{null==h||h(e,v,w?"directory":"file")},[v,w,h])});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{"data-testid":"tree-item-".concat(s.name),role:"treeitem","aria-selected":!1,"aria-expanded":w?j:void 0,tabIndex:0,className:"flex items-center gap-2 py-1.5 pr-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800 rounded transition-colors",style:{paddingLeft:"".concat(.5+1*Math.min(o,20),"rem"),touchAction:"manipulation",WebkitTouchCallout:"none"},onClick:C,onKeyDown:S,onContextMenu:T,onTouchStart:E.onTouchStart,onTouchMove:E.onTouchMove,onTouchEnd:E.onTouchEnd,onTouchCancel:E.onTouchCancel,children:[w?(0,r.jsx)("span",{className:"w-4 h-4 flex items-center justify-center",children:f?(0,r.jsx)("span",{className:"w-3 h-3 border-2 border-gray-300 dark:border-gray-600 border-t-cyan-500 rounded-full animate-spin"}):(0,r.jsx)(eL,{expanded:j})}):(0,r.jsx)("span",{className:"w-4 h-4"}),w?(0,r.jsx)(eR,{open:j}):(0,r.jsx)(eF,{extension:s.extension}),(0,r.jsx)("span",{className:"flex-1 truncate text-sm text-gray-700 dark:text-gray-300",children:"name"===p&&g?(0,r.jsx)(eA,{text:s.name,query:g}):s.name}),(0,r.jsx)("span",{className:"text-xs text-gray-400 flex-shrink-0",children:w?void 0!==s.itemCount&&"".concat(s.itemCount," items"):void 0===(a=s.size)?"":a<1024?"".concat(a," B"):a<1048576?"".concat((a/1024).toFixed(1)," KB"):"".concat((a/1048576).toFixed(1)," MB")}),!w&&s.birthtime&&(0,r.jsx)("span",{className:"text-xs text-gray-400 flex-shrink-0",title:s.birthtime,children:function(e,t){let a=new Date(e);return isNaN(a.getTime())?"":(0,eS.Q)(a,{addSuffix:!0,...t?{locale:t}:{}})}(s.birthtime,b?(0,eT.G)(b):void 0)})]}),w&&j&&N&&(0,r.jsx)("div",{role:"group",children:N.filter(e=>{let t=v?"".concat(v,"/").concat(e.name):e.name;if(!(null==g?void 0:g.trim()))return!0;if("name"===p){let t=g.toLowerCase();return!!e.name.toLowerCase().includes(t)||"directory"===e.type}if("content"===p&&y&&y.size>0){if(y.has(t))return!0;if("directory"===e.type){for(let e of y)if(e.startsWith(t+"/"))return!0}return!1}return!0}).map(t=>(0,r.jsx)(e,{item:t,path:v,depth:o+1,worktreeId:i,expanded:c,cache:d,onToggle:u,onFileSelect:m,onLoadChildren:x,onContextMenu:h,searchQuery:g,searchMode:p,matchedPaths:y,dateFnsLocaleStr:b},t.name))})]})}),eD=(0,l.memo)(function(e){let{worktreeId:t,onFileSelect:a,onNewFile:s,onNewDirectory:n,onRename:o,onDelete:i,onUpload:c,onMove:d,className:u="",refreshTrigger:m=0,searchQuery:x,searchMode:h,searchResults:g,onSearchResultSelect:p,onCmateSetup:y}=e,b=(0,eE.bU)(),[f,k]=(0,l.useState)(!0),[v,j]=(0,l.useState)(null),[w,N]=(0,l.useState)([]),[C,S]=(0,l.useState)(new Set),[T,E]=(0,l.useState)(()=>new Map),M=(0,l.useRef)(C);M.current=C;let L=(0,l.useRef)(new Set),{menuState:R,openMenu:A,closeMenu:F}=function(){let[e,t]=(0,l.useState)(ey),a=(0,l.useCallback)((e,a,r)=>{let s,n;if(e.preventDefault(),"touches"in e&&e.touches.length>0)s=e.touches[0].clientX,n=e.touches[0].clientY;else{if(!("clientX"in e))return;s=e.clientX,n=e.clientY}t({isOpen:!0,position:{x:s,y:n},targetPath:a,targetType:r})},[]),r=(0,l.useCallback)(()=>{t(e=>({...e,isOpen:!1}))},[]),s=(0,l.useCallback)(()=>{t(ey)},[]);return(0,l.useEffect)(()=>{if(!e.isOpen)return;let t=()=>{r()},a=setTimeout(()=>{document.addEventListener("click",t)},0);return()=>{clearTimeout(a),document.removeEventListener("click",t)}},[e.isOpen,r]),(0,l.useEffect)(()=>{if(!e.isOpen)return;let t=e=>{"Escape"===e.key&&r()};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[e.isOpen,r]),{menuState:e,openMenu:a,closeMenu:r,resetMenu:s}}(),P=(0,l.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{let a=e?"/api/worktrees/".concat(t,"/tree/").concat(e):"/api/worktrees/".concat(t,"/tree"),r=await fetch(a);if(!r.ok)throw Error("Failed to load directory: ".concat(r.status));return await r.json()}catch(e){throw console.error("[FileTreeView] Error fetching directory:",e),e}},[t]);(0,l.useEffect)(()=>{let e=!0;return(async()=>{k(!0),j(null);try{let t=await P();if(!e||!t)return;let a=Array.from(M.current),r=new Map,s=[];for(let t=0;t<a.length;t+=5){if(!e)return;let n=a.slice(t,t+5);for(let[e,t]of(await Promise.allSettled(n.map(async e=>{let t=await P(e);return{dirPath:e,data:t}}))).entries())"fulfilled"===t.status&&t.value.data?r.set(t.value.dirPath,t.value.data.items):s.push(n[e])}if(!e)return;N(t.items),E(r),s.length>0&&S(e=>{let t=new Set(e);for(let e of s)e&&t.delete(e);return t})}catch(t){e&&j(t instanceof Error?t.message:"Failed to load files")}finally{e&&k(!1)}})(),()=>{e=!1}},[P,m]);let D=(0,l.useCallback)(async e=>{if(!(T.has(e)||L.current.has(e))){L.current.add(e);try{let t=await P(e);t&&E(a=>{let r=new Map(a);return r.set(e,t.items),r})}catch(e){console.error("[FileTreeView] Error loading children:",e)}finally{L.current.delete(e)}}},[T,P]),O=(0,l.useCallback)(e=>{S(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),I=(0,l.useMemo)(()=>"content"===h&&g&&0!==g.length?(0,er.Ps)(g.map(e=>e.filePath)):new Set,[h,g]);(0,l.useEffect)(()=>{I.size>0&&S(e=>{let t=new Set(e);for(let e of I)(T.has(e)||(null==g?void 0:g.some(t=>t.filePath.startsWith(e+"/"))))&&t.add(e);return t})},[I,T,g]);let _=(0,l.useMemo)(()=>{if(!(null==x?void 0:x.trim()))return w;if("name"===h){let e=x.toLowerCase(),t=(a,r)=>a.filter(a=>{let s=r?"".concat(r,"/").concat(a.name):a.name,n=a.name.toLowerCase().includes(e);if("directory"===a.type){let e=T.get(s);if(e&&t(e,s).length>0)return!0}return n});return t(w,"")}return"content"===h&&I.size>0?w.filter(e=>{if(I.has(e.name))return!0;if("directory"===e.type){for(let t of I)if(t.startsWith(e.name+"/")||t===e.name)return!0}return!1}):w},[w,x,h,I,T]);return f?(0,r.jsxs)("div",{"data-testid":"file-tree-loading",className:"flex items-center justify-center p-4 ".concat(u),children:[(0,r.jsx)("span",{className:"w-5 h-5 border-2 border-gray-300 dark:border-gray-600 border-t-cyan-500 rounded-full animate-spin"}),(0,r.jsx)("span",{className:"ml-2 text-sm text-gray-500 dark:text-gray-400",children:"Loading files..."})]}):v?(0,r.jsx)("div",{"data-testid":"file-tree-error",className:"p-4 bg-red-50 border border-red-200 rounded-lg ".concat(u),children:(0,r.jsx)("p",{className:"text-sm text-red-600",children:v})}):0===w.length?(0,r.jsxs)("div",{"data-testid":"file-tree-empty",className:"p-4 text-center text-gray-500 dark:text-gray-400 ".concat(u),children:[(0,r.jsx)("p",{className:"text-sm",children:"No files found"}),(s||n)&&(0,r.jsxs)("div",{className:"flex flex-col gap-2 mt-4",children:[s&&(0,r.jsxs)("button",{"data-testid":"empty-new-file-button",onClick:()=>s(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[(0,r.jsx)(eb.Z,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:"New File"})]}),n&&(0,r.jsxs)("button",{"data-testid":"empty-new-directory-button",onClick:()=>n(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[(0,r.jsx)(ef.Z,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:"New Directory"})]})]})]}):(null==x?void 0:x.trim())&&0===_.length?(0,r.jsx)("div",{"data-testid":"file-tree-no-results",className:"p-4 text-center text-gray-500 dark:text-gray-400 ".concat(u),children:(0,r.jsxs)("p",{className:"text-sm",children:["No ","content"===h?"files containing":"files matching",' "',x,'"']})}):(0,r.jsxs)("div",{"data-testid":"file-tree-view",role:"tree","aria-label":"File tree",className:"overflow-auto bg-white dark:bg-gray-900 ".concat(u),children:[(s||n||y)&&(0,r.jsxs)("div",{"data-testid":"file-tree-toolbar",className:"flex items-center gap-1 p-1 border-b border-gray-200 dark:border-gray-700",children:[s&&(0,r.jsxs)("button",{"data-testid":"toolbar-new-file-button",onClick:()=>s(""),className:"flex items-center gap-1 px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors",children:[(0,r.jsx)(eb.Z,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:"New File"})]}),n&&(0,r.jsxs)("button",{"data-testid":"toolbar-new-directory-button",onClick:()=>n(""),className:"flex items-center gap-1 px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors",children:[(0,r.jsx)(ef.Z,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:"New Directory"})]}),y&&(0,r.jsxs)("button",{"data-testid":"toolbar-cmate-button",onClick:y,className:"flex items-center gap-1 px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors",children:[(0,r.jsx)(eM.Z,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:"CMATE"})]})]}),_.map(e=>(0,r.jsx)(eP,{item:e,path:"",depth:0,worktreeId:t,expanded:C,cache:T,onToggle:O,onFileSelect:p||a,onLoadChildren:D,onContextMenu:A,searchQuery:x,searchMode:h,matchedPaths:I,dateFnsLocaleStr:b},e.name)),(0,r.jsx)(eC,{isOpen:R.isOpen,position:R.position,targetPath:R.targetPath,targetType:R.targetType,onClose:F,onNewFile:s,onNewDirectory:n,onRename:o,onDelete:i,onUpload:c,onMove:d})]})}),eO=(0,l.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),eI=(0,l.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e_=(0,l.memo)(function(){return(0,r.jsx)("div",{"data-testid":"search-loading",className:"w-4 h-4 border-2 border-gray-300 border-t-cyan-500 rounded-full animate-spin","aria-label":"Searching..."})}),eW=(0,l.memo)(function(e){let{query:t,mode:a,isSearching:s,error:n,onQueryChange:o,onModeChange:i,onClear:c,placeholder:d="Search files...",className:u=""}=e,m=(0,l.useRef)(null),x=(0,l.useCallback)(e=>{o(e.target.value)},[o]),h=(0,l.useCallback)(()=>{var e;c(),null===(e=m.current)||void 0===e||e.focus()},[c]),p=(0,l.useCallback)(e=>{if("Escape"===e.key){if(t)h();else{var a;null===(a=m.current)||void 0===a||a.blur()}}},[t,h]);return(0,l.useEffect)(()=>{if(!(window.innerWidth<g.G)){let e=setTimeout(()=>{var e;null===(e=m.current)||void 0===e||e.focus()},100);return()=>clearTimeout(e)}},[]),(0,r.jsxs)("div",{"data-testid":"search-bar",className:"flex flex-col gap-2 p-2 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700 ".concat(u),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(eO,{})}),(0,r.jsx)("input",{ref:m,type:"text","data-testid":"search-input",value:t,onChange:x,onKeyDown:p,placeholder:d,className:"flex-1 min-w-0 px-2 py-1 text-sm bg-gray-50 dark:bg-gray-800 dark:text-gray-100 border border-gray-200 dark:border-gray-600 rounded focus:outline-none focus:ring-1 focus:ring-cyan-500 focus:border-cyan-500","aria-label":"Search files","aria-busy":s}),(0,r.jsx)("div",{className:"flex-shrink-0 w-6 h-6 flex items-center justify-center",children:s?(0,r.jsx)(e_,{}):t?(0,r.jsx)("button",{type:"button","data-testid":"search-clear",onClick:h,className:"p-1 text-gray-400 hover:text-gray-600 rounded transition-colors","aria-label":"Clear search",children:(0,r.jsx)(eI,{})}):null})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"text-xs text-gray-500 mr-1",children:"Mode:"}),(0,r.jsx)("button",{type:"button","data-testid":"mode-name",onClick:()=>i("name"),className:"px-2 py-0.5 text-xs rounded transition-colors ".concat("name"===a?"bg-cyan-100 dark:bg-cyan-900 text-cyan-700 dark:text-cyan-300 font-medium":"bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600"),"aria-pressed":"name"===a,children:"Name"}),(0,r.jsx)("button",{type:"button","data-testid":"mode-content",onClick:()=>i("content"),className:"px-2 py-0.5 text-xs rounded transition-colors ".concat("content"===a?"bg-cyan-100 dark:bg-cyan-900 text-cyan-700 dark:text-cyan-300 font-medium":"bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600"),"aria-pressed":"content"===a,children:"Content"})]}),n&&(0,r.jsx)("div",{"data-testid":"search-error",className:"text-xs text-red-600 bg-red-50 px-2 py-1 rounded",role:"alert",children:n})]})}),ez=(0,l.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),eB=(0,l.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})})}),eU=(0,l.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),eV=[{id:"history",label:"History",icon:(0,r.jsx)(ez,{})},{id:"files",label:"Files",icon:(0,r.jsx)(eB,{})},{id:"memo",label:"CMATE",icon:(0,r.jsx)(eU,{})}],eH=(0,l.memo)(function(e){let{activeTab:t,onTabChange:a,className:s=""}=e,n=(0,l.useCallback)(e=>{a(e)},[a]),o=(0,l.useCallback)((e,t)=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),a(e))},[a]),i=(0,l.useCallback)(e=>{let a=e===t;return"".concat("flex items-center gap-2 px-4 py-2 text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-cyan-500 focus:ring-inset"," ").concat(a?"bg-cyan-50 dark:bg-cyan-900/30 text-cyan-600 dark:text-cyan-400 border-b-2 border-cyan-600 dark:border-cyan-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800")},[t]);return(0,r.jsx)("div",{role:"tablist","aria-label":"Left pane view switcher",className:"flex border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 ".concat(s),children:eV.map(e=>(0,r.jsxs)("button",{type:"button",role:"tab","aria-selected":t===e.id,"aria-label":e.label,tabIndex:0,onClick:()=>n(e.id),onKeyDown:t=>o(e.id,t),className:i(e.id),children:[e.icon,(0,r.jsx)("span",{children:e.label})]},e.id))})});var eY=a(10789),eq=a(39625),eZ=a(1243),eG=a(30401);let eK=(0,l.memo)(function(e){let{isOpen:t,onClose:a,worktreeId:s,filePath:n}=e,[o,i]=(0,l.useState)(null),[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),[x,h]=(0,l.useState)(!1),g=(0,l.useMemo)(()=>!!((null==o?void 0:o.content)&&!o.isImage&&!o.isVideo),[o]),p=(0,l.useCallback)(async()=>{if(g&&(null==o?void 0:o.content))try{await (0,V.v)(o.content),h(!0),setTimeout(()=>h(!1),2e3)}catch(e){}},[g,o]);return(0,l.useEffect)(()=>{if(!t||!n){i(null),m(null),h(!1);return}(async()=>{d(!0),m(null);try{let e=await fetch("/api/worktrees/".concat(s,"/files/").concat(n));if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to load file")}let t=await e.json();i(t)}catch(e){m(e instanceof Error?e.message:"Failed to load file")}finally{d(!1)}})()},[t,s,n]),(0,r.jsx)(eY.u_,{isOpen:t,onClose:a,title:n,size:"xl",children:(0,r.jsxs)("div",{className:"max-h-[60vh] sm:max-h-[70vh] overflow-y-auto",children:[c&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,r.jsx)("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 dark:border-gray-600 border-t-cyan-600 dark:border-t-cyan-400"}),(0,r.jsx)("p",{className:"ml-3 text-gray-600 dark:text-gray-400",children:"Loading file..."})]}),u&&(0,r.jsx)("div",{className:"bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-800 rounded-lg p-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-5 h-5 text-red-600 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("p",{className:"text-sm text-red-800 dark:text-red-300",children:u})]})}),o&&!c&&!u&&(0,r.jsxs)("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"bg-gray-100 dark:bg-gray-700 px-4 py-2 border-b border-gray-200 dark:border-gray-600 flex items-center justify-between",children:[(0,r.jsxs)("p",{className:"text-xs text-gray-600 dark:text-gray-400 font-mono truncate",children:[o.worktreePath,"/",o.path]}),g&&(0,r.jsx)("button",{"data-testid":"copy-content-button",onClick:p,className:"flex-shrink-0 ml-2 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200","aria-label":"Copy file content",children:x?(0,r.jsx)(eG.Z,{className:"w-4 h-4 text-green-600"}):(0,r.jsx)(F.Z,{className:"w-4 h-4"})})]}),o.isImage?(0,r.jsx)(eq.O,{src:o.content,alt:o.path,mimeType:o.mimeType}):o.isVideo?(0,r.jsx)(eZ.R,{src:o.content,mimeType:o.mimeType}):(0,r.jsx)("div",{className:"p-4",children:(0,r.jsx)("pre",{className:"text-sm overflow-x-auto text-gray-900 dark:text-gray-100",children:(0,r.jsx)("code",{className:"language-".concat(o.extension),children:o.content})})})]})]})})}),eQ=[".md"],eJ=[{extension:".png",maxFileSize:5242880,allowedMimeTypes:["image/png"],magicBytes:[{bytes:[137,80,78,71,13,10,26,10]}]},{extension:".jpg",maxFileSize:5242880,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".jpeg",maxFileSize:5242880,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".gif",maxFileSize:5242880,allowedMimeTypes:["image/gif"],magicBytes:[{bytes:[71,73,70,56,55,97]},{bytes:[71,73,70,56,57,97]}]},{extension:".webp",maxFileSize:5242880,allowedMimeTypes:["image/webp"],magicBytes:[{bytes:[82,73,70,70],offset:0}]},{extension:".mp4",maxFileSize:15728640,allowedMimeTypes:["video/mp4"],magicBytes:[{bytes:[102,116,121,112],offset:4}]},{extension:".txt",maxFileSize:5242880,allowedMimeTypes:["text/plain"]},{extension:".log",maxFileSize:5242880,allowedMimeTypes:["text/plain"]},{extension:".md",maxFileSize:5242880,allowedMimeTypes:["text/markdown","text/plain"]},{extension:".csv",maxFileSize:5242880,allowedMimeTypes:["text/csv"]},{extension:".json",maxFileSize:5242880,allowedMimeTypes:["application/json"]},{extension:".yaml",maxFileSize:5242880,allowedMimeTypes:["text/yaml","application/x-yaml"]},{extension:".yml",maxFileSize:5242880,allowedMimeTypes:["text/yaml","application/x-yaml"]}],eX=eJ.map(e=>e.extension);var e$=a(20318),e0=a(3227),e1=a(36762);let e2=(0,l.memo)(function(e){var t,a;let{memo:s,onUpdate:n,onDelete:o,isSaving:i,error:c,className:d=""}=e,[u,m]=(0,l.useState)(s.title),[x,h]=(0,l.useState)(s.content),[g,p]=(0,l.useState)(!1),y=(0,l.useRef)();(0,l.useEffect)(()=>()=>{y.current&&clearTimeout(y.current)},[]);let{isSaving:b,error:f,saveNow:k}=(0,e1.Q)({value:u,saveFn:async e=>{await n(s.id,{title:e})}}),{isSaving:v,error:j,saveNow:w}=(0,e1.Q)({value:x,saveFn:async e=>{await n(s.id,{content:e})}}),N=null!==(a=null!==(t=null!=c?c:null==f?void 0:f.message)&&void 0!==t?t:null==j?void 0:j.message)&&void 0!==a?a:null,C=(0,l.useCallback)(e=>{m(e.target.value)},[]),S=(0,l.useCallback)(e=>{h(e.target.value)},[]),T=(0,l.useCallback)(()=>{k()},[k]),E=(0,l.useCallback)(()=>{w()},[w]),M=(0,l.useCallback)(()=>{o(s.id)},[s.id,o]),L=(0,l.useCallback)(async()=>{if(x.trim())try{await (0,V.v)(x),p(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>p(!1),2e3)}catch(e){}},[x]);return(0,r.jsxs)("div",{"data-testid":"memo-card",className:"bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg p-4 space-y-3 ".concat(d),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"text",value:u,onChange:C,onBlur:T,placeholder:"Memo title",className:"flex-1 text-sm font-medium text-gray-900 dark:text-gray-100 bg-transparent border-none focus:outline-none focus:ring-0 p-0"}),(null!=i?i:b||v)&&(0,r.jsx)("span",{"data-testid":"saving-indicator",className:"text-xs text-gray-400 dark:text-gray-500",children:"Saving..."}),(0,r.jsx)("button",{type:"button",onClick:L,"aria-label":"Copy memo content",className:"p-1 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 transition-colors rounded",children:g?(0,r.jsx)(eG.Z,{className:"w-4 h-4 text-green-600"}):(0,r.jsx)(F.Z,{className:"w-4 h-4"})}),(0,r.jsx)("button",{type:"button",onClick:M,"aria-label":"Delete memo",className:"p-1 text-gray-400 dark:text-gray-500 hover:text-red-500 transition-colors rounded",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}),(0,r.jsx)("textarea",{value:x,onChange:S,onBlur:E,placeholder:"Enter memo content...",rows:4,className:"w-full text-sm text-gray-700 dark:text-gray-200 bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md p-2 resize-y focus:outline-none focus:ring-2 focus:ring-cyan-500 focus:border-transparent"}),N&&(0,r.jsx)("div",{className:"text-xs text-red-500",children:N})]})}),e4=(0,l.memo)(function(e){let{currentCount:t,maxCount:a,onAdd:s,isLoading:n=!1,className:l=""}=e,o=t>=a||n;return(0,r.jsxs)("div",{"data-testid":"memo-add-button",className:"flex flex-col items-center gap-2 ".concat(l),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{o||s()},disabled:o,"aria-label":"Add Memo","aria-disabled":o,className:"\n flex items-center gap-2 px-4 py-2 rounded-lg border-2 border-dashed\n transition-colors focus:outline-none focus:ring-2 focus:ring-cyan-500\n ".concat(o?"border-gray-200 dark:border-gray-700 text-gray-400 dark:text-gray-500 cursor-not-allowed opacity-50":"border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-300 hover:border-cyan-400 dark:hover:border-cyan-500 hover:text-cyan-600 dark:hover:text-cyan-400 hover:bg-cyan-50 dark:hover:bg-cyan-900/30","\n "),children:[n?(0,r.jsx)("span",{"data-testid":"loading-indicator",className:"w-5 h-5 border-2 border-gray-300 dark:border-gray-600 border-t-cyan-500 rounded-full animate-spin"}):(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Add Memo"})]}),(0,r.jsxs)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[Math.max(0,a-t)," remaining"]})]})}),e5=(0,l.memo)(function(e){let{worktreeId:t,className:a=""}=e,[s,n]=(0,l.useState)([]),[o,i]=(0,l.useState)(!0),[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),[x,h]=(0,l.useState)(null),g=(0,l.useCallback)(async()=>{i(!0),m(null);try{let e=await e0.nE.getAll(t);n(e.sort((e,t)=>e.position-t.position))}catch(e){m((0,e0.zG)(e))}finally{i(!1)}},[t]);(0,l.useEffect)(()=>{g()},[g]);let p=(0,l.useCallback)(async()=>{d(!0),h(null);try{let e=await e0.nE.create(t,{title:"Memo",content:""});n(t=>[...t,e])}catch(e){h((0,e0.zG)(e))}finally{d(!1)}},[t]),y=(0,l.useCallback)(async(e,a)=>{await e0.nE.update(t,e,a),n(t=>t.map(t=>t.id===e?{...t,...a}:t))},[t]),b=(0,l.useCallback)(async e=>{try{await e0.nE.delete(t,e),n(t=>t.filter(t=>t.id!==e))}catch(e){console.error("Failed to delete memo:",e)}},[t]),f=(0,l.useCallback)(()=>{g()},[g]);return o?(0,r.jsx)("div",{"data-testid":"memo-pane",className:"flex flex-col items-center justify-center h-full p-4 ".concat(a),children:(0,r.jsxs)("div",{"data-testid":"memo-loading",className:"flex flex-col items-center gap-3",children:[(0,r.jsx)("div",{className:"w-8 h-8 border-4 border-gray-200 dark:border-gray-700 border-t-cyan-500 rounded-full animate-spin"}),(0,r.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading memos..."})]})}):u?(0,r.jsx)("div",{"data-testid":"memo-pane",className:"flex flex-col items-center justify-center h-full p-4 ".concat(a),children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[(0,r.jsx)("svg",{className:"w-12 h-12 text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("span",{className:"text-sm text-red-600 dark:text-red-400",children:u}),(0,r.jsx)("button",{type:"button",onClick:f,"aria-label":"Retry",className:"px-4 py-2 text-sm font-medium text-white bg-cyan-500 rounded-lg hover:bg-cyan-600 transition-colors",children:"Retry"})]})}):(0,r.jsxs)("div",{"data-testid":"memo-pane",className:"flex flex-col gap-4 p-4 overflow-y-auto ".concat(a),children:[0===s.length&&!x&&(0,r.jsxs)("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:[(0,r.jsx)("p",{children:"No memos yet."}),(0,r.jsx)("p",{className:"text-sm",children:"Click the button below to add one."})]}),s.map(e=>(0,r.jsx)(e2,{memo:e,onUpdate:y,onDelete:b},e.id)),x&&(0,r.jsx)("div",{className:"text-center py-2 text-sm text-red-500",children:x}),(0,r.jsx)(e4,{currentCount:s.length,maxCount:5,onAdd:p,isLoading:c,className:"mt-2"})]})});function e3(e){return new Date(e).toLocaleString()}let e6=(0,l.memo)(function(e){let{worktreeId:t,className:a=""}=e,s=(0,y.T)("schedule"),[n,o]=(0,l.useState)([]),[i,c]=(0,l.useState)([]),[d,u]=(0,l.useState)(!0),[m,x]=(0,l.useState)(null),[h,g]=(0,l.useState)(null),[p,b]=(0,l.useState)(null),f=(0,l.useCallback)(async()=>{u(!0),x(null);try{let[e,a]=await Promise.all([fetch("/api/worktrees/".concat(t,"/execution-logs")),fetch("/api/worktrees/".concat(t,"/schedules"))]);if(e.ok){let t=await e.json();o(t.logs||[])}if(a.ok){let e=await a.json();c(e.schedules||[])}}catch(e){x(e instanceof Error?e.message:"Failed to fetch data")}finally{u(!1)}},[t]);(0,l.useEffect)(()=>{f()},[f]);let k=(0,l.useCallback)(async e=>{if(h===e){g(null),b(null);return}try{let a=await fetch("/api/worktrees/".concat(t,"/execution-logs/").concat(e));if(a.ok){let t=await a.json();b(t.log),g(e)}}catch(e){console.error("Failed to fetch log detail:",e)}},[t,h]);return d?(0,r.jsx)("div",{className:"flex items-center justify-center h-full p-4 ".concat(a),children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)("div",{className:"w-8 h-8 border-4 border-gray-200 dark:border-gray-700 border-t-cyan-500 rounded-full animate-spin"}),(0,r.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("loading")})]})}):m?(0,r.jsx)("div",{className:"flex items-center justify-center h-full p-4 ".concat(a),children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("span",{className:"text-sm text-red-600 dark:text-red-400",children:m}),(0,r.jsx)("button",{type:"button",onClick:()=>void f(),className:"ml-2 px-3 py-1 text-sm text-white bg-cyan-500 rounded hover:bg-cyan-600",children:s("retry")})]})}):(0,r.jsxs)("div",{className:"flex flex-col gap-4 p-4 overflow-y-auto ".concat(a),children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200 mb-2",children:[s("title")," (",i.length,")"]}),0===i.length?(0,r.jsxs)("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:[(0,r.jsx)("p",{className:"font-medium text-gray-600 dark:text-gray-300 mb-3",children:s("noSchedulesTitle")}),(0,r.jsxs)("ol",{className:"text-sm text-left inline-block space-y-1.5 list-decimal list-inside",children:[(0,r.jsx)("li",{children:s("noSchedulesStep1")}),(0,r.jsx)("li",{children:s("noSchedulesStep2")}),(0,r.jsx)("li",{children:s("noSchedulesStep3")}),(0,r.jsx)("li",{children:s("noSchedulesStep4")})]})]}):(0,r.jsx)("div",{className:"space-y-2",children:i.map(e=>(0,r.jsxs)("div",{className:"border border-gray-200 dark:border-gray-700 rounded p-3 bg-white dark:bg-gray-900",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"font-medium text-sm",children:e.name}),(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded ".concat(e.enabled?"bg-green-50 dark:bg-green-900/30 text-green-600 dark:text-green-400":"bg-gray-50 dark:bg-gray-800 text-gray-500 dark:text-gray-400"),children:e.enabled?s("enabled"):s("disabled")})]}),(0,r.jsxs)("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[(0,r.jsxs)("span",{children:[s("cron"),": ",e.cron_expression||"N/A"]}),e.last_executed_at&&(0,r.jsxs)("span",{className:"ml-3",children:[s("lastRun"),": ",e3(e.last_executed_at)]})]})]},e.id))})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200 mb-2",children:[s("executionLogs")," (",n.length,")"]}),0===n.length?(0,r.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("noLogs")}):(0,r.jsx)("div",{className:"space-y-2",children:n.map(e=>(0,r.jsxs)("div",{className:"border border-gray-200 dark:border-gray-700 rounded bg-white dark:bg-gray-900",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>void k(e.id),className:"w-full text-left p-3 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-sm truncate max-w-[60%]",children:e.schedule_name||s("unknownSchedule")}),(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded ".concat(function(e){switch(e){case"completed":return"text-green-600 dark:text-green-400 bg-green-50 dark:bg-green-900/30";case"failed":return"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/30";case"timeout":return"text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-900/30";case"running":return"text-cyan-600 dark:text-cyan-400 bg-cyan-50 dark:bg-cyan-900/30";case"cancelled":return"text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-800"}}(e.status)),children:s("status.".concat(e.status))})]}),(0,r.jsxs)("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[e3(e.started_at),null!==e.exit_code&&(0,r.jsxs)("span",{className:"ml-2",children:[s("exitCode"),": ",e.exit_code]})]})]}),h===e.id&&p&&(0,r.jsxs)("div",{className:"border-t border-gray-200 dark:border-gray-700 p-3 bg-gray-50 dark:bg-gray-800 space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-gray-600 dark:text-gray-300 mb-1",children:s("message")}),(0,r.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-gray-700 dark:text-gray-200",children:p.message})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-gray-600 dark:text-gray-300 mb-1",children:s("response")}),(0,r.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-gray-700 dark:text-gray-200 max-h-60 overflow-y-auto",children:p.result||s("noOutput")})]})]})]},e.id))})]})]})});var e8=a(74707);let e7=(0,l.memo)(function(e){let{worktreeId:t,selectedAgents:a,onSelectedAgentsChange:s,vibeLocalModel:n,onVibeLocalModelChange:o,vibeLocalContextWindow:i,onVibeLocalContextWindowChange:c}=e,d=(0,y.T)("schedule"),[u,m]=(0,l.useState)(()=>new Set(a)),[x,h]=(0,l.useState)(!1),[g,p]=(0,l.useState)(!1),[b,f]=(0,l.useState)([]),[k,v]=(0,l.useState)(null),[j,w]=(0,l.useState)(!1),[N,C]=(0,l.useState)(!1),[S,T]=(0,l.useState)(null!=i?String(i):""),[E,M]=(0,l.useState)(!1),L=(0,l.useRef)(u);L.current=u,(0,l.useEffect)(()=>{g||m(new Set(a))},[a,g]),(0,l.useEffect)(()=>{T(null!=i?String(i):"")},[i]);let R=u.has("vibe-local");(0,l.useEffect)(()=>{if(!R){f([]),v(null);return}let e=!1;return w(!0),fetch("/api/ollama/models").then(e=>e.json()).then(t=>{e||(f(t.models),v(0===t.models.length&&t.error?t.error:null))}).catch(()=>{e||(f([]),v("Failed to fetch models"))}).finally(()=>{e||w(!1)}),()=>{e=!0}},[R]);let A=(0,l.useCallback)(async(e,r)=>{let n=new Set(L.current);if(r?n.add(e):(n.delete(e),p(!0)),m(n),2===n.size){let e=Array.from(n);h(!0);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({selectedAgents:e})})).ok?(m(new Set(e)),s(e)):m(new Set(a))}catch(e){m(new Set(a))}finally{h(!1),p(!1)}}},[t,a,s]),F=(0,l.useCallback)(async e=>{let a=e.target.value,r=""===a?null:a;C(!0);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({vibeLocalModel:r})})).ok&&o(r)}catch(e){}finally{C(!1)}},[t,o]),P=(0,l.useCallback)(e=>{T(e.target.value)},[]),D=(0,l.useCallback)(async()=>{let e=S.trim(),a=parseInt(e,10),r=""===e?null:Number.isNaN(a)?null:a,s=null!=i?i:null;if(r!==s){M(!0);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({vibeLocalContextWindow:r})})).ok?null==c||c(r):T(null!=s?String(s):"")}catch(e){T(null!=s?String(s):"")}finally{M(!1)}}},[S,i,t,c]),O=u.size>=2;return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200 mb-1",children:d("agentSettings")}),(0,r.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-4",children:d("selectAgents")}),(0,r.jsx)("div",{className:"space-y-3",children:e8.tK.map(e=>{let t=u.has(e),a=!t&&O;return(0,r.jsxs)("label",{className:"flex items-center gap-3 p-2 rounded-lg border transition-colors ".concat(t?"border-cyan-200 dark:border-cyan-700 bg-cyan-50 dark:bg-cyan-900/30":a?"border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-800 opacity-50":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-800"),children:[(0,r.jsx)("input",{type:"checkbox","data-testid":"agent-checkbox-".concat(e),"aria-label":(0,e8.Ds)(e),checked:t,disabled:a||x,onChange:t=>A(e,t.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-cyan-600 focus:ring-cyan-500"}),(0,r.jsx)("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(0,e8.Ds)(e)})]},e)})}),x&&(0,r.jsxs)("div",{"data-testid":"agent-settings-loading",className:"mt-3 flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:[(0,r.jsx)("span",{className:"w-3 h-3 border-2 border-cyan-500 border-t-transparent rounded-full animate-spin"}),d("loading")]}),R&&(0,r.jsxs)("div",{className:"mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200 mb-2",children:d("vibeLocalModel")}),j?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:[(0,r.jsx)("span",{className:"w-3 h-3 border-2 border-cyan-500 border-t-transparent rounded-full animate-spin"}),d("loading")]}):k&&0===b.length?(0,r.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:d("ollamaNotAvailable")}):(0,r.jsxs)("select",{"data-testid":"vibe-local-model-select",value:null!=n?n:"",onChange:F,disabled:N,className:"w-full text-sm border border-gray-300 dark:border-gray-600 rounded-md px-3 py-2 bg-white dark:bg-gray-800 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-cyan-500 focus:border-cyan-500 disabled:opacity-50",children:[(0,r.jsx)("option",{value:"",children:d("vibeLocalModelDefault")}),b.map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name,e.parameterSize?" (".concat(e.parameterSize,")"):""]},e.name))]}),(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200 mb-2",children:d("vibeLocalContextWindow")}),(0,r.jsx)("input",{type:"number","data-testid":"vibe-local-context-window-input",step:"1",min:e8.Ho,max:e8.Ns,value:S,onChange:P,onBlur:D,placeholder:d("vibeLocalContextWindowDefault"),disabled:E,className:"w-full text-sm border border-gray-300 dark:border-gray-600 rounded-md px-3 py-2 bg-white dark:bg-gray-800 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-cyan-500 focus:border-cyan-500 disabled:opacity-50"})]})]})]})}),e9=[{id:"notes",labelKey:"notes"},{id:"logs",labelKey:"logs"},{id:"agent",labelKey:"agentTab"}],te=(0,l.memo)(function(e){let{worktreeId:t,className:a="",selectedAgents:s,onSelectedAgentsChange:n,vibeLocalModel:o,onVibeLocalModelChange:i,vibeLocalContextWindow:c,onVibeLocalContextWindowChange:d}=e,u=(0,y.T)("schedule"),[m,x]=(0,l.useState)("notes"),h=(0,l.useCallback)(e=>{x(e)},[]);return(0,r.jsxs)("div",{className:"flex flex-col h-full ".concat(a),children:[(0,r.jsx)("div",{className:"flex border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 flex-shrink-0",children:e9.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>h(e.id),className:"flex-1 px-3 py-2 text-sm font-medium transition-colors ".concat(m===e.id?"text-cyan-600 dark:text-cyan-400 border-b-2 border-cyan-600 dark:border-cyan-400 bg-cyan-50 dark:bg-cyan-900/30":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800"),children:u(e.labelKey)},e.id))}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["notes"===m&&(0,r.jsx)(e5,{worktreeId:t,className:"h-full"}),"logs"===m&&(0,r.jsx)(e6,{worktreeId:t,className:"h-full"}),"agent"===m&&(0,r.jsx)(e7,{worktreeId:t,selectedAgents:s,onSelectedAgentsChange:n,vibeLocalModel:o,onVibeLocalModelChange:i,vibeLocalContextWindow:c,onVibeLocalContextWindowChange:d})]})]})});var tt=a(43616);function ta(){let[e,t]=(0,l.useState)(null),[a,r]=(0,l.useState)(!0),[s,n]=(0,l.useState)(null);return(0,l.useEffect)(()=>{let e=!1;return async function(){try{r(!0),n(null);let a=await e0.Bb.checkForUpdate();e||t(a)}catch(t){e||n(t instanceof Error?t.message:"Failed to check for updates")}finally{e||r(!1)}}(),()=>{e=!0}},[]),{data:e,loading:a,error:s}}function tr(e){let{hasUpdate:t,latestVersion:a,releaseUrl:s,updateCommand:n,installType:l}=e,o=(0,y.T)("worktree");return t?(0,r.jsxs)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3 mt-2",role:"status","aria-label":o("update.available"),"data-testid":"update-notification-banner",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-blue-800 mb-1",children:o("update.available")}),a&&(0,r.jsx)("p",{className:"text-sm text-blue-700 mb-2",children:o("update.latestVersion",{version:a})}),n&&"global"===l&&(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("p",{className:"text-xs text-blue-600 mb-1",children:o("update.updateCommand")}),(0,r.jsx)("code",{className:"block bg-blue-100 rounded px-2 py-1 text-xs text-blue-900 font-mono",children:n})]}),s&&(0,r.jsxs)("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-blue-600 hover:text-blue-800 underline",children:[o("update.viewRelease"),(0,r.jsx)("span",{className:"ml-1","aria-hidden":"true",children:"→"})]}),(0,r.jsx)("p",{className:"text-xs text-blue-500 mt-2",children:o("update.dataPreserved")})]}):null}function ts(e){let{version:t,className:a}=e,s=(0,y.T)("worktree"),{data:n,loading:o}=ta(),i=(0,l.useMemo)(()=>n&&n.hasUpdate?{hasUpdate:n.hasUpdate,latestVersion:n.latestVersion,releaseUrl:n.releaseUrl,updateCommand:n.updateCommand,installType:n.installType}:null,[n]);return(0,r.jsxs)("div",{className:a,"data-testid":"version-section",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:s("update.version")}),(0,r.jsx)("p",{className:"text-sm text-gray-700",children:t}),o&&(0,r.jsx)("p",{className:"text-xs text-gray-400 mt-1","data-testid":"version-loading",children:"..."}),i&&(0,r.jsx)(tr,{...i})]})}let tn="https://github.com/Kewton/CommandMate",tl="".concat(tn,"/issues"),to="".concat(tn,"/issues/new"),ti="".concat(to,"?template=bug_report.md"),tc="".concat(to,"?template=feature_request.md"),td="".concat(to,"?template=question.md");function tu(e){let{className:t}=e,a=(0,y.T)("worktree"),s=[{href:ti,label:a("feedback.bugReport")},{href:tc,label:a("feedback.featureRequest")},{href:td,label:a("feedback.question")},{href:tl,label:a("feedback.viewIssues")}];return(0,r.jsxs)("div",{className:t,"data-testid":"feedback-section",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-gray-500 mb-2",children:a("feedback.title")}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:s.map(e=>{let{href:t,label:a}=e;return(0,r.jsxs)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-blue-600 hover:text-blue-800 underline",children:[a,(0,r.jsx)("span",{className:"ml-1","aria-hidden":"true",children:"→"})]},t)})})]})}var tm=a(98702);function tx(e,t,a){let r={answer:e,cliTool:t};if(a&&(r.promptType=a.type,"multiple_choice"===a.type)){let e=a.options.find(e=>e.isDefault);e&&(r.defaultOptionNumber=e.number)}return r}var th=a(55125),tg=a.n(th);let tp=[36e5,108e5,288e5],ty={36e5:"autoYes.durations.1h",108e5:"autoYes.durations.3h",288e5:"autoYes.durations.8h"};function tb(e){let{isOpen:t,onConfirm:a,onCancel:s,cliToolName:n}=e,o=(0,y.T)("autoYes"),i=(0,y.T)("common"),[c,d]=(0,l.useState)(36e5),[u,m]=(0,l.useState)(""),[x,h]=(0,l.useState)(null),[g,p]=(0,l.useState)(!1),b=(0,l.useRef)(null),f=e=>o(ty[e].replace("autoYes.",""));return(0,l.useEffect)(()=>{t&&(m(""),h(null),p(!1))},[t]),(0,l.useEffect)(()=>{if(!g)return;let e=e=>{b.current&&!b.current.contains(e.target)&&p(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[g]),(0,l.useEffect)(()=>{if(!u.trim()){h(null);return}let e=function(e){if(e.length>500)return{valid:!1,error:"Pattern must be ".concat(500," characters or less")};if(!tg()(e))return{valid:!1,error:"Pattern may cause performance issues (catastrophic backtracking detected)"};try{return new RegExp(e),{valid:!0}}catch(e){return{valid:!1,error:"Invalid regular expression syntax"}}}(u.trim());if(e.valid)h(null);else{var t;h(null!==(t=e.error)&&void 0!==t?t:o("invalidRegexPattern"))}},[u,o]),(0,r.jsx)(tm.u,{isOpen:t,onClose:s,title:n?o("enableTitleWithTool",{toolName:n}):o("enableTitle"),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"text-sm text-gray-700 dark:text-gray-200",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:o("featureDescription")}),(0,r.jsxs)("ul",{className:"list-disc list-inside space-y-1",children:[(0,r.jsx)("li",{children:o("yesNoAutoResponse")}),(0,r.jsx)("li",{children:o("multipleChoiceAutoSelect")})]}),(0,r.jsx)("p",{className:"mt-1",children:o("autoDisableAfter",{duration:f(c)})}),n&&(0,r.jsx)("p",{className:"mt-2 text-gray-500 dark:text-gray-300",children:o("appliesOnlyToCurrent",{toolName:n})})]}),(0,r.jsxs)("div",{className:"text-sm text-gray-700 dark:text-gray-200",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:o("duration")}),(0,r.jsx)("div",{className:"flex gap-2",children:tp.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>d(e),className:"flex-1 py-2 px-3 text-sm font-medium rounded-md border-2 transition-colors ".concat(c===e?"border-cyan-600 bg-cyan-50 dark:bg-cyan-900/30 text-cyan-700 dark:text-cyan-400":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:border-gray-400 dark:hover:border-gray-500"),style:{minHeight:"44px"},children:f(e)},e))})]}),(0,r.jsxs)("div",{className:"text-sm text-gray-700 dark:text-gray-200",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)("label",{htmlFor:"stop-pattern-input",className:"font-medium",children:o("stopPatternLabel")}),(0,r.jsxs)("div",{className:"relative",ref:b,children:[(0,r.jsx)("button",{type:"button",onClick:()=>p(!g),className:"inline-flex items-center justify-center w-4 h-4 rounded-full bg-gray-300 dark:bg-gray-600 text-gray-600 dark:text-gray-200 text-[10px] font-bold hover:bg-gray-400 dark:hover:bg-gray-500 focus:outline-none","aria-label":o("regexTipsLabel"),"data-testid":"regex-tips-button",children:"?"}),g&&(0,r.jsxs)("div",{className:"absolute left-0 top-6 z-50 w-72 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 p-3 shadow-lg text-xs text-gray-700 dark:text-gray-200","data-testid":"regex-tips-tooltip",children:[(0,r.jsx)("p",{className:"font-medium mb-1.5",children:o("regexTipsTitle")}),(0,r.jsxs)("ul",{className:"space-y-1",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-gray-100 dark:bg-gray-700 px-1 rounded",children:"\\bcat\\b"})," ",o("regexTipWordBoundary")]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-gray-100 dark:bg-gray-700 px-1 rounded",children:"error|fatal"})," ",o("regexTipOr")]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-gray-100 dark:bg-gray-700 px-1 rounded",children:"(?i)error"})," ",o("regexTipCaseNote")]})]})]})]})]}),(0,r.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-300 mb-2",children:o("stopPatternDescription")}),(0,r.jsx)("input",{id:"stop-pattern-input",type:"text",value:u,onChange:e=>m(e.target.value),placeholder:o("stopPatternPlaceholder"),className:"w-full px-3 py-2 border rounded-md text-sm font-mono dark:bg-gray-800 dark:text-gray-100 ".concat(x?"border-red-500 focus:ring-red-500 focus:border-red-500":"border-gray-300 dark:border-gray-600 focus:ring-cyan-500 focus:border-cyan-500"," focus:outline-none focus:ring-1"),"data-testid":"stop-pattern-input"}),x&&(0,r.jsx)("p",{className:"mt-1 text-xs text-red-600","data-testid":"stop-pattern-error",children:x})]}),(0,r.jsxs)("div",{className:"text-sm text-gray-700 dark:text-gray-200",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:o("aboutRisks")}),(0,r.jsx)("p",{children:o("riskWarning")})]}),(0,r.jsx)("div",{className:"bg-yellow-50 dark:bg-yellow-900/30 border-l-4 border-yellow-400 dark:border-yellow-600 p-3",children:(0,r.jsxs)("p",{className:"text-sm text-yellow-800 dark:text-yellow-300",children:[(0,r.jsx)("span",{className:"font-medium",children:o("disclaimer")}),o("disclaimerText")]})}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:s,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200",children:i("cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>{a(c,u.trim()||void 0)},disabled:!!x,className:"px-4 py-2 text-sm font-medium rounded-md text-white ".concat(x?"bg-gray-400 cursor-not-allowed":"bg-yellow-600 hover:bg-yellow-700"),"data-testid":"confirm-button",children:o("agreeAndEnable")})]})]})})}let tf=(0,l.memo)(function(e){let{enabled:t,expiresAt:a,onToggle:s,lastAutoResponse:n,cliToolName:o,inline:i=!1}=e,[c,d]=(0,l.useState)(""),[u,m]=(0,l.useState)(null),[x,h]=(0,l.useState)(!1),[g,p]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(!t||!a){d("");return}let e=()=>{d(function(e){let t=Math.max(0,e-Date.now()),a=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return a>0?"".concat(a,":").concat(r.toString().padStart(2,"0"),":").concat(s.toString().padStart(2,"0")):"".concat(r.toString().padStart(2,"0"),":").concat(s.toString().padStart(2,"0"))}(a))};e();let r=setInterval(e,1e3);return()=>clearInterval(r)},[t,a]),(0,l.useEffect)(()=>{if(!n)return;m('Auto responded: "'.concat(n,'"'));let e=setTimeout(()=>m(null),2e3);return()=>clearTimeout(e)},[n]);let y=(0,l.useCallback)(()=>{t?(h(!0),s({enabled:!1}).finally(()=>h(!1))):p(!0)},[t,s]),b=(0,l.useCallback)((e,t)=>{p(!1),h(!0),s({enabled:!0,duration:e,stopPattern:t}).finally(()=>h(!1))},[s]),f=(0,l.useCallback)(()=>{p(!1)},[]);return(0,r.jsxs)("div",{className:i?"flex items-center gap-2":"flex items-center gap-3 px-4 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":t,"aria-label":"Auto Yes mode",disabled:x,onClick:y,className:"relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-cyan-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 ".concat(t?"bg-cyan-600":"bg-gray-300 dark:bg-gray-600"," ").concat(x?"opacity-50":""),children:(0,r.jsx)("span",{className:"inline-block h-4 w-4 transform rounded-full bg-white transition-transform ".concat(t?"translate-x-6":"translate-x-1")})}),(0,r.jsx)("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Auto Yes"}),t&&o&&(0,r.jsxs)("span",{className:"text-xs text-cyan-600 dark:text-cyan-400 font-medium","aria-label":"Auto Yes target",children:["(",(0,e8.ts)(o,""),")"]}),t&&c&&(0,r.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400","aria-label":"Time remaining",children:c}),u&&(0,r.jsx)("span",{className:"text-sm text-green-600 dark:text-green-400 animate-pulse",children:u}),(0,r.jsx)(tb,{isOpen:g,onConfirm:b,onCancel:f,cliToolName:(0,e8.ts)(o,"")})]})});var tk=a(76865),tv=a(32489);let tj=(0,l.memo)(function(e){let{isBranchMismatch:t,currentBranch:a,initialBranch:s}=e,[n,o]=(0,l.useState)(!1);return((0,l.useEffect)(()=>{o(!1)},[a]),!t||n||null===s)?null:(0,r.jsxs)("div",{"data-testid":"branch-mismatch-alert",role:"alert",className:"flex items-center gap-3 px-4 py-2 bg-amber-50 border border-amber-200 text-amber-800 rounded-lg",children:[(0,r.jsx)(tk.Z,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsxs)("span",{className:"text-sm",children:["Branch changed from"," ",(0,r.jsx)("span",{className:"font-medium",children:s})," ","to"," ",(0,r.jsx)("span",{className:"font-medium",children:a})]})}),(0,r.jsx)("button",{type:"button",onClick:()=>o(!0),className:"p-1 rounded hover:bg-amber-100 transition-colors","aria-label":"Dismiss alert",children:(0,r.jsx)(tv.Z,{className:"w-4 h-4"})})]})});var tw=a(87348),tN=a(47712),tC=a(10407),tS=a(56475),tT=a(14924);let tE=(0,l.memo)(function(e){let{isOpen:t,onClose:a,onConfirm:s,worktreeId:n,sourcePath:o,sourceType:c}=e,d=(0,y.T)("worktree"),u=(0,y.T)("common"),[m,x]=(0,l.useState)(""),[h,g]=(0,l.useState)(new Set([""])),[p,b]=(0,l.useState)([]),[f,k]=(0,l.useState)(!1),[v,j]=(0,l.useState)(new Set),w=o.includes("/")?o.substring(0,o.lastIndexOf("/")):"";(0,l.useEffect)(()=>{t&&(x(w),g(new Set([""])),b([]),N())},[t,n]);let N=(0,l.useCallback)(async()=>{k(!0);try{let e=await fetch("/api/worktrees/".concat(n,"/tree"));if(!e.ok)return;let t=(await e.json()).items.filter(e=>"directory"===e.type).map(e=>({name:e.name,path:e.name,loaded:!1}));b(t)}catch(e){}finally{k(!1)}},[n]),C=(0,l.useCallback)(async e=>{j(t=>new Set(t).add(e));try{let t=await fetch("/api/worktrees/".concat(n,"/tree/").concat(e));if(!t.ok)return;let a=(await t.json()).items.filter(e=>"directory"===e.type).map(t=>({name:t.name,path:"".concat(e,"/").concat(t.name),loaded:!1}));b(t=>(function e(t,a,r){return t.map(t=>t.path===a?{...t,children:r,loaded:!0}:t.children?{...t,children:e(t.children,a,r)}:t)})(t,e,a))}catch(e){}finally{j(t=>{let a=new Set(t);return a.delete(e),a})}},[n]),S=(0,l.useCallback)(async e=>{g(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a});let t=function e(t,a){for(let r of t){if(r.path===a)return r;if(r.children){let t=e(r.children,a);if(t)return t}}return null}(p,e);t&&!t.loaded&&await C(e)},[p,C]),T=(0,l.useCallback)(e=>!(e===w||"directory"===c&&(e===o||e.startsWith(o+"/"))),[w,o,c]),E=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=h.has(e.path),s=m===e.path,n=v.has(e.path),l=T(e.path);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 py-1.5 px-2 cursor-pointer rounded text-sm transition-colors ".concat(s?"bg-blue-100 text-blue-800":"hover:bg-gray-100 text-gray-700"," ").concat(l?"":"opacity-40 cursor-not-allowed"),style:{paddingLeft:"".concat(.5+1.25*t,"rem")},onClick:()=>{l&&x(e.path)},children:[(0,r.jsx)("button",{className:"w-4 h-4 flex items-center justify-center flex-shrink-0",onClick:t=>{t.stopPropagation(),S(e.path)},children:n?(0,r.jsx)(i.Z,{className:"w-3 h-3 animate-spin text-gray-400"}):(0,r.jsx)(tC.Z,{className:"w-3 h-3 text-gray-400 transition-transform ".concat(a?"rotate-90":"")})}),a?(0,r.jsx)(tS.Z,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}):(0,r.jsx)(tT.Z,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:e.name})]}),a&&e.children&&(0,r.jsx)("div",{children:e.children.map(e=>E(e,t+1))})]},e.path)},M=T(m);return(0,r.jsx)(tm.u,{isOpen:t,onClose:a,title:d("fileTree.moveDialogTitle"),size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"text-sm text-gray-600",children:[d("fileTree.moveTo"),": ",(0,r.jsx)("span",{className:"font-mono text-gray-800",children:o})]}),(0,r.jsxs)("div",{className:"border border-gray-200 rounded-lg max-h-64 overflow-y-auto p-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 py-1.5 px-2 cursor-pointer rounded text-sm transition-colors ".concat(""===m?"bg-blue-100 text-blue-800":"hover:bg-gray-100 text-gray-700"," ").concat(T("")?"":"opacity-40 cursor-not-allowed"),onClick:()=>{T("")&&x("")},children:[(0,r.jsx)("span",{className:"w-4 h-4"}),(0,r.jsx)(tT.Z,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}),(0,r.jsx)("span",{children:d("fileTree.rootDirectory")})]}),f?(0,r.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,r.jsx)(i.Z,{className:"w-5 h-5 animate-spin text-gray-400"})}):p.map(e=>E(e,1))]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{onClick:a,className:"px-4 py-2 text-sm text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors",children:u("cancel")}),(0,r.jsx)("button",{onClick:()=>s(m),disabled:!M,className:"px-4 py-2 text-sm text-white bg-blue-600 rounded-md hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:d("fileTree.moveConfirm")})]})]})})});function tM(e){return e?e.split("/").map(encodeURIComponent).join("/"):""}let tL=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F\x80-\x9F\u200B-\u200F\u2028-\u202F\uFEFF]/;function tR(e){return e.replace(RegExp(tL.source,"g"),"")}let tA=/^[\w\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\uF900-\uFAFF\s-]{1,100}$/,tF=["default","acceptEdits","plan","dontAsk","bypassPermissions"],tP=["read-only","workspace-write","danger-full-access"],tD=["Name","Cron","Message","CLI Tool","Enabled"],tO=["Permission"],tI="## Schedules\n\n| Name | Cron | Message | CLI Tool | Enabled | Permission |\n|------|------|---------|----------|---------|------------|\n| example-task | 0 * * * * | README.mdを要約してください | claude | true | acceptEdits |\n",t_=(0,o.default)(()=>Promise.all([a.e(7851),a.e(3398),a.e(3516),a.e(4012)]).then(a.bind(a,64012)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[64012]},ssr:!1,loading:()=>(0,r.jsxs)("div",{className:"flex items-center justify-center h-full bg-white dark:bg-gray-900 text-gray-400 dark:text-gray-500",children:[(0,r.jsx)(i.Z,{className:"animate-spin h-6 w-6 mr-2"}),(0,r.jsx)("span",{children:"Loading editor..."})]})}),tW="v".concat("0.4.0");function tz(e,t,a,r){let[s,n]=(0,l.useState)(!1),[o,i]=(0,l.useState)(""),[c,d]=(0,l.useState)(!1);(0,l.useEffect)(()=>{r()&&e&&(i(e.description||""),n(!1))},[a,e]);let u=(0,l.useCallback)(async()=>{if(e){d(!0);try{let a=await e0.Iv.updateDescription(e.id,o);t(a),n(!1)}catch(e){console.error("Failed to save description:",e)}finally{d(!1)}}},[e,o,t]),m=(0,l.useCallback)(()=>{i((null==e?void 0:e.description)||""),n(!1)},[e]);return{isEditing:s,text:o,setText:i,isSaving:c,handleSave:u,handleCancel:m,startEditing:(0,l.useCallback)(()=>{n(!0)},[])}}let tB=(0,l.memo)(function(e){let{worktreeId:t,worktree:a,cardClassName:s,descriptionEditor:n,showLogs:l,onToggleLogs:o}=e,{isEditing:i,text:c,setText:d,isSaving:u,handleSave:m,handleCancel:x,startEditing:h}=n;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:s,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Worktree"}),(0,r.jsx)("p",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:a.name})]}),(0,r.jsxs)("div",{className:s,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Repository"}),(0,r.jsx)("p",{className:"text-base text-gray-900 dark:text-gray-100",children:a.repositoryName}),(0,r.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 break-all",children:a.repositoryPath})]}),(0,r.jsxs)("div",{className:s,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Path"}),(0,r.jsx)("p",{className:"text-sm text-gray-700 dark:text-gray-300 break-all font-mono",children:a.path})]}),a.status&&(0,r.jsxs)("div",{className:s,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Status"}),(0,r.jsx)("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ".concat("done"===a.status?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300":"doing"===a.status?"bg-cyan-100 text-cyan-800 dark:bg-cyan-900 dark:text-cyan-300":"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300"),children:a.status.toUpperCase()})]}),(0,r.jsxs)("div",{className:s,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Description"}),!i&&(0,r.jsx)("button",{type:"button",onClick:h,className:"text-sm text-cyan-600 hover:text-cyan-800 dark:text-cyan-400 dark:hover:text-cyan-300",children:"Edit"})]}),i?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("textarea",{value:c,onChange:e=>d(e.target.value),placeholder:"Add notes about this branch...",className:"w-full min-h-[150px] p-3 border border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100 rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-cyan-500 focus:border-transparent",autoFocus:!0}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:m,disabled:u,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm font-medium",children:u?"Saving...":"Save"}),(0,r.jsx)("button",{type:"button",onClick:x,disabled:u,className:"px-4 py-2 bg-gray-200 text-gray-700 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600 rounded-lg hover:bg-gray-300 disabled:opacity-50 text-sm font-medium",children:"Cancel"})]})]}):(0,r.jsx)("div",{className:"min-h-[50px]",children:a.description?(0,r.jsx)("p",{className:"text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:a.description}):(0,r.jsx)("p",{className:"text-sm text-gray-400 italic",children:"No description added yet"})})]}),a.link&&(0,r.jsxs)("div",{className:s,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Link"}),(0,r.jsx)("a",{href:a.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:underline break-all",children:a.link})]}),a.updatedAt&&(0,r.jsxs)("div",{className:s,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Last Updated"}),(0,r.jsx)("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:new Date(a.updatedAt).toLocaleString()})]}),(0,r.jsx)(ts,{version:tW,className:s}),(0,r.jsx)(tu,{className:s}),(0,r.jsxs)("div",{className:s,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-gray-500",children:"Logs"}),(0,r.jsx)("button",{type:"button",onClick:o,className:"text-sm text-blue-600 hover:text-blue-800",children:l?"Hide":"Show"})]}),l&&(0,r.jsx)(tt.n,{worktreeId:t})]})]})}),tU=(0,l.memo)(function(e){let{worktreeName:t,repositoryName:a,description:s,status:n,gitStatus:l,onBackClick:o,onInfoClick:i,onMenuClick:c,hasUpdate:d}=e,u=ea.Ie[n],m=s?(0,er.aS)(s,50):null;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("button",{type:"button",onClick:c,className:"p-2 -ml-2 rounded-lg text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-100 dark:hover:bg-gray-800 transition-colors","aria-label":"Toggle sidebar",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),(0,r.jsx)("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600","aria-hidden":"true"}),(0,r.jsxs)("button",{type:"button",onClick:o,className:"flex items-center gap-1 text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100 transition-colors","aria-label":"Go back to worktree list",children:[(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1h-2z"})}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Home"})]}),(0,r.jsx)("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600","aria-hidden":"true"}),"spinner"===u.type?(0,r.jsx)("span",{"data-testid":"desktop-status-indicator",title:u.label,"aria-label":u.label,className:"w-3 h-3 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ".concat(u.className)}):(0,r.jsx)("span",{"data-testid":"desktop-status-indicator",title:u.label,"aria-label":u.label,className:"w-3 h-3 rounded-full flex-shrink-0 ".concat(u.className)}),(0,r.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 truncate max-w-[200px] leading-tight",children:t}),m&&(0,r.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-md",title:s,children:m})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:[(0,r.jsx)("span",{className:"truncate max-w-[200px]",children:a}),l&&"(unknown)"!==l.currentBranch&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-gray-300 dark:text-gray-600",children:"/"}),(0,r.jsx)("span",{className:"truncate max-w-[150px] font-mono",title:l.currentBranch,"data-testid":"desktop-branch-name",children:(0,er.aS)(l.currentBranch,30)}),l.isDirty&&(0,r.jsx)("span",{className:"text-amber-500",title:"Uncommitted changes",children:"*"})]})]})]})]}),(0,r.jsxs)("button",{type:"button",onClick:i,className:"relative flex items-center gap-1.5 px-3 py-1.5 text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors","aria-label":"View worktree information",children:[(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Info"}),d&&(0,r.jsx)(eo,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":"Update available"})]})]})}),tV=(0,l.memo)(function(e){let{worktreeId:t,worktree:a,isOpen:s,onClose:n,onWorktreeUpdate:o}=e,[i,c]=(0,l.useState)(!1),d=(0,l.useRef)(s),u=tz(a,o,s,()=>{let e=s&&!d.current;return d.current=s,e});return a?(0,r.jsx)(tm.u,{isOpen:s,onClose:n,title:"Worktree Information",size:"md",children:(0,r.jsx)("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto",children:(0,r.jsx)(tB,{worktreeId:t,worktree:a,cardClassName:"bg-gray-50 dark:bg-gray-800 rounded-lg p-4",descriptionEditor:u,showLogs:i,onToggleLogs:()=>c(!i)})})}):null}),tH=(0,l.memo)(function(){return(0,r.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"status","aria-live":"polite",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-4 border-gray-300 dark:border-gray-600 border-t-cyan-600 dark:border-t-cyan-400","aria-hidden":"true"}),(0,r.jsx)("p",{className:"text-gray-600 dark:text-gray-400",children:"Loading worktree..."})]})})}),tY=(0,l.memo)(function(e){let{message:t,onRetry:a}=e;return(0,r.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"alert","aria-live":"assertive",children:(0,r.jsxs)("div",{className:"text-center p-6 bg-red-50 rounded-lg border border-red-200 max-w-md",children:[(0,r.jsx)("svg",{className:"mx-auto h-12 w-12 text-red-400 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("p",{className:"text-red-600 font-medium",children:"Error loading worktree"}),(0,r.jsx)("p",{className:"text-red-500 text-sm mt-2",children:t}),a&&(0,r.jsx)("button",{type:"button",onClick:a,className:"mt-4 px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2",children:"Retry"})]})})}),tq=(0,l.memo)(function(e){let{worktreeId:t,worktree:a,onWorktreeUpdate:s}=e,[n,o]=(0,l.useState)(!1),i=(0,l.useRef)(null==a?void 0:a.id),c=(0,l.useRef)(!1),d=tz(a,s,null==a?void 0:a.id,()=>{let e=(null==a?void 0:a.id)!==i.current;return i.current=null==a?void 0:a.id,e&&!c.current});return(c.current=d.isEditing,a)?(0,r.jsx)("div",{className:"p-4 space-y-4 overflow-y-auto h-full",children:(0,r.jsx)(tB,{worktreeId:t,worktree:a,cardClassName:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4",descriptionEditor:d,showLogs:n,onToggleLogs:()=>o(!n)})}):(0,r.jsx)("div",{className:"text-gray-500 text-center py-8",children:"Loading worktree info..."})}),tZ=(0,l.memo)(function(e){let{activeTab:t,worktreeId:a,worktree:s,messages:n,terminalOutput:l,isTerminalActive:o,isThinking:i,onFilePathClick:c,onFileSelect:d,onWorktreeUpdate:u,onNewFile:m,onNewDirectory:x,onRename:h,onDelete:g,onUpload:p,onMove:y,refreshTrigger:f,fileSearch:k,showToast:v,onCmateSetup:j,selectedAgents:w,onSelectedAgentsChange:N,vibeLocalModel:C,onVibeLocalModelChange:S,vibeLocalContextWindow:T,onVibeLocalContextWindowChange:E,autoScroll:M,onScrollChange:L,disableAutoFollow:R}=e;switch(t){case"terminal":return(0,r.jsx)(b,{componentName:"TerminalDisplay",children:(0,r.jsx)(A,{output:l,isActive:o,isThinking:i,autoScroll:M,onScrollChange:L,disableAutoFollow:R,className:"h-full"})});case"history":return(0,r.jsx)(b,{componentName:"HistoryPane",children:(0,r.jsx)(Z,{messages:n,worktreeId:a,onFilePathClick:c,className:"h-full",showToast:v})});case"files":var F;return(0,r.jsx)(b,{componentName:"FileTreeView",children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(eW,{query:k.query,mode:k.mode,isSearching:k.isSearching,error:k.error,onQueryChange:k.setQuery,onModeChange:k.setMode,onClear:k.clearSearch}),(0,r.jsx)(eD,{worktreeId:a,onFileSelect:d,onNewFile:m,onNewDirectory:x,onRename:h,onDelete:g,onUpload:p,onMove:y,onCmateSetup:j,refreshTrigger:f,searchQuery:k.query,searchMode:k.mode,searchResults:null===(F=k.results)||void 0===F?void 0:F.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,r.jsx)(b,{componentName:"NotesAndLogsPane",children:(0,r.jsx)(te,{worktreeId:a,className:"h-full",selectedAgents:w,onSelectedAgentsChange:N,vibeLocalModel:C,onVibeLocalModelChange:S,vibeLocalContextWindow:T,onVibeLocalContextWindowChange:E})});case"info":return(0,r.jsx)(tq,{worktreeId:a,worktree:s,onWorktreeUpdate:u});default:return null}}),tG=(0,l.memo)(function(e){var t,a,n,o,i,c,d,u,m,f;let{worktreeId:k}=e,v=(0,s.useRouter)(),j=(0,g.d)(),{toggle:w,openMobileDrawer:N}=(0,p.Sz)(),{state:C,actions:T}=function(){let[e,t]=(0,l.useReducer)(h,void 0,x),a=(0,l.useMemo)(()=>({setPhase:e=>t({type:"SET_PHASE",phase:e}),setTerminalOutput:(e,a)=>t({type:"SET_TERMINAL_OUTPUT",output:e,realtimeSnippet:a}),setTerminalActive:e=>t({type:"SET_TERMINAL_ACTIVE",isActive:e}),setTerminalThinking:e=>t({type:"SET_TERMINAL_THINKING",isThinking:e}),showPrompt:(e,a)=>t({type:"SHOW_PROMPT",data:e,messageId:a}),clearPrompt:()=>t({type:"CLEAR_PROMPT"}),setPromptAnswering:e=>t({type:"SET_PROMPT_ANSWERING",answering:e}),setError:e=>t({type:"SET_ERROR",error:e}),clearError:()=>t({type:"CLEAR_ERROR"}),setMessages:e=>t({type:"SET_MESSAGES",messages:e}),addMessage:e=>t({type:"ADD_MESSAGE",message:e}),updateMessage:(e,a)=>t({type:"UPDATE_MESSAGE",id:e,updates:a}),clearMessages:()=>t({type:"CLEAR_MESSAGES"}),startWaitingForResponse:e=>t({type:"START_WAITING_FOR_RESPONSE",cliToolId:e}),responseReceived:e=>t({type:"RESPONSE_RECEIVED",message:e}),sessionEnded:()=>t({type:"SESSION_ENDED"}),setAutoScroll:e=>t({type:"SET_AUTO_SCROLL",enabled:e}),setMobileActivePane:e=>t({type:"SET_MOBILE_ACTIVE_PANE",pane:e}),setLeftPaneTab:e=>t({type:"SET_LEFT_PANE_TAB",tab:e}),setLayoutMode:e=>t({type:"SET_LAYOUT_MODE",mode:e}),setSplitRatio:e=>t({type:"SET_SPLIT_RATIO",ratio:e}),setWsConnected:e=>t({type:"SET_WS_CONNECTED",connected:e})}),[]);return{state:e,dispatch:t,actions:a}}(),E=(0,y.T)("worktree"),M=(0,y.T)("error"),L=(0,y.T)("common"),R=(0,y.T)("autoYes"),F=(0,y.T)("schedule"),[P,D]=(0,l.useState)(null),[O,I]=(0,l.useState)(!0),[_,W]=(0,l.useState)(null),[z,B]=(0,l.useState)(!1),[U,V]=(0,l.useState)(null),[H,Y]=(0,l.useState)(null),[q,G]=(0,l.useState)(!1),[K,Q]=(0,l.useState)(!1),[J,X]=(0,l.useState)(null),$=(0,l.useRef)(!1),[ee,es]=(0,l.useState)(!1),[en,eo]=(0,l.useState)(tw.Fq),ei=(0,l.useRef)(en);ei.current=en;let[ec,eu]=(0,l.useState)(null),[ex,eh]=(0,l.useState)(null),[eg,ey]=(0,l.useState)(tw.Fq[0]),eb=(0,l.useRef)(eg);eb.current=eg;let[ef,ek]=(0,l.useState)(0),ev=function(e){let{worktreeId:t,initialMode:a="name",debounceMs:r=300}=e,[s,n]=(0,l.useState)(""),[o,i]=(0,l.useState)(""),[c,d]=(0,l.useState)(a),[u,m]=(0,l.useState)(!1),[x,h]=(0,l.useState)(null),[g,p]=(0,l.useState)(null),y=(0,l.useRef)(null),b=(0,l.useMemo)(()=>(0,er.Ds)(e=>{i(e)},r),[r]),f=(0,l.useCallback)(e=>{n(e),b(e),p(null)},[b]),k=(0,l.useCallback)(()=>{n(""),i(""),h(null),p(null),m(!1),y.current&&(y.current.abort(),y.current=null)},[]),v=(0,l.useCallback)(e=>{if(!o.trim())return e;let t=o.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t))},[o]),j=(0,l.useCallback)(()=>x&&0!==x.results.length?(0,er.Ps)(x.results.map(e=>e.filePath)):new Set,[x]);return(0,l.useEffect)(()=>{if("content"!==c||!o.trim()){h(null);return}y.current&&y.current.abort();let e=new AbortController;return y.current=e,(async()=>{m(!0),p(null);try{var a,r;let s=await fetch("/api/worktrees/".concat(encodeURIComponent(t),"/search?q=").concat(encodeURIComponent(o),"&mode=content"),{signal:e.signal});if(!s.ok){let e=await s.json();throw Error((null===(a=e.error)||void 0===a?void 0:a.message)||"Search failed: ".concat(s.status))}let n=await s.json();if(n.success)h({mode:"content",query:o,results:n.results,totalMatches:n.totalMatches,truncated:n.truncated,executionTimeMs:n.executionTimeMs});else throw Error((null===(r=n.error)||void 0===r?void 0:r.message)||"Search failed")}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;p(e instanceof Error?e.message:"An error occurred while searching"),h(null)}finally{m(!1)}})(),()=>{e.abort()}},[c,o,t]),(0,l.useEffect)(()=>{"name"===c&&(h(null),m(!1),p(null))},[c]),{query:s,mode:c,isSearching:u,results:x,error:g,setQuery:f,setMode:d,clearSearch:k,filterByName:v,getMatchedPaths:j}}({worktreeId:k}),ej=(0,l.useRef)(!1),ew=(0,l.useRef)(k);(0,l.useEffect)(()=>{ew.current!==k&&(T.clearMessages(),ej.current=!1,T.setTerminalOutput("",""),ew.current=k)},[k,T]);let eN=(0,l.useCallback)(async()=>{try{var e,t;let a=await fetch("/api/worktrees/".concat(k));if(!a.ok)throw Error("Failed to fetch worktree: ".concat(a.status));let r=await a.json();if(D(r),r.selectedAgents){let e=ei.current;r.selectedAgents.length===e.length&&r.selectedAgents.every((t,a)=>t===e[a])||eo(r.selectedAgents)}return"vibeLocalModel"in r&&eu(null!==(e=r.vibeLocalModel)&&void 0!==e?e:null),"vibeLocalContextWindow"in r&&eh(null!==(t=r.vibeLocalContextWindow)&&void 0!==t?t:null),r}catch(e){return W(e instanceof Error?e.message:"Unknown error"),null}},[k]),eC=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/worktrees/".concat(k,"/messages?cliTool=").concat(eb.current));if(!e.ok)throw Error("Failed to fetch messages: ".concat(e.status));let t=await e.json();T.setMessages(t.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(e){console.error("[WorktreeDetailRefactored] Error fetching messages:",e)}},[k,T]),eS=(0,l.useCallback)(async()=>{try{var e,t,a,r,s;let n=await fetch("/api/worktrees/".concat(k,"/current-output?cliTool=").concat(eb.current));if(!n.ok)return;let l=await n.json(),o=null!==(t=null!==(e=l.fullOutput)&&void 0!==e?e:l.realtimeSnippet)&&void 0!==t?t:"";if((o||l.isRunning)&&T.setTerminalOutput(o,null!==(a=l.realtimeSnippet)&&void 0!==a?a:""),T.setTerminalActive(null!==(r=l.isRunning)&&void 0!==r&&r),T.setTerminalThinking(null!==(s=l.thinking)&&void 0!==s&&s),l.isPromptWaiting&&l.promptData?T.showPrompt(l.promptData,"prompt-".concat(Date.now())):!l.isPromptWaiting&&C.prompt.visible&&T.clearPrompt(),l.autoYes){let e=$.current;Q(l.autoYes.enabled),X(l.autoYes.expiresAt),$.current=l.autoYes.enabled,e&&!l.autoYes.enabled&&"stop_pattern_matched"===l.autoYes.stopReason&&es(!0)}}catch(e){console.error("[WorktreeDetailRefactored] Error fetching current output:",e)}},[k,T,C.prompt.visible]);(0,l.useEffect)(()=>{en.includes(eg)||ey(en[0])},[en,eg]);let eT="opencode"===eg,eE=(0,l.useCallback)(e=>{eo(e)},[]),eM=(0,l.useCallback)(e=>{eu(e)},[]),eL=(0,l.useCallback)(e=>{eh(e)},[]),eR=(0,l.useRef)(eg);(0,l.useEffect)(()=>{eR.current!==eg&&(eR.current=eg,T.clearMessages(),T.setTerminalOutput("",""),eC(),eS())},[eg,T,eC,eS]);let eA=(0,l.useCallback)(e=>{V(e)},[]),eF=(0,l.useCallback)(e=>{var t;let a=null===(t=e.split(".").pop())||void 0===t?void 0:t.toLowerCase();eQ.includes(a?".".concat(a):"")?Y(e):V(e)},[]),eP=(0,l.useCallback)(()=>{V(null)},[]),eO=(0,l.useCallback)(()=>{Y(null)},[]),eI=(0,l.useCallback)(e=>{ek(e=>e+1)},[]),e_=(0,l.useCallback)(e=>{T.setLeftPaneTab(e)},[T]),ez=(0,l.useCallback)(()=>{v.push("/")},[v]),eB=(0,l.useCallback)(()=>{B(!0)},[]),eU=(0,l.useCallback)(()=>{B(!1)},[]),eV=(0,l.useCallback)(async e=>{T.setPromptAnswering(!0);try{let t=tx(e,eg,C.prompt.data),a=await fetch("/api/worktrees/".concat(k,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw Error("Failed to send prompt response: ".concat(a.status));T.clearPrompt(),await eS()}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e)}finally{T.setPromptAnswering(!1)}},[k,T,eS,eg,C.prompt.data]),eY=(0,l.useCallback)(()=>{T.clearPrompt()},[T]),eq=(0,l.useCallback)(e=>{T.setMobileActivePane(e)},[T]),eZ=(0,l.useCallback)(e=>{T.setAutoScroll(e)},[T]),eG=(0,l.useCallback)(()=>{eC(),eS()},[eC,eS]),e0=(0,l.useCallback)(async e=>{try{let t=await fetch("/api/worktrees/".concat(k,"/auto-yes"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e.enabled,cliToolId:eg,duration:e.duration,stopPattern:e.stopPattern})});if(t.ok){let e=await t.json();Q(e.enabled),X(e.expiresAt),$.current=e.enabled}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[k,eg]),[e1,e2]=(0,l.useState)(!1),e4=(0,l.useCallback)(()=>{e2(!0)},[]),e5=(0,l.useCallback)(async()=>{e2(!1);try{if(!(await fetch("/api/worktrees/".concat(k,"/kill-session?cliTool=").concat(eg),{method:"POST"})).ok)return;T.clearMessages(),T.setTerminalOutput("",""),T.setTerminalActive(!1),T.setTerminalThinking(!1),T.clearPrompt(),await eN()}catch(e){console.error("[WorktreeDetailRefactored] Error killing session:",e)}},[k,eg,T,eN]),e3=(0,l.useCallback)(()=>{e2(!1)},[]),e6=(0,l.useCallback)(async e=>{let t=window.prompt("Enter file name (e.g., document.md):");if(!t)return;let a=t.endsWith(".md")?t:"".concat(t,".md"),r=e?"".concat(e,"/").concat(a):a;try{if(!(await fetch("/api/worktrees/".concat(k,"/files/").concat(tM(r)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:""})})).ok)throw Error("Failed to create file");ek(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create file:",e),window.alert(M("fileOps.failedToCreateFile"))}},[k,M]),e7=(0,l.useCallback)(async e=>{let t=window.prompt("Enter directory name:");if(!t)return;let a=e?"".concat(e,"/").concat(t):t;try{if(!(await fetch("/api/worktrees/".concat(k,"/files/").concat(tM(a)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"directory"})})).ok)throw Error("Failed to create directory");ek(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create directory:",e),window.alert(M("fileOps.failedToCreateDirectory"))}},[k,M]),e9=(0,l.useCallback)(async e=>{let t=e.split("/").pop()||"",a=window.prompt("Enter new name:",t);if(a&&a!==t)try{if(!(await fetch("/api/worktrees/".concat(k,"/files/").concat(tM(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"rename",newName:a})})).ok)throw Error("Failed to rename");ek(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to rename:",e),window.alert(M("fileOps.failedToRename"))}},[k,M]),tt=(0,l.useCallback)(async e=>{let t=e.split("/").pop()||e;if(window.confirm(L("confirmDelete",{name:t})))try{if(!(await fetch("/api/worktrees/".concat(k,"/files/").concat(tM(e),"?recursive=true"),{method:"DELETE"})).ok)throw Error("Failed to delete");(H===e||(null==H?void 0:H.startsWith("".concat(e,"/"))))&&Y(null),ek(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert(M("fileOps.failedToDelete"))}},[k,H,L,M]),{toasts:tr,showToast:ts,removeToast:tn}=(0,e$.pm)();(0,l.useEffect)(()=>{ee&&(ts(R("stopPatternMatched"),"info"),es(!1))},[ee,ts,R]);let{moveTarget:tl,isMoveDialogOpen:to,handleMove:ti,handleMoveConfirm:tc,handleMoveCancel:td}=function(e,t,a,r){let[s,n]=(0,l.useState)(null),[o,i]=(0,l.useState)(!1),c=(0,l.useCallback)((e,t)=>{n({path:e,type:t}),i(!0)},[]),d=(0,l.useCallback)(async l=>{if(s)try{let n=await fetch("/api/worktrees/".concat(e,"/files/").concat(s.path),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"move",destination:l})}),i=await n.json();if(!n.ok||!i.success){var o;let e=(null===(o=i.error)||void 0===o?void 0:o.message)||"Failed to move";null==r||r(e);return}null==a||a("Moved successfully"),t()}catch(e){null==r||r("Failed to move")}finally{n(null),i(!1)}},[s,e,t,a,r]);return{moveTarget:s,isMoveDialogOpen:o,handleMove:c,handleMoveConfirm:d,handleMoveCancel:(0,l.useCallback)(()=>{n(null),i(!1)},[])}}(k,()=>ek(e=>e+1),e=>ts(e,"success"),e=>ts(e,"error")),tu=(0,l.useRef)(null),th=(0,l.useRef)(""),tg=(0,l.useCallback)(e=>{var t;th.current=e,null===(t=tu.current)||void 0===t||t.click()},[]),tp=(0,l.useCallback)(async()=>{try{var e;let t;let a=await fetch("/api/worktrees/".concat(k,"/tree"));if(!a.ok)throw Error("Failed to list worktree files: ".concat(a.status));let r=await a.json();if((null!==(e=r.items)&&void 0!==e?e:[]).some(e=>"CMATE.md"===e.name)){let e=await fetch("/api/worktrees/".concat(k,"/files/CMATE.md"));if(!e.ok)throw Error("Failed to read CMATE.md: ".concat(e.status));let a=await e.json();if("string"!=typeof a.content){ts(F("cmateValidation.failed"),"error");return}t=a.content}else{if(!(await fetch("/api/worktrees/".concat(k,"/files/CMATE.md"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:tI})})).ok)throw Error("Failed to create CMATE.md");ts(F("cmateCreated"),"success"),ek(e=>e+1),t=tI}let s=function(e){let t=[],a=e.split("\n"),r=!1;for(let e of a){let a=e.trim(),s=a.match(/^##\s+(.+)$/);if(s){r="Schedules"===s[1].trim();continue}if(!r||!a.startsWith("|"))continue;let n=a.split("|").slice(1,-1).map(e=>e.trim());for(let e=0;e<tD.length;e++){let a=tD[e],r=n[e];r&&r===a||t.push({row:-1,message:"Header column ".concat(e+1,': expected "').concat(a,'", got "').concat(r||"(missing)",'"'),field:"header"})}for(let e=0;e<tO.length;e++){let a=tD.length+e,r=tO[e],s=n[a];void 0!==s&&s!==r&&t.push({row:-1,message:"Header column ".concat(a+1,': expected "').concat(r,'", got "').concat(s,'"'),field:"header"})}break}return t}(t),n=(function(e){let t=new Map,a=e.split("\n"),r=null,s=!1,n=!1;for(let e of a){let a=e.trim(),l=a.match(/^##\s+(.+)$/);if(l){r=l[1].trim(),s=!1,n=!1,t.has(r)||t.set(r,[]);continue}if(!a||!a.startsWith("|")||!r)continue;if(!s){s=!0;continue}if(!n){if(a.match(/^\|[\s-:|]+\|$/)){n=!0;continue}n=!0}let o=a.split("|").slice(1,-1).map(e=>e.trim());o.length>0&&t.get(r).push(o)}return t})(t).get("Schedules");if(!n||0===n.length){ts(F("cmateValidation.noSchedulesSection"),"error");return}let l=function(e){let t=[];for(let r=0;r<e.length;r++){let s=e[r];if(s.length<3){t.push({row:r,message:"Row ".concat(r+1,": insufficient columns (need at least 3, got ").concat(s.length,")"),field:"columns"});continue}let[n,l,o]=s,i=tR(n);tA.test(i)||t.push({row:r,message:"Row ".concat(r+1,': invalid name "').concat(i,'"'),field:"name"}),!function(e){if(e.length>100)return!1;let t=e.trim().split(/\s+/);return t.length>=5&&t.length<=6}(l)&&t.push({row:r,message:"Row ".concat(r+1,': invalid cron "').concat(l,'"'),field:"cron"}),tR(o).trim()||t.push({row:r,message:"Row ".concat(r+1,": empty message"),field:"message"});let c=s[5];if(void 0!==c&&""!==c.trim()){var a;let e=c.trim(),n=(null===(a=s[3])||void 0===a?void 0:a.trim())||"claude";("codex"===n?tP:tF).includes(e)||t.push({row:r,message:"Row ".concat(r+1,': invalid permission "').concat(e,'" for ').concat(n),field:"permission"})}}return t}(n),o=[...s,...l];if(0===o.length)ts(F("cmateValidation.valid",{count:String(n.length)}),"success");else{let e=o.slice(0,3).map(e=>e.message).join("; "),t=o.length>3?" (+".concat(o.length-3,")"):"";ts(F("cmateValidation.errors",{errorCount:String(o.length),details:e+t}),"error")}}catch(e){console.error("[WorktreeDetailRefactored] CMATE setup error:",e),ts(F("cmateValidation.failed"),"error")}},[k,ts,F]),ty=(0,l.useCallback)(async e=>{var t,a,r;let s=null===(t=e.target.files)||void 0===t?void 0:t[0];if(!s)return;e.target.value="";let n=th.current,l=".".concat(null===(a=s.name.split(".").pop())||void 0===a?void 0:a.toLowerCase());if(!function(e){if(!e)return!1;let t=e.toLowerCase();return eX.includes(t)}(l)){ts("Unsupported file type: ".concat(l,". Allowed: ").concat(eX.join(", ")),"error");return}let o=function(e){var t;let a=function(e){let t=e.toLowerCase();return eJ.find(e=>e.extension===t)}(e);return null!==(t=null==a?void 0:a.maxFileSize)&&void 0!==t?t:5242880}(l);if(s.size>o){ts("File too large. Maximum size: ".concat((o/1024/1024).toFixed(1),"MB"),"error");return}let i=new FormData;i.append("file",s);try{let e=await fetch("/api/worktrees/".concat(k,"/upload/").concat(tM(n||".")),{method:"POST",body:i});if(!e.ok){let t=await e.json().catch(()=>({})),a=(null==t?void 0:null===(r=t.error)||void 0===r?void 0:r.message)||"Failed to upload file";ts(a,"error");return}let t=await e.json();ts("Uploaded: ".concat(t.filename),"success"),ek(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),ts("Upload failed. Please try again.","error")}},[k,ts]),{data:tb}=ta(),tk=null!==(c=null==tb?void 0:tb.hasUpdate)&&void 0!==c&&c,{lastAutoResponse:tv}=function(e){let{worktreeId:t,cliTool:a,isPromptWaiting:r,promptData:s,autoYesEnabled:n,lastServerResponseTimestamp:o}=e,i=(0,l.useRef)(null),[c,d]=(0,l.useState)(null);return(0,l.useEffect)(()=>{var e;if(!r){i.current=null;return}if(!s||!n||o&&Date.now()-o<3e3)return;let l=(e={type:s.type,question:s.question},"".concat(e.type,":").concat(e.question));if(i.current===l)return;let c=function(e){if("yes_no"===e.type)return"y";if("multiple_choice"===e.type){let t=e.options.find(e=>e.isDefault),a=null!=t?t:e.options[0];return!a||a.requiresTextInput?null:a.number.toString()}return null}(s);if(null===c)return;i.current=l,d(c);let u=tx(c,a,s);fetch("/api/worktrees/".concat(t,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}).catch(e=>{console.error("[useAutoYes] Failed to send auto-response:",e)})},[r,s,n,t,a,o]),{lastAutoResponse:c}}({worktreeId:k,cliTool:eg,isPromptWaiting:C.prompt.visible,promptData:C.prompt.data,autoYesEnabled:K}),tC=(0,l.useCallback)(async()=>{W(null),I(!0),await eN()&&await Promise.all([eC(),eS()]),I(!1)},[eN,eC,eS]),tS=(0,l.useRef)(0),tT=(0,l.useCallback)(async()=>{if("visible"!==document.visibilityState)return;let e=Date.now();if(!(e-tS.current<5e3)){if(tS.current=e,_){tC();return}try{await Promise.all([eN(),eC(),eS()])}finally{W(null)}}},[_,tC,eN,eC,eS]);(0,l.useEffect)(()=>{if(ej.current)return;let e=!0;return(async()=>{I(!0);let t=await eN();e&&(t&&await Promise.all([eC(),eS()]),e&&(I(!1),ej.current=!0))})(),()=>{e=!1}},[eN,eC,eS]),(0,l.useEffect)(()=>(document.addEventListener("visibilitychange",tT),()=>{document.removeEventListener("visibilitychange",tT)}),[tT]),(0,l.useEffect)(()=>{if(O||_)return;let e=setInterval(async()=>{await Promise.all([eS(),eN(),eC()])},C.terminal.isActive?2e3:5e3);return()=>clearInterval(e)},[O,_,eS,eN,eC,C.terminal.isActive]),(0,l.useEffect)(()=>{T.setLayoutMode(j?"tabs":"split")},[j,T]);let tL=(0,l.useMemo)(()=>(function(e,t){var a;let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"claude";if(t)return"error";if(!e)return"idle";let s=null===(a=e.sessionStatusByCli)||void 0===a?void 0:a[r];if(s){if(s.isWaitingForResponse)return"waiting";if(s.isProcessing)return"running";if(s.isRunning)return"ready"}if("claude"===r){if(e.isWaitingForResponse)return"waiting";if(e.isProcessing)return"running";if(e.isSessionRunning)return"ready"}return"idle"})(P,null!==C.error.type,eg),[P,C.error.type,eg]),tW=(0,l.useMemo)(()=>C.layout.mobileActivePane,[C.layout.mobileActivePane]),tz=(0,l.useMemo)(()=>C.layout.leftPaneTab,[C.layout.leftPaneTab]),tB=null!==(d=null==P?void 0:P.name)&&void 0!==d?d:"Unknown",tq=(0,l.useMemo)(()=>(0,r.jsx)(A,{output:C.terminal.output,isActive:C.terminal.isActive,isThinking:C.terminal.isThinking,autoScroll:C.terminal.autoScroll,onScrollChange:eZ,disableAutoFollow:eT}),[C.terminal.output,C.terminal.isActive,C.terminal.isThinking,C.terminal.autoScroll,eZ,eT]),tG=(0,l.useMemo)(()=>{var e;return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(eH,{activeTab:tz,onTabChange:e_}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["history"===tz&&(0,r.jsx)(Z,{messages:C.messages,worktreeId:k,onFilePathClick:eA,className:"h-full",showToast:ts}),"files"===tz&&(0,r.jsx)(b,{componentName:"FileTreeView",children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(eW,{query:ev.query,mode:ev.mode,isSearching:ev.isSearching,error:ev.error,onQueryChange:ev.setQuery,onModeChange:ev.setMode,onClear:ev.clearSearch}),(0,r.jsx)(eD,{worktreeId:k,onFileSelect:eF,onNewFile:e6,onNewDirectory:e7,onRename:e9,onDelete:tt,onUpload:tg,onMove:ti,onCmateSetup:tp,refreshTrigger:ef,searchQuery:ev.query,searchMode:ev.mode,searchResults:null===(e=ev.results)||void 0===e?void 0:e.results,className:"flex-1 min-h-0"})]})}),"memo"===tz&&(0,r.jsx)(b,{componentName:"NotesAndLogsPane",children:(0,r.jsx)(te,{worktreeId:k,className:"h-full",selectedAgents:en,onSelectedAgentsChange:eE,vibeLocalModel:ec,onVibeLocalModelChange:eM,vibeLocalContextWindow:ex,onVibeLocalContextWindowChange:eL})})]})]})},[tz,e_,C.messages,k,eA,ts,ev.query,ev.mode,ev.isSearching,ev.error,ev.setQuery,ev.setMode,ev.clearSearch,null===(t=ev.results)||void 0===t?void 0:t.results,eF,e6,e7,e9,tt,tg,ti,tp,ef,en,eE,ec,eM,ex,eL]);return O?(0,r.jsx)(tH,{}):_?(0,r.jsx)(tY,{message:_,onRetry:tC}):j?(0,r.jsx)(b,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(el,{worktreeName:tB,repositoryName:null==P?void 0:P.repositoryName,status:tL,gitStatus:null==P?void 0:P.gitStatus,onBackClick:ez,onMenuClick:N}),(null==P?void 0:P.gitStatus)&&P.gitStatus.isBranchMismatch&&(0,r.jsx)("div",{className:"z-35",children:(0,r.jsx)(tj,{isBranchMismatch:P.gitStatus.isBranchMismatch,currentBranch:P.gitStatus.currentBranch,initialBranch:P.gitStatus.initialBranch})}),(0,r.jsxs)("div",{className:"sticky top-0 z-30 flex items-center justify-between px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:[(0,r.jsx)(tf,{enabled:K,expiresAt:J,onToggle:e0,lastAutoResponse:tv,cliToolName:eg,inline:!0}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(0,r.jsx)("nav",{className:"flex gap-2","aria-label":"CLI Tool Selection",children:en.map(e=>{var t;let a=(0,tN.He)(null==P?void 0:null===(t=P.sessionStatusByCli)||void 0===t?void 0:t[e]),s=ea.F4[a];return(0,r.jsxs)("button",{onClick:()=>ey(e),className:"px-1.5 py-0.5 rounded font-medium text-xs transition-colors flex items-center gap-1 ".concat(eg===e?"bg-blue-100 text-blue-700":"text-gray-500 hover:text-gray-700"),"aria-current":eg===e?"page":void 0,children:["spinner"===s.type?(0,r.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ".concat(s.className),title:s.label}):(0,r.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ".concat(s.className),title:s.label}),(0,e8.Ds)(e)]},e)})}),(0,r.jsxs)("button",{onClick:e4,disabled:!(null==P?void 0:null===(n=P.sessionStatusByCli)||void 0===n?void 0:null===(a=n[eg])||void 0===a?void 0:a.isRunning),className:"flex items-center gap-0.5 px-1.5 py-0.5 text-xs font-medium rounded transition-colors ".concat((null==P?void 0:null===(i=P.sessionStatusByCli)||void 0===i?void 0:null===(o=i[eg])||void 0===o?void 0:o.isRunning)?"text-red-600 hover:bg-red-50":"invisible"),"aria-label":"End ".concat(eg," session"),children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"✕"}),"End"]})]})]}),(0,r.jsx)("main",{className:"flex-1 pb-32 overflow-hidden",style:{paddingBottom:"calc(8rem + env(safe-area-inset-bottom, 0px))"},children:(0,r.jsx)(tZ,{activeTab:tW,worktreeId:k,worktree:P,messages:C.messages,terminalOutput:C.terminal.output,isTerminalActive:C.terminal.isActive,isThinking:C.terminal.isThinking,onFilePathClick:eA,onFileSelect:eF,onWorktreeUpdate:D,onNewFile:e6,onNewDirectory:e7,onRename:e9,onDelete:tt,onUpload:tg,onMove:ti,refreshTrigger:ef,fileSearch:ev,showToast:ts,onCmateSetup:tp,selectedAgents:en,onSelectedAgentsChange:eE,vibeLocalModel:ec,onVibeLocalModelChange:eM,vibeLocalContextWindow:ex,onVibeLocalContextWindowChange:eL,autoScroll:C.terminal.autoScroll,onScrollChange:eZ,disableAutoFollow:eT})}),(0,r.jsx)("div",{className:"fixed left-0 right-0 border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 p-2 z-30",style:{bottom:"calc(4rem + env(safe-area-inset-bottom, 0px))"},children:(0,r.jsx)(ep.R,{worktreeId:k,onMessageSent:eG,cliToolId:eg,isSessionRunning:C.terminal.isActive})}),(0,r.jsx)(ed,{activeTab:tW,onTabChange:eq,hasNewOutput:!1,hasPrompt:C.prompt.visible,hasUpdate:tk}),!K&&(0,r.jsx)(em,{promptData:C.prompt.data,visible:C.prompt.visible,answering:C.prompt.answering,onRespond:eV,onDismiss:eY,cliToolName:(0,e8.Ds)(eg)}),(0,r.jsx)(eK,{isOpen:null!==U,onClose:eP,worktreeId:k,filePath:null!=U?U:""}),H&&(0,r.jsx)(tm.u,{isOpen:!0,onClose:eO,title:H.split("/").pop()||"Editor",size:"full",disableClose:q,children:(0,r.jsx)("div",{className:"h-[80vh]",children:(0,r.jsx)(t_,{worktreeId:k,filePath:H,onClose:eO,onSave:eI,onMaximizedChange:G})})}),(0,r.jsx)("input",{ref:tu,type:"file",accept:eX.join(","),onChange:ty,className:"hidden","aria-label":"Upload file"}),(0,r.jsx)(tm.u,{isOpen:e1,onClose:e3,title:E("session.confirmEnd",{tool:(0,e8.Ds)(eg)}),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-gray-700",children:E("session.endWarning")}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:e3,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700",children:L("cancel")}),(0,r.jsx)("button",{type:"button",onClick:e5,className:"px-4 py-2 text-sm font-medium rounded-md bg-red-600 hover:bg-red-700 text-white",children:L("end")})]})]})}),tl&&(0,r.jsx)(tE,{isOpen:to,onClose:td,onConfirm:tc,worktreeId:k,sourcePath:tl.path,sourceType:tl.type}),(0,r.jsx)(e$.Ix,{toasts:tr,onClose:tn})]})}):(0,r.jsx)(b,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"h-full flex flex-col relative",children:[(0,r.jsx)(tU,{worktreeName:tB,repositoryName:null!==(f=null==P?void 0:P.repositoryName)&&void 0!==f?f:"Unknown",description:null==P?void 0:P.description,status:tL,gitStatus:null==P?void 0:P.gitStatus,onBackClick:ez,onInfoClick:eB,onMenuClick:w,hasUpdate:tk}),(0,r.jsxs)("div",{className:"px-4 py-2 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[(0,r.jsx)("nav",{className:"flex gap-4","aria-label":"CLI Tool Selection",children:en.map(e=>{var t;let a=(0,tN.He)(null==P?void 0:null===(t=P.sessionStatusByCli)||void 0===t?void 0:t[e]),s=ea.F4[a];return(0,r.jsxs)("button",{onClick:()=>ey(e),className:"pb-2 px-2 border-b-2 font-medium text-sm transition-colors flex items-center gap-1.5 ".concat(eg===e?"border-cyan-600 text-cyan-600":"border-transparent text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100"),"aria-current":eg===e?"page":void 0,children:["spinner"===s.type?(0,r.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 border-2 border-t-transparent animate-spin ".concat(s.className),title:s.label,"aria-label":"".concat(e," status: ").concat(s.label)}):(0,r.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ".concat(s.className),title:s.label,"aria-label":"".concat(e," status: ").concat(s.label)}),(0,e8.Ds)(e)]},e)})}),(null==P?void 0:null===(m=P.sessionStatusByCli)||void 0===m?void 0:null===(u=m[eg])||void 0===u?void 0:u.isRunning)&&(0,r.jsxs)("button",{onClick:e4,className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-red-600 hover:text-red-800 hover:bg-red-50 rounded transition-colors","aria-label":"End ".concat(eg," session"),children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"✕"}),"End Session"]})]}),(null==P?void 0:P.gitStatus)&&(0,r.jsx)(tj,{isBranchMismatch:P.gitStatus.isBranchMismatch,currentBranch:P.gitStatus.currentBranch,initialBranch:P.gitStatus.initialBranch}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(S,{leftPane:tG,rightPane:tq,initialLeftWidth:40,minLeftWidth:20,maxLeftWidth:60})}),(0,r.jsx)("div",{className:"flex-shrink-0 border-t border-gray-200 dark:border-gray-700 p-4 bg-gray-50 dark:bg-gray-800",children:(0,r.jsx)(ep.R,{worktreeId:k,onMessageSent:eG,cliToolId:eg,isSessionRunning:C.terminal.isActive})}),(0,r.jsx)(tf,{enabled:K,expiresAt:J,onToggle:e0,lastAutoResponse:tv,cliToolName:eg}),C.prompt.visible&&!K&&(0,r.jsx)("div",{className:"fixed bottom-20 left-1/2 transform -translate-x-1/2 z-50 w-full max-w-2xl px-4",children:(0,r.jsx)(et,{promptData:C.prompt.data,messageId:C.prompt.messageId,visible:C.prompt.visible,answering:C.prompt.answering,onRespond:eV,onDismiss:eY,cliToolName:(0,e8.Ds)(eg)})}),(0,r.jsx)(tV,{worktreeId:k,worktree:P,isOpen:z,onClose:eU,onWorktreeUpdate:D}),(0,r.jsx)(eK,{isOpen:null!==U,onClose:eP,worktreeId:k,filePath:null!=U?U:""}),H&&(0,r.jsx)(tm.u,{isOpen:!0,onClose:eO,title:H.split("/").pop()||"Editor",size:"full",disableClose:q,children:(0,r.jsx)("div",{className:"h-[80vh]",children:(0,r.jsx)(t_,{worktreeId:k,filePath:H,onClose:eO,onSave:eI,onMaximizedChange:G})})}),(0,r.jsx)("input",{ref:tu,type:"file",accept:eX.join(","),onChange:ty,className:"hidden","aria-label":"Upload file"}),(0,r.jsx)(tm.u,{isOpen:e1,onClose:e3,title:E("session.confirmEnd",{tool:(0,e8.Ds)(eg)}),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:E("session.endWarning")}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:e3,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700 dark:bg-gray-700 dark:hover:bg-gray-600 dark:text-gray-300",children:L("cancel")}),(0,r.jsx)("button",{type:"button",onClick:e5,className:"px-4 py-2 text-sm font-medium rounded-md bg-red-600 hover:bg-red-700 text-white",children:L("end")})]})]})}),tl&&(0,r.jsx)(tE,{isOpen:to,onClose:td,onConfirm:tc,worktreeId:k,sourcePath:tl.path,sourceType:tl.type}),(0,r.jsx)(e$.Ix,{toasts:tr,onClose:tn})]})})});function tK(){let e=(0,s.useParams)().id;return(0,r.jsx)(n.Vw,{children:(0,r.jsx)(tG,{worktreeId:e})})}},39625:function(e,t,a){"use strict";a.d(t,{O:function(){return n}});var r=a(57437),s=a(2265);function n(e){let{src:t,alt:a,onError:n}=e,[l,o]=(0,s.useState)(!1);return l?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[(0,r.jsx)("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),(0,r.jsx)("p",{className:"text-sm",children:"Failed to load image"}),(0,r.jsx)("p",{className:"text-xs text-gray-400 mt-1",children:a})]}):(0,r.jsx)("div",{className:"flex items-center justify-center p-4",children:(0,r.jsx)("img",{src:t,alt:a,onError:()=>{o(!0),null==n||n()},style:{maxWidth:"100%",maxHeight:"500px",objectFit:"contain"},className:"rounded-lg shadow-sm"})})}},37979:function(e,t,a){"use strict";a.d(t,{m:function(){return c}});var r=a(57437),s=a(2265);let n=["flex-shrink-0","bg-gray-700","transition-colors","duration-150","hover:bg-cyan-500","focus:outline-none","focus:ring-2","focus:ring-cyan-500","focus:ring-offset-2","focus:ring-offset-gray-900"],l=["w-1","h-full","cursor-col-resize","hover:w-2"],o=["h-1","w-full","cursor-row-resize","hover:h-2"];function i(e,t){return"touches"in e&&e.touches.length>0?t?e.touches[0].clientX:e.touches[0].clientY:"clientX"in e?t?e.clientX:e.clientY:0}let c=(0,s.memo)(function(e){let{onResize:t,orientation:a="horizontal",ariaValueNow:c=50,onDoubleClick:d,minRatio:u=.1}=e,[m,x]=(0,s.useState)(!1),h=(0,s.useRef)(0),g=(0,s.useRef)(null),p="horizontal"===a,y=(0,s.useCallback)(e=>{e.preventDefault(),x(!0),h.current=i(e,p)},[p]),b=(0,s.useCallback)(e=>{1===e.touches.length&&(x(!0),h.current=i(e,p))},[p]),f=(0,s.useCallback)(e=>{if(!m)return;let a=i(e,p);t(a-h.current),h.current=a},[m,p,t]),k=(0,s.useCallback)(e=>{if(!m||1!==e.touches.length)return;let a=i(e,p);t(a-h.current),h.current=a},[m,p,t]),v=(0,s.useCallback)(()=>{x(!1)},[]),j=(0,s.useCallback)(()=>{d&&d()},[d]),w=(0,s.useCallback)(e=>{let a=0;p?"ArrowRight"===e.key?a=10:"ArrowLeft"===e.key&&(a=-10):"ArrowDown"===e.key?a=10:"ArrowUp"===e.key&&(a=-10),0!==a&&(e.preventDefault(),t(a))},[p,t]);(0,s.useEffect)(()=>(m&&(document.addEventListener("mousemove",f),document.addEventListener("mouseup",v),document.addEventListener("touchmove",k),document.addEventListener("touchend",v),document.body.style.userSelect="none",document.body.style.cursor=p?"col-resize":"row-resize"),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",v),document.removeEventListener("touchmove",k),document.removeEventListener("touchend",v),document.body.style.userSelect="",document.body.style.cursor=""}),[m,f,v,k,p]);let N=(0,s.useMemo)(()=>[...n,...p?l:o,...m?["bg-cyan-500","dragging",p?"w-2":"h-2"]:[]].join(" "),[p,m]);return(0,r.jsx)("div",{ref:g,role:"separator","aria-orientation":a,"aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":"Resize panes. Use ".concat(p?"left and right":"up and down"," arrow keys to adjust."),tabIndex:0,className:N,onMouseDown:y,onTouchStart:b,onKeyDown:w,onDoubleClick:j})})},1243:function(e,t,a){"use strict";a.d(t,{R:function(){return n}});var r=a(57437),s=a(2265);function n(e){let{src:t,onError:a}=e,[n,l]=(0,s.useState)(!0),[o,i]=(0,s.useState)(!1);return o?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[(0,r.jsx)("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),(0,r.jsx)("p",{className:"text-sm",children:"Failed to load video"})]}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center p-4",children:[n&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,r.jsx)("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"}),(0,r.jsx)("p",{className:"ml-3 text-gray-600",children:"Loading video..."})]}),(0,r.jsx)("video",{controls:!0,src:t,onLoadedData:()=>{l(!1)},onError:()=>{l(!1),i(!0),null==a||a()},style:{maxWidth:"100%",maxHeight:"500px",display:n?"none":"block"},className:"rounded-lg shadow-sm",children:"Your browser does not support the video tag."})]})}},36762:function(e,t,a){"use strict";a.d(t,{Q:function(){return s}});var r=a(2265);function s(e){let{value:t,saveFn:a,debounceMs:s=300,disabled:n=!1,maxRetries:l=3,onSaveComplete:o}=e,[i,c]=(0,r.useState)(!1),[d,u]=(0,r.useState)(null),m=(0,r.useRef)(t),x=(0,r.useRef)(a),h=(0,r.useRef)(o),g=(0,r.useRef)(null),p=(0,r.useRef)(!0),y=(0,r.useRef)(t);(0,r.useEffect)(()=>{m.current=t},[t]),(0,r.useEffect)(()=>{x.current=a},[a]),(0,r.useEffect)(()=>{h.current=o},[o]),(0,r.useEffect)(()=>(p.current=!0,()=>{p.current=!1,g.current&&clearTimeout(g.current)}),[]);let b=(0,r.useCallback)(async e=>{if(!p.current)return;c(!0),u(null);let t=null,a=0;for(;a<=l;)try{if(await x.current(e),p.current){var r;c(!1),u(null),null===(r=h.current)||void 0===r||r.call(h)}return}catch(e){if(t=e instanceof Error?e:Error(String(e)),++a<=l){let e=1e3*Math.pow(2,a-1);await new Promise(t=>setTimeout(t,e))}}p.current&&(c(!1),u(t))},[l]),f=(0,r.useCallback)(()=>{g.current&&(clearTimeout(g.current),g.current=null)},[]),k=(0,r.useCallback)(async()=>{n||(f(),await b(m.current))},[n,f,b]);return(0,r.useEffect)(()=>{if(t!==y.current&&!n)return f(),g.current=setTimeout(()=>{b(m.current)},s),()=>{f()}},[t,n,s,f,b]),{isSaving:i,error:d,saveNow:k}}}},function(e){e.O(0,[9234,216,12,8913,8528,2083,2971,2117,1744],function(){return e(e.s=5635)}),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1224],{22706:function(e,t,n){Promise.resolve().then(n.bind(n,27323))},51817:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});let l=(0,n(79205).Z)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},30166:function(e,t,n){"use strict";n.d(t,{default:function(){return s.a}});var l=n(55775),s=n.n(l)},55775:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return r}});let l=n(47043);n(57437),n(2265);let s=l._(n(15602));function r(e,t){var n;let l={loading:e=>{let{error:t,isLoading:n,pastDelay:l}=e;return null}};"function"==typeof e&&(l.loader=e);let r={...l,...t};return(0,s.default)({...r,modules:null==(n=r.loadableGenerated)?void 0:n.modules})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},81523:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return s}});let l=n(18993);function s(e){let{reason:t,children:n}=e;if("undefined"==typeof window)throw new l.BailoutToCSRError(t);return n}},15602:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return o}});let l=n(57437),s=n(2265),r=n(81523),a=n(70049);function i(e){return{default:e&&"default"in e?e.default:e}}let d={loader:()=>Promise.resolve(i(()=>null)),loading:null,ssr:!0},o=function(e){let t={...d,...e},n=(0,s.lazy)(()=>t.loader().then(i)),o=t.loading;function c(e){let i=o?(0,l.jsx)(o,{isLoading:!0,pastDelay:!0,error:null}):null,d=t.ssr?(0,l.jsxs)(l.Fragment,{children:["undefined"==typeof window?(0,l.jsx)(a.PreloadCss,{moduleIds:t.modules}):null,(0,l.jsx)(n,{...e})]}):(0,l.jsx)(r.BailoutToCSR,{reason:"next/dynamic",children:(0,l.jsx)(n,{...e})});return(0,l.jsx)(s.Suspense,{fallback:i,children:d})}return c.displayName="LoadableComponent",c}},70049:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadCss",{enumerable:!0,get:function(){return r}});let l=n(57437),s=n(20544);function r(e){let{moduleIds:t}=e;if("undefined"!=typeof window)return null;let n=(0,s.getExpectedRequestStore)("next/dynamic css"),r=[];if(n.reactLoadableManifest&&t){let e=n.reactLoadableManifest;for(let n of t){if(!e[n])continue;let t=e[n].files.filter(e=>e.endsWith(".css"));r.push(...t)}}return 0===r.length?null:(0,l.jsx)(l.Fragment,{children:r.map(e=>(0,l.jsx)("link",{precedence:"dynamic",rel:"stylesheet",href:n.assetPrefix+"/_next/"+encodeURI(e),as:"style"},e))})}},27323:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return m}});var l=n(57437),s=n(2265),r=n(30166),a=n(27648),i=n(51817),d=n(79205);let o=(0,d.Z)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),c=(0,d.Z)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),u=(0,d.Z)("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]),f=(0,d.Z)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),x=(0,r.default)(()=>Promise.all([n.e(6741),n.e(9838),n.e(4671)]).then(n.bind(n,74671)).then(e=>({default:e.TerminalComponent})),{loadableGenerated:{webpack:()=>[74671]},ssr:!1,loading:()=>(0,l.jsxs)("div",{className:"flex items-center justify-center h-full bg-gray-900 text-gray-400",children:[(0,l.jsx)(i.Z,{className:"animate-spin h-6 w-6 mr-2"}),(0,l.jsx)("span",{children:"Loading terminal..."})]})});function m(e){let{params:t}=e,[n,r]=(0,s.useState)("claude");return(0,l.jsxs)("div",{className:"h-screen flex flex-col bg-gray-900",children:[(0,l.jsx)("div",{className:"bg-gray-800 border-b border-gray-700 px-4 py-3",children:(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsxs)("div",{className:"flex items-center gap-4",children:[(0,l.jsxs)(a.default,{href:"/worktrees/".concat(t.id),className:"flex items-center gap-2 text-gray-400 hover:text-white transition-colors",children:[(0,l.jsx)(o,{size:20}),(0,l.jsx)("span",{children:"Back"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 text-white",children:[(0,l.jsx)(c,{size:20}),(0,l.jsxs)("h1",{className:"text-lg font-semibold",children:["Terminal: ",t.id]})]})]}),(0,l.jsx)("div",{className:"flex items-center gap-2",children:[{id:"claude",name:"Claude",icon:"\uD83E\uDD16",color:"bg-purple-600"},{id:"codex",name:"Codex",icon:"⚡",color:"bg-blue-600"},{id:"gemini",name:"Gemini",icon:"✦",color:"bg-green-600"},{id:"bash",name:"Bash",icon:"\uD83D\uDCBB",color:"bg-gray-600"}].map(e=>(0,l.jsxs)("button",{onClick:()=>r(e.id),className:"\n px-4 py-2 rounded-lg flex items-center gap-2 transition-all\n ".concat(n===e.id?"".concat(e.color," text-white shadow-lg"):"bg-gray-700 text-gray-300 hover:bg-gray-600","\n "),children:[(0,l.jsx)("span",{className:"text-lg",children:e.icon}),(0,l.jsx)("span",{className:"text-sm font-medium",children:e.name})]},e.id))})]})}),(0,l.jsx)("div",{className:"flex-1 p-4",children:(0,l.jsx)("div",{className:"h-full bg-gray-800 rounded-lg overflow-hidden shadow-2xl",children:(0,l.jsx)(x,{worktreeId:t.id,cliToolId:n,className:"h-full"})})}),(0,l.jsx)("div",{className:"bg-gray-800 border-t border-gray-700 px-4 py-2",children:(0,l.jsxs)("div",{className:"flex items-center justify-between text-xs text-gray-400",children:[(0,l.jsxs)("div",{className:"flex items-center gap-4",children:[(0,l.jsxs)("span",{className:"flex items-center gap-1",children:[(0,l.jsx)(u,{size:14}),"Terminal Mode"]}),(0,l.jsxs)("span",{className:"flex items-center gap-1",children:[(0,l.jsx)(f,{size:14}),n.toUpperCase()," Session"]})]}),(0,l.jsx)("div",{children:(0,l.jsx)("span",{className:"text-gray-500",children:"Press Ctrl+C to interrupt • Ctrl+D to exit"})})]})})]})}}},function(e){e.O(0,[216,2971,2117,1744],function(){return e(e.s=22706)}),_N_E=e.O()}]);