commandmate 0.32.0 → 0.33.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 +159 -159
- package/.next/app-path-routes-manifest.json +28 -28
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +12 -12
- 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_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_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.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.js +2 -2
- package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/hooks/permission-request/route.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.js.nft.json +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/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.js.nft.json +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_client-reference-manifest.js +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_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_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/page.js +11 -11
- 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 +28 -28
- package/.next/server/chunks/1210.js +1 -1
- package/.next/server/chunks/5043.js +1 -1
- package/.next/server/chunks/5164.js +1 -1
- package/.next/server/chunks/6491.js +2 -2
- package/.next/server/chunks/6838.js +1 -1
- package/.next/server/chunks/7875.js +2 -2
- package/.next/server/chunks/8918.js +4 -4
- package/.next/server/chunks/9130.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/{4718-0053d42fb635e700.js → 4718-d97f52cd932dc1ee.js} +1 -1
- package/.next/static/chunks/app/worktrees/[id]/page-18a7d9374bd8c218.js +1 -0
- package/.next/static/css/{96d94a4ba771efc3.css → fb455b4e308adbaa.css} +1 -1
- package/.next/trace +13 -13
- package/README.md +6 -2
- package/dist/cli/commands/instances.d.ts.map +1 -1
- package/dist/cli/commands/instances.js +44 -15
- package/dist/cli/commands/peers.d.ts.map +1 -1
- package/dist/cli/commands/peers.js +12 -0
- package/dist/cli/commands/whoami.d.ts +67 -0
- package/dist/cli/commands/whoami.d.ts.map +1 -1
- package/dist/cli/commands/whoami.js +106 -0
- package/dist/cli/utils/api-client.d.ts +30 -1
- package/dist/cli/utils/api-client.d.ts.map +1 -1
- package/dist/cli/utils/api-client.js +28 -5
- package/dist/server/src/lib/detection/cli-patterns.js +206 -2
- package/dist/server/src/lib/hooks/agent-event-service.js +27 -5
- package/dist/server/src/lib/hooks/sources/codex/history.js +63 -3
- package/dist/server/src/lib/hooks/sources/codex/transcript.js +140 -6
- package/dist/server/src/lib/hooks/sources/launch-command.js +112 -15
- package/dist/server/src/lib/hooks/sources/turn-body.js +3 -1
- package/dist/server/src/lib/hooks/stop-history-capture.js +252 -50
- package/dist/server/src/lib/polling/response-checker.js +129 -5
- package/dist/server/src/lib/polling/response-dedup.js +136 -0
- package/dist/server/src/lib/relay/relay-delivery.js +160 -6
- package/package.json +1 -1
- package/.next/static/chunks/app/worktrees/[id]/page-06e1ff5ce2d126fd.js +0 -1
- /package/.next/static/{UIUPchtWvcEuQgcbGJv4g → eVkZd6vpcQwyJIlbymCUg}/_buildManifest.js +0 -0
- /package/.next/static/{UIUPchtWvcEuQgcbGJv4g → eVkZd6vpcQwyJIlbymCUg}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4718],{2317:(e,t,r)=>{r.d(t,{V:()=>i});var n=r(12115);function o(){try{let e="__localStorage_test__";return window.localStorage.setItem(e,"test"),window.localStorage.removeItem(e),!0}catch(e){return!1}}function i(e){let{key:t,defaultValue:r,validate:i,serialize:a=JSON.stringify,deserialize:s=JSON.parse}=e,l=(0,n.useRef)(r),c=(0,n.useRef)(i),u=(0,n.useRef)(a),d=(0,n.useRef)(s);l.current=r,c.current=i,u.current=a,d.current=s;let[f,p]=(0,n.useState)(!1),[g,m]=(0,n.useState)(r),y=(0,n.useCallback)(()=>{if(!o())return l.current;try{let e=window.localStorage.getItem(t);if(null===e)return l.current;let r=d.current(e);if(c.current)return c.current(r)?r:l.current;return r}catch(e){return l.current}},[t]),h=(0,n.useCallback)(e=>{if(o())try{let r=u.current(e);window.localStorage.setItem(t,r)}catch(e){}},[t]),w=(0,n.useCallback)(e=>{m(t=>{let r="function"==typeof e?e(t):e;return h(r),r})},[h]),b=(0,n.useCallback)(()=>{if(o())try{window.localStorage.removeItem(t)}catch(e){}m(l.current)},[t]);return(0,n.useEffect)(()=>{p(o()),m(y())},[y]),{value:g,setValue:w,removeValue:b,isAvailable:f}}},7636:(e,t,r)=>{r.d(t,{BN:()=>C,EN:()=>a,LV:()=>p,PB:()=>l,Si:()=>i,UZ:()=>d,Xn:()=>b,ZC:()=>T,ZD:()=>E,_s:()=>S,fs:()=>k,j:()=>w,m3:()=>s,nO:()=>g,s6:()=>f,zD:()=>h});var n=r(38606);let o=["updatedAt","repositoryName","branchName","status","lastSent"],i=e=>o.includes(e),a=["always","collapsed","hidden"],s=e=>a.includes(e),l="collapsed",c={waiting:0,ready:1,running:2,generating:3,idle:4},u=["waiting","running","generating","ready","idle"];function d(e){let t=new Set;for(let r of e)!1===r.visible&&t.add(r.path);return t}function f(e,t){return 0===t.size?e.slice():e.filter(e=>{let r=e.repositoryPath;return!r||!t.has(r)})}function p(e){let t=function(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)|0;return Math.abs(t)}(e)%360;return"hsl(".concat(t,", ").concat(65,"%, ").concat(60,"%)")}function g(e,t){if(!e&&!t)return 0;if(!e)return 1;if(!t)return -1;let r=e instanceof Date?e.getTime():new Date(e).getTime();return(t instanceof Date?t.getTime():new Date(t).getTime())-r}function m(e){return e.cliStatus&&Object.keys(e.cliStatus).length>0?(0,n.A7)(e.cliStatus):e.status}function y(e){return"waiting"===m(e)}function h(e){let t=new Set(e.map(m));for(let e of u)if(t.has(e))return e;return"idle"}function w(e){let t=0;for(let r of e)y(r)&&t++;return t}function b(e,t,r){let n=[...e],o="status"!==t;return n.sort((e,n)=>{if(o){let t=Number(y(n))-Number(y(e));if(0!==t)return t}let i=0;switch(t){case"updatedAt":{let t=e=>e?e instanceof Date?e.getTime():new Date(e).getTime():0,r=t(e.lastActivity);i=t(n.lastActivity)-r;break}case"repositoryName":{let t=e.repositoryName.toLowerCase(),r=n.repositoryName.toLowerCase();i=t.localeCompare(r);break}case"branchName":{let t=e.name.toLowerCase(),r=n.name.toLowerCase();i=t.localeCompare(r);break}case"status":i=c[e.status]-c[n.status];break;case"lastSent":{let t=g(e.lastActivity,n.lastActivity);if(!e.lastActivity&&!n.lastActivity){i=0;break}if(!e.lastActivity)return 1;if(!n.lastActivity)return -1;i=t;break}default:i=0}return("updatedAt"===t||"lastSent"===t?"desc"===r:"asc"===r)?i:-i}),n}function S(e,t,r){let n=new Map;for(let t of e){let e=t.repositoryName;n.has(e)||n.set(e,[]),n.get(e).push(t)}return[...n.keys()].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).map(e=>({repositoryName:e,branches:b(n.get(e),t,r)}))}let v="mcbd-sidebar-group-order-cache";function E(){try{let e=localStorage.getItem(v);if(!e)return[];let t=function(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return[];return t.filter(e=>"string"==typeof e).slice(0,500)}catch(e){return[]}}(e);return t.length,t}catch(e){return[]}}function T(e){try{localStorage.setItem(v,JSON.stringify(e))}catch(e){}}function C(e,t){if(0===t.length)return e.slice();let r=new Map(t.map((e,t)=>[e,t]));return e.slice().sort((e,t)=>{let n=r.has(e.repositoryName)?r.get(e.repositoryName):1/0,o=r.has(t.repositoryName)?r.get(t.repositoryName):1/0;return n===o?e.repositoryName.localeCompare(t.repositoryName):n-o})}function k(e,t){return"hidden"!==e&&("always"===e||!t)}},22592:(e,t,r)=>{r.d(t,{Ps:()=>d,W5:()=>u});var n=r(95155),o=r(12115),i=r(38218),a=r(68704);let s="data-pc-size",l={size:a.r5,setSize:()=>{},isMobile:!1,factor:a.d8[a.r5].factor,isAvailable:!1},c=(0,o.createContext)(l);function u(e){let{children:t}=e,{size:r,setSize:l,isAvailable:u}=(0,a.of)(),d=(0,i.a)();(0,o.useEffect)(()=>{if("undefined"==typeof document)return;let e=document.documentElement;return d?void e.removeAttribute(s):(e.setAttribute(s,r),()=>{e.removeAttribute(s)})},[r,d]);let f=(0,o.useMemo)(()=>({size:r,setSize:l,isMobile:d,factor:a.d8[r].factor,isAvailable:u}),[r,l,d,u]);return(0,n.jsx)(c.Provider,{value:f,children:t})}function d(){return(0,o.useContext)(c)}},24373:(e,t,r)=>{r.d(t,{Kg:()=>i,Lv:()=>a});var n=r(12115),o=r(66966);function i(e){let t=0;for(let r of e)!0===r.isWaitingForResponse&&t++;return t}function a(){let e=(0,o.rC)(),t=null==e?void 0:e.worktrees;return(0,n.useMemo)(()=>{let e=t?t.filter(e=>!0===e.isWaitingForResponse):[];return{count:e.length,worktrees:e}},[t])}r(44308)},32916:(e,t,r)=>{r.d(t,{GB:()=>u,VF:()=>d,pT:()=>f});var n=r(95155),o=r(12115),i=r(7636);let a="updatedAt",s=(0,o.createContext)(null);function l(e,t,r,n){let i=(0,o.useRef)(!0);(0,o.useEffect)(()=>{try{let t=localStorage.getItem(e);t&&n(t)}catch(e){}},[]),(0,o.useEffect)(()=>{if(i.current){i.current=!1;return}try{localStorage.setItem(e,r())}catch(e){}},[t])}function c(e,t){switch(t.type){case"TOGGLE":return{...e,isOpen:!e.isOpen};case"SET_WIDTH":return{...e,width:t.width};case"OPEN_MOBILE_DRAWER":return{...e,isMobileDrawerOpen:!0};case"CLOSE_MOBILE_DRAWER":return{...e,isMobileDrawerOpen:!1};case"SET_SORT_KEY":return{...e,sortKey:t.sortKey};case"SET_SORT_DIRECTION":return{...e,sortDirection:t.sortDirection};case"LOAD_SORT_SETTINGS":return{...e,sortKey:t.sortKey,sortDirection:t.sortDirection};case"SET_VIEW_MODE":return{...e,viewMode:t.viewMode};case"SET_OPEN":return e.isOpen===t.isOpen?e:{...e,isOpen:t.isOpen};case"SET_REPOSITORY_ORDER":return{...e,repositoryOrder:t.repositoryOrder};case"SET_REPO_TAB_BAR_MODE":return{...e,repoTabBarMode:t.repoTabBarMode};default:return e}}function u(e){let{children:t,initialOpen:r=!0,initialWidth:u=224}=e,[d,f]=(0,o.useReducer)(c,{isOpen:r,width:u,isMobileDrawerOpen:!1,sortKey:a,sortDirection:"desc",viewMode:"grouped",repositoryOrder:(0,i.ZD)(),repoTabBarMode:i.PB});l("mcbd-sidebar-sort","".concat(d.sortKey,":").concat(d.sortDirection),()=>JSON.stringify({sortKey:d.sortKey,sortDirection:d.sortDirection}),e=>{try{let t=JSON.parse(e),r=t.sortDirection,n=(0,i.Si)(t.sortKey)?t.sortKey:a;n&&("asc"===r||"desc"===r)&&f({type:"LOAD_SORT_SETTINGS",sortKey:n,sortDirection:r})}catch(e){}}),l("mcbd-sidebar-view-mode",d.viewMode,()=>d.viewMode,e=>{("grouped"===e||"flat"===e)&&f({type:"SET_VIEW_MODE",viewMode:e})}),l("mcbd-sidebar-width",d.width,()=>String(d.width),e=>{let t=Number(e);!isNaN(t)&&t>0&&f({type:"SET_WIDTH",width:288===t?224:t})}),l("mcbd-sidebar-open",d.isOpen,()=>String(d.isOpen),e=>{("true"===e||"false"===e)&&f({type:"SET_OPEN",isOpen:"true"===e})}),l("mcbd-repo-tab-bar-mode",d.repoTabBarMode,()=>d.repoTabBarMode,e=>{(0,i.m3)(e)&&f({type:"SET_REPO_TAB_BAR_MODE",repoTabBarMode:e})});let p=(0,o.useCallback)(()=>{f({type:"TOGGLE"})},[]),g=(0,o.useCallback)(e=>{f({type:"SET_WIDTH",width:e})},[]),m=(0,o.useCallback)(()=>{f({type:"OPEN_MOBILE_DRAWER"})},[]),y=(0,o.useCallback)(()=>{f({type:"CLOSE_MOBILE_DRAWER"})},[]),h=(0,o.useCallback)(e=>{f({type:"SET_SORT_KEY",sortKey:e})},[]),w=(0,o.useCallback)(e=>{f({type:"SET_SORT_DIRECTION",sortDirection:e})},[]),b=(0,o.useCallback)(e=>{f({type:"SET_VIEW_MODE",viewMode:e})},[]),S=(0,o.useCallback)(e=>{f({type:"SET_REPOSITORY_ORDER",repositoryOrder:e}),(0,i.ZC)(e)},[]),v=(0,o.useCallback)(e=>{f({type:"SET_REPO_TAB_BAR_MODE",repoTabBarMode:e})},[]),E=(0,o.useMemo)(()=>({isOpen:d.isOpen,width:d.width,isMobileDrawerOpen:d.isMobileDrawerOpen,sortKey:d.sortKey,sortDirection:d.sortDirection,toggle:p,setWidth:g,openMobileDrawer:m,closeMobileDrawer:y,setSortKey:h,setSortDirection:w,viewMode:d.viewMode,setViewMode:b,repositoryOrder:d.repositoryOrder,setRepositoryOrder:S,repoTabBarMode:d.repoTabBarMode,setRepoTabBarMode:v}),[d.isOpen,d.width,d.isMobileDrawerOpen,d.sortKey,d.sortDirection,d.viewMode,d.repositoryOrder,d.repoTabBarMode,p,g,m,y,h,w,b,S,v]);return(0,n.jsx)(s.Provider,{value:E,children:t})}function d(){let e=(0,o.useContext)(s);if(!e)throw Error("useSidebarContext must be used within a SidebarProvider");return e}function f(){return(0,o.useContext)(s)}},38218:(e,t,r)=>{r.d(t,{D:()=>i,a:()=>a});var n=r(12115);let o=n.useLayoutEffect,i=768;function a(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{breakpoint:t=i}=e,[r,a]=(0,n.useState)(!1);return o(()=>{let e=window.matchMedia("(max-width: ".concat(t-1,"px)"));a(e.matches);let r=e=>{a(e.matches)};return e.addEventListener("change",r),()=>{e.removeEventListener("change",r)}},[t]),r}},38606:(e,t,r)=>{r.d(t,{A7:()=>c,kA:()=>i,f_:()=>f,dw:()=>u,XK:()=>p});var n=r(54014),o=r(55449);function i(e){return e?e.isWaitingForResponse?"waiting":e.isProcessing?"running":e.isRunning?"ready":"idle":"idle"}let a={start:"nextAction.start",sendMessage:"nextAction.sendMessage",approveReject:"nextAction.approveReject",replyToPrompt:"nextAction.replyToPrompt",checkStalled:"nextAction.checkStalled",running:"nextAction.running"};Object.values(a);let s="exited",l={idle:null,ready:"ready",running:"running",generating:"running",waiting:"waiting"};function c(e){if(!e)return"idle";let t=Object.values(e).filter(e=>void 0!==e);return 0===t.length?"idle":t.includes("waiting")?"waiting":t.includes("running")?"running":t.includes("generating")?"generating":t.includes("ready")?"ready":"idle"}function u(e,t,r){return e?Object.entries(e).map(e=>{var o;let[i,a]=e,s=null!=(o=null==t?void 0:t[i])?o:(0,n.f_)(i,i),l=null==r?void 0:r(i);return"".concat(s,": ").concat(null!=a?a:"idle").concat(l?" (".concat(l,")"):"")}).join(", "):""}let d=["prompt","menu","unclassified"];function f(e){var t,r,n;let o=Object.values(null!=(r=null!=(t=e.sessionStatusByInstance)?t:e.sessionStatusByCli)?r:{}).filter(e=>void 0!==e),i=!1,a=new Set;for(let e of o)e.awaitingInstruction&&(i=!0),e.waitingKind&&a.add(e.waitingKind);return{waitingKind:null!=(n=d.find(e=>a.has(e)))?n:null,awaitingInstruction:i}}function p(e){var t,r,u,d,p,g;let m=i(void 0!==e.isSessionRunning?{isRunning:null!=(t=e.isSessionRunning)&&t,isWaitingForResponse:null!=(r=e.isWaitingForResponse)&&r,isProcessing:null!=(u=e.isProcessing)&&u}:void 0),y=!!e.lastAssistantMessageAt&&(!e.lastViewedAt||new Date(e.lastAssistantMessageAt)>new Date(e.lastViewedAt)),{cliStatus:h,cliStatusLabels:w,exitedInstanceIds:b}=function(e){var t,r,a,l,c,u;let d={},f={},p=[],g=e.sessionStatusByInstance;if(!g){for(let c of null!=(t=e.selectedAgents)?t:(0,o.sA)())d[c]=i(null==(r=e.sessionStatusByCli)?void 0:r[c]),f[c]=(0,n.oo)(c),(null==(l=e.sessionStatusByCli)||null==(a=l[c])?void 0:a.sessionStatusReason)===s&&p.push(c);return{cliStatus:d,cliStatusLabels:f,exitedInstanceIds:p}}let m=e.agentInstances&&e.agentInstances.length>0?e.agentInstances:(0,n.lu)(null!=(c=e.selectedAgents)?c:(0,o.sA)()),y=new Set;for(let e of m)y.add(e.id),d[e.id]=i(g[e.id]),f[e.id]=(0,n.sw)(e),(null==(u=g[e.id])?void 0:u.sessionStatusReason)===s&&p.push(e.id);for(let[e,t]of Object.entries(g)){if(y.has(e))continue;let r=i(t);"idle"!==r&&(d[e]=r,f[e]=function(e){let t=n.XH.find(t=>e.startsWith("".concat(t,"-")));if(t){let r=e.slice(t.length+1);return"".concat((0,n.oo)(t)," ").concat(r)}return(0,n.f_)(e,e)}(e))}return{cliStatus:d,cliStatusLabels:f,exitedInstanceIds:p}}(e),S=c(h),{waitingKind:v,awaitingInstruction:E}=f(e);return{id:e.id,name:e.name,repositoryName:null!=(d=e.repositoryDisplayName)?d:e.repositoryName,status:m,hasUnread:y,lastActivity:e.updatedAt,description:e.description,cliStatus:h,cliStatusLabels:w,exitedInstanceIds:b,worktreePath:e.path,waitingKind:v,awaitingInstruction:E,nextActionKey:(p=l[S],g="waiting"===S?"approval":null,p&&"idle"!==p?"ready"===p?a.sendMessage:"waiting"===p&&"approval"===g?a.approveReject:"waiting"===p?a.replyToPrompt:(0,a.running):a.start)}}},39649:(e,t,r)=>{r.d(t,{$f:()=>d,H8:()=>u});var n=r(95155),o=r(12115),i=r(80344);let a={PROCESSING:2e3,SESSION_RUNNING:5e3,IDLE:1e4},s=(0,o.createContext)(null),l={selectedWorktreeId:null,worktrees:[],repositories:[],selectedWorktreeDetail:null,isLoading:!0,isLoadingDetail:!1,error:null};function c(e,t){switch(t.type){case"SET_WORKTREES":return{...e,worktrees:t.worktrees,isLoading:!1};case"SET_REPOSITORIES":return{...e,repositories:t.repositories};case"SELECT_WORKTREE":{var r;let n=null!=(r=e.worktrees.find(e=>e.id===t.id))?r:null;return{...e,selectedWorktreeId:t.id,selectedWorktreeDetail:null!=n?n:e.selectedWorktreeDetail,isLoadingDetail:null===n}}case"SET_WORKTREE_DETAIL":return{...e,selectedWorktreeDetail:t.detail};case"SET_LOADING":return{...e,isLoading:t.isLoading};case"SET_LOADING_DETAIL":return{...e,isLoadingDetail:t.isLoadingDetail};case"SET_ERROR":return{...e,error:t.error,isLoading:!1};default:return e}}function u(e){let{children:t,externalWorktrees:r,externalRepositories:u,externalIsLoading:d,externalError:f,externalRefresh:p}=e,g=void 0!==r,[m,y]=(0,o.useReducer)(c,l);(0,o.useEffect)(()=>{g&&r&&y({type:"SET_WORKTREES",worktrees:r})},[g,r]),(0,o.useEffect)(()=>{g&&u&&y({type:"SET_REPOSITORIES",repositories:u})},[g,u]);let h=(0,o.useCallback)(async()=>{if(!g){y({type:"SET_LOADING",isLoading:!0}),y({type:"SET_ERROR",error:null});try{var e;let t=await i.y.getAll();y({type:"SET_WORKTREES",worktrees:t.worktrees}),y({type:"SET_REPOSITORIES",repositories:null!=(e=t.repositories)?e:[]})}catch(e){y({type:"SET_ERROR",error:e instanceof Error?e.message:"Failed to fetch worktrees"})}}},[g]),w=(0,o.useCallback)(async e=>{y({type:"SELECT_WORKTREE",id:e}),y({type:"SET_ERROR",error:null});try{i.y.markAsViewed(e).catch(e=>{console.warn("[WorktreeSelectionContext] Failed to mark as viewed:",e)});let t=await i.y.getById(e);y({type:"SET_WORKTREE_DETAIL",detail:t})}catch(e){y({type:"SET_ERROR",error:e instanceof Error?e.message:"Failed to fetch worktree detail"})}finally{y({type:"SET_LOADING_DETAIL",isLoadingDetail:!1})}},[]),b=(0,o.useCallback)(async()=>{if(g&&p)return void await p();await h()},[g,p,h]);(0,o.useEffect)(()=>{g||h()},[h,g]),(0,o.useEffect)(()=>{if(g)return;let e=null,t=!0,r=async()=>{if(t)try{var n,o;let s=await i.y.getAll();y({type:"SET_WORKTREES",worktrees:s.worktrees}),y({type:"SET_REPOSITORIES",repositories:null!=(n=s.repositories)?n:[]});let l=(o=s.worktrees).some(e=>e.isProcessing||e.isWaitingForResponse)?a.PROCESSING:o.some(e=>e.isSessionRunning)?a.SESSION_RUNNING:a.IDLE;t&&(e=setTimeout(r,l))}catch(n){if(n instanceof i.hD&&401===n.status)return;console.error("[WorktreeSelectionContext] Polling error:",n),t&&(e=setTimeout(r,a.SESSION_RUNNING))}};return r(),()=>{t=!1,e&&clearTimeout(e)}},[g]);let S=g&&void 0!==d?d:m.isLoading,v=g&&f?f.message:null,E={selectedWorktreeId:m.selectedWorktreeId,worktrees:m.worktrees,repositories:m.repositories,selectedWorktreeDetail:m.selectedWorktreeDetail,isLoading:S,isLoadingDetail:m.isLoadingDetail,error:null!=v?v:m.error,selectWorktree:w,refreshWorktrees:b};return(0,n.jsx)(s.Provider,{value:E,children:t})}function d(){let e=(0,o.useContext)(s);if(!e)throw Error("useWorktreeSelection must be used within a WorktreeSelectionProvider");return e}},44308:(e,t,r)=>{r.d(t,{$h:()=>d,DR:()=>o,IH:()=>c,Iu:()=>n,Nb:()=>f,SD:()=>i,_d:()=>l,bm:()=>p,ks:()=>s,t7:()=>u,z7:()=>a});let n=7e3,o=["in_review","approval","stalled"],i="in_review",a="filter",s="/review?".concat(a,"=approval");function l(e){return e&&o.includes(e)?e:null}let c=["claude","codex","copilot","antigravity","opencode"],u=1e3,d=5,f=100,p=1e3},52703:(e,t,r)=>{r.d(t,{Oo:()=>o,ST:()=>n,T4:()=>s,dz:()=>a,rz:()=>i,zS:()=>l});let n="client_version",o="version_mismatch",i="chat_turn_progress",a="messages_invalidated",s="model_changed";function l(e){let t;try{t=JSON.parse(e)}catch(e){return null}if(!t||"object"!=typeof t)return null;let r=t;if("broadcast"===r.type){let e=r.data;return e&&"object"==typeof e?"string"!=typeof e.type?null:(void 0===e.worktreeId&&"string"==typeof r.worktreeId&&(e.worktreeId=r.worktreeId),e):null}return"string"==typeof r.type?r:null}},54014:(e,t,r)=>{r.d(t,{Ab:()=>o,NL:()=>y,O6:()=>p,XH:()=>n,f_:()=>d,hR:()=>c,lu:()=>g,n6:()=>s,oo:()=>u,pQ:()=>i,sw:()=>f,vz:()=>m});let n=["claude","codex","gemini","vibe-local","opencode","copilot","antigravity","command-code"],o=10,i=50,a=/^[a-zA-Z0-9_-]+$/;function s(e){return"string"==typeof e&&e.length>0&&e.length<=64&&a.test(e)}let l={claude:"Claude",codex:"Codex",gemini:"Gemini","vibe-local":"Vibe Local",opencode:"OpenCode",copilot:"Copilot",antigravity:"Antigravity","command-code":"Command Code"};function c(e){return n.includes(e)}function u(e){var t;return null!=(t=l[e])?t:e}function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Assistant";return e&&c(e)?u(e):t}function f(e){let t=e.alias;return"string"==typeof t&&t.trim().length>0?t:u(e.cliTool)}function p(e,t,r){let n=e.find(e=>e.id===t);return n?f(n):u(r)}function g(e){return e.map((e,t)=>({id:e,cliTool:e,alias:u(e),order:t}))}let m=128,y=2097152},55449:(e,t,r)=>{r.d(t,{IK:()=>l,qD:()=>d,sA:()=>s,zk:()=>o});var n=r(63001);let o="/api/settings/default-agents",i=n.fJ,a=new Set;function s(){return i}function l(e){if(!Array.isArray(e))return!1;let t=(0,n.Lt)(e);if(!t.valid)return!1;let r=t.value;if(r.length===i.length&&r.every((e,t)=>e===i[t]))return!1;for(let e of(i=r,a))e();return!0}let c=null,u=!1;async function d(){return u?i:c||("function"!=typeof fetch?i:c=(async()=>{try{let e=await fetch(o);if(e.ok){let t=await e.json();l(null==t?void 0:t.defaultSelectedAgents),u=!0}}catch(e){}finally{c=null}return i})())}},63001:(e,t,r)=>{r.d(t,{Lt:()=>s,Wj:()=>i,eu:()=>o,fJ:()=>a});var n=r(54014);let o=2,i=6,a=["claude","codex","antigravity"];function s(e){return e.length<o||e.length>i?{valid:!1,error:"Must be ".concat(o,"-").concat(i," elements")}:e.every(e=>"string"==typeof e&&n.XH.includes(e))?new Set(e).size!==e.length?{valid:!1,error:"Duplicate tool IDs not allowed"}:{valid:!0,value:e}:{valid:!1,error:"Invalid CLI tool ID"}}},63365:(e,t,r)=>{r.d(t,{tS:()=>u,xM:()=>d,T3:()=>f});var n=r(95155),o=r(12115),i=r(52703);function a(){return"undefined"!=typeof globalThis&&"function"==typeof globalThis.WebSocket?globalThis.WebSocket:null}let s=()=>{},l={status:"disconnected",connected:!1,subscribe:s,unsubscribe:s,addListener:()=>s},c=(0,o.createContext)(null);function u(e){let{children:t,enabled:r=!0}=e,s=(0,o.useRef)(new Set),l=(0,o.useRef)(new Map),{status:u,subscribe:d,unsubscribe:f}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{onEvent:t,onStatusChange:r,autoReconnect:n=!0,reconnectBaseDelay:s=1e3,reconnectMaxDelay:l=3e4,enabled:c=!0}=e,[u,d]=(0,o.useState)("disconnected"),f=(0,o.useRef)(null),p=(0,o.useRef)(null),g=(0,o.useRef)(0),m=(0,o.useRef)(new Set),y=(0,o.useRef)(!1),h=(0,o.useRef)(t);h.current=t;let w=(0,o.useRef)(r);w.current=r;let b=(0,o.useCallback)(e=>{var t;d(e),null==(t=w.current)||t.call(w,e)},[]),S=(0,o.useCallback)(()=>{null!==p.current&&(clearTimeout(p.current),p.current=null)},[]),v=(0,o.useCallback)(()=>{if(!c)return;let e=a();if(!e||f.current&&(f.current.readyState===e.OPEN||f.current.readyState===e.CONNECTING))return;S(),y.current=!1,b("connecting");let t="https:"===window.location.protocol?"wss:":"ws:",r=new e("".concat(t,"//").concat(window.location.host));f.current=r,r.onopen=()=>{g.current=0,b("connected");try{r.send(JSON.stringify({type:i.ST,version:"0.32.0"}))}catch(e){}m.current.forEach(e=>{try{r.send(JSON.stringify({type:"subscribe",worktreeId:e}))}catch(e){}})},r.onmessage=e=>{var t;let r="string"==typeof e.data?e.data:String(e.data),n=(0,i.zS)(r);n&&(null==(t=h.current)||t.call(h,n))},r.onerror=()=>{b("error")},r.onclose=()=>{var e;if(f.current=null,b("disconnected"),y.current||!n||"undefined"!=typeof document&&"hidden"===document.visibilityState)return;let t=(e=g.current,Math.min(s*2**Math.max(0,e),l));g.current+=1,p.current=setTimeout(()=>{p.current=null,v()},t)}},[c,n,s,l,b,S]),E=(0,o.useCallback)(()=>{if(S(),y.current=!0,f.current){try{f.current.close(1e3,"Client disconnect")}catch(e){}f.current=null}},[S]),T=(0,o.useCallback)(e=>{let t=f.current,r=a();if(t&&r&&t.readyState===r.OPEN)try{t.send(JSON.stringify(e))}catch(e){}},[]),C=(0,o.useCallback)(e=>{m.current.has(e)||(m.current.add(e),T({type:"subscribe",worktreeId:e}))},[T]),k=(0,o.useCallback)(e=>{m.current.has(e)&&(m.current.delete(e),T({type:"unsubscribe",worktreeId:e}))},[T]);return(0,o.useEffect)(()=>{if(c)return v(),()=>{E()}},[c,v,E]),(0,o.useEffect)(()=>{if(!c||"undefined"==typeof document)return;let e=()=>{"visible"===document.visibilityState&&(f.current||(g.current=0,v()))};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[c,v]),{status:u,subscribe:C,unsubscribe:k,send:T}}({enabled:r,onEvent:(0,o.useCallback)(e=>{s.current.forEach(t=>{try{t(e)}catch(e){}})},[])}),p=(0,o.useCallback)(e=>{var t;let r=l.current,n=null!=(t=r.get(e))?t:0;r.set(e,n+1),0===n&&d(e)},[d]),g=(0,o.useCallback)(e=>{var t;let r=l.current,n=null!=(t=r.get(e))?t:0;n<=1?(r.delete(e),f(e)):r.set(e,n-1)},[f]),m=(0,o.useCallback)(e=>(s.current.add(e),()=>{s.current.delete(e)}),[]),y=(0,o.useMemo)(()=>({status:u,connected:"connected"===u,subscribe:p,unsubscribe:g,addListener:m}),[u,p,g,m]);return(0,n.jsx)(c.Provider,{value:y,children:t})}function d(){var e;return null!=(e=(0,o.useContext)(c))?e:l}function f(e){let{addListener:t}=d(),r=(0,o.useRef)(e);r.current=e,(0,o.useEffect)(()=>t(e=>r.current(e)),[t])}},65380:(e,t,r)=>{r.d(t,{H:()=>s,O:()=>a});var n=r(95155),o=r(12115);let i=(0,o.createContext)(!1);function a(e){let{children:t,authEnabled:r}=e;return(0,n.jsx)(i.Provider,{value:r,children:t})}function s(){return(0,o.useContext)(i)}},66966:(e,t,r)=>{r.d(t,{g7:()=>u,rC:()=>f,Fn:()=>d});var n=r(95155),o=r(12115),i=r(80344),a=r(63365);let s=[2e3,5e3,1e4];var l=r(39649);let c=(0,o.createContext)(null);function u(e){let{children:t}=e,{worktrees:r,repositories:u,isLoading:d,error:f,refresh:p}=function(){let[e,t]=(0,o.useState)([]),[r,n]=(0,o.useState)([]),[l,c]=(0,o.useState)(!0),[u,d]=(0,o.useState)(null),f=(0,o.useRef)(null),p=(0,o.useRef)([]),g=(0,o.useRef)(null),m=(0,o.useRef)(0),y=(0,o.useRef)(null),h=(0,o.useRef)(async()=>{}),w=(0,o.useCallback)(()=>{null!==y.current&&(clearTimeout(y.current),y.current=null)},[]),{connected:b,subscribe:S,unsubscribe:v,addListener:E}=(0,a.xM)(),T=(0,o.useRef)(b);T.current=b;let C=(0,o.useCallback)(async()=>{try{var e,r;d(null);let a=await fetch("/api/worktrees"),s=(0,i.O0)(a);if(s)throw s;if(!a.ok)throw Error("Failed to fetch worktrees: ".concat(a.status));let l=(0,i.xd)(a);if(l)throw l;let c=await a.json(),u=null!=(e=c.worktrees)?e:[],f=null!=(r=c.repositories)?r:[];(0,o.startTransition)(()=>{t(u),n(f)}),p.current=u,m.current=0,w()}catch(r){let e=r instanceof Error?r:Error(String(r));console.error("[useWorktreesCache] Failed to fetch worktrees:",e),d(e);let t=m.current;0===p.current.length&&t<s.length&&(m.current=t+1,w(),y.current=setTimeout(()=>{y.current=null,h.current()},s[t]))}finally{c(!1)}},[w]);h.current=C,(0,o.useEffect)(()=>{C()},[C]),(0,o.useEffect)(()=>w,[w]);let k=(0,o.useCallback)(()=>p.current.some(e=>!0===e.isSessionRunning),[]),O=(0,o.useCallback)(()=>{let e=k();return T.current?e?2e4:6e4:e?5e3:3e4},[k]),R=(0,o.useCallback)(()=>{null!==f.current&&(clearInterval(f.current),f.current=null),g.current=null},[]),x=(0,o.useCallback)(()=>{R();let e=O();g.current=e,f.current=setInterval(()=>{C()},e)},[O,C,R]);(0,o.useEffect)(()=>{let e=()=>{document.hidden?R():(C(),x())},t=setTimeout(()=>{x()},0);return document.addEventListener("visibilitychange",e),()=>{clearTimeout(t),R(),document.removeEventListener("visibilitychange",e)}},[C,x,R]),(0,o.useEffect)(()=>{if(p.current=e,"undefined"!=typeof document&&document.hidden||null===g.current)return;let t=O();g.current!==t&&x()},[e,b,O,x]);let N=e.map(e=>e.id).sort().join(" ");return(0,o.useEffect)(()=>{let e=N.length>0?N.split(" "):[];return e.forEach(e=>S(e)),()=>{e.forEach(e=>v(e))}},[N,S,v]),(0,o.useEffect)(()=>E(e=>{if("session_status_changed"===e.type&&"string"==typeof e.worktreeId){let i=e.worktreeId,a=e.isWaitingForResponse;if("boolean"==typeof a){var r,n;let s=null!=(r=e.instance)?r:null,l=null!=(n=e.waitingKind)?n:null;(0,o.startTransition)(()=>{t(e=>{let t=!1,r=e.map(e=>{if(e.id!==i)return e;let r=function(e,t){var r,n,o;let i,a=null!=(n=t.instance)?n:null,s=a?null==(r=e.sessionStatusByInstance)?void 0:r[a]:void 0,l=e.sessionStatusByInstance;if(a&&s&&s.isWaitingForResponse!==t.waiting&&(l={...e.sessionStatusByInstance,[a]:{...s,isWaitingForResponse:t.waiting,waitingKind:null!=(o=t.waitingKind)?o:null}}),t.waiting)i=!0;else{let e=l?Object.values(l):[];i=e.length>0&&e.some(e=>(null==e?void 0:e.isWaitingForResponse)===!0)}return l===e.sessionStatusByInstance&&i===e.isWaitingForResponse?e:{...e,sessionStatusByInstance:l,isWaitingForResponse:i}}(e,{waiting:a,instance:s,waitingKind:l});return r!==e&&(t=!0),r});return t?r:e})});return}let s=e.isRunning;if("boolean"==typeof s){if((null!=e.cliTool||null!=e.instance)&&!1===s)return void C();(0,o.startTransition)(()=>{t(e=>{let t=!1,r=e.map(e=>e.id===i&&e.isSessionRunning!==s?(t=!0,{...e,isSessionRunning:s}):e);return t?r:e})})}}else("message"===e.type||"message_updated"===e.type)&&C()}),[E,C]),{worktrees:e,repositories:r,isLoading:l,error:u,refresh:C}}(),g=(0,o.useMemo)(()=>({worktrees:r,repositories:u,isLoading:d,error:f,refresh:p}),[r,u,d,f,p]);return(0,n.jsx)(c.Provider,{value:g,children:(0,n.jsx)(l.H8,{externalWorktrees:r,externalRepositories:u,externalIsLoading:d,externalError:f,externalRefresh:p,children:t})})}function d(){let e=(0,o.useContext)(c);if(null===e)throw Error("useWorktreesCacheContext must be used within a WorktreesCacheProvider");return e}function f(){return(0,o.useContext)(c)}},68704:(e,t,r)=>{r.d(t,{Uf:()=>i,d8:()=>a,fM:()=>s,of:()=>c,r5:()=>o,rq:()=>l});var n=r(2317);let o="medium",i=["large","medium","small","xsmall"],a={large:{value:"large",rootFontSizePx:18,factor:1.125,terminalFontSize:16},medium:{value:"medium",rootFontSizePx:16,factor:1,terminalFontSize:14},small:{value:"small",rootFontSizePx:14,factor:.875,terminalFontSize:12},xsmall:{value:"xsmall",rootFontSizePx:12.5,factor:.78,terminalFontSize:11}};function s(e){return"string"==typeof e&&Object.prototype.hasOwnProperty.call(a,e)}function l(e){return a[e].terminalFontSize}function c(){let{value:e,setValue:t,isAvailable:r}=(0,n.V)({key:"mcbd-pc-display-size",defaultValue:o,validate:s});return{size:e,setSize:t,isAvailable:r}}},70628:(e,t,r)=>{r.d(t,{K:()=>s,S:()=>a});var n=r(95155),o=r(12115);let i=(0,o.createContext)({open:!1,setOpen:()=>{},toggle:()=>{}});function a(e){let{children:t}=e,[r,a]=(0,o.useState)(!1),s=(0,o.useCallback)(()=>a(e=>!e),[]),l=(0,o.useMemo)(()=>({open:r,setOpen:a,toggle:s}),[r,s]);return(0,n.jsx)(i.Provider,{value:l,children:t})}function s(){return(0,o.useContext)(i)}},77016:(e,t,r)=>{r.d(t,{W:()=>w,n:()=>b});var n=r(95155),o=r(12115),i=r(18955),a=r(52056),s=r(89559),l=r(65229),c=r(59854),u=r(63365),d=r(52703);let f=0,p=new Set;function g(){for(let e of p)e()}function m(e){return p.add(e),()=>{p.delete(e)}}function y(){return f>0}function h(){return!1}function w(){return(0,o.useSyncExternalStore)(m,y,h)}function b(){let e=(0,i.c)("common"),[t,r]=(0,o.useState)(null),[p,m]=(0,o.useState)(null),y=(0,o.useCallback)(e=>{if(e.type!==d.Oo)return;let{serverVersion:t,clientVersion:n}=e;"string"==typeof t&&"string"==typeof n&&t&&n&&t!==p&&r({serverVersion:t,clientVersion:n})},[p]);(0,u.T3)(y);let h=null!==t;(0,o.useEffect)(()=>{if(h)return f+=1,g(),()=>{f-=1,g()}},[h]);let w=(0,o.useCallback)(()=>{window.location.reload()},[]),b=(0,o.useCallback)(()=>{r(e=>(e&&m(e.serverVersion),null))},[]);return t?(0,n.jsxs)("div",{"data-testid":"version-mismatch-banner",role:"alert","aria-live":"assertive",className:"fixed top-3 left-1/2 -translate-x-1/2 flex items-start gap-3 max-w-[92vw] rounded-lg border border-warning-border bg-warning-subtle px-4 py-3 text-warning-foreground shadow-lg",style:{zIndex:c.M.TOAST},children:[(0,n.jsx)(a.A,{className:"h-5 w-5 shrink-0 mt-0.5","aria-hidden":"true"}),(0,n.jsxs)("div",{className:"flex flex-col gap-0.5 text-sm",children:[(0,n.jsx)("span",{className:"font-semibold",children:e("versionMismatch.title")}),(0,n.jsx)("span",{children:e("versionMismatch.description",{serverVersion:t.serverVersion,clientVersion:t.clientVersion})})]}),(0,n.jsxs)("button",{type:"button","data-testid":"version-mismatch-reload",onClick:w,className:"shrink-0 inline-flex items-center gap-1.5 rounded-md border border-warning-border px-3 py-1.5 text-sm font-medium hover:opacity-80 focus:outline-none focus:ring-2 focus:ring-offset-2",children:[(0,n.jsx)(s.A,{className:"h-4 w-4","aria-hidden":"true"}),e("versionMismatch.reload")]}),(0,n.jsx)("button",{type:"button","data-testid":"version-mismatch-dismiss",onClick:b,"aria-label":e("versionMismatch.dismiss"),className:"shrink-0 hover:opacity-70 focus:outline-none focus:ring-2 focus:ring-offset-2",children:(0,n.jsx)(l.A,{className:"h-4 w-4","aria-hidden":"true"})})]}):null}},80344:(e,t,r)=>{r.d(t,{$T:()=>d,GQ:()=>p,O0:()=>i,Rx:()=>c,gC:()=>u,hD:()=>n,hS:()=>f,xd:()=>a,y:()=>l});class n extends Error{constructor(e,t,r){super(e),this.status=t,this.data=r,this.name="ApiError"}}async function o(e,t,r){if(!(e.headers.get("content-type")||"").includes("application/json"))return t;try{return await e.json()}catch(e){return t}}function i(e){var t;return e.redirected&&(null!=(t=e.url)?t:"").includes("/login")?new n("Authentication required",401):null}function a(e){return e.headers?(e.headers.get("content-type")||"").includes("application/json")?null:new n("Unexpected response format",e.status):null}async function s(e,t){try{let r=new Headers(null==t?void 0:t.headers);r.set("Content-Type","application/json");let s=await fetch(e,{...t,headers:r}),l=i(s);if(l)throw l;if(!s.ok){let e=await o(s,{},"error-body");throw new n(e.error||"HTTP error ".concat(s.status),s.status,e)}let c=a(s);if(c)throw c;return s.json()}catch(e){if(e instanceof n)throw e;throw new n(e instanceof Error?e.message:"Unknown error",0,e)}}let l={getAll:async()=>s("/api/worktrees"),getById:async e=>s("/api/worktrees/".concat(e)),updateDescription:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({description:t})}),updateLink:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({link:t})}),toggleFavorite:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({favorite:t})}),updateStatus:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({status:t})}),updateCliTool:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({cliToolId:t})}),markAsViewed:async e=>s("/api/worktrees/".concat(e,"/viewed"),{method:"PATCH"}),async getMessages(e,t,r,n){let o=new URLSearchParams;return t&&o.append("cliTool",t),r&&o.append("includeArchived","true"),"number"==typeof n&&Number.isFinite(n)&&o.append("limit",String(n)),s("/api/worktrees/".concat(e,"/messages").concat(o.toString()?"?".concat(o.toString()):""))},async sendMessage(e,t,r){var n;let o={content:t};return(null==r?void 0:r.cliToolId)&&(o.cliToolId=r.cliToolId),(null==r?void 0:r.instanceId)&&(o.instanceId=r.instanceId),(null==r?void 0:r.imagePath)&&(o.imagePath=r.imagePath),null===(n=await s("/api/worktrees/".concat(e,"/send"),{method:"POST",body:JSON.stringify(o)}))||"object"!=typeof n||n.timestamp instanceof Date?n:{...n,timestamp:new Date(n.timestamp)}},async uploadImageFile(e,t){let r=Date.now(),n="".concat(r,"-").concat(t.name),i=".commandmate/attachments",a=new FormData;a.append("file",new File([t],n,{type:t.type}));let s=await fetch("/api/worktrees/".concat(e,"/upload/").concat(i),{method:"POST",body:a});if(!s.ok){var l;let e=await o(s,{},"error-body");throw Error((null==e||null==(l=e.error)?void 0:l.message)||"Upload failed (HTTP ".concat(s.status,")"))}return{path:(await o(s,{},"response-body")).path||"".concat(i,"/").concat(n)}},getLogs:async e=>s("/api/worktrees/".concat(e,"/logs")),async getLogFile(e,t,r){let n=(null==r?void 0:r.sanitize)?"?sanitize=true":"";return s("/api/worktrees/".concat(e,"/logs/").concat(t).concat(n))},async killSession(e,t,r){let n=new URLSearchParams;t&&n.set("cliTool",t),r&&n.set("instance",r);let o=n.toString();return s("/api/worktrees/".concat(e,"/kill-session").concat(o?"?".concat(o):""),{method:"POST"})}},c={scan:async e=>s("/api/repositories/scan",{method:"POST",body:JSON.stringify({repositoryPath:e})}),sync:async()=>s("/api/repositories/sync",{method:"POST"}),delete:async e=>s("/api/repositories",{method:"DELETE",body:JSON.stringify({repositoryPath:e})}),async clone(e,t){var r;return s("/api/repositories/clone",{method:"POST",body:JSON.stringify({cloneUrl:e,fork:null!=(r=null==t?void 0:t.fork)&&r})})},getCloneStatus:async e=>s("/api/repositories/clone/".concat(e)),getExcluded:async()=>s("/api/repositories/excluded"),restore:async e=>s("/api/repositories/restore",{method:"PUT",body:JSON.stringify({repositoryPath:e})}),list:async()=>s("/api/repositories"),updateDisplayName:async(e,t)=>s("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({displayName:t})}),updateVisibility:async(e,t)=>s("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({visible:t})}),updateEnabled:async(e,t)=>s("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({enabled:t})}),validatePath:async e=>s("/api/repositories/validate-path",{method:"POST",body:JSON.stringify({repositoryPath:e})})},u={async browse(e){let t=e?"?path=".concat(encodeURIComponent(e)):"";return s("/api/fs/browse".concat(t))},addRecentPath:async e=>s("/api/fs/recent-paths",{method:"POST",body:JSON.stringify({path:e})})},d={getAll:async e=>(await s("/api/worktrees/".concat(e,"/memos"))).memos,create:async(e,t)=>(await s("/api/worktrees/".concat(e,"/memos"),{method:"POST",body:JSON.stringify(t||{})})).memo,update:async(e,t,r)=>(await s("/api/worktrees/".concat(e,"/memos/").concat(t),{method:"PUT",body:JSON.stringify(r)})).memo,delete:async(e,t)=>s("/api/worktrees/".concat(e,"/memos/").concat(t),{method:"DELETE"}),async reorder(e,t){await s("/api/worktrees/".concat(e,"/memos"),{method:"PATCH",body:JSON.stringify({memoIds:t})})}};function f(e){return e instanceof n||e instanceof Error?e.message:"An unknown error occurred"}let p={checkForUpdate:async()=>s("/api/app/update-check",{method:"GET"}),startUpdate:async()=>s("/api/app/update",{method:"POST"}),async ping(){try{return(await fetch("/api/auth/status",{cache:"no-store"})).ok}catch(e){return!1}}}},89275:(e,t,r)=>{r.d(t,{Bo:()=>u,Hq:()=>l});var n=r(95155),o=r(12115),i=r(20063);let a={startTransition:e=>e()},s=(0,o.createContext)(null);function l(){var e;let t=(0,i.useRouter)(),{startTransition:r}=null!=(e=(0,o.useContext)(s))?e:a;return(0,o.useMemo)(()=>({push:e=>r(()=>t.push(e)),replace:e=>r(()=>t.replace(e))}),[t,r])}function c(e){let{onCommit:t}=e,r=(0,i.usePathname)(),n=(0,o.useRef)(!1);return(0,o.useEffect)(()=>{if(!n.current){n.current=!0;return}t()},[r,t]),null}function u(e){let{children:t}=e,r=(0,o.useRef)(null),i=(0,o.useCallback)(()=>{var e;null==(e=r.current)||e.call(r)},[]),a=(0,o.useCallback)(e=>{var t;t=()=>new Promise(t=>{let n=!1,o=()=>{n||(n=!0,t())};r.current=o,e(),window.setTimeout(o,500)}),"undefined"==typeof document||"function"!=typeof document.startViewTransition||"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches?t():document.startViewTransition(t)},[]),l=(0,o.useMemo)(()=>({startTransition:a}),[a]);return(0,n.jsxs)(s.Provider,{value:l,children:[(0,n.jsx)(c,{onCommit:i}),t]})}},92614:(e,t,r)=>{r.d(t,{C:()=>s,E:()=>a});var n=r(95155),o=r(12115);let i=(0,o.createContext)({open:!1,setOpen:()=>{},toggle:()=>{}});function a(e){let{children:t}=e,[r,a]=(0,o.useState)(!1),s=(0,o.useCallback)(()=>a(e=>!e),[]),l=(0,o.useMemo)(()=>({open:r,setOpen:a,toggle:s}),[r,s]);return(0,n.jsx)(i.Provider,{value:l,children:t})}function s(){return(0,o.useContext)(i)}},94442:(e,t,r)=>{r.d(t,{dj:()=>v,tE:()=>S});var n=r(95155),o=r(12115),i=r(47650),a=r(18955),s=r(42529),l=r(78874),c=r(52056),u=r(23327),d=r(65229),f=r(59854),p=r(9900),g=r(9286);function m(e){let{type:t,iconColor:r}=e,o="h-5 w-5 ".concat(r);switch(t){case"success":return(0,n.jsx)(s.A,{className:o,"data-testid":"toast-icon-success"});case"error":return(0,n.jsx)(l.A,{className:o,"data-testid":"toast-icon-error"});case"warning":return(0,n.jsx)(c.A,{className:o,"data-testid":"toast-icon-warning"});default:return(0,n.jsx)(u.A,{className:o,"data-testid":"toast-icon-info"})}}function y(e){let{id:t,message:r,type:i,onClose:s,duration:l=3e3,onClick:c}=e,u=(0,a.c)("common"),f=(0,o.useRef)(null),y=function(e){switch(e){case"success":return{bgColor:"bg-success-subtle",borderColor:"border-success-border",textColor:"text-success-foreground",iconColor:"text-success-foreground"};case"error":return{bgColor:"bg-danger-subtle",borderColor:"border-danger-border",textColor:"text-danger-foreground",iconColor:"text-danger-foreground"};case"warning":return{bgColor:"bg-warning-subtle",borderColor:"border-warning-border",textColor:"text-warning-foreground",iconColor:"text-warning-foreground"};default:return{bgColor:"bg-info-subtle",borderColor:"border-info-border",textColor:"text-info-foreground",iconColor:"text-info-foreground"}}}(i),[h,w]=(0,o.useState)(!0),{shouldRender:b,isExiting:S}=(0,g.O)(h,p.Ys),v=(0,o.useRef)(s);v.current=s,(0,o.useEffect)(()=>{b||v.current(t)},[b,t]),(0,o.useEffect)(()=>(l>0&&(f.current=setTimeout(()=>{w(!1)},l)),()=>{f.current&&clearTimeout(f.current)}),[l]);let E=(0,o.useCallback)(()=>{f.current&&clearTimeout(f.current),w(!1)},[]);return(0,n.jsxs)("div",{"data-testid":"toast-".concat(t),role:"alert",className:"\n ".concat(y.bgColor,"\n ").concat(y.borderColor,"\n ").concat(y.textColor,"\n border rounded-lg shadow-lg p-4 min-w-[300px] max-w-[400px]\n flex items-start gap-3\n ").concat(S?"animate-out fade-out-0 slide-out-to-right-full duration-200 fill-mode-forwards pointer-events-none":"animate-slide-in","\n "),children:[(0,n.jsx)(m,{type:i,iconColor:y.iconColor}),c?(0,n.jsx)("button",{type:"button","data-testid":"toast-action-button",onClick:()=>{c(),E()},className:"flex-1 text-left text-sm font-medium underline-offset-2 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:r}):(0,n.jsx)("p",{className:"flex-1 text-sm font-medium",children:r}),(0,n.jsx)("button",{"data-testid":"toast-close-button",onClick:E,"aria-label":u("closeNotification"),className:"\n ".concat(y.textColor,"\n hover:opacity-70\n focus:outline-none focus:ring-2 focus:ring-offset-2\n transition-opacity\n "),children:(0,n.jsx)(d.A,{className:"h-4 w-4"})})]})}function h(e){let{toasts:t,onClose:r}=e,[a,s]=(0,o.useState)(!1);(0,o.useEffect)(()=>{s(!0)},[]);let l=(0,n.jsx)("div",{"data-testid":"toast-container","aria-live":"polite",className:"fixed bottom-4 right-4 flex flex-col gap-2",style:{zIndex:f.M.TOAST},children:t.map(e=>(0,n.jsx)(y,{id:e.id,message:e.message,type:e.type,onClose:r,duration:e.duration,onClick:e.onClick},e.id))});return a?(0,i.createPortal)(l,document.body):null}function w(){let[e,t]=(0,o.useState)([]),r=(0,o.useRef)(0),n=(0,o.useCallback)(function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e3,i=arguments.length>3?arguments[3]:void 0,a="toast-".concat(++r.current,"-").concat(Date.now()),s={id:a,message:e,type:n,duration:o,...(null==i?void 0:i.onClick)?{onClick:i.onClick}:{}};return t(e=>[...e,s]),a},[]),i=(0,o.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]),a=(0,o.useCallback)(()=>{t([])},[]);return(0,o.useMemo)(()=>({toasts:e,showToast:n,removeToast:i,clearToasts:a}),[e,n,i,a])}let b=(0,o.createContext)(null);function S(e){let{children:t}=e,r=w();return(0,n.jsxs)(b.Provider,{value:r,children:[t,(0,n.jsx)(h,{toasts:r.toasts,onClose:r.removeToast})]})}function v(){let e=(0,o.useContext)(b),t=w();return null!=e?e:t}}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4718],{2317:(e,t,r)=>{r.d(t,{V:()=>i});var n=r(12115);function o(){try{let e="__localStorage_test__";return window.localStorage.setItem(e,"test"),window.localStorage.removeItem(e),!0}catch(e){return!1}}function i(e){let{key:t,defaultValue:r,validate:i,serialize:a=JSON.stringify,deserialize:s=JSON.parse}=e,l=(0,n.useRef)(r),c=(0,n.useRef)(i),u=(0,n.useRef)(a),d=(0,n.useRef)(s);l.current=r,c.current=i,u.current=a,d.current=s;let[f,p]=(0,n.useState)(!1),[g,m]=(0,n.useState)(r),y=(0,n.useCallback)(()=>{if(!o())return l.current;try{let e=window.localStorage.getItem(t);if(null===e)return l.current;let r=d.current(e);if(c.current)return c.current(r)?r:l.current;return r}catch(e){return l.current}},[t]),h=(0,n.useCallback)(e=>{if(o())try{let r=u.current(e);window.localStorage.setItem(t,r)}catch(e){}},[t]),w=(0,n.useCallback)(e=>{m(t=>{let r="function"==typeof e?e(t):e;return h(r),r})},[h]),b=(0,n.useCallback)(()=>{if(o())try{window.localStorage.removeItem(t)}catch(e){}m(l.current)},[t]);return(0,n.useEffect)(()=>{p(o()),m(y())},[y]),{value:g,setValue:w,removeValue:b,isAvailable:f}}},7636:(e,t,r)=>{r.d(t,{BN:()=>C,EN:()=>a,LV:()=>p,PB:()=>l,Si:()=>i,UZ:()=>d,Xn:()=>b,ZC:()=>T,ZD:()=>E,_s:()=>S,fs:()=>k,j:()=>w,m3:()=>s,nO:()=>g,s6:()=>f,zD:()=>h});var n=r(38606);let o=["updatedAt","repositoryName","branchName","status","lastSent"],i=e=>o.includes(e),a=["always","collapsed","hidden"],s=e=>a.includes(e),l="collapsed",c={waiting:0,ready:1,running:2,generating:3,idle:4},u=["waiting","running","generating","ready","idle"];function d(e){let t=new Set;for(let r of e)!1===r.visible&&t.add(r.path);return t}function f(e,t){return 0===t.size?e.slice():e.filter(e=>{let r=e.repositoryPath;return!r||!t.has(r)})}function p(e){let t=function(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)|0;return Math.abs(t)}(e)%360;return"hsl(".concat(t,", ").concat(65,"%, ").concat(60,"%)")}function g(e,t){if(!e&&!t)return 0;if(!e)return 1;if(!t)return -1;let r=e instanceof Date?e.getTime():new Date(e).getTime();return(t instanceof Date?t.getTime():new Date(t).getTime())-r}function m(e){return e.cliStatus&&Object.keys(e.cliStatus).length>0?(0,n.A7)(e.cliStatus):e.status}function y(e){return"waiting"===m(e)}function h(e){let t=new Set(e.map(m));for(let e of u)if(t.has(e))return e;return"idle"}function w(e){let t=0;for(let r of e)y(r)&&t++;return t}function b(e,t,r){let n=[...e],o="status"!==t;return n.sort((e,n)=>{if(o){let t=Number(y(n))-Number(y(e));if(0!==t)return t}let i=0;switch(t){case"updatedAt":{let t=e=>e?e instanceof Date?e.getTime():new Date(e).getTime():0,r=t(e.lastActivity);i=t(n.lastActivity)-r;break}case"repositoryName":{let t=e.repositoryName.toLowerCase(),r=n.repositoryName.toLowerCase();i=t.localeCompare(r);break}case"branchName":{let t=e.name.toLowerCase(),r=n.name.toLowerCase();i=t.localeCompare(r);break}case"status":i=c[e.status]-c[n.status];break;case"lastSent":{let t=g(e.lastActivity,n.lastActivity);if(!e.lastActivity&&!n.lastActivity){i=0;break}if(!e.lastActivity)return 1;if(!n.lastActivity)return -1;i=t;break}default:i=0}return("updatedAt"===t||"lastSent"===t?"desc"===r:"asc"===r)?i:-i}),n}function S(e,t,r){let n=new Map;for(let t of e){let e=t.repositoryName;n.has(e)||n.set(e,[]),n.get(e).push(t)}return[...n.keys()].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).map(e=>({repositoryName:e,branches:b(n.get(e),t,r)}))}let v="mcbd-sidebar-group-order-cache";function E(){try{let e=localStorage.getItem(v);if(!e)return[];let t=function(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return[];return t.filter(e=>"string"==typeof e).slice(0,500)}catch(e){return[]}}(e);return t.length,t}catch(e){return[]}}function T(e){try{localStorage.setItem(v,JSON.stringify(e))}catch(e){}}function C(e,t){if(0===t.length)return e.slice();let r=new Map(t.map((e,t)=>[e,t]));return e.slice().sort((e,t)=>{let n=r.has(e.repositoryName)?r.get(e.repositoryName):1/0,o=r.has(t.repositoryName)?r.get(t.repositoryName):1/0;return n===o?e.repositoryName.localeCompare(t.repositoryName):n-o})}function k(e,t){return"hidden"!==e&&("always"===e||!t)}},22592:(e,t,r)=>{r.d(t,{Ps:()=>d,W5:()=>u});var n=r(95155),o=r(12115),i=r(38218),a=r(68704);let s="data-pc-size",l={size:a.r5,setSize:()=>{},isMobile:!1,factor:a.d8[a.r5].factor,isAvailable:!1},c=(0,o.createContext)(l);function u(e){let{children:t}=e,{size:r,setSize:l,isAvailable:u}=(0,a.of)(),d=(0,i.a)();(0,o.useEffect)(()=>{if("undefined"==typeof document)return;let e=document.documentElement;return d?void e.removeAttribute(s):(e.setAttribute(s,r),()=>{e.removeAttribute(s)})},[r,d]);let f=(0,o.useMemo)(()=>({size:r,setSize:l,isMobile:d,factor:a.d8[r].factor,isAvailable:u}),[r,l,d,u]);return(0,n.jsx)(c.Provider,{value:f,children:t})}function d(){return(0,o.useContext)(c)}},24373:(e,t,r)=>{r.d(t,{Kg:()=>i,Lv:()=>a});var n=r(12115),o=r(66966);function i(e){let t=0;for(let r of e)!0===r.isWaitingForResponse&&t++;return t}function a(){let e=(0,o.rC)(),t=null==e?void 0:e.worktrees;return(0,n.useMemo)(()=>{let e=t?t.filter(e=>!0===e.isWaitingForResponse):[];return{count:e.length,worktrees:e}},[t])}r(44308)},32916:(e,t,r)=>{r.d(t,{GB:()=>u,VF:()=>d,pT:()=>f});var n=r(95155),o=r(12115),i=r(7636);let a="updatedAt",s=(0,o.createContext)(null);function l(e,t,r,n){let i=(0,o.useRef)(!0);(0,o.useEffect)(()=>{try{let t=localStorage.getItem(e);t&&n(t)}catch(e){}},[]),(0,o.useEffect)(()=>{if(i.current){i.current=!1;return}try{localStorage.setItem(e,r())}catch(e){}},[t])}function c(e,t){switch(t.type){case"TOGGLE":return{...e,isOpen:!e.isOpen};case"SET_WIDTH":return{...e,width:t.width};case"OPEN_MOBILE_DRAWER":return{...e,isMobileDrawerOpen:!0};case"CLOSE_MOBILE_DRAWER":return{...e,isMobileDrawerOpen:!1};case"SET_SORT_KEY":return{...e,sortKey:t.sortKey};case"SET_SORT_DIRECTION":return{...e,sortDirection:t.sortDirection};case"LOAD_SORT_SETTINGS":return{...e,sortKey:t.sortKey,sortDirection:t.sortDirection};case"SET_VIEW_MODE":return{...e,viewMode:t.viewMode};case"SET_OPEN":return e.isOpen===t.isOpen?e:{...e,isOpen:t.isOpen};case"SET_REPOSITORY_ORDER":return{...e,repositoryOrder:t.repositoryOrder};case"SET_REPO_TAB_BAR_MODE":return{...e,repoTabBarMode:t.repoTabBarMode};default:return e}}function u(e){let{children:t,initialOpen:r=!0,initialWidth:u=224}=e,[d,f]=(0,o.useReducer)(c,{isOpen:r,width:u,isMobileDrawerOpen:!1,sortKey:a,sortDirection:"desc",viewMode:"grouped",repositoryOrder:(0,i.ZD)(),repoTabBarMode:i.PB});l("mcbd-sidebar-sort","".concat(d.sortKey,":").concat(d.sortDirection),()=>JSON.stringify({sortKey:d.sortKey,sortDirection:d.sortDirection}),e=>{try{let t=JSON.parse(e),r=t.sortDirection,n=(0,i.Si)(t.sortKey)?t.sortKey:a;n&&("asc"===r||"desc"===r)&&f({type:"LOAD_SORT_SETTINGS",sortKey:n,sortDirection:r})}catch(e){}}),l("mcbd-sidebar-view-mode",d.viewMode,()=>d.viewMode,e=>{("grouped"===e||"flat"===e)&&f({type:"SET_VIEW_MODE",viewMode:e})}),l("mcbd-sidebar-width",d.width,()=>String(d.width),e=>{let t=Number(e);!isNaN(t)&&t>0&&f({type:"SET_WIDTH",width:288===t?224:t})}),l("mcbd-sidebar-open",d.isOpen,()=>String(d.isOpen),e=>{("true"===e||"false"===e)&&f({type:"SET_OPEN",isOpen:"true"===e})}),l("mcbd-repo-tab-bar-mode",d.repoTabBarMode,()=>d.repoTabBarMode,e=>{(0,i.m3)(e)&&f({type:"SET_REPO_TAB_BAR_MODE",repoTabBarMode:e})});let p=(0,o.useCallback)(()=>{f({type:"TOGGLE"})},[]),g=(0,o.useCallback)(e=>{f({type:"SET_WIDTH",width:e})},[]),m=(0,o.useCallback)(()=>{f({type:"OPEN_MOBILE_DRAWER"})},[]),y=(0,o.useCallback)(()=>{f({type:"CLOSE_MOBILE_DRAWER"})},[]),h=(0,o.useCallback)(e=>{f({type:"SET_SORT_KEY",sortKey:e})},[]),w=(0,o.useCallback)(e=>{f({type:"SET_SORT_DIRECTION",sortDirection:e})},[]),b=(0,o.useCallback)(e=>{f({type:"SET_VIEW_MODE",viewMode:e})},[]),S=(0,o.useCallback)(e=>{f({type:"SET_REPOSITORY_ORDER",repositoryOrder:e}),(0,i.ZC)(e)},[]),v=(0,o.useCallback)(e=>{f({type:"SET_REPO_TAB_BAR_MODE",repoTabBarMode:e})},[]),E=(0,o.useMemo)(()=>({isOpen:d.isOpen,width:d.width,isMobileDrawerOpen:d.isMobileDrawerOpen,sortKey:d.sortKey,sortDirection:d.sortDirection,toggle:p,setWidth:g,openMobileDrawer:m,closeMobileDrawer:y,setSortKey:h,setSortDirection:w,viewMode:d.viewMode,setViewMode:b,repositoryOrder:d.repositoryOrder,setRepositoryOrder:S,repoTabBarMode:d.repoTabBarMode,setRepoTabBarMode:v}),[d.isOpen,d.width,d.isMobileDrawerOpen,d.sortKey,d.sortDirection,d.viewMode,d.repositoryOrder,d.repoTabBarMode,p,g,m,y,h,w,b,S,v]);return(0,n.jsx)(s.Provider,{value:E,children:t})}function d(){let e=(0,o.useContext)(s);if(!e)throw Error("useSidebarContext must be used within a SidebarProvider");return e}function f(){return(0,o.useContext)(s)}},38218:(e,t,r)=>{r.d(t,{D:()=>i,a:()=>a});var n=r(12115);let o=n.useLayoutEffect,i=768;function a(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{breakpoint:t=i}=e,[r,a]=(0,n.useState)(!1);return o(()=>{let e=window.matchMedia("(max-width: ".concat(t-1,"px)"));a(e.matches);let r=e=>{a(e.matches)};return e.addEventListener("change",r),()=>{e.removeEventListener("change",r)}},[t]),r}},38606:(e,t,r)=>{r.d(t,{A7:()=>c,kA:()=>i,f_:()=>f,dw:()=>u,XK:()=>p});var n=r(54014),o=r(55449);function i(e){return e?e.isWaitingForResponse?"waiting":e.isProcessing?"running":e.isRunning?"ready":"idle":"idle"}let a={start:"nextAction.start",sendMessage:"nextAction.sendMessage",approveReject:"nextAction.approveReject",replyToPrompt:"nextAction.replyToPrompt",checkStalled:"nextAction.checkStalled",running:"nextAction.running"};Object.values(a);let s="exited",l={idle:null,ready:"ready",running:"running",generating:"running",waiting:"waiting"};function c(e){if(!e)return"idle";let t=Object.values(e).filter(e=>void 0!==e);return 0===t.length?"idle":t.includes("waiting")?"waiting":t.includes("running")?"running":t.includes("generating")?"generating":t.includes("ready")?"ready":"idle"}function u(e,t,r){return e?Object.entries(e).map(e=>{var o;let[i,a]=e,s=null!=(o=null==t?void 0:t[i])?o:(0,n.f_)(i,i),l=null==r?void 0:r(i);return"".concat(s,": ").concat(null!=a?a:"idle").concat(l?" (".concat(l,")"):"")}).join(", "):""}let d=["prompt","menu","unclassified"];function f(e){var t,r,n;let o=Object.values(null!=(r=null!=(t=e.sessionStatusByInstance)?t:e.sessionStatusByCli)?r:{}).filter(e=>void 0!==e),i=!1,a=new Set;for(let e of o)e.awaitingInstruction&&(i=!0),e.waitingKind&&a.add(e.waitingKind);return{waitingKind:null!=(n=d.find(e=>a.has(e)))?n:null,awaitingInstruction:i}}function p(e){var t,r,u,d,p,g;let m=i(void 0!==e.isSessionRunning?{isRunning:null!=(t=e.isSessionRunning)&&t,isWaitingForResponse:null!=(r=e.isWaitingForResponse)&&r,isProcessing:null!=(u=e.isProcessing)&&u}:void 0),y=!!e.lastAssistantMessageAt&&(!e.lastViewedAt||new Date(e.lastAssistantMessageAt)>new Date(e.lastViewedAt)),{cliStatus:h,cliStatusLabels:w,exitedInstanceIds:b}=function(e){var t,r,a,l,c,u;let d={},f={},p=[],g=e.sessionStatusByInstance;if(!g){for(let c of null!=(t=e.selectedAgents)?t:(0,o.sA)())d[c]=i(null==(r=e.sessionStatusByCli)?void 0:r[c]),f[c]=(0,n.oo)(c),(null==(l=e.sessionStatusByCli)||null==(a=l[c])?void 0:a.sessionStatusReason)===s&&p.push(c);return{cliStatus:d,cliStatusLabels:f,exitedInstanceIds:p}}let m=e.agentInstances&&e.agentInstances.length>0?e.agentInstances:(0,n.lu)(null!=(c=e.selectedAgents)?c:(0,o.sA)()),y=new Set;for(let e of m)y.add(e.id),d[e.id]=i(g[e.id]),f[e.id]=(0,n.sw)(e),(null==(u=g[e.id])?void 0:u.sessionStatusReason)===s&&p.push(e.id);for(let[e,t]of Object.entries(g)){if(y.has(e))continue;let r=i(t);"idle"!==r&&(d[e]=r,f[e]=function(e){let t=n.XH.find(t=>e.startsWith("".concat(t,"-")));if(t){let r=e.slice(t.length+1);return"".concat((0,n.oo)(t)," ").concat(r)}return(0,n.f_)(e,e)}(e))}return{cliStatus:d,cliStatusLabels:f,exitedInstanceIds:p}}(e),S=c(h),{waitingKind:v,awaitingInstruction:E}=f(e);return{id:e.id,name:e.name,repositoryName:null!=(d=e.repositoryDisplayName)?d:e.repositoryName,status:m,hasUnread:y,lastActivity:e.updatedAt,description:e.description,cliStatus:h,cliStatusLabels:w,exitedInstanceIds:b,worktreePath:e.path,waitingKind:v,awaitingInstruction:E,nextActionKey:(p=l[S],g="waiting"===S?"approval":null,p&&"idle"!==p?"ready"===p?a.sendMessage:"waiting"===p&&"approval"===g?a.approveReject:"waiting"===p?a.replyToPrompt:(0,a.running):a.start)}}},39649:(e,t,r)=>{r.d(t,{$f:()=>d,H8:()=>u});var n=r(95155),o=r(12115),i=r(80344);let a={PROCESSING:2e3,SESSION_RUNNING:5e3,IDLE:1e4},s=(0,o.createContext)(null),l={selectedWorktreeId:null,worktrees:[],repositories:[],selectedWorktreeDetail:null,isLoading:!0,isLoadingDetail:!1,error:null};function c(e,t){switch(t.type){case"SET_WORKTREES":return{...e,worktrees:t.worktrees,isLoading:!1};case"SET_REPOSITORIES":return{...e,repositories:t.repositories};case"SELECT_WORKTREE":{var r;let n=null!=(r=e.worktrees.find(e=>e.id===t.id))?r:null;return{...e,selectedWorktreeId:t.id,selectedWorktreeDetail:null!=n?n:e.selectedWorktreeDetail,isLoadingDetail:null===n}}case"SET_WORKTREE_DETAIL":return{...e,selectedWorktreeDetail:t.detail};case"SET_LOADING":return{...e,isLoading:t.isLoading};case"SET_LOADING_DETAIL":return{...e,isLoadingDetail:t.isLoadingDetail};case"SET_ERROR":return{...e,error:t.error,isLoading:!1};default:return e}}function u(e){let{children:t,externalWorktrees:r,externalRepositories:u,externalIsLoading:d,externalError:f,externalRefresh:p}=e,g=void 0!==r,[m,y]=(0,o.useReducer)(c,l);(0,o.useEffect)(()=>{g&&r&&y({type:"SET_WORKTREES",worktrees:r})},[g,r]),(0,o.useEffect)(()=>{g&&u&&y({type:"SET_REPOSITORIES",repositories:u})},[g,u]);let h=(0,o.useCallback)(async()=>{if(!g){y({type:"SET_LOADING",isLoading:!0}),y({type:"SET_ERROR",error:null});try{var e;let t=await i.y.getAll();y({type:"SET_WORKTREES",worktrees:t.worktrees}),y({type:"SET_REPOSITORIES",repositories:null!=(e=t.repositories)?e:[]})}catch(e){y({type:"SET_ERROR",error:e instanceof Error?e.message:"Failed to fetch worktrees"})}}},[g]),w=(0,o.useCallback)(async e=>{y({type:"SELECT_WORKTREE",id:e}),y({type:"SET_ERROR",error:null});try{i.y.markAsViewed(e).catch(e=>{console.warn("[WorktreeSelectionContext] Failed to mark as viewed:",e)});let t=await i.y.getById(e);y({type:"SET_WORKTREE_DETAIL",detail:t})}catch(e){y({type:"SET_ERROR",error:e instanceof Error?e.message:"Failed to fetch worktree detail"})}finally{y({type:"SET_LOADING_DETAIL",isLoadingDetail:!1})}},[]),b=(0,o.useCallback)(async()=>{if(g&&p)return void await p();await h()},[g,p,h]);(0,o.useEffect)(()=>{g||h()},[h,g]),(0,o.useEffect)(()=>{if(g)return;let e=null,t=!0,r=async()=>{if(t)try{var n,o;let s=await i.y.getAll();y({type:"SET_WORKTREES",worktrees:s.worktrees}),y({type:"SET_REPOSITORIES",repositories:null!=(n=s.repositories)?n:[]});let l=(o=s.worktrees).some(e=>e.isProcessing||e.isWaitingForResponse)?a.PROCESSING:o.some(e=>e.isSessionRunning)?a.SESSION_RUNNING:a.IDLE;t&&(e=setTimeout(r,l))}catch(n){if(n instanceof i.hD&&401===n.status)return;console.error("[WorktreeSelectionContext] Polling error:",n),t&&(e=setTimeout(r,a.SESSION_RUNNING))}};return r(),()=>{t=!1,e&&clearTimeout(e)}},[g]);let S=g&&void 0!==d?d:m.isLoading,v=g&&f?f.message:null,E={selectedWorktreeId:m.selectedWorktreeId,worktrees:m.worktrees,repositories:m.repositories,selectedWorktreeDetail:m.selectedWorktreeDetail,isLoading:S,isLoadingDetail:m.isLoadingDetail,error:null!=v?v:m.error,selectWorktree:w,refreshWorktrees:b};return(0,n.jsx)(s.Provider,{value:E,children:t})}function d(){let e=(0,o.useContext)(s);if(!e)throw Error("useWorktreeSelection must be used within a WorktreeSelectionProvider");return e}},44308:(e,t,r)=>{r.d(t,{$h:()=>d,DR:()=>o,IH:()=>c,Iu:()=>n,Nb:()=>f,SD:()=>i,_d:()=>l,bm:()=>p,ks:()=>s,t7:()=>u,z7:()=>a});let n=7e3,o=["in_review","approval","stalled"],i="in_review",a="filter",s="/review?".concat(a,"=approval");function l(e){return e&&o.includes(e)?e:null}let c=["claude","codex","copilot","antigravity","opencode"],u=1e3,d=5,f=100,p=1e3},52703:(e,t,r)=>{r.d(t,{Oo:()=>o,ST:()=>n,T4:()=>s,dz:()=>a,rz:()=>i,zS:()=>l});let n="client_version",o="version_mismatch",i="chat_turn_progress",a="messages_invalidated",s="model_changed";function l(e){let t;try{t=JSON.parse(e)}catch(e){return null}if(!t||"object"!=typeof t)return null;let r=t;if("broadcast"===r.type){let e=r.data;return e&&"object"==typeof e?"string"!=typeof e.type?null:(void 0===e.worktreeId&&"string"==typeof r.worktreeId&&(e.worktreeId=r.worktreeId),e):null}return"string"==typeof r.type?r:null}},54014:(e,t,r)=>{r.d(t,{Ab:()=>o,NL:()=>y,O6:()=>p,XH:()=>n,f_:()=>d,hR:()=>c,lu:()=>g,n6:()=>s,oo:()=>u,pQ:()=>i,sw:()=>f,vz:()=>m});let n=["claude","codex","gemini","vibe-local","opencode","copilot","antigravity","command-code"],o=10,i=50,a=/^[a-zA-Z0-9_-]+$/;function s(e){return"string"==typeof e&&e.length>0&&e.length<=64&&a.test(e)}let l={claude:"Claude",codex:"Codex",gemini:"Gemini","vibe-local":"Vibe Local",opencode:"OpenCode",copilot:"Copilot",antigravity:"Antigravity","command-code":"Command Code"};function c(e){return n.includes(e)}function u(e){var t;return null!=(t=l[e])?t:e}function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Assistant";return e&&c(e)?u(e):t}function f(e){let t=e.alias;return"string"==typeof t&&t.trim().length>0?t:u(e.cliTool)}function p(e,t,r){let n=e.find(e=>e.id===t);return n?f(n):u(r)}function g(e){return e.map((e,t)=>({id:e,cliTool:e,alias:u(e),order:t}))}let m=128,y=2097152},55449:(e,t,r)=>{r.d(t,{IK:()=>l,qD:()=>d,sA:()=>s,zk:()=>o});var n=r(63001);let o="/api/settings/default-agents",i=n.fJ,a=new Set;function s(){return i}function l(e){if(!Array.isArray(e))return!1;let t=(0,n.Lt)(e);if(!t.valid)return!1;let r=t.value;if(r.length===i.length&&r.every((e,t)=>e===i[t]))return!1;for(let e of(i=r,a))e();return!0}let c=null,u=!1;async function d(){return u?i:c||("function"!=typeof fetch?i:c=(async()=>{try{let e=await fetch(o);if(e.ok){let t=await e.json();l(null==t?void 0:t.defaultSelectedAgents),u=!0}}catch(e){}finally{c=null}return i})())}},63001:(e,t,r)=>{r.d(t,{Lt:()=>s,Wj:()=>i,eu:()=>o,fJ:()=>a});var n=r(54014);let o=2,i=6,a=["claude","codex","antigravity"];function s(e){return e.length<o||e.length>i?{valid:!1,error:"Must be ".concat(o,"-").concat(i," elements")}:e.every(e=>"string"==typeof e&&n.XH.includes(e))?new Set(e).size!==e.length?{valid:!1,error:"Duplicate tool IDs not allowed"}:{valid:!0,value:e}:{valid:!1,error:"Invalid CLI tool ID"}}},63365:(e,t,r)=>{r.d(t,{tS:()=>u,xM:()=>d,T3:()=>f});var n=r(95155),o=r(12115),i=r(52703);function a(){return"undefined"!=typeof globalThis&&"function"==typeof globalThis.WebSocket?globalThis.WebSocket:null}let s=()=>{},l={status:"disconnected",connected:!1,subscribe:s,unsubscribe:s,addListener:()=>s},c=(0,o.createContext)(null);function u(e){let{children:t,enabled:r=!0}=e,s=(0,o.useRef)(new Set),l=(0,o.useRef)(new Map),{status:u,subscribe:d,unsubscribe:f}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{onEvent:t,onStatusChange:r,autoReconnect:n=!0,reconnectBaseDelay:s=1e3,reconnectMaxDelay:l=3e4,enabled:c=!0}=e,[u,d]=(0,o.useState)("disconnected"),f=(0,o.useRef)(null),p=(0,o.useRef)(null),g=(0,o.useRef)(0),m=(0,o.useRef)(new Set),y=(0,o.useRef)(!1),h=(0,o.useRef)(t);h.current=t;let w=(0,o.useRef)(r);w.current=r;let b=(0,o.useCallback)(e=>{var t;d(e),null==(t=w.current)||t.call(w,e)},[]),S=(0,o.useCallback)(()=>{null!==p.current&&(clearTimeout(p.current),p.current=null)},[]),v=(0,o.useCallback)(()=>{if(!c)return;let e=a();if(!e||f.current&&(f.current.readyState===e.OPEN||f.current.readyState===e.CONNECTING))return;S(),y.current=!1,b("connecting");let t="https:"===window.location.protocol?"wss:":"ws:",r=new e("".concat(t,"//").concat(window.location.host));f.current=r,r.onopen=()=>{g.current=0,b("connected");try{r.send(JSON.stringify({type:i.ST,version:"0.33.0"}))}catch(e){}m.current.forEach(e=>{try{r.send(JSON.stringify({type:"subscribe",worktreeId:e}))}catch(e){}})},r.onmessage=e=>{var t;let r="string"==typeof e.data?e.data:String(e.data),n=(0,i.zS)(r);n&&(null==(t=h.current)||t.call(h,n))},r.onerror=()=>{b("error")},r.onclose=()=>{var e;if(f.current=null,b("disconnected"),y.current||!n||"undefined"!=typeof document&&"hidden"===document.visibilityState)return;let t=(e=g.current,Math.min(s*2**Math.max(0,e),l));g.current+=1,p.current=setTimeout(()=>{p.current=null,v()},t)}},[c,n,s,l,b,S]),E=(0,o.useCallback)(()=>{if(S(),y.current=!0,f.current){try{f.current.close(1e3,"Client disconnect")}catch(e){}f.current=null}},[S]),T=(0,o.useCallback)(e=>{let t=f.current,r=a();if(t&&r&&t.readyState===r.OPEN)try{t.send(JSON.stringify(e))}catch(e){}},[]),C=(0,o.useCallback)(e=>{m.current.has(e)||(m.current.add(e),T({type:"subscribe",worktreeId:e}))},[T]),k=(0,o.useCallback)(e=>{m.current.has(e)&&(m.current.delete(e),T({type:"unsubscribe",worktreeId:e}))},[T]);return(0,o.useEffect)(()=>{if(c)return v(),()=>{E()}},[c,v,E]),(0,o.useEffect)(()=>{if(!c||"undefined"==typeof document)return;let e=()=>{"visible"===document.visibilityState&&(f.current||(g.current=0,v()))};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[c,v]),{status:u,subscribe:C,unsubscribe:k,send:T}}({enabled:r,onEvent:(0,o.useCallback)(e=>{s.current.forEach(t=>{try{t(e)}catch(e){}})},[])}),p=(0,o.useCallback)(e=>{var t;let r=l.current,n=null!=(t=r.get(e))?t:0;r.set(e,n+1),0===n&&d(e)},[d]),g=(0,o.useCallback)(e=>{var t;let r=l.current,n=null!=(t=r.get(e))?t:0;n<=1?(r.delete(e),f(e)):r.set(e,n-1)},[f]),m=(0,o.useCallback)(e=>(s.current.add(e),()=>{s.current.delete(e)}),[]),y=(0,o.useMemo)(()=>({status:u,connected:"connected"===u,subscribe:p,unsubscribe:g,addListener:m}),[u,p,g,m]);return(0,n.jsx)(c.Provider,{value:y,children:t})}function d(){var e;return null!=(e=(0,o.useContext)(c))?e:l}function f(e){let{addListener:t}=d(),r=(0,o.useRef)(e);r.current=e,(0,o.useEffect)(()=>t(e=>r.current(e)),[t])}},65380:(e,t,r)=>{r.d(t,{H:()=>s,O:()=>a});var n=r(95155),o=r(12115);let i=(0,o.createContext)(!1);function a(e){let{children:t,authEnabled:r}=e;return(0,n.jsx)(i.Provider,{value:r,children:t})}function s(){return(0,o.useContext)(i)}},66966:(e,t,r)=>{r.d(t,{g7:()=>u,rC:()=>f,Fn:()=>d});var n=r(95155),o=r(12115),i=r(80344),a=r(63365);let s=[2e3,5e3,1e4];var l=r(39649);let c=(0,o.createContext)(null);function u(e){let{children:t}=e,{worktrees:r,repositories:u,isLoading:d,error:f,refresh:p}=function(){let[e,t]=(0,o.useState)([]),[r,n]=(0,o.useState)([]),[l,c]=(0,o.useState)(!0),[u,d]=(0,o.useState)(null),f=(0,o.useRef)(null),p=(0,o.useRef)([]),g=(0,o.useRef)(null),m=(0,o.useRef)(0),y=(0,o.useRef)(null),h=(0,o.useRef)(async()=>{}),w=(0,o.useCallback)(()=>{null!==y.current&&(clearTimeout(y.current),y.current=null)},[]),{connected:b,subscribe:S,unsubscribe:v,addListener:E}=(0,a.xM)(),T=(0,o.useRef)(b);T.current=b;let C=(0,o.useCallback)(async()=>{try{var e,r;d(null);let a=await fetch("/api/worktrees"),s=(0,i.O0)(a);if(s)throw s;if(!a.ok)throw Error("Failed to fetch worktrees: ".concat(a.status));let l=(0,i.xd)(a);if(l)throw l;let c=await a.json(),u=null!=(e=c.worktrees)?e:[],f=null!=(r=c.repositories)?r:[];(0,o.startTransition)(()=>{t(u),n(f)}),p.current=u,m.current=0,w()}catch(r){let e=r instanceof Error?r:Error(String(r));console.error("[useWorktreesCache] Failed to fetch worktrees:",e),d(e);let t=m.current;0===p.current.length&&t<s.length&&(m.current=t+1,w(),y.current=setTimeout(()=>{y.current=null,h.current()},s[t]))}finally{c(!1)}},[w]);h.current=C,(0,o.useEffect)(()=>{C()},[C]),(0,o.useEffect)(()=>w,[w]);let k=(0,o.useCallback)(()=>p.current.some(e=>!0===e.isSessionRunning),[]),O=(0,o.useCallback)(()=>{let e=k();return T.current?e?2e4:6e4:e?5e3:3e4},[k]),R=(0,o.useCallback)(()=>{null!==f.current&&(clearInterval(f.current),f.current=null),g.current=null},[]),x=(0,o.useCallback)(()=>{R();let e=O();g.current=e,f.current=setInterval(()=>{C()},e)},[O,C,R]);(0,o.useEffect)(()=>{let e=()=>{document.hidden?R():(C(),x())},t=setTimeout(()=>{x()},0);return document.addEventListener("visibilitychange",e),()=>{clearTimeout(t),R(),document.removeEventListener("visibilitychange",e)}},[C,x,R]),(0,o.useEffect)(()=>{if(p.current=e,"undefined"!=typeof document&&document.hidden||null===g.current)return;let t=O();g.current!==t&&x()},[e,b,O,x]);let N=e.map(e=>e.id).sort().join(" ");return(0,o.useEffect)(()=>{let e=N.length>0?N.split(" "):[];return e.forEach(e=>S(e)),()=>{e.forEach(e=>v(e))}},[N,S,v]),(0,o.useEffect)(()=>E(e=>{if("session_status_changed"===e.type&&"string"==typeof e.worktreeId){let i=e.worktreeId,a=e.isWaitingForResponse;if("boolean"==typeof a){var r,n;let s=null!=(r=e.instance)?r:null,l=null!=(n=e.waitingKind)?n:null;(0,o.startTransition)(()=>{t(e=>{let t=!1,r=e.map(e=>{if(e.id!==i)return e;let r=function(e,t){var r,n,o;let i,a=null!=(n=t.instance)?n:null,s=a?null==(r=e.sessionStatusByInstance)?void 0:r[a]:void 0,l=e.sessionStatusByInstance;if(a&&s&&s.isWaitingForResponse!==t.waiting&&(l={...e.sessionStatusByInstance,[a]:{...s,isWaitingForResponse:t.waiting,waitingKind:null!=(o=t.waitingKind)?o:null}}),t.waiting)i=!0;else{let e=l?Object.values(l):[];i=e.length>0&&e.some(e=>(null==e?void 0:e.isWaitingForResponse)===!0)}return l===e.sessionStatusByInstance&&i===e.isWaitingForResponse?e:{...e,sessionStatusByInstance:l,isWaitingForResponse:i}}(e,{waiting:a,instance:s,waitingKind:l});return r!==e&&(t=!0),r});return t?r:e})});return}let s=e.isRunning;if("boolean"==typeof s){if((null!=e.cliTool||null!=e.instance)&&!1===s)return void C();(0,o.startTransition)(()=>{t(e=>{let t=!1,r=e.map(e=>e.id===i&&e.isSessionRunning!==s?(t=!0,{...e,isSessionRunning:s}):e);return t?r:e})})}}else("message"===e.type||"message_updated"===e.type)&&C()}),[E,C]),{worktrees:e,repositories:r,isLoading:l,error:u,refresh:C}}(),g=(0,o.useMemo)(()=>({worktrees:r,repositories:u,isLoading:d,error:f,refresh:p}),[r,u,d,f,p]);return(0,n.jsx)(c.Provider,{value:g,children:(0,n.jsx)(l.H8,{externalWorktrees:r,externalRepositories:u,externalIsLoading:d,externalError:f,externalRefresh:p,children:t})})}function d(){let e=(0,o.useContext)(c);if(null===e)throw Error("useWorktreesCacheContext must be used within a WorktreesCacheProvider");return e}function f(){return(0,o.useContext)(c)}},68704:(e,t,r)=>{r.d(t,{Uf:()=>i,d8:()=>a,fM:()=>s,of:()=>c,r5:()=>o,rq:()=>l});var n=r(2317);let o="medium",i=["large","medium","small","xsmall"],a={large:{value:"large",rootFontSizePx:18,factor:1.125,terminalFontSize:16},medium:{value:"medium",rootFontSizePx:16,factor:1,terminalFontSize:14},small:{value:"small",rootFontSizePx:14,factor:.875,terminalFontSize:12},xsmall:{value:"xsmall",rootFontSizePx:12.5,factor:.78,terminalFontSize:11}};function s(e){return"string"==typeof e&&Object.prototype.hasOwnProperty.call(a,e)}function l(e){return a[e].terminalFontSize}function c(){let{value:e,setValue:t,isAvailable:r}=(0,n.V)({key:"mcbd-pc-display-size",defaultValue:o,validate:s});return{size:e,setSize:t,isAvailable:r}}},70628:(e,t,r)=>{r.d(t,{K:()=>s,S:()=>a});var n=r(95155),o=r(12115);let i=(0,o.createContext)({open:!1,setOpen:()=>{},toggle:()=>{}});function a(e){let{children:t}=e,[r,a]=(0,o.useState)(!1),s=(0,o.useCallback)(()=>a(e=>!e),[]),l=(0,o.useMemo)(()=>({open:r,setOpen:a,toggle:s}),[r,s]);return(0,n.jsx)(i.Provider,{value:l,children:t})}function s(){return(0,o.useContext)(i)}},77016:(e,t,r)=>{r.d(t,{W:()=>w,n:()=>b});var n=r(95155),o=r(12115),i=r(18955),a=r(52056),s=r(89559),l=r(65229),c=r(59854),u=r(63365),d=r(52703);let f=0,p=new Set;function g(){for(let e of p)e()}function m(e){return p.add(e),()=>{p.delete(e)}}function y(){return f>0}function h(){return!1}function w(){return(0,o.useSyncExternalStore)(m,y,h)}function b(){let e=(0,i.c)("common"),[t,r]=(0,o.useState)(null),[p,m]=(0,o.useState)(null),y=(0,o.useCallback)(e=>{if(e.type!==d.Oo)return;let{serverVersion:t,clientVersion:n}=e;"string"==typeof t&&"string"==typeof n&&t&&n&&t!==p&&r({serverVersion:t,clientVersion:n})},[p]);(0,u.T3)(y);let h=null!==t;(0,o.useEffect)(()=>{if(h)return f+=1,g(),()=>{f-=1,g()}},[h]);let w=(0,o.useCallback)(()=>{window.location.reload()},[]),b=(0,o.useCallback)(()=>{r(e=>(e&&m(e.serverVersion),null))},[]);return t?(0,n.jsxs)("div",{"data-testid":"version-mismatch-banner",role:"alert","aria-live":"assertive",className:"fixed top-3 left-1/2 -translate-x-1/2 flex items-start gap-3 max-w-[92vw] rounded-lg border border-warning-border bg-warning-subtle px-4 py-3 text-warning-foreground shadow-lg",style:{zIndex:c.M.TOAST},children:[(0,n.jsx)(a.A,{className:"h-5 w-5 shrink-0 mt-0.5","aria-hidden":"true"}),(0,n.jsxs)("div",{className:"flex flex-col gap-0.5 text-sm",children:[(0,n.jsx)("span",{className:"font-semibold",children:e("versionMismatch.title")}),(0,n.jsx)("span",{children:e("versionMismatch.description",{serverVersion:t.serverVersion,clientVersion:t.clientVersion})})]}),(0,n.jsxs)("button",{type:"button","data-testid":"version-mismatch-reload",onClick:w,className:"shrink-0 inline-flex items-center gap-1.5 rounded-md border border-warning-border px-3 py-1.5 text-sm font-medium hover:opacity-80 focus:outline-none focus:ring-2 focus:ring-offset-2",children:[(0,n.jsx)(s.A,{className:"h-4 w-4","aria-hidden":"true"}),e("versionMismatch.reload")]}),(0,n.jsx)("button",{type:"button","data-testid":"version-mismatch-dismiss",onClick:b,"aria-label":e("versionMismatch.dismiss"),className:"shrink-0 hover:opacity-70 focus:outline-none focus:ring-2 focus:ring-offset-2",children:(0,n.jsx)(l.A,{className:"h-4 w-4","aria-hidden":"true"})})]}):null}},80344:(e,t,r)=>{r.d(t,{$T:()=>d,GQ:()=>p,O0:()=>i,Rx:()=>c,gC:()=>u,hD:()=>n,hS:()=>f,xd:()=>a,y:()=>l});class n extends Error{constructor(e,t,r){super(e),this.status=t,this.data=r,this.name="ApiError"}}async function o(e,t,r){if(!(e.headers.get("content-type")||"").includes("application/json"))return t;try{return await e.json()}catch(e){return t}}function i(e){var t;return e.redirected&&(null!=(t=e.url)?t:"").includes("/login")?new n("Authentication required",401):null}function a(e){return e.headers?(e.headers.get("content-type")||"").includes("application/json")?null:new n("Unexpected response format",e.status):null}async function s(e,t){try{let r=new Headers(null==t?void 0:t.headers);r.set("Content-Type","application/json");let s=await fetch(e,{...t,headers:r}),l=i(s);if(l)throw l;if(!s.ok){let e=await o(s,{},"error-body");throw new n(e.error||"HTTP error ".concat(s.status),s.status,e)}let c=a(s);if(c)throw c;return s.json()}catch(e){if(e instanceof n)throw e;throw new n(e instanceof Error?e.message:"Unknown error",0,e)}}let l={getAll:async()=>s("/api/worktrees"),getById:async e=>s("/api/worktrees/".concat(e)),updateDescription:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({description:t})}),updateLink:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({link:t})}),toggleFavorite:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({favorite:t})}),updateStatus:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({status:t})}),updateCliTool:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({cliToolId:t})}),markAsViewed:async e=>s("/api/worktrees/".concat(e,"/viewed"),{method:"PATCH"}),async getMessages(e,t,r,n){let o=new URLSearchParams;return t&&o.append("cliTool",t),r&&o.append("includeArchived","true"),"number"==typeof n&&Number.isFinite(n)&&o.append("limit",String(n)),s("/api/worktrees/".concat(e,"/messages").concat(o.toString()?"?".concat(o.toString()):""))},async sendMessage(e,t,r){var n;let o={content:t};return(null==r?void 0:r.cliToolId)&&(o.cliToolId=r.cliToolId),(null==r?void 0:r.instanceId)&&(o.instanceId=r.instanceId),(null==r?void 0:r.imagePath)&&(o.imagePath=r.imagePath),null===(n=await s("/api/worktrees/".concat(e,"/send"),{method:"POST",body:JSON.stringify(o)}))||"object"!=typeof n||n.timestamp instanceof Date?n:{...n,timestamp:new Date(n.timestamp)}},async uploadImageFile(e,t){let r=Date.now(),n="".concat(r,"-").concat(t.name),i=".commandmate/attachments",a=new FormData;a.append("file",new File([t],n,{type:t.type}));let s=await fetch("/api/worktrees/".concat(e,"/upload/").concat(i),{method:"POST",body:a});if(!s.ok){var l;let e=await o(s,{},"error-body");throw Error((null==e||null==(l=e.error)?void 0:l.message)||"Upload failed (HTTP ".concat(s.status,")"))}return{path:(await o(s,{},"response-body")).path||"".concat(i,"/").concat(n)}},getLogs:async e=>s("/api/worktrees/".concat(e,"/logs")),async getLogFile(e,t,r){let n=(null==r?void 0:r.sanitize)?"?sanitize=true":"";return s("/api/worktrees/".concat(e,"/logs/").concat(t).concat(n))},async killSession(e,t,r){let n=new URLSearchParams;t&&n.set("cliTool",t),r&&n.set("instance",r);let o=n.toString();return s("/api/worktrees/".concat(e,"/kill-session").concat(o?"?".concat(o):""),{method:"POST"})}},c={scan:async e=>s("/api/repositories/scan",{method:"POST",body:JSON.stringify({repositoryPath:e})}),sync:async()=>s("/api/repositories/sync",{method:"POST"}),delete:async e=>s("/api/repositories",{method:"DELETE",body:JSON.stringify({repositoryPath:e})}),async clone(e,t){var r;return s("/api/repositories/clone",{method:"POST",body:JSON.stringify({cloneUrl:e,fork:null!=(r=null==t?void 0:t.fork)&&r})})},getCloneStatus:async e=>s("/api/repositories/clone/".concat(e)),getExcluded:async()=>s("/api/repositories/excluded"),restore:async e=>s("/api/repositories/restore",{method:"PUT",body:JSON.stringify({repositoryPath:e})}),list:async()=>s("/api/repositories"),updateDisplayName:async(e,t)=>s("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({displayName:t})}),updateVisibility:async(e,t)=>s("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({visible:t})}),updateEnabled:async(e,t)=>s("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({enabled:t})}),validatePath:async e=>s("/api/repositories/validate-path",{method:"POST",body:JSON.stringify({repositoryPath:e})})},u={async browse(e){let t=e?"?path=".concat(encodeURIComponent(e)):"";return s("/api/fs/browse".concat(t))},addRecentPath:async e=>s("/api/fs/recent-paths",{method:"POST",body:JSON.stringify({path:e})})},d={getAll:async e=>(await s("/api/worktrees/".concat(e,"/memos"))).memos,create:async(e,t)=>(await s("/api/worktrees/".concat(e,"/memos"),{method:"POST",body:JSON.stringify(t||{})})).memo,update:async(e,t,r)=>(await s("/api/worktrees/".concat(e,"/memos/").concat(t),{method:"PUT",body:JSON.stringify(r)})).memo,delete:async(e,t)=>s("/api/worktrees/".concat(e,"/memos/").concat(t),{method:"DELETE"}),async reorder(e,t){await s("/api/worktrees/".concat(e,"/memos"),{method:"PATCH",body:JSON.stringify({memoIds:t})})}};function f(e){return e instanceof n||e instanceof Error?e.message:"An unknown error occurred"}let p={checkForUpdate:async()=>s("/api/app/update-check",{method:"GET"}),startUpdate:async()=>s("/api/app/update",{method:"POST"}),async ping(){try{return(await fetch("/api/auth/status",{cache:"no-store"})).ok}catch(e){return!1}}}},89275:(e,t,r)=>{r.d(t,{Bo:()=>u,Hq:()=>l});var n=r(95155),o=r(12115),i=r(20063);let a={startTransition:e=>e()},s=(0,o.createContext)(null);function l(){var e;let t=(0,i.useRouter)(),{startTransition:r}=null!=(e=(0,o.useContext)(s))?e:a;return(0,o.useMemo)(()=>({push:e=>r(()=>t.push(e)),replace:e=>r(()=>t.replace(e))}),[t,r])}function c(e){let{onCommit:t}=e,r=(0,i.usePathname)(),n=(0,o.useRef)(!1);return(0,o.useEffect)(()=>{if(!n.current){n.current=!0;return}t()},[r,t]),null}function u(e){let{children:t}=e,r=(0,o.useRef)(null),i=(0,o.useCallback)(()=>{var e;null==(e=r.current)||e.call(r)},[]),a=(0,o.useCallback)(e=>{var t;t=()=>new Promise(t=>{let n=!1,o=()=>{n||(n=!0,t())};r.current=o,e(),window.setTimeout(o,500)}),"undefined"==typeof document||"function"!=typeof document.startViewTransition||"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches?t():document.startViewTransition(t)},[]),l=(0,o.useMemo)(()=>({startTransition:a}),[a]);return(0,n.jsxs)(s.Provider,{value:l,children:[(0,n.jsx)(c,{onCommit:i}),t]})}},92614:(e,t,r)=>{r.d(t,{C:()=>s,E:()=>a});var n=r(95155),o=r(12115);let i=(0,o.createContext)({open:!1,setOpen:()=>{},toggle:()=>{}});function a(e){let{children:t}=e,[r,a]=(0,o.useState)(!1),s=(0,o.useCallback)(()=>a(e=>!e),[]),l=(0,o.useMemo)(()=>({open:r,setOpen:a,toggle:s}),[r,s]);return(0,n.jsx)(i.Provider,{value:l,children:t})}function s(){return(0,o.useContext)(i)}},94442:(e,t,r)=>{r.d(t,{dj:()=>v,tE:()=>S});var n=r(95155),o=r(12115),i=r(47650),a=r(18955),s=r(42529),l=r(78874),c=r(52056),u=r(23327),d=r(65229),f=r(59854),p=r(9900),g=r(9286);function m(e){let{type:t,iconColor:r}=e,o="h-5 w-5 ".concat(r);switch(t){case"success":return(0,n.jsx)(s.A,{className:o,"data-testid":"toast-icon-success"});case"error":return(0,n.jsx)(l.A,{className:o,"data-testid":"toast-icon-error"});case"warning":return(0,n.jsx)(c.A,{className:o,"data-testid":"toast-icon-warning"});default:return(0,n.jsx)(u.A,{className:o,"data-testid":"toast-icon-info"})}}function y(e){let{id:t,message:r,type:i,onClose:s,duration:l=3e3,onClick:c}=e,u=(0,a.c)("common"),f=(0,o.useRef)(null),y=function(e){switch(e){case"success":return{bgColor:"bg-success-subtle",borderColor:"border-success-border",textColor:"text-success-foreground",iconColor:"text-success-foreground"};case"error":return{bgColor:"bg-danger-subtle",borderColor:"border-danger-border",textColor:"text-danger-foreground",iconColor:"text-danger-foreground"};case"warning":return{bgColor:"bg-warning-subtle",borderColor:"border-warning-border",textColor:"text-warning-foreground",iconColor:"text-warning-foreground"};default:return{bgColor:"bg-info-subtle",borderColor:"border-info-border",textColor:"text-info-foreground",iconColor:"text-info-foreground"}}}(i),[h,w]=(0,o.useState)(!0),{shouldRender:b,isExiting:S}=(0,g.O)(h,p.Ys),v=(0,o.useRef)(s);v.current=s,(0,o.useEffect)(()=>{b||v.current(t)},[b,t]),(0,o.useEffect)(()=>(l>0&&(f.current=setTimeout(()=>{w(!1)},l)),()=>{f.current&&clearTimeout(f.current)}),[l]);let E=(0,o.useCallback)(()=>{f.current&&clearTimeout(f.current),w(!1)},[]);return(0,n.jsxs)("div",{"data-testid":"toast-".concat(t),role:"alert",className:"\n ".concat(y.bgColor,"\n ").concat(y.borderColor,"\n ").concat(y.textColor,"\n border rounded-lg shadow-lg p-4 min-w-[300px] max-w-[400px]\n flex items-start gap-3\n ").concat(S?"animate-out fade-out-0 slide-out-to-right-full duration-200 fill-mode-forwards pointer-events-none":"animate-slide-in","\n "),children:[(0,n.jsx)(m,{type:i,iconColor:y.iconColor}),c?(0,n.jsx)("button",{type:"button","data-testid":"toast-action-button",onClick:()=>{c(),E()},className:"flex-1 text-left text-sm font-medium underline-offset-2 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:r}):(0,n.jsx)("p",{className:"flex-1 text-sm font-medium",children:r}),(0,n.jsx)("button",{"data-testid":"toast-close-button",onClick:E,"aria-label":u("closeNotification"),className:"\n ".concat(y.textColor,"\n hover:opacity-70\n focus:outline-none focus:ring-2 focus:ring-offset-2\n transition-opacity\n "),children:(0,n.jsx)(d.A,{className:"h-4 w-4"})})]})}function h(e){let{toasts:t,onClose:r}=e,[a,s]=(0,o.useState)(!1);(0,o.useEffect)(()=>{s(!0)},[]);let l=(0,n.jsx)("div",{"data-testid":"toast-container","aria-live":"polite",className:"fixed bottom-4 right-4 flex flex-col gap-2",style:{zIndex:f.M.TOAST},children:t.map(e=>(0,n.jsx)(y,{id:e.id,message:e.message,type:e.type,onClose:r,duration:e.duration,onClick:e.onClick},e.id))});return a?(0,i.createPortal)(l,document.body):null}function w(){let[e,t]=(0,o.useState)([]),r=(0,o.useRef)(0),n=(0,o.useCallback)(function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e3,i=arguments.length>3?arguments[3]:void 0,a="toast-".concat(++r.current,"-").concat(Date.now()),s={id:a,message:e,type:n,duration:o,...(null==i?void 0:i.onClick)?{onClick:i.onClick}:{}};return t(e=>[...e,s]),a},[]),i=(0,o.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]),a=(0,o.useCallback)(()=>{t([])},[]);return(0,o.useMemo)(()=>({toasts:e,showToast:n,removeToast:i,clearToasts:a}),[e,n,i,a])}let b=(0,o.createContext)(null);function S(e){let{children:t}=e,r=w();return(0,n.jsxs)(b.Provider,{value:r,children:[t,(0,n.jsx)(h,{toasts:r.toasts,onClose:r.removeToast})]})}function v(){let e=(0,o.useContext)(b),t=w();return null!=e?e:t}}}]);
|