commandmate 0.3.1 → 0.3.2
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.
- package/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +17 -17
- package/.next/app-path-routes-manifest.json +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/1.pack +0 -0
- package/.next/cache/webpack/client-production/2.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack.old +0 -0
- package/.next/cache/webpack/edge-server-production/0.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/required-server-files.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app/update-check/route.js +1 -1
- package/.next/server/app/api/external-apps/[id]/health/route.js +1 -1
- package/.next/server/app/api/external-apps/[id]/route.js +1 -1
- package/.next/server/app/api/external-apps/route.js +1 -1
- package/.next/server/app/api/hooks/claude-done/route.js +1 -1
- package/.next/server/app/api/repositories/clone/[jobId]/route.js +1 -1
- package/.next/server/app/api/repositories/clone/route.js +1 -1
- package/.next/server/app/api/repositories/excluded/route.js +7 -7
- package/.next/server/app/api/repositories/restore/route.js +3 -3
- package/.next/server/app/api/repositories/route.js +13 -11
- package/.next/server/app/api/repositories/scan/route.js +1 -1
- package/.next/server/app/api/repositories/sync/route.js +3 -3
- package/.next/server/app/api/worktrees/[id]/auto-yes/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cli-tool/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/current-output/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route.js +1 -0
- package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route.js.nft.json +1 -0
- package/.next/server/app/api/worktrees/[id]/execution-logs/route.js +9 -0
- package/.next/server/app/api/worktrees/[id]/execution-logs/route.js.nft.json +1 -0
- package/.next/server/app/api/worktrees/[id]/files/[...path]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/interrupt/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/kill-session/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/[filename]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/route.js +2 -2
- package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/messages/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/prompt-response/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/respond/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js +1 -0
- package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js.nft.json +1 -0
- package/.next/server/app/api/worktrees/[id]/schedules/route.js +4 -0
- package/.next/server/app/api/worktrees/[id]/schedules/route.js.nft.json +1 -0
- package/.next/server/app/api/worktrees/[id]/search/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/send/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/slash-commands/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/start-polling/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/[...path]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/upload/[...path]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/viewed/route.js +1 -1
- package/.next/server/app/api/worktrees/route.js +1 -1
- package/.next/server/app/login/page.js.nft.json +1 -1
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/proxy/[...path]/route.js +1 -1
- package/.next/server/app/worktrees/[id]/files/[...path]/page.js.nft.json +1 -1
- package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/page.js +8 -3
- package/.next/server/app/worktrees/[id]/page.js.nft.json +1 -1
- package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/terminal/page.js.nft.json +1 -1
- package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +14 -10
- package/.next/server/chunks/2314.js +1 -0
- package/.next/server/chunks/3860.js +1 -1
- package/.next/server/chunks/6228.js +1 -0
- package/.next/server/chunks/7425.js +85 -30
- package/.next/server/chunks/7536.js +1 -1
- package/.next/server/functions-config-manifest.json +1 -1
- package/.next/server/middleware-manifest.json +5 -5
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/app/worktrees/[id]/page-0c889ab3f30d5af7.js +1 -0
- package/.next/static/css/bd6065b03ddb3efd.css +3 -0
- package/.next/trace +5 -5
- package/.next/types/app/api/worktrees/[id]/execution-logs/[logId]/route.ts +343 -0
- package/.next/types/app/api/worktrees/[id]/execution-logs/route.ts +343 -0
- package/.next/types/app/api/worktrees/[id]/schedules/[scheduleId]/route.ts +343 -0
- package/.next/types/app/api/worktrees/[id]/schedules/route.ts +343 -0
- package/dist/cli/utils/docs-reader.d.ts.map +1 -1
- package/dist/cli/utils/docs-reader.js +1 -0
- package/dist/server/server.js +5 -0
- package/dist/server/src/config/cmate-constants.js +79 -0
- package/dist/server/src/config/schedule-config.js +54 -0
- package/dist/server/src/lib/claude-executor.js +147 -0
- package/dist/server/src/lib/cmate-parser.js +240 -0
- package/dist/server/src/lib/db-instance.js +3 -0
- package/dist/server/src/lib/db-migrations.js +96 -2
- package/dist/server/src/lib/env-sanitizer.js +57 -0
- package/dist/server/src/lib/schedule-manager.js +397 -0
- package/dist/server/src/types/cmate.js +6 -0
- package/package.json +2 -1
- package/.next/static/chunks/app/worktrees/[id]/page-a556551ce5c69dec.js +0 -1
- package/.next/static/css/b9ea6a4fad17dc32.css +0 -3
- /package/.next/static/{hmAjbCPjxX_C0Os7rphI1 → j8HFvzDZj7tHjAnhpXUno}/_buildManifest.js +0 -0
- /package/.next/static/{hmAjbCPjxX_C0Os7rphI1 → j8HFvzDZj7tHjAnhpXUno}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.id=7536,exports.ids=[7536],exports.modules={89194:(e,t,s)=>{s.d(t,{Lg:()=>o,NA:()=>a});var n=s(10927),i=s(43839);let r=(0,s(43895).h)("cli-session");async function o(e,t){let s=i.g.getInstance().getTool(t).getSessionName(e);return await (0,n.Hk)(s)}async function a(e,t,s=1e3){let o=r.withContext({worktreeId:e,cliToolId:t});o.debug("captureSessionOutput:start",{requestedLines:s});let a=i.g.getInstance().getTool(t),l=a.getSessionName(e);if(!await (0,n.Hk)(l))throw o.debug("captureSessionOutput:sessionNotFound",{sessionName:l}),Error(`${a.name} session ${l} does not exist`);try{let e=await (0,n.xq)(l,{startLine:-s}),t=e.split("\n").length;return o.debug("captureSessionOutput:success",{actualLines:t,lastFewLines:e.split("\n").slice(-3).join(" | ")}),e}catch(t){let e=t instanceof Error?t.message:String(t);throw o.error("captureSessionOutput:failed",{error:e}),Error(`Failed to capture ${a.name} output: ${e}`)}}},43839:(e,t,s)=>{s.d(t,{g:()=>y});var n=s(61282),i=s(21764);let r=/^[a-zA-Z0-9_-]+$/;var o=s(10927);let a=(0,i.promisify)(n.exec);class l{async isInstalled(){try{return await a(`which ${this.command}`,{timeout:5e3}),!0}catch{return!1}}getSessionName(e){let t=`mcbd-${this.id}-${e}`;return function(e){if(!r.test(e))throw Error(`Invalid session name format: ${e}`)}(t),t}async interrupt(e){let t=this.getSessionName(e);await (0,o.ZV)(t,"Escape")}}var u=s(62648);class c extends l{async isInstalled(){return await (0,u.Uv)()}async isRunning(e){return await (0,u.YI)(e)}async startSession(e,t){await (0,u.ym)({worktreeId:e,worktreePath:t})}async sendMessage(e,t){await (0,u.xd)(e,t)}async killSession(e){await (0,u._f)(e)}constructor(...e){super(...e),this.id="claude",this.name="Claude Code",this.command="claude"}}var m=s(92900);let p=(0,i.promisify)(n.exec);function d(e){return e instanceof Error?e.message:String(e)}class f extends l{async isRunning(e){let t=this.getSessionName(e);return await (0,o.Hk)(t)}async startSession(e,t){if(!await this.isInstalled())throw Error("Codex CLI is not installed or not in PATH");let s=this.getSessionName(e);if(await (0,o.Hk)(s)){console.log(`Codex session ${s} already exists`);return}try{await (0,o.ed)({sessionName:s,workingDirectory:t,historyLimit:5e4}),await new Promise(e=>setTimeout(e,100)),await (0,o.Is)(s,"codex",!0),await new Promise(e=>setTimeout(e,3e3)),await (0,o.Is)(s,"2",!0),await new Promise(e=>setTimeout(e,200)),await p(`tmux send-keys -t "${s}" Down`),await new Promise(e=>setTimeout(e,200)),await p(`tmux send-keys -t "${s}" Enter`),await new Promise(e=>setTimeout(e,200)),console.log(`✓ Started Codex session: ${s}`)}catch(t){let e=d(t);throw Error(`Failed to start Codex session: ${e}`)}}async sendMessage(e,t){let s=this.getSessionName(e);if(!await (0,o.Hk)(s))throw Error(`Codex session ${s} does not exist. Start the session first.`);try{await (0,o.Is)(s,t,!1),await new Promise(e=>setTimeout(e,100)),await p(`tmux send-keys -t "${s}" C-m`),await new Promise(e=>setTimeout(e,200)),t.includes("\n")&&await (0,m.N)(s),console.log(`✓ Sent message to Codex session: ${s}`)}catch(t){let e=d(t);throw Error(`Failed to send message to Codex: ${e}`)}}async killSession(e){let t=this.getSessionName(e);try{await (0,o.Hk)(t)&&(await p(`tmux send-keys -t "${t}" C-d`),await new Promise(e=>setTimeout(e,500))),await (0,o.AJ)(t)&&console.log(`✓ Stopped Codex session: ${t}`)}catch(t){let e=d(t);throw console.error(`Error stopping Codex session: ${e}`),t}}constructor(...e){super(...e),this.id="codex",this.name="Codex CLI",this.command="codex"}}let h=(0,i.promisify)(n.exec);class g extends l{async isRunning(e){let t=this.getSessionName(e);return await (0,o.Hk)(t)}async startSession(e,t){if(!await this.isInstalled())throw Error("Gemini CLI is not installed or not in PATH");let s=this.getSessionName(e);if(await (0,o.Hk)(s)){console.log(`Gemini session ${s} already exists`);return}try{await (0,o.ed)({sessionName:s,workingDirectory:t,historyLimit:5e4}),console.log(`✓ Started Gemini session: ${s}`)}catch(t){let e=t instanceof Error?t.message:String(t);throw Error(`Failed to start Gemini session: ${e}`)}}async sendMessage(e,t){let s=this.getSessionName(e);if(!await (0,o.Hk)(s))throw Error(`Gemini session ${s} does not exist. Start the session first.`);try{let e=t.replace(/'/g,"'\\''");await (0,o.Is)(s,`echo '${e}' | gemini`,!0),console.log(`✓ Sent message to Gemini session: ${s}`)}catch(t){let e=t instanceof Error?t.message:String(t);throw Error(`Failed to send message to Gemini: ${e}`)}}async killSession(e){let t=this.getSessionName(e);try{await (0,o.Hk)(t)&&(await h(`tmux send-keys -t "${t}" C-d`),await new Promise(e=>setTimeout(e,500))),await (0,o.AJ)(t)&&console.log(`✓ Stopped Gemini session: ${t}`)}catch(t){let e=t instanceof Error?t.message:String(t);throw console.error(`Error stopping Gemini session: ${e}`),t}}constructor(...e){super(...e),this.id="gemini",this.name="Gemini CLI",this.command="gemini"}}var w=s(59991);class y{constructor(){this.tools=new Map,this.tools.set("claude",new c),this.tools.set("codex",new f),this.tools.set("gemini",new g)}static getInstance(){return y.instance||(y.instance=new y),y.instance}getTool(e){let t=this.tools.get(e);if(!t)throw Error(`CLI tool '${e}' not found`);return t}getAllTools(){return Array.from(this.tools.values())}async getToolInfo(e){let t=this.getTool(e),s=await t.isInstalled();return{id:t.id,name:t.name,command:t.command,installed:s}}async getAllToolsInfo(){return Promise.all(this.getAllTools().map(async e=>{let t=await e.isInstalled();return{id:e.id,name:e.name,command:e.command,installed:t}}))}async getInstalledTools(){return(await this.getAllToolsInfo()).filter(e=>e.installed)}stopPollers(e,t){(0,w.FN)(e,t)}}},63661:(e,t,s)=>{s.d(t,{F:()=>o,J:()=>f});let n=(0,s(43895).h)("prompt-detector"),i=[{regex:/^(.+)\s+\(y\/n\)\s*$/m},{regex:/^(.+)\s+\[y\/N\]\s*$/m,defaultOption:"no"},{regex:/^(.+)\s+\[Y\/n\]\s*$/m,defaultOption:"yes"},{regex:/^(.+)\s+\(yes\/no\)\s*$/m}];function r(e,t,s,n){return{isPrompt:!0,promptData:{type:"yes_no",question:e,options:["yes","no"],status:"pending",...void 0!==n&&{defaultOption:n},instructionText:s},cleanContent:t,rawContent:s}}function o(e,t){n.debug("detectPrompt:start",{outputLength:e.length});let s=e.split("\n").slice(-20).join("\n"),o=function(e,t){let s=t?.requireDefaultIndicator??!0,n=e.split("\n"),i=n.length;for(;i>0&&""===n[i-1].trim();)i--;let r=Math.max(0,i-50);if(s){let t=!1;for(let e=r;e<i;e++){let s=n[e].trim();if(l.test(s)){t=!0;break}}if(!t)return m(e)}let o=[],p=-1;for(let t=i-1;t>=r;t--){let s=n[t].trim(),i=s.match(l);if(i){let e=parseInt(i[1],10),t=i[2].trim();o.unshift({number:e,label:t,isDefault:!0});continue}let r=s.match(u);if(r){let e=parseInt(r[1],10),t=r[2].trim();o.unshift({number:e,label:t,isDefault:!1});continue}if(0===o.length&&s.startsWith("❯"))return m(e);if(o.length>0&&s&&!c.test(s)){if(d(s)){p=t;break}if(function(e,t){let s=t.endsWith("?")||t.endsWith("?");return!!(!s&&/^\s{2,}[^\d]/.test(e)&&!/^\s*\d+\./.test(e)||t.length<5&&!s||/^[\/~]/.test(t)||t.length>=2&&/^[a-zA-Z0-9_-]+$/.test(t))}(n[t],s))continue;p=t;break}}if(!function(e){if(0===e.length||1!==e[0])return!1;for(let t=1;t<e.length;t++)if(e[t]!==e[t-1]+1)return!1;return!0}(o.map(e=>e.number)))return m(e);let f=o.some(e=>e.isDefault);if(o.length<2||s&&!f||!s&&(-1===p||!d(n[p]?.trim()??"")&&!function(e,t,s,n){let i=Math.max(n,t-3);for(let s=t-1;s>=i;s--){let t=e[s]?.trim()??"";if(!(!t||c.test(t))&&d(t))return!0}return!1}(n,p,0,r)))return m(e);let h=function(e,t){if(t<0)return"Please select an option:";let s=[];for(let n=Math.max(0,t-5);n<=t;n++){let t=e[n].trim();t&&!c.test(t)&&s.push(t)}return s.join(" ")}(n,p),g=function(e,t,s){if(t<0)return;let n=e.slice(Math.max(0,t-19),s).map(e=>e.trimEnd()).join("\n").trim();return n.length>0?n:void 0}(n,p,i);return{isPrompt:!0,promptData:{type:"multiple_choice",question:h.trim(),options:o.map(e=>{let t=a.some(t=>t.test(e.label));return{number:e.number,label:e.label,isDefault:e.isDefault,requiresTextInput:t}}),status:"pending",instructionText:g},cleanContent:h.trim(),rawContent:function(e){let t=e.split("\n"),s=(t.length>200?t.slice(-200):t).join("\n");return s.length>5e3&&(s=s.slice(-5e3)),s}(e.trim())}}(e,t);if(o.isPrompt)return n.info("detectPrompt:multipleChoice",{isPrompt:!0,question:o.promptData?.question,optionsCount:o.promptData?.options?.length}),o;let p=s.trim();for(let e of i){let t=s.match(e.regex);if(t){let s=t[1].trim();return r(s,s,p,e.defaultOption)}}let f=s.match(/^(.*?)Approve\?\s*$/m);if(f){let e=f[1].trim();return r(e?`${e} Approve?`:"Approve?",e||"Approve?",p)}return n.debug("detectPrompt:complete",{isPrompt:!1}),{isPrompt:!1,cleanContent:e.trim()}}let a=[/type\s+here/i,/tell\s+(me|claude)/i,/enter\s+/i,/custom/i,/differently/i],l=/^\s*\u276F\s*(\d+)\.\s*(.+)$/,u=/^\s*(\d+)\.\s*(.+)$/,c=/^[-─]+$/;function m(e){return{isPrompt:!1,cleanContent:e.trim()}}let p=/(?:select|choose|pick|which|what|how|where|enter|type|specify|confirm|approve|accept|reject|decide|preference|option)/i;function d(e){return 0!==e.length&&!!(e.includes("?")||e.includes("?")||p.test(e))}function f(e,t="yes_no"){let s=e.toLowerCase().trim();if("multiple_choice"===t){if(/^\d+$/.test(s))return s;throw Error("Invalid answer for multiple choice prompt. Expected a number.")}if("yes"===s||"y"===s)return"y";if("no"===s||"n"===s)return"n";throw Error("Invalid answer for yes/no prompt. Expected 'yes', 'no', 'y', or 'n'.")}},59991:(e,t,s)=>{s.d(t,{FN:()=>S,RJ:()=>y,ci:()=>w,cn:()=>C});var n=s(89194),i=s(97425),r=s(75748),o=s(68507),a=s(63661),l=s(76966),u=s(89287),c=s(19377);let m=["Waiting for auth","⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function p(e){return{response:"",isComplete:!1,lineCount:e}}function d(e,t,s,n,i,r){let o=$(t,s,n,i,r),a=e.slice(o);return{response:(0,c.vp)(a.join("\n")),isComplete:!0,lineCount:s}}let f=new Map,h=new Map;function g(e,t){let s=(0,c.Sg)(t);return(0,a.F)((0,c.vp)(e),s)}function w(e){let t=(0,c.vp)(e).split("\n"),s=-1;for(let e=t.length-1;e>=0;e--)if(/^❯\s+\S/.test(t[e])){s=e;break}let n=s>=0?s+1:0,i=t.slice(n),r=[/CLAUDE_HOOKS_/,/\/bin\/claude/,/^claude\s*$/,/@.*\s+%\s*$/,/^[^⏺]*curl.*POST/,/^[^⏺]*Content-Type/,/^[^⏺]*export\s+CLAUDE_/,/^\s*$/,/^[╭╮╰╯│─\s]+$/,/^[│╭╮╰╯].*[│╭╮╰╯]$/,/Claude Code v[\d.]+/,/^Tips for getting started/,/^Welcome back/,/Run \/init to create/,/^Recent activity/,/^No recent activity/,/▐▛███▜▌|▝▜█████▛▘|▘▘ ▝▝/,/^\s*Opus \d+\.\d+\s*·\s*Claude Max/,/\.com's Organization/,/\?\s*for shortcuts\s*$/,/^─{10,}$/,/^❯\s*$/,c.d8],o=[];for(let e of i)!r.some(t=>t.test(e))&&e.trim()&&o.push(e);return o.join("\n").trim()}function y(e){let t=e.split("\n"),s=[],n=[/^maenokota@.*%/,/^zsh:/,/^feature-issue-\d+/,/^\s*$/],i=!1,r=[];for(let e of t){if(e.includes("✦")){i=!0;let t=e.indexOf("✦"),s=e.substring(t+1).trim();s&&r.push(s);continue}if(i){if(n.some(t=>t.test(e)))continue;r.push(e)}}if(r.length>0)return r.join("\n").trim();for(let e of t)n.some(t=>t.test(e))||s.push(e);return s.join("\n").trim()}function $(e,t,s,n,i){if((e=Math.max(0,e))>=t||s){let e=i(40);return e>=0?e+1:0}if("codex"===n)return Math.max(0,e);if(e>=t-5){let e=i(50);return e>=0?e+1:Math.max(0,t-40)}return Math.max(0,e)}async function x(e,t){let s=(0,i.n)();try{if(!(0,r.gU)(s,e))return console.error(`Worktree ${e} not found, stopping poller`),S(e,t),!1;if(!await (0,n.Lg)(e,t))return S(e,t),!1;let i=(0,r.zl)(s,e,t),a=i?.lastCapturedLine||0,f=await (0,n.NA)(e,t,1e4),h=function(e,t,s){let n=e.split("\n"),i=n.length;for(;i>0&&""===n[i-1].trim();)i--;let r=n.slice(0,i),o=r.length,a=o>0&&t>25&&o+25<t,l=o>0&&t>50&&o<50,u=a||l;if(!u&&o<t-5)return null;let f=Math.max(0,o-20),h=r.slice(f).join("\n"),{promptPattern:w,separatorPattern:y,thinkingPattern:x,skipPatterns:C}=(0,c.bs)(s),S=(e=60)=>{let t="codex"===s?/^›\s+(?!Implement|Find and fix|Type|Summarize)/:/^[>❯]\s+\S/;for(let s=o-1;s>=Math.max(0,o-e);s--){let e=(0,c.vp)(r[s]);if(t.test(e))return s}return -1};if("claude"===s&&g(r.join("\n"),s).isPrompt)return d(r,t,o,u,s,S);let I=(0,c.vp)(h),k=w.test(I),v=y.test(I),P=x.test(I),E=("codex"===s||"gemini"===s)&&k&&!P,T="claude"===s&&k&&v&&!P;if(E||T){let e=[],n=$(t,o,u,s,S),i=o;for(let t=n;t<o;t++){let n=r[t],o=(0,c.vp)(n);if("codex"===s&&/^›\s+/.test(o)||"gemini"===s&&/^(%|\$|.*@.*[%$#])\s*$/.test(o)){i=t;break}C.some(e=>e.test(o))||e.push(n)}let a=e.join("\n").trim(),l=a.split("\n").slice(-5).join("\n");if(x.test(l))return p(o);if("claude"===s){let e=(0,c.vp)(a),t=/[╭╮╰╯│]/.test(e)||/░{3,}/.test(e)||/▓{3,}/.test(e),s=/Claude Code|claude\/|v\d+\.\d+/.test(e),n=/Tip:|for shortcuts|\?\s*for help/.test(e),i=/^\s*\/Users\/.*$/m.test(e)&&e.split("\n").length<30,r=e.match(/^[>❯]\s+(\S.*)$/m);if(r){let t=e.indexOf(r[0]);if(0===e.substring(t+r[0].length).trim().split("\n").filter(e=>{let t=e.trim();return t&&!C.some(e=>e.test(t))&&!/^─+$/.test(t)}).length)return p(o)}else if((t||s||n||i)&&a.length<2e3)return p(o)}return"gemini"===s&&((a.match(/[░███]/g)||[]).length>.3*a.length||m.some(e=>a.includes(e))||!a.includes("✦")&&a.length<10)?p(o):{response:a,isComplete:!0,lineCount:i}}if(g(r.join("\n"),s).isPrompt)return d(r,t,o,u,s,S);let b=[],M=u||t>=o-5,N=M?S(80):-1,D=M?N>=0?N+1:Math.max(0,o-80):Math.max(0,t);for(let e=D;e<o;e++){let t=r[e],s=(0,c.vp)(t);C.some(e=>e.test(s))||b.push(t)}let A=b.join("\n").trim();return A?{response:A,isComplete:!1,lineCount:o}:p(o)}(f,a,t);if(!h||!h.isComplete){let{thinkingPattern:n}=(0,c.bs)(t),i=(0,c.vp)(f).split("\n").slice(-5).join("\n");if(n.test(i)){let n=(0,r.GP)(s,e,t);n>0&&console.log(`Marked ${n} pending prompt(s) as answered (thinking detected) for ${e}`)}return!1}if(h.lineCount===a&&!i?.inProgressMessageId)return!1;if(h.lineCount<=a)return console.log(`[checkForResponse] Already saved up to line ${a}, skipping (result: ${h.lineCount})`),!1;let x=g(h.response,t);if(x.isPrompt){(0,r.Mf)(s,e,t);let n=(0,r.tn)(s,{worktreeId:e,role:"assistant",content:x.rawContent||x.cleanContent,messageType:"prompt",promptData:x.promptData,timestamp:new Date,cliToolId:t});return(0,r.IH)(s,e,t,h.lineCount),(0,o.ps)("message",{worktreeId:e,message:n}),S(e,t),!0}if(!h.response||""===h.response.trim())return(0,r.IH)(s,e,t,h.lineCount),!1;let C="claude"===t?(0,u.Z)(h.response):void 0,I=h.response;if("gemini"===t?I=y(h.response):"claude"===t&&(I=w(h.response)),!I||""===I.trim()||"[No content]"===I)return(0,r.IH)(s,e,t,h.lineCount),(0,r.Mf)(s,e,t),!1;I&&await (0,l.o)(s,e,I,t);let k=(0,r.GP)(s,e,t);k>0&&console.log(`Marked ${k} pending prompt(s) as answered for ${e}`);let v=(0,r.zl)(s,e,t);if(v&&h.lineCount<=v.lastCapturedLine)return console.log(`[checkForResponse] Race condition detected, skipping save (result: ${h.lineCount}, current: ${v.lastCapturedLine})`),!1;let P=(0,r.tn)(s,{worktreeId:e,role:"assistant",content:I,messageType:"normal",timestamp:new Date,cliToolId:t,summary:C?.summary,logFileName:C?.logFileName,requestId:C?.requestId});return(0,o.ps)("message",{worktreeId:e,message:P}),(0,r.IH)(s,e,t,h.lineCount),!0}catch(t){return console.error(`Error checking for response (${e}):`,t instanceof Error?t.message:String(t)),!1}}function C(e,t){let s=`${e}:${t}`;S(e,t),h.set(s,Date.now());let n=setInterval(async()=>{let n=h.get(s);if(n&&Date.now()-n>18e5){S(e,t);return}try{await x(e,t)}catch(e){console.error("[Poller] Error:",e)}},2e3);f.set(s,n)}function S(e,t){let s=`${e}:${t}`,n=f.get(s);n&&(clearInterval(n),f.delete(s),h.delete(s))}}};
|
|
1
|
+
"use strict";exports.id=7536,exports.ids=[7536],exports.modules={89194:(e,t,s)=>{s.d(t,{Lg:()=>o,NA:()=>a});var n=s(10927),i=s(43839);let r=(0,s(43895).h)("cli-session");async function o(e,t){let s=i.g.getInstance().getTool(t).getSessionName(e);return await (0,n.Hk)(s)}async function a(e,t,s=1e3){let o=r.withContext({worktreeId:e,cliToolId:t});o.debug("captureSessionOutput:start",{requestedLines:s});let a=i.g.getInstance().getTool(t),l=a.getSessionName(e);if(!await (0,n.Hk)(l))throw o.debug("captureSessionOutput:sessionNotFound",{sessionName:l}),Error(`${a.name} session ${l} does not exist`);try{let e=await (0,n.xq)(l,{startLine:-s}),t=e.split("\n").length;return o.debug("captureSessionOutput:success",{actualLines:t,lastFewLines:e.split("\n").slice(-3).join(" | ")}),e}catch(t){let e=t instanceof Error?t.message:String(t);throw o.error("captureSessionOutput:failed",{error:e}),Error(`Failed to capture ${a.name} output: ${e}`)}}},43839:(e,t,s)=>{s.d(t,{g:()=>y});var n=s(61282),i=s(21764);let r=/^[a-zA-Z0-9_-]+$/;var o=s(10927);let a=(0,i.promisify)(n.exec);class l{async isInstalled(){try{return await a(`which ${this.command}`,{timeout:5e3}),!0}catch{return!1}}getSessionName(e){let t=`mcbd-${this.id}-${e}`;return function(e){if(!r.test(e))throw Error(`Invalid session name format: ${e}`)}(t),t}async interrupt(e){let t=this.getSessionName(e);await (0,o.ZV)(t,"Escape")}}var u=s(62648);class c extends l{async isInstalled(){return await (0,u.Uv)()}async isRunning(e){return await (0,u.YI)(e)}async startSession(e,t){await (0,u.ym)({worktreeId:e,worktreePath:t})}async sendMessage(e,t){await (0,u.xd)(e,t)}async killSession(e){await (0,u._f)(e)}constructor(...e){super(...e),this.id="claude",this.name="Claude Code",this.command="claude"}}var m=s(92900);let p=(0,i.promisify)(n.exec);function d(e){return e instanceof Error?e.message:String(e)}class f extends l{async isRunning(e){let t=this.getSessionName(e);return await (0,o.Hk)(t)}async startSession(e,t){if(!await this.isInstalled())throw Error("Codex CLI is not installed or not in PATH");let s=this.getSessionName(e);if(await (0,o.Hk)(s)){console.log(`Codex session ${s} already exists`);return}try{await (0,o.ed)({sessionName:s,workingDirectory:t,historyLimit:5e4}),await new Promise(e=>setTimeout(e,100)),await (0,o.Is)(s,"codex",!0),await new Promise(e=>setTimeout(e,3e3)),await (0,o.Is)(s,"2",!0),await new Promise(e=>setTimeout(e,200)),await p(`tmux send-keys -t "${s}" Down`),await new Promise(e=>setTimeout(e,200)),await p(`tmux send-keys -t "${s}" Enter`),await new Promise(e=>setTimeout(e,200)),console.log(`✓ Started Codex session: ${s}`)}catch(t){let e=d(t);throw Error(`Failed to start Codex session: ${e}`)}}async sendMessage(e,t){let s=this.getSessionName(e);if(!await (0,o.Hk)(s))throw Error(`Codex session ${s} does not exist. Start the session first.`);try{await (0,o.Is)(s,t,!1),await new Promise(e=>setTimeout(e,100)),await p(`tmux send-keys -t "${s}" C-m`),await new Promise(e=>setTimeout(e,200)),t.includes("\n")&&await (0,m.N)(s),console.log(`✓ Sent message to Codex session: ${s}`)}catch(t){let e=d(t);throw Error(`Failed to send message to Codex: ${e}`)}}async killSession(e){let t=this.getSessionName(e);try{await (0,o.Hk)(t)&&(await p(`tmux send-keys -t "${t}" C-d`),await new Promise(e=>setTimeout(e,500))),await (0,o.AJ)(t)&&console.log(`✓ Stopped Codex session: ${t}`)}catch(t){let e=d(t);throw console.error(`Error stopping Codex session: ${e}`),t}}constructor(...e){super(...e),this.id="codex",this.name="Codex CLI",this.command="codex"}}let g=(0,i.promisify)(n.exec);class h extends l{async isRunning(e){let t=this.getSessionName(e);return await (0,o.Hk)(t)}async startSession(e,t){if(!await this.isInstalled())throw Error("Gemini CLI is not installed or not in PATH");let s=this.getSessionName(e);if(await (0,o.Hk)(s)){console.log(`Gemini session ${s} already exists`);return}try{await (0,o.ed)({sessionName:s,workingDirectory:t,historyLimit:5e4}),console.log(`✓ Started Gemini session: ${s}`)}catch(t){let e=t instanceof Error?t.message:String(t);throw Error(`Failed to start Gemini session: ${e}`)}}async sendMessage(e,t){let s=this.getSessionName(e);if(!await (0,o.Hk)(s))throw Error(`Gemini session ${s} does not exist. Start the session first.`);try{let e=t.replace(/'/g,"'\\''");await (0,o.Is)(s,`echo '${e}' | gemini`,!0),console.log(`✓ Sent message to Gemini session: ${s}`)}catch(t){let e=t instanceof Error?t.message:String(t);throw Error(`Failed to send message to Gemini: ${e}`)}}async killSession(e){let t=this.getSessionName(e);try{await (0,o.Hk)(t)&&(await g(`tmux send-keys -t "${t}" C-d`),await new Promise(e=>setTimeout(e,500))),await (0,o.AJ)(t)&&console.log(`✓ Stopped Gemini session: ${t}`)}catch(t){let e=t instanceof Error?t.message:String(t);throw console.error(`Error stopping Gemini session: ${e}`),t}}constructor(...e){super(...e),this.id="gemini",this.name="Gemini CLI",this.command="gemini"}}var w=s(59991);class y{constructor(){this.tools=new Map,this.tools.set("claude",new c),this.tools.set("codex",new f),this.tools.set("gemini",new h)}static getInstance(){return y.instance||(y.instance=new y),y.instance}getTool(e){let t=this.tools.get(e);if(!t)throw Error(`CLI tool '${e}' not found`);return t}getAllTools(){return Array.from(this.tools.values())}async getToolInfo(e){let t=this.getTool(e),s=await t.isInstalled();return{id:t.id,name:t.name,command:t.command,installed:s}}async getAllToolsInfo(){return Promise.all(this.getAllTools().map(async e=>{let t=await e.isInstalled();return{id:e.id,name:e.name,command:e.command,installed:t}}))}async getInstalledTools(){return(await this.getAllToolsInfo()).filter(e=>e.installed)}stopPollers(e,t){(0,w.FN)(e,t)}}},63661:(e,t,s)=>{s.d(t,{F:()=>o,J:()=>f});let n=(0,s(43895).h)("prompt-detector"),i=[{regex:/^(.+)\s+\(y\/n\)\s*$/m},{regex:/^(.+)\s+\[y\/N\]\s*$/m,defaultOption:"no"},{regex:/^(.+)\s+\[Y\/n\]\s*$/m,defaultOption:"yes"},{regex:/^(.+)\s+\(yes\/no\)\s*$/m}];function r(e,t,s,n){return{isPrompt:!0,promptData:{type:"yes_no",question:e,options:["yes","no"],status:"pending",...void 0!==n&&{defaultOption:n},instructionText:s},cleanContent:t,rawContent:s}}function o(e,t){n.debug("detectPrompt:start",{outputLength:e.length});let s=e.split("\n").slice(-20).join("\n"),o=function(e,t){let s=t?.requireDefaultIndicator??!0,n=e.split("\n"),i=n.length;for(;i>0&&""===n[i-1].trim();)i--;let r=Math.max(0,i-50);if(s){let t=!1;for(let e=r;e<i;e++){let s=n[e].trim();if(l.test(s)){t=!0;break}}if(!t)return m(e)}let o=[],p=-1;for(let t=i-1;t>=r;t--){let s=n[t].trim(),i=s.match(l);if(i){let e=parseInt(i[1],10),t=i[2].trim();o.unshift({number:e,label:t,isDefault:!0});continue}let r=s.match(u);if(r){let e=parseInt(r[1],10),t=r[2].trim();o.unshift({number:e,label:t,isDefault:!1});continue}if(0===o.length&&s.startsWith("❯"))return m(e);if(o.length>0&&s&&!c.test(s)){if(d(s)){p=t;break}if(function(e,t){let s=t.endsWith("?")||t.endsWith("?");return!!(!s&&/^\s{2,}[^\d]/.test(e)&&!/^\s*\d+\./.test(e)||t.length<5&&!s||/^[\/~]/.test(t)||t.length>=2&&/^[a-zA-Z0-9_-]+$/.test(t))}(n[t],s))continue;p=t;break}}if(!function(e){if(0===e.length||1!==e[0])return!1;for(let t=1;t<e.length;t++)if(e[t]!==e[t-1]+1)return!1;return!0}(o.map(e=>e.number)))return m(e);let f=o.some(e=>e.isDefault);if(o.length<2||s&&!f||!s&&(-1===p||!d(n[p]?.trim()??"")&&!function(e,t,s,n){let i=Math.max(n,t-3);for(let s=t-1;s>=i;s--){let t=e[s]?.trim()??"";if(!(!t||c.test(t))&&d(t))return!0}return!1}(n,p,0,r)))return m(e);let g=function(e,t){if(t<0)return"Please select an option:";let s=[];for(let n=Math.max(0,t-5);n<=t;n++){let t=e[n].trim();t&&!c.test(t)&&s.push(t)}return s.join(" ")}(n,p),h=function(e,t,s){if(t<0)return;let n=e.slice(Math.max(0,t-19),s).map(e=>e.trimEnd()).join("\n").trim();return n.length>0?n:void 0}(n,p,i);return{isPrompt:!0,promptData:{type:"multiple_choice",question:g.trim(),options:o.map(e=>{let t=a.some(t=>t.test(e.label));return{number:e.number,label:e.label,isDefault:e.isDefault,requiresTextInput:t}}),status:"pending",instructionText:h},cleanContent:g.trim(),rawContent:function(e){let t=e.split("\n"),s=(t.length>200?t.slice(-200):t).join("\n");return s.length>5e3&&(s=s.slice(-5e3)),s}(e.trim())}}(e,t);if(o.isPrompt)return n.info("detectPrompt:multipleChoice",{isPrompt:!0,question:o.promptData?.question,optionsCount:o.promptData?.options?.length}),o;let p=s.trim();for(let e of i){let t=s.match(e.regex);if(t){let s=t[1].trim();return r(s,s,p,e.defaultOption)}}let f=s.match(/^(.*?)Approve\?\s*$/m);if(f){let e=f[1].trim();return r(e?`${e} Approve?`:"Approve?",e||"Approve?",p)}return n.debug("detectPrompt:complete",{isPrompt:!1}),{isPrompt:!1,cleanContent:e.trim()}}let a=[/type\s+here/i,/tell\s+(me|claude)/i,/enter\s+/i,/custom/i,/differently/i],l=/^\s*\u276F\s*(\d+)\.\s*(.+)$/,u=/^\s*(\d+)\.\s*(.+)$/,c=/^[-─]+$/;function m(e){return{isPrompt:!1,cleanContent:e.trim()}}let p=/(?:select|choose|pick|which|what|how|where|enter|type|specify|confirm|approve|accept|reject|decide|preference|option)/i;function d(e){return 0!==e.length&&!!(e.includes("?")||e.includes("?")||p.test(e))}function f(e,t="yes_no"){let s=e.toLowerCase().trim();if("multiple_choice"===t){if(/^\d+$/.test(s))return s;throw Error("Invalid answer for multiple choice prompt. Expected a number.")}if("yes"===s||"y"===s)return"y";if("no"===s||"n"===s)return"n";throw Error("Invalid answer for yes/no prompt. Expected 'yes', 'no', 'y', or 'n'.")}},59991:(e,t,s)=>{s.d(t,{FN:()=>S,RJ:()=>y,ci:()=>w,cn:()=>C});var n=s(89194),i=s(97425),r=s(75748),o=s(68507),a=s(63661),l=s(76966),u=s(89287),c=s(19377);let m=["Waiting for auth","⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function p(e){return{response:"",isComplete:!1,lineCount:e}}function d(e,t,s,n,i,r){let o=$(t,s,n,i,r),a=e.slice(o);return{response:(0,c.vp)(a.join("\n")),isComplete:!0,lineCount:s}}let f=new Map,g=new Map;function h(e,t){let s=(0,c.Sg)(t);return(0,a.F)((0,c.vp)(e),s)}function w(e){let t=(0,c.vp)(e).split("\n"),s=-1;for(let e=t.length-1;e>=0;e--)if(/^❯\s+\S/.test(t[e])){s=e;break}let n=s>=0?s+1:0,i=t.slice(n),r=[/CLAUDE_HOOKS_/,/\/bin\/claude/,/^claude\s*$/,/@.*\s+%\s*$/,/^[^⏺]*curl.*POST/,/^[^⏺]*Content-Type/,/^[^⏺]*export\s+CLAUDE_/,/^\s*$/,/^[╭╮╰╯│─\s]+$/,/^[│╭╮╰╯].*[│╭╮╰╯]$/,/Claude Code v[\d.]+/,/^Tips for getting started/,/^Welcome back/,/Run \/init to create/,/^Recent activity/,/^No recent activity/,/▐▛███▜▌|▝▜█████▛▘|▘▘ ▝▝/,/^\s*Opus \d+\.\d+\s*·\s*Claude Max/,/\.com's Organization/,/\?\s*for shortcuts\s*$/,/^─{10,}$/,/^❯\s*$/,c.d8],o=[];for(let e of i)!r.some(t=>t.test(e))&&e.trim()&&o.push(e);return o.join("\n").trim()}function y(e){let t=e.split("\n"),s=[],n=[/^maenokota@.*%/,/^zsh:/,/^feature-issue-\d+/,/^\s*$/],i=!1,r=[];for(let e of t){if(e.includes("✦")){i=!0;let t=e.indexOf("✦"),s=e.substring(t+1).trim();s&&r.push(s);continue}if(i){if(n.some(t=>t.test(e)))continue;r.push(e)}}if(r.length>0)return r.join("\n").trim();for(let e of t)n.some(t=>t.test(e))||s.push(e);return s.join("\n").trim()}function $(e,t,s,n,i){if((e=Math.max(0,e))>=t||s){let e=i(40);return e>=0?e+1:0}if("codex"===n)return Math.max(0,e);if(e>=t-5){let e=i(50);return e>=0?e+1:Math.max(0,t-40)}return Math.max(0,e)}async function x(e,t){let s=(0,i.getDbInstance)();try{if(!(0,r.gU)(s,e))return console.error(`Worktree ${e} not found, stopping poller`),S(e,t),!1;if(!await (0,n.Lg)(e,t))return S(e,t),!1;let i=(0,r.zl)(s,e,t),a=i?.lastCapturedLine||0,f=await (0,n.NA)(e,t,1e4),g=function(e,t,s){let n=e.split("\n"),i=n.length;for(;i>0&&""===n[i-1].trim();)i--;let r=n.slice(0,i),o=r.length,a=o>0&&t>25&&o+25<t,l=o>0&&t>50&&o<50,u=a||l;if(!u&&o<t-5)return null;let f=Math.max(0,o-20),g=r.slice(f).join("\n"),{promptPattern:w,separatorPattern:y,thinkingPattern:x,skipPatterns:C}=(0,c.bs)(s),S=(e=60)=>{let t="codex"===s?/^›\s+(?!Implement|Find and fix|Type|Summarize)/:/^[>❯]\s+\S/;for(let s=o-1;s>=Math.max(0,o-e);s--){let e=(0,c.vp)(r[s]);if(t.test(e))return s}return -1};if("claude"===s&&h(r.join("\n"),s).isPrompt)return d(r,t,o,u,s,S);let I=(0,c.vp)(g),k=w.test(I),v=y.test(I),P=x.test(I),E=("codex"===s||"gemini"===s)&&k&&!P,T="claude"===s&&k&&v&&!P;if(E||T){let e=[],n=$(t,o,u,s,S),i=o;for(let t=n;t<o;t++){let n=r[t],o=(0,c.vp)(n);if("codex"===s&&/^›\s+/.test(o)||"gemini"===s&&/^(%|\$|.*@.*[%$#])\s*$/.test(o)){i=t;break}C.some(e=>e.test(o))||e.push(n)}let a=e.join("\n").trim(),l=a.split("\n").slice(-5).join("\n");if(x.test(l))return p(o);if("claude"===s){let e=(0,c.vp)(a),t=/[╭╮╰╯│]/.test(e)||/░{3,}/.test(e)||/▓{3,}/.test(e),s=/Claude Code|claude\/|v\d+\.\d+/.test(e),n=/Tip:|for shortcuts|\?\s*for help/.test(e),i=/^\s*\/Users\/.*$/m.test(e)&&e.split("\n").length<30,r=e.match(/^[>❯]\s+(\S.*)$/m);if(r){let t=e.indexOf(r[0]);if(0===e.substring(t+r[0].length).trim().split("\n").filter(e=>{let t=e.trim();return t&&!C.some(e=>e.test(t))&&!/^─+$/.test(t)}).length)return p(o)}else if((t||s||n||i)&&a.length<2e3)return p(o)}return"gemini"===s&&((a.match(/[░███]/g)||[]).length>.3*a.length||m.some(e=>a.includes(e))||!a.includes("✦")&&a.length<10)?p(o):{response:a,isComplete:!0,lineCount:i}}if(h(r.join("\n"),s).isPrompt)return d(r,t,o,u,s,S);let b=[],M=u||t>=o-5,N=M?S(80):-1,D=M?N>=0?N+1:Math.max(0,o-80):Math.max(0,t);for(let e=D;e<o;e++){let t=r[e],s=(0,c.vp)(t);C.some(e=>e.test(s))||b.push(t)}let A=b.join("\n").trim();return A?{response:A,isComplete:!1,lineCount:o}:p(o)}(f,a,t);if(!g||!g.isComplete){let{thinkingPattern:n}=(0,c.bs)(t),i=(0,c.vp)(f).split("\n").slice(-5).join("\n");if(n.test(i)){let n=(0,r.GP)(s,e,t);n>0&&console.log(`Marked ${n} pending prompt(s) as answered (thinking detected) for ${e}`)}return!1}if(g.lineCount===a&&!i?.inProgressMessageId)return!1;if(g.lineCount<=a)return console.log(`[checkForResponse] Already saved up to line ${a}, skipping (result: ${g.lineCount})`),!1;let x=h(g.response,t);if(x.isPrompt){(0,r.Mf)(s,e,t);let n=(0,r.tn)(s,{worktreeId:e,role:"assistant",content:x.rawContent||x.cleanContent,messageType:"prompt",promptData:x.promptData,timestamp:new Date,cliToolId:t});return(0,r.IH)(s,e,t,g.lineCount),(0,o.ps)("message",{worktreeId:e,message:n}),S(e,t),!0}if(!g.response||""===g.response.trim())return(0,r.IH)(s,e,t,g.lineCount),!1;let C="claude"===t?(0,u.Z)(g.response):void 0,I=g.response;if("gemini"===t?I=y(g.response):"claude"===t&&(I=w(g.response)),!I||""===I.trim()||"[No content]"===I)return(0,r.IH)(s,e,t,g.lineCount),(0,r.Mf)(s,e,t),!1;I&&await (0,l.o)(s,e,I,t);let k=(0,r.GP)(s,e,t);k>0&&console.log(`Marked ${k} pending prompt(s) as answered for ${e}`);let v=(0,r.zl)(s,e,t);if(v&&g.lineCount<=v.lastCapturedLine)return console.log(`[checkForResponse] Race condition detected, skipping save (result: ${g.lineCount}, current: ${v.lastCapturedLine})`),!1;let P=(0,r.tn)(s,{worktreeId:e,role:"assistant",content:I,messageType:"normal",timestamp:new Date,cliToolId:t,summary:C?.summary,logFileName:C?.logFileName,requestId:C?.requestId});return(0,o.ps)("message",{worktreeId:e,message:P}),(0,r.IH)(s,e,t,g.lineCount),!0}catch(t){return console.error(`Error checking for response (${e}):`,t instanceof Error?t.message:String(t)),!1}}function C(e,t){let s=`${e}:${t}`;S(e,t),g.set(s,Date.now());let n=setInterval(async()=>{let n=g.get(s);if(n&&Date.now()-n>18e5){S(e,t);return}try{await x(e,t)}catch(e){console.error("[Poller] Error:",e)}},2e3);f.set(s,n)}function S(e,t){let s=`${e}:${t}`,n=f.get(s);n&&(clearInterval(n),f.delete(s),g.delete(s))}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":1,"functions":{"/api/app/update-check":{},"/api/
|
|
1
|
+
{"version":1,"functions":{"/api/app/update-check":{},"/api/external-apps/[id]/health":{},"/api/external-apps/[id]":{},"/api/external-apps":{},"/api/auth/status":{},"/api/worktrees/[id]/logs/[filename]":{},"/api/worktrees/[id]/logs":{},"/api/worktrees":{},"/proxy/[...path]":{}}}
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"wasm": [],
|
|
18
18
|
"assets": [],
|
|
19
19
|
"env": {
|
|
20
|
-
"__NEXT_BUILD_ID": "
|
|
21
|
-
"NEXT_SERVER_ACTIONS_ENCRYPTION_KEY": "
|
|
22
|
-
"__NEXT_PREVIEW_MODE_ID": "
|
|
23
|
-
"__NEXT_PREVIEW_MODE_ENCRYPTION_KEY": "
|
|
24
|
-
"__NEXT_PREVIEW_MODE_SIGNING_KEY": "
|
|
20
|
+
"__NEXT_BUILD_ID": "j8HFvzDZj7tHjAnhpXUno",
|
|
21
|
+
"NEXT_SERVER_ACTIONS_ENCRYPTION_KEY": "7A+IEUNscHQfPu+2/wFZTP1war59FAH/S7w0MNJ+QsI=",
|
|
22
|
+
"__NEXT_PREVIEW_MODE_ID": "15473dfdcc7fa96c4bce23e42905b6d0",
|
|
23
|
+
"__NEXT_PREVIEW_MODE_ENCRYPTION_KEY": "e2e5c7b4b10b2917e0ef3813fb1a206d6d8ab171d63ad90a1e34ff73607b5f63",
|
|
24
|
+
"__NEXT_PREVIEW_MODE_SIGNING_KEY": "62930ceda175fa74eca9c5a4f818fae279612ba1122751bc0621f05d39fdcad7"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>500: Internal Server Error</title><meta name="next-head-count" content="3"/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-3c0ee3ce5b546818.js" defer=""></script><script src="/_next/static/chunks/framework-8e0e0f4a6b83a956.js" defer=""></script><script src="/_next/static/chunks/main-db79434ee4a6c931.js" defer=""></script><script src="/_next/static/chunks/pages/_app-3c9ca398d360b709.js" defer=""></script><script src="/_next/static/chunks/pages/_error-cf5ca766ac8f493f.js" defer=""></script><script src="/_next/static/
|
|
1
|
+
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>500: Internal Server Error</title><meta name="next-head-count" content="3"/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-3c0ee3ce5b546818.js" defer=""></script><script src="/_next/static/chunks/framework-8e0e0f4a6b83a956.js" defer=""></script><script src="/_next/static/chunks/main-db79434ee4a6c931.js" defer=""></script><script src="/_next/static/chunks/pages/_app-3c9ca398d360b709.js" defer=""></script><script src="/_next/static/chunks/pages/_error-cf5ca766ac8f493f.js" defer=""></script><script src="/_next/static/j8HFvzDZj7tHjAnhpXUno/_buildManifest.js" defer=""></script><script src="/_next/static/j8HFvzDZj7tHjAnhpXUno/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":500}},"page":"/_error","query":{},"buildId":"j8HFvzDZj7tHjAnhpXUno","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"node":{},"edge":{},"encryptionKey":"
|
|
1
|
+
{"node":{},"edge":{},"encryptionKey":"7A+IEUNscHQfPu+2/wFZTP1war59FAH/S7w0MNJ+QsI="}
|
|
@@ -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,6725))},6725:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return au}});var r=a(57437),s=a(99376),n=a(8820),l=a(2265);let i={output:"",realtimeSnippet:"",isActive:!1,isThinking:!1,autoScroll:!0,lastUpdated:null},o={data:null,messageId:null,visible:!1,answering:!1},c={mode:"split",mobileActivePane:"terminal",leftPaneTab:"history",splitRatio:.5},d={type:null,message:null,retryable:!1,retryCount:0};function u(){return{phase:"idle",terminal:{...i},prompt:{...o},layout:{...c},error:{...d},messages:[],wsConnected:!1}}function m(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:{...o}};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:{...d}};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:{...o}};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:{...i},prompt:{...o}};default:return e}}var x=a(58819),h=a(43241),p=a(38706);class f 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)(g,{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 g(e){let{componentName:t,error:a,onRetry:s}=e,n=(0,p.T)("error"),l=(0,p.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")})]})}let b=["flex-shrink-0","bg-gray-700","transition-colors","duration-150","hover:bg-blue-500","focus:outline-none","focus:ring-2","focus:ring-blue-500","focus:ring-offset-2","focus:ring-offset-gray-900"],y=["w-1","h-full","cursor-col-resize","hover:w-2"],v=["h-1","w-full","cursor-row-resize","hover:h-2"];function j(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 w=(0,l.memo)(function(e){let{onResize:t,orientation:a="horizontal",ariaValueNow:s=50,onDoubleClick:n,minRatio:i=.1}=e,[o,c]=(0,l.useState)(!1),d=(0,l.useRef)(0),u=(0,l.useRef)(null),m="horizontal"===a,x=(0,l.useCallback)(e=>{e.preventDefault(),c(!0),d.current=j(e,m)},[m]),h=(0,l.useCallback)(e=>{1===e.touches.length&&(c(!0),d.current=j(e,m))},[m]),p=(0,l.useCallback)(e=>{if(!o)return;let a=j(e,m);t(a-d.current),d.current=a},[o,m,t]),f=(0,l.useCallback)(e=>{if(!o||1!==e.touches.length)return;let a=j(e,m);t(a-d.current),d.current=a},[o,m,t]),g=(0,l.useCallback)(()=>{c(!1)},[]),w=(0,l.useCallback)(()=>{n&&n()},[n]),N=(0,l.useCallback)(e=>{let a=0;m?"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))},[m,t]);(0,l.useEffect)(()=>(o&&(document.addEventListener("mousemove",p),document.addEventListener("mouseup",g),document.addEventListener("touchmove",f),document.addEventListener("touchend",g),document.body.style.userSelect="none",document.body.style.cursor=m?"col-resize":"row-resize"),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",g),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",g),document.body.style.userSelect="",document.body.style.cursor=""}),[o,p,g,f,m]);let k=(0,l.useMemo)(()=>[...b,...m?y:v,...o?["bg-blue-500","dragging",m?"w-2":"h-2"]:[]].join(" "),[m,o]);return(0,r.jsx)("div",{ref:u,role:"separator","aria-orientation":a,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100,"aria-label":"Resize panes. Use ".concat(m?"left and right":"up and down"," arrow keys to adjust."),tabIndex:0,className:k,onMouseDown:x,onTouchStart:h,onKeyDown:N,onDoubleClick:w})}),N={left:"History",right:"Terminal"},k={left:"HistoryPane",right:"TerminalPane"},C=(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:N[t]})}),S=(0,l.memo)(function(e){let{leftPane:t,rightPane:a}=e,[s,n]=(0,l.useState)("right"),i=(0,l.useCallback)(()=>n("left"),[]),o=(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)(C,{pane:"left",isActive:"left"===s,onClick:i}),(0,r.jsx)(C,{pane:"right",isActive:"right"===s,onClick:o})]}),(0,r.jsx)("div",{id:"".concat(s,"-panel"),role:"tabpanel",className:"flex-1 overflow-hidden",children:(0,r.jsx)(f,{componentName:k[s],children:"left"===s?t:a})})]})}),E=(0,l.memo)(function(e){let{leftPane:t,rightPane:a,leftWidth:s,onResize:n,className:i}=e,o=(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(i).trim(),[i]);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:o,className:"flex-shrink-0 overflow-hidden",children:(0,r.jsx)(f,{componentName:k.left,children:t})}),(0,r.jsx)(w,{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)(f,{componentName:k.right,children:a})})]})}),T=(0,l.memo)(function(e){let{leftPane:t,rightPane:a,initialLeftWidth:s=50,minLeftWidth:n=20,maxLeftWidth:i=80,className:o=""}=e,c=(0,x.d)(),d=(0,l.useRef)(null),[u,m]=(0,l.useState)(s),h=(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(i,Math.max(n,e+r)))},[n,i]);return c?(0,r.jsx)(S,{leftPane:t,rightPane:a}):(0,r.jsx)("div",{ref:d,className:"h-full",children:(0,r.jsx)(E,{leftPane:t,rightPane:a,leftWidth:u,onResize:h,className:o})})});var M=a(47835),R=a.n(M),L=a(34343);let F=new(a.n(L)())({fg:"#d1d5db",bg:"#1f2937",newline:!0,escapeXML:!0});function P(){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:i,className:o=""}=e,{scrollRef:c,autoScroll:d,handleScroll:u,scrollToBottom:m}=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),i=(0,l.useCallback)(e=>{n(e),null==a||a(e)},[a]),o=(0,l.useCallback)(()=>{let e=r.current;if(!e)return!0;let{scrollTop:t,scrollHeight:a,clientHeight:s}=e;return a-s-t<=50},[]),c=(0,l.useCallback)(()=>{let e=o();e&&!s?i(!0):!e&&s&&i(!1)},[s,o,i]),d=(0,l.useCallback)(()=>{let e=r.current;e&&(e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),s||i(!0))},[s,i]);return{scrollRef:r,autoScroll:s,setAutoScroll:i,scrollToBottom:d,handleScroll:c}}({initialAutoScroll:n,onAutoScrollChange:i}),x=function(e){let t=F.toHtml(e);return R().sanitize(t,{ALLOWED_TAGS:["span","br"],ALLOWED_ATTR:["style"],ALLOW_DATA_ATTR:!1})}(t||"");(0,l.useEffect)(()=>{d&&c.current&&c.current.scrollTo({top:c.current.scrollHeight,behavior:"instant"})},[x,d,c]);let h=(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":"",o].filter(Boolean).join(" "),[a,o]);return(0,r.jsxs)("div",{className:"relative h-full flex flex-col",children:[(0,r.jsxs)("div",{ref:c,role:"log","aria-live":"polite","aria-label":"Terminal output",className:h,onScroll:u,children:[(0,r.jsx)("div",{className:"whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:x}}),a&&s&&(0,r.jsx)(P,{})]}),!d&&(0,r.jsx)("button",{onClick:m,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 D=a(78867);let I=/(\/[^\s\n<>"']+\.[a-zA-Z0-9]+)/g;function _(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(I);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 z(){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 W=(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)(D.Z,{size:14,"aria-hidden":"true"})})]})}),B=(0,l.memo)(function(e){let{message:t,index:a,total:s,isExpanded:n,onFilePathClick:i,onCopy:o}=e,c=(0,l.useMemo)(()=>t.timestamp.toLocaleTimeString(),[t.timestamp]),{text:d,isTruncated:u}=(0,l.useMemo)(()=>_(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:i}),!n&&u&&(0,r.jsx)("span",{className:"text-gray-500",children:"..."})]}),o&&(0,r.jsx)("button",{type:"button","data-testid":"copy-assistant-message",onClick:()=>o(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)(D.Z,{size:14,"aria-hidden":"true"})})]})}),U=(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,i)=>(0,r.jsxs)(l.Fragment,{children:[i>0&&(0,r.jsx)("div",{"data-testid":"assistant-message-divider",className:"border-t border-dashed border-gray-600"}),(0,r.jsx)(B,{message:e,index:i,total:t.length,isExpanded:a,onFilePathClick:s,onCopy:n})]},e.id))})});function V(){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 H=(0,l.memo)(function(e){let{pair:t,onFilePathClick:a,isExpanded:s=!1,onToggleExpand:n,onCopy:i}=e,o=(0,l.useMemo)(()=>t.assistantMessages.some(e=>{let{isTruncated:t}=_(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)(V,{}),t.userMessage&&(0,r.jsx)(W,{message:t.userMessage,onFilePathClick:a,onCopy:i}),"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)(z,{})}):t.assistantMessages.length>0?(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(U,{messages:t.assistantMessages,isExpanded:s,onFilePathClick:a,onCopy:i}),o&&(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 Z=a(32636);function Y(){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 q(){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 G=["h-full","flex","flex-col","overflow-y-auto","overflow-x-hidden","bg-gray-900","rounded-lg","border","border-gray-700"],K=(0,l.memo)(function(e){let{messages:t,worktreeId:a,onFilePathClick:s,isLoading:n=!1,className:i="",showToast:o}=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]),i=(0,l.useCallback)(()=>{r(new Set(t.map(e=>e.id)))},[t]);return{pairs:t,expandedPairs:a,toggleExpand:s,isExpanded:n,expandAll:i,collapseAll:(0,l.useCallback)(()=>{r(new Set)},[])}}(t),p=(0,l.useMemo)(()=>[...G,i].filter(Boolean).join(" "),[i]),f=(0,l.useCallback)(e=>s(e),[s]),g=(0,l.useCallback)(e=>()=>h(e),[h]),b=(0,l.useCallback)(async e=>{try{await (0,Z.v)(e),null==o||o("Copied to clipboard","success")}catch(e){console.error("[HistoryPane] Failed to copy to clipboard"),null==o||o("Failed to copy","error")}},[o]);return(0,r.jsxs)("div",{ref:c,role:"region","aria-label":"Message history",className:p,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)(Y,{}):0===t.length?(0,r.jsx)(q,{}):m.map(e=>(0,r.jsx)(H,{pair:e,onFilePathClick:f,isExpanded:x(e.id),onToggleExpand:g(e.id),onCopy:b},e.id))})]})}),X={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",none:""};function J(e){let{visible:t,duration:a=200}=e,[r,s]=(0,l.useState)(t?"visible":"hidden"),n=(0,l.useRef)(null),i=(0,l.useRef)(t);(0,l.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]),(0,l.useEffect)(()=>{let e=i.current;i.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 o="hidden"!==r,c="fade-in"===r||"fade-out"===r;return{shouldRender:o,animationClass:(0,l.useMemo)(()=>{switch(r){case"fade-in":return X.fadeIn;case"fade-out":return X.fadeOut;default:return X.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(),$="bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500";function ee(e){let{promptData:t,answering:a,onRespond:s,onDismiss:n,labelId:i}=e,o=(0,p.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),f=(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]),g=(null==f?void 0:f.requiresTextInput)===!0,b=a||x,y=(0,l.useCallback)(async e=>{if(!b){h(!0);try{await s(e)}catch(e){}finally{h(!1)}}},[b,s]),v=(0,l.useCallback)(async()=>{if(!b&&null!==c){h(!0);try{let e=g&&u.trim()?u.trim():c.toString();await s(e)}catch(e){}finally{h(!1)}}},[b,s,c,g,u]);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:i,className:"text-lg font-semibold text-yellow-800 flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xl","aria-hidden":"true",children:"?"}),o("confirmationFromClaude")]}),n&&(0,r.jsx)("button",{type:"button",onClick:n,"aria-label":"close",className:"p-1 rounded hover:bg-yellow-200 transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5 text-yellow-700",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 bg-gray-50 rounded p-2 border border-gray-200",children:t.instructionText}),(0,r.jsx)("p",{className:"text-gray-800 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",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:o("sending")})]}),"yes_no"===t.type&&(0,r.jsx)(et,{promptData:t,disabled:b,onYes:()=>y("yes"),onNo:()=>y("no")}),"multiple_choice"===t.type&&(0,r.jsx)(ea,{promptData:t,disabled:b,selectedOption:c,onSelectOption:d,textInputValue:u,onTextInputChange:m,showTextInput:g,onSubmit:v})]})}function et(e){let{promptData:t,disabled:a,onYes:s,onNo:n}=e,l=(0,p.T)("prompt"),i="yes"===t.defaultOption,o="no"===t.defaultOption,c="".concat(Q," ").concat($," ").concat(i?"primary default highlighted":""),d="".concat(Q," ").concat(o?"bg-gray-600 text-white hover:bg-gray-700 primary default highlighted":"bg-white border-2 border-gray-300 hover:bg-gray-50 text-gray-800 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 ea(e){let{promptData:t,disabled:a,selectedOption:s,onSelectOption:n,textInputValue:i,onTextInputChange:o,showTextInput:c,onSubmit:d}=e,u=(0,l.useId)(),m=(0,p.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-blue-50 border-2 border-blue-500":"bg-white border-2 border-gray-200 hover:border-gray-300"," ").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-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:i,onChange:e=>o(e.target.value),disabled:a,placeholder:m("enterValuePlaceholder"),className:"w-full px-4 py-2 border-2 border-gray-300 rounded-lg 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(Q," ").concat($),children:m("submit")})]})}function er(e){let t,{promptData:a,messageId:s,visible:n,answering:i,onRespond:o,onDismiss:c}=e,{shouldRender:d,animationClass:u}=J({visible:n&&null!==a,duration:200}),m=(0,l.useId)();if(!d||!a)return null;let x=(t="opacity-100","animate-fade-in"===u?t="opacity-100 transform translate-y-0":"animate-fade-out"===u&&(t="opacity-0 transform translate-y-2"),"".concat("bg-yellow-50 border-2 border-yellow-300 rounded-lg p-4 shadow-lg transition-all duration-200 ease-in-out"," ").concat(u," ").concat(t));return(0,r.jsx)(f,{componentName:"PromptPanel",children:(0,r.jsx)("div",{"data-testid":"prompt-panel",role:"dialog","aria-labelledby":m,"aria-modal":"true",className:x,children:(0,r.jsx)(ee,{promptData:a,answering:i,onRespond:o,onDismiss:c,labelId:m})})})}var es=a(8672),en=a(93448);let el=(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})})}),ei={back:"M15 19l-7-7 7-7",menu:"M4 6h16M4 12h16M4 18h16"};function eo(e){let{worktreeName:t,repositoryName:a,status:s,gitStatus:n,onBackClick:i,onMenuClick:o}=e,c=(0,l.useMemo)(()=>es.xh[s],[s]);return(0,r.jsx)("header",{"data-testid":"mobile-header",role:"banner",className:"fixed top-0 inset-x-0 bg-white border-b border-gray-200 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:i&&(0,r.jsx)("button",{type:"button",onClick:i,"aria-label":"Back",className:"p-2 -ml-2 rounded-full hover:bg-gray-100 transition-colors",children:(0,r.jsx)(el,{path:ei.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 truncate text-center leading-tight",children:t}),(0,r.jsxs)("div",{className:"flex items-center gap-1 text-xs text-gray-500",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",children:"/"}),(0,r.jsx)("span",{className:"truncate max-w-[80px] font-mono",title:n.currentBranch,"data-testid":"mobile-branch-name",children:(0,en.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:o&&(0,r.jsx)("button",{type:"button",onClick:o,"aria-label":"Menu",className:"p-2 -mr-2 rounded-full hover:bg-gray-100 transition-colors",children:(0,r.jsx)(el,{path:ei.menu})})})]})})}function ec(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-blue-500 ".concat(s).trim(),"aria-label":a})}let ed=(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})})}),eu=[{id:"terminal",label:"Terminal",icon:(0,r.jsx)(ed,{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)(ed,{path:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})},{id:"files",label:"Files",icon:(0,r.jsx)(ed,{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)(ed,{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)(ed,{path:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}];function em(e){let{activeTab:t,onTabChange:a,hasNewOutput:s=!1,hasPrompt:n=!1,hasUpdate:i=!1}=e,o=(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-blue-600 bg-blue-50":"text-gray-500 hover:text-gray-700 hover:bg-gray-50")},[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 border-t border-gray-200 flex pb-safe z-40",children:eu.map(e=>(0,r.jsxs)("button",{type:"button",role:"tab","aria-selected":t===e.id,"aria-label":e.label,onClick:()=>a(e.id),className:o(e.id),children:[e.icon,(0,r.jsx)("span",{className:"text-xs mt-1",children:e.label}),"terminal"===e.id&&c,"info"===e.id&&i&&(0,r.jsx)(ec,{"data-testid":"info-update-badge",className:"absolute top-1 right-1","aria-label":"Update available"})]},e.id))})}let ex={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 border-2 border-gray-300 hover:bg-gray-50 text-gray-800 focus:ring-gray-500",defaultSelected:"bg-gray-600 text-white hover:bg-gray-700"};function eh(e){let{promptData:t,visible:a,answering:s,onRespond:n,onDismiss:i}=e,{shouldRender:o,animationClass:c}=J({visible:a&&null!==t,duration:300}),d=(0,l.useId)(),[u,m]=(0,l.useState)(null),[x,h]=(0,l.useState)(0),p=(0,l.useRef)(null);(0,l.useEffect)(()=>{a||h(0)},[a]);let g=(0,l.useCallback)(e=>{m(e.touches[0].clientY)},[]),b=(0,l.useCallback)(e=>{if(null===u)return;let t=e.touches[0].clientY-u;t>0&&h(t)},[u]),y=(0,l.useCallback)(()=>{x>100&&i&&i(),h(0),m(null)},[x,i]),v=(0,l.useCallback)(()=>{i&&i()},[i]),j=(0,l.useCallback)(e=>{e.stopPropagation()},[]);if(!o||!t)return null;let w="animate-fade-out"===c,N=x>0?"translateY(".concat(x,"px)"):void 0;return(0,r.jsxs)(f,{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":d,onClick:j,onTouchStart:g,onTouchMove:b,onTouchEnd:y,style:{transform:N},className:"fixed bottom-0 inset-x-0 bg-white 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 rounded-full","aria-hidden":"true"})}),(0,r.jsx)("div",{className:"px-4 pb-6",children:(0,r.jsx)(ep,{promptData:t,answering:s,onRespond:n,labelId:d})})]})]})}function ep(e){let{promptData:t,answering:a,onRespond:s,labelId:n}=e,i=(0,p.T)("prompt"),[o,c]=(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}),[d,u]=(0,l.useState)(""),[m,x]=(0,l.useState)(!1),h=(0,l.useMemo)(()=>{var e;return"multiple_choice"!==t.type?null:null!==(e=t.options.find(e=>e.number===o))&&void 0!==e?e:null},[t,o]),f=(null==h?void 0:h.requiresTextInput)===!0,g=a||m,b=(0,l.useCallback)(async e=>{if(!g){x(!0);try{await s(e)}catch(e){}finally{x(!1)}}},[g,s]),y=(0,l.useCallback)(async()=>{if(!g&&null!==o){x(!0);try{let e=f&&d.trim()?d.trim():o.toString();await s(e)}catch(e){}finally{x(!1)}}},[g,s,o,f,d]);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h3",{id:n,className:"text-lg font-semibold text-gray-900",children:i("confirmationFromClaude")}),t.instructionText&&(0,r.jsx)("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap text-sm text-gray-600 bg-gray-50 rounded p-2 border border-gray-200",children:t.instructionText}),(0,r.jsx)("p",{className:"text-gray-700 leading-relaxed",children:t.question}),g&&(0,r.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-gray-500",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:i("sending")})]}),"yes_no"===t.type&&(0,r.jsx)(ef,{promptData:t,disabled:g,onYes:()=>b("yes"),onNo:()=>b("no")}),"multiple_choice"===t.type&&(0,r.jsx)(eg,{promptData:t,disabled:g,selectedOption:o,onSelectOption:c,textInputValue:d,onTextInputChange:u,showTextInput:f,onSubmit:y})]})}let ef=(0,l.memo)(function(e){let{promptData:t,disabled:a,onYes:s,onNo:n}=e,l=(0,p.T)("prompt"),i="yes"===t.defaultOption,o="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(ex.base," ").concat(ex.primary," ").concat(i?"ring-2 ring-blue-300":""),children:l("yes")}),(0,r.jsx)("button",{type:"button",onClick:n,disabled:a,className:"flex-1 ".concat(ex.base," ").concat(o?ex.defaultSelected:ex.secondary),children:l("no")})]})}),eg=(0,l.memo)(function(e){let{promptData:t,disabled:a,selectedOption:s,onSelectOption:n,textInputValue:i,onTextInputChange:o,showTextInput:c,onSubmit:d}=e,u=(0,l.useId)(),m=(0,p.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 border-2 border-blue-500":"bg-white border-2 border-gray-200 hover:border-gray-300"," ").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",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:i,onChange:e=>o(e.target.value),disabled:a,placeholder:m("enterValuePlaceholder"),className:"w-full px-4 py-3 border-2 border-gray-300 rounded-lg 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(ex.base," ").concat(ex.primary),children:m("submit")})]})});var eb=a(6940);let ey={isOpen:!1,position:{x:0,y:0},targetPath:null,targetType:null};var ev=a(88964),ej=a(49465),ew=a(17689),eN=a(45675),ek=a(79548),eC=a(18930),eS=a(3468);let eE=(0,l.memo)(function(e){let{isOpen:t,position:a,targetPath:s,targetType:n,onClose:i,onNewFile:o,onNewDirectory:c,onRename:d,onDelete:u,onUpload:m,onMove:x}=e,h=(0,l.useRef)(null),p=(0,l.useCallback)(e=>{e&&s&&e(s),i()},[s,i]),f=[{id:"new-file",label:"New File",icon:(0,r.jsx)(ev.Z,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>p(o),showFor:["directory"]},{id:"new-directory",label:"New Directory",icon:(0,r.jsx)(ej.Z,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>p(c),showFor:["directory"]},{id:"upload",label:"Upload File",icon:(0,r.jsx)(ew.Z,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>p(m),showFor:["directory"],showDividerAfter:!0},{id:"rename",label:"Rename",icon:(0,r.jsx)(eN.Z,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>p(d)},{id:"move",label:"Move",icon:(0,r.jsx)(ek.Z,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>{x&&s&&n&&x(s,n),i()},showDividerAfter:!0},{id:"delete",label:"Delete",icon:(0,r.jsx)(eC.Z,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>p(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){i();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,i]),(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:eS.k.CONTEXT_MENU,left:"".concat(a.x,"px"),top:"".concat(a.y,"px")},children:f.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<f.length-1&&(0,r.jsx)("div",{"data-testid":"context-menu-divider",className:"my-1 border-t border-gray-200"})]},e.id))}):null});var eT=a(45306),eM=a(98408),eR=a(69234),eL=a(48736);let eF=(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 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"})})}),eP=(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,en.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 text-gray-900 px-0.5 rounded",children:e},t):(0,r.jsx)("span",{children:e},t))})}),eD=(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"})})}),eI=(0,l.memo)(function e(t){var a;let{item:s,path:n,depth:i,worktreeId:o,expanded:c,cache:d,onToggle:u,onFileSelect:m,onLoadChildren:x,onContextMenu:h,searchQuery:p,searchMode:f,matchedPaths:g,dateFnsLocaleStr:b}=t,[y,v]=(0,l.useState)(!1),j=n?"".concat(n,"/").concat(s.name):s.name,w=c.has(j),N="directory"===s.type,k=d.get(j),C=(0,l.useCallback)(async()=>{N?(w||k||(v(!0),await x(j),v(!1)),u(j)):null==m||m(j)},[N,w,k,j,x,u,m]),S=(0,l.useCallback)(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),C())},[C]),E=(0,l.useCallback)(e=>{e.preventDefault(),null==h||h(e,j,N?"directory":"file")},[j,N,h]),T=function(e){let{delay:t=500,moveThreshold:a=10,onLongPress:r}=e,s=(0,l.useRef)(null),n=(0,l.useRef)(null),i=(0,l.useRef)(null),o=(0,l.useCallback)(()=>{s.current&&(clearTimeout(s.current),s.current=null),n.current=null,i.current=null},[]);(0,l.useEffect)(()=>()=>o(),[o]);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},i.current=e,s.current=setTimeout(()=>{i.current&&r(i.current),o()},t)},[t,r,o]);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&&o()},[a,o]),onTouchEnd:(0,l.useCallback)(()=>{o()},[o]),onTouchCancel:(0,l.useCallback)(()=>{o()},[o])}}({onLongPress:(0,l.useCallback)(e=>{null==h||h(e,j,N?"directory":"file")},[j,N,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":N?w:void 0,tabIndex:0,className:"flex items-center gap-2 py-1.5 pr-2 cursor-pointer hover:bg-gray-100 rounded transition-colors",style:{paddingLeft:"".concat(.5+1*Math.min(i,20),"rem"),touchAction:"manipulation",WebkitTouchCallout:"none"},onClick:C,onKeyDown:S,onContextMenu:E,onTouchStart:T.onTouchStart,onTouchMove:T.onTouchMove,onTouchEnd:T.onTouchEnd,onTouchCancel:T.onTouchCancel,children:[N?(0,r.jsx)("span",{className:"w-4 h-4 flex items-center justify-center",children:y?(0,r.jsx)("span",{className:"w-3 h-3 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}):(0,r.jsx)(eF,{expanded:w})}):(0,r.jsx)("span",{className:"w-4 h-4"}),N?(0,r.jsx)(eP,{open:w}):(0,r.jsx)(eD,{extension:s.extension}),(0,r.jsx)("span",{className:"flex-1 truncate text-sm text-gray-700",children:"name"===f&&p?(0,r.jsx)(eA,{text:s.name,query:p}):s.name}),(0,r.jsx)("span",{className:"text-xs text-gray-400 flex-shrink-0",children:N?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")}),!N&&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,eT.Q)(a,{addSuffix:!0,...t?{locale:t}:{}})}(s.birthtime,b?(0,eM.G)(b):void 0)})]}),N&&w&&k&&(0,r.jsx)("div",{role:"group",children:k.filter(e=>{let t=j?"".concat(j,"/").concat(e.name):e.name;if(!(null==p?void 0:p.trim()))return!0;if("name"===f){let t=p.toLowerCase();return!!e.name.toLowerCase().includes(t)||"directory"===e.type}if("content"===f&&g&&g.size>0){if(g.has(t))return!0;if("directory"===e.type){for(let e of g)if(e.startsWith(t+"/"))return!0}return!1}return!0}).map(t=>(0,r.jsx)(e,{item:t,path:j,depth:i+1,worktreeId:o,expanded:c,cache:d,onToggle:u,onFileSelect:m,onLoadChildren:x,onContextMenu:h,searchQuery:p,searchMode:f,matchedPaths:g,dateFnsLocaleStr:b},t.name))})]})}),e_=(0,l.memo)(function(e){let{worktreeId:t,onFileSelect:a,onNewFile:s,onNewDirectory:n,onRename:i,onDelete:o,onUpload:c,onMove:d,className:u="",refreshTrigger:m=0,searchQuery:x,searchMode:h,searchResults:p,onSearchResultSelect:f,onCmateSetup:g}=e,b=(0,eR.bU)(),[y,v]=(0,l.useState)(!0),[j,w]=(0,l.useState)(null),[N,k]=(0,l.useState)([]),[C,S]=(0,l.useState)(new Set),[E,T]=(0,l.useState)(()=>new Map),M=(0,l.useRef)(C);M.current=C;let R=(0,l.useRef)(new Set),{menuState:L,openMenu:F,closeMenu:P}=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}}(),A=(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()=>{v(!0),w(null);try{let t=await A();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 A(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;k(t.items),T(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&&w(t instanceof Error?t.message:"Failed to load files")}finally{e&&v(!1)}})(),()=>{e=!1}},[A,m]);let D=(0,l.useCallback)(async e=>{if(!(E.has(e)||R.current.has(e))){R.current.add(e);try{let t=await A(e);t&&T(a=>{let r=new Map(a);return r.set(e,t.items),r})}catch(e){console.error("[FileTreeView] Error loading children:",e)}finally{R.current.delete(e)}}},[E,A]),I=(0,l.useCallback)(e=>{S(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),_=(0,l.useMemo)(()=>"content"===h&&p&&0!==p.length?(0,en.Ps)(p.map(e=>e.filePath)):new Set,[h,p]);(0,l.useEffect)(()=>{_.size>0&&S(e=>{let t=new Set(e);for(let e of _)(E.has(e)||(null==p?void 0:p.some(t=>t.filePath.startsWith(e+"/"))))&&t.add(e);return t})},[_,E,p]);let O=(0,l.useMemo)(()=>{if(!(null==x?void 0:x.trim()))return N;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=E.get(s);if(e&&t(e,s).length>0)return!0}return n});return t(N,"")}return"content"===h&&_.size>0?N.filter(e=>{if(_.has(e.name))return!0;if("directory"===e.type){for(let t of _)if(t.startsWith(e.name+"/")||t===e.name)return!0}return!1}):N},[N,x,h,_,E]);return y?(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 border-t-blue-500 rounded-full animate-spin"}),(0,r.jsx)("span",{className:"ml-2 text-sm text-gray-500",children:"Loading files..."})]}):j?(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:j})}):0===N.length?(0,r.jsxs)("div",{"data-testid":"file-tree-empty",className:"p-4 text-center text-gray-500 ".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)(ev.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)(ej.Z,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:"New Directory"})]})]})]}):(null==x?void 0:x.trim())&&0===O.length?(0,r.jsx)("div",{"data-testid":"file-tree-no-results",className:"p-4 text-center text-gray-500 ".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 ".concat(u),children:[(s||n||g)&&(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)(ev.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)(ej.Z,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:"New Directory"})]}),g&&(0,r.jsxs)("button",{"data-testid":"toolbar-cmate-button",onClick:g,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)(eL.Z,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:"CMATE"})]})]}),O.map(e=>(0,r.jsx)(eI,{item:e,path:"",depth:0,worktreeId:t,expanded:C,cache:E,onToggle:I,onFileSelect:f||a,onLoadChildren:D,onContextMenu:F,searchQuery:x,searchMode:h,matchedPaths:_,dateFnsLocaleStr:b},e.name)),(0,r.jsx)(eE,{isOpen:L.isOpen,position:L.position,targetPath:L.targetPath,targetType:L.targetType,onClose:P,onNewFile:s,onNewDirectory:n,onRename:i,onDelete:o,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"})})}),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:"M6 18L18 6M6 6l12 12"})})}),eW=(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-blue-500 rounded-full animate-spin","aria-label":"Searching..."})}),eB=(0,l.memo)(function(e){let{query:t,mode:a,isSearching:s,error:n,onQueryChange:i,onModeChange:o,onClear:c,placeholder:d="Search files...",className:u=""}=e,m=(0,l.useRef)(null),h=(0,l.useCallback)(e=>{i(e.target.value)},[i]),p=(0,l.useCallback)(()=>{var e;c(),null===(e=m.current)||void 0===e||e.focus()},[c]),f=(0,l.useCallback)(e=>{if("Escape"===e.key){if(t)p();else{var a;null===(a=m.current)||void 0===a||a.blur()}}},[t,p]);return(0,l.useEffect)(()=>{if(!(window.innerWidth<x.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 border-b border-gray-200 ".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:h,onKeyDown:f,placeholder:d,className:"flex-1 min-w-0 px-2 py-1 text-sm bg-gray-50 border border-gray-200 rounded focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-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)(eW,{}):t?(0,r.jsx)("button",{type:"button","data-testid":"search-clear",onClick:p,className:"p-1 text-gray-400 hover:text-gray-600 rounded transition-colors","aria-label":"Clear search",children:(0,r.jsx)(ez,{})}):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:()=>o("name"),className:"px-2 py-0.5 text-xs rounded transition-colors ".concat("name"===a?"bg-blue-100 text-blue-700 font-medium":"bg-gray-100 text-gray-600 hover:bg-gray-200"),"aria-pressed":"name"===a,children:"Name"}),(0,r.jsx)("button",{type:"button","data-testid":"mode-content",onClick:()=>o("content"),className:"px-2 py-0.5 text-xs rounded transition-colors ".concat("content"===a?"bg-blue-100 text-blue-700 font-medium":"bg-gray-100 text-gray-600 hover:bg-gray-200"),"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})]})}),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:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),eV=(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"})})}),eH=(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"})})}),eZ=[{id:"history",label:"History",icon:(0,r.jsx)(eU,{})},{id:"files",label:"Files",icon:(0,r.jsx)(eV,{})},{id:"memo",label:"CMATE",icon:(0,r.jsx)(eH,{})}],eY=(0,l.memo)(function(e){let{activeTab:t,onTabChange:a,className:s=""}=e,n=(0,l.useCallback)(e=>{a(e)},[a]),i=(0,l.useCallback)((e,t)=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),a(e))},[a]),o=(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-blue-500 focus:ring-inset"," ").concat(a?"bg-blue-50 text-blue-600 border-b-2 border-blue-600":"text-gray-500 hover:text-gray-700 hover:bg-gray-50")},[t]);return(0,r.jsx)("div",{role:"tablist","aria-label":"Left pane view switcher",className:"flex border-b border-gray-200 bg-white ".concat(s),children:eZ.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=>i(e.id,t),className:o(e.id),children:[e.icon,(0,r.jsx)("span",{children:e.label})]},e.id))})});var eq=a(10789),eG=a(39625),eK=a(1243),eX=a(30401);function eJ(e){let{isOpen:t,onClose:a,worktreeId:s,filePath:n}=e,[i,o]=(0,l.useState)(null),[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),[x,h]=(0,l.useState)(!1),p=(0,l.useMemo)(()=>!!((null==i?void 0:i.content)&&!i.isImage&&!i.isVideo),[i]),f=(0,l.useCallback)(async()=>{if(p&&(null==i?void 0:i.content))try{await (0,Z.v)(i.content),h(!0),setTimeout(()=>h(!1),2e3)}catch(e){}},[p,i]);return(0,l.useEffect)(()=>{if(!t||!n){o(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();o(t)}catch(e){m(e instanceof Error?e.message:"Failed to load file")}finally{d(!1)}})()},[t,s,n]),(0,r.jsx)(eq.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 border-t-blue-600"}),(0,r.jsx)("p",{className:"ml-3 text-gray-600",children:"Loading file..."})]}),u&&(0,r.jsx)("div",{className:"bg-red-50 border border-red-200 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",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",children:u})]})}),i&&!c&&!u&&(0,r.jsxs)("div",{className:"bg-gray-50 rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"bg-gray-100 px-4 py-2 border-b border-gray-200 flex items-center justify-between",children:[(0,r.jsxs)("p",{className:"text-xs text-gray-600 font-mono truncate",children:[i.worktreePath,"/",i.path]}),p&&(0,r.jsx)("button",{"data-testid":"copy-content-button",onClick:f,className:"flex-shrink-0 ml-2 p-1 rounded hover:bg-gray-200 transition-colors text-gray-500 hover:text-gray-700","aria-label":"Copy file content",children:x?(0,r.jsx)(eX.Z,{className:"w-4 h-4 text-green-600"}):(0,r.jsx)(D.Z,{className:"w-4 h-4"})})]}),i.isImage?(0,r.jsx)(eG.O,{src:i.content,alt:i.path,mimeType:i.mimeType}):i.isVideo?(0,r.jsx)(eK.R,{src:i.content,mimeType:i.mimeType}):(0,r.jsx)("div",{className:"p-4",children:(0,r.jsx)("pre",{className:"text-sm overflow-x-auto",children:(0,r.jsx)("code",{className:"language-".concat(i.extension),children:i.content})})})]})]})})}var eQ=a(54887),e$=a(53012),e0=a(23260),e1=a(57934),e2=a(12158);a(57792);var e4=a(76865),e5=a(93807),e3=a(42208),e6=a(74440),e8=a(47416),e7=a(83229),e9=a(32489),te=a(20318),tt=a(30166),ta=a(51817);let tr=(0,tt.default)(()=>Promise.all([a.e(2714),a.e(656),a.e(13)]).then(a.bind(a,70013)).then(e=>({default:e.MermaidDiagram})),{loadableGenerated:{webpack:()=>[70013]},ssr:!1,loading:()=>(0,r.jsxs)("div",{className:"mermaid-loading flex items-center gap-2 text-gray-500 p-4",children:[(0,r.jsx)(ta.Z,{className:"animate-spin h-4 w-4"}),(0,r.jsx)("span",{children:"Loading diagram..."})]})});function ts(e){let{className:t,children:a,inline:s}=e;if(s)return(0,r.jsx)("code",{className:t,children:a});if(t&&t.split(" ").includes("language-mermaid")){let e=null==a?"":"string"==typeof a?a:Array.isArray(a)?a.map(e=>"string"==typeof e?e:"").join(""):String(a);return(0,r.jsx)(tr,{code:e})}return(0,r.jsx)("code",{className:t,children:a})}function tn(){return"undefined"==typeof document?null:document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null}async function tl(e){if(e.requestFullscreen)return e.requestFullscreen();if(e.webkitRequestFullscreen)return e.webkitRequestFullscreen();if(e.mozRequestFullScreen)return e.mozRequestFullScreen();if(e.msRequestFullscreen)return e.msRequestFullscreen();throw Error("Fullscreen API not supported")}async function ti(){if("undefined"!=typeof document){if(document.exitFullscreen)return document.exitFullscreen();if(document.webkitExitFullscreen)return document.webkitExitFullscreen();if(document.mozCancelFullScreen)return document.mozCancelFullScreen();if(document.msExitFullscreen)return document.msExitFullscreen()}}function to(){try{let e="__localStorage_test__";return window.localStorage.setItem(e,"test"),window.localStorage.removeItem(e),!0}catch(e){return!1}}function tc(e){let{key:t,defaultValue:a,validate:r,serialize:s=JSON.stringify,deserialize:n=JSON.parse}=e,i=(0,l.useRef)(a),o=(0,l.useRef)(r),c=(0,l.useRef)(s),d=(0,l.useRef)(n);i.current=a,o.current=r,c.current=s,d.current=n;let[u,m]=(0,l.useState)(!1),[x,h]=(0,l.useState)(a),p=(0,l.useCallback)(()=>{if(!to())return i.current;try{let e=window.localStorage.getItem(t);if(null===e)return i.current;let a=d.current(e);if(o.current)return o.current(a)?a:i.current;return a}catch(e){return i.current}},[t]),f=(0,l.useCallback)(e=>{if(to())try{let a=c.current(e);window.localStorage.setItem(t,a)}catch(e){}},[t]),g=(0,l.useCallback)(e=>{h(t=>{let a="function"==typeof e?e(t):e;return f(a),a})},[f]),b=(0,l.useCallback)(()=>{if(to())try{window.localStorage.removeItem(t)}catch(e){}h(i.current)},[t]);return(0,l.useEffect)(()=>{m(to()),h(p())},[p]),{value:x,setValue:g,removeValue:b,isAvailable:u}}let td=()=>null!=window.visualViewport,tu={split:{showEditor:!0,showPreview:!0,editorWidth:"w-1/2",previewWidth:"w-1/2"},editor:{showEditor:!0,showPreview:!1,editorWidth:"w-full",previewWidth:"w-0"},preview:{showEditor:!1,showPreview:!0,editorWidth:"w-0",previewWidth:"w-full"}},tm="commandmate:md-editor-view-mode",tx={WARNING_THRESHOLD:512e3};function th(e){return"number"==typeof e&&e>=.1&&e<=.9}function tp(e){return"boolean"==typeof e}function tf(e){return"split"===e||"editor"===e||"preview"===e}function tg(e){let{worktreeId:t,filePath:a,onClose:s,onSave:n,initialViewMode:i,onMaximizedChange:o}=e,[c,d]=(0,l.useState)(""),[u,m]=(0,l.useState)(""),[h,p]=(0,l.useState)(""),[f,g]=(0,l.useState)(()=>(function(e){if(e&&tf(e))return e;{let e=localStorage.getItem(tm);if(e&&tf(e))return e}return"split"})(i)),[b,y]=(0,l.useState)(!0),[v,j]=(0,l.useState)(!1),[N,k]=(0,l.useState)(null),[C,S]=(0,l.useState)(!1),[E,T]=(0,l.useState)(!1),[M,R]=(0,l.useState)("editor"),[L,F]=(0,l.useState)(null),{toasts:P,showToast:A,removeToast:I}=(0,te.pm)(),_=(0,l.useRef)(null),O=(0,l.useRef)(null),z=(0,l.useRef)(null),W=(0,l.useRef)(null),B=(0,x.d)(),{isKeyboardVisible:U,keyboardHeight:V}=function(){let[e,t]=(0,l.useState)(!1),[a,r]=(0,l.useState)(0),s=(0,l.useCallback)(()=>{if(!td())return;let e=window.visualViewport,a=window.innerHeight-e.height,s=a>100;t(s),r(s?a:0)},[]);return(0,l.useEffect)(()=>{if(!td())return;let e=window.visualViewport;return s(),e.addEventListener("resize",s),()=>{e.removeEventListener("resize",s)}},[s]),{isKeyboardVisible:e,keyboardHeight:a}}(),{value:H,setValue:Y}=tc({key:"commandmate:md-editor-maximized",defaultValue:!1,validate:tp}),{isFullscreen:q,isFallbackMode:G,enterFullscreen:K,exitFullscreen:X,toggleFullscreen:J}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{elementRef:t,onEnter:a,onExit:r,onError:s}=e,[n,i]=(0,l.useState)(!1),[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(null),m=(0,l.useCallback)(()=>{let e=null!=tn();i(e),!e&&o&&c(!1)},[o]),x=(0,l.useCallback)(async()=>{if(u(null),"undefined"!=typeof navigator&&(/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)){i(!0),c(!0),null==a||a();return}if("undefined"!=typeof document&&(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)&&(null==t?void 0:t.current))try{await tl(t.current),i(!0),c(!1),null==a||a()}catch(t){let e=t instanceof Error?t.message:"Failed to enter fullscreen";u(e),null==s||s(t instanceof Error?t:Error(e)),i(!0),c(!0),null==a||a()}else i(!0),c(!0),null==a||a()},[t,a,s]),h=(0,l.useCallback)(async()=>{if(u(null),o){i(!1),c(!1),null==r||r();return}if(tn())try{await ti(),i(!1),null==r||r()}catch(t){let e=t instanceof Error?t.message:"Failed to exit fullscreen";u(e),null==s||s(t instanceof Error?t:Error(e)),i(!1),c(!1),null==r||r()}else i(!1),c(!1),null==r||r()},[o,r,s]),p=(0,l.useCallback)(async()=>{n?await h():await x()},[n,x,h]);return(0,l.useEffect)(()=>{if("undefined"!=typeof document)return document.addEventListener("fullscreenchange",m),document.addEventListener("webkitfullscreenchange",m),document.addEventListener("mozfullscreenchange",m),document.addEventListener("MSFullscreenChange",m),()=>{document.removeEventListener("fullscreenchange",m),document.removeEventListener("webkitfullscreenchange",m),document.removeEventListener("mozfullscreenchange",m),document.removeEventListener("MSFullscreenChange",m)}},[m]),{isFullscreen:n,isFallbackMode:o,enterFullscreen:x,exitFullscreen:h,toggleFullscreen:p,error:d}}({elementRef:z,onEnter:()=>Y(!0),onExit:()=>Y(!1)}),{value:Q,setValue:$}=tc({key:"commandmate:md-editor-split-ratio",defaultValue:.5,validate:th}),{ref:ee}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{onSwipeLeft:t,onSwipeRight:a,onSwipeUp:r,onSwipeDown:s,threshold:n=50,enabled:i=!0}=e,o=(0,l.useRef)(null),[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),x=(0,l.useRef)(null),h=(0,l.useCallback)(()=>{m(null)},[]),p=(0,l.useCallback)(e=>{if(!i)return;if(e.target instanceof HTMLElement&&function(e){let t=e;for(;t;){let{overflowY:e}=getComputedStyle(t);if(("auto"===e||"scroll"===e)&&t.scrollHeight>t.clientHeight)return!0;t=t.parentElement}return!1}(e.target)){x.current=null;return}let t=e.touches[0];x.current={x:t.clientX,y:t.clientY},d(!0)},[i]),f=(0,l.useCallback)(e=>{if(!i||!x.current)return;let t=e.touches[0],a=t.clientX-x.current.x,r=t.clientY-x.current.y,s=Math.abs(a),l=Math.abs(r);s>l&&s>=n?m(a<0?"left":"right"):l>=n&&m(r<0?"up":"down")},[i,n]),g=(0,l.useCallback)(e=>{if(!i||!x.current){d(!1);return}let l=e.changedTouches[0],o=l.clientX-x.current.x,c=l.clientY-x.current.y,u=Math.abs(o),h=Math.abs(c);u>h?u>=n&&(o<0?(m("left"),null==t||t()):(m("right"),null==a||a())):h>=n&&(c<0?(m("up"),null==r||r()):(m("down"),null==s||s())),x.current=null,d(!1)},[i,n,t,a,r,s]);return(0,l.useEffect)(()=>{let e=o.current;if(e)return e.addEventListener("touchstart",p),e.addEventListener("touchmove",f),e.addEventListener("touchend",g),()=>{e.removeEventListener("touchstart",p),e.removeEventListener("touchmove",f),e.removeEventListener("touchend",g)}},[p,f,g]),{ref:o,isSwiping:c,swipeDirection:u,resetSwipeDirection:h}}({onSwipeDown:()=>{q&&X()},threshold:150,enabled:q&&B}),et=c!==u,ea=tu[f],er=B&&window.innerHeight>window.innerWidth&&"split"===f,es=(0,l.useMemo)(()=>(0,en.Ds)(e=>{p(e)},300),[]),el=(0,l.useCallback)(async()=>{y(!0),k(null);try{let r=await fetch("/api/worktrees/".concat(t,"/files/").concat(a)),s=await r.json();if(!r.ok||!s.success){var e;throw Error((null===(e=s.error)||void 0===e?void 0:e.message)||"Failed to load file")}let n=s.content||"";d(n),m(n),p(n),new Blob([n]).size>tx.WARNING_THRESHOLD&&S(!0)}catch(e){k(e instanceof Error?e.message:"Failed to load file")}finally{y(!1)}},[t,a]),ei=(0,l.useCallback)(async()=>{if(et&&!v){j(!0);try{let r=await fetch("/api/worktrees/".concat(t,"/files/").concat(a),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:c})}),s=await r.json();if(!r.ok||!s.success){var e;throw Error((null===(e=s.error)||void 0===e?void 0:e.message)||"Failed to save file")}m(c),A("File saved successfully","success"),n&&n(a)}catch(e){A(e instanceof Error?e.message:"Failed to save file","error")}finally{j(!1)}}},[t,a,c,et,v,n,A]),eo=(0,l.useCallback)(e=>{let t=e.target.value;d(t),es(t)},[es]),ec=(0,l.useCallback)(e=>{g(e),localStorage.setItem(tm,e)},[]),ed=(0,l.useCallback)(()=>{(!et||window.confirm("You have unsaved changes. Are you sure you want to close?"))&&s&&s()},[et,s]),eu=(0,l.useCallback)(async()=>{try{await (0,Z.v)(c),T(!0),setTimeout(()=>T(!1),2e3)}catch(e){}},[c]),em=(0,l.useCallback)(e=>{if(!W.current)return;let t=W.current.offsetWidth;if(0===t)return;let a=e/t;$(e=>Math.max(.1,Math.min(.9,e+a)))},[$]),ex=(0,l.useCallback)(()=>{$(.5)},[$]),eh=(0,l.useCallback)(e=>{if((e.ctrlKey||e.metaKey)&&"s"===e.key){e.preventDefault(),ei();return}if((e.ctrlKey||e.metaKey)&&e.shiftKey&&"F"===e.key){e.preventDefault(),J();return}if("Escape"===e.key&&q){e.preventDefault(),X();return}},[ei,J,X,q]);(0,l.useEffect)(()=>{let e=e=>{"Escape"===e.key&&q&&(e.preventDefault(),X())};return q&&document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[q,X]),(0,l.useEffect)(()=>{H&&!q&&K()},[]),(0,l.useEffect)(()=>{if("undefined"==typeof document)return;let e=document.getElementById("markdown-editor-portal");return e||((e=document.createElement("div")).id="markdown-editor-portal",document.body.appendChild(e)),F(e),()=>{let e=document.getElementById("markdown-editor-portal");e&&0===e.childNodes.length&&e.remove()}},[]),(0,l.useEffect)(()=>{null==o||o(q)},[q,o]),(0,l.useEffect)(()=>{el()},[el]),(0,l.useEffect)(()=>{let e=e=>{et&&(e.preventDefault(),e.returnValue="")};return et?(O.current=e,window.addEventListener("beforeunload",e)):O.current&&(window.removeEventListener("beforeunload",O.current),O.current=null),()=>{O.current&&window.removeEventListener("beforeunload",O.current)}},[et]);let ep=(0,l.useMemo)(()=>{let e="flex flex-col bg-white";return q&&G?"".concat(e," fixed inset-0"):"".concat(e," h-full")},[q,G]),ef=(0,l.useMemo)(()=>{if(q)return{zIndex:eS.k.MAXIMIZED_EDITOR}},[q]),eg=(0,l.useMemo)(()=>{if("split"===f&&!er)return{width:"".concat(100*Q,"%"),flexShrink:0}},[f,Q,er]),eb=(0,l.useMemo)(()=>{if("split"===f&&!er)return{width:"".concat((1-Q)*100,"%"),flexShrink:0}},[f,Q,er]),ey=(0,l.useMemo)(()=>{if(U&&V>0)return{paddingBottom:V}},[U,V]),ev=(0,l.useMemo)(()=>({code:ts}),[]),ej=(0,l.useMemo)(()=>(0,r.jsx)(e$.UG,{remarkPlugins:[e0.Z],rehypePlugins:[e1.Z,e2.Z],components:ev,children:h}),[h,ev]);if(b)return(0,r.jsx)("div",{"data-testid":"markdown-editor",className:"flex items-center justify-center h-full bg-white",children:(0,r.jsxs)("div",{className:"text-center",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:"mt-4 text-gray-600",children:"Loading..."})]})});if(N)return(0,r.jsx)("div",{"data-testid":"markdown-editor-error",className:"flex items-center justify-center h-full bg-white",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)(e4.Z,{className:"h-12 w-12 text-red-500 mx-auto mb-4"}),(0,r.jsx)("p",{className:"text-red-600",children:N}),s&&(0,r.jsx)("button",{onClick:s,className:"mt-4 px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-lg",children:"Close"})]})});let ew=(0,r.jsxs)("div",{ref:e=>{z.current=e,ee.current=e},"data-testid":"markdown-editor",className:ep,style:ef,onKeyDown:eh,role:q&&G?"dialog":void 0,"aria-modal":q&&G?"true":void 0,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 bg-gray-50",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-shrink",children:[(0,r.jsx)(eL.Z,{className:"h-4 w-4 text-gray-500 flex-shrink-0"}),(0,r.jsx)("span",{className:"text-sm font-medium text-gray-700 truncate",children:a}),et&&(0,r.jsx)("span",{"data-testid":"dirty-indicator",className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800 flex-shrink-0",children:"Unsaved"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!er&&(0,r.jsxs)("div",{className:"flex items-center gap-1 bg-gray-100 rounded-lg p-1",children:[(0,r.jsx)("button",{"data-testid":"view-mode-split","aria-pressed":"split"===f,onClick:()=>ec("split"),className:"p-1.5 rounded ".concat("split"===f?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"),title:"Split view",children:(0,r.jsx)(e5.Z,{className:"h-4 w-4"})}),(0,r.jsx)("button",{"data-testid":"view-mode-editor","aria-pressed":"editor"===f,onClick:()=>ec("editor"),className:"p-1.5 rounded ".concat("editor"===f?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"),title:"Editor only",children:(0,r.jsx)(eL.Z,{className:"h-4 w-4"})}),(0,r.jsx)("button",{"data-testid":"view-mode-preview","aria-pressed":"preview"===f,onClick:()=>ec("preview"),className:"p-1.5 rounded ".concat("preview"===f?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"),title:"Preview only",children:(0,r.jsx)(e3.Z,{className:"h-4 w-4"})})]}),(0,r.jsx)("button",{"data-testid":"copy-content-button",onClick:eu,className:"p-1.5 hover:bg-gray-100 rounded ".concat(E?"text-green-500":"text-gray-500 hover:text-gray-700"),title:"Copy content",children:E?(0,r.jsx)(eX.Z,{className:"h-4 w-4"}):(0,r.jsx)(D.Z,{className:"h-4 w-4"})}),(0,r.jsx)("button",{"data-testid":"maximize-button",onClick:J,className:"p-1.5 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded",title:q?"Exit fullscreen (ESC)":"Enter fullscreen (Ctrl+Shift+F)","aria-pressed":q,children:q?(0,r.jsx)(e6.Z,{className:"h-4 w-4"}):(0,r.jsx)(e8.Z,{className:"h-4 w-4"})}),(0,r.jsxs)("button",{"data-testid":"save-button",onClick:ei,disabled:!et||v,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ".concat(et&&!v?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-100 text-gray-400 cursor-not-allowed"),children:[(0,r.jsx)(e7.Z,{className:"h-4 w-4"}),v?"Saving...":"Save"]}),s&&(0,r.jsx)("button",{"data-testid":"close-button",onClick:ed,className:"p-1.5 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded",title:"Close",children:(0,r.jsx)(e9.Z,{className:"h-4 w-4"})})]})]}),q&&(0,r.jsxs)("div",{"data-testid":"maximize-hint",className:"flex items-center justify-center px-4 py-1 bg-gray-800 text-gray-300 text-xs",children:["Press ESC to exit fullscreen ",B&&"(or swipe down)"]}),C&&(0,r.jsxs)("div",{"data-testid":"large-file-warning",className:"flex items-center gap-2 px-4 py-2 bg-yellow-50 border-b border-yellow-200 text-yellow-800 text-sm",children:[(0,r.jsx)(e4.Z,{className:"h-4 w-4"}),"Large file: Performance may be affected.",(0,r.jsx)("button",{onClick:()=>S(!1),className:"ml-auto text-yellow-600 hover:text-yellow-800",children:(0,r.jsx)(e9.Z,{className:"h-4 w-4"})})]}),er&&(0,r.jsxs)("div",{className:"flex border-b border-gray-200",children:[(0,r.jsxs)("button",{"data-testid":"mobile-tab-editor",onClick:()=>R("editor"),className:"flex-1 py-2 text-sm font-medium ".concat("editor"===M?"text-blue-600 border-b-2 border-blue-600":"text-gray-500"),children:[(0,r.jsx)(eL.Z,{className:"h-4 w-4 inline-block mr-1"}),"Editor"]}),(0,r.jsxs)("button",{"data-testid":"mobile-tab-preview",onClick:()=>R("preview"),className:"flex-1 py-2 text-sm font-medium ".concat("preview"===M?"text-blue-600 border-b-2 border-blue-600":"text-gray-500"),children:[(0,r.jsx)(e3.Z,{className:"h-4 w-4 inline-block mr-1"}),"Preview"]})]}),(0,r.jsxs)("div",{ref:W,className:"flex flex-1 overflow-hidden",style:ey,children:[er?"editor"===M&&(0,r.jsx)("div",{"data-testid":"markdown-editor-container",className:"flex flex-col overflow-hidden w-full",children:(0,r.jsx)("textarea",{ref:_,"data-testid":"markdown-editor-textarea",value:c,onChange:eo,onKeyDown:eh,className:"flex-1 p-4 font-mono text-sm resize-none focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset",placeholder:"Start typing markdown...",spellCheck:!1})}):(0,r.jsx)("div",{"data-testid":"markdown-editor-container",className:"flex flex-col overflow-hidden transition-all duration-200 ".concat(ea.showEditor?"":"hidden"),style:"split"===f?eg:{width:ea.showEditor?"100%":"0%"},children:(0,r.jsx)("textarea",{ref:_,"data-testid":"markdown-editor-textarea",value:c,onChange:eo,onKeyDown:eh,className:"flex-1 p-4 font-mono text-sm resize-none focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-inset",placeholder:"Start typing markdown...",spellCheck:!1})}),"split"===f&&ea.showEditor&&ea.showPreview&&!er&&(0,r.jsx)(w,{onResize:em,onDoubleClick:ex,orientation:"horizontal",ariaValueNow:Math.round(100*Q),minRatio:.1}),er?"preview"===M&&(0,r.jsx)("div",{"data-testid":"markdown-preview-container",className:"flex flex-col overflow-hidden w-full",children:(0,r.jsx)("div",{"data-testid":"markdown-preview",className:"flex-1 p-4 overflow-y-auto prose prose-sm max-w-none",children:ej})}):(0,r.jsx)("div",{"data-testid":"markdown-preview-container",className:"flex flex-col overflow-hidden transition-all duration-200 ".concat(ea.showPreview?"":"hidden"),style:"split"===f?eb:{width:ea.showPreview?"100%":"0%"},children:(0,r.jsx)("div",{"data-testid":"markdown-preview",className:"flex-1 p-4 overflow-y-auto prose prose-sm max-w-none",children:ej})})]}),(0,r.jsx)(te.Ix,{toasts:P,onClose:I})]});return q&&G&&L?(0,eQ.createPortal)(ew,L):ew}let tb=[".md"],ty=[{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"]}],tv=ty.map(e=>e.extension);var tj=a(3227);function tw(e){let{value:t,saveFn:a,debounceMs:r=300,disabled:s=!1,maxRetries:n=3,onSaveComplete:i}=e,[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(null),m=(0,l.useRef)(t),x=(0,l.useRef)(a),h=(0,l.useRef)(i),p=(0,l.useRef)(null),f=(0,l.useRef)(!0),g=(0,l.useRef)(t);(0,l.useEffect)(()=>{m.current=t},[t]),(0,l.useEffect)(()=>{x.current=a},[a]),(0,l.useEffect)(()=>{h.current=i},[i]),(0,l.useEffect)(()=>(f.current=!0,()=>{f.current=!1,p.current&&clearTimeout(p.current)}),[]);let b=(0,l.useCallback)(async e=>{if(!f.current)return;c(!0),u(null);let t=null,a=0;for(;a<=n;)try{if(await x.current(e),f.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<=n){let e=1e3*Math.pow(2,a-1);await new Promise(t=>setTimeout(t,e))}}f.current&&(c(!1),u(t))},[n]),y=(0,l.useCallback)(()=>{p.current&&(clearTimeout(p.current),p.current=null)},[]),v=(0,l.useCallback)(async()=>{s||(y(),await b(m.current))},[s,y,b]);return(0,l.useEffect)(()=>{if(t!==g.current&&!s)return y(),p.current=setTimeout(()=>{b(m.current)},r),()=>{y()}},[t,s,r,y,b]),{isSaving:o,error:d,saveNow:v}}let tN=(0,l.memo)(function(e){var t,a;let{memo:s,onUpdate:n,onDelete:i,isSaving:o,error:c,className:d=""}=e,[u,m]=(0,l.useState)(s.title),[x,h]=(0,l.useState)(s.content),[p,f]=(0,l.useState)(!1),g=(0,l.useRef)();(0,l.useEffect)(()=>()=>{g.current&&clearTimeout(g.current)},[]);let{isSaving:b,error:y,saveNow:v}=tw({value:u,saveFn:async e=>{await n(s.id,{title:e})}}),{isSaving:j,error:w,saveNow:N}=tw({value:x,saveFn:async e=>{await n(s.id,{content:e})}}),k=null!==(a=null!==(t=null!=c?c:null==y?void 0:y.message)&&void 0!==t?t:null==w?void 0:w.message)&&void 0!==a?a:null,C=(0,l.useCallback)(e=>{m(e.target.value)},[]),S=(0,l.useCallback)(e=>{h(e.target.value)},[]),E=(0,l.useCallback)(()=>{v()},[v]),T=(0,l.useCallback)(()=>{N()},[N]),M=(0,l.useCallback)(()=>{i(s.id)},[s.id,i]),R=(0,l.useCallback)(async()=>{if(x.trim())try{await (0,Z.v)(x),f(!0),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>f(!1),2e3)}catch(e){}},[x]);return(0,r.jsxs)("div",{"data-testid":"memo-card",className:"bg-white border border-gray-200 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:E,placeholder:"Memo title",className:"flex-1 text-sm font-medium text-gray-900 bg-transparent border-none focus:outline-none focus:ring-0 p-0"}),(null!=o?o:b||j)&&(0,r.jsx)("span",{"data-testid":"saving-indicator",className:"text-xs text-gray-400",children:"Saving..."}),(0,r.jsx)("button",{type:"button",onClick:R,"aria-label":"Copy memo content",className:"p-1 text-gray-400 hover:text-gray-600 transition-colors rounded",children:p?(0,r.jsx)(eX.Z,{className:"w-4 h-4 text-green-600"}):(0,r.jsx)(D.Z,{className:"w-4 h-4"})}),(0,r.jsx)("button",{type:"button",onClick:M,"aria-label":"Delete memo",className:"p-1 text-gray-400 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:T,placeholder:"Enter memo content...",rows:4,className:"w-full text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-md p-2 resize-y focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),k&&(0,r.jsx)("div",{className:"text-xs text-red-500",children:k})]})}),tk=(0,l.memo)(function(e){let{currentCount:t,maxCount:a,onAdd:s,isLoading:n=!1,className:l=""}=e,i=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:()=>{i||s()},disabled:i,"aria-label":"Add Memo","aria-disabled":i,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-blue-500\n ".concat(i?"border-gray-200 text-gray-400 cursor-not-allowed opacity-50":"border-gray-300 text-gray-600 hover:border-blue-400 hover:text-blue-600 hover:bg-blue-50","\n "),children:[n?(0,r.jsx)("span",{"data-testid":"loading-indicator",className:"w-5 h-5 border-2 border-gray-300 border-t-blue-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",children:[Math.max(0,a-t)," remaining"]})]})}),tC=(0,l.memo)(function(e){let{worktreeId:t,className:a=""}=e,[s,n]=(0,l.useState)([]),[i,o]=(0,l.useState)(!0),[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),[x,h]=(0,l.useState)(null),p=(0,l.useCallback)(async()=>{o(!0),m(null);try{let e=await tj.nE.getAll(t);n(e.sort((e,t)=>e.position-t.position))}catch(e){m((0,tj.zG)(e))}finally{o(!1)}},[t]);(0,l.useEffect)(()=>{p()},[p]);let f=(0,l.useCallback)(async()=>{d(!0),h(null);try{let e=await tj.nE.create(t,{title:"Memo",content:""});n(t=>[...t,e])}catch(e){h((0,tj.zG)(e))}finally{d(!1)}},[t]),g=(0,l.useCallback)(async(e,a)=>{await tj.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 tj.nE.delete(t,e),n(t=>t.filter(t=>t.id!==e))}catch(e){console.error("Failed to delete memo:",e)}},[t]),y=(0,l.useCallback)(()=>{p()},[p]);return i?(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 border-t-blue-500 rounded-full animate-spin"}),(0,r.jsx)("span",{className:"text-sm text-gray-500",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",children:u}),(0,r.jsx)("button",{type:"button",onClick:y,"aria-label":"Retry",className:"px-4 py-2 text-sm font-medium text-white bg-blue-500 rounded-lg hover:bg-blue-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",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)(tN,{memo:e,onUpdate:g,onDelete:b},e.id)),x&&(0,r.jsx)("div",{className:"text-center py-2 text-sm text-red-500",children:x}),(0,r.jsx)(tk,{currentCount:s.length,maxCount:5,onAdd:f,isLoading:c,className:"mt-2"})]})});function tS(e){return new Date(e).toLocaleString()}let tE=(0,l.memo)(function(e){let{worktreeId:t,className:a=""}=e,s=(0,p.T)("schedule"),[n,i]=(0,l.useState)([]),[o,c]=(0,l.useState)([]),[d,u]=(0,l.useState)(!0),[m,x]=(0,l.useState)(null),[h,f]=(0,l.useState)(null),[g,b]=(0,l.useState)(null),y=(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();i(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)(()=>{y()},[y]);let v=(0,l.useCallback)(async e=>{if(h===e){f(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),f(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 border-t-blue-500 rounded-full animate-spin"}),(0,r.jsx)("span",{className:"text-sm text-gray-500",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",children:m}),(0,r.jsx)("button",{type:"button",onClick:()=>void y(),className:"ml-2 px-3 py-1 text-sm text-white bg-blue-500 rounded hover:bg-blue-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 mb-2",children:[s("title")," (",o.length,")"]}),0===o.length?(0,r.jsxs)("div",{className:"text-center py-8 text-gray-500",children:[(0,r.jsx)("p",{className:"font-medium text-gray-600 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:o.map(e=>(0,r.jsxs)("div",{className:"border border-gray-200 rounded p-3 bg-white",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 text-green-600":"bg-gray-50 text-gray-500"),children:e.enabled?s("enabled"):s("disabled")})]}),(0,r.jsxs)("div",{className:"text-xs text-gray-500 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"),": ",tS(e.last_executed_at)]})]})]},e.id))})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:[s("executionLogs")," (",n.length,")"]}),0===n.length?(0,r.jsx)("p",{className:"text-sm text-gray-500",children:s("noLogs")}):(0,r.jsx)("div",{className:"space-y-2",children:n.map(e=>(0,r.jsxs)("div",{className:"border border-gray-200 rounded bg-white",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>void v(e.id),className:"w-full text-left p-3 hover:bg-gray-50 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 bg-green-50";case"failed":return"text-red-600 bg-red-50";case"timeout":return"text-yellow-600 bg-yellow-50";case"running":return"text-blue-600 bg-blue-50";case"cancelled":return"text-gray-600 bg-gray-50"}}(e.status)),children:s("status.".concat(e.status))})]}),(0,r.jsxs)("div",{className:"text-xs text-gray-500 mt-1",children:[tS(e.started_at),null!==e.exit_code&&(0,r.jsxs)("span",{className:"ml-2",children:[s("exitCode"),": ",e.exit_code]})]})]}),h===e.id&&g&&(0,r.jsxs)("div",{className:"border-t border-gray-200 p-3 bg-gray-50 space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-gray-600 mb-1",children:s("message")}),(0,r.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-gray-700",children:g.message})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-gray-600 mb-1",children:s("response")}),(0,r.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-gray-700 max-h-60 overflow-y-auto",children:g.result||s("noOutput")})]})]})]},e.id))})]})]})}),tT=(0,l.memo)(function(e){let{worktreeId:t,className:a=""}=e,s=(0,p.T)("schedule"),[n,i]=(0,l.useState)("notes"),o=(0,l.useCallback)(e=>{i(e)},[]);return(0,r.jsxs)("div",{className:"flex flex-col h-full ".concat(a),children:[(0,r.jsxs)("div",{className:"flex border-b border-gray-200 bg-white flex-shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:()=>o("notes"),className:"flex-1 px-3 py-2 text-sm font-medium transition-colors ".concat("notes"===n?"text-blue-600 border-b-2 border-blue-600 bg-blue-50":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"),children:s("notes")}),(0,r.jsx)("button",{type:"button",onClick:()=>o("logs"),className:"flex-1 px-3 py-2 text-sm font-medium transition-colors ".concat("logs"===n?"text-blue-600 border-b-2 border-blue-600 bg-blue-50":"text-gray-500 hover:text-gray-700 hover:bg-gray-50"),children:s("logs")})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:"notes"===n?(0,r.jsx)(tC,{worktreeId:t,className:"h-full"}):(0,r.jsx)(tE,{worktreeId:t,className:"h-full"})})]})});var tM=a(43616);function tR(){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 tj.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 tL(e){let{hasUpdate:t,latestVersion:a,releaseUrl:s,updateCommand:n,installType:l}=e,i=(0,p.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":i("update.available"),"data-testid":"update-notification-banner",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-blue-800 mb-1",children:i("update.available")}),a&&(0,r.jsx)("p",{className:"text-sm text-blue-700 mb-2",children:i("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:i("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:[i("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:i("update.dataPreserved")})]}):null}function tF(e){let{version:t,className:a}=e,s=(0,p.T)("worktree"),{data:n,loading:i}=tR(),o=(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}),i&&(0,r.jsx)("p",{className:"text-xs text-gray-400 mt-1","data-testid":"version-loading",children:"..."}),o&&(0,r.jsx)(tL,{...o})]})}let tP="https://github.com/Kewton/CommandMate",tA="".concat(tP,"/issues"),tD="".concat(tP,"/issues/new"),tI="".concat(tD,"?template=bug_report.md"),t_="".concat(tD,"?template=feature_request.md"),tO="".concat(tD,"?template=question.md");function tz(e){let{className:t}=e,a=(0,p.T)("worktree"),s=[{href:tI,label:a("feedback.bugReport")},{href:t_,label:a("feedback.featureRequest")},{href:tO,label:a("feedback.question")},{href:tA,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 tW=a(98702);function tB(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 tU=a(55125),tV=a.n(tU);let tH=[36e5,108e5,288e5],tZ={36e5:"autoYes.durations.1h",108e5:"autoYes.durations.3h",288e5:"autoYes.durations.8h"};function tY(e){let{isOpen:t,onConfirm:a,onCancel:s,cliToolName:n}=e,i=(0,p.T)("autoYes"),o=(0,p.T)("common"),[c,d]=(0,l.useState)(36e5),[u,m]=(0,l.useState)(""),[x,h]=(0,l.useState)(null),[f,g]=(0,l.useState)(!1),b=(0,l.useRef)(null),y=e=>i(tZ[e].replace("autoYes.",""));return(0,l.useEffect)(()=>{t&&(m(""),h(null),g(!1))},[t]),(0,l.useEffect)(()=>{if(!f)return;let e=e=>{b.current&&!b.current.contains(e.target)&&g(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[f]),(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(!tV()(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:i("invalidRegexPattern"))}},[u,i]),(0,r.jsx)(tW.u,{isOpen:t,onClose:s,title:n?i("enableTitleWithTool",{toolName:n}):i("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",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:i("featureDescription")}),(0,r.jsxs)("ul",{className:"list-disc list-inside space-y-1",children:[(0,r.jsx)("li",{children:i("yesNoAutoResponse")}),(0,r.jsx)("li",{children:i("multipleChoiceAutoSelect")})]}),(0,r.jsx)("p",{className:"mt-1",children:i("autoDisableAfter",{duration:y(c)})}),n&&(0,r.jsx)("p",{className:"mt-2 text-gray-500",children:i("appliesOnlyToCurrent",{toolName:n})})]}),(0,r.jsxs)("div",{className:"text-sm text-gray-700",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:i("duration")}),(0,r.jsx)("div",{className:"flex gap-2",children:tH.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-blue-600 bg-blue-50 text-blue-700":"border-gray-300 bg-white text-gray-700 hover:border-gray-400"),style:{minHeight:"44px"},children:y(e)},e))})]}),(0,r.jsxs)("div",{className:"text-sm text-gray-700",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:i("stopPatternLabel")}),(0,r.jsxs)("div",{className:"relative",ref:b,children:[(0,r.jsx)("button",{type:"button",onClick:()=>g(!f),className:"inline-flex items-center justify-center w-4 h-4 rounded-full bg-gray-300 text-gray-600 text-[10px] font-bold hover:bg-gray-400 focus:outline-none","aria-label":i("regexTipsLabel"),"data-testid":"regex-tips-button",children:"?"}),f&&(0,r.jsxs)("div",{className:"absolute left-0 top-6 z-50 w-72 rounded-md border border-gray-200 bg-white p-3 shadow-lg text-xs text-gray-700","data-testid":"regex-tips-tooltip",children:[(0,r.jsx)("p",{className:"font-medium mb-1.5",children:i("regexTipsTitle")}),(0,r.jsxs)("ul",{className:"space-y-1",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-gray-100 px-1 rounded",children:"\\bcat\\b"})," ",i("regexTipWordBoundary")]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-gray-100 px-1 rounded",children:"error|fatal"})," ",i("regexTipOr")]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-gray-100 px-1 rounded",children:"(?i)error"})," ",i("regexTipCaseNote")]})]})]})]})]}),(0,r.jsx)("p",{className:"text-xs text-gray-500 mb-2",children:i("stopPatternDescription")}),(0,r.jsx)("input",{id:"stop-pattern-input",type:"text",value:u,onChange:e=>m(e.target.value),placeholder:i("stopPatternPlaceholder"),className:"w-full px-3 py-2 border rounded-md text-sm font-mono ".concat(x?"border-red-500 focus:ring-red-500 focus:border-red-500":"border-gray-300 focus:ring-blue-500 focus:border-blue-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",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:i("aboutRisks")}),(0,r.jsx)("p",{children:i("riskWarning")})]}),(0,r.jsx)("div",{className:"bg-yellow-50 border-l-4 border-yellow-400 p-3",children:(0,r.jsxs)("p",{className:"text-sm text-yellow-800",children:[(0,r.jsx)("span",{className:"font-medium",children:i("disclaimer")}),i("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 hover:bg-gray-300 text-gray-700",children:o("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:i("agreeAndEnable")})]})]})})}function tq(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}let tG=(0,l.memo)(function(e){let{enabled:t,expiresAt:a,onToggle:s,lastAutoResponse:n,cliToolName:i,inline:o=!1}=e,[c,d]=(0,l.useState)(""),[u,m]=(0,l.useState)(null),[x,h]=(0,l.useState)(!1),[p,f]=(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 g=(0,l.useCallback)(()=>{t?(h(!0),s({enabled:!1}).finally(()=>h(!1))):f(!0)},[t,s]),b=(0,l.useCallback)((e,t)=>{f(!1),h(!0),s({enabled:!0,duration:e,stopPattern:t}).finally(()=>h(!1))},[s]),y=(0,l.useCallback)(()=>{f(!1)},[]);return(0,r.jsxs)("div",{className:o?"flex items-center gap-2":"flex items-center gap-3 px-4 py-2 bg-gray-50 border-b border-gray-200",children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":t,"aria-label":"Auto Yes mode",disabled:x,onClick:g,className:"relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ".concat(t?"bg-blue-600":"bg-gray-300"," ").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",children:"Auto Yes"}),t&&i&&(0,r.jsxs)("span",{className:"text-xs text-blue-600 font-medium","aria-label":"Auto Yes target",children:["(",tq(i),")"]}),t&&c&&(0,r.jsx)("span",{className:"text-sm text-gray-500","aria-label":"Time remaining",children:c}),u&&(0,r.jsx)("span",{className:"text-sm text-green-600 animate-pulse",children:u}),(0,r.jsx)(tY,{isOpen:p,onConfirm:b,onCancel:y,cliToolName:tq(i)})]})}),tK=(0,l.memo)(function(e){let{isBranchMismatch:t,currentBranch:a,initialBranch:s}=e,[n,i]=(0,l.useState)(!1);return((0,l.useEffect)(()=>{i(!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)(e4.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:()=>i(!0),className:"p-1 rounded hover:bg-amber-100 transition-colors","aria-label":"Dismiss alert",children:(0,r.jsx)(e9.Z,{className:"w-4 h-4"})})]})});var tX=a(47712),tJ=a(10407),tQ=a(56475),t$=a(14924);let t0=(0,l.memo)(function(e){let{isOpen:t,onClose:a,onConfirm:s,worktreeId:n,sourcePath:i,sourceType:o}=e,c=(0,p.T)("worktree"),d=(0,p.T)("common"),[u,m]=(0,l.useState)(""),[x,h]=(0,l.useState)(new Set([""])),[f,g]=(0,l.useState)([]),[b,y]=(0,l.useState)(!1),[v,j]=(0,l.useState)(new Set),w=i.includes("/")?i.substring(0,i.lastIndexOf("/")):"";(0,l.useEffect)(()=>{t&&(m(w),h(new Set([""])),g([]),N())},[t,n]);let N=(0,l.useCallback)(async()=>{y(!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}));g(t)}catch(e){}finally{y(!1)}},[n]),k=(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}));g(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]),C=(0,l.useCallback)(async e=>{h(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}(f,e);t&&!t.loaded&&await k(e)},[f,k]),S=(0,l.useCallback)(e=>!(e===w||"directory"===o&&(e===i||e.startsWith(i+"/"))),[w,i,o]),E=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=x.has(e.path),s=u===e.path,n=v.has(e.path),l=S(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&&m(e.path)},children:[(0,r.jsx)("button",{className:"w-4 h-4 flex items-center justify-center flex-shrink-0",onClick:t=>{t.stopPropagation(),C(e.path)},children:n?(0,r.jsx)(ta.Z,{className:"w-3 h-3 animate-spin text-gray-400"}):(0,r.jsx)(tJ.Z,{className:"w-3 h-3 text-gray-400 transition-transform ".concat(a?"rotate-90":"")})}),a?(0,r.jsx)(tQ.Z,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}):(0,r.jsx)(t$.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)},T=S(u);return(0,r.jsx)(tW.u,{isOpen:t,onClose:a,title:c("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:[c("fileTree.moveTo"),": ",(0,r.jsx)("span",{className:"font-mono text-gray-800",children:i})]}),(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(""===u?"bg-blue-100 text-blue-800":"hover:bg-gray-100 text-gray-700"," ").concat(S("")?"":"opacity-40 cursor-not-allowed"),onClick:()=>{S("")&&m("")},children:[(0,r.jsx)("span",{className:"w-4 h-4"}),(0,r.jsx)(t$.Z,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}),(0,r.jsx)("span",{children:c("fileTree.rootDirectory")})]}),b?(0,r.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,r.jsx)(ta.Z,{className:"w-5 h-5 animate-spin text-gray-400"})}):f.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:d("cancel")}),(0,r.jsx)("button",{onClick:()=>s(u),disabled:!T,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:c("fileTree.moveConfirm")})]})]})})});function t1(e){return e?e.split("/").map(encodeURIComponent).join("/"):""}let t2=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F\x80-\x9F\u200B-\u200F\u2028-\u202F\uFEFF]/;function t4(e){return e.replace(RegExp(t2.source,"g"),"")}let t5=/^[\w\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\uF900-\uFAFF\s-]{1,100}$/,t3=["default","acceptEdits","plan","dontAsk","bypassPermissions"],t6=["read-only","workspace-write","danger-full-access"],t8=["Name","Cron","Message","CLI Tool","Enabled"],t7=["Permission"],t9="## Schedules\n\n| Name | Cron | Message | CLI Tool | Enabled | Permission |\n|------|------|---------|----------|---------|------------|\n| example-task | 0 * * * * | README.mdを要約してください | claude | true | acceptEdits |\n",ae="v".concat("0.3.2");function at(e){return e.charAt(0).toUpperCase()+e.slice(1)}function aa(e,t,a,r){let[s,n]=(0,l.useState)(!1),[i,o]=(0,l.useState)(""),[c,d]=(0,l.useState)(!1);(0,l.useEffect)(()=>{r()&&e&&(o(e.description||""),n(!1))},[a,e]);let u=(0,l.useCallback)(async()=>{if(e){d(!0);try{let a=await tj.Iv.updateDescription(e.id,i);t(a),n(!1)}catch(e){console.error("Failed to save description:",e)}finally{d(!1)}}},[e,i,t]),m=(0,l.useCallback)(()=>{o((null==e?void 0:e.description)||""),n(!1)},[e]);return{isEditing:s,text:i,setText:o,isSaving:c,handleSave:u,handleCancel:m,startEditing:(0,l.useCallback)(()=>{n(!0)},[])}}let ar=(0,l.memo)(function(e){let{worktreeId:t,worktree:a,cardClassName:s,descriptionEditor:n,showLogs:l,onToggleLogs:i}=e,{isEditing:o,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 mb-1",children:"Worktree"}),(0,r.jsx)("p",{className:"text-lg font-semibold text-gray-900",children:a.name})]}),(0,r.jsxs)("div",{className:s,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-gray-500 mb-1",children:"Repository"}),(0,r.jsx)("p",{className:"text-base text-gray-900",children:a.repositoryName}),(0,r.jsx)("p",{className:"text-xs text-gray-500 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 mb-1",children:"Path"}),(0,r.jsx)("p",{className:"text-sm text-gray-700 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 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":"doing"===a.status?"bg-blue-100 text-blue-800":"bg-gray-100 text-gray-800"),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",children:"Description"}),!o&&(0,r.jsx)("button",{type:"button",onClick:h,className:"text-sm text-blue-600 hover:text-blue-800",children:"Edit"})]}),o?(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 rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-blue-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 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 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 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 mb-1",children:"Last Updated"}),(0,r.jsx)("p",{className:"text-sm text-gray-700",children:new Date(a.updatedAt).toLocaleString()})]}),(0,r.jsx)(tF,{version:ae,className:s}),(0,r.jsx)(tz,{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:i,className:"text-sm text-blue-600 hover:text-blue-800",children:l?"Hide":"Show"})]}),l&&(0,r.jsx)(tM.n,{worktreeId:t})]})]})}),as=(0,l.memo)(function(e){let{worktreeName:t,repositoryName:a,description:s,status:n,gitStatus:l,onBackClick:i,onInfoClick:o,onMenuClick:c,hasUpdate:d}=e,u=es.Ie[n],m=s?(0,en.aS)(s,50):null;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-white border-b border-gray-200",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 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","aria-hidden":"true"}),(0,r.jsxs)("button",{type:"button",onClick:i,className:"flex items-center gap-1 text-gray-600 hover:text-gray-900 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:"M15 19l-7-7 7-7"})}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Back"})]}),(0,r.jsx)("div",{className:"w-px h-6 bg-gray-300","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 truncate max-w-[200px] leading-tight",children:t}),m&&(0,r.jsx)("span",{className:"text-sm text-gray-500 truncate max-w-md",title:s,children:m})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-500",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",children:"/"}),(0,r.jsx)("span",{className:"truncate max-w-[150px] font-mono",title:l.currentBranch,"data-testid":"desktop-branch-name",children:(0,en.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:o,className:"relative flex items-center gap-1.5 px-3 py-1.5 text-gray-600 hover:text-gray-900 hover:bg-gray-100 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)(ec,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":"Update available"})]})]})}),an=(0,l.memo)(function(e){let{worktreeId:t,worktree:a,isOpen:s,onClose:n,onWorktreeUpdate:i}=e,[o,c]=(0,l.useState)(!1),d=(0,l.useRef)(s),u=aa(a,i,s,()=>{let e=s&&!d.current;return d.current=s,e});return a?(0,r.jsx)(tW.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)(ar,{worktreeId:t,worktree:a,cardClassName:"bg-gray-50 rounded-lg p-4",descriptionEditor:u,showLogs:o,onToggleLogs:()=>c(!o)})})}):null}),al=(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 border-t-blue-600","aria-hidden":"true"}),(0,r.jsx)("p",{className:"text-gray-600",children:"Loading worktree..."})]})})}),ai=(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"})]})})}),ao=(0,l.memo)(function(e){let{worktreeId:t,worktree:a,onWorktreeUpdate:s}=e,[n,i]=(0,l.useState)(!1),o=(0,l.useRef)(null==a?void 0:a.id),c=(0,l.useRef)(!1),d=aa(a,s,null==a?void 0:a.id,()=>{let e=(null==a?void 0:a.id)!==o.current;return o.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)(ar,{worktreeId:t,worktree:a,cardClassName:"bg-white rounded-lg border border-gray-200 p-4",descriptionEditor:d,showLogs:n,onToggleLogs:()=>i(!n)})}):(0,r.jsx)("div",{className:"text-gray-500 text-center py-8",children:"Loading worktree info..."})}),ac=(0,l.memo)(function(e){let{activeTab:t,worktreeId:a,worktree:s,messages:n,terminalOutput:l,isTerminalActive:i,isThinking:o,onFilePathClick:c,onFileSelect:d,onWorktreeUpdate:u,onNewFile:m,onNewDirectory:x,onRename:h,onDelete:p,onUpload:g,onMove:b,refreshTrigger:y,fileSearch:v,showToast:j,onCmateSetup:w}=e;switch(t){case"terminal":return(0,r.jsx)(f,{componentName:"TerminalDisplay",children:(0,r.jsx)(A,{output:l,isActive:i,isThinking:o,className:"h-full"})});case"history":return(0,r.jsx)(f,{componentName:"HistoryPane",children:(0,r.jsx)(K,{messages:n,worktreeId:a,onFilePathClick:c,className:"h-full",showToast:j})});case"files":var N;return(0,r.jsx)(f,{componentName:"FileTreeView",children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(eB,{query:v.query,mode:v.mode,isSearching:v.isSearching,error:v.error,onQueryChange:v.setQuery,onModeChange:v.setMode,onClear:v.clearSearch}),(0,r.jsx)(e_,{worktreeId:a,onFileSelect:d,onNewFile:m,onNewDirectory:x,onRename:h,onDelete:p,onUpload:g,onMove:b,onCmateSetup:w,refreshTrigger:y,searchQuery:v.query,searchMode:v.mode,searchResults:null===(N=v.results)||void 0===N?void 0:N.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,r.jsx)(f,{componentName:"NotesAndLogsPane",children:(0,r.jsx)(tT,{worktreeId:a,className:"h-full"})});case"info":return(0,r.jsx)(ao,{worktreeId:a,worktree:s,onWorktreeUpdate:u});default:return null}}),ad=(0,l.memo)(function(e){var t,a,n,i,o,c,d,g,b,y;let{worktreeId:v}=e,j=(0,s.useRouter)(),w=(0,x.d)(),{toggle:N,openMobileDrawer:k}=(0,h.Sz)(),{state:C,actions:S}=function(){let[e,t]=(0,l.useReducer)(m,void 0,u),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,p.T)("worktree"),M=(0,p.T)("error"),R=(0,p.T)("common"),L=(0,p.T)("autoYes"),F=(0,p.T)("schedule"),[P,D]=(0,l.useState)(null),[I,_]=(0,l.useState)(!0),[O,z]=(0,l.useState)(null),[W,B]=(0,l.useState)(!1),[U,V]=(0,l.useState)(null),[H,Z]=(0,l.useState)(null),[Y,q]=(0,l.useState)(!1),[G,X]=(0,l.useState)(!1),[J,Q]=(0,l.useState)(null),$=(0,l.useRef)(!1),[ee,et]=(0,l.useState)(!1),[ea,el]=(0,l.useState)("claude"),ei=(0,l.useRef)(ea);ei.current=ea;let[ec,ed]=(0,l.useState)(0),eu=function(e){let{worktreeId:t,initialMode:a="name",debounceMs:r=300}=e,[s,n]=(0,l.useState)(""),[i,o]=(0,l.useState)(""),[c,d]=(0,l.useState)(a),[u,m]=(0,l.useState)(!1),[x,h]=(0,l.useState)(null),[p,f]=(0,l.useState)(null),g=(0,l.useRef)(null),b=(0,l.useMemo)(()=>(0,en.Ds)(e=>{o(e)},r),[r]),y=(0,l.useCallback)(e=>{n(e),b(e),f(null)},[b]),v=(0,l.useCallback)(()=>{n(""),o(""),h(null),f(null),m(!1),g.current&&(g.current.abort(),g.current=null)},[]),j=(0,l.useCallback)(e=>{if(!i.trim())return e;let t=i.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t))},[i]),w=(0,l.useCallback)(()=>x&&0!==x.results.length?(0,en.Ps)(x.results.map(e=>e.filePath)):new Set,[x]);return(0,l.useEffect)(()=>{if("content"!==c||!i.trim()){h(null);return}g.current&&g.current.abort();let e=new AbortController;return g.current=e,(async()=>{m(!0),f(null);try{var a,r;let s=await fetch("/api/worktrees/".concat(encodeURIComponent(t),"/search?q=").concat(encodeURIComponent(i),"&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:i,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;f(e instanceof Error?e.message:"An error occurred while searching"),h(null)}finally{m(!1)}})(),()=>{e.abort()}},[c,i,t]),(0,l.useEffect)(()=>{"name"===c&&(h(null),m(!1),f(null))},[c]),{query:s,mode:c,isSearching:u,results:x,error:p,setQuery:y,setMode:d,clearSearch:v,filterByName:j,getMatchedPaths:w}}({worktreeId:v}),ex=(0,l.useRef)(!1),ep=(0,l.useRef)(v);(0,l.useEffect)(()=>{ep.current!==v&&(S.clearMessages(),ex.current=!1,S.setTerminalOutput("",""),ep.current=v)},[v,S]);let ef=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/worktrees/".concat(v));if(!e.ok)throw Error("Failed to fetch worktree: ".concat(e.status));let t=await e.json();return D(t),t}catch(e){return z(e instanceof Error?e.message:"Unknown error"),null}},[v]),eg=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/worktrees/".concat(v,"/messages?cliTool=").concat(ei.current));if(!e.ok)throw Error("Failed to fetch messages: ".concat(e.status));let t=await e.json();S.setMessages(t.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(e){console.error("[WorktreeDetailRefactored] Error fetching messages:",e)}},[v,S]),ey=(0,l.useCallback)(async()=>{try{var e,t,a,r,s;let n=await fetch("/api/worktrees/".concat(v,"/current-output?cliTool=").concat(ei.current));if(!n.ok)return;let l=await n.json(),i=null!==(t=null!==(e=l.fullOutput)&&void 0!==e?e:l.realtimeSnippet)&&void 0!==t?t:"";if((i||l.isRunning)&&S.setTerminalOutput(i,null!==(a=l.realtimeSnippet)&&void 0!==a?a:""),S.setTerminalActive(null!==(r=l.isRunning)&&void 0!==r&&r),S.setTerminalThinking(null!==(s=l.thinking)&&void 0!==s&&s),l.isPromptWaiting&&l.promptData?S.showPrompt(l.promptData,"prompt-".concat(Date.now())):!l.isPromptWaiting&&C.prompt.visible&&S.clearPrompt(),l.autoYes){let e=$.current;X(l.autoYes.enabled),Q(l.autoYes.expiresAt),$.current=l.autoYes.enabled,e&&!l.autoYes.enabled&&"stop_pattern_matched"===l.autoYes.stopReason&&et(!0)}}catch(e){console.error("[WorktreeDetailRefactored] Error fetching current output:",e)}},[v,S,C.prompt.visible]),ev=(0,l.useRef)(ea);(0,l.useEffect)(()=>{ev.current!==ea&&(ev.current=ea,S.clearMessages(),S.setTerminalOutput("",""),eg(),ey())},[ea,S,eg,ey]);let ej=(0,l.useCallback)(e=>{V(e)},[]),ew=(0,l.useCallback)(e=>{var t;let a=null===(t=e.split(".").pop())||void 0===t?void 0:t.toLowerCase();tb.includes(a?".".concat(a):"")?Z(e):V(e)},[]),eN=(0,l.useCallback)(()=>{V(null)},[]),ek=(0,l.useCallback)(()=>{Z(null)},[]),eC=(0,l.useCallback)(e=>{ed(e=>e+1)},[]),eS=(0,l.useCallback)(e=>{S.setLeftPaneTab(e)},[S]),eE=(0,l.useCallback)(()=>{j.push("/")},[j]),eT=(0,l.useCallback)(()=>{B(!0)},[]),eM=(0,l.useCallback)(()=>{B(!1)},[]),eR=(0,l.useCallback)(async e=>{S.setPromptAnswering(!0);try{let t=tB(e,ea,C.prompt.data),a=await fetch("/api/worktrees/".concat(v,"/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));S.clearPrompt(),await ey()}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e)}finally{S.setPromptAnswering(!1)}},[v,S,ey,ea,C.prompt.data]),eL=(0,l.useCallback)(()=>{S.clearPrompt()},[S]),eF=(0,l.useCallback)(e=>{S.setMobileActivePane(e)},[S]),eP=(0,l.useCallback)(e=>{S.setAutoScroll(e)},[S]),eA=(0,l.useCallback)(()=>{eg(),ey()},[eg,ey]),eD=(0,l.useCallback)(async e=>{try{let t=await fetch("/api/worktrees/".concat(v,"/auto-yes"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e.enabled,cliToolId:ea,duration:e.duration,stopPattern:e.stopPattern})});if(t.ok){let e=await t.json();X(e.enabled),Q(e.expiresAt),$.current=e.enabled}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[v,ea]),[eI,eO]=(0,l.useState)(!1),ez=(0,l.useCallback)(()=>{eO(!0)},[]),eW=(0,l.useCallback)(async()=>{eO(!1);try{if(!(await fetch("/api/worktrees/".concat(v,"/kill-session?cliTool=").concat(ea),{method:"POST"})).ok)return;S.clearMessages(),S.setTerminalOutput("",""),S.setTerminalActive(!1),S.setTerminalThinking(!1),S.clearPrompt(),await ef()}catch(e){console.error("[WorktreeDetailRefactored] Error killing session:",e)}},[v,ea,S,ef]),eU=(0,l.useCallback)(()=>{eO(!1)},[]),eV=(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(v,"/files/").concat(t1(r)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:""})})).ok)throw Error("Failed to create file");ed(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create file:",e),window.alert(M("fileOps.failedToCreateFile"))}},[v,M]),eH=(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(v,"/files/").concat(t1(a)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"directory"})})).ok)throw Error("Failed to create directory");ed(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create directory:",e),window.alert(M("fileOps.failedToCreateDirectory"))}},[v,M]),eZ=(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(v,"/files/").concat(t1(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"rename",newName:a})})).ok)throw Error("Failed to rename");ed(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to rename:",e),window.alert(M("fileOps.failedToRename"))}},[v,M]),eq=(0,l.useCallback)(async e=>{let t=e.split("/").pop()||e;if(window.confirm(R("confirmDelete",{name:t})))try{if(!(await fetch("/api/worktrees/".concat(v,"/files/").concat(t1(e),"?recursive=true"),{method:"DELETE"})).ok)throw Error("Failed to delete");(H===e||(null==H?void 0:H.startsWith("".concat(e,"/"))))&&Z(null),ed(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert(M("fileOps.failedToDelete"))}},[v,H,R,M]),{toasts:eG,showToast:eK,removeToast:eX}=(0,te.pm)();(0,l.useEffect)(()=>{ee&&(eK(L("stopPatternMatched"),"info"),et(!1))},[ee,eK,L]);let{moveTarget:eQ,isMoveDialogOpen:e$,handleMove:e0,handleMoveConfirm:e1,handleMoveCancel:e2}=function(e,t,a,r){let[s,n]=(0,l.useState)(null),[i,o]=(0,l.useState)(!1),c=(0,l.useCallback)((e,t)=>{n({path:e,type:t}),o(!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})}),o=await n.json();if(!n.ok||!o.success){var i;let e=(null===(i=o.error)||void 0===i?void 0:i.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),o(!1)}},[s,e,t,a,r]);return{moveTarget:s,isMoveDialogOpen:i,handleMove:c,handleMoveConfirm:d,handleMoveCancel:(0,l.useCallback)(()=>{n(null),o(!1)},[])}}(v,()=>ed(e=>e+1),e=>eK(e,"success"),e=>eK(e,"error")),e4=(0,l.useRef)(null),e5=(0,l.useRef)(""),e3=(0,l.useCallback)(e=>{var t;e5.current=e,null===(t=e4.current)||void 0===t||t.click()},[]),e6=(0,l.useCallback)(async()=>{try{var e;let t;let a=await fetch("/api/worktrees/".concat(v,"/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(v,"/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){eK(F("cmateValidation.failed"),"error");return}t=a.content}else{if(!(await fetch("/api/worktrees/".concat(v,"/files/CMATE.md"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:t9})})).ok)throw Error("Failed to create CMATE.md");eK(F("cmateCreated"),"success"),ed(e=>e+1),t=t9}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<t8.length;e++){let a=t8[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<t7.length;e++){let a=t8.length+e,r=t7[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 i=a.split("|").slice(1,-1).map(e=>e.trim());i.length>0&&t.get(r).push(i)}return t})(t).get("Schedules");if(!n||0===n.length){eK(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,i]=s,o=t4(n);t5.test(o)||t.push({row:r,message:"Row ".concat(r+1,': invalid name "').concat(o,'"'),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"}),t4(i).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?t6:t3).includes(e)||t.push({row:r,message:"Row ".concat(r+1,': invalid permission "').concat(e,'" for ').concat(n),field:"permission"})}}return t}(n),i=[...s,...l];if(0===i.length)eK(F("cmateValidation.valid",{count:String(n.length)}),"success");else{let e=i.slice(0,3).map(e=>e.message).join("; "),t=i.length>3?" (+".concat(i.length-3,")"):"";eK(F("cmateValidation.errors",{errorCount:String(i.length),details:e+t}),"error")}}catch(e){console.error("[WorktreeDetailRefactored] CMATE setup error:",e),eK(F("cmateValidation.failed"),"error")}},[v,eK,F]),e8=(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=e5.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 tv.includes(t)}(l)){eK("Unsupported file type: ".concat(l,". Allowed: ").concat(tv.join(", ")),"error");return}let i=function(e){var t;let a=function(e){let t=e.toLowerCase();return ty.find(e=>e.extension===t)}(e);return null!==(t=null==a?void 0:a.maxFileSize)&&void 0!==t?t:5242880}(l);if(s.size>i){eK("File too large. Maximum size: ".concat((i/1024/1024).toFixed(1),"MB"),"error");return}let o=new FormData;o.append("file",s);try{let e=await fetch("/api/worktrees/".concat(v,"/upload/").concat(t1(n||".")),{method:"POST",body:o});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";eK(a,"error");return}let t=await e.json();eK("Uploaded: ".concat(t.filename),"success"),ed(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),eK("Upload failed. Please try again.","error")}},[v,eK]),{data:e7}=tR(),e9=null!==(o=null==e7?void 0:e7.hasUpdate)&&void 0!==o&&o,{lastAutoResponse:tt}=function(e){let{worktreeId:t,cliTool:a,isPromptWaiting:r,promptData:s,autoYesEnabled:n,lastServerResponseTimestamp:i}=e,o=(0,l.useRef)(null),[c,d]=(0,l.useState)(null);return(0,l.useEffect)(()=>{var e;if(!r){o.current=null;return}if(!s||!n||i&&Date.now()-i<3e3)return;let l=(e={type:s.type,question:s.question},"".concat(e.type,":").concat(e.question));if(o.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;o.current=l,d(c);let u=tB(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,i]),{lastAutoResponse:c}}({worktreeId:v,cliTool:ea,isPromptWaiting:C.prompt.visible,promptData:C.prompt.data,autoYesEnabled:G}),ta=(0,l.useCallback)(async()=>{z(null),_(!0),await ef()&&await Promise.all([eg(),ey()]),_(!1)},[ef,eg,ey]),tr=(0,l.useRef)(0),ts=(0,l.useCallback)(async()=>{if("visible"!==document.visibilityState)return;let e=Date.now();if(!(e-tr.current<5e3)){if(tr.current=e,O){ta();return}try{await Promise.all([ef(),eg(),ey()])}finally{z(null)}}},[O,ta,ef,eg,ey]);(0,l.useEffect)(()=>{if(ex.current)return;let e=!0;return(async()=>{_(!0);let t=await ef();e&&(t&&await Promise.all([eg(),ey()]),e&&(_(!1),ex.current=!0))})(),()=>{e=!1}},[ef,eg,ey]),(0,l.useEffect)(()=>(document.addEventListener("visibilitychange",ts),()=>{document.removeEventListener("visibilitychange",ts)}),[ts]),(0,l.useEffect)(()=>{if(I||O)return;let e=setInterval(async()=>{await Promise.all([ey(),ef(),eg()])},C.terminal.isActive?2e3:5e3);return()=>clearInterval(e)},[I,O,ey,ef,eg,C.terminal.isActive]),(0,l.useEffect)(()=>{S.setLayoutMode(w?"tabs":"split")},[w,S]);let tn=(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,ea),[P,C.error.type,ea]),tl=(0,l.useMemo)(()=>C.layout.mobileActivePane,[C.layout.mobileActivePane]),ti=(0,l.useMemo)(()=>C.layout.leftPaneTab,[C.layout.leftPaneTab]),to=null!==(c=null==P?void 0:P.name)&&void 0!==c?c:"Unknown";return I?(0,r.jsx)(al,{}):O?(0,r.jsx)(ai,{message:O,onRetry:ta}):w?(0,r.jsx)(f,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(eo,{worktreeName:to,repositoryName:null==P?void 0:P.repositoryName,status:tn,gitStatus:null==P?void 0:P.gitStatus,onBackClick:eE,onMenuClick:k}),(null==P?void 0:P.gitStatus)&&P.gitStatus.isBranchMismatch&&(0,r.jsx)("div",{className:"fixed top-14 inset-x-0 z-35",children:(0,r.jsx)(tK,{isBranchMismatch:P.gitStatus.isBranchMismatch,currentBranch:P.gitStatus.currentBranch,initialBranch:P.gitStatus.initialBranch})}),(0,r.jsxs)("div",{className:"fixed top-14 inset-x-0 z-30 flex items-center justify-between px-3 py-1.5 bg-gray-50 border-b border-gray-200",children:[(0,r.jsx)(tG,{enabled:G,expiresAt:J,onToggle:eD,lastAutoResponse:tt,cliToolName:ea,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:["claude","codex"].map(e=>{var t;let a=(0,tX.He)(null==P?void 0:null===(t=P.sessionStatusByCli)||void 0===t?void 0:t[e]),s=es.F4[a];return(0,r.jsxs)("button",{onClick:()=>el(e),className:"px-1.5 py-0.5 rounded font-medium text-xs transition-colors flex items-center gap-1 ".concat(ea===e?"bg-blue-100 text-blue-700":"text-gray-500 hover:text-gray-700"),"aria-current":ea===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}),at(e)]},e)})}),(0,r.jsxs)("button",{onClick:ez,disabled:!(null==P?void 0:null===(a=P.sessionStatusByCli)||void 0===a?void 0:null===(t=a[ea])||void 0===t?void 0:t.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===(n=i[ea])||void 0===n?void 0:n.isRunning)?"text-red-600 hover:bg-red-50":"invisible"),"aria-label":"End ".concat(ea," session"),children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"✕"}),"End"]})]})]}),(0,r.jsx)("main",{className:"flex-1 pt-[6.25rem] pb-32 overflow-hidden",style:{paddingBottom:"calc(8rem + env(safe-area-inset-bottom, 0px))"},children:(0,r.jsx)(ac,{activeTab:tl,worktreeId:v,worktree:P,messages:C.messages,terminalOutput:C.terminal.output,isTerminalActive:C.terminal.isActive,isThinking:C.terminal.isThinking,onFilePathClick:ej,onFileSelect:ew,onWorktreeUpdate:D,onNewFile:eV,onNewDirectory:eH,onRename:eZ,onDelete:eq,onUpload:e3,onMove:e0,refreshTrigger:ec,fileSearch:eu,showToast:eK,onCmateSetup:e6})}),(0,r.jsx)("div",{className:"fixed left-0 right-0 border-t border-gray-200 bg-white p-2 z-30",style:{bottom:"calc(4rem + env(safe-area-inset-bottom, 0px))"},children:(0,r.jsx)(eb.R,{worktreeId:v,onMessageSent:eA,cliToolId:ea,isSessionRunning:C.terminal.isActive})}),(0,r.jsx)(em,{activeTab:tl,onTabChange:eF,hasNewOutput:!1,hasPrompt:C.prompt.visible,hasUpdate:e9}),!G&&(0,r.jsx)(eh,{promptData:C.prompt.data,visible:C.prompt.visible,answering:C.prompt.answering,onRespond:eR,onDismiss:eL}),(0,r.jsx)(eJ,{isOpen:null!==U,onClose:eN,worktreeId:v,filePath:null!=U?U:""}),H&&(0,r.jsx)(tW.u,{isOpen:!0,onClose:ek,title:H.split("/").pop()||"Editor",size:"full",disableClose:Y,children:(0,r.jsx)("div",{className:"h-[80vh]",children:(0,r.jsx)(tg,{worktreeId:v,filePath:H,onClose:ek,onSave:eC,onMaximizedChange:q})})}),(0,r.jsx)("input",{ref:e4,type:"file",accept:tv.join(","),onChange:e8,className:"hidden","aria-label":"Upload file"}),(0,r.jsx)(tW.u,{isOpen:eI,onClose:eU,title:E("session.confirmEnd",{tool:at(ea)}),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:eU,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700",children:R("cancel")}),(0,r.jsx)("button",{type:"button",onClick:eW,className:"px-4 py-2 text-sm font-medium rounded-md bg-red-600 hover:bg-red-700 text-white",children:R("end")})]})]})}),eQ&&(0,r.jsx)(t0,{isOpen:e$,onClose:e2,onConfirm:e1,worktreeId:v,sourcePath:eQ.path,sourceType:eQ.type}),(0,r.jsx)(te.Ix,{toasts:eG,onClose:eX})]})}):(0,r.jsx)(f,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"h-full flex flex-col relative",children:[(0,r.jsx)(as,{worktreeName:to,repositoryName:null!==(y=null==P?void 0:P.repositoryName)&&void 0!==y?y:"Unknown",description:null==P?void 0:P.description,status:tn,gitStatus:null==P?void 0:P.gitStatus,onBackClick:eE,onInfoClick:eT,onMenuClick:N,hasUpdate:e9}),(0,r.jsxs)("div",{className:"px-4 py-2 bg-white border-b border-gray-200 flex items-center justify-between",children:[(0,r.jsx)("nav",{className:"flex gap-4","aria-label":"CLI Tool Selection",children:["claude","codex"].map(e=>{var t;let a=(0,tX.He)(null==P?void 0:null===(t=P.sessionStatusByCli)||void 0===t?void 0:t[e]),s=es.F4[a];return(0,r.jsxs)("button",{onClick:()=>el(e),className:"pb-2 px-2 border-b-2 font-medium text-sm transition-colors flex items-center gap-1.5 ".concat(ea===e?"border-blue-600 text-blue-600":"border-transparent text-gray-600 hover:text-gray-900"),"aria-current":ea===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)}),at(e)]},e)})}),(null==P?void 0:null===(g=P.sessionStatusByCli)||void 0===g?void 0:null===(d=g[ea])||void 0===d?void 0:d.isRunning)&&(0,r.jsxs)("button",{onClick:ez,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(ea," session"),children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"✕"}),"End Session"]})]}),(null==P?void 0:P.gitStatus)&&(0,r.jsx)(tK,{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)(T,{leftPane:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(eY,{activeTab:ti,onTabChange:eS}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["history"===ti&&(0,r.jsx)(K,{messages:C.messages,worktreeId:v,onFilePathClick:ej,className:"h-full",showToast:eK}),"files"===ti&&(0,r.jsx)(f,{componentName:"FileTreeView",children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(eB,{query:eu.query,mode:eu.mode,isSearching:eu.isSearching,error:eu.error,onQueryChange:eu.setQuery,onModeChange:eu.setMode,onClear:eu.clearSearch}),(0,r.jsx)(e_,{worktreeId:v,onFileSelect:ew,onNewFile:eV,onNewDirectory:eH,onRename:eZ,onDelete:eq,onUpload:e3,onMove:e0,onCmateSetup:e6,refreshTrigger:ec,searchQuery:eu.query,searchMode:eu.mode,searchResults:null===(b=eu.results)||void 0===b?void 0:b.results,className:"flex-1 min-h-0"})]})}),"memo"===ti&&(0,r.jsx)(f,{componentName:"NotesAndLogsPane",children:(0,r.jsx)(tT,{worktreeId:v,className:"h-full"})})]})]}),rightPane:(0,r.jsx)(A,{output:C.terminal.output,isActive:C.terminal.isActive,isThinking:C.terminal.isThinking,autoScroll:C.terminal.autoScroll,onScrollChange:eP}),initialLeftWidth:40,minLeftWidth:20,maxLeftWidth:60})}),(0,r.jsx)("div",{className:"flex-shrink-0 border-t border-gray-200 p-4 bg-gray-50",children:(0,r.jsx)(eb.R,{worktreeId:v,onMessageSent:eA,cliToolId:ea,isSessionRunning:C.terminal.isActive})}),(0,r.jsx)(tG,{enabled:G,expiresAt:J,onToggle:eD,lastAutoResponse:tt,cliToolName:ea}),C.prompt.visible&&!G&&(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)(er,{promptData:C.prompt.data,messageId:C.prompt.messageId,visible:C.prompt.visible,answering:C.prompt.answering,onRespond:eR,onDismiss:eL})}),(0,r.jsx)(an,{worktreeId:v,worktree:P,isOpen:W,onClose:eM,onWorktreeUpdate:D}),(0,r.jsx)(eJ,{isOpen:null!==U,onClose:eN,worktreeId:v,filePath:null!=U?U:""}),H&&(0,r.jsx)(tW.u,{isOpen:!0,onClose:ek,title:H.split("/").pop()||"Editor",size:"full",disableClose:Y,children:(0,r.jsx)("div",{className:"h-[80vh]",children:(0,r.jsx)(tg,{worktreeId:v,filePath:H,onClose:ek,onSave:eC,onMaximizedChange:q})})}),(0,r.jsx)("input",{ref:e4,type:"file",accept:tv.join(","),onChange:e8,className:"hidden","aria-label":"Upload file"}),(0,r.jsx)(tW.u,{isOpen:eI,onClose:eU,title:E("session.confirmEnd",{tool:at(ea)}),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:eU,className:"px-4 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-700",children:R("cancel")}),(0,r.jsx)("button",{type:"button",onClick:eW,className:"px-4 py-2 text-sm font-medium rounded-md bg-red-600 hover:bg-red-700 text-white",children:R("end")})]})]})}),eQ&&(0,r.jsx)(t0,{isOpen:e$,onClose:e2,onConfirm:e1,worktreeId:v,sourcePath:eQ.path,sourceType:eQ.type}),(0,r.jsx)(te.Ix,{toasts:eG,onClose:eX})]})})});function au(){let e=(0,s.useParams)().id;return(0,r.jsx)(n.Vw,{children:(0,r.jsx)(ad,{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,i]=(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:()=>{i(!0),null==n||n()},style:{maxWidth:"100%",maxHeight:"500px",objectFit:"contain"},className:"rounded-lg shadow-sm"})})}},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),[i,o]=(0,s.useState)(!1);return i?(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),o(!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."})]})}}},function(e){e.O(0,[7851,9234,216,1038,2335,9178,8528,8091,2971,2117,1744],function(){return e(e.s=5635)}),_N_E=e.O()}]);
|