commandmate 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +328 -319
- package/.next/app-path-routes-manifest.json +26 -26
- package/.next/build-manifest.json +5 -5
- package/.next/prerender-manifest.json +9 -9
- package/.next/required-server-files.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agents/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agents/versions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app/update-check/route.js +1 -1
- package/.next/server/app/api/app/update-check/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/conversation/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/current-output/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/messages/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/session/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/start/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/terminal/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/tools/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/capabilities/route.js +1 -1
- package/.next/server/app/api/capabilities/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/daily-summary/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/daily-summary/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/[id]/health/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/fs/browse/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/fs/recent-paths/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/hooks/agent-event/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/hooks/permission-request/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/metrics/vibe/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/escalation/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/relays/[relayId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/relays/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/remote/pair/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/clone/[jobId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/clone/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/sync/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/validate-path/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/settings/default-agents/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/settings/default-surface-mode/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sidebar/group-order/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/installations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/operations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/reindex/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/slash-commands/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[taskId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/templates/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/verification/runs/[runId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/verification/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/auto-yes/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/capture/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/clear-composer/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cli-reference/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cli-tool/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cmate/schedules/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/env/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/files/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/create/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/delete/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branches/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/checkout/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/commit/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/fetch/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/log/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/pull/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/push/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/reset/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/revert/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/staged/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/apply/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/pop/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/push/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/unstage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/working-diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/instances/notes/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/instances/opencode/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/interrupt/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/kill-session/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/[filename]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/marp-render/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/messages/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/opencode/diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/opencode/session/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/opencode/share/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/prompt-response/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/resolve-target/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/respond/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/active/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/search/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/send/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update-plan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/slash-commands/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/special-keys/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tasks/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/terminal/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/history/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/upload/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/config/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/apply-default-agents/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/route.js +1 -1
- package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
- package/.next/server/app/chat/page.js +2 -2
- package/.next/server/app/chat/page.js.nft.json +1 -1
- package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
- package/.next/server/app/more/page.js +2 -2
- package/.next/server/app/more/page_client-reference-manifest.js +1 -1
- package/.next/server/app/offline/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/proxy/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
- package/.next/server/app/review/page_client-reference-manifest.js +1 -1
- package/.next/server/app/sessions/page.js +2 -2
- package/.next/server/app/sessions/page.js.nft.json +1 -1
- package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/[skillId]/page.js +1 -1
- package/.next/server/app/skills/[skillId]/page.js.nft.json +1 -1
- package/.next/server/app/skills/[skillId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/installed/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/files/[...path]/page.js +2 -2
- package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/page.js +9 -22
- 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_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +26 -26
- package/.next/server/chunks/1707.js +14 -0
- package/.next/server/chunks/3123.js +1 -1
- package/.next/server/chunks/3543.js +1 -1
- package/.next/server/chunks/364.js +1 -0
- package/.next/server/chunks/3945.js +1 -1
- package/.next/server/chunks/4802.js +1 -1
- package/.next/server/chunks/6130.js +1 -1
- package/.next/server/chunks/7004.js +1 -0
- package/.next/server/chunks/8142.js +1 -0
- package/.next/server/chunks/8728.js +1 -1
- package/.next/server/chunks/9123.js +1 -1
- package/.next/server/chunks/9627.js +1 -1
- package/.next/server/chunks/9701.js +1 -0
- package/.next/server/middleware-build-manifest.js +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/2039-117a361f795ddc4b.js +1 -0
- package/.next/static/chunks/2053-ce3fe896ad45e50f.js +1 -0
- package/.next/static/chunks/2407-6b8ca567e18ad583.js +1 -0
- package/.next/static/chunks/3160-79d24ca264a528b9.js +1 -0
- package/.next/static/chunks/4949-d804db873cfd9310.js +1 -0
- package/.next/static/chunks/{6022-7a7d1760fc9814c7.js → 6022-d2d7bd9373ff3ae9.js} +1 -1
- package/.next/static/chunks/6983-3ed2099251793bdf.js +1 -0
- package/.next/static/chunks/934-a37509667baa86ee.js +1 -0
- package/.next/static/chunks/9526-4fe2fc64be44e5c1.js +1 -0
- package/.next/static/chunks/app/chat/page-bfc1f5bb17bd771d.js +1 -0
- package/.next/static/chunks/app/more/page-400ffa825f8f150e.js +1 -0
- package/.next/static/chunks/app/sessions/page-366edfaa0b1faad2.js +1 -0
- package/.next/static/chunks/app/skills/[skillId]/{page-844872df04f52943.js → page-ce8f6fd9e4356580.js} +1 -1
- package/.next/static/chunks/app/worktrees/[id]/page-df482ec0c378c77b.js +1 -0
- package/.next/static/chunks/{webpack-1dc9eb5ebb4fa5ff.js → webpack-0281b30457d46ebc.js} +1 -1
- package/.next/static/css/c511ecdf1e7f18a0.css +1 -0
- package/.next/trace +14 -14
- package/dist/server/src/lib/auto-yes-state.js +36 -0
- package/package.json +1 -1
- package/.next/server/chunks/120.js +0 -1
- package/.next/server/chunks/7593.js +0 -1
- package/.next/static/chunks/1191-b7dfdfe86b1d31d1.js +0 -1
- package/.next/static/chunks/2053-9ac860ab4e92ac89.js +0 -1
- package/.next/static/chunks/2407-b9001cc6041876e1.js +0 -1
- package/.next/static/chunks/4809-145884b958e7d9a6.js +0 -1
- package/.next/static/chunks/5542-b6457f305d724a6b.js +0 -1
- package/.next/static/chunks/app/chat/page-609c9a0f5ce44799.js +0 -1
- package/.next/static/chunks/app/more/page-7c5380e4a7561935.js +0 -1
- package/.next/static/chunks/app/sessions/page-6486d9a643c1dc6f.js +0 -1
- package/.next/static/chunks/app/worktrees/[id]/page-3a58ae66e203f935.js +0 -1
- package/.next/static/css/b09bede85744e1cf.css +0 -1
- /package/.next/static/{0vChXhzA5YWj3f0D6A-Cn → zNNp00FuBenN_iZtIvIBP}/_buildManifest.js +0 -0
- /package/.next/static/{0vChXhzA5YWj3f0D6A-Cn → zNNp00FuBenN_iZtIvIBP}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4949],{308:(e,t,n)=>{n.d(t,{Md:()=>c});var r=n(12115),a=n(60199),s=n(52703),l=n(67149);l.tC.pollMs,l.tC.wsFallbackMs;let i="claude";function o(e,t,n){let r=e.findIndex(e=>e.id===t.id),a=[...e];r>=0?a[r]=t:a.push(t);var s=[...a].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime());if(void 0===n||n<1)return s;let l=s.filter(e=>"user"===e.role).map(e=>e.timestamp.getTime()).sort((e,t)=>t-e);if(l.length<=n)return s;let i=l[n-1];return s.filter(e=>e.timestamp.getTime()>=i)}function c(e){let{worktreeId:t,cliToolId:n,instanceId:c,limit:u,includeArchived:d=!1,enabled:m=!0,cadence:f=l.tC}=e,[h,p]=(0,r.useState)([]),[g,x]=(0,r.useState)(!0),{connected:b,subscribe:v,unsubscribe:y,addListener:w}=(0,a.xM)(),k=null!=c?c:n,j=(0,r.useRef)(0),N=(0,r.useRef)(n);N.current=n;let C=(0,r.useRef)(k);C.current=k;let S=(0,r.useRef)(u);S.current=u;let T=(0,r.useRef)(d);T.current=d;let I=(0,r.useRef)(new Map),M=(0,r.useCallback)(async()=>{let e=++j.current,r=new Map;I.current=r;try{let a=new URLSearchParams({cliTool:n,instance:k,unit:"pairs"});void 0!==u&&a.set("limit",String(u)),d&&a.set("includeArchived","true");let s=await fetch("/api/worktrees/".concat(t,"/messages?").concat(a.toString()));if(!s.ok)return;let l=await s.json();if(j.current!==e||N.current!==n||C.current!==k)return;let i=l.map(e=>({...e,timestamp:new Date(e.timestamp)}));for(let e of r.values())i=o(i,e,u);I.current===r&&(I.current=new Map),p(i),x(!1)}catch(t){if(j.current!==e||N.current!==n||C.current!==k)return;console.error("[useSplitMessages] fetch error:",t),x(!1)}},[t,n,k,u,d]),E="".concat(t,"::").concat(n,"::").concat(k),A=(0,r.useRef)(E);return(0,r.useEffect)(()=>{A.current!==E&&(A.current=E,j.current+=1,I.current=new Map,p([]),x(!0))},[E]),(0,r.useEffect)(()=>{if(!m)return;let e=!1,t=setInterval(()=>{"hidden"!==document.visibilityState&&M()},(0,l.z1)(f,{connected:b}));"undefined"!=typeof document&&"hidden"!==document.visibilityState&&M();let n=()=>{"visible"!==document.visibilityState||e||M()};return document.addEventListener("visibilitychange",n),()=>{e=!0,clearInterval(t),document.removeEventListener("visibilitychange",n)}},[m,f,b,M]),(0,r.useEffect)(()=>{if(m)return v(t),()=>y(t)},[m,t,v,y]),(0,r.useEffect)(()=>{if(m)return w(e=>{var n,r,a,l;if("message"===e.type||"message_updated"===e.type){if(e.worktreeId!==t)return;let a=e.message;if(!a||"string"!=typeof a.id)return;let s=null!=(n=a.cliToolId)?n:i,l=null!=(r=a.instanceId)?r:s;if(s!==N.current||l!==C.current||!a.content||""===a.content.trim()||a.archived&&!T.current)return;let c={...a,timestamp:new Date(a.timestamp),cliToolId:s,instanceId:l};I.current.set(c.id,c),p(e=>o(e,c,S.current));return}if(e.type===s.dz){if(e.worktreeId!==t)return;let n=null!=(a=e.cliToolId)?a:i,r=null!=(l=e.instanceId)?l:n;if(n!==N.current||r!==C.current)return;M();return}if("session_status_changed"===e.type)e.worktreeId===t&&!1===e.isRunning&&(null==e.instance||e.instance===C.current)&&(null==e.cliTool||e.cliTool===N.current)&&M()})},[m,t,w,M]),{messages:h,isLoading:g,refresh:(0,r.useCallback)(()=>M(),[M])}}},813:(e,t,n)=>{n.d(t,{D:()=>r});function r(e,t,n){let r=new TextEncoder;if(r.encode(e).length<=t)return e;let a=t-r.encode(n).length,s=0,l="";for(let t of e){let e=r.encode(t).length;if(s+e>a)break;s+=e,l+=t}return"".concat(l).concat(n)}},2954:(e,t,n)=>{n.d(t,{T:()=>m});var r=n(95155),a=n(12115),s=n(18955),l=n(91758),i=n(94465),o=n(76351);function c(e){let{isOpen:t,onConfirm:n,onCancel:l,cliToolName:c}=e,u=(0,s.c)("autoYes"),d=(0,s.c)("common"),[m,f]=(0,a.useState)(o.t6),[h,p]=(0,a.useState)(""),[g,x]=(0,a.useState)(null),[b,v]=(0,a.useState)(!1),y=(0,a.useRef)(null),w=e=>u(o.Ni[e].replace("autoYes.",""));return(0,a.useEffect)(()=>{t&&(p(""),x(null),v(!1))},[t]),(0,a.useEffect)(()=>{if(!b)return;let e=e=>{y.current&&!y.current.contains(e.target)&&v(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[b]),(0,a.useEffect)(()=>{if(!h.trim())return void x(null);let e=(0,o.P0)(h.trim());if(e.valid)x(null);else{var t;x(null!=(t=e.error)?t:u("invalidRegexPattern"))}},[h,u]),(0,r.jsx)(i.a,{isOpen:t,onClose:l,title:c?u("enableTitleWithTool",{toolName:c}):u("enableTitle"),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"text-sm text-foreground",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:u("featureDescription")}),(0,r.jsxs)("ul",{className:"list-disc list-inside space-y-1",children:[(0,r.jsx)("li",{children:u("yesNoAutoResponse")}),(0,r.jsx)("li",{children:u("multipleChoiceAutoSelect")})]}),(0,r.jsx)("p",{className:"mt-1",children:u("autoDisableAfter",{duration:w(m)})}),c&&(0,r.jsx)("p",{className:"mt-2 text-muted-foreground",children:u("appliesOnlyToCurrent",{toolName:c})})]}),(0,r.jsxs)("div",{className:"text-sm text-foreground",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:u("duration")}),(0,r.jsx)("div",{className:"flex gap-2",children:o.z9.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>f(e),className:"flex-1 py-2 px-3 text-sm font-medium rounded-md border-2 transition-colors ".concat(m===e?"border-accent-600 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-400":"border-border bg-surface dark:bg-surface-2 text-foreground hover:border-muted-foreground"),style:{minHeight:"44px"},children:w(e)},e))})]}),(0,r.jsxs)("div",{className:"text-sm text-foreground",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:u("stopPatternLabel")}),(0,r.jsxs)("div",{className:"relative",ref:y,children:[(0,r.jsx)("button",{type:"button",onClick:()=>v(!b),className:"inline-flex items-center justify-center w-4 h-4 rounded-full bg-muted text-muted-foreground text-[10px] font-bold hover:bg-muted/80 focus:outline-none","aria-label":u("regexTipsLabel"),"data-testid":"regex-tips-button",children:"?"}),b&&(0,r.jsxs)("div",{className:"absolute left-0 top-6 z-50 w-72 rounded-md border border-border bg-surface p-3 shadow-lg text-xs text-foreground","data-testid":"regex-tips-tooltip",children:[(0,r.jsx)("p",{className:"font-medium mb-1.5",children:u("regexTipsTitle")}),(0,r.jsxs)("ul",{className:"space-y-1",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-muted px-1 rounded",children:"\\bcat\\b"})," ",u("regexTipWordBoundary")]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-muted px-1 rounded",children:"error|fatal"})," ",u("regexTipOr")]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-muted px-1 rounded",children:"(?i)error"})," ",u("regexTipCaseNote")]})]})]})]})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-2",children:u("stopPatternDescription")}),(0,r.jsx)("input",{id:"stop-pattern-input",type:"text",value:h,onChange:e=>p(e.target.value),placeholder:u("stopPatternPlaceholder"),className:"w-full px-3 py-2 border rounded-md text-sm font-mono bg-surface dark:bg-surface-2 text-foreground ".concat(g?"border-danger focus:ring-danger focus:border-danger":"border-input focus:ring-ring focus:border-accent-500"," focus:outline-none focus:ring-1"),"data-testid":"stop-pattern-input"}),g&&(0,r.jsx)("p",{className:"mt-1 text-xs text-danger","data-testid":"stop-pattern-error",children:g})]}),(0,r.jsxs)("div",{className:"text-sm text-foreground",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:u("aboutRisks")}),(0,r.jsx)("p",{children:u("riskWarning")})]}),(0,r.jsx)("div",{className:"bg-warning-subtle border-l-4 border-warning p-3",children:(0,r.jsxs)("p",{className:"text-sm text-warning-foreground",children:[(0,r.jsx)("span",{className:"font-medium",children:u("disclaimer")}),u("disclaimerText")]})}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:l,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:d("cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>{n(m,h.trim()||void 0)},disabled:!!g,className:"px-4 py-2 text-sm font-medium rounded-md text-white ".concat(g?"bg-muted-foreground cursor-not-allowed":"bg-warning hover:bg-warning/90"),"data-testid":"confirm-button",children:u("agreeAndEnable")})]})]})})}var u=n(9900),d=n(54014);let m=(0,a.memo)(function(e){let{enabled:t,expiresAt:n,onToggle:i,lastAutoResponse:m,cliToolName:f,inline:h=!1,showToolName:p=!0,onExpire:g}=e,x=(0,s.c)("autoYes"),[b,v]=(0,a.useState)(""),[y,w]=(0,a.useState)(null),[k,j]=(0,a.useState)(!1),[N,C]=(0,a.useState)(!1),[S,T]=(0,a.useState)(!1);(0,a.useEffect)(()=>{if(!t||!n){v(""),T(!1);return}T(!1);let e=!1,r=()=>(v((0,o.$B)(n)),n-Date.now()<=0&&!e&&(e=!0,T(!0),null==g||g(),!0));if(r())return;let a=setInterval(()=>{r()&&clearInterval(a)},o.$s);return()=>clearInterval(a)},[t,n,g]),(0,a.useEffect)(()=>{if(!m)return;w('Auto responded: "'.concat(m,'"'));let e=setTimeout(()=>w(null),u.I2);return()=>clearTimeout(e)},[m]);let I=t&&!S,M=(0,a.useCallback)(()=>{I?(j(!0),i({enabled:!1}).finally(()=>j(!1))):C(!0)},[I,i]),E=(0,a.useCallback)((e,t)=>{C(!1),j(!0),i({enabled:!0,duration:e,stopPattern:t}).finally(()=>j(!1))},[i]),A=(0,a.useCallback)(()=>{C(!1)},[]);return(0,r.jsxs)("div",{className:h?"flex items-center gap-2":"flex items-center gap-3 px-4 py-2 bg-surface-2 border-b border-border",children:[(0,r.jsx)(l.d,{checked:I,onCheckedChange:M,disabled:k,"aria-label":x("toggleLabel")}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:x("label")}),p&&f&&(0,r.jsxs)("span",{className:"text-xs text-accent-600 dark:text-accent-400 font-medium","aria-label":x("targetLabel"),children:["(",(0,d.f_)(f,""),")"]}),I&&b&&(0,r.jsx)("span",{className:"text-sm text-muted-foreground","aria-label":x("timeRemaining"),children:b}),y&&(0,r.jsx)("span",{className:"text-sm text-success animate-pulse",children:y}),(0,r.jsx)(c,{isOpen:N,onConfirm:E,onCancel:A,cliToolName:(0,d.f_)(f,"")})]})})},4300:(e,t,n)=>{n.d(t,{QN:()=>u,Qu:()=>c,bx:()=>i});let r="claude-turn:",a="antigravity-turn:",s="command-code-turn:",l=["oc-turn:",r,"codex-turn:",a,s];function i(e){return"string"==typeof e&&l.some(t=>e.startsWith(t))}let o=[[r,"claude-prompt:"],[a,"antigravity-prompt:"],[s,"command-code-prompt:"]];function c(e){if("string"!=typeof e)return null;for(let t of l)if(e.startsWith(t))return 0===e.slice(t.length).trim().length?null:e;return null}function u(e){for(let[t,n]of o){if(!e.startsWith(t))continue;let r=e.slice(t.length);return 0===r.trim().length?null:"".concat(n).concat(r)}return null}},9708:(e,t,n)=>{n.d(t,{O:()=>i,k:()=>l});var r=n(12115);let a=Object.freeze({}),s=(0,r.createContext)(a),l=s.Provider;function i(){return(0,r.useContext)(s)}},14006:(e,t,n)=>{n.d(t,{D:()=>b});var r=n(95155),a=n(12115),s=n(18955),l=n(20562),i=n(8803),o=n(78596),c=n(68872);let u=/\x1b(?:\[[0-9;?]*)?$/;var d=n(51515);function m(e){return""===(0,d.aJ)(e).trim()}var f=n(18341),h=n(78660);function p(e){let{query:t,onQueryChange:n,matchCount:s,currentIndex:l,onNext:i,onPrev:o,onClose:c,isAtMaxMatches:u=!1}=e,d=(0,a.useRef)(null);(0,a.useEffect)(()=>{var e;null==(e=d.current)||e.focus()},[]);let m=(0,a.useCallback)(e=>{"Escape"===e.key&&c()},[c]),f=(0,a.useCallback)(e=>{n(e.target.value)},[n]),p=0===s?"0/0":u?"".concat(l+1,"/").concat(h.F0,"以上"):"".concat(l+1,"/").concat(s);return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-gray-800 border border-gray-600 rounded shadow-lg",role:"search","aria-label":"ターミナル内テキスト検索",children:[(0,r.jsx)("input",{ref:d,type:"text",value:t,onChange:f,onKeyDown:m,placeholder:"検索...",className:"bg-transparent text-gray-200 text-sm outline-none w-32 sm:w-40 placeholder-gray-500","aria-label":"検索キーワード",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,r.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"text-gray-400 text-xs min-w-[3rem] text-right",children:p}),(0,r.jsx)("button",{onClick:o,disabled:0===s,"aria-label":"前の結果",className:"text-gray-300 hover:text-white disabled:text-gray-600 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▲"}),(0,r.jsx)("button",{onClick:i,disabled:0===s,"aria-label":"次の結果",className:"text-gray-300 hover:text-white disabled:text-gray-600 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▼"}),(0,r.jsx)("button",{onClick:c,"aria-label":"検索を閉じる",className:"text-gray-400 hover:text-white min-w-[36px] min-h-[36px] flex items-center justify-center text-base ml-1",children:"✕"})]})}var g=n(68394);function x(){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 b=(0,a.memo)(function(e){let{output:t,isActive:n,attaching:b=!1,isThinking:v=!1,autoScroll:y=!0,onScrollChange:w,disableAutoFollow:k=!1,compactTuiLayoutPadding:j=!1,preservePaintedPanelRows:N=!1,wrapMode:C="viewport",density:S="regular",className:T=""}=e,I=(0,s.c)("worktree"),{scrollRef:M,autoScroll:E,handleScroll:A,scrollToBottom:L,scrollToTop:R}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{initialAutoScroll:t=!0,onAutoScrollChange:n}=e,r=(0,a.useRef)(null),[s,l]=(0,a.useState)(t),i=(0,a.useRef)(!1),o=(0,a.useRef)(null);(0,a.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]);let c=(0,a.useCallback)(e=>{l(e),null==n||n(e)},[n]),u=(0,a.useCallback)(()=>{let e=r.current;if(!e)return!0;let{scrollTop:t,scrollHeight:n,clientHeight:a}=e;return n-a-t<=50},[]),d=(0,a.useCallback)(()=>{if(i.current)return;let e=u();e&&!s?c(!0):!e&&s&&c(!1)},[s,u,c]),m=(0,a.useCallback)(()=>{let e=r.current;e&&(i.current=!0,e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),s||c(!0),o.current=setTimeout(()=>{i.current=!1,o.current=null},500))},[s,c]),f=(0,a.useCallback)(()=>{let e=r.current;e&&(i.current=!0,e.scrollTo({top:0,behavior:"smooth"}),s&&c(!1),o.current=setTimeout(()=>{i.current=!1,o.current=null},500))},[s,c]);return{scrollRef:r,autoScroll:s,setAutoScroll:c,scrollToBottom:m,scrollToTop:f,handleScroll:d}}({initialAutoScroll:y,onAutoScrollChange:w}),P=null!=t?t:"",D=(0,a.useMemo)(()=>j?N?(0,f.Dk)(P):function(e){if(""===e)return"";let t=e.split("\n"),n=[],r=!1,a=0;for(;a<t.length;){if(!m(t[a])){n.push(t[a]),r=!0,a++;continue}let e=a;for(;e<t.length&&m(t[e]);)e++;let s=e-a,l=!r,i=e>=t.length;if(!l&&!i)if(s<=2)for(let r=a;r<e;r++)n.push(t[r]);else n.push((0,d.x6)(t.slice(a,e).join("")));a=e}return n.join("\n")}(P):P,[j,N,P]),z=(0,a.useMemo)(()=>{if("frame"===C)return{minWidth:"".concat((0,g.pN)(D),"ch")}},[C,D]),{isOpen:O,query:F,matchCount:H,currentIndex:q,isAtMaxMatches:K,openSearch:B,closeSearch:U,setQuery:W,nextMatch:$,prevMatch:Q}=(0,h.Yr)({output:D,containerRef:M}),Y=(0,a.useCallback)(e=>{(e.ctrlKey||e.metaKey)&&"f"===e.key&&(e.preventDefault(),B())},[B]);(0,a.useEffect)(()=>{let e=()=>B();return window.addEventListener("terminal-search-open",e),()=>window.removeEventListener("terminal-search-open",e)},[B]);let[_,J]=(0,a.useState)(()=>D?[{key:0,html:(0,o.l5)(D)}]:[]),G=(0,a.useRef)(D),V=(0,a.useRef)(0);(0,a.useEffect)(()=>{let e=function(e,t){if(e===t)return{mode:"noop",text:t,appended:"",retainedLength:e.length};if(0===e.length||t.length<=e.length||!t.startsWith(e))return{mode:"replace",text:t,appended:"",retainedLength:0};let n=e.match(u),r=n?e.length-n[0].length:e.length;return{mode:"append",text:t,appended:t.slice(r),retainedLength:r}}(G.current,D);if(G.current=D,"noop"===e.mode)return;let t="append"===e.mode&&e.appended.length>c.ZJ;if("append"===e.mode&&!t)return void J(t=>(V.current+=1,t.length>=400)?[{key:V.current,html:(0,o.l5)(D)}]:[...t,{key:V.current,html:(0,o.l5)(e.appended)}]);V.current+=1,J(D?[{key:V.current,html:(0,o.l5)(D)}]:[])},[D]);let[Z,X]=(0,a.useState)(!1);(0,a.useEffect)(()=>{b?X(!1):n&&X(!0)},[b,n]);let ee=!t,et=ee&&b,en=ee&&!b&&!n&&Z,er=(0,a.useRef)(!1);(0,a.useEffect)(()=>{k&&(er.current=!0)},[k]),(0,a.useEffect)(()=>{if(M.current){if(er.current&&k&&D){M.current.scrollTo({top:0,behavior:"instant"}),er.current=!1;return}!k&&E&&M.current.scrollTo({top:M.current.scrollHeight,behavior:"instant"})}},[_,D,E,k,M]);let ea=(0,a.useMemo)(()=>["terminal","font-mono","compact"===S?"text-xs":"text-sm","compact"===S?"p-2":"p-4","rounded-lg","overflow-y-auto","frame"===C?"overflow-x-auto":"overflow-x-hidden","bg-gray-900","text-gray-300","border","border-gray-700","h-full",n?"active":"",T].filter(Boolean).join(" "),[n,T,C,S]),[es,el]=(0,a.useState)(!1),ei=(0,a.useRef)(null),eo=(0,a.useCallback)(()=>{el(!0),ei.current&&clearTimeout(ei.current),ei.current=setTimeout(()=>el(!1),1500)},[]);(0,a.useEffect)(()=>()=>{ei.current&&clearTimeout(ei.current)},[]);let ec=(0,a.useCallback)(()=>{A(),eo()},[A,eo]),eu=["absolute bottom-4 right-4 flex items-center justify-center h-9 w-9 rounded-full bg-surface/80 backdrop-blur border border-border text-muted-foreground shadow-lg transition-opacity hover:text-surface-foreground hover:opacity-100 focus-visible:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",es?"opacity-100":"opacity-60"].join(" ");return(0,r.jsxs)("div",{className:"relative h-full flex flex-col",children:[O&&(0,r.jsx)("div",{className:"absolute top-2 right-2 z-10",children:(0,r.jsx)(p,{query:F,onQueryChange:W,matchCount:H,currentIndex:q,onNext:$,onPrev:Q,onClose:U,isAtMaxMatches:K})}),(0,r.jsxs)("div",{ref:M,role:"log","aria-live":"polite","aria-label":"Terminal output",className:ea,onScroll:ec,onKeyDown:Y,tabIndex:0,children:[(0,r.jsx)("div",{className:"frame"===C?"whitespace-pre w-max":"whitespace-pre-wrap break-words",style:z,children:_.map(e=>(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:e.html}},e.key))}),et&&(0,r.jsx)("div",{"data-testid":"terminal-loading-placeholder",className:"flex h-full items-center justify-center px-4 text-center text-sm text-gray-500 select-none",children:I("terminal.loading")}),en&&(0,r.jsx)("div",{"data-testid":"terminal-ended-placeholder",className:"flex h-full items-center justify-center px-4 text-center text-sm text-gray-500 select-none",children:I("terminal.sessionEnded")}),n&&v&&(0,r.jsx)(x,{})]}),E?(0,r.jsx)("button",{type:"button",onClick:R,className:eu,"aria-label":"Scroll to top",children:(0,r.jsx)(l.A,{size:16,"aria-hidden":"true"})}):(0,r.jsx)("button",{type:"button",onClick:L,className:eu,"aria-label":"Scroll to bottom",children:(0,r.jsx)(i.A,{size:16,"aria-hidden":"true"})})]})})},16342:(e,t,n)=>{n.d(t,{LQ:()=>l,Ml:()=>s,sh:()=>a});let r=RegExp("^\\p{M}$","u");function a(e,t){if(e.length<=t)return e.length;let n=0,a=0;for(let s of e){let e=+!r.test(s);if(1===e&&n>=t)break;n+=e,a+=s.length}return a}function s(e,t,n){return e.slice(a(e,t),a(e,n))}function l(e){let t=0;for(let n of e)r.test(n)||(t+=1);return t}},18341:(e,t,n)=>{n.d(t,{CG:()=>l,Dk:()=>o,Uw:()=>i});var r=n(51515);let a=/\x1b\[([0-9;]*)m/g;function s(e){return""===(0,r.aJ)(e).trim()}function l(e){return s(e)&&""!==(0,r.aJ)(e)&&function(e){let t;for(a.lastIndex=0;null!==(t=a.exec(e));)if(function(e){let t=0;for(;t<e.length;){let n=e[t];if(38===n||48===n||58===n){if(48===n)return!0;let r=e[t+1];t+=5===r?3:2===r?5:2;continue}if(n>=40&&n<=47||n>=100&&n<=107)return!0;t+=1}return!1}(t[1].split(";").filter(e=>""!==e).map(e=>Number(e)).filter(e=>Number.isInteger(e))))return!0;return!1}(e)}function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(""===e)return"";let{isStructuralRow:n}=t,a=e.split("\n"),l=[],i=!1,o=0,c=e=>{var t;return s(e)&&!(null!=(t=null==n?void 0:n(e))&&t)};for(;o<a.length;){if(!c(a[o])){l.push(a[o]),i=!0,o++;continue}let e=o;for(;e<a.length&&c(a[e]);)e++;let t=e-o,n=!i,s=e>=a.length;if(!n&&!s)if(t<=2)for(let t=o;t<e;t++)l.push(a[t]);else l.push((0,r.x6)(a.slice(o,e).join("")));o=e}return l.join("\n")}function o(e){return i(e,{isStructuralRow:l})}},19985:(e,t,n)=>{n.d(t,{F5:()=>i,Fg:()=>r,HB:()=>s,Hv:()=>l});let r=0x1400000,a=[{extension:".png",mimeType:"image/png",magicBytes:[137,80,78,71]},{extension:".jpg",mimeType:"image/jpeg",magicBytes:[255,216,255]},{extension:".jpeg",mimeType:"image/jpeg",magicBytes:[255,216,255]},{extension:".gif",mimeType:"image/gif",magicBytes:[71,73,70,56]},{extension:".webp",mimeType:"image/webp",magicBytes:[82,73,70,70]},{extension:".svg",mimeType:"image/svg+xml"}];function s(e){return e?e.startsWith(".")?e.toLowerCase():"."+e.toLowerCase():""}let l=[".png",".jpg",".jpeg",".gif",".webp",".svg"].filter(e=>".svg"!==e),i=l.map(e=>(function(e){let t=s(e),n=a.find(e=>e.extension===t);return(null==n?void 0:n.mimeType)||"application/octet-stream"})(e)).filter(e=>"application/octet-stream"!==e).join(",")},20877:(e,t,n)=>{n.d(t,{Gg:()=>f,Gw:()=>a,HI:()=>u,aX:()=>d,eu:()=>s,fq:()=>m});let r={highlightName:"terminal-search",currentHighlightName:"terminal-search-current",fallbackOverlayId:"terminal-search-fallback-overlay",fallbackOverlayBgColor:"rgba(255, 165, 0, 0.6)"},a={highlightName:"history-search",currentHighlightName:"history-search-current",fallbackOverlayId:"history-search-fallback-overlay",fallbackOverlayBgColor:"rgba(59, 130, 246, 0.6)"};function s(e){return{highlightName:"history-search-".concat(e),currentHighlightName:"history-search-current-".concat(e),fallbackOverlayId:"history-search-fallback-overlay-".concat(e),fallbackOverlayBgColor:a.fallbackOverlayBgColor}}function l(){return"undefined"!=typeof CSS&&null!==CSS&&"highlights"in CSS}function i(e,t,n){let r=document.createRange(),a=!1;for(let{node:s,start:l,end:i}of e)if(!a&&t<i&&t>=l&&(r.setStart(s,t-l),a=!0),a&&n<=i)return r.setEnd(s,n-l),r;return a?r:null}function o(e){var t;l()&&(CSS.highlights.delete(e.highlightName),CSS.highlights.delete(e.currentHighlightName)),null==(t=document.getElementById(e.fallbackOverlayId))||t.remove()}function c(e,t,n,r){if(0===t.length)return void o(r);let a=function(e){let t,n=[],r=0,a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;t=a.nextNode();){var s,l;let e=null!=(l=null==(s=t.nodeValue)?void 0:s.length)?l:0;n.push({node:t,start:r,end:r+e}),r+=e}return n}(e),s=t[n],c=s?i(a,s.start,s.end):null;if(l()){let e=[];t.forEach((t,r)=>{if(r===n)return;let s=i(a,t.start,t.end);s&&e.push(s)}),CSS.highlights.set(r.highlightName,new Highlight(...e)),CSS.highlights.delete(r.currentHighlightName)}if(function(e,t,n){let r=document.getElementById(n.fallbackOverlayId);if(!t||"function"!=typeof t.getBoundingClientRect){null==r||r.remove();return}let a=t.getBoundingClientRect(),s=e.getBoundingClientRect();r?r.style.backgroundColor=n.fallbackOverlayBgColor:((r=document.createElement("div")).id=n.fallbackOverlayId,r.style.position="absolute",r.style.backgroundColor=n.fallbackOverlayBgColor,r.style.borderRadius="2px",r.style.pointerEvents="none",r.style.zIndex="5",e instanceof HTMLElement&&(e.style.position="relative"),e.appendChild(r)),r.style.top="".concat(a.top-s.top+e.scrollTop,"px"),r.style.left="".concat(a.left-s.left+e.scrollLeft,"px"),r.style.width="".concat(a.width,"px"),r.style.height="".concat(a.height,"px")}(e,c,r),c){let e=c.startContainer,t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"})}}function u(){o(r)}function d(e,t,n){c(e,t,n,r)}function m(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a;o(e)}function f(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:a;c(e,t,n,r)}},23570:(e,t,n)=>{n.d(t,{cV:()=>c,g6:()=>o});var r=n(95155),a=n(12115),s=n(87364),l=n(81507),i=n(72115);let o="worktree-history-pane",c=(0,a.memo)(function(e){let{history:t,terminal:n}=e,{visible:c,width:u,setWidth:d}=(0,l.TG)(),m=(0,a.useRef)(null),f=(0,a.useCallback)(e=>{let t=m.current;if(!t)return;let n=t.offsetWidth;0!==n&&d(u+e/n*100)},[u,d]);return(0,r.jsxs)("div",{ref:m,className:"flex h-full min-h-0 w-full",children:[null!=t&&(c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:o,"data-testid":"terminal-container-history-slot","aria-label":"History pane",style:{width:"".concat(u,"%")},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,r.jsx)(s.t,{componentName:"HistoryPane",children:t})}),(0,r.jsx)(i.f,{onResize:f,orientation:"horizontal",ariaValueNow:u})]}):null),(0,r.jsx)("div",{"data-testid":"terminal-container-terminal-slot","aria-label":"Terminal pane",className:"flex-grow overflow-hidden min-w-0",children:(0,r.jsx)(s.t,{componentName:"TerminalAndFilePanel",children:n})})]})})},35252:(e,t,n)=>{n.d(t,{w:()=>l});var r=n(12115),a=n(78660);function s(e){if(0===e.length)return"0";let t=e[e.length-1],n=t.timestamp instanceof Date?t.timestamp.getTime():String(t.timestamp);return"".concat(e.length,"|").concat(t.id,"|").concat(n)}function l(e){let{messages:t}=e,[n,l]=(0,r.useState)(!1),[i,o]=(0,r.useState)(""),[c,u]=(0,r.useState)([]),[d,m]=(0,r.useState)(0),[f,h]=(0,r.useState)(!1),p=(0,r.useRef)(null),g=(0,r.useRef)(""),x=(0,r.useRef)(!1),b=(0,r.useRef)(s(t)),v=(0,r.useRef)(t);v.current=t;let y=c.reduce((e,t)=>e+t.ranges.length,0),w=(0,r.useMemo)(()=>(function(e,t){if(0===e.length||t<0)return null;let n=0;for(let r of e){if(t<n+r.ranges.length)return{messageId:r.messageId,localIndex:t-n};n+=r.ranges.length}return null})(c,d),[c,d]),k=(0,r.useCallback)(()=>{p.current&&(clearTimeout(p.current),p.current=null)},[]),j=(0,r.useCallback)(e=>{let{positions:t,capped:n}=function(e,t){if(t.length<a.E2||0===e.length)return{positions:[],capped:!1};let n=t.toLowerCase(),r=t.length,s=[],l=0,i=!1;for(let t of e){if(i)break;let o=t.content;if(!o)continue;let c=o.toLowerCase(),u=[],d=0;for(;;){let s=c.indexOf(n,d);if(-1===s)break;if(u.push({start:s,end:s+r}),d=s+1,(l+=1)>=a.F0){if(-1!==c.indexOf(n,d))i=!0;else{let r=e.indexOf(t)+1;for(let t=r;t<e.length;t++){let r=e[t].content;if(r&&-1!==r.toLowerCase().indexOf(n)){i=!0;break}}}break}}u.length>0&&s.push({messageId:t.id,ranges:u})}return{positions:s,capped:i}}(v.current,e);u(t),m(0),h(n)},[]),N=(0,r.useCallback)(e=>{k(),g.current=e,x.current||(p.current=setTimeout(()=>{j(e)},a.e1))},[k,j]),C=(0,r.useCallback)(e=>{o(e),N(e)},[N]),S=(0,r.useCallback)(()=>{l(!0)},[]),T=(0,r.useCallback)(()=>{l(!1),o(""),g.current="",u([]),m(0),h(!1),k()},[k]),I=(0,r.useCallback)(()=>{m(e=>0===y?0:(e+1)%y)},[y]),M=(0,r.useCallback)(()=>{m(e=>0===y?0:(e-1+y)%y)},[y]),E=(0,r.useCallback)(()=>{x.current=!0,k()},[k]),A=(0,r.useCallback)(()=>{x.current=!1;let e=g.current;e.length>=a.E2&&(k(),p.current=setTimeout(()=>{j(e)},a.e1))},[k,j]);return(0,r.useEffect)(()=>{let e=s(t);if(e===b.current)return;b.current=e;let n=g.current;n.length>=a.E2&&j(n)},[t,j]),(0,r.useEffect)(()=>()=>{k(),g.current=""},[k]),{isOpen:n,query:i,matchCount:y,currentIndex:d,isAtMaxMatches:f,matchPositions:c,currentMatch:w,openSearch:S,closeSearch:T,setQuery:C,onCompositionStart:E,onCompositionEnd:A,nextMatch:I,prevMatch:M}}},40240:(e,t,n)=>{n.d(t,{tY:()=>y,XU:()=>b});var r=n(95155),a=n(12115),s=n(18955),l=n(24033),i=n(51021),o=n(56827),c=n(49509),u=n(2317);let d={mobile:{storageKey:"commandmate:mobile:opencodeQuickKeysOpen",defaultOpen:!1},desktop:{storageKey:"commandmate:desktop:opencodeQuickKeysOpen",defaultOpen:!0}},m=e=>"boolean"==typeof e;function f(e){return[i.Mx,e]}let h=[{id:"agentNext",keys:["Tab"],notation:"tab"},{id:"agentPrev",keys:["BTab"],notation:"shift+tab"},{id:"commands",keys:["C-p"],notation:"ctrl+p"},{id:"variant",keys:["C-t"],notation:"ctrl+t"}],p=[{id:"agents",keys:f("a"),notation:"ctrl+x a"},{id:"sessions",keys:f("l"),notation:"ctrl+x l"},{id:"newSession",keys:f("n"),notation:"ctrl+x n"},{id:"models",keys:f("m"),notation:"ctrl+x m"},{id:"themes",keys:f("t"),notation:"ctrl+x t"}],g=[h,p,[{id:"timeline",keys:f("g"),notation:"ctrl+x g",sessionScoped:!0},{id:"undo",keys:f("u"),notation:"ctrl+x u",sessionScoped:!0},{id:"redo",keys:f("r"),notation:"ctrl+x r",sessionScoped:!0},{id:"compact",keys:f("c"),notation:"ctrl+x c",sessionScoped:!0}],[{id:"pageUp",keys:["PageUp"],notation:"pgup"},{id:"pageDown",keys:["PageDown"],notation:"pgdn"},{id:"first",keys:["Home"],notation:"home"},{id:"last",keys:["End"],notation:"end"}]],x=g.reduce((e,t)=>e+t.length,0),b=(0,a.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:i,hasAgentSession:f,onKeysSent:h,compact:p=!1,collapsible:b=!1,layout:v="mobile"}=e,y=(0,s.c)("worktree"),{activeKey:w,markPressed:k}=(0,c.t)(),j=(0,o.B)(t,n,i,h),{open:N,toggle:C}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"mobile",{storageKey:t,defaultOpen:n}=d[e],{value:r,setValue:s,isAvailable:l}=(0,u.V)({key:t,defaultValue:n,validate:m});return{open:r,toggle:(0,a.useCallback)(()=>s(e=>!e),[s]),isPersistent:l}}(v),S=(0,a.useId)(),T=(0,a.useCallback)(e=>{k(e.id),j([...e.keys])},[k,j]);if("opencode"!==n)return null;let I=(0,r.jsxs)("div",{className:"@container flex flex-wrap items-center gap-1.5 ".concat(b?"px-1.5 pb-1.5":"py-1.5 bg-muted rounded-lg"),id:b?S:void 0,role:"toolbar","aria-label":y("opencodeQuickKeys.toolbarLabel"),"data-testid":"opencode-quick-keys",children:[b?null:(0,r.jsx)("span",{className:"text-xs text-muted-foreground mx-2",children:y("opencodeQuickKeys.caption")}),g.map((e,t)=>(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[t>0?(0,r.jsx)("span",{className:"w-px h-6 bg-border mx-0.5","aria-hidden":"true"}):null,e.map(e=>{let t=y("opencodeQuickKeys.keys.".concat(e.id)),n=!0===e.sessionScoped&&!f;return(0,r.jsxs)("button",{type:"button",disabled:n,className:"min-h-[44px] px-3 py-2 text-sm font-medium rounded-md\n border border-border\n focus:outline-none focus:ring-2 focus:ring-ring\n transition-colors duration-75\n disabled:opacity-50 disabled:cursor-not-allowed\n ".concat(w===e.id?"bg-accent-500 text-white border-accent-500 scale-95":"bg-surface dark:bg-surface-2 hover:bg-muted active:bg-muted disabled:hover:bg-surface"),"aria-label":"".concat(t," (").concat(e.notation,")"),title:n?y("opencodeQuickKeys.needsSession",{notation:e.notation}):"".concat(t," — ").concat(e.notation),"data-testid":"opencode-quick-key-".concat(e.id),onClick:()=>T(e),children:[t,p?null:(0,r.jsx)("span",{className:"ml-1.5 text-xs text-muted-foreground hidden @min-[640px]:inline",children:e.notation})]},e.id)})]},e[0].id))]});return b?(0,r.jsxs)("div",{className:"bg-muted rounded-lg","data-testid":"opencode-quick-keys-disclosure",children:[(0,r.jsxs)("button",{type:"button",className:"w-full min-h-[44px] flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg touch-manipulation transition-colors hover:bg-surface-2 active:bg-surface-2 focus:outline-none focus:ring-2 focus:ring-ring","aria-expanded":N,"aria-controls":S,"aria-label":N?y("opencodeQuickKeys.hideKeys"):y("opencodeQuickKeys.showKeys"),"data-testid":"opencode-quick-keys-toggle",onClick:C,children:[(0,r.jsx)(l.A,{className:"w-4 h-4 shrink-0 transition-transform duration-150 ".concat(N?"":"-rotate-90"),"aria-hidden":"true"}),(0,r.jsx)("span",{children:y("opencodeQuickKeys.toolbarLabel")}),(0,r.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:x})]}),N?I:null]}):I}),v=["variant","models","commands"].map(e=>{let t=[...h,...p].find(t=>t.id===e);if(!t)throw Error("OpencodeQuickKeys: unknown model key id ".concat(e));return t}),y=(0,a.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:l,onKeysSent:i}=e,u=(0,s.c)("worktree"),{activeKey:d,markPressed:m}=(0,c.t)(),f=(0,o.B)(t,n,l,i),h=(0,a.useCallback)(e=>{m(e.id),f([...e.keys])},[m,f]);return"opencode"!==n?null:(0,r.jsxs)("div",{"data-testid":"opencode-model-keys",role:"toolbar","aria-label":u("selectionKeys.opencodeToolbarLabel"),className:"flex flex-wrap items-center gap-1.5 rounded-lg bg-muted px-2 py-1.5",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:u("selectionKeys.opencodeCaption")}),v.map(e=>{let t=u("opencodeQuickKeys.keys.".concat(e.id));return(0,r.jsxs)("button",{type:"button","data-testid":"opencode-model-key-".concat(e.id),"aria-label":"".concat(t," (").concat(e.notation,")"),title:"".concat(t," — ").concat(e.notation),onClick:()=>h(e),className:"min-h-[44px] rounded-md border border-border px-3 py-2 text-sm font-medium transition-colors duration-75 touch-manipulation focus:outline-none focus:ring-2 focus:ring-ring ".concat(d===e.id?"border-accent-500 bg-accent-500 text-white scale-95":"bg-surface hover:bg-muted active:bg-muted dark:bg-surface-2"),children:[t,(0,r.jsx)("span",{className:"ml-1.5 text-xs text-muted-foreground",children:e.notation})]},e.id)})]})})},41108:(e,t,n)=>{n.d(t,{UI:()=>c});var r=n(12115);function a(){return{pending:0,delivered:0,prompt:0,expired:0,cancelled:0}}let s=[],l=new Map;function i(){return{open:s,counts:a()}}async function o(e,t){try{var n;let r=await fetch("/api/relays?worktree=".concat(encodeURIComponent(e)));if(!r.ok)return;let i=await r.json();if(l.get(e)!==t)return;for(let e of(t.snapshot={open:Array.isArray(i.open)?i.open:s,counts:null!=(n=i.counts)?n:a()},t.listeners))e()}catch(e){}}function c(e){let[t]=(0,r.useState)(i),n=(0,r.useCallback)(t=>{let n;if(!e)return()=>{};let r=((n=l.get(e))||(n={snapshot:i(),listeners:new Set,timer:null,refs:0},l.set(e,n)),n.refs+=1,null===n.timer&&(o(e,n),n.timer=setInterval(()=>void o(e,n),2e4)),n);return r.listeners.add(t),()=>{r.listeners.delete(t),function(e){let t=l.get(e);t&&(t.refs-=1,t.refs>0||(t.timer&&clearInterval(t.timer),l.delete(e)))}(e)}},[e]),a=(0,r.useCallback)(()=>{var n,r;return e&&null!=(r=null==(n=l.get(e))?void 0:n.snapshot)?r:t},[e,t]),{open:s,counts:c}=(0,r.useSyncExternalStore)(n,a,a),u=(0,r.useCallback)(()=>{let t=e?l.get(e):void 0;e&&t&&o(e,t)},[e]);return(0,r.useMemo)(()=>({open:s,counts:c,owedBy:t=>s.filter(n=>n.to.worktreeId===e&&n.to.instanceId===t),awaitedBy:t=>s.filter(n=>n.from.worktreeId===e&&n.from.instanceId===t),refresh:u}),[s,c,e,u])}},47160:(e,t,n)=>{n.d(t,{CL:()=>R,Et:()=>H,UI:()=>O,a3:()=>P,vY:()=>B,ZS:()=>G,Gn:()=>Z,qI:()=>en,PZ:()=>K,ZK:()=>et});var r=n(95155),a=n(12115),s=n(18955),l=n(24033),i=n(27937),o=n(1473),c=n(53842),u=n(22479),d=n(76907),m=n(49502),f=n(35299),h=n(6132),p=n(48314),g=n(65229),x=n(75426),b=n(54916),v=n(51238),y=n(10934),w=n(5225),k=n(4300),j=n(83012),N=n(51515),C=n(89568),S=n(99112),T=n(70738);let I="Tool calls",M=new RegExp("^>[ \\t]*\\*\\*".concat(I,"(?:[ \\t]*\\((\\d+)\\))?\\*\\*[ \\t]*$")),E=/^- `[^`\n]+`(?: — .*)?$/;function A(e){return{prose:e,toolLog:"",toolCalls:0}}var L=n(92147);let R="mr-auto w-full max-w-full px-1 text-sm text-foreground",P="chat-bubble",D="chat-turn-header",z="chat-turn-time",O="flex w-full flex-col gap-1 pb-3",F="max-w-full overflow-x-hidden break-words [word-break:break-word]",H="".concat(F," chat-md"),q=a.createContext({showAll:!1}),K=q.Provider,B={showAll:!0},U="mr-auto flex w-fit max-w-full items-center gap-1.5 rounded-full border border-border bg-surface-2 px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring";function W(){let{showAll:e}=a.useContext(q),[t,n]=(0,a.useState)(null),r=null!==t&&t.against===e?t.isOpen:e,s=(0,a.useCallback)(()=>n({against:e,isOpen:!r}),[e,r]);return{isOpen:r,toggle:s}}let $=/^>[ \t]*\*\*Thinking(?:[ \t]*\((\d+)\))?\*\*[ \t]*$/,Q=(0,a.memo)(function(e){let{blocks:t,children:n}=e,a=(0,s.c)("worktree"),{isOpen:c,toggle:u}=W(),d=c?l.A:i.A;return(0,r.jsxs)("div",{"data-testid":"chat-thinking-group","data-thinking-blocks":t,className:"mt-2 flex w-full flex-col gap-1",children:[(0,r.jsxs)("button",{type:"button","data-testid":"chat-thinking-toggle",onClick:u,"aria-expanded":c,"aria-label":a(c?"chatTranscript.thinking.collapse":"chatTranscript.thinking.expand"),className:U,children:[(0,r.jsx)(o.A,{size:12,"aria-hidden":"true"}),(0,r.jsx)("span",{children:a("chatTranscript.thinking.summary",{count:t})}),(0,r.jsx)(d,{size:12,"aria-hidden":"true"})]}),c&&(0,r.jsx)("div",{"data-testid":"chat-thinking-body",className:"max-w-full border-l-2 border-border pl-2 text-muted-foreground",children:n})]})}),Y=(0,a.memo)(function(e){let{toolCalls:t,children:n}=e,a=(0,s.c)("worktree"),{isOpen:o,toggle:u}=W(),d=o?l.A:i.A;return(0,r.jsxs)("div",{"data-testid":"chat-tool-log-group","data-tool-calls":t,className:"mt-2 flex w-full flex-col gap-1",children:[(0,r.jsxs)("button",{type:"button","data-testid":"chat-tool-log-toggle",onClick:u,"aria-expanded":o,"aria-label":a(o?"chatTranscript.toolLog.collapse":"chatTranscript.toolLog.expand"),className:U,children:[(0,r.jsx)(c.A,{size:12,"aria-hidden":"true"}),(0,r.jsx)("span",{children:a("chatTranscript.toolLog.summary",{count:t})}),(0,r.jsx)(d,{size:12,"aria-hidden":"true"})]}),o&&(0,r.jsx)("div",{"data-testid":"chat-tool-log-body",className:"max-w-full border-l-2 border-border pl-2 text-muted-foreground",children:n})]})}),_={claude:!0,codex:!0,antigravity:!0,"command-code":!0,opencode:!0,copilot:!1,gemini:!1,"vibe-local":!1},J=(0,a.memo)(function(e){let{children:t}=e,n=(0,s.c)("worktree"),{isOpen:a,toggle:o}=W(),c=a?l.A:i.A;return(0,r.jsxs)("div",{"data-testid":"chat-pane-scrape-group",className:"flex w-full flex-col gap-1",children:[(0,r.jsxs)("button",{type:"button","data-testid":"chat-pane-scrape-toggle",onClick:o,"aria-expanded":a,className:U,children:[(0,r.jsx)(u.A,{size:12,"aria-hidden":"true"}),(0,r.jsx)("span",{children:n("agentSource.kindScraper")}),(0,r.jsx)(c,{size:12,"aria-hidden":"true"})]}),a&&(0,r.jsx)("div",{"data-testid":"chat-pane-scrape-body",className:"max-w-full border-l-2 border-border pl-2 text-muted-foreground",children:t})]})}),G=(0,a.memo)(function(e){var t;let{href:n,children:l,onFilePathClick:i,...o}=e,c=(0,s.c)("worktree"),u=n?(0,T.z)(n):null,d=(0,a.useCallback)(e=>{n&&(e.preventDefault(),i(n))},[n,i]);return n&&null!==u&&"anchor"!==u?"external"===u?(0,r.jsx)("a",{...o,href:n,target:"_blank",rel:"noopener noreferrer",children:l}):(0,r.jsx)("a",{...o,href:n,"data-testid":"chat-file-link",onClick:d,className:"cursor-pointer font-mono text-sm text-accent-700 underline-offset-2 hover:underline dark:text-accent-400","aria-label":c("conversation.openFile",{path:null!=(t=(0,T.h)(n))?t:n}),children:l}):(0,r.jsx)("a",{...o,href:n,children:l})}),V=(0,a.memo)(function(e){let{content:t,onFilePathClick:n}=e,l=(0,s.c)("worktree"),i=(0,a.useMemo)(()=>(0,C.ML)(t),[t]),o=(0,a.useCallback)(e=>()=>n(e),[n]);return(0,r.jsx)("span",{children:i.map((e,t)=>"path"===e.type?(0,r.jsx)("button",{type:"button",onClick:o(e.content),className:"cursor-pointer font-mono text-sm text-accent-700 underline-offset-2 hover:underline dark:text-accent-400","aria-label":l("conversation.openFile",{path:e.content}),children:e.content},t):(0,r.jsx)("span",{children:e.content},t))})}),Z=(0,a.memo)(function(e){let{content:t,onFilePathClick:n}=e,s=(0,a.useMemo)(()=>{let e=e=>a.Children.map(e,e=>"string"==typeof e?(0,r.jsx)(V,{content:e,onFilePathClick:n}):e);return{p:t=>{let{children:n}=t;return(0,r.jsx)("p",{children:e(n)})},li:t=>{let{children:n}=t;return(0,r.jsx)("li",{children:e(n)})},td:t=>{let{children:n}=t;return(0,r.jsx)("td",{children:e(n)})},th:t=>{let{children:n}=t;return(0,r.jsx)("th",{children:e(n)})},strong:t=>{let{children:n}=t;return(0,r.jsx)("strong",{children:e(n)})},em:t=>{let{children:n}=t;return(0,r.jsx)("em",{children:e(n)})},a:e=>{let{href:t,children:a,node:s,...l}=e;return(0,r.jsx)(G,{...l,href:t,onFilePathClick:n,children:a})}}},[n]),l=(0,a.useMemo)(()=>[y.A,w.A],[]),i=(0,a.useMemo)(()=>(function(e){if("string"!=typeof e||0===e.length)return A(null!=e?e:"");if(!e.includes(I)&&!e.startsWith("- `"))return A(e);let t=e.split("\n"),n=t.length;for(;n>0&&0===t[n-1].trim().length;)n-=1;for(let e=n-1;e>=0;e-=1){let r=M.exec(t[e]);if(!r){if(!t[e].startsWith(">"))break;continue}if(e>0&&t[e-1].startsWith(">"))break;let a=t.slice(e+1,n).map(e=>e.replace(/^>[ \t]?/,"")).join("\n").replace(/^\n+/,"").replace(/\n+$/,""),s=r[1]?Number.parseInt(r[1],10):0;return{prose:t.slice(0,e).join("\n").replace(/\n+$/,""),toolLog:a,toolCalls:Number.isFinite(s)&&s>0?s:a.split("\n").filter(e=>e.trim().length>0).length}}let r=0;for(;r<t.length&&E.test(t[r]);)r+=1;return 0===r?A(e):{prose:t.slice(r).join("\n").replace(/^\n+/,""),toolLog:t.slice(0,r).join("\n"),toolCalls:r}})(t),[t]),o=(0,a.useMemo)(()=>(function(e){if(!e.includes("Thinking"))return{body:e,reasoning:null,blocks:0};let t=e.split("\n"),n=[],r=[],a=0,s=0;for(;s<t.length;){let e=$.exec(t[s]),l=0===s||!t[s-1].startsWith(">");if(!e||!l){n.push(t[s]),s+=1;continue}let i=s+1;for(;i<t.length&&t[i].startsWith(">");)i+=1;let o=e[1]?Number.parseInt(e[1],10):1;a+=Number.isFinite(o)&&o>0?o:1,r.push(t.slice(s+1,i).map(e=>e.replace(/^>[ \t]?/,"")).join("\n").replace(/^\n+/,"").replace(/\n+$/,"")),s=i}return 0===a?{body:e,reasoning:null,blocks:0}:{body:n.join("\n").replace(/\n{3,}/g,"\n\n").trim(),reasoning:r.join("\n\n").replace(/^\n+/,"").replace(/\n+$/,""),blocks:a}})(i.prose),[i.prose]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v.oz,{remarkPlugins:S.eT,rehypePlugins:l,components:s,children:o.body}),null!==o.reasoning&&(0,r.jsx)(Q,{blocks:o.blocks,children:(0,r.jsx)(v.oz,{remarkPlugins:S.eT,rehypePlugins:l,components:s,children:o.reasoning})}),i.toolCalls>0&&(0,r.jsx)(Y,{toolCalls:i.toolCalls,children:(0,r.jsx)(v.oz,{remarkPlugins:S.eT,rehypePlugins:l,components:s,children:i.toolLog})})]})}),X={human:"chatTranscript.toolApproval.answeredByHuman",auto:"chatTranscript.toolApproval.autoApproved",terminal:"chatTranscript.toolApproval.answeredInTerminal",pending:"chatTranscript.toolApproval.awaitingAnswer",unclassified:"chatTranscript.toolApproval.unclassified",unknown:"chatTranscript.toolApproval.resolved"},ee={...X,auto:"chatTranscript.toolApproval.autoAnswered"},et=(0,a.memo)(function(e){let{entries:t}=e,n=(0,s.c)("worktree"),{isOpen:a,toggle:o}=W();if(0===t.length)return null;let c=a?l.A:i.A,u=(0,L.rS)(t),f=u.questions+u.confirmations>0,h=u.approvals>0,p=[];h&&p.push(n("chatTranscript.toolApproval.summary",{count:u.approvals})),u.questions>0&&p.push(n("chatTranscript.toolApproval.summaryQuestions",{count:u.questions})),u.confirmations>0&&p.push(n(h||u.questions>0?"chatTranscript.toolApproval.summaryConfirmations":"chatTranscript.toolApproval.summaryConfirmationsOnly",{count:u.confirmations}));let g=h?d.A:m.A;return(0,r.jsxs)("div",{"data-testid":"chat-tool-approval-group","data-approval-count":t.length,"data-approvals":u.approvals,"data-questions":u.questions,"data-confirmations":u.confirmations,className:"".concat(O," items-start"),children:[(0,r.jsxs)("button",{type:"button","data-testid":"chat-tool-approval-toggle",onClick:o,"aria-expanded":a,"aria-label":n("chatTranscript.toolApproval.".concat(a?"collapse":"expand").concat(f&&h?"Mixed":f?"Questions":"")),className:U,children:[(0,r.jsx)(g,{size:12,"aria-hidden":"true"}),(0,r.jsx)("span",{children:p.join(n("chatTranscript.toolApproval.summarySeparator"))}),(0,r.jsx)(c,{size:12,"aria-hidden":"true"})]}),a&&(0,r.jsx)("ul",{"data-testid":"chat-tool-approval-list",className:"mr-auto flex w-full max-w-full flex-col gap-1 pl-1",children:t.map(e=>{let t="question"===e.kind,a=t?ee:X,s=t?"confirmation"===e.phase?"chatTranscript.toolApproval.submitConfirmation":"chatTranscript.toolApproval.unlabeledQuestion":"chatTranscript.toolApproval.unlabeled";return(0,r.jsxs)("li",{"data-testid":"chat-tool-approval-entry","data-approval-outcome":e.outcome,"data-approval-kind":e.kind,"data-approval-phase":e.phase,"data-approval-confirmation":e.confirmationOutcome,"data-approval-audit":e.isPermissionAudit?"true":void 0,"data-approval-merged":e.messageIds.length,className:"flex max-w-full flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs text-muted-foreground",children:["confirmation"===e.phase&&e.label&&(0,r.jsx)("span",{"data-testid":"chat-tool-approval-phase",children:n("chatTranscript.toolApproval.submitConfirmation")}),(0,r.jsx)("span",{className:"min-w-0 break-words [word-break:break-word] font-mono text-foreground",children:e.label||n(s)}),(0,r.jsx)("span",{"data-testid":"chat-tool-approval-outcome",children:n(a[e.outcome])}),e.confirmationOutcome&&(0,r.jsx)("span",{"data-testid":"chat-tool-approval-confirmation",children:n("chatTranscript.toolApproval.confirmation",{outcome:n(ee[e.confirmationOutcome])})})]},e.id)})})]})}),en=(0,a.memo)(function(e){var t;let{message:n,showHeader:l,header:i,onFilePathClick:o,onCopy:c,onInsertToMessage:u,onRetryPending:d,onDiscardPending:m}=e,v=(0,s.c)("worktree"),y=(0,s.c)("common"),w="user"===n.role,C=n.optimisticState,S=(0,k.bx)(n.requestId),T="assistant"===n.role&&"normal"===n.messageType&&("string"!=typeof n.requestId||!(n.requestId.length>0))&&!0===_[null!=(t=n.cliToolId)?t:"claude"],I=(0,a.useMemo)(()=>"number"==typeof(null==i?void 0:i.startedAtMs)?new Date(i.startedAtMs):null,[null==i?void 0:i.startedAtMs]),M=(0,j.g8)(n.timestamp,I),E=l?"role":(null==i?void 0:i.variant)==="time"?"time":"none",A=(0,a.useMemo)(()=>{var e;return"string"==typeof(e=n.content)?(0,N.aJ)(e):""},[n.content]),L=S?n.content:A,q=[w?"".concat("w-fit rounded-2xl border px-3 py-2 text-sm text-foreground"," ").concat("ml-auto"," ").concat("max-w-[85%] sm:max-w-[75%]"," rounded-br-md"):R,w&&"error"===C?"border-danger-border bg-danger-subtle":"",w&&"error"!==C?"border-accent-500/30 bg-accent-500/10":"","sending"===C?"opacity-70":""].filter(Boolean).join(" "),K=S?H:"".concat(F," whitespace-pre-wrap");return(0,r.jsxs)("div",{"data-testid":"chat-message-row","data-role":n.role,"data-row-message-id":n.id,className:[O,n.archived?"opacity-60":""].filter(Boolean).join(" "),children:["role"===E&&(0,r.jsxs)("div",{"data-testid":D,"data-header-variant":"role",className:["flex flex-wrap items-center gap-x-2 px-1 text-xs text-muted-foreground",w?"justify-end":""].filter(Boolean).join(" "),children:[(0,r.jsx)("span",{className:w?"font-medium text-accent-700 dark:text-accent-400":"font-medium",children:v(w?"conversation.you":"conversation.assistant")}),M&&(0,r.jsx)("span",{"data-testid":z,children:M})]}),"time"===E&&M&&(0,r.jsxs)("div",{"data-testid":D,"data-header-variant":"time",role:"separator","aria-label":v("chatTranscript.turnBoundary"),className:"flex w-full items-center gap-2 px-1 pt-2 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"h-px min-w-[1rem] flex-1 bg-border","aria-hidden":"true"}),(0,r.jsx)("span",{"data-testid":z,className:"shrink-0 whitespace-nowrap",children:M}),(0,r.jsx)("span",{className:"h-px min-w-[1rem] flex-1 bg-border","aria-hidden":"true"})]}),(0,r.jsx)("div",{"data-testid":P,className:q,children:T?(0,r.jsx)(J,{children:(0,r.jsx)("div",{"data-message-id":n.id,className:K,children:(0,r.jsx)(V,{content:A,onFilePathClick:o})})}):(0,r.jsx)("div",{"data-message-id":n.id,"data-markdown":S?"true":void 0,className:K,children:S?(0,r.jsx)(Z,{content:n.content,onFilePathClick:o}):(0,r.jsx)(V,{content:A,onFilePathClick:o})})}),(0,r.jsxs)("div",{"data-testid":"chat-message-actions",className:["flex items-center gap-1 px-1",w?"justify-end":""].filter(Boolean).join(" "),children:["sending"===C&&(0,r.jsxs)("span",{"data-testid":"chat-optimistic-sending",className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,r.jsx)(f.A,{size:12,className:"animate-spin","aria-hidden":"true"}),(0,r.jsx)("span",{children:v("conversation.sending")})]}),"error"===C&&(0,r.jsxs)("span",{"data-testid":"chat-optimistic-error",className:"flex items-center gap-1 text-xs text-danger-foreground",children:[(0,r.jsx)(h.A,{size:12,"aria-hidden":"true"}),(0,r.jsx)("span",{children:v("conversation.failedToSend")})]}),"error"===C?(0,r.jsxs)(r.Fragment,{children:[d&&(0,r.jsxs)("button",{type:"button","data-testid":"chat-pending-retry",onClick:()=>d(n.id),className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-accent-700 transition-colors hover:bg-muted dark:text-accent-400","aria-label":v("conversation.retrySending"),title:y("retry"),children:[(0,r.jsx)(p.A,{size:12,"aria-hidden":"true"}),y("retry")]}),m&&(0,r.jsxs)("button",{type:"button","data-testid":"chat-pending-discard",onClick:()=>m(n.id),className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-danger-foreground","aria-label":v("conversation.discardMessage"),title:v("conversation.discard"),children:[(0,r.jsx)(g.A,{size:12,"aria-hidden":"true"}),v("conversation.discard")]})]}):(0,r.jsxs)(r.Fragment,{children:[c&&(0,r.jsx)("button",{type:"button","data-testid":"chat-copy-message",onClick:()=>c(L),className:"rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":v("conversation.copyMessage"),title:v("conversation.copy"),children:(0,r.jsx)(x.A,{size:14,"aria-hidden":"true"})}),w&&u&&(0,r.jsx)("button",{type:"button","data-testid":"chat-insert-user-message",onClick:()=>u(L),className:"rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-accent-600 dark:hover:text-accent-400","aria-label":v("conversation.insertToMessage"),title:v("conversation.insertToMessage"),children:(0,r.jsx)(b.A,{size:14,"aria-hidden":"true"})})]})]})]})})},49509:(e,t,n)=>{n.d(t,{t:()=>s});var r=n(12115),a=n(9900);function s(){let[e,t]=(0,r.useState)(null),n=(0,r.useRef)(null);return(0,r.useEffect)(()=>()=>{null!==n.current&&(clearTimeout(n.current),n.current=null)},[]),{activeKey:e,markPressed:(0,r.useCallback)(e=>{t(e),null!==n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{n.current=null,t(null)},a.tX)},[])}}},50857:(e,t,n)=>{function r(e){return"running"===e||"generating"===e||"waiting"===e}function a(e){return e.isActive||r(e.status)}function s(e,t){let n=e.map((e,t)=>({it:e,index:t})).filter(e=>{let{it:t}=e;return a(t)}),r=new Set;return t>0&&n.length>0&&[...n].sort((e,t)=>Number(t.it.isActive)-Number(e.it.isActive)||e.index-t.index).slice(0,t).forEach(e=>{let{index:t}=e;return r.add(t)}),e.map((e,t)=>a(e)?{...e,slot:r.has(t)?"pill":"overflow"}:{...e,slot:"dot"})}n.d(t,{Lm:()=>a,Qo:()=>r,Uw:()=>s})},51021:(e,t,n)=>{n.d(t,{Mx:()=>l,mE:()=>r,qL:()=>s});let r="s",a=["Up","Down","Left","Right","Enter","Escape","Tab","BTab","PageUp","PageDown","Home","End","q","1","2","3","4","5","6","7","8","9","y","n"];[...a];let s=["claude","command-code"],l="C-x",i=["C-p","C-t"],o=["a","l","t","m","g","u","r","c"];[...a,...i,...o],[...a,...i,...o]},51515:(e,t,n)=>{n.d(t,{aJ:()=>l,wJ:()=>i,x6:()=>o});let r="\\x1b\\][^\\x07\\x1b]*(?:\\x07|\\x1b\\\\)",a=RegExp(r,"g"),s=RegExp("\\x1b\\[[0-9;]*[a-zA-Z]|".concat(r,"|\\[[0-9;]*m"),"g");function l(e){return e.replace(s,"")}function i(e){return e.replace(a,"")}function o(e){let t=e.match(s);return t?t.join(""):""}},55813:(e,t,n)=>{n.d(t,{M:()=>l});var r=n(55041),a=n(8574);let s={en:a.c,ja:r.ja};function l(e){var t;return null!=(t=s[e])?t:a.c}},56827:(e,t,n)=>{n.d(t,{B:()=>s});var r=n(12115),a=n(9900);function s(e,t,n,s){return(0,r.useCallback)(r=>{let l=n&&n!==t?{cliToolId:t,keys:r,instanceId:n}:{cliToolId:t,keys:r};fetch("/api/worktrees/".concat(encodeURIComponent(e),"/special-keys"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}).then(()=>{s&&setTimeout(s,a.LK)}).catch(e=>{console.error("Failed to send special keys:",e)})},[e,t,n,s])}},60734:(e,t,n)=>{n.d(t,{y:()=>u});var r=n(95155),a=n(12115),s=n(18955),l=n(56827),i=n(49509);let o=[{key:"Left",label:"◀",ariaLabel:"Left"},{key:"Up",label:"▲",ariaLabel:"Up"},{key:"Down",label:"▼",ariaLabel:"Down"},{key:"Right",label:"▶",ariaLabel:"Right"},{key:"Enter",label:"↵",ariaLabel:"Enter"},{key:"Escape",label:"Esc",ariaLabel:"Escape"}],c=[{key:"PageUp",label:"PgUp",ariaLabel:"Page Up"},{key:"PageDown",label:"PgDn",ariaLabel:"Page Down"},{key:"Home",label:"Home",ariaLabel:"Home"},{key:"End",label:"End",ariaLabel:"End"},{key:"q",label:"q",ariaLabelKey:"navigation.quitPager"}];function u(e){let{worktreeId:t,cliToolId:n,instanceId:u,onKeysSent:d,showPagerKeys:m=!1}=e,f=(0,s.c)("worktree"),{activeKey:h,markPressed:p}=(0,i.t)(),g=(0,l.B)(t,n,u,d),x=(0,a.useCallback)(e=>{p(e[0]),g(e)},[p,g]),b=(0,a.useMemo)(()=>m?[...o,...c]:o,[m]),v=(0,a.useCallback)(e=>{let t={ArrowLeft:"Left",ArrowUp:"Up",ArrowDown:"Down",ArrowRight:"Right",Enter:"Enter",Escape:"Escape"}[e.key];t&&(e.preventDefault(),x([t]))},[x]);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 py-1.5 bg-muted rounded-lg",onKeyDown:v,role:"toolbar","aria-label":f("navigation.toolbarLabel"),children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground mx-2",children:f("navigation.caption")}),b.map(e=>{let{key:t,label:n,ariaLabel:a,ariaLabelKey:s}=e;return(0,r.jsx)("button",{type:"button",className:"min-w-[44px] min-h-[44px] px-3 py-2 text-sm font-medium rounded-md\n border border-border\n focus:outline-none focus:ring-2 focus:ring-ring\n transition-colors duration-75\n ".concat(h===t?"bg-accent-500 text-white border-accent-500 scale-95":"bg-surface dark:bg-surface-2 hover:bg-muted active:bg-muted"),"aria-label":s?f(s):a,onClick:()=>x([t]),children:n},t)})]})}},62560:(e,t,n)=>{n.d(t,{NK:()=>g});var r=n(12115),a=n(60199),s=n(51515);let l=/^[>❯]/,i=/^\u203A/;function o(e){return void 0===e||""===(0,s.aJ)(e).trim()}function c(e){let t=[],n={dim:!1,bold:!1},r=0;for(;r<e.length;){let a=e[r];if("\x1b"!==a){t.push({ch:a,dim:n.dim,bold:n.bold}),r++;continue}let s=e[r+1];if("["===s){let t=r+2;for(;t<e.length&&!/[A-Za-z]/.test(e[t]);)t++;if(t>=e.length)break;"m"===e[t]&&(n=function(e,t){let n=""===e?["0"]:e.split(";"),{dim:r,bold:a}=t;for(let e=0;e<n.length;e++){let t=""===n[e]?0:Number(n[e]);if(!Number.isNaN(t)){if(38===t||48===t||58===t){let t=""===n[e+1]||void 0===n[e+1]?-1:Number(n[e+1]);5===t?e+=2:2===t?e+=4:e+=1;continue}0===t||22===t?(r=!1,a=!1):1===t?a=!0:2===t&&(r=!0)}}return{dim:r,bold:a}}(e.slice(r+2,t),n)),r=t+1;continue}if("]"===s){let t=r+2;for(;t<e.length;){if("\x07"===e[t]){t++;break}if("\x1b"===e[t]&&"\\"===e[t+1]){t+=2;break}t++}r=t;continue}r+=2}return t}let u=new Set(["claude","codex"]);function d(e){let t=e.length;for(;t>0&&""===e[t-1].trim();)t--;return e.slice(0,t)}var m=n(67149);m.$C.activeMs,m.$C.idleMs,m.$C.wsFallbackMs;let f={session:null,context:null,diff:null};function h(e){var t,n,r,a,s,l,i,o,c,u,d,m;let f=e.session,h=e.context,g=e.diff;return JSON.stringify([null!=(t=null==f?void 0:f.title)?t:null,null!=(n=null==f?void 0:f.agent)?n:null,null!=(r=null==f?void 0:f.model)?r:null,null!=(a=null==f?void 0:f.cost)?a:null,null!=(s=null==f?void 0:f.tokens)?s:null,null!=(l=null==h?void 0:h.tokens)?l:null,null!=(i=null==h?void 0:h.limit)?i:null,null!=(o=null==h?void 0:h.percent)?o:null,null!=(c=null==g?void 0:g.turnMessageId)?c:null,null!=(u=null==g?void 0:g.revertedMessageId)?u:null,null!=(d=null==g?void 0:g.files.map(p))?d:null,null!=(m=null==g?void 0:g.revertedFiles.map(p))?m:null])}function p(e){var t,n;return"".concat(null!=(t=e.file)?t:"",":").concat(null!=(n=e.status)?n:"",":").concat(e.additions,":").concat(e.deletions)}function g(e){let{worktreeId:t,cliToolId:n,instanceId:p,enabled:g=!0,cadence:x=m.$C}=e,b=null!=p?p:n,[v,y]=(0,r.useState)(()=>({output:"",realtimeSnippet:"",isRunning:!1,isThinking:!1,sessionStatus:"",isSelectionListActive:!1,isPagerActive:!1,isDismissablePanelActive:!1,isUnclassifiedActive:!1,composerText:"",attaching:!0,autoScroll:!0})),[w,k]=(0,r.useState)(()=>({visible:!1,data:null,messageId:null,answering:!1})),[j,N]=(0,r.useState)(f),C=(0,r.useRef)(0),S=(0,r.useRef)(n);S.current=n;let T=(0,r.useRef)(b);T.current=b;let I=(0,r.useRef)(w.visible);I.current=w.visible;let{connected:M,subscribe:E,unsubscribe:A,addListener:L}=(0,a.xM)(),R=(0,r.useRef)(0),P=(0,r.useRef)(0),D=(0,r.useRef)(null),z=(0,r.useRef)(null),[O,F]=(0,r.useState)(!1),H=(0,r.useCallback)(()=>{F(!0),null!==z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{z.current=null,F(!1)},5e3)},[]),q=(0,r.useCallback)(e=>{var t,n;let r=null!=(n=null!=(t=e.fullOutput)?t:e.realtimeSnippet)?n:"";!0===e.isUnclassifiedActive&&!0!==e.isPromptWaiting&&!0!==e.isSelectionListActive&&!0!==e.isPagerActive&&!0!==e.isDismissablePanelActive?(P.current+=1,null!=D.current||(D.current=Date.now())):(P.current=0,D.current=null);let a=P.current>=2&&null!==D.current&&Date.now()-D.current>=500,m=e.isRunning?function(e,t){if(!u.has(t))return{text:"",state:"unsupported_tool"};let n=e.split("\n"),r=function(e,t){if("claude"===t){let t=function(e){var t;let n=e=>/^─{10,}$/.test((0,s.aJ)(e).trimEnd()),r=e.length-1;for(;r>=0&&""===e[r].trim();)r--;if(r<0)return null;let a=-1;for(let t=r;t>=Math.max(0,r-4);t--)if(n(e[t])){a=t;break}if(a<0)return null;let i=-1;for(let t=a-1;t>=Math.max(0,a-40);t--)if(n(e[t])){i=t;break}return i<0||!l.test((0,s.aJ)(null!=(t=e[i+1])?t:""))?null:{openingSeparator:i,closingSeparator:a}}(e);return null===t?null:{firstRow:t.openingSeparator+1,lastRow:t.closingSeparator-1,glyph:l}}let n=function(e){let t=e.length-1;for(;t>=0&&o(e[t]);)t--;if(t<0)return null;for(let n=0;n<4&&t>=0;n++){let n=t,r=t;for(;r>0&&!o(e[r-1]);)r--;if(function(e){if(void 0===e)return!1;let t=c(e);if(0===t.length||"›"!==t[0].ch||t[0].dim||t.length>1&&" "!==t[1].ch)return!1;let n=t.slice(2).find(e=>" "!==e.ch);return void 0===n||!n.bold}(e[r]))return{firstRow:r,lastRow:Math.min(n,r+40-1)};for(t=r-1;t>=0&&o(e[t]);)t--}return null}(e);return null===n?null:{firstRow:n.firstRow,lastRow:n.lastRow,glyph:i}}(n,t);if(null===r)return{text:"",state:"no_composer"};let a=[],m=[];for(let e=r.firstRow;e<=r.lastRow;e++){var f;let t=function(e,t,n){if(t){let t=e.findIndex(e=>n.test(e.ch));if(t<0)return e;let r=t+1;return r<e.length&&/\s/.test(e[r].ch)&&r++,e.slice(r)}let r=0;for(;r<2&&r<e.length&&" "===e[r].ch;)r++;return e.slice(r)}(c(null!=(f=n[e])?f:""),e===r.firstRow,r.glyph);a.push(t.filter(e=>!e.dim).map(e=>e.ch).join("").trimEnd()),m.push(t.map(e=>e.ch).join("").trimEnd())}let h=d(a).join("\n");return""!==h.trim()?{text:h.slice(0,2e3),state:"content"}:{text:"",state:""===d(m).join("\n").trim()?"empty":"ghost"}}(r,S.current).text:"";y(t=>{var n,s,l,i,o,c,u;let d=!1===e.isRunning,f=!!r||!!e.isRunning||d;return{...t,output:f?r:t.output,realtimeSnippet:null!=(n=e.realtimeSnippet)?n:"",isRunning:null!=(s=e.isRunning)&&s,isThinking:null!=(l=e.thinking)&&l,sessionStatus:null!=(i=e.sessionStatus)?i:t.sessionStatus,isSelectionListActive:null!=(o=e.isSelectionListActive)&&o,isPagerActive:null!=(c=e.isPagerActive)&&c,isDismissablePanelActive:null!=(u=e.isDismissablePanelActive)&&u,isUnclassifiedActive:a,composerText:m,attaching:!1}}),e.isPromptWaiting&&e.promptData?k(t=>{var n,r;return{...t,visible:!0,data:null!=(n=e.promptData)?n:t.data,messageId:null!=(r=t.messageId)?r:"prompt-".concat(Date.now())}}):!e.isPromptWaiting&&I.current&&k({visible:!1,data:null,messageId:null,answering:!1})},[]),K=(0,r.useCallback)(async()=>{let e=++C.current;try{var r,a,s,l,i,o;let c=await fetch("/api/worktrees/".concat(t,"/current-output?cliTool=").concat(n,"&instance=").concat(encodeURIComponent(b)));if(!c.ok)return;let u=await c.json();if(C.current!==e||S.current!==n||T.current!==b||u.cliToolId&&u.cliToolId!==n)return;q(u);let d={session:null!=(l=null==(r=u.structuredEvents)?void 0:r.session)?l:null,context:null!=(i=null==(a=u.structuredEvents)?void 0:a.sessionContext)?i:null,diff:null!=(o=null==(s=u.structuredEvents)?void 0:s.sessionDiff)?o:null};N(e=>h(e)===h(d)?e:d)}catch(t){if(C.current!==e||S.current!==n||T.current!==b)return;console.error("[useTerminalPanePolling] fetch error:",t)}},[t,n,b,q]),B="".concat(t,"::").concat(n,"::").concat(b),U=(0,r.useRef)(B);(0,r.useEffect)(()=>{U.current!==B&&(U.current=B,C.current+=1,R.current=0,P.current=0,D.current=null,F(!1),null!==z.current&&(clearTimeout(z.current),z.current=null),y(e=>({...e,output:"",realtimeSnippet:"",isRunning:!1,isThinking:!1,sessionStatus:"",isSelectionListActive:!1,isPagerActive:!1,isDismissablePanelActive:!1,isUnclassifiedActive:!1,composerText:"",attaching:!0})),k({visible:!1,data:null,messageId:null,answering:!1}),N(f))},[B]),(0,r.useEffect)(()=>{if(g)return E(t),()=>A(t)},[g,t,E,A]),(0,r.useEffect)(()=>{R.current=0,F(!1),null!==z.current&&(clearTimeout(z.current),z.current=null)},[M]),(0,r.useEffect)(()=>()=>{null!==z.current&&clearTimeout(z.current)},[]),(0,r.useEffect)(()=>{if(g)return L(e=>{var n;if("terminal_snapshot"!==e.type||e.worktreeId!==t||e.cliToolId!==S.current||e.instanceId!==T.current||e.version<=R.current)return;R.current=e.version,H();let r=e.output.split("\n").slice(-100).join("\n");q({fullOutput:e.output,realtimeSnippet:r,isRunning:e.isRunning,sessionStatus:e.sessionStatus,thinking:e.thinking,isSelectionListActive:e.isSelectionListActive,isPagerActive:e.isPagerActive,isDismissablePanelActive:e.isDismissablePanelActive,isUnclassifiedActive:e.isUnclassifiedActive,isPromptWaiting:e.isPromptWaiting,promptData:null!=(n=e.promptData)?n:null})})},[g,t,L,q,H]),(0,r.useEffect)(()=>{if(g)return L(e=>{if("session_status_changed"===e.type)e.worktreeId===t&&!1===e.isRunning&&(null==e.instance||e.instance===T.current)&&(null==e.cliTool||e.cliTool===S.current)&&(R.current=0,q({fullOutput:"",realtimeSnippet:"",isRunning:!1,sessionStatus:"idle",thinking:!1,isSelectionListActive:!1,isPagerActive:!1,isDismissablePanelActive:!1,isUnclassifiedActive:!1,isPromptWaiting:!1,promptData:null}))})},[g,t,L,q]),(0,r.useEffect)(()=>{if(!g)return;let e=!1,t=w.visible||v.isSelectionListActive||v.isPagerActive||v.isDismissablePanelActive||v.isUnclassifiedActive,n=setInterval(()=>{"hidden"!==document.visibilityState&&K()},(0,m.lN)(x,{connected:M,pushHealthy:O,interactionActive:t,sessionAlive:v.isRunning,generating:(0,m.f8)(v.sessionStatus)}));"undefined"!=typeof document&&"hidden"!==document.visibilityState&&K();let r=()=>{"visible"!==document.visibilityState||e||K()};return document.addEventListener("visibilitychange",r),()=>{e=!0,null!==n&&(clearInterval(n),n=null),document.removeEventListener("visibilitychange",r)}},[g,x,M,O,v.isRunning,v.sessionStatus,v.isSelectionListActive,v.isPagerActive,v.isDismissablePanelActive,v.isUnclassifiedActive,w.visible,K]);let W=(0,r.useCallback)(e=>{y(t=>t.autoScroll===e?t:{...t,autoScroll:e})},[]),$=(0,r.useCallback)(e=>{k(t=>({...t,answering:e}))},[]);return{terminal:v,prompt:w,agentSession:j,setAutoScroll:W,setPromptAnswering:$,clearPrompt:(0,r.useCallback)(()=>{k({visible:!1,data:null,messageId:null,answering:!1})},[]),refresh:(0,r.useCallback)(()=>K(),[K])}}},64653:(e,t,n)=>{n.d(t,{o4:()=>l});var r=n(76246);let a={method:"HEAD",cache:"no-store"},s=(e,t)=>fetch(e,t);async function l(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:s;try{var l;return(l=await n("/api/worktrees/".concat(encodeURIComponent(e),"/files/").concat((0,r.o)(t)),a)).ok?"present":404===l.status||400===l.status||403===l.status?"missing":"unknown"}catch(e){return"unknown"}}},67149:(e,t,n)=>{n.d(t,{$C:()=>r,WT:()=>l,f8:()=>o,lN:()=>c,sD:()=>a,tC:()=>s,z1:()=>u});let r={activeMs:2e3,idleMs:5e3,wsFallbackMs:15e3,activeRequiresGenerating:!1,idleTrustsConnection:!1},a={activeMs:4e3,idleMs:1e4,wsFallbackMs:15e3,activeRequiresGenerating:!0,idleTrustsConnection:!0},s={pollMs:5e3,wsFallbackMs:15e3},l={pollMs:15e3,wsFallbackMs:3e4},i=new Set(["running","waiting"]);function o(e){return i.has(e)}function c(e,t){if(t.interactionActive)return e.activeMs;let n=e.activeRequiresGenerating?t.generating:t.sessionAlive;return t.connected&&t.pushHealthy||t.connected&&!n&&e.idleTrustsConnection?e.wsFallbackMs:n?e.activeMs:e.idleMs}function u(e,t){return t.connected?e.wsFallbackMs:e.pollMs}},68276:(e,t,n)=>{n.d(t,{LT:()=>r,XF:()=>a});let r="unclassified";function a(e){return null!=e&&e.type!==r}},68394:(e,t,n)=>{n.d(t,{EK:()=>c,Wq:()=>i,pN:()=>u});var r=n(51515);let a=new Set(["claude","codex","opencode"]),s=new Set(["opencode"]),l=new Set(["opencode"]),i={wrapMode:"frame",density:"compact"},o=/\x1b\[[0-9;]*m/g;function c(e){return{compactTuiLayoutPadding:a.has(e),preservePaintedPanelRows:s.has(e),mobileWrapMode:l.has(e)?"frame":"viewport"}}function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:400,n=1;for(let a of e.split("\n")){let e=(0,r.wJ)(a).replace(o,"").trimEnd().length;if(e>n&&(n=e),n>=t)return t}return n}},68872:(e,t,n)=>{n.d(t,{ED:()=>a,ZJ:()=>r,yi:()=>s});let r=1048576,a="[... 古い出力を省略しました / older output truncated ...]",s=65536},70738:(e,t,n)=>{n.d(t,{h:()=>u,z:()=>o});var r=n(69352);let a=/^(https?|mailto|tel|file):/i,s=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,l=/^file:\/\/(localhost)?/i,i=/:\d+(?::\d+)?$/;function o(e){let t=(0,r.d3)(e.trim());return t?t.startsWith("#")?"anchor":l.test(t)?"file":s.test(t)&&!a.test(t)?null:"external"===(0,r.dj)(t)?"external":"file":null}function c(e){let t=[];for(let n of e.split("/"))if(""!==n&&"."!==n){if(".."===n){t.pop();continue}t.push(n)}return t.join("/")}function u(e,t){var n;if("file"!==o(e))return null;let r=(function(e){try{return decodeURIComponent(e)}catch(t){return e}})((function(e){let t=e.indexOf("#");return -1===t?e:e.slice(0,t)})(e.trim().replace(l,"")).replace(i,"")).trim();if(!r)return null;if(!r.startsWith("/"))return c(r)||null;let a=t?(n=t.trim()).length>1&&n.endsWith("/")?n.replace(/\/+$/,""):n:"";return a&&a.startsWith("/")?r===a?null:r.startsWith("".concat(a,"/"))?c(r.slice(a.length+1))||null:r:r}},72115:(e,t,n)=>{n.d(t,{f:()=>u});var r=n(95155),a=n(12115),s=n(18955);let l=["relative","flex-shrink-0","bg-border","transition-colors","duration-150","hover:bg-accent-500","dark:hover:bg-accent-500","focus:outline-none","focus:ring-2","focus:ring-ring","focus:ring-offset-2","focus:ring-offset-background"],i=["w-1","h-full","cursor-col-resize","before:content-['']","before:absolute","before:inset-y-0","before:-inset-x-1"],o=["h-1","w-full","cursor-row-resize","before:content-['']","before:absolute","before:inset-x-0","before:-inset-y-1"];function c(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 u=(0,a.memo)(function(e){let{onResize:t,orientation:n="horizontal",ariaValueNow:u=50,onDoubleClick:d,minRatio:m=.1}=e,f=(0,s.c)("worktree"),[h,p]=(0,a.useState)(!1),g=(0,a.useRef)(0),x=(0,a.useRef)(null),b="horizontal"===n,v=(0,a.useCallback)(e=>{e.preventDefault(),p(!0),g.current=c(e,b)},[b]),y=(0,a.useCallback)(e=>{1===e.touches.length&&(p(!0),g.current=c(e,b))},[b]),w=(0,a.useCallback)(e=>{if(!h)return;let n=c(e,b);t(n-g.current),g.current=n},[h,b,t]),k=(0,a.useCallback)(e=>{if(!h||1!==e.touches.length)return;let n=c(e,b);t(n-g.current),g.current=n},[h,b,t]),j=(0,a.useCallback)(()=>{p(!1)},[]),N=(0,a.useCallback)(()=>{d&&d()},[d]),C=(0,a.useCallback)(e=>{let n=0;b?"ArrowRight"===e.key?n=10:"ArrowLeft"===e.key&&(n=-10):"ArrowDown"===e.key?n=10:"ArrowUp"===e.key&&(n=-10),0!==n&&(e.preventDefault(),t(n))},[b,t]);(0,a.useEffect)(()=>(h&&(document.addEventListener("mousemove",w),document.addEventListener("mouseup",j),document.addEventListener("touchmove",k),document.addEventListener("touchend",j),document.body.style.userSelect="none",document.body.style.cursor=b?"col-resize":"row-resize"),()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",j),document.removeEventListener("touchmove",k),document.removeEventListener("touchend",j),document.body.style.userSelect="",document.body.style.cursor=""}),[h,w,j,k,b]);let S=(0,a.useMemo)(()=>[...l,...b?i:o,...h?["bg-accent-500","dark:bg-accent-500","dragging",b?"w-2":"h-2"]:[]].join(" "),[b,h]);return(0,r.jsx)("div",{ref:x,role:"separator","aria-orientation":n,"aria-valuenow":u,"aria-valuemin":0,"aria-valuemax":100,"aria-label":f("paneResizer.label",{arrows:f(b?"paneResizer.arrowsHorizontal":"paneResizer.arrowsVertical")}),tabIndex:0,className:S,onMouseDown:v,onTouchStart:y,onKeyDown:C,onDoubleClick:N})})},73190:(e,t,n)=>{n.d(t,{U:()=>u});var r=n(95155),a=n(12115),s=n(56827),l=n(49509);let i=[{key:"Left",label:"◀",ariaLabel:"Send Left"},{key:"Up",label:"▲",ariaLabel:"Send Up"},{key:"Down",label:"▼",ariaLabel:"Send Down"},{key:"Right",label:"▶",ariaLabel:"Send Right"},{key:"Enter",label:"↵",ariaLabel:"Send Enter"}],o={key:"Escape",label:"Esc",ariaLabel:"Send Escape"},c={key:"q",label:"q",ariaLabel:"Send q (quit)"};function u(e){let{worktreeId:t,cliToolId:n,instanceId:u,onKeysSent:d}=e,{activeKey:m,markPressed:f}=(0,l.t)(),h=(0,s.B)(t,n,u,d),p="codex"===n?[...i,o,c]:[...i,o],g=(0,a.useCallback)(e=>{f(e),h([e])},[f,h]);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 py-1.5 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800/50 rounded-lg",role:"toolbar","aria-label":"Terminal navigation keys",children:[(0,r.jsx)("span",{className:"text-xs text-amber-700 dark:text-amber-400 mx-2",title:"Send navigation / escape keys when the terminal is stuck in a TUI overlay",children:"Navigate"}),p.map(e=>{let{key:t,label:n,ariaLabel:a}=e;return(0,r.jsx)("button",{type:"button",className:"min-w-[44px] min-h-[44px] px-3 py-2 text-sm font-medium rounded-md\n border border-amber-300 dark:border-amber-700\n focus:outline-none focus:ring-2 focus:ring-amber-500\n transition-colors duration-75\n ".concat(m===t?"bg-amber-500 text-white border-amber-500 scale-95":"bg-white dark:bg-gray-700 hover:bg-amber-50 dark:hover:bg-gray-600 active:bg-amber-100 dark:active:bg-gray-500"),"aria-label":a,onClick:()=>g(t),children:n},t)})]})}},73333:(e,t,n)=>{n.d(t,{E:()=>L});var r=n(95155),a=n(12115),s=n(18955),l=n(80344),i=n(79651),o=n(28019);function c(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e=>{var t;return null!=(t=e.description)?t:""};if(!t.trim())return e;let r=t.toLowerCase();return e.map(e=>({...e,commands:e.commands.filter(e=>{let t=e.name.toLowerCase().includes(r),a=n(e).toLowerCase().includes(r);return t||a})})).filter(e=>e.commands.length>0)}function u(e,t){return"codex-skill"===e.source?"antigravity"===t?"/".concat(e.name):"$".concat(e.name):"/".concat(e.name)}function d(e,t){var n;return e.descriptionKey?t(e.descriptionKey):null!=(n=e.description)?n:""}function m(e){let{groups:t,onSelect:n,highlightedIndex:a=-1,className:l="",cliToolId:i}=e,o=(0,s.c)("worktree"),c=0;return 0===t.length?(0,r.jsx)("div",{className:"text-sm text-muted-foreground p-4 text-center ".concat(l),children:o("slashCommands.empty")}):(0,r.jsx)("div",{className:"overflow-y-auto ".concat(l),children:t.map(e=>(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider bg-muted",children:e.label}),(0,r.jsx)("div",{children:e.commands.map(e=>{var t;let s=c;c++;let l=s===a;return(0,r.jsxs)("button",{type:"button","data-command-item":!0,"data-highlighted":l,onClick:()=>n(e),className:"w-full px-3 py-2 text-left flex items-start gap-2 hover:bg-accent-50 dark:hover:bg-accent-900/30 transition-colors ".concat(l?"bg-accent-100 dark:bg-accent-900/40":""),children:[(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-mono text-sm flex-shrink-0",children:u(e,i)}),(null==(t=e.cliTools)?void 0:t.length)===1&&"codex"===e.cliTools[0]&&(0,r.jsx)("span",{className:"mt-0.5 rounded border border-accent-200 bg-accent-50 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-accent-700 dark:border-accent-800 dark:bg-accent-950/40 dark:text-accent-300",children:"Codex"}),"user-catalog"===e.source&&(0,r.jsx)("span",{"data-testid":"user-catalog-badge",className:"mt-0.5 rounded border border-border bg-muted px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:o("slashCommands.sourceBadge.userCatalog")}),(0,r.jsx)("span",{className:"text-muted-foreground text-sm truncate",children:d(e,o)})]},e.name)})})]},e.category))})}function f(e,t,n){if(t<=0||n<=0)return 0;let r=e+t+8-n;return r>0?-Math.min(r,Math.max(0,e-8)):e<8?8-e:0}let h=(0,a.memo)(function(e){let{isOpen:t,groups:n,onSelect:l,onClose:i,isMobile:o=!1,position:u,onFreeInput:h,isCatalogStale:p=!1,cliToolId:g}=e,[x,b]=(0,a.useState)(""),[v,y]=(0,a.useState)(0),w=(0,a.useRef)(null),k=(0,a.useRef)(null),j=(0,a.useRef)({x:0,y:0}),[N,C]=(0,a.useState)({x:0,y:0}),S=(0,s.c)("worktree"),T=(0,s.c)("common"),I=(0,a.useMemo)(()=>c(n,x,e=>d(e,S)),[n,x,S]),M=(0,a.useMemo)(()=>I.flatMap(e=>e.commands),[I]);(0,a.useEffect)(()=>{t&&(b(""),y(0),setTimeout(()=>{var e;null==(e=w.current)||e.focus()},50))},[t]);let E=(0,a.useCallback)(e=>{l(e),i()},[l,i]),A=(0,a.useCallback)(e=>{if(t)switch(e.key){case"Escape":e.preventDefault(),i();break;case"ArrowDown":e.preventDefault(),y(e=>Math.min(e+1,M.length-1));break;case"ArrowUp":e.preventDefault(),y(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),M[v]&&E(M[v])}},[t,M,v,i,E]);if((0,a.useEffect)(()=>{if(t)return document.addEventListener("keydown",A),()=>{document.removeEventListener("keydown",A)}},[t,A]),(0,a.useLayoutEffect)(()=>{let e=e=>{j.current=e,C(t=>t.x===e.x&&t.y===e.y?t:e)};if(!t||o)return void e({x:0,y:0});let n=k.current;if(!n)return;let r=n.getBoundingClientRect();e({x:f(r.left-j.current.x,r.width,window.innerWidth),y:f(r.top-j.current.y,r.height,window.innerHeight)})},[t,o,I,null==u?void 0:u.top,null==u?void 0:u.left]),!t)return null;let L=p?(0,r.jsx)("div",{"data-testid":"slash-command-stale-note",className:"px-3 py-2 border-t border-border text-xs text-muted-foreground",children:S("slashCommands.catalogStale.hint")}):null;if(o)return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40",onClick:i,"aria-hidden":"true"}),(0,r.jsxs)("div",{"data-testid":"slash-command-bottom-sheet",className:"fixed bottom-0 left-0 right-0 bg-surface rounded-t-xl z-50 max-h-[70vh] flex flex-col shadow-xl",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:S("slashCommands.title")}),(0,r.jsx)("button",{type:"button",onClick:i,"aria-label":T("close"),className:"p-2 rounded-full hover:bg-muted",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"px-4 py-2 border-b border-border",children:(0,r.jsx)("input",{ref:w,type:"text",value:x,onChange:e=>b(e.target.value),placeholder:S("slashCommands.searchPlaceholder"),className:"w-full px-3 py-2 border border-input bg-surface dark:bg-surface-2 text-foreground rounded-lg focus:outline-none focus:ring-2 focus:ring-ring"})}),h&&(0,r.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:()=>h(x),className:"w-full px-4 py-3 text-left border-b border-border flex items-center gap-2 hover:bg-accent-50 dark:hover:bg-accent-900/30 transition-colors",children:[(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,r.jsx)("span",{className:"text-muted-foreground",children:S("slashCommands.enterCustomCommand")})]}),(0,r.jsx)(m,{groups:I,onSelect:E,highlightedIndex:v,className:"flex-1 overflow-y-auto pb-20",cliToolId:g}),L]})]});let R=u?{top:u.top,left:u.left}:{bottom:"100%",left:0,marginBottom:"4px"};return(0,r.jsxs)("div",{ref:k,role:"listbox","data-testid":"slash-command-dropdown",className:"absolute bg-surface border border-border rounded-lg shadow-lg z-50 w-80 max-h-96 flex flex-col",style:0!==N.x||0!==N.y?{...R,transform:"translate(".concat(N.x,"px, ").concat(N.y,"px)")}:R,children:[(0,r.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,r.jsx)("input",{ref:w,type:"text",value:x,onChange:e=>b(e.target.value),placeholder:S("slashCommands.searchPlaceholder"),className:"w-full px-3 py-1.5 text-sm border border-input bg-surface dark:bg-surface-2 text-foreground rounded focus:outline-none focus:ring-1 focus:ring-ring"})}),h&&(0,r.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:()=>h(x),className:"w-full px-3 py-2 text-left border-b border-border flex items-center gap-2 hover:bg-accent-50 dark:hover:bg-accent-900/30 transition-colors text-sm",children:[(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,r.jsx)("span",{className:"text-muted-foreground",children:S("slashCommands.enterCustomCommand")})]}),(0,r.jsx)(m,{groups:I,onSelect:E,highlightedIndex:v,className:"flex-1 overflow-y-auto",cliToolId:g}),L,(0,r.jsxs)("div",{className:"px-3 py-1.5 border-t border-border text-xs text-muted-foreground flex gap-3",children:[(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded",children:"Enter"})," ",S("slashCommands.selectHint")]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded",children:"Esc"})," ",S("slashCommands.closeHint")]})]})]})});var p=n(3005);let g=(0,a.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:l,disabled:i=!1,onInterrupt:o}=e,c=(0,s.c)("worktree"),[u,d]=(0,a.useState)(!1),m=(0,a.useRef)(0),f=(0,a.useCallback)(async()=>{let e=Date.now();if(!(e-m.current<1e3)){m.current=e,d(!0);try{let e=l&&l!==n?{cliToolId:n,instanceId:l}:{cliToolId:n},r=await fetch("/api/worktrees/".concat(t,"/interrupt"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.ok)null==o||o();else{let e=await r.json().catch(()=>({}));console.error("[InterruptButton] Failed to send interrupt:",e.error||r.statusText)}}catch(e){console.error("[InterruptButton] Error sending interrupt:",e)}finally{d(!1)}}},[t,n,l,o]);return(0,r.jsx)("button",{type:"button",onClick:f,disabled:i||u,className:"flex-shrink-0 p-2 text-danger hover:bg-danger/10 rounded-full transition-colors disabled:text-muted-foreground/40 disabled:hover:bg-transparent","aria-label":c("interrupt.stopProcessing"),"data-testid":"interrupt-button",children:u?(0,r.jsx)(p.y,{size:"md"}):(0,r.jsx)(x,{})})});function x(){return(0,r.jsx)("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}var b=n(44309),v=n(50386),y=n(62512),w=n(4788),k=n(5917),j=n(75426),N=n(77588);let C=(0,a.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:l,disabled:i=!1,onActionComplete:c,showToast:u}=e,d=(0,s.c)("worktree.opencodeSession"),m=(0,o.SC)(),[f,h]=(0,a.useState)(null),[p,g]=(0,a.useState)(null),[x,C]=(0,a.useState)(null),[S,T]=(0,a.useState)(!1),[I,M]=(0,a.useState)(null),E="opencode"===n,A=null!=l?l:n,L=(0,a.useCallback)(e=>{if(u){M(null),u(e,"error");return}M(e)},[u]),R=(0,a.useCallback)((e,t,n)=>"NO_OPENCODE_PORT"===e.code?d("errorNoPort"):"NO_OPENCODE_SESSION"===e.code?d(n):e.error||t||d("errorUnknown"),[d]),P=(0,a.useCallback)(async()=>{if(E)try{let e=await fetch("/api/worktrees/".concat(t,"/opencode/share?instance=").concat(encodeURIComponent(A)));if(!e.ok)return void g(null);g(await e.json())}catch(e){g(null)}},[E,t,A]);(0,a.useEffect)(()=>{P()},[P]);let D=(0,a.useCallback)(async e=>{h(e),M(null);try{let n=await fetch("/api/worktrees/".concat(t,"/opencode/session"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,instanceId:A})});if(!n.ok){let t=await n.json().catch(()=>({}));console.error("[OpencodeSessionControls] action failed:",e,t.error||n.statusText),L(R(t,n.statusText,"errorNoSessionFork"));return}null==c||c(e),"list"!==e&&(C(null),P())}catch(e){console.error("[OpencodeSessionControls] request error:",e),L(d("errorRequestFailed"))}finally{h(null)}},[t,A,c,P,L,R,d]),z=(0,a.useCallback)(async()=>{if(await m({title:d("shareConfirmTitle"),description:d("shareConfirmBody"),confirmLabel:d("shareConfirmLabel"),variant:"danger"})){h("share"),M(null);try{let e=await fetch("/api/worktrees/".concat(t,"/opencode/share"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({instanceId:A})}),n=await e.json().catch(()=>({}));if(!e.ok||"string"!=typeof n.url){console.error("[OpencodeSessionControls] share failed:",n.error||e.statusText),L(R(n,e.statusText,"errorNoSessionShare")),P();return}C(n.url),T(!1),P()}catch(e){console.error("[OpencodeSessionControls] share request error:",e),L(d("errorRequestFailed"))}finally{h(null)}}},[m,d,t,A,P,L,R]),O=(0,a.useCallback)(async()=>{h("unshare"),M(null);try{let e=await fetch("/api/worktrees/".concat(t,"/opencode/share?instance=").concat(encodeURIComponent(A)),{method:"DELETE"});if(!e.ok){let t=await e.json().catch(()=>({}));console.error("[OpencodeSessionControls] unshare failed:",t.error||e.statusText),L(R(t,e.statusText,"errorNoSessionShare"));return}C(null),T(!1),P()}catch(e){console.error("[OpencodeSessionControls] unshare request error:",e),L(d("errorRequestFailed"))}finally{h(null)}},[t,A,P,L,R,d]),F=(0,a.useCallback)(async()=>{if(null!==x)try{await navigator.clipboard.writeText(x),T(!0),M(null)}catch(e){console.error("[OpencodeSessionControls] clipboard write failed:",e),L(d("errorCopyFailed"))}},[x,L,d]);if(!E)return null;let H=[{action:"new",icon:(0,r.jsx)(b.A,{className:"h-5 w-5","aria-hidden":"true"})},{action:"list",icon:(0,r.jsx)(v.A,{className:"h-5 w-5","aria-hidden":"true"})},{action:"fork",icon:(0,r.jsx)(y.A,{className:"h-5 w-5","aria-hidden":"true"})}],q="flex-shrink-0 p-2 text-muted-foreground hover:text-accent-600 hover:bg-accent-50 dark:hover:text-accent-400 dark:hover:bg-accent-900/30 rounded-full transition-colors disabled:text-muted-foreground/50 disabled:hover:bg-transparent";return(0,r.jsxs)("div",{className:"flex items-center gap-1","data-testid":"opencode-session-controls",children:[H.map(e=>{let{action:t,icon:n}=e;return(0,r.jsx)(o.$n,{variant:"ghost",type:"button",onClick:()=>void D(t),disabled:i||null!==f,className:q,"aria-label":d(t),title:d(t),"data-testid":"opencode-session-".concat(t),children:f===t?(0,r.jsx)(o.y$,{size:"md"}):n},t)}),(null==p?void 0:p.canShare)?(0,r.jsx)(o.$n,{variant:"ghost",type:"button",onClick:()=>void z(),disabled:i||null!==f,className:q,"aria-label":d("share"),title:d("share"),"data-testid":"opencode-session-share",children:"share"===f?(0,r.jsx)(o.y$,{size:"md"}):(0,r.jsx)(w.A,{className:"h-5 w-5","aria-hidden":"true"})}):null,null!==x?(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1 rounded-full border border-warning-border bg-warning-subtle px-2 py-0.5 text-xs text-warning-foreground","data-testid":"opencode-share-result",children:[(0,r.jsx)("span",{className:"sr-only",children:d("sharePublicNotice")}),(0,r.jsx)("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"truncate text-accent-600 underline dark:text-accent-400",title:x,"data-testid":"opencode-share-url",children:x}),(0,r.jsx)(o.$n,{variant:"ghost",type:"button",onClick:()=>void F(),className:"flex-shrink-0 rounded-full p-1 text-muted-foreground hover:text-accent-600","aria-label":d("shareCopy"),title:d("shareCopy"),"data-testid":"opencode-share-copy",children:S?(0,r.jsx)(k.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}):(0,r.jsx)(j.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),(0,r.jsx)(o.$n,{variant:"ghost",type:"button",onClick:()=>void O(),disabled:null!==f,className:"flex-shrink-0 rounded-full p-1 text-muted-foreground hover:text-danger-foreground","aria-label":d("unshare"),title:d("unshare"),"data-testid":"opencode-session-unshare",children:"unshare"===f?(0,r.jsx)(o.y$,{size:"sm"}):(0,r.jsx)(N.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):null,null!==I?(0,r.jsx)("span",{role:"alert",className:"flex min-w-0 items-center rounded-full border border-danger-border bg-danger-subtle px-2 py-0.5 text-xs text-danger-foreground",title:I,"data-testid":"opencode-session-error",children:(0,r.jsx)("span",{className:"truncate",children:I})}):null]})});var S=n(74385),T=n(38218),I=n(19985);let M="commandmate:draft-message:",E="Queued (session busy) — your message will run after the current task finishes.";function A(e,t){return"".concat(M).concat(e,":").concat(t)}let L=(0,a.memo)(function(e){let{worktreeId:t,onMessageSent:n,cliToolId:d,instanceId:m,isSessionRunning:f=!1,pendingInsertText:p,onInsertConsumed:x,splitIndex:b=0,onFocus:v,isProcessing:y=!1,showToast:w,autoYesSlot:k,onOptimisticSend:j}=e,N=(0,s.c)("worktree"),[L,R]=(0,a.useState)(""),[P,D]=(0,a.useState)(!1),[z,O]=(0,a.useState)(null),[F,H]=(0,a.useState)(!1),[q,K]=(0,a.useState)(!1),[B,U]=(0,a.useState)(!1),W=(0,a.useRef)(null),$=(0,a.useRef)(null),Q=(0,a.useRef)(!1),Y=(0,a.useRef)(null),_=(0,a.useRef)(null),J=(0,T.a)(),{groups:G,isCatalogStale:V}=function(e,t){let[n,r]=(0,a.useState)([]),[s,i]=(0,a.useState)(!0),[o,u]=(0,a.useState)(null),[d,m]=(0,a.useState)(""),[f,h]=(0,a.useState)(t||"claude"),[p,g]=(0,a.useState)({}),x=(0,a.useCallback)(async()=>{try{var n;i(!0),u(null);let a=e?"/api/worktrees/".concat(e,"/slash-commands"):"/api/slash-commands";t&&(a+="?cliTool=".concat(t));let s=await fetch(a,{cache:"no-store"});if(!s.ok)throw Error("HTTP error ".concat(s.status));let l=await s.json();r(l.groups),h(l.cliTool||t||"claude"),g(null!=(n=l.catalogStaleness)?n:{})}catch(e){u((0,l.hS)(e)),r([]),g({})}finally{i(!1)}},[e,t]);(0,a.useEffect)(()=>{x()},[x]),(0,a.useEffect)(()=>{if(!e)return;let t=t=>{let n=t.detail;(null==n?void 0:n.worktreeId)===e&&x()};return window.addEventListener(S.I,t),()=>window.removeEventListener(S.I,t)},[e,x]);let b=(0,a.useMemo)(()=>n.flatMap(e=>e.commands),[n]),v=(0,a.useMemo)(()=>c(n,d),[n,d]),y=(0,a.useMemo)(()=>Object.values(p).some(e=>e.stale),[p]);return{groups:n,filteredGroups:v,allCommands:b,loading:s,error:o,filter:d,setFilter:m,refresh:(0,a.useCallback)(()=>{x()},[x]),cliTool:f,isCatalogStale:y}}(t,d),{attachedImage:Z,fileInputRef:X,isUploading:ee,error:et,acceptAttribute:en,openFileDialog:er,handleFileSelect:ea,removeAttachment:es,resetAfterSend:el}=function(e,t){let[n,r]=(0,a.useState)(null),[s,l]=(0,a.useState)(!1),[i,o]=(0,a.useState)(null),c=(0,a.useRef)(null),u=(0,a.useCallback)(()=>{var e;null==(e=c.current)||e.click()},[]),d=(0,a.useCallback)(async n=>{var a;let s=null==(a=n.target.files)?void 0:a[0];if(!s)return;o(null);let i=function(e){let t=e.name.lastIndexOf(".");if(-1===t)return"Unsupported file format";let n=(0,I.HB)(e.name.substring(t));if(!I.Hv.includes(n))return"Unsupported file format: ".concat(n);if(e.size>I.Fg){let e=I.Fg/1024/1024;return"File size exceeds ".concat(e,"MB limit")}return null}(s);if(i){o(i),c.current&&(c.current.value="");return}l(!0);try{let n=await t(e,s);r({file:s,path:n.path})}catch(e){o(e instanceof Error?e.message:"Upload failed")}finally{l(!1),c.current&&(c.current.value="")}},[e,t]),m=(0,a.useCallback)(()=>{r(null),o(null)},[]),f=(0,a.useCallback)(()=>{r(null)},[]);return{attachedImage:n,fileInputRef:c,isUploading:s,error:i,acceptAttribute:I.F5,openFileDialog:u,handleFileSelect:d,removeAttachment:m,resetAfterSend:f}}(t,(0,a.useCallback)((e,t)=>l.y.uploadImageFile(e,t),[]));(0,a.useEffect)(()=>{try{0===b&&function(e){try{let t="".concat(M).concat(e),n=window.localStorage.getItem(t);if(null===n)return;let r=A(e,0);null===window.localStorage.getItem(r)&&window.localStorage.setItem(r,n),window.localStorage.removeItem(t)}catch(e){}}(t);let e=window.localStorage.getItem(A(t,b));e?R(e):R("")}catch(e){}return()=>{_.current&&clearTimeout(_.current)}},[t,b]),(0,a.useEffect)(()=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{try{let e=A(t,b);L?window.localStorage.setItem(e,L):window.localStorage.removeItem(e)}catch(e){}},500)},[L,t,b]),(0,a.useEffect)(()=>{let e=W.current;e&&(L?(e.style.height="auto",e.style.height="".concat(Math.min(e.scrollHeight,160),"px")):e.style.height="24px")},[L]),(0,a.useEffect)(()=>{p&&(R(e=>""===e.trim()?p:e+"\n\n"+p),null==x||x())},[p,x]);let ei=(0,a.useCallback)(async()=>{if(F||!L.trim()&&!Z||P)return;let e=L.trim(),r=d||"claude",a={cliToolId:r};if(m&&m!==r&&(a.instanceId=m),Z&&(a.imagePath=Z.path),j){O(null),j(e,a),R(""),U(!1),el();try{window.localStorage.removeItem(A(t,b))}catch(e){}y&&(null==w||w(E,"warning")),null==n||n(r);return}try{D(!0),O(null);let s=await l.y.sendMessage(t,e,a);R(""),U(!1),el();try{window.localStorage.removeItem(A(t,b))}catch(e){}y&&(null==w||w(E,"warning")),null==n||n(r,s)}catch(e){O((0,l.hS)(e))}finally{D(!1)}},[F,L,Z,P,t,d,m,n,el,b,y,w,j]),eo=(0,a.useCallback)(async e=>{e.preventDefault(),await ei()},[ei]),ec=(0,a.useCallback)(()=>{H(!0),Q.current=!1,$.current&&clearTimeout($.current)},[]),eu=(0,a.useCallback)(()=>{H(!1),Q.current=!0,$.current&&clearTimeout($.current),$.current=setTimeout(()=>{Q.current=!1},300)},[]),ed=(0,a.useCallback)(e=>{var t;R("".concat(u(e,d)," ")),K(!1),null==(t=W.current)||t.focus()},[d]),em=(0,a.useCallback)(()=>{var e;K(!1),U(!1),null==(e=W.current)||e.focus()},[]),ef=(0,a.useCallback)(e=>{K(!1),U(!0),R(e?"/".concat(e):"/"),setTimeout(()=>{var e;null==(e=W.current)||e.focus()},50)},[]),eh=(0,a.useCallback)(e=>{let t=e.target.value;if(R(t),""===t){U(!1),K(!1);return}if(B)return;let n="/"===t||t.startsWith("/")&&!t.includes(" "),r="codex"===d&&("$"===t||t.startsWith("$")&&!t.includes(" "));n||r?K(!0):K(!1)},[B,d]),ep=(0,a.useCallback)(e=>{let{keyCode:t}=e.nativeEvent;if(229!==t){if("Escape"===e.key&&q){e.preventDefault(),em();return}if(Q.current&&"Enter"===e.key){Q.current=!1;return}if("Enter"===e.key&&!F&&(!q||B)){if(J)return;e.shiftKey||(e.preventDefault(),ei())}}},[q,B,F,J,ei,em]);return(0,r.jsxs)("div",{ref:Y,className:"space-y-2 relative","data-testid":"message-input-container",children:[(z||et)&&(0,r.jsx)("div",{className:"p-2 bg-danger-subtle border border-danger-border rounded text-sm text-danger-foreground",children:z||et}),Z&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-accent-50 dark:bg-accent-900/20 border border-accent-200 dark:border-accent-800 rounded-lg text-sm","data-testid":"image-attachment-preview",children:[(0,r.jsx)("svg",{className:"h-4 w-4 flex-shrink-0 text-accent-600 dark:text-accent-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,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)("span",{className:"truncate text-accent-800 dark:text-accent-300",children:Z.file.name}),(0,r.jsx)("button",{type:"button",onClick:es,className:"flex-shrink-0 p-0.5 text-accent-600 hover:text-danger-foreground dark:text-accent-400 rounded transition-colors","aria-label":N("composer.removeAttachment"),"data-testid":"remove-attachment-button",children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("input",{ref:X,type:"file",accept:en,onChange:ea,className:"hidden","data-testid":"image-file-input"}),(0,r.jsxs)("form",{onSubmit:eo,className:"rounded-xl bg-surface border border-border shadow-sm px-3 py-2 focus-within:ring-2 focus-within:ring-accent-500/40 transition-shadow flex flex-col gap-1.5",children:[(0,r.jsxs)("div",{className:J?"flex flex-col gap-1":"flex items-center gap-2",children:[J&&(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(o.$n,{variant:"ghost",type:"button",onClick:()=>{B&&U(!1),K(!0)},className:"flex-shrink-0 p-2 text-muted-foreground hover:text-accent-600 hover:bg-accent-50 dark:hover:text-accent-400 dark:hover:bg-accent-900/30 rounded-full transition-colors","aria-label":N("composer.showSlashCommands"),"data-testid":"mobile-command-button",children:(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"})})}),(0,r.jsx)(o.$n,{variant:"ghost",type:"button",onClick:er,disabled:ee||P,className:"flex-shrink-0 p-2 text-muted-foreground hover:text-accent-600 hover:bg-accent-50 dark:hover:text-accent-400 dark:hover:bg-accent-900/30 rounded-full transition-colors disabled:text-muted-foreground/50 disabled:hover:bg-transparent","aria-label":N("composer.attachImage"),"data-testid":"attach-image-button",children:ee?(0,r.jsx)(o.y$,{size:"md"}):(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}),(0,r.jsx)(C,{worktreeId:t,cliToolId:d||"claude",instanceId:m,disabled:!f,showToast:w}),(0,r.jsx)(g,{worktreeId:t,cliToolId:d||"claude",instanceId:m,disabled:!f})]}),!J&&(0,r.jsx)(o.$n,{variant:"ghost",type:"button",onClick:er,disabled:ee||P,className:"flex-shrink-0 p-2 text-muted-foreground hover:text-accent-600 hover:bg-accent-50 dark:hover:text-accent-400 dark:hover:bg-accent-900/30 rounded-full transition-colors disabled:text-muted-foreground/50 disabled:hover:bg-transparent","aria-label":N("composer.attachImage"),"data-testid":"attach-image-button",children:ee?(0,r.jsx)(o.y$,{size:"md"}):(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,r.jsx)("textarea",{ref:W,"data-testid":"message-input-textarea",value:L,onChange:eh,onKeyDown:ep,onCompositionStart:ec,onCompositionEnd:eu,onFocus:v,placeholder:N("composer.placeholder"),disabled:P,rows:1,inputMode:"text",enterKeyHint:"send",className:"flex-1 outline-none bg-transparent resize-none overflow-y-auto scrollbar-thin",style:{minHeight:"36px",maxHeight:"160px",paddingTop:"8px",paddingBottom:"8px",lineHeight:"20px"}}),!J&&(0,r.jsx)(C,{worktreeId:t,cliToolId:d||"claude",instanceId:m,disabled:!f,showToast:w}),!J&&(0,r.jsx)(g,{worktreeId:t,cliToolId:d||"claude",instanceId:m,disabled:!f}),(0,r.jsx)(o.$n,{variant:"ghost",type:"submit","data-testid":"send-message-button","data-can-send":String((!!L.trim()||!!Z)&&!P),disabled:!L.trim()&&!Z||P,className:"flex-shrink-0 p-2 rounded-full transition-colors disabled:hover:bg-transparent ".concat((L.trim()||Z)&&!P?"bg-accent-600 text-white hover:bg-accent-700 shadow-sm":"text-muted-foreground/50"),"aria-label":N("composer.sendMessage"),children:P?(0,r.jsx)(o.y$,{size:"md"}):(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]})]}),(k||!J)&&(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 min-w-0","data-testid":"composer-meta-row",children:[(0,r.jsx)("div",{className:"flex items-center gap-2 min-w-0 overflow-x-auto scrollbar-hide",children:k}),!J&&(0,r.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground select-none",children:[(0,r.jsx)(i.u,{children:"/"}),(0,r.jsx)("span",{children:N("composer.commandsHint")}),(0,r.jsx)("span",{"aria-hidden":"true",className:"opacity-50",children:"\xb7"}),(0,r.jsx)(i.u,{children:"⇧"}),(0,r.jsx)(i.u,{children:"↵"}),(0,r.jsx)("span",{children:N("composer.newlineHint")})]})]})]}),(0,r.jsx)(h,{isOpen:q,groups:G,onSelect:ed,onClose:em,isMobile:J,onFreeInput:ef,isCatalogStale:V,cliToolId:d})]})})},75676:(e,t,n)=>{n.d(t,{jg:()=>s,kQ:()=>l,mR:()=>c,mS:()=>o,wf:()=>r});let r="terminal",a=new Set(["terminal","chat"]);function s(e){return"string"==typeof e&&a.has(e)}let l={data:null,messageId:null,visible:!1,answering:!1},i={mode:"split",mobileActivePane:"terminal",leftPaneTab:"history",splitRatio:.5,leftPaneCollapsed:!1,activityBar:{active:"files"},historyPane:{visible:!0,width:25,collapsed:!1}},o={type:null,message:null,retryable:!1,retryCount:0};function c(){return{phase:"idle",prompt:{...l},layout:{...i},error:{...o},messages:[],wsConnected:!1}}},76351:(e,t,n)=>{n.d(t,{z9:()=>s,$s:()=>o,t6:()=>l,Ni:()=>i,eJ:()=>u,$B:()=>d,P0:()=>c});var r=n(82912),a=n.n(r);n(95704);let s=[36e5,108e5,288e5],l=36e5,i={36e5:"autoYes.durations.1h",108e5:"autoYes.durations.3h",288e5:"autoYes.durations.8h"},o=1e3;function c(e){if(e.length>500)return{valid:!1,error:"Pattern must be ".concat(500," characters or less")};if(!a()(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"}}}function u(e,t){arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{return e.test(t)}catch(e){return null}}function d(e){let t=Math.max(0,e-Date.now()),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),a=Math.floor(t%6e4/1e3);return n>0?"".concat(n,":").concat(r.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0")):"".concat(r.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0"))}},78596:(e,t,n)=>{n.d(t,{l5:()=>d});var r=n(46980),a=n.n(r),s=n(62459),l=n.n(s),i=n(68872),o=n(51515);let c=new(l())({fg:"#d1d5db",bg:"#1f2937",newline:!0,escapeXML:!0}),u=/[\x40-\x7e]/;function d(e){let t=function(e){if(e.length<=i.ZJ)return e;let t=i.ED+"\n",n=i.ZJ-t.length;if(n<=0)return i.ED.slice(0,i.ZJ);let r=e.length-n,a=e.indexOf("\n",r);if(-1!==a&&a-r<=i.yi)return t+e.slice(a+1);let s=function(e,t){let n=e.lastIndexOf("\x1b",t-1);if(-1===n)return t;let r=e.slice(n+1,t);if(u.test(r.slice(1)))return t;for(let n=t;n<e.length;n++)if(u.test(e[n]))return n+1;return e.length}(e,r),l=e.charCodeAt(s);return l>=56320&&l<=57343&&(s+=1),t+e.slice(s)}(e.replace(/\0/g,"")),n=(0,o.wJ)(t),r=c.toHtml(n);return a().sanitize(r,{ALLOWED_TAGS:["span","br"],ALLOWED_ATTR:["style"],ALLOW_DATA_ATTR:!1})}},78660:(e,t,n)=>{n.d(t,{E2:()=>i,F0:()=>s,Yr:()=>o,e1:()=>l});var r=n(12115),a=n(20877);let s=500,l=300,i=2;function o(e){let{output:t,containerRef:n}=e,[o,c]=(0,r.useState)(!1),[u,d]=(0,r.useState)(""),[m,f]=(0,r.useState)([]),[h,p]=(0,r.useState)(0),[g,x]=(0,r.useState)(!1),b=(0,r.useRef)(null),v=(0,r.useRef)(""),y=m.length,w=(0,r.useCallback)(e=>{var t;if(e.length<i||!n.current)return{positions:[],capped:!1};let r=(null!=(t=n.current.textContent)?t:"").toLowerCase(),a=e.toLowerCase(),l=[],o=0;for(;l.length<s;){let t=r.indexOf(a,o);if(-1===t)break;l.push({start:t,end:t+e.length}),o=t+1}let c=l.length>=s&&-1!==r.indexOf(a,o);return{positions:l,capped:c}},[n]),k=(0,r.useCallback)(e=>{let{positions:t,capped:r}=w(e);f(t),p(0),x(r),n.current&&(t.length>0?(0,a.aX)(n.current,t,0):(0,a.HI)())},[w,n]),j=(0,r.useCallback)(e=>{d(e),b.current&&clearTimeout(b.current),v.current=e,b.current=setTimeout(()=>{k(e)},l)},[k]),N=(0,r.useCallback)(()=>{c(!0)},[]),C=(0,r.useCallback)(()=>{c(!1),d(""),v.current="",f([]),p(0),x(!1),b.current&&clearTimeout(b.current),(0,a.HI)()},[]),S=(0,r.useCallback)(()=>{0!==y&&p(e=>{let t=(e+1)%y;return n.current&&m.length>0&&(0,a.aX)(n.current,m,t),t})},[y,m,n]),T=(0,r.useCallback)(()=>{0!==y&&p(e=>{let t=(e-1+y)%y;return n.current&&m.length>0&&(0,a.aX)(n.current,m,t),t})},[y,m,n]);return(0,r.useEffect)(()=>{v.current.length<i||k(v.current)},[t,k]),(0,r.useEffect)(()=>()=>{b.current&&clearTimeout(b.current),(0,a.HI)()},[]),{isOpen:o,query:u,matchCount:y,currentIndex:h,isAtMaxMatches:g,openSearch:N,closeSearch:C,setQuery:j,nextMatch:S,prevMatch:T}}},80635:(e,t,n)=>{n.d(t,{v4:()=>l});var r=n(12115);function a(e){let t=new Set;for(let n of e)"user"===n.role&&t.add(n.id);return t}function s(e,t,n){let r=new Set,a=new Set,s=e.filter(e=>"sending"===e.status);if(0===s.length)return{reconciledTempIds:r,consumedServerIds:a};let l=t.filter(e=>"user"===e.role&&!n.has(e.id)).sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()),i=new Set;for(let e of[...s].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime())){let t=l.find(t=>!i.has(t.id)&&!e.baselineUserIds.has(t.id)&&t.content===e.content);t&&(i.add(t.id),r.add(e.tempId),a.add(t.id))}return{reconciledTempIds:r,consumedServerIds:a}}function l(e){var t,n;let{worktreeId:l,serverMessages:i,sendFn:o,onSent:c,timeoutMs:u=3e4,connectivity:d,resendGraceMs:m=250}=e,[f,h]=(0,r.useState)([]),p=null!=(t=null==d?void 0:d.offline)&&t,g=null==(n=null==d?void 0:d.reachable)||n,x=(0,r.useRef)(i);x.current=i;let b=(0,r.useRef)(f);b.current=f;let v=(0,r.useRef)(c);v.current=c;let y=(0,r.useRef)(o);y.current=o;let w=(0,r.useRef)(p);w.current=p;let k=(0,r.useRef)(0),j=(0,r.useRef)(new Map),N=(0,r.useRef)(new Set),C=(0,r.useRef)(new Set),S=(0,r.useRef)(new Set),T=(0,r.useCallback)(e=>{let t=j.current.get(e);void 0!==t&&(clearTimeout(t),j.current.delete(e))},[]),I=(0,r.useCallback)(e=>{T(e),h(t=>t.map(t=>t.tempId!==e||"sending"!==t.status?t:w.current&&!t.autoResendAttempted?t.queued?t:{...t,queued:!0}:{...t,status:"error",queued:!1}))},[T]),M=(0,r.useCallback)(e=>{T(e);let t=setTimeout(()=>{j.current.delete(e),I(e)},u);j.current.set(e,t)},[T,I,u]),E=(0,r.useCallback)(async e=>{M(e.tempId),N.current.add(e.tempId);try{var t;await y.current(e.content,e.options),h(t=>t.map(t=>t.tempId!==e.tempId||t.accepted?t:{...t,accepted:!0})),null==(t=v.current)||t.call(v)}catch(t){I(e.tempId)}finally{N.current.delete(e.tempId)}},[M,I]),A=(0,r.useCallback)((e,t)=>{let n={tempId:"pending-".concat(k.current++),content:e,options:t,timestamp:new Date,status:"sending",baselineUserIds:a(x.current),queued:!1,accepted:!1,autoResendAttempted:!1};h(e=>[...e,n]),E(n)},[E]),L=(0,r.useCallback)(e=>{let t=b.current.find(t=>t.tempId===e);if(!t)return;let n={...t,status:"sending",timestamp:new Date,baselineUserIds:a(x.current),queued:!1,accepted:!1,autoResendAttempted:!1};h(t=>t.map(t=>t.tempId===e?n:t)),E(n)},[E]),R=(0,r.useCallback)(e=>{let t=b.current.find(t=>t.tempId===e);return T(e),N.current.delete(e),h(t=>t.filter(t=>t.tempId!==e)),null==t?void 0:t.content},[T]);(0,r.useEffect)(()=>{let{reconciledTempIds:e,consumedServerIds:t}=s(b.current,i,C.current),n=new Set(i.map(e=>e.id)),r=new Set;C.current.forEach(e=>{n.has(e)&&r.add(e)}),t.forEach(e=>r.add(e)),C.current=r,0!==e.size&&(e.forEach(e=>S.current.add(e)),e.forEach(T),h(t=>t.filter(t=>!e.has(t.tempId))))},[i,T]),(0,r.useEffect)(()=>{if(!p)return;let e=f.filter(e=>"sending"===e.status&&!e.queued&&!e.autoResendAttempted);if(0===e.length)return;let t=new Set(e.map(e=>e.tempId));t.forEach(T),h(e=>e.map(e=>t.has(e.tempId)?{...e,queued:!0}:e))},[p,f,T]);let P=(0,r.useRef)(!1),[D,z]=(0,r.useState)(0),[O,F]=(0,r.useState)(0),H=(0,r.useRef)(m);H.current=m;let q=f.reduce((e,t)=>t.queued&&"sending"===t.status?e+1:e,0);return(0,r.useEffect)(()=>{(!g||q>0)&&(P.current=!0),g&&P.current&&(P.current=!1,b.current.some(e=>"sending"===e.status)&&z(e=>e+1))},[g,q]),(0,r.useEffect)(()=>{let e;if(0===D)return;let t=!1;return(async()=>{try{var n;await (null==(n=v.current)?void 0:n.call(v))}catch(e){}t||(e=setTimeout(()=>F(e=>e+1),H.current))})(),()=>{t=!0,void 0!==e&&clearTimeout(e)}},[D]),(0,r.useEffect)(()=>{if(0===O)return;let e=b.current,t=e.filter(e=>"sending"===e.status);if(0===t.length)return;let{reconciledTempIds:n}=s(e,x.current,C.current),r=[],a=[];for(let e of t)!(n.has(e.tempId)||S.current.has(e.tempId))&&(e.accepted||N.current.has(e.tempId)?a.push(e.tempId):e.queued?r.push(e):j.current.has(e.tempId)||a.push(e.tempId));if(a.forEach(M),0===r.length)return;let l=new Set(r.map(e=>e.tempId));h(e=>e.map(e=>l.has(e.tempId)?{...e,queued:!1,autoResendAttempted:!0}:e)),r.forEach(e=>{E({...e,queued:!1,autoResendAttempted:!0})})},[O,M,E]),(0,r.useEffect)(()=>{let e=j.current;return()=>{e.forEach(e=>clearTimeout(e)),e.clear()}},[]),{messages:(0,r.useMemo)(()=>{if(0===f.length)return i;let{reconciledTempIds:e}=s(f,i,C.current),t=f.filter(t=>!e.has(t.tempId)).map(e=>({id:e.tempId,worktreeId:l,role:"user",content:e.content,timestamp:e.timestamp,messageType:"normal",archived:!1,cliToolId:e.options.cliToolId,instanceId:e.options.instanceId,optimisticState:e.status}));return 0===t.length?i:[...i,...t]},[i,f,l]),pending:f,sendOptimistic:A,retry:L,discard:R}}},81507:(e,t,n)=>{n.d(t,{Ce:()=>d,TG:()=>u,jt:()=>s,sg:()=>l});var r=n(12115);let a={visible:"commandmate.worktree.historyVisible",width:"commandmate.worktree.historyWidth"},s={visible:"commandmate.sessions.tileHistoryVisible",width:"commandmate.sessions.tileHistoryWidth"},l=40;function i(e){return Number.isFinite(e)?Math.min(60,Math.max(10,e)):l}let o="commandmate:historyPaneStateChange";function c(e){try{window.dispatchEvent(new CustomEvent(o,{detail:e}))}catch(e){}}function u(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a,{visible:t,width:n}=e,[s,u]=(0,r.useState)(!0),[d,m]=(0,r.useState)(l),f=(0,r.useRef)(s);f.current=s;let h=(0,r.useRef)(d);return h.current=d,(0,r.useEffect)(()=>{let e=function(e){try{let t=window.localStorage.getItem(e);if("true"===t)return!0;if("false"===t)return!1}catch(e){}return!0}(t),r=function(e){try{let t=window.localStorage.getItem(e);if(null===t)return l;let n=Number(t);if(Number.isFinite(n))return i(n)}catch(e){}return l}(n);u(e),m(r)},[t,n]),(0,r.useEffect)(()=>{let e=e=>{e.detail&&e.detail.scope===t&&(e.detail.visible!==f.current&&u(e.detail.visible),e.detail.width!==h.current&&m(e.detail.width))};return window.addEventListener(o,e),()=>window.removeEventListener(o,e)},[t]),{visible:s,width:d,toggle:(0,r.useCallback)(()=>{let e=!f.current;u(e);try{window.localStorage.setItem(t,String(e))}catch(e){}c({scope:t,visible:e,width:h.current})},[t]),setWidth:(0,r.useCallback)(e=>{let r=i(e);m(r);try{window.localStorage.setItem(n,String(r))}catch(e){}c({scope:t,visible:f.current,width:r})},[t,n])}}function d(e){return"split-history-slot-".concat(e)}},83012:(e,t,n)=>{n.d(t,{Fx:()=>l,Uq:()=>o,bg:()=>i,fw:()=>s,g8:()=>c});var r=n(53298),a=n(73683);function s(e,t){let n=new Date(e);return isNaN(n.getTime())?"":(0,r.m)(n,{addSuffix:!0,...t?{locale:t}:{}})}function l(e){let t=new Date(e);if(isNaN(t.getTime()))return"";let n=Math.round((Date.now()-t.getTime())/1e3);if(n<45)return"now";let r=Math.round(n/60);if(r<60)return"".concat(r,"m ago");let a=Math.round(r/60);if(a<24)return"".concat(a,"h ago");let s=Math.round(a/24);return s<7?"".concat(s,"d ago"):s<30?"".concat(Math.round(s/7),"w ago"):s<365?"".concat(Math.round(s/30),"mo ago"):"".concat(Math.round(s/365),"y ago")}function i(e,t){return!(e instanceof Date)||isNaN(e.getTime())?"":(0,a.GP)(e,"PPp",t?{locale:t}:void 0)}function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date;if(!(e instanceof Date)||isNaN(e.getTime()))return"";let n=t instanceof Date&&!isNaN(t.getTime())?t:new Date,r=e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate();return(0,a.GP)(e,r?"HH:mm":"M/d HH:mm")}function c(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Date;if(!d(e))return"";let r=d(n)?n:new Date,s=d(t)?t:null,l=m(e,r)&&(null===s||m(s,r)&&m(s,e))?"HH:mm":"M/d HH:mm",i=(0,a.GP)(e,l);if(null===s)return i;let o=(0,a.GP)(s,l);return o===i?i:"".concat(o).concat(u).concat(i)}let u=" → ";function d(e){return e instanceof Date&&!isNaN(e.getTime())}function m(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}},83051:(e,t,n)=>{n.d(t,{bl:()=>X,Ce:()=>f.Ce});var r=n(95155),a=n(12115),s=n(18955),l=n(96195),i=n(7620),o=n(12181),c=n(20508),u=n(86651),d=n(90368),m=n(28019),f=n(81507),h=n(35252),p=n(35299),g=n(6132),x=n(48314),b=n(65229),v=n(54916),y=n(75426),w=n(24033),k=n(36809),j=n(51238),N=n(10934),C=n(5225),S=n(4300),T=n(55813),I=n(83012),M=n(89568),E=n(99112),A=n(47160);function L(e){let t=e.split("\n");if(t.length<=2&&e.length<=100)return{text:e,isTruncated:!1};let n=t.slice(0,2).join("\n");return n.length>100&&(n=n.slice(0,100)),{text:n,isTruncated:!0}}let R=(0,a.memo)(function(e){let{content:t,onFilePathClick:n}=e,l=(0,s.c)("worktree"),i=(0,a.useMemo)(()=>(0,M.ML)(t),[t]),o=(0,a.useCallback)(e=>()=>n(e),[n]);return(0,r.jsx)("span",{children:i.map((e,t)=>"path"===e.type?(0,r.jsx)("button",{type:"button",onClick:o(e.content),className:"text-accent-700 dark:text-accent-400 hover:text-accent-600 dark:hover:text-accent-300 hover:underline cursor-pointer font-mono text-sm","aria-label":l("conversation.openFile",{path:e.content}),children:e.content},t):(0,r.jsx)("span",{children:e.content},t))})}),P=(0,a.memo)(function(e){let{content:t,onFilePathClick:n}=e,s=(0,a.useMemo)(()=>{let e=e=>a.Children.map(e,e=>"string"==typeof e?(0,r.jsx)(R,{content:e,onFilePathClick:n}):e);return{p:t=>{let{children:n}=t;return(0,r.jsx)("p",{children:e(n)})},li:t=>{let{children:n}=t;return(0,r.jsx)("li",{children:e(n)})},td:t=>{let{children:n}=t;return(0,r.jsx)("td",{children:e(n)})},th:t=>{let{children:n}=t;return(0,r.jsx)("th",{children:e(n)})},strong:t=>{let{children:n}=t;return(0,r.jsx)("strong",{children:e(n)})},em:t=>{let{children:n}=t;return(0,r.jsx)("em",{children:e(n)})},a:e=>{let{href:t,children:a,node:s,...l}=e;return(0,r.jsx)(A.ZS,{...l,href:t,onFilePathClick:n,children:a})}}},[n]),l=(0,a.useMemo)(()=>[N.A,C.A],[]);return(0,r.jsx)(j.oz,{remarkPlugins:E.eT,rehypePlugins:l,components:s,children:t})});function D(){let e=(0,s.c)("worktree");return(0,r.jsxs)("div",{"data-testid":"pending-indicator",className:"flex items-center gap-2 text-muted-foreground 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-muted-foreground rounded-full animate-pulse"}),(0,r.jsx)("span",{className:"w-2 h-2 bg-muted-foreground rounded-full animate-pulse",style:{animationDelay:"150ms"}}),(0,r.jsx)("span",{className:"w-2 h-2 bg-muted-foreground rounded-full animate-pulse",style:{animationDelay:"300ms"}})]}),(0,r.jsx)("span",{className:"text-sm",children:e("conversation.waitingForResponse")})]})}let z=(0,a.memo)(function(e){let{message:t,onFilePathClick:n,onCopy:a,onInsertToMessage:l,onRetryPending:i,onDiscardPending:o}=e,c=(0,k.Ym)(),u=(0,s.c)("worktree"),d=(0,s.c)("common"),m=(0,T.M)(c),f=(0,I.bg)(t.timestamp,m),h=t.optimisticState,w=["group relative border-l-2 p-3 transition-opacity","error"===h?"border-danger-border bg-danger-subtle":"border-accent-500 bg-accent-500/10","sending"===h?"opacity-70":""].filter(Boolean).join(" ");return(0,r.jsxs)("div",{className:w,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-accent-700 dark:text-accent-400",children:u("conversation.you")}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:f}),"sending"===h&&(0,r.jsxs)("span",{"data-testid":"optimistic-sending",className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,r.jsx)(p.A,{size:12,className:"animate-spin","aria-hidden":"true"}),(0,r.jsx)("span",{children:u("conversation.sending")})]}),"error"===h&&(0,r.jsxs)("span",{"data-testid":"optimistic-error",className:"flex items-center gap-1 text-xs text-danger-foreground",children:[(0,r.jsx)(g.A,{size:12,"aria-hidden":"true"}),(0,r.jsx)("span",{children:u("conversation.failedToSend")})]}),"error"===h?(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[i&&(0,r.jsxs)("button",{type:"button","data-testid":"pending-retry",onClick:()=>i(t.id),className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-accent-700 dark:text-accent-400 hover:bg-muted transition-colors","aria-label":u("conversation.retrySending"),title:d("retry"),children:[(0,r.jsx)(x.A,{size:12,"aria-hidden":"true"}),d("retry")]}),o&&(0,r.jsxs)("button",{type:"button","data-testid":"pending-discard",onClick:()=>o(t.id),className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-muted-foreground hover:text-danger-foreground hover:bg-muted transition-colors","aria-label":u("conversation.discardMessage"),title:u("conversation.discard"),children:[(0,r.jsx)(b.A,{size:12,"aria-hidden":"true"}),u("conversation.discard")]})]}):(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100 [@media(hover:none)]:opacity-100",children:[l&&(0,r.jsx)("button",{type:"button","data-testid":"insert-user-message",onClick:()=>l(t.content),className:"p-1 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 hover:bg-muted rounded transition-colors","aria-label":u("conversation.insertToMessage"),title:u("conversation.insertToMessage"),children:(0,r.jsx)(v.A,{size:14,"aria-hidden":"true"})}),a&&(0,r.jsx)("button",{type:"button","data-testid":"copy-user-message",onClick:()=>a(t.content),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors","aria-label":u("conversation.copyMessage"),title:u("conversation.copy"),children:(0,r.jsx)(y.A,{size:14,"aria-hidden":"true"})})]})]}),(0,r.jsx)("div",{"data-message-id":t.id,className:"text-sm text-foreground whitespace-pre-wrap break-words [word-break:break-word] max-w-full overflow-x-hidden",children:(0,r.jsx)(R,{content:t.content,onFilePathClick:n})})]})}),O=(0,a.memo)(function(e){let{message:t,index:n,total:l,isExpanded:i,onFilePathClick:o,onCopy:c,hasLongContent:u=!1,onToggleExpand:d}=e,m=(0,k.Ym)(),f=(0,s.c)("worktree"),h=(0,T.M)(m),p=(0,I.bg)(t.timestamp,h),{text:g,isTruncated:x}=(0,a.useMemo)(()=>L(t.content),[t.content]),b=i||!x?t.content:g,v=(0,S.bx)(t.requestId),j=v&&x&&!i;return(0,r.jsxs)("div",{className:"assistant-message-item group 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-muted-foreground",children:f("conversation.assistant")}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:p}),l>1&&(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",n+1,"/",l,")"]}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100 [@media(hover:none)]:opacity-100",children:[0===n&&u&&!!d&&(0,r.jsxs)("button",{type:"button",onClick:d,className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-accent-700 dark:text-accent-400 hover:text-accent-600 dark:hover:text-accent-300 hover:bg-muted transition-colors","aria-expanded":i,"aria-label":f(i?"conversation.collapseMessage":"conversation.expandMessage"),children:[(0,r.jsx)(w.A,{size:12,className:"transition-transform ".concat(i?"rotate-180":""),"aria-hidden":"true"}),f(i?"conversation.collapse":"conversation.expand")]}),c&&(0,r.jsx)("button",{type:"button","data-testid":"copy-assistant-message",onClick:()=>c(t.content),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors","aria-label":f("conversation.copyMessage"),title:f("conversation.copy"),children:(0,r.jsx)(y.A,{size:14,"aria-hidden":"true"})})]})]}),v?(0,r.jsx)("div",{"data-message-id":t.id,"data-markdown":"true",className:["assistant-md text-xs text-foreground break-words [word-break:break-word] max-w-full overflow-x-hidden",j?"".concat("max-h-[3.25rem]"," overflow-y-hidden"):""].filter(Boolean).join(" "),children:(0,r.jsx)(P,{content:t.content,onFilePathClick:o})}):(0,r.jsxs)("div",{"data-message-id":t.id,className:"text-xs text-foreground whitespace-pre-wrap break-words [word-break:break-word] max-w-full overflow-x-hidden",children:[(0,r.jsx)(R,{content:b,onFilePathClick:o}),!i&&x&&(0,r.jsx)("span",{className:"text-muted-foreground",children:"..."})]})]})}),F=(0,a.memo)(function(e){let{messages:t,isExpanded:n,onFilePathClick:s,onCopy:l,hasLongContent:i=!1,onToggleExpand:o}=e;return(0,r.jsx)("div",{className:"bg-surface-2/50 border-l-2 border-border p-2 border-t border-border space-y-2",children:t.map((e,c)=>(0,r.jsxs)(a.Fragment,{children:[c>0&&(0,r.jsx)("div",{"data-testid":"assistant-message-divider",className:"border-t border-dashed border-border"}),(0,r.jsx)(O,{message:e,index:c,total:t.length,isExpanded:n,onFilePathClick:s,onCopy:l,hasLongContent:i,onToggleExpand:o})]},e.id))})});function H(){let e=(0,s.c)("worktree");return(0,r.jsxs)("div",{"data-testid":"orphan-indicator",className:"bg-warning/10 text-warning-foreground 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:e("conversation.systemMessage")})]})}let q=(0,a.memo)(function(e){var t;let{pair:n,onFilePathClick:l,isExpanded:i=!1,onToggleExpand:o,onCopy:c,onInsertToMessage:u,showAssistant:d=!0,onRetryPending:m,onDiscardPending:f}=e,h=(0,s.c)("worktree"),p=(null==(t=n.userMessage)?void 0:t.optimisticState)!==void 0,g=(0,a.useMemo)(()=>n.assistantMessages.some(e=>{let{isTruncated:t}=L(e.content);return t}),[n.assistantMessages]),x=(0,a.useCallback)(()=>{o&&o()},[o]),b=(0,a.useMemo)(()=>{let e="pending"===n.status?"pending":"orphan"===n.status?"orphan border-l-4 border-warning":"";return"".concat("border border-border rounded-lg overflow-hidden mb-4 transition-colors"," ").concat(e).trim()},[n.status]),v=n.userMessage?h("conversation.conversationLabel",{preview:"".concat(n.userMessage.content.substring(0,50)).concat(n.userMessage.content.length>50?"...":"")}):h("conversation.systemMessageLabel");return(0,r.jsxs)("div",{"data-testid":"conversation-pair-card",role:"article","aria-label":v,className:b,children:["orphan"===n.status&&(0,r.jsx)(H,{}),n.userMessage&&(0,r.jsx)(z,{message:n.userMessage,onFilePathClick:l,onCopy:c,onInsertToMessage:u,onRetryPending:m,onDiscardPending:f}),"pending"!==n.status||p?d&&n.assistantMessages.length>0?(0,r.jsx)(F,{messages:n.assistantMessages,isExpanded:i,onFilePathClick:l,onCopy:c,hasLongContent:g,onToggleExpand:x}):null:(0,r.jsx)("div",{className:"bg-muted/40 border-l-2 border-border p-3 border-t border-border",children:(0,r.jsx)(D,{})})]})});var K=n(92710),B=n(23570),U=n(60322),W=n(70738),$=n(64653),Q=n(9708),Y=n(20877),_=n(88731),J=n(96802);function G(){let e=(0,s.c)("worktree");return(0,r.jsx)("div",{"data-testid":"loading-indicator",role:"status","aria-label":e("history.loading"),children:[0,1,2].map(e=>(0,r.jsxs)("div",{className:"mb-4 overflow-hidden rounded-lg border border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 p-3",children:[(0,r.jsx)(m.EA,{className:"h-4 w-4 rounded-full"}),(0,r.jsx)(m.EA,{className:"h-4 w-1/3"})]}),(0,r.jsxs)("div",{className:"space-y-2 px-3 pb-3",children:[(0,r.jsx)(m.EA,{className:"h-3 w-full"}),(0,r.jsx)(m.EA,{className:"h-3 w-5/6"}),(0,r.jsx)(m.EA,{className:"h-3 w-2/3"})]})]},e))})}function V(){let e=(0,s.c)("worktree");return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",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:e("history.empty")})]})}let Z=["h-full","flex","flex-col","overflow-hidden","bg-surface-2","rounded-lg","border","border-border"],X=(0,a.memo)(function(e){let{messages:t,worktreeId:n,worktreePath:p,onFilePathClick:g,isLoading:x=!1,className:b="",showToast:v,onInsertToMessage:y,onRetryPending:w,onDiscardPending:k,showArchived:j=!1,onShowArchivedChange:N,historyDisplayLimit:C,onHistoryDisplayLimitChange:S,historyUserOnly:T=!1,onHistoryUserOnlyChange:I,onCollapse:M,splitIndex:E,cliToolId:A}=e,L=(0,s.c)("worktree"),R=(0,a.useRef)(null),P=(0,Q.O)(),D=null!=p?p:P.worktreePath,z=(0,a.useMemo)(()=>void 0===E?Y.Gw:(0,Y.eu)(E),[E]),O=void 0===E?"history-pane-collapse-button":"history-pane-collapse-button-".concat(E),F=void 0===E?B.g6:(0,f.Ce)(E),H=(0,a.useRef)(!0),X=(0,a.useRef)(-1),ee=(0,a.useRef)(null),{pairs:et,isExpanded:en,toggleExpand:er}=function(e){let t=(0,a.useMemo)(()=>(function(e){if(0===e.length)return[];let t=[...e].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()),n=[],r=null;for(let e of t)if("user"===e.role)r={id:e.id,userMessage:e,assistantMessages:[],status:"pending"},n.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"};n.push(t),r=t}return n})(e),[e]),[n,r]=(0,a.useState)(new Set),s=(0,a.useCallback)(e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),l=(0,a.useCallback)(e=>n.has(e),[n]),i=(0,a.useCallback)(()=>{r(new Set(t.map(e=>e.id)))},[t]);return{pairs:t,expandedPairs:n,toggleExpand:s,isExpanded:l,expandAll:i,collapseAll:(0,a.useCallback)(()=>{r(new Set)},[])}}(t),ea=(0,a.useMemo)(()=>t.filter(e=>!e.archived&&"string"==typeof e.content&&e.content.length>0&&(!T||"user"===e.role)),[t,T]),{isOpen:es,query:el,matchCount:ei,currentIndex:eo,isAtMaxMatches:ec,matchPositions:eu,currentMatch:ed,openSearch:em,closeSearch:ef,setQuery:eh,onCompositionStart:ep,onCompositionEnd:eg,nextMatch:ex,prevMatch:eb}=(0,h.w)({messages:ea}),ev=es&&eu.length>0,ey=(0,a.useMemo)(()=>t.filter(e=>"relay"===e.messageType).length,[t]),[ew,ek]=(0,a.useState)(new Set);(0,a.useEffect)(()=>{ef()},[n]);let ej=(0,a.useMemo)(()=>T?et.filter(e=>e.userMessage):et,[et,T]),eN=(0,a.useMemo)(()=>{let e=new Map;for(let t of ej)for(let n of(t.userMessage&&e.set(t.userMessage.id,t.id),t.assistantMessages))e.set(n.id,t.id);return e},[ej]),eC=(0,a.useMemo)(()=>{let e=new Map;return ej.forEach((t,n)=>e.set(t.id,n)),e},[ej]),eS=(0,l.Te)({count:ej.length,getScrollElement:()=>R.current,estimateSize:()=>J.__,overscan:J.b,getItemKey:e=>{var t,n;return null!=(n=null==(t=ej[e])?void 0:t.id)?n:e}}),eT=eS.getVirtualItems(),eI=eT.length>0?"".concat(eT[0].index,"-").concat(eT[eT.length-1].index):"",eM=(0,a.useCallback)(()=>{let e=R.current;e&&(H.current=(0,J.Mp)({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}))},[]);(0,a.useLayoutEffect)(()=>{let e=X.current,t=ej.length;X.current=t,-1!==e&&t>e&&t>0&&H.current&&!ev&&eS.scrollToIndex(t-1,{align:"end"})},[ej.length,ev,eS]),(0,a.useLayoutEffect)(()=>{if(!es||0===eu.length)return void ek(e=>0===e.size?e:new Set);ek(function(e,t){let n=new Map;for(let e of t)for(let t of(e.userMessage&&n.set(e.userMessage.id,e.id),e.assistantMessages))n.set(t.id,e.id);let r=new Set;for(let t of e){let e=n.get(t.messageId);e&&r.add(e)}return r}(eu,et))},[es,eu,et]),(0,a.useEffect)(()=>{if(!es||!ed)return;let e=eN.get(ed.messageId);if(void 0===e)return;let t=eC.get(e);void 0!==t&&eS.scrollToIndex(t,{align:"center"})},[es,ed,eN,eC,eS]),(0,a.useLayoutEffect)(()=>{let e=R.current;if(!e)return;if(!es||0===eu.length)return void(0,Y.fq)(z);let t=null;for(let r of eu){var n;let a=(n=r.messageId,e.querySelector('[data-message-id="'.concat(CSS.escape(n),'"]')));if(!a)continue;let s=(null==ed?void 0:ed.messageId)===r.messageId,l=s?ed.localIndex:-1;(0,Y.Gg)(a,r.ranges,l,z),s&&a instanceof HTMLElement&&(t=a)}return t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"}),()=>{(0,Y.fq)(z)}},[es,eu,ed,ew,z,eI]),(0,a.useEffect)(()=>{let e=R.current;if(es)null===ee.current&&e&&(ee.current=e.scrollTop);else{if(null!==ee.current&&e){let t=ee.current;requestAnimationFrame(()=>{e.scrollTop=t})}ee.current=null}},[es]);let eE=(0,a.useMemo)(()=>[...Z,b].filter(Boolean).join(" "),[b]),eA=(0,a.useRef)(L);eA.current=L;let eL=(0,a.useCallback)(e=>{let t=(0,W.h)(e,D);null!==t&&(async()=>{if("missing"===await (0,$.o4)(n,t)){null==v||v(eA.current("conversation.filePathMissing"),"error");return}g(t)})()},[g,n,D,v]),eR=(0,a.useCallback)(e=>()=>er(e),[er]),eP=(0,a.useCallback)(async e=>{try{await (0,U.l)(e),null==v||v(eA.current("history.copied"),"success")}catch(e){console.error("[HistoryPane] Failed to copy to clipboard"),null==v||v(eA.current("history.copyFailed"),"error")}},[v]),eD=e=>{var t,n;let a=(null==(t=e.userMessage)?void 0:t.archived)===!0||(null==(n=e.assistantMessages)?void 0:n.some(e=>!0===e.archived)),s=en(e.id)||ew.has(e.id);return(0,r.jsx)("div",{className:a?"opacity-60":"",children:(0,r.jsx)(q,{pair:e,onFilePathClick:eL,isExpanded:s,onToggleExpand:eR(e.id),onCopy:eP,onInsertToMessage:y,onRetryPending:w,onDiscardPending:k,showAssistant:!T})})},ez=(0,a.useCallback)(e=>{let t=parseInt(e.target.value,10);(0,_.UK)(t)&&(null==S||S(t))},[S]),eO=(0,a.useCallback)(()=>{es?ef():em()},[es,em,ef]);return(0,r.jsxs)("div",{role:"region","aria-label":L("history.regionLabel"),className:eE,children:[(0,r.jsxs)("div",{className:"flex-shrink-0 bg-surface-2 border-b border-border px-4 py-2 flex items-center justify-between flex-wrap gap-1",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:L("history.title")}),ey>0&&(0,r.jsxs)("span",{"data-testid":"history-relay-count",title:L("relay.historyBadgeTitle"),className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,r.jsx)(i.A,{size:12,className:"shrink-0","aria-hidden":"true"}),L("relay.historyCount",{count:ey})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[S&&void 0!==C&&(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer",children:[(0,r.jsx)("span",{children:L("history.show")}),(0,r.jsx)("select",{value:C,onChange:ez,"aria-label":L("history.displayLimit"),className:"rounded border border-input bg-surface text-foreground text-xs px-1.5 py-0.5 focus:outline-none focus:ring-1 focus:ring-ring",children:_.dl.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]}),N&&(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer",children:[(0,r.jsx)(m.Sc,{checked:j,onCheckedChange:e=>N(!0===e),className:"h-3.5 w-3.5"}),L("history.showArchived")]}),I&&(0,r.jsx)("button",{type:"button",onClick:()=>I(!T),"aria-label":L("history.showUserOnly"),"aria-pressed":T,className:"p-1 rounded transition-colors ".concat(T?"bg-accent-500/15 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:text-foreground"),title:L(T?"history.showAllMessages":"history.showUserOnly"),children:T?(0,r.jsx)(o.A,{size:14,"aria-hidden":"true"}):(0,r.jsx)(c.A,{size:14,"aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:eO,"aria-label":L(es?"history.closeSearch":"history.openSearch"),"aria-pressed":es,className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors",title:L(es?"history.closeSearch":"history.openSearch"),children:(0,r.jsx)(u.A,{size:14,"aria-hidden":"true"})}),M&&(0,r.jsx)("button",{type:"button",onClick:M,"aria-label":L("terminal.hideHistory"),"aria-expanded":"true","aria-controls":F,className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors",title:L("terminal.hideHistory"),"data-testid":O,children:(0,r.jsx)(d.A,{size:14,"aria-hidden":"true"})})]})]}),es&&(0,r.jsx)("div",{className:"flex-shrink-0 px-3 py-2 bg-surface-2 border-b border-border",children:(0,r.jsx)(K.Y,{query:el,onQueryChange:eh,matchCount:ei,currentIndex:eo,onNext:ex,onPrev:eb,onClose:ef,isAtMaxMatches:ec,onCompositionStart:ep,onCompositionEnd:eg})}),(0,r.jsx)("div",{ref:R,"data-testid":"history-scroll-container",onScroll:eM,className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden p-4",children:x?(0,r.jsx)(G,{}):0===ej.length?(0,r.jsx)(V,{}):0===eT.length?(0,r.jsx)("div",{"data-testid":"history-fallback-list",children:ej.slice(0,J.vC).map(e=>(0,r.jsx)("div",{children:eD(e)},e.id))}):(0,r.jsx)("div",{style:{height:eS.getTotalSize(),width:"100%",position:"relative"},children:eT.map(e=>{let t=ej[e.index];return t?(0,r.jsx)("div",{"data-index":e.index,ref:eS.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:"translateY(".concat(e.start,"px)")},children:eD(t)},e.key):null})})})]})})},84228:(e,t,n)=>{n.d(t,{wY:()=>eK});var r=n(95155),a=n(12115),s=n(18955),l=n(7620),i=n(35299),o=n(8803),c=n(22479),u=n(41108),d=n(95342),m=n(96195),f=n(24033),h=n(27937),p=n(54485),g=n(37586),x=n(20562),b=n(53842),v=n(86651),y=n(28019),w=n(35252),k=n(60322),j=n(70738),N=n(64653),C=n(9708),S=n(20877),T=n(96802),I=n(89568),M=n(92147);let E={highlightName:"chat-search",currentHighlightName:"chat-search-current",fallbackOverlayId:"chat-search-fallback-overlay",fallbackOverlayBgColor:"rgba(59, 130, 246, 0.6)"},A="commandmate:chatShowToolActivity";function L(){try{return"true"===window.localStorage.getItem(A)}catch(e){return!1}}var R=n(47160);let P="chat-live-turn",D=(0,a.memo)(function(e){let{turnKey:t,version:n,body:a,partial:l=!1,isThinking:o=!1,showHeader:c=!1,onFilePathClick:u}=e,d=(0,s.c)("worktree"),m="string"==typeof a&&a.length>0;return(0,r.jsxs)("div",{"data-testid":P,"data-role":"assistant","data-turn-key":t,"data-version":void 0===n?void 0:String(n),"data-has-body":m?"true":"false",role:"group","aria-label":d("chatSurface.progressLabel"),className:R.UI,children:[c&&(0,r.jsx)("div",{className:"flex items-center gap-2 px-1 text-xs text-muted-foreground",children:(0,r.jsx)("span",{className:"font-medium",children:d("conversation.assistant")})}),(0,r.jsxs)("div",{"data-testid":R.a3,className:R.CL,children:[m&&(0,r.jsx)("div",{"data-testid":"chat-live-turn-body","data-markdown":"true",className:R.Et,children:(0,r.jsx)(R.Gn,{content:a,onFilePathClick:u})}),(0,r.jsxs)("div",{"data-testid":"chat-live-turn-indicator",role:"status","aria-live":"polite",className:["flex flex-wrap items-center gap-2 text-xs text-muted-foreground",m?"mt-1.5":""].filter(Boolean).join(" "),children:[(0,r.jsx)(i.A,{size:14,className:"animate-spin","aria-hidden":"true"}),(0,r.jsx)("span",{children:d(o?"chatSurface.thinking":"chatSurface.generating")}),l&&(0,r.jsx)("span",{"data-testid":"chat-live-turn-partial",className:"rounded border border-warning-border bg-warning-subtle px-1 py-0.5 text-warning-foreground",children:d("chatSurface.progressPartial")})]})]})]})});var z=n(92710);let O="chat-transcript-scroll-container",F="chat-transcript-jump-fab",H="absolute bottom-3 right-3 z-10 flex h-9 w-9 items-center justify-center rounded-full border border-border bg-surface-2/80 text-muted-foreground shadow-lg backdrop-blur transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation";function q(){let e=(0,s.c)("worktree");return(0,r.jsx)("div",{"data-testid":"chat-transcript-loading",role:"status","aria-label":e("chatTranscript.loading"),children:[0,1,2].map(e=>(0,r.jsxs)("div",{className:"mb-4 flex flex-col gap-1 ".concat(e%2==0?"items-end":"items-start"),children:[(0,r.jsx)(y.EA,{className:"h-3 w-24"}),(0,r.jsx)(y.EA,{className:"h-14 rounded-2xl ".concat(e%2==0?"w-2/3":"w-11/12")})]},e))})}function K(e){let{turnKey:t,version:n,body:a,partial:l=!1,showHeader:i=!1,onFilePathClick:o}=e,c=(0,s.c)("worktree"),u="string"==typeof a&&a.length>0;return(0,r.jsxs)("div",{"data-testid":P,"data-role":"assistant","data-settling":"true","data-turn-key":t,"data-version":void 0===n?void 0:String(n),"data-has-body":u?"true":"false",role:"group","aria-label":c("chatSurface.settlingLabel"),className:R.UI,children:[i&&(0,r.jsx)("div",{className:"flex items-center gap-2 px-1 text-xs text-muted-foreground",children:(0,r.jsx)("span",{className:"font-medium",children:c("conversation.assistant")})}),(0,r.jsxs)("div",{"data-testid":R.a3,className:R.CL,children:[u&&(0,r.jsx)("div",{"data-testid":"chat-live-turn-body","data-markdown":"true",className:R.Et,children:(0,r.jsx)(R.Gn,{content:a,onFilePathClick:o})}),(0,r.jsxs)("div",{"data-testid":"chat-settling-turn-note",className:["flex flex-wrap items-center gap-2 text-xs text-muted-foreground",u?"mt-1.5":""].filter(Boolean).join(" "),children:[(0,r.jsx)("span",{children:c("chatSurface.settling")}),l&&(0,r.jsx)("span",{"data-testid":"chat-live-turn-partial",className:"rounded border border-warning-border bg-warning-subtle px-1 py-0.5 text-warning-foreground",children:c("chatSurface.progressPartial")})]})]})]})}function B(e){let{count:t,isOpen:n,regionId:a,onToggle:l}=e,i=(0,s.c)("worktree"),o=n?f.A:h.A;return(0,r.jsx)("div",{className:"mb-2 flex w-full items-center",children:(0,r.jsxs)("button",{type:"button","data-testid":"chat-previous-session-toggle","data-count":String(t),onClick:l,"aria-expanded":n,"aria-controls":a,"aria-label":i(n?"chatTranscript.previousSession.collapse":"chatTranscript.previousSession.expand"),className:"flex min-h-[32px] items-center gap-1.5 rounded-full border border-border bg-surface-2 px-3 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation",children:[(0,r.jsx)(p.A,{size:12,"aria-hidden":"true"}),(0,r.jsx)("span",{children:i("chatTranscript.previousSession.summary",{count:t})}),(0,r.jsx)(o,{size:12,"aria-hidden":"true"})]})})}function U(){let e=(0,s.c)("worktree");return(0,r.jsxs)("div",{"data-testid":"chat-session-ended-banner",role:"status",className:"mt-2 flex flex-col gap-0.5 rounded-lg border border-border bg-surface-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:e("terminal.sessionEnded")}),(0,r.jsx)("span",{children:e("chatTranscript.previousSession.hint")})]})}function W(){let e=(0,s.c)("worktree");return(0,r.jsxs)("div",{"data-testid":"chat-transcript-empty",className:"flex flex-col items-center justify-center gap-1 py-10 text-center text-muted-foreground",children:[(0,r.jsx)(g.A,{className:"mb-1 h-10 w-10 opacity-50","aria-hidden":"true"}),(0,r.jsx)("p",{className:"text-sm",children:e("chatTranscript.empty")}),(0,r.jsx)("p",{className:"text-xs",children:e("chatTranscript.emptyHint")})]})}let $=(0,a.memo)(function(e){let{messages:t,worktreeId:n,worktreePath:l,cliToolId:c,instanceId:u,isLoading:d=!1,className:f="",onFilePathClick:h,showToast:p,onInsertToMessage:g,onRetryPending:y,onDiscardPending:P,splitIndex:$,liveTurn:Q=null,sessionEnded:Y=!1,onScrollControlsChange:_}=e,J=(0,s.c)("worktree"),G=(0,a.useRef)(null),V=(0,a.useMemo)(()=>void 0===$?E:{highlightName:"chat-search-".concat($),currentHighlightName:"chat-search-current-".concat($),fallbackOverlayId:"chat-search-fallback-overlay-".concat($),fallbackOverlayBgColor:E.fallbackOverlayBgColor},[$]),Z=(0,a.useMemo)(()=>{let e=t.filter(e=>!e.archived);return e.length===t.length?t:e},[t]),X=Y&&!d,ee="".concat(n,"|").concat(null!=c?c:"","|").concat(null!=u?u:""),et=(0,a.useRef)(null),en=(0,a.useRef)(ee);en.current!==ee&&(en.current=ee,et.current=null),X?null===et.current&&(et.current=new Set(Z.filter(e=>!e.optimisticState).map(e=>e.id))):et.current=null;let er=et.current,{previousMessages:ea,currentMessages:es}=(0,a.useMemo)(()=>{if(null===er||0===er.size)return{previousMessages:[],currentMessages:Z};let e=[],t=[];for(let n of Z)!n.optimisticState&&er.has(n.id)?e.push(n):t.push(n);return{previousMessages:e,currentMessages:t}},[er,Z]),el=ea.length,ei=X&&el>0,[eo,ec]=(0,a.useState)(!1),eu=(0,a.useCallback)(()=>{ec(e=>!e)},[]);(0,a.useEffect)(()=>{ei||ec(!1)},[ei]),(0,a.useEffect)(()=>{ec(!1)},[ee]);let ed=(0,a.useMemo)(()=>void 0===$?"chat-previous-session-region":"chat-previous-session-region-".concat($),[$]),em=(0,a.useRef)(!0),ef=(0,a.useRef)(-1),eh=(0,a.useRef)(d),ep=(0,a.useRef)(0),[eg,ex]=(0,a.useState)(!0),eb=(0,a.useMemo)(()=>(eo?Z:es).filter(e=>!e.archived&&!(0,M.nY)(e)&&"string"==typeof e.content&&e.content.length>0),[Z,es,eo]),{isOpen:ev,query:ey,matchCount:ew,currentIndex:ek,isAtMaxMatches:ej,matchPositions:eN,currentMatch:eC,openSearch:eS,closeSearch:eT,setQuery:eI,onCompositionStart:eM,onCompositionEnd:eE,nextMatch:eA,prevMatch:eL}=(0,w.w)({messages:eb}),eR=ev&&eN.length>0,[eP,eD]=(0,a.useState)(L),ez=(0,a.useCallback)(()=>{let e=!eP;eD(e);try{window.localStorage.setItem(A,String(e))}catch(e){}},[eP]),eO=(0,a.useMemo)(()=>({showAll:eP}),[eP]),eF=(0,a.useMemo)(()=>ev&&0!==eN.length?new Set(eN.map(e=>e.messageId)):null,[ev,eN]);(0,a.useEffect)(()=>{eT()},[n]);let eH=(0,a.useMemo)(()=>ei?[{kind:"previousSessionHeader",key:"previous-session-header",count:el},...eo?(0,I.UY)(ea).map(e=>({...e,previousSession:!0})):[],...(0,I.UY)(es)]:(0,I.UY)(Z),[ei,eo,Z,ea,es,el]);ep.current=eH.length;let eq=(0,m.Te)({count:eH.length,getScrollElement:()=>G.current,estimateSize:()=>I.hM,overscan:I.B7,getItemKey:e=>{var t,n;return null!=(n=null==(t=eH[e])?void 0:t.key)?n:e}}),eK=eq.getVirtualItems(),eB=eK.length>0?"".concat(eK[0].index,"-").concat(eK[eK.length-1].index):"",eU=(0,a.useMemo)(()=>{let e=new Map;return eH.forEach((t,n)=>{if("previousSessionHeader"!==t.kind)if("message"===t.kind)e.set(t.message.id,n);else for(let r of t.entries)for(let t of r.messageIds)e.set(t,n)}),e},[eH]),eW=(0,a.useRef)(null),e$=(0,a.useCallback)(()=>{let e=eW.current;eW.current=null,e&&null!==e.frame&&cancelAnimationFrame(e.frame)},[]),eQ=(0,a.useCallback)(()=>{e$();let e=ep.current-1;if(e<0||(eq.scrollToIndex(e,{align:"end"}),"function"!=typeof requestAnimationFrame))return;let t={frame:null,frames:0,stableFrames:0,totalSize:eq.getTotalSize(),deadline:Date.now()+600},n=()=>{if(t.frame=null,eW.current!==t)return;t.frames+=1;let e=ep.current-1;if(e<0||!em.current||t.frames>12||Date.now()>t.deadline){eW.current=null;return}let r=eq.getTotalSize();if(r===t.totalSize){if(t.stableFrames+=1,t.stableFrames>=3){eW.current=null;return}}else t.stableFrames=0,t.totalSize=r,eq.scrollToIndex(e,{align:"end"});t.frame=requestAnimationFrame(n)};eW.current=t,t.frame=requestAnimationFrame(n)},[eq,e$]);(0,a.useEffect)(()=>e$,[e$]);let eY=(0,a.useCallback)(()=>{em.current=!0,ex(!0),eQ()},[eQ]),e_=(0,a.useCallback)(()=>{e$(),em.current=!1,ex(!1),ep.current>0&&eq.scrollToIndex(0,{align:"start"})},[eq,e$]),eJ=(0,a.useCallback)(()=>{let e=G.current;if(!e)return;let t=(0,T.Mp)({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight});(t||null===eW.current)&&(em.current=t,ex(t))},[]);(0,a.useLayoutEffect)(()=>{let e=ef.current,t=eh.current,n=Z.length;ef.current=n,eh.current=d,d||eR||0===eH.length||!em.current||(-1===e||t||!(n<=e))&&eQ()},[Z.length,eH.length,d,eR,eQ]),(0,a.useEffect)(()=>{if(_)return _({scrollToLatest:eY,scrollToTop:e_}),()=>_(null)},[_,eY,e_]);let eG=(0,a.useCallback)(e=>{if("Home"!==e.key&&"End"!==e.key)return;let t=e.target;t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable)||0!==ep.current&&(e.preventDefault(),"End"===e.key?eY():e_())},[eY,e_]);(0,a.useEffect)(()=>{if(!ev||!eC)return;let e=eU.get(eC.messageId);void 0!==e&&eq.scrollToIndex(e,{align:"center"})},[ev,eC,eU,eq]),(0,a.useLayoutEffect)(()=>{let e=G.current;if(!e)return;if(!ev||0===eN.length)return void(0,S.fq)(V);let t=null;for(let n of eN){let r=e.querySelector('[data-message-id="'.concat(CSS.escape(n.messageId),'"]'));if(!r)continue;let a=(null==eC?void 0:eC.messageId)===n.messageId;(0,S.Gg)(r,n.ranges,a?eC.localIndex:-1,V),a&&r instanceof HTMLElement&&(t=r)}return t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"}),()=>{(0,S.fq)(V)}},[ev,eN,eC,V,eB]);let eV=(0,a.useRef)(J);eV.current=J;let eZ=(0,C.O)(),eX=null!=l?l:eZ.worktreePath,e0=(0,a.useCallback)(e=>{if(!h)return;let t=(0,j.h)(e,eX);null!==t&&(async()=>{if("missing"===await (0,N.o4)(n,t)){null==p||p(eV.current("conversation.filePathMissing"),"error");return}h(t)})()},[h,n,eX,p]),e1=(0,a.useCallback)(async e=>{try{await (0,k.l)(e),null==p||p(eV.current("history.copied"),"success")}catch(e){null==p||p(eV.current("history.copyFailed"),"error")}},[p]),e2=(0,a.useCallback)(e=>{let t=eH[e];if(!t)return null;if("previousSessionHeader"===t.kind)return(0,r.jsx)(B,{count:t.count,isOpen:eo,regionId:ed,onToggle:eu});let n=e=>t.previousSession?(0,r.jsx)("div",{"data-previous-session":"true",className:"opacity-60",children:e}):e;if("approvals"===t.kind)return n((0,r.jsx)(R.ZK,{entries:t.entries}));let a=(0,r.jsx)(R.qI,{message:t.message,showHeader:t.showHeader,header:t.header,onFilePathClick:e0,onCopy:e1,onInsertToMessage:g,onRetryPending:y,onDiscardPending:P});return n((null==eF?void 0:eF.has(t.message.id))?(0,r.jsx)(R.PZ,{value:R.vY,children:a}):a)},[eH,e0,e1,g,y,P,eF,eo,ed,eu]),e5=null!==Q&&!0!==Q.settling;return(0,r.jsxs)("div",{"data-testid":"chat-transcript","data-tool-activity":eP?"shown":"folded",role:"log","aria-label":J("chatTranscript.regionLabel"),className:["relative flex h-full min-h-0 w-full flex-col overflow-hidden bg-surface",f].filter(Boolean).join(" "),children:[(0,r.jsx)("div",{ref:G,"data-testid":O,onScroll:eJ,onKeyDown:eG,tabIndex:0,className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-3 py-3",children:(0,r.jsxs)(R.PZ,{value:eO,children:[d?(0,r.jsx)(q,{}):0===eH.length?Q?null:(0,r.jsx)(W,{}):0===eK.length?(0,r.jsx)("div",{"data-testid":"chat-transcript-fallback-list",id:ei?ed:void 0,children:eH.slice(0,I.JD).map((e,t)=>(0,r.jsx)("div",{children:e2(t)},e.key))}):(0,r.jsx)("div",{id:ei?ed:void 0,style:{height:eq.getTotalSize(),width:"100%",position:"relative"},children:eK.map(e=>(0,r.jsx)("div",{"data-index":e.index,ref:eq.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:"translateY(".concat(e.start,"px)")},children:e2(e.index)},e.key))}),Q&&(Q.settling?(0,r.jsx)(K,{turnKey:Q.turnKey,version:Q.version,body:Q.body,partial:Q.partial,showHeader:(0,I.CK)(Z[Z.length-1]),onFilePathClick:e0}):(0,r.jsx)(D,{turnKey:Q.turnKey,version:Q.version,body:Q.body,partial:Q.partial,isThinking:Q.isThinking,showHeader:(0,I.CK)(Z[Z.length-1]),onFilePathClick:e0})),ei&&(0,r.jsx)(U,{})]})}),eH.length>0&&(eg?(0,r.jsx)("button",{type:"button","data-testid":F,"data-direction":"top",onClick:e_,"aria-label":J("chatTranscript.jumpToTop"),title:J("chatTranscript.jumpToTop"),className:H,children:(0,r.jsx)(x.A,{size:16,"aria-hidden":"true"})}):(0,r.jsx)("button",{type:"button","data-testid":F,"data-direction":"latest","data-generating":e5?"true":void 0,onClick:eY,"aria-label":J(e5?"chatSurface.jumpToLatestGenerating":"chatSurface.jumpToLatest"),title:J(e5?"chatSurface.jumpToLatestGenerating":"chatSurface.jumpToLatest"),className:H,children:e5?(0,r.jsx)(i.A,{size:16,className:"animate-spin","aria-hidden":"true"}):(0,r.jsx)(o.A,{size:16,"aria-hidden":"true"})})),(0,r.jsxs)("div",{className:"pointer-events-none absolute right-2 top-2 z-10 flex items-start justify-end gap-1",children:[!ev&&(0,r.jsx)("div",{className:"pointer-events-auto",children:(0,r.jsx)("button",{type:"button","data-testid":"chat-transcript-tool-activity-toggle",onClick:ez,"aria-pressed":eP,"aria-label":J(eP?"chatTranscript.toolActivity.hide":"chatTranscript.toolActivity.show"),title:J(eP?"chatTranscript.toolActivity.hide":"chatTranscript.toolActivity.show"),className:["rounded-full border border-border p-1.5 shadow-sm backdrop-blur transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation",eP?"bg-accent-500/15 text-accent-700 hover:bg-accent-500/25 dark:text-accent-400":"bg-surface-2/80 text-muted-foreground hover:bg-muted hover:text-foreground"].join(" "),children:(0,r.jsx)(b.A,{size:14,"aria-hidden":"true"})})}),(0,r.jsx)("div",{className:"pointer-events-auto",children:ev?(0,r.jsx)(z.Y,{query:ey,onQueryChange:eI,matchCount:ew,currentIndex:ek,onNext:eA,onPrev:eL,onClose:eT,isAtMaxMatches:ej,onCompositionStart:eM,onCompositionEnd:eE}):(0,r.jsx)("button",{type:"button","data-testid":"chat-transcript-search-toggle",onClick:eS,"aria-label":J("chatTranscript.openSearch"),title:J("chatTranscript.openSearch"),className:"rounded-full border border-border bg-surface-2/80 p-1.5 text-muted-foreground shadow-sm backdrop-blur transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation",children:(0,r.jsx)(v.A,{size:14,"aria-hidden":"true"})})})]})]})});var Q=n(78596),Y=n(51515),_=n(16342);let J=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\[[0-9;]*m/g,G=/^(?:\x1b\[|\[)([0-9;]*)m$/,V=new Set([38,48,58]);function Z(e){let t;J.lastIndex=0;let n=[],r="",a=null,s=0,l=0,i=0;for(;null!==(t=J.exec(e));){let o=e.slice(i,t.index);r+=o,s+=(0,_.LQ)(o),i=t.index+t[0].length;let c=G.exec(t[0]);if(null===c)continue;let u=function(e,t){let n=(""===t?"0":t).split(";"),r=e;for(let e=0;e<n.length;e++){let t=Number(""===n[e]?"0":n[e]);if(Number.isFinite(t)){if(V.has(t)){let a="2"===n[e+1]?4:2*("5"===n[e+1]);a>0&&48===t&&(r=n.slice(e,e+1+a).join(";")),e+=a;continue}0===t||49===t?r=null:(t>=40&&t<=47||t>=100&&t<=107)&&(r=n[e])}}return r}(a,c[1]);u!==a&&(s>l&&n.push({bg:a,start:l,end:s}),a=u,l=s)}let o=e.slice(i);r+=o,(s+=(0,_.LQ)(o))>l&&n.push({bg:a,start:l,end:s});let c=new Set(n.map(e=>e.start));return n.length>0&&c.add(n[n.length-1].end),{text:r,segments:n,edges:c,width:s}}function X(e,t){for(let n of e.segments)if(n.start<=t&&t<n.end)return n.bg;return null}function ee(e){let t=new Set;for(let n of e.segments)null!==n.bg&&t.add(n.bg);return t}function et(e){let t=new Map;for(let r of e.segments){var n;null!==r.bg&&t.set(r.bg,(null!=(n=t.get(r.bg))?n:0)+(r.end-r.start))}let r=null,a=0;for(let[e,n]of t)n>a&&(r=e,a=n);return{bg:r,columns:a}}var en=n(18341),er=n(813);let ea=/\S[^\S\n]{2,}esc[^\S\n]*$/,es=/^[│┃╹]/;function el(e,t,n){if(!e.edges.has(t)||!e.edges.has(n))return!1;for(let r of e.segments)if(!(r.end<=t)&&!(r.start>=n)&&null===r.bg)return!1;return!(X(e,t-1)===X(e,t)||n<e.width&&X(e,n)===X(e,n-1)||es.test((0,_.Ml)(e.text,t-1,t)))&&!es.test((0,_.Ml)(e.text,t,n))}let ei=/^[^0-9A-Za-z]*([1-9])[.)]\s+\S/,eo=/\bs\s+to\s+use\s+this\s+session\s+only\b/i,ec=/\bEnter\s+to\s+set\s+as\s+default\b/i,eu=/\btype\s+to\s+search\b|\bsearch\s+\w+\s*(?:…|\.\.\.)|(?:^|·)\s*\/\s+search\b/im,ed=/\benter\s+to\s+select\b\s*[·•]\s*esc\s+to\s+cancel\b/i,em=/^\s*(?:press|hit|type)?\s*(?:<)?esc(?:ape)?(?:>)?\s+to\s+(?:close|dismiss|exit)\b[\s.·•]*$/im,ef=/^\u2500+$/,eh="●◉⦿",ep=new RegExp("^\\s*([".concat(eh).concat("◯○◌⚪","])\\s+\\S")),eg=/\besc\s+to\s+interrupt\b|^[^\S\n]*✻[^\S\n]+\S/im;function ex(e){let t=function(e){if(!e)return null;let t=e.replace(/\r\n/g,"\n").split("\n").map(Y.aJ),n=t.length-1;for(;n>=0&&""===t[n].trim();)n-=1;if(n<1)return null;let r=-1;for(let e=n-1;e>=0;e-=1){let n=t[e].trim();if(!(n.length<40)&&ef.test(n)){r=e;break}}if(r<0)return null;let a=t.slice(r+1,n+1),s=a.join("\n");if(eu.test(s)||ed.test(s)||em.test(s)||eg.test(s))return null;let l=a.findIndex(e=>""!==e.trim());if(l<0||!function(e){let t=e.split("|");if(t.length<2)return!1;let n=0,r=0;for(let e of t){let t=ep.exec(e);if(null===t)return!1;eh.includes(t[1])?n+=1:r+=1}return n>0&&r>0}(a[l]))return null;let i=[],o=-1;for(let e=l+1;e<a.length;e+=1){let t=ei.exec(a[e]);null!==t&&(o<0&&(o=e),i.push(Number(t[1])))}if(i.length<2||!a.slice(l+1,o).some(e=>""!==e.trim()))return null;let c=0,u=-1;for(let e=0;e<a.length;e+=1){let t=a[e].split("❯").length-1;0!==t&&(c+=t,ei.test(a[e])&&(u=e))}return 0===c||u<0?null:{ruleLineIndex:r,firstLineIndex:r+1,lastLineIndex:n,tabLineIndex:r+1+l,numbers:i,cursorCount:c,cursorLineIndex:r+1+u}}(e);return null!==t&&t.numbers.every((e,t)=>e===t+1)&&1===t.cursorCount?{ruleLineIndex:t.ruleLineIndex,firstLineIndex:t.firstLineIndex,lastLineIndex:t.lastLineIndex,tabLineIndex:t.tabLineIndex,cursorLineIndex:t.cursorLineIndex,optionCount:t.numbers.length}:null}let eb={optionCount:0,offersSessionScope:!1,commitsDefaultOnEnter:!1,hasFilterInput:!1},ev=[function(e){let t=function(e){let t=e.split("\n").map(Z),n=new Set,r=null;for(let e of t){if(!e.text.includes("esc"))continue;let a=[...e.edges].sort((e,t)=>e-t);for(let s of a)if(!(s<1))for(let l of a){if(l-s<16)continue;let a="".concat(s,":").concat(l);if(n.has(a)||!el(e,s,l))continue;let i=(0,_.Ml)(e.text,s,l);if(!ea.test(i))continue;n.add(a);let o=t.filter(e=>el(e,s,l));if(o.length<3)continue;let c=o.indexOf(e);c<0||c>=3||(null===r||o.length>r.rows)&&(r={id:"opencode_modal_overlay",headerText:(0,er.D)(i.trim(),200,"…[truncated]"),left:s,right:l,rows:o.length,headerRow:c,frameRowStart:t.indexOf(o[0]),frameRowEnd:t.indexOf(o[o.length-1])})}}return r}(e);return null===t?null:e.split("\n").slice(t.frameRowStart,t.frameRowEnd+1).join("\n")},function(e){let t=e.replace(/\r\n/g,"\n").split("\n"),n=-1;for(let e=t.length-1;e>=0;e-=1)if(ed.test((0,Y.aJ)(t[e]))){n=e;break}if(n<0){let n=ex(e);return null===n?null:t.slice(n.firstLineIndex,n.lastLineIndex+1).join("\n")}for(let e=n-1;e>=0;e-=1){let r=(0,Y.aJ)(t[e]).trim();if(!(r.length<40)&&ef.test(r))return t.slice(e+1,n+1).join("\n")}return null}];function ey(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return"";let n=e.replace(/\r\n/g,"\n");if(t.selectionList)for(let e of ev){let t=e(n);if(null===t)continue;let r=(0,en.Uw)(t,{isStructuralRow:en.CG});if(""!==r)return r}let r=(0,en.Uw)(n,{isStructuralRow:en.CG});if(""===r)return"";if(t.selectionList)return r;let a=r.split("\n"),s=function(e){if(void 0===e||!Number.isFinite(e))return 16;let t=Math.trunc(e);return t<12?12:t>20?20:t}(t.maxLines);return a.slice(-s).join("\n")}let ew=/^[^\S\n]*[❯›●][^\S\n]/;function ek(e){let{frame:t,maxLines:n=16,maxHeightClassName:l="max-h-64",actions:i,reason:o,className:c=""}=e,u=(0,s.c)("worktree"),d="selectionList"===o,m=(0,a.useMemo)(()=>ey(t,{maxLines:n,selectionList:d}),[t,n,d]),f=(0,a.useMemo)(()=>m?(0,Q.l5)(m):"",[m]),h=(0,a.useRef)(null),p=(0,a.useMemo)(()=>d&&m?function(e){let t=e.split("\n"),n=-1;for(let e=t.length-1;e>=0;e-=1)if(ew.test((0,Y.aJ)(t[e]))){n=e;break}return Math.max(n,function(e){let t=e.map(Z),n=t.map(et),r=t.map(ee);for(let e=t.length-1;e>=0;e-=1){let{bg:a,columns:s}=n[e];if(!(null===a||s<8||e>0&&r[e-1].has(a))&&!(e+1<t.length&&r[e+1].has(a)))return e}return -1}(t))}(m):-1,[d,m]);return((0,a.useLayoutEffect)(()=>{if(p<0)return;let e=h.current;if(!e)return;let t=(0,Y.aJ)(m).split("\n").length;if(t<=1)return;let n=e.scrollHeight-e.clientHeight;if(n<=0)return;let r=window.getComputedStyle(e),a=Number.parseFloat(r.paddingTop)||0,s=Number.parseFloat(r.paddingBottom)||0,l=Math.max(0,e.scrollHeight-a-s)/t,i=a+p*l-(e.clientHeight-l)/2;e.scrollTop=Math.min(n,Math.max(0,i))},[p,m]),m)?(0,r.jsxs)("div",{"data-testid":"chat-dialog-card","data-reason":o,role:"group","aria-label":u("chatSurface.dialogCardLabel"),className:["flex min-w-0 flex-col gap-2",c].filter(Boolean).join(" "),children:[(0,r.jsx)("div",{ref:h,"data-testid":"chat-dialog-card-frame",className:"overflow-auto rounded-lg border border-border bg-terminal-surface p-2 font-mono text-[11px] leading-snug text-terminal-foreground ".concat(l),children:(0,r.jsx)("div",{className:"whitespace-pre w-max",dangerouslySetInnerHTML:{__html:f}})}),i?(0,r.jsx)("div",{"data-testid":"chat-dialog-card-actions",className:"min-w-0",children:i}):null]}):null}var ej=n(60734),eN=n(73190),eC=n(51021),eS=n(56827),eT=n(49509);let eI=[{key:"1",label:"1",ariaLabel:"Send 1"},{key:"2",label:"2",ariaLabel:"Send 2"},{key:"3",label:"3",ariaLabel:"Send 3"},{key:"4",label:"4",ariaLabel:"Send 4"},{key:"5",label:"5",ariaLabel:"Send 5"},{key:"6",label:"6",ariaLabel:"Send 6"},{key:"7",label:"7",ariaLabel:"Send 7"},{key:"8",label:"8",ariaLabel:"Send 8"},{key:"9",label:"9",ariaLabel:"Send 9"}],eM=[{key:"y",label:"y",ariaLabel:"Send y"},{key:"n",label:"n",ariaLabel:"Send n"},{key:"Enter",label:"↵",ariaLabel:"Send Enter"}],eE="Escape";function eA(e){let{worktreeId:t,cliToolId:n,instanceId:l,onKeysSent:i}=e,o=(0,s.c)("worktree"),{activeKey:c,markPressed:u}=(0,eT.t)(),d=(0,eS.B)(t,n,l,i),m=(0,a.useCallback)(e=>{u(e),d([e])},[u,d]);return(0,r.jsxs)("div",{"data-testid":"prompt-answer-keys",role:"toolbar","aria-label":o("promptAnswerKeys.toolbarLabel"),className:"flex flex-wrap items-center gap-1.5 rounded-lg bg-muted px-2 py-1.5",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:o("promptAnswerKeys.caption")}),[...eI,...eM].map(e=>{let{key:t,label:n,ariaLabel:a}=e;return(0,r.jsx)("button",{type:"button","data-testid":"prompt-answer-key-".concat(t),"aria-label":a,onClick:()=>m(t),className:"min-h-[44px] min-w-[44px] rounded-md border border-border px-3 py-2 text-sm font-medium transition-colors duration-75 touch-manipulation focus:outline-none focus:ring-2 focus:ring-ring ".concat(c===t?"border-accent-500 bg-accent-500 text-white scale-95":"bg-surface hover:bg-muted active:bg-muted dark:bg-surface-2"),children:n},t)})]})}function eL(e){let{worktreeId:t,cliToolId:n,instanceId:l,onKeysSent:i,optionCount:o}=e,c=(0,s.c)("worktree"),{activeKey:u,markPressed:d}=(0,eT.t)(),m=(0,eS.B)(t,n,l,i),f=(0,a.useMemo)(()=>{let e=Math.min(Math.trunc(o),9);return!Number.isFinite(e)||e<1?[]:eI.slice(0,e)},[o]),h=(0,a.useCallback)(e=>{d(e),m([e])},[d,m]);return 0===f.length?null:(0,r.jsxs)("div",{"data-testid":"selection-number-keys","data-option-count":String(f.length),role:"toolbar","aria-label":c("selectionKeys.numbersToolbarLabel"),className:"flex flex-wrap items-center gap-1.5 rounded-lg bg-muted px-2 py-1.5",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:c("selectionKeys.numbersCaption")}),f.map(e=>{let{key:t,label:n,ariaLabel:a}=e;return(0,r.jsx)("button",{type:"button","data-testid":"selection-number-key-".concat(t),"aria-label":a,onClick:()=>h(t),className:"min-h-[44px] min-w-[44px] rounded-md border border-border px-3 py-2 text-sm font-medium transition-colors duration-75 touch-manipulation focus:outline-none focus:ring-2 focus:ring-ring ".concat(u===t?"border-accent-500 bg-accent-500 text-white scale-95":"bg-surface hover:bg-muted active:bg-muted dark:bg-surface-2"),children:n},t)})]})}function eR(e){let{worktreeId:t,cliToolId:n,instanceId:l,onKeysSent:i,commitsDefaultOnEnter:o}=e,c=(0,s.c)("worktree"),{activeKey:u,markPressed:d}=(0,eT.t)(),m=(0,eS.B)(t,n,l,i),f=(0,a.useCallback)(e=>{d(e),m([e])},[d,m]);return(0,r.jsxs)("div",{"data-testid":"selection-commit-keys",role:"toolbar","aria-label":c("selectionKeys.commitToolbarLabel"),className:"flex flex-wrap items-center gap-1.5 rounded-lg bg-muted px-2 py-1.5",children:[(0,r.jsx)("button",{type:"button","data-testid":"selection-commit-session","aria-label":c("selectionKeys.sessionOnlyAria"),title:c("selectionKeys.sessionOnlyAria"),onClick:()=>f(eC.mE),className:"min-h-[44px] rounded-md border px-3 py-2 text-sm font-medium transition-colors duration-75 touch-manipulation focus:outline-none focus:ring-2 focus:ring-ring ".concat(u===eC.mE?"border-accent-500 bg-accent-500 text-white scale-95":"border-accent-500 bg-surface text-accent-600 hover:bg-muted active:bg-muted dark:bg-surface-2 dark:text-accent-400"),children:c("selectionKeys.sessionOnly")}),(0,r.jsx)("button",{type:"button","data-testid":"selection-commit-default","aria-label":c("selectionKeys.setDefaultAria"),title:c("selectionKeys.setDefaultAria"),onClick:()=>f("Enter"),className:"min-h-[44px] rounded-md border border-border px-3 py-2 text-sm font-medium transition-colors duration-75 touch-manipulation focus:outline-none focus:ring-2 focus:ring-ring ".concat("Enter"===u?"border-accent-500 bg-accent-500 text-white scale-95":"bg-surface hover:bg-muted active:bg-muted dark:bg-surface-2"),children:c("selectionKeys.setDefault")}),o?(0,r.jsx)("p",{"data-testid":"selection-commit-warning",className:"w-full text-xs text-muted-foreground",children:c("selectionKeys.defaultWarning")}):null]})}function eP(e){let{worktreeId:t,cliToolId:n,instanceId:l,onKeysSent:i}=e,o=(0,s.c)("worktree"),{activeKey:c,markPressed:u}=(0,eT.t)(),d=(0,eS.B)(t,n,l,i),m=(0,a.useCallback)(()=>{u(eE),d([eE])},[u,d]);return(0,r.jsx)("div",{"data-testid":"dismiss-panel-keys",role:"toolbar","aria-label":o("dismissPanelKeys.toolbarLabel"),className:"flex flex-wrap items-center gap-1.5 rounded-lg bg-muted px-2 py-1.5",children:(0,r.jsx)("button",{type:"button","data-testid":"dismiss-panel-key-Escape","aria-label":o("dismissPanelKeys.closeAria"),title:o("dismissPanelKeys.closeAria"),onClick:m,className:"min-h-[44px] rounded-md border px-3 py-2 text-sm font-medium transition-colors duration-75 touch-manipulation focus:outline-none focus:ring-2 focus:ring-ring ".concat(c===eE?"border-accent-500 bg-accent-500 text-white scale-95":"border-accent-500 bg-surface text-accent-600 hover:bg-muted active:bg-muted dark:bg-surface-2 dark:text-accent-400"),children:o("dismissPanelKeys.close")})})}[...eI.map(e=>e.key),...eM.map(e=>e.key)];var eD=n(40240),ez=n(68276),eO=n(60199),eF=n(52703);let eH='[data-testid="'.concat(O,'"]'),eq={pager:"chatSurface.reasonPager",selectionList:"chatSurface.reasonSelectionList",dismissablePanel:"chatSurface.reasonDismissablePanel",unclassified:"chatSurface.reasonUnclassified",promptUnreadable:"chatSurface.reasonPromptUnreadable"},eK=(0,a.memo)(function(e){var t,n;let{messages:m,worktreeId:f,worktreePath:h,cliToolId:p,instanceId:g,live:x,onSurfaceModeChange:b,frame:v,onKeysSent:y,compact:w=!1,history:k,className:j=""}=e,N=(0,s.c)("worktree"),C=(0,a.useRef)(null),S=(0,a.useMemo)(()=>(function(e){let t=new Map;for(let n of e)t.set(n.id,n);return t.size===e.length?e:Array.from(t.values())})(m),[m]),I=!1===x.attaching&&!1===x.isRunning,M=(0,a.useRef)(!0),E=(0,a.useRef)(-1),[A,L]=(0,a.useState)(!1),[R,P]=(0,a.useState)(!0),D=(0,a.useCallback)(()=>{var e,t;return null!=(t=null==(e=C.current)?void 0:e.querySelector(eH))?t:null},[]),[z,O]=(0,a.useState)(!1),F=(0,a.useCallback)(e=>{O(null!==e)},[]),H=(0,a.useCallback)(()=>{let e=D();e&&(e.scrollTop=e.scrollHeight),M.current=!0,P(!0),L(!1)},[D]);(0,a.useEffect)(()=>{let e=D();if(!e)return;let t=()=>{let t=(0,T.Mp)({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight});M.current=t,P(t),t&&L(!1)};return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[D,null==k?void 0:k.isLoading]),(0,a.useLayoutEffect)(()=>{let e=E.current,t=S.length;if(E.current=t,-1!==e&&!(t<=e)){if(M.current){let e=D();e&&(e.scrollTop=e.scrollHeight);return}L(!0)}},[S.length,D]);let q="running"===x.sessionStatus,K=function(e){let{worktreeId:t,cliToolId:n,instanceId:r,enabled:s=!0}=e,{addListener:l,connected:i}=(0,eO.xM)(),[o,c]=(0,a.useState)(null),u=(0,a.useRef)(0),d=null!=r?r:n;(0,a.useEffect)(()=>{u.current=0,c(null)},[t,n,d]),(0,a.useEffect)(()=>{s&&(u.current=0,c(null))},[s]),(0,a.useEffect)(()=>{!i&&s&&(u.current=0,c(null))},[i,s]),(0,a.useEffect)(()=>{if(s||null===o)return;let e=setTimeout(()=>c(null),6e5);return()=>clearTimeout(e)},[s,o]),(0,a.useEffect)(()=>{if(s&&void 0!==n)return l(e=>{e.type===eF.rz&&void 0!==n&&void 0!==d&&e.worktreeId===t&&e.cliToolId===n&&e.instanceId===d&&"string"==typeof e.turnKey&&0!==e.turnKey.length&&"string"==typeof e.body&&"number"==typeof e.version&&Number.isFinite(e.version)&&(e.version<=u.current||(u.current=e.version,c({turnKey:e.turnKey,body:e.body,partial:!0===e.partial,version:e.version,settling:!1})))})},[l,s,t,n,d]);let m=(0,a.useMemo)(()=>null===o?null:{...o,settling:!0},[o]);return s?i?o:null:m}({worktreeId:f,cliToolId:p,instanceId:g,enabled:q}),B=S.length?S[S.length-1].id:null,U=(null==K?void 0:K.settling)===!0,W=(0,a.useRef)(null),[Q,_]=(0,a.useState)(!1);(0,a.useEffect)(()=>{if(!U){W.current=null,_(!1);return}if(null===W.current){W.current={id:B};return}W.current.id!==B&&_(!0)},[U,B]);let[J,G]=(0,a.useState)(null);(0,a.useEffect)(()=>{I&&null!==K&&G(K.turnKey)},[I,K]);let V=null===K||K.turnKey===J||function(e,t){for(let n=e.length-1;n>=0;n-=1)if(e[n].requestId===t)return!0;return!1}(S,K.turnKey)||K.settling&&Q?null:K,Z=(0,a.useMemo)(()=>I?null:null!==V?{turnKey:V.turnKey,version:V.version,body:V.body,partial:V.partial,isThinking:!V.settling&&!0===x.isThinking,settling:V.settling}:q?{isThinking:!0===x.isThinking}:null,[V,q,x.isThinking,I]),X=null!==Z,ee=X&&!0!==Z.settling,et=(0,a.useRef)(!1);(0,a.useLayoutEffect)(()=>{if(!et.current){et.current=!0;return}if(!M.current)return;let e=D();e&&(e.scrollTop=e.scrollHeight)},[null==V?void 0:V.body,X,D]);let en=x.isPagerActive?"pager":x.isSelectionListActive?"selectionList":(null!=(n=x.isDismissablePanelActive)?n:function(e){if(!e)return!1;let t=(0,Y.aJ)(e.replace(/\r\n/g,"\n")).split("\n"),n=t.length-1;for(;n>=0&&""===t[n].trim();)n-=1;return!(n<0)&&t.slice(Math.max(0,n+1-15),n+1).some(e=>em.test(e))}(v))?"dismissablePanel":x.isUnclassifiedActive?"unclassified":x.isPromptWaiting&&!(0,ez.XF)(x.promptData)?"promptUnreadable":null,er=(0,a.useCallback)(()=>{b("terminal")},[b]),ea=(0,a.useRef)(null);(0,a.useEffect)(()=>()=>{null!==ea.current&&clearTimeout(ea.current)},[]);let es=(0,a.useCallback)(()=>{null==y||y(),null!==ea.current&&clearTimeout(ea.current),ea.current=setTimeout(()=>{ea.current=null,null==y||y()},400)},[y]),el=(0,a.useMemo)(()=>"selectionList"===en?function(e){if(!e)return eb;let t=function(e){let t=(0,Y.aJ)(e.replace(/\r\n/g,"\n")).split("\n"),n=t.length-1;for(;n>=0&&""===t[n].trim();)n-=1;return n<0?[]:t.slice(Math.max(0,n+1-40),n+1)}(e);if(0===t.length)return eb;let n=t.join("\n");return{optionCount:function(e){let t=0,n=0;for(let r of e){let e=ei.exec(r);if(null===e)continue;let a=Number(e[1]);a===n+1?(n=a,t=a):1===a?(n=1,t=1):n=0}return Math.min(t,9)}(t),offersSessionScope:eo.test(n),commitsDefaultOnEnter:ec.test(n),hasFilterInput:eu.test(n)}}(v):null,[en,v]),ed=(0,a.useMemo)(()=>"selectionList"===en&&null!==ex(v),[en,v]),ef=(0,a.useMemo)(()=>"selectionList"===en&&v?ey(v,{selectionList:!0}).split("\n").length:0,[en,v]),eh=(0,a.useMemo)(()=>{if(null===en||!p)return null;let e={worktreeId:f,cliToolId:p,instanceId:g,onKeysSent:es};switch(en){case"pager":return(0,r.jsx)(ej.y,{...e,showPagerKeys:!0});case"selectionList":{var t;let n=(null==el?void 0:el.offersSessionScope)===!0&&eC.qL.includes(p);return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(ej.y,{...e}),!el||ed||!((t=el).optionCount>0)||t.offersSessionScope||t.hasFilterInput?null:(0,r.jsx)(eL,{...e,optionCount:el.optionCount}),n&&el?(0,r.jsx)(eR,{...e,commitsDefaultOnEnter:el.commitsDefaultOnEnter}):null,(0,r.jsx)(eD.tY,{worktreeId:f,cliToolId:p,instanceId:g,onKeysSent:es})]})}case"dismissablePanel":return(0,r.jsx)(eP,{...e});case"unclassified":return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(eN.U,{...e}),(0,r.jsx)(eA,{...e})]});case"promptUnreadable":return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{"data-testid":"chat-surface-unreadable-hint",className:"text-xs text-muted-foreground",children:N("chatSurface.unreadableHint")}),(0,r.jsx)(eA,{...e})]})}},[en,p,f,g,es,el,ed,N]),ep=null!=k?k:{},eg=(0,u.UI)(f),ev=null!=(t=null!=g?g:p)?t:null,ew=(0,a.useMemo)(()=>ev?(0,d.y)((0,d.g)({owed:eg.owedBy(ev),awaiting:eg.awaitedBy(ev),aliasOf:e=>e.worktreeId===f?e.instanceId:"".concat(e.instanceId," @ ").concat(e.worktreeId)})):null,[eg,ev,f]);return(0,r.jsxs)("div",{ref:C,"data-testid":"chat-surface","data-instance-id":null!=g?g:p,className:["flex h-full min-h-0 w-full flex-col overflow-hidden bg-surface text-surface-foreground",j].filter(Boolean).join(" "),children:[ew&&(0,r.jsxs)("div",{"data-testid":"chat-surface-relay","data-relay-tone":ew.tone,role:"status",className:"flex shrink-0 items-center gap-1.5 border-b border-border px-3 py-1 text-xs ".concat("prompt"===ew.tone?"bg-warning-subtle text-warning-foreground":"bg-surface-2 text-muted-foreground"),children:[(0,r.jsx)(l.A,{size:12,className:"shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:N("relay.".concat(ew.key),ew.params)})]}),(0,r.jsxs)("div",{className:"relative min-h-0 flex-1 overflow-hidden",children:[(0,r.jsx)($,{...ep,messages:S,worktreeId:f,worktreePath:h,cliToolId:p,liveTurn:Z,instanceId:g,sessionEnded:I,onScrollControlsChange:F,className:"h-full"}),!z&&(A||X&&!R)&&(0,r.jsxs)("button",{type:"button","data-testid":"chat-surface-new-messages","data-generating":ee?"true":void 0,onClick:H,"aria-label":ee?N("chatSurface.jumpToLatestGenerating"):void 0,className:"absolute bottom-3 left-1/2 z-10 flex min-h-[36px] -translate-x-1/2 items-center gap-1.5 rounded-full border border-border bg-surface-2 px-3 py-1.5 text-xs font-medium text-foreground shadow-lg transition-colors hover:bg-muted focus:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation",children:[ee?(0,r.jsx)(i.A,{size:14,className:"animate-spin","aria-hidden":"true"}):(0,r.jsx)(o.A,{size:14,"aria-hidden":"true"}),N("chatSurface.jumpToLatest")]})]}),null!==en&&(0,r.jsxs)("div",{"data-testid":"chat-surface-live",role:"group","aria-label":N("chatSurface.liveRegionLabel"),className:"flex shrink-0 flex-col gap-2 border-t border-border bg-surface px-3 py-2",children:[(0,r.jsxs)("div",{"data-testid":"chat-surface-terminal-banner","data-reason":en,role:"status","aria-label":N("chatSurface.bannerLabel"),className:"flex flex-wrap items-center gap-2 rounded-lg border border-warning-border bg-warning-subtle px-2 py-1.5",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 text-xs text-foreground",children:N(eq[en])}),(0,r.jsxs)("button",{type:"button","data-testid":"chat-surface-open-terminal",onClick:er,className:"flex min-h-[32px] shrink-0 items-center gap-1 rounded-md border border-warning-border bg-surface px-2 py-1 text-xs font-medium text-warning-foreground transition-colors hover:bg-muted focus:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation",children:[(0,r.jsx)(c.A,{size:14,"aria-hidden":"true"}),N("chatSurface.openTerminal")]})]}),v?(0,r.jsx)(ek,{frame:v,reason:en,maxLines:w?12:void 0,maxHeightClassName:ef>24?"max-h-[35vh]":w?"max-h-32":"max-h-64",actions:eh}):null]})]})})},87364:(e,t,n)=>{n.d(t,{t:()=>l});var r=n(95155),a=n(12115),s=n(18955);class l extends a.Component{static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){var n,r;console.error("[ErrorBoundary:".concat(this.props.componentName||"unknown","]"),e,t),null==(n=(r=this.props).onError)||n.call(r,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,r.jsx)(i,{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 i(e){let{componentName:t,error:n,onRetry:a}=e,l=(0,s.c)("error"),i=(0,s.c)("common");return(0,r.jsxs)("div",{className:"p-4 bg-danger-subtle border border-danger-border rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-danger-foreground 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?l("boundary.errorOccurredIn",{componentName:t}):l("boundary.errorOccurred")})]}),n&&(0,r.jsx)("p",{className:"text-sm text-danger-foreground/80 mb-3",children:n.message}),a&&(0,r.jsx)("button",{onClick:a,className:"px-4 py-2 bg-danger-foreground text-danger-subtle rounded hover:opacity-90 transition-opacity text-sm",children:i("retry")})]})}},88731:(e,t,n)=>{n.d(t,{UK:()=>l,dl:()=>r,gP:()=>i,v8:()=>a,wP:()=>s});let r=[50,100,150,200,250,500,1e3],a=50,s="commandmate:historyDisplayLimit";function l(e){return r.includes(e)}let i="commandmate:historyUserOnly"},89568:(e,t,n)=>{n.d(t,{B7:()=>s,CK:()=>f,JD:()=>i,ML:()=>m,UY:()=>u,hM:()=>l});var r=n(4300),a=n(92147);let s=8,l=120,i=40,o={variant:"none",startedAtMs:null};function c(e){var t,n;return"".concat(null!=(t=e.cliToolId)?t:"","|").concat(null!=(n=e.instanceId)?n:"")}function u(e){let t,n=function(e){let t=[],n=[],r=[],s=!1,l=()=>{t.push(...n,...r),n=[],r=[]};for(let i of e){if("user"===i.role&&!(0,a.nY)(i)){l(),t.push(i);continue}if(!(0,a.nY)(i)){r.push(i);continue}r.length>0&&(s=!0),n.push(i)}return l(),s?t:e}(e),s=function(e){let t=new Map;for(let n of e){if("user"!==n.role||(0,a.nY)(n)||n.optimisticState||n.archived)continue;let e=n.requestId;if("string"!=typeof e||0===e.length)continue;if(t.has(e)){t.set(e,null);continue}let r=n.timestamp instanceof Date?n.timestamp.getTime():NaN;t.set(e,Number.isFinite(r)?{atMs:r,scope:c(n)}:null)}return t}(n),l=[],i=function(e){let t=new Map,n=0,r=!1;for(let s of e){if(!(0,a.nY)(s)){r=!1;continue}r||(n+=1,r=!0),t.has(s.id)||t.set(s.id,n)}return t}(e),u=[],d=null,m=null,f=()=>{0!==u.length&&(l.push({kind:"approvals",key:"approvals:".concat(u[0].id),entries:(0,a.GV)(u,{runIds:i})}),u=[])};for(let e of n){var h;if((0,a.nY)(e)){u.push(e);continue}f();let n=!(h=t)||h.role!==e.role,i=o;if("assistant"!==e.role)d=null,m=null,n&&(i={variant:"role",startedAtMs:null});else{let t=c(e);(n||m!==t)&&(d=null),m=t;let a=(0,r.Qu)(e.requestId),l=function(e,t,n){if(null===t)return null;let a=(0,r.QN)(t);if(null===a)return null;let s=n.get(a);if(!s||s.scope!==c(e))return null;let l=e.timestamp instanceof Date?e.timestamp.getTime():NaN;return!Number.isFinite(l)||s.atMs>l?null:s.atMs}(e,a,s);n?i={variant:"role",startedAtMs:l}:null!==a&&null!==d&&a!==d&&(i={variant:"time",startedAtMs:l}),null!==a&&(d=a)}l.push({kind:"message",key:e.id,message:e,showHeader:n,header:i}),t=e}return f(),l}let d=/(^|[\s`"'(\[<(「『【])(\/[^\s\n<>"']+\.[a-zA-Z0-9]+)/g;function m(e){if("string"!=typeof e||0===e.length)return[{type:"text",content:""}];let t=[],n=0;for(let s of e.matchAll(d)){var r,a;let l=null!=(r=s[1])?r:"",i=s[2];if(!i)continue;let o=(null!=(a=s.index)?a:0)+l.length;o>n&&t.push({type:"text",content:e.slice(n,o)}),t.push({type:"path",content:i}),n=o+i.length}return 0===t.length?[{type:"text",content:e}]:(n<e.length&&t.push({type:"text",content:e.slice(n)}),t)}function f(e){return!e||"assistant"!==e.role}},92147:(e,t,n)=>{n.d(t,{GV:()=>N,rS:()=>C,nY:()=>y});var r=n(68276),a=n(3648);function s(){let e=(0,a._)(["←s*(?:[☐☒☑][^←→☐☒☑✔]*)+✔s*Submits*→"],["←\\s*(?:[☐☒☑][^←→☐☒☑✔]*)+✔\\s*Submit\\s*→"]);return s=function(){return e},e}let l=String.raw(s()),i=new RegExp("^".concat(l,"\\s*"));new RegExp("^\\s?".concat(l,"$"));let o=/\s*Ready to submit your answers\?\s*$/,c=/^Review your answers\s*/,u=/●\s*([^●→]+)/g,d=/^submit answers$/i,m=/^cancel$/i,f={human:5,auto:4,terminal:3,pending:2,unclassified:1,unknown:0};function h(e){return"object"==typeof e&&null!==e?e:null}function p(e,t){let n=null==e?void 0:e[t];return"string"==typeof n?n:""}function g(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if("string"==typeof n){t.push(n);continue}let e=p(h(n),"label");e&&t.push(e)}return t}function x(e){return e.replace(/\s+/g," ").trim()}function b(e){return e.length<=160?e:"".concat(e.slice(0,159).trimEnd(),"…")}function v(e){return x(e).replace(i,"").trim()}function y(e){return(null==e?void 0:e.messageType)==="prompt"}function w(e){let t=null==e?void 0:e.summary;return"string"==typeof t&&t.startsWith("PermissionRequest allow")}function k(e){return{...e,messageIds:[...e.messageIds],reviewQuestions:[...e.reviewQuestions]}}function j(e,t,n){if(e<=0||t<=0)return!1;let r=t-e;return r>=0&&r<=n}function N(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{windowMs:n=5e3,runIds:a}=t;return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3,n=[];for(let r of e){if("question"===r.kind){let e=n[n.length-1];if("confirmation"===r.phase){if(e&&"question"===e.kind&&"question"===e.phase&&e.scopeKey===r.scopeKey&&e.runId===r.runId&&""!==e.questionText&&r.reviewQuestions.includes(e.questionText)&&j(e.timestampMs,r.timestampMs,t)){e.messageIds.push(...r.messageIds),e.confirmationOutcome=r.outcome;continue}n.push(k(r));continue}if(e&&"question"===e.kind&&"question"===e.phase&&""!==r.mergeKey&&e.mergeKey===r.mergeKey&&e.runId===r.runId&&j(e.timestampMs,r.timestampMs,t)){e.messageIds.push(...r.messageIds),e.label||(e.label=r.label),f[r.outcome]>f[e.outcome]&&(e.outcome=r.outcome);continue}n.push(k(r));continue}let e=r.mergeKey?n.find(e=>"approval"===e.kind&&e.mergeKey===r.mergeKey&&Math.abs(r.timestampMs-e.timestampMs)<=t):void 0;if(!e){n.push(k(r));continue}e.messageIds.push(...r.messageIds),e.isPermissionAudit=e.isPermissionAudit||r.isPermissionAudit,e.label||(e.label=r.label),f[r.outcome]>f[e.outcome]&&(e.outcome=r.outcome)}return n}(e.map(e=>{var t;return function(e){let t,n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=h(e.promptData),l=w(e),i=p(s,"question"),f=p(s,"approvalTarget"),y=p(s,"answeredBy"),k=p(s,"status"),j=p(s,"type"),N="string"==typeof e.summary?e.summary:"",C=function(e,t){let n=v(e),r=o.test(n),a=g(t),s=n.replace(o,"").replace(c,"").trim();return{hasTail:r,hasSubmitOptions:a.some(e=>d.test(e.trim()))&&a.some(e=>m.test(e.trim())),reviewQuestions:[...s.matchAll(u)].map(e=>{var t;return(null!=(t=e[1])?t:"").trim()}).filter(e=>e.length>0)}}(i,null==s?void 0:s.options),{kind:S,phase:T}=w(e)?{kind:"approval"}:(null==s?void 0:s.isAskUserQuestion)===!0?{kind:"question",phase:C.hasTail||C.hasSubmitOptions?"confirmation":"question"}:C.hasTail&&(C.hasSubmitOptions||C.reviewQuestions.length>0)?{kind:"question",phase:"confirmation"}:{kind:"approval"};t=l?"auto":"auto"===y||"human"===y||"terminal"===y?y:j===r.LT||"unclassified"===k?"unclassified":"pending"===k?"pending":"unknown";let I=function(e){let t="string"==typeof e.cliToolId&&e.cliToolId?e.cliToolId:"claude",n="string"==typeof e.instanceId&&e.instanceId?e.instanceId:t;return JSON.stringify(["string"==typeof e.worktreeId?e.worktreeId:"",t,n])}(e),M="question"===S&&"question"===T,E=M?v(i):"",A="question"===S&&"confirmation"===T&&1===C.reviewQuestions.length?C.reviewQuestions[0]:"";n="question"===S?b(M?E:A):b(x(i||N));let L="";if(M){let e=h(null==s?void 0:s.askUserQuestion),t="number"==typeof(null==e?void 0:e.questionIndex)?e.questionIndex:null;L=E?JSON.stringify(["question",I,E,t,g(null==s?void 0:s.options)]):""}else"approval"===S&&(L=i?JSON.stringify([i,f]):"");return{id:e.id,messageIds:[e.id],label:n,outcome:t,isPermissionAudit:l,timestampMs:function(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:0}if("string"==typeof e||"number"==typeof e){let t=new Date(e).getTime();return Number.isFinite(t)?t:0}return 0}(e.timestamp),mergeKey:L,kind:S,...T?{phase:T}:{},questionText:E,reviewQuestions:C.reviewQuestions,scopeKey:I,runId:a}}(e,null!=(t=null==a?void 0:a.get(e.id))?t:0)}),n)}function C(e){let t=0,n=0,r=0;for(let a of e)"question"!==a.kind?t+=1:"confirmation"===a.phase?r+=1:n+=1;return{approvals:t,questions:n,confirmations:r,total:e.length}}},92710:(e,t,n)=>{n.d(t,{Y:()=>i});var r=n(95155),a=n(12115),s=n(18955),l=n(78660);function i(e){let{query:t,onQueryChange:n,matchCount:i,currentIndex:o,onNext:c,onPrev:u,onClose:d,isAtMaxMatches:m,onCompositionStart:f,onCompositionEnd:h}=e,p=(0,a.useRef)(null),g=(0,s.c)("worktree");(0,a.useEffect)(()=>{var e;null==(e=p.current)||e.focus()},[]);let x=(0,a.useCallback)(e=>{"Escape"===e.key&&d()},[d]),b=(0,a.useCallback)(e=>{n(e.target.value)},[n]),v=0===i?"0/0":m?g("history.search.countAtMax",{current:o+1,max:l.F0}):"".concat(o+1,"/").concat(i);return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-surface border border-border rounded shadow-lg",role:"search","aria-label":g("history.search.regionLabel"),children:[(0,r.jsx)("input",{ref:p,type:"text",value:t,onChange:b,onKeyDown:x,onCompositionStart:f,onCompositionEnd:h,placeholder:g("history.search.placeholder"),className:"bg-transparent text-foreground text-sm outline-none w-32 sm:w-40 placeholder-muted-foreground","aria-label":g("history.search.keywordLabel"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,r.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"text-muted-foreground text-xs min-w-[3rem] text-right",children:v}),(0,r.jsx)("button",{type:"button",onClick:u,disabled:0===i,"aria-label":g("history.search.prev"),className:"text-muted-foreground hover:text-foreground disabled:opacity-40 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▲"}),(0,r.jsx)("button",{type:"button",onClick:c,disabled:0===i,"aria-label":g("history.search.next"),className:"text-muted-foreground hover:text-foreground disabled:opacity-40 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▼"}),(0,r.jsx)("button",{type:"button",onClick:d,"aria-label":g("history.search.close"),className:"text-muted-foreground hover:text-foreground min-w-[36px] min-h-[36px] flex items-center justify-center text-base ml-1",children:"✕"})]})}},95342:(e,t,n)=>{function r(e){let t=[],n=e.awaiting.filter(e=>"prompt"===e.state);n.length>0&&t.push({tone:"prompt",key:"badgePrompt",params:{count:n.length,alias:e.aliasOf(n[0].to)},titleKey:"promptTitle",count:n.length});let r=e.awaiting.filter(e=>"prompt"!==e.state);return 1===r.length?t.push({tone:"awaiting",key:"badgeAwaiting",params:{alias:e.aliasOf(r[0].to)},titleKey:"awaitingTitle",count:1}):r.length>1&&t.push({tone:"awaiting",key:"badgeAwaitingMany",params:{count:r.length},titleKey:"awaitingTitle",count:r.length}),1===e.owed.length?t.push({tone:"owed",key:"badgeOwed",params:{alias:e.aliasOf(e.owed[0].from)},titleKey:"owedTitle",count:1}):e.owed.length>1&&t.push({tone:"owed",key:"badgeOwedMany",params:{count:e.owed.length},titleKey:"owedTitle",count:e.owed.length}),t}function a(e){if(0===e.length)return null;let[t]=e,n="prompt"===t.tone?"stripPrompt":"owed"===t.tone?"stripOwed":t.count>1?"stripAwaitingMany":"stripAwaiting";return{...t,key:n}}n.d(t,{g:()=>r,y:()=>a})},96802:(e,t,n)=>{n.d(t,{Mp:()=>l,__:()=>a,b:()=>r,vC:()=>s});let r=6,a=160,s=30;function l(e){let{scrollTop:t,scrollHeight:n,clientHeight:r}=e,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:80,s=n-t-r;return!!Number.isFinite(s)&&s<=a}}}]);
|