@jingyi0605/codingns 0.5.5 → 0.6.1
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/bin/codingns.mjs +15 -2
- package/dist/public/assets/{AdaptiveButlerPage-CUyNL98E.js → AdaptiveButlerPage-Dw72U3hG.js} +3 -3
- package/dist/public/assets/App-CcDXqFl1.css +1 -0
- package/dist/public/assets/{App-BFP7LCSC.js → App-Dsf3ooXU.js} +3 -3
- package/dist/public/assets/{BootstrapPage-G74dX2Us.js → BootstrapPage-CE0m1qSR.js} +1 -1
- package/dist/public/assets/ConversationPage-8wOY7SX-.js +4 -0
- package/dist/public/assets/{DesktopDetachPreviewPage-IV7oEdOX.js → DesktopDetachPreviewPage-Dxarr_Wf.js} +1 -1
- package/dist/public/assets/DesktopWindowPage-VytPwJ4c.js +2 -0
- package/dist/public/assets/FileContextPanel-DwFzLsOp.js +1 -0
- package/dist/public/assets/GitSidebar-CH6WqTrM.js +6 -0
- package/dist/public/assets/MobileCreateSessionSheet-DcxKM00P.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-COTc7cRr.js → MobileTopHeaderFrame-C5rIKQT6.js} +1 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-CfUnHgv_.js +1 -0
- package/dist/public/assets/RelayConnectEntryPage-CgMvVZwa.js +1 -0
- package/dist/public/assets/ServerSettingsModal-CFul__z1.js +1 -0
- package/dist/public/assets/SessionIndexPage-B-tRhBXC.js +1 -0
- package/dist/public/assets/SettingsPage-C9LGxSQZ.js +1 -0
- package/dist/public/assets/TerminalManagerPanel-BbORd-ee.js +1 -0
- package/dist/public/assets/{TerminalPage-DpsvQQVR.js → TerminalPage-DWHv6mlu.js} +19 -19
- package/dist/public/assets/TerminalRuntimeFallbackModal-B29YxbQe.js +1 -0
- package/dist/public/assets/ToolFilesPage-Dx9cv9hu.js +1 -0
- package/dist/public/assets/ToolGitPage-D7H3vAia.js +1 -0
- package/dist/public/assets/ToolProcessesPage-PqQWxsy-.js +1 -0
- package/dist/public/assets/ToolsHomePage-CX05Pe_4.js +1 -0
- package/dist/public/assets/WorkbenchLandingPage-CchkAC75.js +1 -0
- package/dist/public/assets/WorkbenchLayout-pOZvEqp7.js +3 -0
- package/dist/public/assets/{WorkbenchModal-CbDxaCOR.js → WorkbenchModal-ColqvV6a.js} +1 -1
- package/dist/public/assets/WorkbenchShellRoute-C0_h4lP6.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-RGZpA0_J.css +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-Deqy2_pO.js +1 -0
- package/dist/public/assets/WorkspaceDetailPage-Cvf-ZdlB.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-Dsyvqyk1.js +1 -0
- package/dist/public/assets/client-runtime-manager-DROQJ9v3.js +1 -0
- package/dist/public/assets/{file-tree-icon-BMKuc5pw.js → file-tree-icon-Bp3Ntt7u.js} +7 -7
- package/dist/public/assets/index-B84Po2NA.css +1 -0
- package/dist/public/assets/index-C-0oeG_5.js +42 -0
- package/dist/public/assets/legna-code-6TqgZ4Ls.png +0 -0
- package/dist/public/assets/login-direct-candidate-resolver-DotM530R.js +1 -0
- package/dist/public/assets/model-switch-api-Bh9nYslz.js +1 -0
- package/dist/public/assets/{preferences-service-gv_9vGKz.js → preferences-service-BG6GKG29.js} +1 -1
- package/dist/public/assets/relay-entry-pmr-c42O.js +1 -0
- package/dist/public/assets/session-runtime-machine-YN84QBlr.js +21 -0
- package/dist/public/assets/{styles-BWPBZvze.css → styles-CsEMfdaS.css} +1 -1
- package/dist/public/assets/{terminal-runtime-meta-B9xJGY__.js → terminal-runtime-meta-8_uRZf7h.js} +1 -1
- package/dist/public/assets/useRegisteredDebugTemplates-DWX7LXQu.js +1 -0
- package/dist/public/assets/window-BVUB8gMK.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +3 -0
- package/dist/server/config/env.js +10 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/modules/client/npm-global-package-service.d.ts +7 -1
- package/dist/server/modules/client/npm-global-package-service.js +149 -43
- package/dist/server/modules/client/npm-global-package-service.js.map +1 -1
- package/dist/server/modules/client/service-update-task-service.js +6 -2
- package/dist/server/modules/client/service-update-task-service.js.map +1 -1
- package/dist/server/modules/client/service-update-types.d.ts +2 -0
- package/dist/server/modules/git/git-controller.d.ts +3 -0
- package/dist/server/modules/git/git-controller.js +3 -0
- package/dist/server/modules/git/git-controller.js.map +1 -1
- package/dist/server/modules/git/git-read-service.js +47 -1
- package/dist/server/modules/git/git-read-service.js.map +1 -1
- package/dist/server/modules/git/git-write-service.d.ts +4 -0
- package/dist/server/modules/git/git-write-service.js +24 -0
- package/dist/server/modules/git/git-write-service.js.map +1 -1
- package/dist/server/modules/git/types.d.ts +1 -0
- package/dist/server/modules/git/workspace-repo-guard.d.ts +2 -0
- package/dist/server/modules/git/workspace-repo-guard.js +24 -10
- package/dist/server/modules/git/workspace-repo-guard.js.map +1 -1
- package/dist/server/modules/model-switch/cc-switch-adapter.d.ts +7 -0
- package/dist/server/modules/model-switch/cc-switch-adapter.js +17 -0
- package/dist/server/modules/model-switch/cc-switch-adapter.js.map +1 -1
- package/dist/server/modules/parallel-sessions/parallel-session-controller.d.ts +57 -0
- package/dist/server/modules/parallel-sessions/parallel-session-controller.js +77 -0
- package/dist/server/modules/parallel-sessions/parallel-session-controller.js.map +1 -0
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.d.ts +88 -0
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.js +625 -0
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.js.map +1 -0
- package/dist/server/modules/parallel-sessions/session-isolated-workspace-service.d.ts +56 -0
- package/dist/server/modules/parallel-sessions/session-isolated-workspace-service.js +483 -0
- package/dist/server/modules/parallel-sessions/session-isolated-workspace-service.js.map +1 -0
- package/dist/server/modules/provider/opencode-model-options.d.ts +1 -0
- package/dist/server/modules/provider/opencode-model-options.js +54 -12
- package/dist/server/modules/provider/opencode-model-options.js.map +1 -1
- package/dist/server/modules/provider/provider-controller.d.ts +6 -1
- package/dist/server/modules/provider/provider-controller.js +24 -2
- package/dist/server/modules/provider/provider-controller.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-helper-client.d.ts +2 -0
- package/dist/server/modules/provider/provider-discovery-helper-client.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-helper-process.js +1 -1
- package/dist/server/modules/provider/provider-discovery-helper-process.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-runtime.js +5 -1
- package/dist/server/modules/provider/provider-discovery-runtime.js.map +1 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-candidate-endpoints.d.ts +2 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-candidate-endpoints.js +129 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-candidate-endpoints.js.map +1 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js +12 -9
- package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js.map +1 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js +1 -128
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js.map +1 -1
- package/dist/server/modules/sessions/claude-runtime-helper-client.d.ts +1 -0
- package/dist/server/modules/sessions/claude-runtime-helper-client.js +14 -0
- package/dist/server/modules/sessions/claude-runtime-helper-client.js.map +1 -1
- package/dist/server/modules/sessions/codex-app-server-helper-client.d.ts +4 -0
- package/dist/server/modules/sessions/codex-app-server-helper-client.js +66 -45
- package/dist/server/modules/sessions/codex-app-server-helper-client.js.map +1 -1
- package/dist/server/modules/sessions/codex-app-server-helper-process.js +21 -2
- package/dist/server/modules/sessions/codex-app-server-helper-process.js.map +1 -1
- package/dist/server/modules/sessions/provider-session-delete-cli.js +2 -0
- package/dist/server/modules/sessions/provider-session-delete-cli.js.map +1 -1
- package/dist/server/modules/sessions/session-controller.d.ts +7 -0
- package/dist/server/modules/sessions/session-controller.js +22 -0
- package/dist/server/modules/sessions/session-controller.js.map +1 -1
- package/dist/server/modules/sessions/session-history-service.d.ts +21 -2
- package/dist/server/modules/sessions/session-history-service.js +425 -29
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-service.d.ts +23 -2
- package/dist/server/modules/sessions/session-live-runtime-service.js +472 -74
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
- package/dist/server/modules/sessions/session-message-attachment-service.js +2 -2
- package/dist/server/modules/sessions/session-message-attachment-service.js.map +1 -1
- package/dist/server/modules/sessions/session-provider-config-service.d.ts +66 -0
- package/dist/server/modules/sessions/session-provider-config-service.js +821 -0
- package/dist/server/modules/sessions/session-provider-config-service.js.map +1 -0
- package/dist/server/modules/sessions/session-provider-error-mapper.d.ts +2 -0
- package/dist/server/modules/sessions/session-provider-error-mapper.js +42 -0
- package/dist/server/modules/sessions/session-provider-error-mapper.js.map +1 -1
- package/dist/server/modules/workbench/codex-archive-watcher.d.ts +16 -0
- package/dist/server/modules/workbench/codex-archive-watcher.js +50 -0
- package/dist/server/modules/workbench/codex-archive-watcher.js.map +1 -0
- package/dist/server/modules/workbench/workbench-service.d.ts +11 -2
- package/dist/server/modules/workbench/workbench-service.js +37 -8
- package/dist/server/modules/workbench/workbench-service.js.map +1 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.d.ts +1 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js +26 -3
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js.map +1 -1
- package/dist/server/modules/workspace/workspace-service.d.ts +3 -1
- package/dist/server/modules/workspace/workspace-service.js +10 -2
- package/dist/server/modules/workspace/workspace-service.js.map +1 -1
- package/dist/server/modules/worktree/worktree-base-ref-resolver.d.ts +20 -0
- package/dist/server/modules/worktree/worktree-base-ref-resolver.js +111 -0
- package/dist/server/modules/worktree/worktree-base-ref-resolver.js.map +1 -0
- package/dist/server/modules/worktree/worktree-cleanup-service.js +9 -3
- package/dist/server/modules/worktree/worktree-cleanup-service.js.map +1 -1
- package/dist/server/modules/worktree/worktree-manager.d.ts +0 -1
- package/dist/server/modules/worktree/worktree-manager.js +14 -20
- package/dist/server/modules/worktree/worktree-manager.js.map +1 -1
- package/dist/server/routes/git.js +1 -0
- package/dist/server/routes/git.js.map +1 -1
- package/dist/server/routes/parallel-groups.d.ts +3 -0
- package/dist/server/routes/parallel-groups.js +9 -0
- package/dist/server/routes/parallel-groups.js.map +1 -0
- package/dist/server/server/create-server.d.ts +8 -0
- package/dist/server/server/create-server.js +48 -11
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/server/workbench-runtime-terminal-sync.d.ts +14 -0
- package/dist/server/server/workbench-runtime-terminal-sync.js +17 -0
- package/dist/server/server/workbench-runtime-terminal-sync.js.map +1 -0
- package/dist/server/storage/repositories/parallel-session-group-repository.d.ts +11 -0
- package/dist/server/storage/repositories/parallel-session-group-repository.js +131 -0
- package/dist/server/storage/repositories/parallel-session-group-repository.js.map +1 -0
- package/dist/server/storage/repositories/parallel-session-member-repository.d.ts +12 -0
- package/dist/server/storage/repositories/parallel-session-member-repository.js +150 -0
- package/dist/server/storage/repositories/parallel-session-member-repository.js.map +1 -0
- package/dist/server/storage/repositories/session-binding-repository.js +44 -5
- package/dist/server/storage/repositories/session-binding-repository.js.map +1 -1
- package/dist/server/storage/repositories/session-index-repository.js +6 -0
- package/dist/server/storage/repositories/session-index-repository.js.map +1 -1
- package/dist/server/storage/repositories/session-isolated-workspace-repository.d.ts +15 -0
- package/dist/server/storage/repositories/session-isolated-workspace-repository.js +230 -0
- package/dist/server/storage/repositories/session-isolated-workspace-repository.js.map +1 -0
- package/dist/server/storage/sqlite/client.js +19 -0
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +78 -0
- package/dist/server/types/domain.d.ts +78 -0
- package/dist/server/ws/workbench-ws-hub.d.ts +3 -1
- package/dist/server/ws/workbench-ws-hub.js +23 -4
- package/dist/server/ws/workbench-ws-hub.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.d.ts +5 -2
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js +40 -8
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/index.d.ts +2 -0
- package/node_modules/@codingns/session-sync-core/dist/index.js +2 -0
- package/node_modules/@codingns/session-sync-core/dist/index.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.d.ts +10 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js +110 -35
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.d.ts +11 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js +105 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +34 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js +131 -39
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.d.ts +9 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js +17 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.d.ts +8 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js +19 -6
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +13 -8
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.d.ts +3 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js +46 -22
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.d.ts +5 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +103 -51
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.d.ts +2 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +528 -301
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js +32 -8
- package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.d.ts +10 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js +16 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js +196 -15
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/types.d.ts +2 -0
- package/node_modules/@codingns/session-sync-core/dist/types.d.ts +1 -1
- package/node_modules/@codingns/session-sync-core/dist/types.js +1 -1
- package/node_modules/@codingns/session-sync-core/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/public/assets/App-DUAg5urj.css +0 -1
- package/dist/public/assets/ConversationPage-Bz0_tvvM.js +0 -2
- package/dist/public/assets/DesktopWindowPage-BBmHyRg5.js +0 -2
- package/dist/public/assets/FileContextPanel--FVTxDrq.js +0 -1
- package/dist/public/assets/GitSidebar-DAiSi9oc.js +0 -6
- package/dist/public/assets/MobileCreateSessionSheet-DqVwz_Hp.js +0 -1
- package/dist/public/assets/MobileSheet-D1lMrcvD.js +0 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-DJPV9ym2.js +0 -1
- package/dist/public/assets/RelayConnectEntryPage-dSwU8VzK.js +0 -1
- package/dist/public/assets/ServerSettingsModal-B34ms3ze.js +0 -1
- package/dist/public/assets/SessionIndexPage-D3tG1gmM.js +0 -1
- package/dist/public/assets/SettingsPage-B3-6-5GL.js +0 -1
- package/dist/public/assets/TerminalManagerPanel-DhuTEdzV.js +0 -1
- package/dist/public/assets/TerminalRuntimeFallbackModal-CNzOt5v5.js +0 -1
- package/dist/public/assets/ToolFilesPage-BX9QDi9Y.js +0 -1
- package/dist/public/assets/ToolGitPage-4VtFox3p.js +0 -1
- package/dist/public/assets/ToolProcessesPage-DZJC6Qnt.js +0 -1
- package/dist/public/assets/ToolsHomePage-D7JbrAWv.js +0 -1
- package/dist/public/assets/WorkbenchLandingPage-C0yqnzqh.js +0 -1
- package/dist/public/assets/WorkbenchLayout-Brlj8K3i.js +0 -3
- package/dist/public/assets/WorkbenchShellRoute-BMcnFadA.css +0 -1
- package/dist/public/assets/WorkbenchShellRoute-puGpdDFY.js +0 -1
- package/dist/public/assets/WorkspaceDebugDetailPage-fTGweC9N.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-BtaIzSDB.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-CUmmYDrM.js +0 -1
- package/dist/public/assets/client-runtime-manager-RHFa_iWo.js +0 -1
- package/dist/public/assets/default-session-permission-mode-Cu5SreTG.js +0 -1
- package/dist/public/assets/index-Cq3ue0za.css +0 -1
- package/dist/public/assets/index-DEbFT-Aq.js +0 -42
- package/dist/public/assets/session-runtime-machine-Bfnxkk9B.js +0 -17
- package/dist/public/assets/useRegisteredDebugTemplates-CDfl54Wt.js +0 -1
- package/dist/public/assets/window-BWqRixxq.js +0 -1
- /package/dist/public/assets/{styles-CSUx5LGe.js → styles-DRVvx_kv.js} +0 -0
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileContextPanel--FVTxDrq.js","assets/index-DEbFT-Aq.js","assets/index-Cq3ue0za.css","assets/App-BFP7LCSC.js","assets/App-DUAg5urj.css","assets/MobileSheet-D1lMrcvD.js","assets/WorkbenchModal-CbDxaCOR.js","assets/file-tree-icon-BMKuc5pw.js","assets/window-BWqRixxq.js","assets/event-DvH9tcej.js","assets/GitSidebar-DAiSi9oc.js","assets/default-session-permission-mode-Cu5SreTG.js","assets/TerminalManagerPanel-DhuTEdzV.js","assets/terminal-runtime-meta-B9xJGY__.js","assets/TerminalRuntimeFallbackModal-CNzOt5v5.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var ec=Object.defineProperty;var tc=(e,n,s)=>n in e?ec(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var ge=(e,n,s)=>tc(e,typeof n!="symbol"?n+"":n,s);import{C as Q,t as r,b as l,j as t,e as nn,m as Zs,G as Aa,H as nc,D as sc,J as rc,w as Pa,A as Ba,p as Qr,K as ic,L as oc,M as La,i as Da,N as Mi,f as Hi,h as _a,O as ac,l as Fa,y as lc,n as cc,z as dc,_ as Ui}from"./index-DEbFT-Aq.js";import{m as Se,e as Tn,h as ei,u as er,g as tr,f as Xn,i as uc,j as hc,O as po}from"./App-BFP7LCSC.js";import{e as $i,l as fc,m as mc,$ as Oa,a0 as pc,M as bc,i as kc,j as gc,a1 as wc,a2 as xc,u as Er,g as vc,a3 as yc,a4 as Sc,a5 as jc,a6 as Ha,a7 as Nc,a8 as Ua,a9 as Cc,aa as Tc,ab as $a,H as Ic,a as Rc,o as Mc,S as Ec,n as qa,P as Wc,r as Ac,ac as Pc}from"./MobileSheet-D1lMrcvD.js";import{t as gs,P as Yr,g as Ga}from"./window-BWqRixxq.js";import{R as Bc,_ as bo,a as ko,C as Ka,i as ie}from"./event-DvH9tcej.js";import{W as Ue}from"./WorkbenchModal-CbDxaCOR.js";const ws=new Map;function qi(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function go(e,n){return!Number.isFinite(e)||Date.now()-e>n}function Jr(e,n){const s=ws.get(e);if(s&&!go(s.savedAt,n))return s.value;if(!qi())return null;const i=window.sessionStorage.getItem(e);if(!i)return null;try{const o=JSON.parse(i);return!o||go(o.savedAt,n)?(window.sessionStorage.removeItem(e),ws.delete(e),null):(ws.set(e,o),o.value)}catch{return window.sessionStorage.removeItem(e),ws.delete(e),null}}function Ys(e,n){const s={savedAt:Date.now(),value:n};if(ws.set(e,s),!!qi())try{window.sessionStorage.setItem(e,JSON.stringify(s))}catch{}}function sm(e){ws.delete(e),qi()&&window.sessionStorage.removeItem(e)}const Lc="codingns.debug.perf";function Dc(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Lc)==="1"}catch{return!1}}function qe(e,n){if(!Dc()||typeof performance>"u")return;const s=Math.round(performance.now());if(n&&Object.keys(n).length>0){console.info(`[perf-ui] ${e} ${s}ms`,n);return}console.info(`[perf-ui] ${e} ${s}ms`)}function rm(e,n,s,i){return Q.request("/api/files/content",{method:"PUT",body:JSON.stringify({workspaceId:e,path:n,content:s,expectedVersion:i??void 0})})}function im(e){return Q.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function om(e){return Q.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function am(e,n){const s=new URLSearchParams({workspaceId:e,path:n});return Q.request(`/api/files/download?${s.toString()}`)}function _c(e,n,s=1,i=20){const o=new URLSearchParams({workspaceId:e,keyword:n,page:String(s),pageSize:String(i)});return Q.request(`/api/files/search?${o.toString()}`)}function lm(e,n){const s=new URLSearchParams({workspaceId:e,path:n});return Q.request(`/api/files/preview?${s.toString()}`)}function cm(e){return Q.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function dm(e,n,s){const i=new URLSearchParams({workspaceId:e,path:n,staged:String(s)});return Q.request(`/api/git/diff?${i.toString()}`)}function um(e,n){return Q.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:n})})}function hm(e,n){return Q.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:n})})}function fm(e,n){return Q.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:n})})}function mm(e,n){return Q.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:n})})}function pm(e,n){return Q.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:n})})}function bm(e){return Q.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function km(e,n=5,s=null){const i=new URLSearchParams({workspaceId:e,limit:String(n)});return s&&i.set("cursor",s),Q.request(`/api/git/history?${i.toString()}`)}function gm(e,n){const s=new URLSearchParams({workspaceId:e,commitHash:n});return Q.request(`/api/git/commit-detail?${s.toString()}`)}function Fc(e){return Q.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function Oc(e){return Q.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function wm(e,n,s){return Q.request("/api/git/branches/switch",{method:"POST",body:JSON.stringify({workspaceId:e,branchName:n,create:s})})}function xm(e,n,s,i,o){return Q.request("/api/git/remote/sync",{method:"POST",body:JSON.stringify({workspaceId:e,action:n,...s?{remote:s}:{},...i?{auth:i}:{},...o?{remember:o}:{}})})}function vm(e){return Q.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}var zr,Vr;function za(e){var n;if("items"in e)e.items=(n=e.items)===null||n===void 0?void 0:n.map(s=>"rid"in s?s:za(s));else if("action"in e&&e.action){const s=new Ka;return s.onmessage=e.action,delete e.action,{...e,handler:s}}return e}async function Ss(e,n){const s=new Ka;if(n&&typeof n=="object"&&("action"in n&&n.action&&(s.onmessage=n.action,delete n.action),"item"in n&&n.item&&typeof n.item=="object"&&"About"in n.item&&n.item.About&&typeof n.item.About=="object"&&"icon"in n.item.About&&n.item.About.icon&&(n.item.About.icon=gs(n.item.About.icon)),"icon"in n&&n.icon&&(n.icon=gs(n.icon)),"items"in n&&n.items)){let i=function(o){var c;return"rid"in o?[o.rid,o.kind]:("item"in o&&typeof o.item=="object"&&(!((c=o.item.About)===null||c===void 0)&&c.icon)&&(o.item.About.icon=gs(o.item.About.icon)),"icon"in o&&o.icon&&(o.icon=gs(o.icon)),"items"in o&&o.items&&(o.items=o.items.map(i)),za(o))};n.items=n.items.map(i)}return ie("plugin:menu|new",{kind:e,options:n,handler:s})}class js extends Bc{get id(){return bo(this,zr,"f")}get kind(){return bo(this,Vr,"f")}constructor(n,s,i){super(n),zr.set(this,void 0),Vr.set(this,void 0),ko(this,zr,s),ko(this,Vr,i)}}zr=new WeakMap,Vr=new WeakMap;class Gi extends js{constructor(n,s){super(n,s,"MenuItem")}static async new(n){return Ss("MenuItem",n).then(([s,i])=>new Gi(s,i))}async text(){return ie("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(n){return ie("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:n})}async isEnabled(){return ie("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(n){return ie("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:n})}async setAccelerator(n){return ie("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:n})}}class Ki extends js{constructor(n,s){super(n,s,"Check")}static async new(n){return Ss("Check",n).then(([s,i])=>new Ki(s,i))}async text(){return ie("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(n){return ie("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:n})}async isEnabled(){return ie("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(n){return ie("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:n})}async setAccelerator(n){return ie("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:n})}async isChecked(){return ie("plugin:menu|is_checked",{rid:this.rid})}async setChecked(n){return ie("plugin:menu|set_checked",{rid:this.rid,checked:n})}}var wo;(function(e){e.Add="Add",e.Advanced="Advanced",e.Bluetooth="Bluetooth",e.Bookmarks="Bookmarks",e.Caution="Caution",e.ColorPanel="ColorPanel",e.ColumnView="ColumnView",e.Computer="Computer",e.EnterFullScreen="EnterFullScreen",e.Everyone="Everyone",e.ExitFullScreen="ExitFullScreen",e.FlowView="FlowView",e.Folder="Folder",e.FolderBurnable="FolderBurnable",e.FolderSmart="FolderSmart",e.FollowLinkFreestanding="FollowLinkFreestanding",e.FontPanel="FontPanel",e.GoLeft="GoLeft",e.GoRight="GoRight",e.Home="Home",e.IChatTheater="IChatTheater",e.IconView="IconView",e.Info="Info",e.InvalidDataFreestanding="InvalidDataFreestanding",e.LeftFacingTriangle="LeftFacingTriangle",e.ListView="ListView",e.LockLocked="LockLocked",e.LockUnlocked="LockUnlocked",e.MenuMixedState="MenuMixedState",e.MenuOnState="MenuOnState",e.MobileMe="MobileMe",e.MultipleDocuments="MultipleDocuments",e.Network="Network",e.Path="Path",e.PreferencesGeneral="PreferencesGeneral",e.QuickLook="QuickLook",e.RefreshFreestanding="RefreshFreestanding",e.Refresh="Refresh",e.Remove="Remove",e.RevealFreestanding="RevealFreestanding",e.RightFacingTriangle="RightFacingTriangle",e.Share="Share",e.Slideshow="Slideshow",e.SmartBadge="SmartBadge",e.StatusAvailable="StatusAvailable",e.StatusNone="StatusNone",e.StatusPartiallyAvailable="StatusPartiallyAvailable",e.StatusUnavailable="StatusUnavailable",e.StopProgressFreestanding="StopProgressFreestanding",e.StopProgress="StopProgress",e.TrashEmpty="TrashEmpty",e.TrashFull="TrashFull",e.User="User",e.UserAccounts="UserAccounts",e.UserGroup="UserGroup",e.UserGuest="UserGuest"})(wo||(wo={}));class zi extends js{constructor(n,s){super(n,s,"Icon")}static async new(n){return Ss("Icon",n).then(([s,i])=>new zi(s,i))}async text(){return ie("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(n){return ie("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:n})}async isEnabled(){return ie("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(n){return ie("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:n})}async setAccelerator(n){return ie("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:n})}async setIcon(n){return ie("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:gs(n)})}}class Vi extends js{constructor(n,s){super(n,s,"Predefined")}static async new(n){return Ss("Predefined",n).then(([s,i])=>new Vi(s,i))}async text(){return ie("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(n){return ie("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:n})}}function ys([e,n,s]){switch(s){case"Submenu":return new Xi(e,n);case"Predefined":return new Vi(e,n);case"Check":return new Ki(e,n);case"Icon":return new zi(e,n);case"MenuItem":default:return new Gi(e,n)}}class Xi extends js{constructor(n,s){super(n,s,"Submenu")}static async new(n){return Ss("Submenu",n).then(([s,i])=>new Xi(s,i))}async text(){return ie("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(n){return ie("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:n})}async isEnabled(){return ie("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(n){return ie("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:n})}async append(n){return ie("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(n)?n:[n]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async prepend(n){return ie("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(n)?n:[n]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async insert(n,s){return ie("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(n)?n:[n]).map(i=>"rid"in i?[i.rid,i.kind]:i),position:s})}async remove(n){return ie("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[n.rid,n.kind]})}async removeAt(n){return ie("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:n}).then(ys)}async items(){return ie("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(n=>n.map(ys))}async get(n){return ie("plugin:menu|get",{rid:this.rid,kind:this.kind,id:n}).then(s=>s?ys(s):null)}async popup(n,s){var i;return ie("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(i=s==null?void 0:s.label)!==null&&i!==void 0?i:null,at:n instanceof Yr?n:n?new Yr(n):null})}async setAsWindowsMenuForNSApp(){return ie("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return ie("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(n){return ie("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:gs(n)})}}class xs extends js{constructor(n,s){super(n,s,"Menu")}static async new(n){return Ss("Menu",n).then(([s,i])=>new xs(s,i))}static async default(){return ie("plugin:menu|create_default").then(([n,s])=>new xs(n,s))}async append(n){return ie("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(n)?n:[n]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async prepend(n){return ie("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(n)?n:[n]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async insert(n,s){return ie("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(n)?n:[n]).map(i=>"rid"in i?[i.rid,i.kind]:i),position:s})}async remove(n){return ie("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[n.rid,n.kind]})}async removeAt(n){return ie("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:n}).then(ys)}async items(){return ie("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(n=>n.map(ys))}async get(n){return ie("plugin:menu|get",{rid:this.rid,kind:this.kind,id:n}).then(s=>s?ys(s):null)}async popup(n,s){var i;return ie("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(i=s==null?void 0:s.label)!==null&&i!==void 0?i:null,at:n instanceof Yr?n:n?new Yr(n):null})}async setAsAppMenu(){return ie("plugin:menu|set_as_app_menu",{rid:this.rid}).then(n=>n?new xs(n[0],n[1]):null)}async setAsWindowMenu(n){var s;return ie("plugin:menu|set_as_window_menu",{rid:this.rid,window:(s=n==null?void 0:n.label)!==null&&s!==void 0?s:null}).then(i=>i?new xs(i[0],i[1]):null)}}async function Hc(e){if(e.length===0)return;await(await xs.new({items:e.map(s=>({id:s.id,text:s.label,enabled:!s.disabled,accelerator:s.accelerator,action:()=>{s.onSelect()}}))})).popup(void 0,Ga())}function Va(e,n){const s=new Map(e.map(c=>[n.getId(c),c])),i=new Map,o=[];for(const c of e){const h=Uc(c,s,n);if(!h){o.push(c);continue}const f=i.get(h)??[];i.set(h,[...f,c])}return[...o].sort(n.compare).map(c=>Ja(c,0,i,n,new Set))}function Ns(e){return Array.isArray(e==null?void 0:e.children)?e.children:[]}function Xa(e){return e.flatMap(n=>[n.item,...Xa(Ns(n))])}function Sn(e){return e.flatMap(n=>[n,...Sn(Ns(n))])}function Yi(e,n){return e.some(s=>n(s.item)||Yi(Ns(s),n))}function Ya(e,n,s){return e?s(e.item)===n?!0:Ns(e).some(i=>Ya(i,n,s)):!1}function ks(e,n,s){for(const i of e){const o=s(i.item);if(o===n)return[];const c=ks(Ns(i),n,s);if(Ya(i,n,s)&&c.length>=0)return[o,...c]}return[]}function Ja(e,n,s,i,o){const c=i.getId(e),h=new Set(o);h.add(c);const f=[...s.get(c)??[]].filter(k=>!h.has(i.getId(k))).sort(i.compare).map(k=>Ja(k,n+1,s,i,h));return{item:e,depth:n,children:f}}function Uc(e,n,s){const i=xo(s.getParentId(e));if(!i)return null;const o=n.get(i);if(!o)return null;const c=new Set([s.getId(e)]);let h=o;for(;h;){const f=s.getId(h);if(c.has(f))return null;c.add(f);const k=xo(s.getParentId(h));if(!k||(h=n.get(k),!h))return i}return i}function xo(e){const n=e==null?void 0:e.trim();return n||null}function at(){return"/workspaces"}function Gt(e){return`/workspaces/${encodeURIComponent(e)}`}function Za(e){return`${Gt(e)}/debug`}function Qs(e){return`${Gt(e)}/sessions`}function $t(e,n){return`${Qs(e)}/${encodeURIComponent(n)}`}function Qa(e,n){const s=`${Gt(e)}/tools`;if(!n)return s;const i=new URLSearchParams({tab:n});return`${s}?${i.toString()}`}function el(e){return`${Gt(e)}/tools/files`}function tl(e){return`${Gt(e)}/tools/git`}function nl(e){return`${Gt(e)}/tools/processes`}function vs(e){return`${Gt(e)}/terminals`}function Vn(e,n){const s=`${Gt(e)}/butler`;if(!n)return s;const i=new URLSearchParams({tab:n});return`${s}?${i.toString()}`}function $c(e){return e.flatMap(n=>[...n.sessions.map(s=>({session:s,workspace:n.workspace})),...rl(n.childWorktrees??[])]).sort((n,s)=>(s.session.lastMessageAt??s.session.updatedAt).localeCompare(n.session.lastMessageAt??n.session.updatedAt))}function ym(e){return Va(e,{getId:n=>n.session.sessionId,getParentId:n=>{var s;return((s=n.session.parentSessionId)==null?void 0:s.trim())||null},compare:Gc})}function sl(e,n){const s=qc(),i=new URLSearchParams({provider:n});return`${$t(e,s)}?${i.toString()}`}function qc(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`draft-${e.randomUUID()}`:`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Gc(e,n){return(n.session.lastMessageAt??n.session.updatedAt).localeCompare(e.session.lastMessageAt??e.session.updatedAt)}function rl(e){return e.flatMap(n=>[...n.sessions.map(s=>({session:s,workspace:n.workspace})),...rl(n.children)])}const Kc="mobile.tools.last-primary-tool";function il(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(Kc)==="git"?"git":"files"}catch{return"files"}}function Ji(e){var i;const n=[{pattern:"/workspaces/:workspaceId/tools/processes",routeKind:"processes"},{pattern:"/workspaces/:workspaceId/tools/files",routeKind:"files"},{pattern:"/workspaces/:workspaceId/tools/git",routeKind:"git"},{pattern:"/workspaces/:workspaceId/tools",routeKind:"home"}];for(const o of n){const c=Se(o.pattern,e),h=((i=c==null?void 0:c.params.workspaceId)==null?void 0:i.trim())??null;if(h)return{workspaceId:h,routeKind:o.routeKind,legacy:!1}}const s=[{pattern:"/tools/processes",routeKind:"processes"},{pattern:"/tools/files",routeKind:"files"},{pattern:"/tools/git",routeKind:"git"},{pattern:"/tools",routeKind:"home"}];for(const o of s)if(Se(o.pattern,e))return{workspaceId:null,routeKind:o.routeKind,legacy:!0};return null}function zc(e,n){const s=Ji(e);if((s==null?void 0:s.routeKind)==="git")return"git";if((s==null?void 0:s.routeKind)==="files")return"files";const i=new URLSearchParams(n).get("tab");return i==="git"?"git":i==="files"?"files":il()}function Zi(e,n){const s=Ji(e);return(s==null?void 0:s.routeKind)==="processes"&&s.workspaceId?vs(s.workspaceId):s!=null&&s.workspaceId?Qa(s.workspaceId,zc(e,n)):s!=null&&s.legacy?il()==="git"?"/tools?tab=git":"/tools?tab=files":null}function Qi({activeEntry:e,presentation:n,pathname:s,search:i,moreButtonLabel:o}){if(n==="conversation-focus"||e!=="butler")return null;const c=Ji(s);return c?c.routeKind==="processes"?{title:r("shell.terminalManagerEntry"),showBackButton:!0,showMoreButton:!1,moreButtonLabel:o}:(c.routeKind==="home"||c.routeKind==="files"||c.routeKind==="git",null):null}const ol=l.createContext({composerPortalTarget:null});function eo({composerPortalTarget:e,children:n}){return t.jsx(ol.Provider,{value:{composerPortalTarget:e},children:n})}function Sm(){return l.useContext(ol)}function to(e,n,s){const[i,o]=l.useState(void 0);return l.useEffect(()=>{const c=e.current,h=n.current;if(!s||!c||!h){o(void 0),c&&c.style.removeProperty("--mobile-conversation-tabbar-height");return}const f=c,k=h;function p(){if(!e.current||!k.isConnected)return;const N=`${Math.round(k.getBoundingClientRect().height)}px`;f.style.setProperty("--mobile-conversation-tabbar-height",N),o(N)}p();const g=typeof ResizeObserver<"u"?new ResizeObserver(p):null;return g==null||g.observe(k),window.addEventListener("resize",p),()=>{g==null||g.disconnect(),window.removeEventListener("resize",p),f.style.removeProperty("--mobile-conversation-tabbar-height")}},[s,e,n]),i}const Vc=3e3,Wr=10,vo=84,yo=.36;function no({enabled:e,rootRef:n,suspended:s=!1,resetKey:i}){const o=l.useRef(null),c=l.useRef(null),h=l.useRef("visible"),f=l.useRef(1),[k,p]=l.useState("visible"),[g,N]=l.useState(1);l.useEffect(()=>{h.current=k},[k]),l.useEffect(()=>{f.current=g},[g]);function C(){Kn(o),o.current=window.setTimeout(()=>{I()},Vc)}function I(){p("hidden"),N(0)}function H(){p("visible"),N(1),C()}l.useEffect(()=>{if(Kn(o),!e){Kn(o),p("visible"),N(1);return}if(s){p("hidden"),N(0);return}return H(),()=>{Kn(o)}},[e,i,s]),l.useEffect(()=>()=>{Kn(o)},[]),l.useEffect(()=>{if(!e||s){c.current=null;return}const A=n.current;if(!A)return;function x(G){if(G.touches.length!==1){c.current=null;return}const j=G.touches[0],Z=No(G.target);if(!j||!Z){c.current=null;return}c.current={surface:Z,startX:j.clientX,startY:j.clientY,pointerType:"touch",initialState:h.current==="visible"?"visible":"hidden",touchId:j.identifier,dragging:!1,latestProgress:f.current},h.current==="visible"&&Kn(o)}function P(G){const j=c.current;if(!j||j.pointerType!=="touch")return;const Z=bi(G.touches,j.touchId);if(!Z)return;const ee=Z.clientX-j.startX,E=Z.clientY-j.startY;if(j.surface==="conversation"){if(Math.abs(E)<=Wr||Math.abs(E)<=Math.abs(ee))return;c.current=null,j.initialState==="visible"&&I();return}const ue=j.initialState==="hidden"?-E:E;ue<=Wr&&!j.dragging||(To(G),j.dragging=!0,j.latestProgress=So(j.initialState,ue),p("dragging"),N(j.latestProgress))}function _(G){const j=c.current;if(!(!j||j.pointerType!=="touch"||!bi(G.changedTouches,j.touchId))){if(c.current=null,!j.dragging){j.initialState==="visible"&&C();return}jo(j.initialState,j.latestProgress,H,p,N)}}function Y(G){const j=c.current;if(!(!j||j.pointerType!=="touch"||!bi(G.changedTouches,j.touchId))){if(c.current=null,!j.dragging){j.initialState==="visible"&&C();return}if(j.initialState==="visible"){H();return}p("hidden"),N(0)}}function R(G){if(G.pointerType!=="touch")return;const j=No(G.target);if(!j){c.current=null;return}if(c.current={surface:j,startX:G.clientX,startY:G.clientY,pointerType:"pointer",initialState:h.current==="visible"?"visible":"hidden",pointerId:G.pointerId,captureTarget:G.target instanceof Element?G.target:null,dragging:!1,latestProgress:f.current},G.target instanceof Element)try{G.target.setPointerCapture(G.pointerId)}catch{}h.current==="visible"&&Kn(o)}function K(G){const j=c.current;if(!j||j.pointerType!=="pointer")return;const Z=G.clientX-j.startX,ee=G.clientY-j.startY;if(j.surface==="conversation"){if(Math.abs(ee)<=Wr||Math.abs(ee)<=Math.abs(Z))return;c.current=null,j.initialState==="visible"&&I();return}const E=j.initialState==="hidden"?-ee:ee;E<=Wr&&!j.dragging||(To(G),j.dragging=!0,j.latestProgress=So(j.initialState,E),p("dragging"),N(j.latestProgress))}function V(G){const j=c.current;if(!(!j||j.pointerType!=="pointer"||j.pointerId!==G.pointerId)){if(c.current=null,Xc(j),!j.dragging){j.initialState==="visible"&&C();return}jo(j.initialState,j.latestProgress,H,p,N)}}return A.addEventListener("touchstart",x,{passive:!0}),A.addEventListener("pointerdown",R,{passive:!0}),window.addEventListener("touchmove",P,{passive:!1}),window.addEventListener("touchend",_),window.addEventListener("touchcancel",Y),window.addEventListener("pointermove",K,{passive:!1}),window.addEventListener("pointerup",V),window.addEventListener("pointercancel",V),()=>{A.removeEventListener("touchstart",x),A.removeEventListener("pointerdown",R),window.removeEventListener("touchmove",P),window.removeEventListener("touchend",_),window.removeEventListener("touchcancel",Y),window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V)}},[e,n,s]);const U=e&&!s?g:e?0:1;return{state:s&&e?"hidden":k,progress:U,isOpen:U>.01}}function Kn(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function So(e,n){return Co(e==="hidden"?n/vo:1-n/vo,0,1)}function jo(e,n,s,i,o){if(e==="hidden"){if(n>=yo){s();return}i("hidden"),o(0);return}if(n<=1-yo){i("hidden"),o(0);return}s()}function Xc(e){if(!(e.pointerType!=="pointer"||typeof e.pointerId!="number"||!(e.captureTarget instanceof Element)))try{e.captureTarget.hasPointerCapture(e.pointerId)&&e.captureTarget.releasePointerCapture(e.pointerId)}catch{}}function bi(e,n){if(typeof n!="number")return e[0]??null;for(let s=0;s<e.length;s+=1){const i=e[s];if((i==null?void 0:i.identifier)===n)return i}return null}function No(e){return e instanceof Element?e.closest(".composer-panel")?"composer":e.closest(".message-list, .message-timeline, .mobile-conversation-main, .conversation-page-shell, .mobile-butler-main-stage, .mobile-butler-chat-body, .mobile-butler-page-shell")?"conversation":null:null}function Co(e,n,s){return Math.min(Math.max(e,n),s)}function To(e){e.cancelable&&e.preventDefault()}function nr({viewportClass:e,activeEntry:n,hasNavigationPanel:s,hasAuxiliaryPanel:i,preferCompactLayout:o=!1}){return o||e==="compact"?"compact":e==="expanded"&&s&&i?"expanded":n==="butler"&&i?"medium-auxiliary":s?"medium-navigation":i?"medium-auxiliary":"compact"}function ti(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function al(e){return e==="medium-navigation"||e==="expanded"}function ll(e){return e==="medium-auxiliary"||e==="expanded"}function so({viewportClass:e,activeEntry:n,hasNavigationPanel:s,hasAuxiliaryPanel:i,preferCompactLayout:o=!1,children:c,navigationPanel:h,auxiliaryPanel:f}){const k=nr({viewportClass:e,activeEntry:n,hasNavigationPanel:s,hasAuxiliaryPanel:i,preferCompactLayout:o}),p=al(k)&&h,g=ll(k)&&f;return t.jsxs("div",{className:"mobile-adaptive-pane-layout","data-pane-layout":k,children:[p?t.jsx("aside",{className:"workbench-nav surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-navigation",children:h}):null,t.jsx("div",{className:"mobile-adaptive-pane-main",children:c}),g?t.jsx("aside",{className:"workbench-auxiliary surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-auxiliary",children:f}):null]})}function Yc({activeEntry:e,presentation:n="default",children:s,navigationPanel:i,auxiliaryPanel:o,onNavigateWorkspaces:c,onNavigateTerminals:h,onNavigateSessions:f,onNavigateButler:k,onNavigateToolProcesses:p,onNavigateSettings:g}){const N=Tn(),C=$i(),I=ei(),H=er(),U=l.useRef(null),A=l.useRef(null),[x,P]=l.useState(null),_=n==="conversation-focus",Y=ti({isNativeMobile:N.isNativeMobile,viewportClass:N.viewportClass}),R=no({enabled:_,rootRef:U,resetKey:`${I.pathname}${I.search}`}),K=nr({viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!i,hasAuxiliaryPanel:!!o,preferCompactLayout:Y}),V=Qi({activeEntry:e,presentation:n,pathname:I.pathname,search:I.search,moreButtonLabel:r("shell.androidMoreAction")}),G=[{key:"workspaces",label:r("shell.mobileWorkspacesEntry"),icon:t.jsx(Qc,{}),onClick:c},{key:"sessions",label:r("shell.mobileSessionsEntry"),icon:t.jsx(ed,{}),onClick:f},{key:"terminals",label:r("shell.mobileButlerEntry"),icon:t.jsx(nd,{}),onClick:k},{key:"butler",label:r("shell.mobileTerminalsEntry"),icon:t.jsx(td,{}),onClick:h},{key:"settings",label:r("shell.mobileSettingsEntry"),icon:t.jsx(sd,{}),onClick:g}],j=_?{"--mobile-conversation-tabbar-progress":R.progress.toFixed(4)}:void 0;to(U,A,_);function Z(){const E=Zi(I.pathname,I.search);if(!E){h();return}H(E,{replace:!0})}const ee=t.jsx("nav",{ref:A,className:"android-workbench-bottom-nav","aria-label":r("shell.title"),children:G.map(E=>t.jsxs("button",{type:"button",className:"android-workbench-bottom-nav-item","data-active":E.key===e,"aria-current":E.key===e?"page":void 0,onClick:()=>{E.key!==e&&C.trigger("selection"),E.onClick()},children:[t.jsx("span",{className:"android-workbench-bottom-nav-icon","aria-hidden":"true",children:E.icon}),t.jsx("span",{className:"android-workbench-bottom-nav-label",children:E.label})]},E.key))});return t.jsx(eo,{composerPortalTarget:_?x:null,children:t.jsxs("div",{ref:U,className:"android-workbench-shell","data-active-entry":e,"data-mobile-presentation":n,"data-pane-layout":K,"data-tabbar-open":_?R.isOpen:!0,"data-conversation-tabbar-state":_?R.state:"default",style:j,children:[V?t.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[t.jsxs("div",{className:"android-workbench-topbar-leading",children:[V.showBackButton?t.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":r("common.back"),onClick:Z,children:t.jsx(Jc,{})}):null,t.jsx("div",{className:"android-workbench-topbar-copy",children:t.jsx("h1",{children:V.title})})]}),t.jsx("div",{className:"android-workbench-topbar-actions",children:V.showMoreButton?t.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":V.moreButtonLabel,onClick:p,children:t.jsx(Zc,{})}):null})]}):null,t.jsx("div",{className:"android-workbench-content",children:t.jsx(so,{viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!i,hasAuxiliaryPanel:!!o,preferCompactLayout:Y,navigationPanel:i,auxiliaryPanel:o,children:s})}),_?t.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[t.jsx("div",{ref:P,className:"mobile-conversation-bottom-layer-composer-slot"}),t.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:ee})]}):ee]})})}function Jc(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"m15 18-6-6 6-6"}),t.jsx("path",{d:"M21 12H9"})]})}function Zc(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),t.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),t.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Qc(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),t.jsx("path",{d:"M8 13h8"})]})}function ed(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function td(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),t.jsx("path",{d:"m7.5 9 3 3-3 3"}),t.jsx("path",{d:"M12.5 15H17"})]})}function nd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),t.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),t.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function sd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}const rd=120,Ks={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function Ei(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function id(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable||e.closest("[contenteditable='true']"))return!0;if(e instanceof HTMLTextAreaElement)return!e.readOnly&&!e.disabled;if(e instanceof HTMLInputElement){if(e.readOnly||e.disabled)return!1;const n=(e.type||"text").toLowerCase();return!["button","checkbox","color","file","hidden","image","radio","range","reset","submit"].includes(n)}return!1}function od(){var n;if(typeof window>"u")return 0;const e=[window.innerHeight,typeof document<"u"?(n=document.documentElement)==null?void 0:n.clientHeight:0].filter(Ei);return e.length>0?Math.max(...e):0}function Io(){if(typeof window>"u")return Ks;const e=window.visualViewport,n=od(),s=(e==null?void 0:e.height)??n,i=Ei(s)?Math.round(s):null,o=Ei(e==null?void 0:e.offsetTop)?(e==null?void 0:e.offsetTop)??0:0,c=i===null?0:Math.max(0,Math.round(n-i-o));return{viewportHeight:i,keyboardInset:c,keyboardOpen:id(typeof document<"u"?document.activeElement:null)&&c>=rd}}function ki(e,n){if(typeof document>"u")return;[document.documentElement,document.body].filter(i=>i instanceof HTMLElement).forEach(i=>{if(!e){delete i.dataset.mobileKeyboardOpen,delete i.dataset.mobileViewportBound,i.style.removeProperty("--mobile-shell-viewport-height"),i.style.removeProperty("--mobile-shell-keyboard-inset");return}i.dataset.mobileKeyboardOpen=String(n.keyboardOpen),i.dataset.mobileViewportBound="true",n.viewportHeight===null?i.style.removeProperty("--mobile-shell-viewport-height"):i.style.setProperty("--mobile-shell-viewport-height",`${n.viewportHeight}px`),i.style.setProperty("--mobile-shell-keyboard-inset",`${n.keyboardInset}px`)})}function ad(e){const[n,s]=l.useState(()=>e?Io():Ks),i=l.useRef(null);return l.useEffect(()=>{if(!e){s(Ks),ki(!1,Ks);return}function o(){s(Io())}function c(){i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,o()},0)}o();const h=window.visualViewport;return window.addEventListener("resize",o),window.addEventListener("orientationchange",o),h==null||h.addEventListener("resize",o),h==null||h.addEventListener("scroll",o),document.addEventListener("focusin",o),document.addEventListener("focusout",c),()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null),window.removeEventListener("resize",o),window.removeEventListener("orientationchange",o),h==null||h.removeEventListener("resize",o),h==null||h.removeEventListener("scroll",o),document.removeEventListener("focusin",o),document.removeEventListener("focusout",c),ki(!1,Ks)}},[e]),l.useEffect(()=>{ki(e,n)},[e,n]),n}function ld({activeEntry:e,presentation:n="default",children:s,navigationPanel:i,auxiliaryPanel:o,onNavigateWorkspaces:c,onNavigateTerminals:h,onNavigateSessions:f,onNavigateButler:k,onNavigateToolProcesses:p,onNavigateSettings:g}){const N=Tn(),C=$i(),I=ei(),H=er(),U=l.useRef(null),A=l.useRef(null),[x,P]=l.useState(null),_=n==="conversation-focus",Y=ti({isNativeMobile:N.isNativeMobile,viewportClass:N.viewportClass}),R=no({enabled:_,rootRef:U,resetKey:`${I.pathname}${I.search}`}),K=nr({viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!i,hasAuxiliaryPanel:!!o,preferCompactLayout:Y}),V=Qi({activeEntry:e,presentation:n,pathname:I.pathname,search:I.search,moreButtonLabel:r("shell.iosMoreAction")}),G=[{key:"workspaces",label:r("shell.mobileWorkspacesEntry"),icon:t.jsx(ud,{}),onClick:c},{key:"sessions",label:r("shell.mobileSessionsEntry"),icon:t.jsx(hd,{}),onClick:f},{key:"terminals",label:r("shell.mobileButlerEntry"),icon:t.jsx(md,{}),onClick:k},{key:"butler",label:r("shell.mobileTerminalsEntry"),icon:t.jsx(fd,{}),onClick:h},{key:"settings",label:r("shell.mobileSettingsEntry"),icon:t.jsx(pd,{}),onClick:g}],j=_?{"--mobile-conversation-tabbar-progress":R.progress.toFixed(4)}:void 0;to(U,A,_);function Z(){const E=Zi(I.pathname,I.search);if(!E){h();return}H(E,{replace:!0})}const ee=t.jsx("nav",{ref:A,className:"ios-workbench-tabbar","aria-label":r("shell.title"),children:G.map(E=>t.jsxs("button",{type:"button",className:"ios-workbench-tabbar-item","data-active":E.key===e,"aria-current":E.key===e?"page":void 0,onClick:()=>{E.key!==e&&C.trigger("selection"),E.onClick()},children:[t.jsx("span",{className:"ios-workbench-tabbar-icon","aria-hidden":"true",children:E.icon}),t.jsx("span",{className:"ios-workbench-tabbar-label",children:E.label})]},E.key))});return t.jsx(eo,{composerPortalTarget:_?x:null,children:t.jsxs("div",{ref:U,className:"ios-workbench-shell","data-active-entry":e,"data-mobile-presentation":n,"data-pane-layout":K,"data-tabbar-open":_?R.isOpen:!0,"data-conversation-tabbar-state":_?R.state:"default",style:j,children:[V?t.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[t.jsx("div",{className:"ios-workbench-nav-leading",children:V.showBackButton?t.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":r("common.back"),onClick:Z,children:[t.jsx(cd,{}),t.jsx("span",{children:r("common.back")})]}):null}),t.jsx("div",{className:"ios-workbench-nav-copy",children:t.jsx("h1",{children:V.title})}),t.jsx("div",{className:"ios-workbench-nav-actions",children:V.showMoreButton?t.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":V.moreButtonLabel,onClick:p,children:t.jsx(dd,{})}):null})]}):null,t.jsx("div",{className:"ios-workbench-content",children:t.jsx(so,{viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!i,hasAuxiliaryPanel:!!o,preferCompactLayout:Y,navigationPanel:i,auxiliaryPanel:o,children:s})}),_?t.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[t.jsx("div",{ref:P,className:"mobile-conversation-bottom-layer-composer-slot"}),t.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:ee})]}):ee]})})}function cd(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:t.jsx("path",{d:"m15 18-6-6 6-6"})})}function dd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),t.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),t.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function ud(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[t.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),t.jsx("path",{d:"M8 13h8"})]})}function hd(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function fd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),t.jsx("path",{d:"m7.5 9 3 3-3 3"}),t.jsx("path",{d:"M12.5 15H17"})]})}function md(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[t.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),t.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),t.jsx("circle",{cx:"10",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),t.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function pd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function bd(e){const n=Tn();return n.platform==="ios"?t.jsx(ld,{...e}):n.platform==="android"?t.jsx(Yc,{...e}):t.jsx(kd,{...e})}function kd({activeEntry:e,presentation:n="default",children:s,navigationPanel:i,auxiliaryPanel:o,onNavigateWorkspaces:c,onNavigateTerminals:h,onNavigateSessions:f,onNavigateButler:k,onNavigateToolProcesses:p,onNavigateSettings:g}){const N=Tn(),C=$i(),I=ei(),H=er(),U=l.useRef(null),A=l.useRef(null),[x,P]=l.useState(null),_=ad(N.platform==="web"),Y=N.platform==="web"&&_.keyboardOpen,R=n==="conversation-focus",K=ti({isNativeMobile:N.isNativeMobile,viewportClass:N.viewportClass}),V=no({enabled:R,rootRef:U,suspended:Y,resetKey:`${I.pathname}${I.search}`}),G=nr({viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!i,hasAuxiliaryPanel:!!o,preferCompactLayout:K}),j=Qi({activeEntry:e,presentation:n,pathname:I.pathname,search:I.search,moreButtonLabel:r("shell.iosMoreAction")}),Z=[{key:"workspaces",label:r("shell.mobileWorkspacesEntry"),icon:t.jsx(xd,{}),onClick:c},{key:"sessions",label:r("shell.mobileSessionsEntry"),icon:t.jsx(vd,{}),onClick:f},{key:"terminals",label:r("shell.mobileButlerEntry"),icon:t.jsx(Sd,{}),onClick:k},{key:"butler",label:r("shell.mobileTerminalsEntry"),icon:t.jsx(yd,{}),onClick:h},{key:"settings",label:r("shell.mobileSettingsEntry"),icon:t.jsx(jd,{}),onClick:g}],ee=R?{"--mobile-conversation-tabbar-progress":V.progress.toFixed(4)}:void 0;to(U,A,R);function E(){const $=Zi(I.pathname,I.search);if(!$){h();return}H($,{replace:!0})}const ue=t.jsx("nav",{ref:A,className:"mobile-workbench-tabbar","aria-label":r("shell.title"),hidden:Y,children:Z.map($=>t.jsxs("button",{type:"button",className:"mobile-workbench-tabbar-item","data-active":$.key===e,"aria-current":$.key===e?"page":void 0,onClick:()=>{$.key!==e&&C.trigger("selection"),$.onClick()},children:[t.jsx("span",{className:"mobile-workbench-tabbar-icon","aria-hidden":"true",children:$.icon}),t.jsx("span",{className:"mobile-workbench-tabbar-label",children:$.label})]},$.key))});return t.jsx(eo,{composerPortalTarget:R?x:null,children:t.jsxs("div",{ref:U,className:"mobile-workbench-shell","data-active-entry":e,"data-mobile-presentation":n,"data-mobile-runtime":N.platform,"data-mobile-keyboard-open":Y,"data-pane-layout":G,"data-tabbar-open":Y?!1:R?V.isOpen:!0,"data-conversation-tabbar-state":R?V.state:"default",style:ee,children:[j?t.jsxs("header",{className:"mobile-workbench-header","data-header-kind":"tools",children:[t.jsxs("div",{className:"mobile-workbench-header-leading",children:[j.showBackButton?t.jsx("button",{type:"button",className:"mobile-workbench-header-button","aria-label":r("common.back"),onClick:E,children:t.jsx(gd,{})}):null,t.jsx("div",{className:"mobile-workbench-header-copy",children:t.jsx("h1",{children:j.title})})]}),t.jsx("div",{className:"mobile-workbench-header-actions",children:j.showMoreButton?t.jsx("button",{type:"button",className:"mobile-workbench-header-button mobile-tools-more-button","aria-label":j.moreButtonLabel,onClick:p,children:t.jsx(wd,{})}):null})]}):null,t.jsx("div",{className:"mobile-workbench-content",children:t.jsx(so,{viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!i,hasAuxiliaryPanel:!!o,preferCompactLayout:K,navigationPanel:i,auxiliaryPanel:o,children:s})}),R?t.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[t.jsx("div",{ref:P,className:"mobile-conversation-bottom-layer-composer-slot"}),t.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:ue})]}):ue]})})}function gd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("path",{d:"m15 18-6-6 6-6"}),t.jsx("path",{d:"M21 12H9"})]})}function wd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),t.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),t.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function xd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),t.jsx("path",{d:"M8 13h8"})]})}function vd(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function yd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),t.jsx("path",{d:"m7.5 9 3 3-3 3"}),t.jsx("path",{d:"M12.5 15H17"})]})}function Sd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),t.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),t.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function jd(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}class Nd{constructor(n){ge(this,"maxAttempts");ge(this,"baseDelayMs");ge(this,"reconnectAttempts",0);ge(this,"reconnectTimer",null);ge(this,"disposed",!1);this.options=n,this.maxAttempts=n.maxAttempts??4,this.baseDelayMs=n.baseDelayMs??300}start(){this.options.onReconnect(!1)}markConnected(){this.reconnectAttempts=0,this.options.onStateChange("connected")}markTransientFailure(){this.disposed||this.reconnectAttempts>0||this.options.onStateChange("reconnecting")}markDisconnected(){if(this.disposed)return;if(!nn.getState().autoReconnect){this.options.onStateChange("reconnect_failed");return}if(this.reconnectAttempts+=1,this.reconnectAttempts>this.maxAttempts){this.options.onStateChange("reconnect_failed");return}this.options.onStateChange("reconnecting");const n=this.baseDelayMs*this.reconnectAttempts;this.reconnectTimer=window.setTimeout(()=>{this.options.onReconnect(!0)},n)}reconnectNow(){this.reconnectAttempts=0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onReconnect(!0)}close(){this.disposed=!0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onStateChange("closed")}}class Cd{constructor(n){ge(this,"socket",null);ge(this,"disposed",!1);ge(this,"authRecoveryInFlight",!1);ge(this,"pendingRefresh",!1);ge(this,"workbenchKnownRevision");ge(this,"lastWorkbenchSnapshot",null);ge(this,"fileTreeSubscription",null);ge(this,"gitSubscription",null);ge(this,"terminalManagerSubscription",null);ge(this,"workspaceManagementSubscription",null);ge(this,"pendingFileTreeRefresh",null);ge(this,"pendingGitRefresh",null);ge(this,"pendingTerminalManagerRefresh",null);ge(this,"pendingWorkspaceManagementRefresh",null);ge(this,"fileTreeRevisionByPath",new Map);ge(this,"gitRevisionByWorkspaceId",new Map);ge(this,"terminalManagerRevisionByWorkspaceId",new Map);ge(this,"workspaceManagementRevisionByWorkspaceId",new Map);ge(this,"fileTreeListeners",new Set);ge(this,"gitListeners",new Set);ge(this,"terminalManagerListeners",new Set);ge(this,"workspaceManagementListeners",new Set);ge(this,"workbenchSubscribeStartedAtMs",null);ge(this,"workbenchRefreshStartedAtMs",null);ge(this,"connectionManager");this.options=n,this.workbenchKnownRevision=null,this.connectionManager=new Nd({onReconnect:s=>{this.connect(s)},onStateChange:n.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const n=this.socket;if(!Ro(n)){this.pendingRefresh=!0;return}this.workbenchRefreshStartedAtMs=performance.now(),n.send(JSON.stringify({type:"workbench.refresh",knownRevision:this.workbenchKnownRevision??void 0})),qe("workbench.refresh.sent",{knownRevision:this.workbenchKnownRevision}),this.pendingRefresh=!1}setWorkbenchKnownRevision(n){this.workbenchKnownRevision=kt(n)}primeWorkbenchSnapshot(n){if(!n||!Array.isArray(n.items)){this.lastWorkbenchSnapshot=null,this.workbenchKnownRevision=null;return}this.lastWorkbenchSnapshot=n,this.workbenchKnownRevision=kt(n.revision)??null}subscribeFileTree(n,s,i){this.fileTreeSubscription={workspaceId:n,paths:Mo(s),knownRevisionByPath:gi(i==null?void 0:i.knownRevisionByPath)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:n,paths:this.fileTreeSubscription.paths,knownRevisions:wi(n,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})}requestFileTreeRefresh(n,s,i){const o=Mo(s),c={type:"fileTree.refresh",workspaceId:n,paths:o,knownRevisions:wi(n,o,gi(i==null?void 0:i.knownRevisionByPath),this.fileTreeRevisionByPath)};this.sendWhenReady(c)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:n,paths:o,knownRevisionByPath:gi(i==null?void 0:i.knownRevisionByPath)}}subscribeGit(n,s){this.gitSubscription={workspaceId:n,knownRevision:kt(s==null?void 0:s.knownRevision)},this.sendWhenReady({type:"git.subscribe",workspaceId:n,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(n)})}requestGitRefresh(n,s){const i={type:"git.refresh",workspaceId:n,knownRevision:kt(s==null?void 0:s.knownRevision)??this.gitRevisionByWorkspaceId.get(n)};this.sendWhenReady(i)?this.pendingGitRefresh=null:this.pendingGitRefresh={workspaceId:n,knownRevision:kt(s==null?void 0:s.knownRevision)}}subscribeTerminalManager(n,s){this.terminalManagerSubscription={workspaceId:n,knownRevision:kt(s==null?void 0:s.knownRevision)},this.sendWhenReady({type:"terminalManager.subscribe",workspaceId:n,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(n)})}requestTerminalManagerRefresh(n,s){const i={type:"terminalManager.refresh",workspaceId:n,knownRevision:kt(s==null?void 0:s.knownRevision)??this.terminalManagerRevisionByWorkspaceId.get(n)};this.sendWhenReady(i)?this.pendingTerminalManagerRefresh=null:this.pendingTerminalManagerRefresh={workspaceId:n,knownRevision:kt(s==null?void 0:s.knownRevision)}}subscribeWorkspaceManagement(n,s){this.workspaceManagementSubscription={workspaceId:n,knownRevision:kt(s==null?void 0:s.knownRevision)},this.sendWhenReady({type:"workspaceManagement.subscribe",workspaceId:n,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(n)})}requestWorkspaceManagementRefresh(n,s){const i={type:"workspaceManagement.refresh",workspaceId:n,knownRevision:kt(s==null?void 0:s.knownRevision)??this.workspaceManagementRevisionByWorkspaceId.get(n)};this.sendWhenReady(i)?this.pendingWorkspaceManagementRefresh=null:this.pendingWorkspaceManagementRefresh={workspaceId:n,knownRevision:kt(s==null?void 0:s.knownRevision)}}addFileTreeSnapshotListener(n){return this.fileTreeListeners.add(n),()=>{this.fileTreeListeners.delete(n)}}addGitSnapshotListener(n){return this.gitListeners.add(n),()=>{this.gitListeners.delete(n)}}addTerminalManagerSnapshotListener(n){return this.terminalManagerListeners.add(n),()=>{this.terminalManagerListeners.delete(n)}}addWorkspaceManagementSnapshotListener(n){return this.workspaceManagementListeners.add(n),()=>{this.workspaceManagementListeners.delete(n)}}close(){var n;this.disposed=!0,this.connectionManager.close(),(n=this.socket)==null||n.close(),this.socket=null}connect(n){var k;if(this.disposed)return;n&&this.socket&&(this.socket.close(),this.socket=null);const s=(k=Zs.getState().session)==null?void 0:k.accessToken;if(!s){this.options.onUnauthorized();return}const i=Aa(),o=nc(i),c=o.baseUrl,h=`${sc("/ws",c)}?access_token=${encodeURIComponent(s)}`,f=o.transport.createWebSocket({path:"/ws",baseUrl:c,url:h});this.socket=f,f.addEventListener("open",()=>{this.workbenchSubscribeStartedAtMs=performance.now(),f.send(JSON.stringify({type:"workbench.subscribe",knownRevision:this.workbenchKnownRevision??void 0})),qe("workbench.subscribe.sent",{knownRevision:this.workbenchKnownRevision,baseUrl:c}),this.pendingRefresh&&this.requestRefresh(),this.fileTreeSubscription&&f.send(JSON.stringify({type:"fileTree.subscribe",workspaceId:this.fileTreeSubscription.workspaceId,paths:this.fileTreeSubscription.paths,knownRevisions:wi(this.fileTreeSubscription.workspaceId,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})),this.pendingFileTreeRefresh&&this.requestFileTreeRefresh(this.pendingFileTreeRefresh.workspaceId,this.pendingFileTreeRefresh.paths,{knownRevisionByPath:this.pendingFileTreeRefresh.knownRevisionByPath}),this.gitSubscription&&f.send(JSON.stringify({type:"git.subscribe",workspaceId:this.gitSubscription.workspaceId,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(this.gitSubscription.workspaceId)})),this.pendingGitRefresh&&this.requestGitRefresh(this.pendingGitRefresh.workspaceId,{knownRevision:this.pendingGitRefresh.knownRevision}),this.terminalManagerSubscription&&f.send(JSON.stringify({type:"terminalManager.subscribe",workspaceId:this.terminalManagerSubscription.workspaceId,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(this.terminalManagerSubscription.workspaceId)})),this.pendingTerminalManagerRefresh&&this.requestTerminalManagerRefresh(this.pendingTerminalManagerRefresh.workspaceId,{knownRevision:this.pendingTerminalManagerRefresh.knownRevision}),this.workspaceManagementSubscription&&f.send(JSON.stringify({type:"workspaceManagement.subscribe",workspaceId:this.workspaceManagementSubscription.workspaceId,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(this.workspaceManagementSubscription.workspaceId)})),this.pendingWorkspaceManagementRefresh&&this.requestWorkspaceManagementRefresh(this.pendingWorkspaceManagementRefresh.workspaceId,{knownRevision:this.pendingWorkspaceManagementRefresh.knownRevision})}),f.addEventListener("message",p=>{var N,C,I,H,U,A,x,P,_,Y;if(!(p instanceof MessageEvent)||typeof p.data!="string")return;const g=JSON.parse(p.data);if(g.type==="system.connected"){this.connectionManager.markConnected();return}if(g.type==="session.error"){g.error_code==="UNAUTHORIZED"&&this.handleUnauthorized();return}if(g.type==="workbench.snapshot"&&(qe("workbench.snapshot.received",{unchanged:g.unchanged,revision:g.revision,workspaceCount:((N=g.snapshot)==null?void 0:N.items.length)??0,sessionCount:g.snapshot?Rd(g.snapshot):0,subscribeDurationMs:Ar(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Ar(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null),g.type==="workbench.delta"){qe("workbench.delta.received",{baseRevision:g.baseRevision,revision:g.revision,changedWorkspaceCount:g.changedItems.length,removedWorkspaceCount:g.removedWorkspaceIds.length,subscribeDurationMs:Ar(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Ar(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null;const R=Id(this.lastWorkbenchSnapshot,g);if(!R){qe("workbench.delta.mismatch",{currentRevision:((C=this.lastWorkbenchSnapshot)==null?void 0:C.revision)??null,baseRevision:g.baseRevision,revision:g.revision}),this.workbenchKnownRevision=null,this.lastWorkbenchSnapshot=null,this.connectionManager.reconnectNow();return}this.lastWorkbenchSnapshot=R,this.workbenchKnownRevision=g.revision,this.options.onSnapshot(R);return}if(g.type==="fileTree.snapshot"){const R=g.snapshot;if(R)R.revision=g.revision,this.fileTreeRevisionByPath.set(Wi(R.workspaceId,R.path),g.revision);else if(g.unchanged&&this.fileTreeSubscription)for(const K of this.fileTreeSubscription.paths)this.fileTreeRevisionByPath.set(Wi(this.fileTreeSubscription.workspaceId,K),g.revision);if(!R)return;(H=(I=this.options).onFileTreeSnapshot)==null||H.call(I,R),this.fileTreeListeners.forEach(K=>K(R));return}if(g.type==="git.snapshot"){const R=g.snapshot;if(R?(R.revision=g.revision,this.gitRevisionByWorkspaceId.set(R.workspaceId,g.revision)):g.unchanged&&this.gitSubscription&&this.gitRevisionByWorkspaceId.set(this.gitSubscription.workspaceId,g.revision),!R)return;(A=(U=this.options).onGitSnapshot)==null||A.call(U,R),this.gitListeners.forEach(K=>K(R));return}if(g.type==="terminalManager.snapshot"){const R=g.snapshot;if(R?(R.revision=g.revision,this.terminalManagerRevisionByWorkspaceId.set(R.workspaceId,g.revision)):g.unchanged&&this.terminalManagerSubscription&&this.terminalManagerRevisionByWorkspaceId.set(this.terminalManagerSubscription.workspaceId,g.revision),!R)return;(P=(x=this.options).onTerminalManagerSnapshot)==null||P.call(x,R),this.terminalManagerListeners.forEach(K=>K(R));return}if(g.type==="workspaceManagement.snapshot"){const R=g.snapshot;if(R?(R.revision=g.revision,this.workspaceManagementRevisionByWorkspaceId.set(R.workspaceId,g.revision)):g.unchanged&&this.workspaceManagementSubscription&&this.workspaceManagementRevisionByWorkspaceId.set(this.workspaceManagementSubscription.workspaceId,g.revision),!R)return;(Y=(_=this.options).onWorkspaceManagementSnapshot)==null||Y.call(_,R),this.workspaceManagementListeners.forEach(K=>K(R));return}g.type==="workbench.snapshot"&&g.snapshot&&Td(g.snapshot)?(g.snapshot.revision=g.revision,this.lastWorkbenchSnapshot=g.snapshot,this.workbenchKnownRevision=g.revision,this.options.onSnapshot(g.snapshot)):g.type==="workbench.snapshot"&&g.unchanged&&(this.workbenchKnownRevision=g.revision,this.lastWorkbenchSnapshot&&(this.lastWorkbenchSnapshot={...this.lastWorkbenchSnapshot,revision:g.revision}))}),f.addEventListener("close",()=>{this.disposed||this.socket!==f||this.connectionManager.markDisconnected()}),f.addEventListener("error",()=>{this.disposed||this.socket!==f||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const n=this.socket;this.socket=null,n==null||n.close(),Zs.refresh().then(s=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(s.status==="refreshed"){this.connectionManager.reconnectNow();return}if(s.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendWhenReady(n){const s=this.socket;return Ro(s)?(s.send(JSON.stringify(n)),!0):!1}}function Ro(e){return e!==null&&e.readyState===1}function Td(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function Mo(e){const n=new Set;for(const s of e??[""])n.add(s.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...n]}function kt(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function Id(e,n){if(!e||e.revision!==n.baseRevision)return null;const s=new Map(e.items.map(o=>[o.workspace.id,o]));for(const o of n.removedWorkspaceIds)s.delete(o);for(const o of n.changedItems)s.set(o.workspace.id,o);const i=[];for(const o of n.orderedWorkspaceIds){const c=s.get(o);if(!c)return null;i.push(c)}return{revision:n.revision,items:i}}function gi(e){return e?Object.fromEntries(Object.entries(e).map(([n,s])=>[n.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),kt(s)]).filter(n=>n[1]!==null)):{}}function wi(e,n,s,i){const o=n.map(c=>{const h=c.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return[h,s[h]??i.get(Wi(e,h))??null]}).filter(c=>!!c[1]);if(o.length!==0)return Object.fromEntries(o)}function Wi(e,n){return`${e}::${n}`}function Rd(e){return e.items.reduce((n,s)=>n+s.sessions.length+cl(s.childWorktrees??[]),0)}function cl(e){return e.reduce((n,s)=>{if(typeof s!="object"||s===null)return n;const i=s,o=Array.isArray(i.sessions)?i.sessions.length:0,c=Array.isArray(i.children)?cl(i.children):0;return n+o+c},0)}function Ar(e){return e===null||typeof performance>"u"?null:Math.round(performance.now()-e)}const Eo=6,Md=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function Ed(e){return e instanceof HTMLElement?!e.closest(Md):!0}function Ai(e,n,s){return e.isDesktop&&e.ui.osFamily==="macos"&&n===0&&Ed(s)}function dl(e){return e.isDesktop&&e.ui.osFamily==="macos"&&e.ui.prefersOverlayTitlebar}function ul(e){return dl(e)?"":void 0}function Wd(e){if(!Ai(e.platform,e.button,e.target)||typeof window>"u")return;const n=e.clientX,s=e.clientY;let i=!0;const o=()=>{i&&(i=!1,window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",h),window.removeEventListener("blur",f))},c=k=>{Math.abs(k.clientX-n)<Eo&&Math.abs(k.clientY-s)<Eo||(o(),Ad())},h=()=>{o()},f=()=>{o()};window.addEventListener("mousemove",c),window.addEventListener("mouseup",h),window.addEventListener("blur",f)}async function Ad(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await Ga().startDragging()}const Zr=.78,Pd=1;function Bd(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function hl(e,n,s,i){const o=Math.hypot(s-e,i-n),c=Math.min(1,o/120);return Zr+(Pd-Zr)*c}function jn(e){return Math.round(Number.isFinite(e)?e:0)}function Ld(e){if(!Bd())return null;const n=jn(e.x),s=jn(e.y);let i=!1,o=Promise.resolve();const c=(f,k)=>(o=o.then(async()=>{await window.__TAURI_INTERNALS__.invoke(f,k)}).catch(()=>{}),o),h=async()=>{i||(i=!0,await c("close_detach_preview"))};return c("show_detach_preview",{title:e.title,x:n,y:s,scale:Zr}),{updatePosition(f,k){if(i)return;const p=jn(f),g=jn(k);c("update_detach_preview_position",{x:p,y:g,scale:hl(n,s,p,g)})},complete(){return h()},cancel(){return h()}}}function Dd(e){if(typeof document>"u")return null;const n=jn(e.x),s=jn(e.y),i=document.createElement("div");i.className="desktop-window-detach-animation",i.setAttribute("aria-hidden","true"),i.dataset.state="preview",i.style.left=`${n}px`,i.style.top=`${s}px`,i.style.setProperty("--detach-preview-scale",Zr.toFixed(3));const o=document.createElement("div");o.className="desktop-window-detach-animation-bar";const c=document.createElement("strong");c.className="desktop-window-detach-animation-title",c.textContent=e.title;const h=document.createElement("div");h.className="desktop-window-detach-animation-body",o.append(c),i.append(o,h),document.body.append(i);let f=!1;const k=()=>{f||(f=!0,i.remove())};return{updatePosition(p,g){if(f)return;const N=jn(p),C=jn(g),I=hl(n,s,N,C);i.style.left=`${N}px`,i.style.top=`${C}px`,i.style.setProperty("--detach-preview-scale",I.toFixed(3))},async complete(){k()},async cancel(){k()}}}function Wo(e){return Ld(e)??Dd(e)}const _d={files:{kind:"files",label:"文件",defaultFocusOwner:"file-context-panel"},git:{kind:"git",label:"Git",defaultFocusOwner:"git-sidebar"},processes:{kind:"processes",label:"调试",defaultFocusOwner:"terminal-manager-panel"},terminals:{kind:"terminals",label:"终端",defaultFocusOwner:"terminal-page"}};function Fd(e){return{...e,bounds:{...e.bounds}}}function Od(e,n,s){n&&(e.windows.registerDescriptor(n),s?e.windows.markWindowOpen(n.windowId):e.windows.markWindowClosed(n.windowId))}function Hd(e){return _d[e]}function fl(e,n){return`${e}-${n}`}async function ni(e,n,s){const i=s.workspaceId.trim(),o=Hd(n);if(!e.isDesktop||!e.bridge.supported)return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前运行环境不支持桌面外部窗口。"};if(!i)return{ok:!1,errorCode:"WINDOW_WORKSPACE_REQUIRED",detail:`${o.label}外部窗口必须绑定工作区。`};const c=fl(n,i),h=e.windows.getDescriptor(c),f=h?Fd(h):null,k=e.windows.isWindowOpen(c),p=rc({windowId:c,kind:n,workspaceId:i,workspaceName:s.workspaceName??(f==null?void 0:f.workspaceName)??null,sessionId:s.sessionId??(f==null?void 0:f.sessionId)??null,mode:"external",bounds:f==null?void 0:f.bounds,focusOwner:s.focusOwner??o.defaultFocusOwner});e.windows.registerDescriptor(p);const g=await e.bridge.createWindow(p);return g.ok?(e.windows.markWindowOpen(c),{ok:!0,value:p}):(f?Od(e,f,k):e.windows.removeWindow(c),{ok:!1,errorCode:g.errorCode,detail:g.detail})}function jm(e){return fl("terminals",e)}function Ud(e,n){return ni(e,"files",n)}function $d(e,n){return ni(e,"git",n)}function qd(e,n){return ni(e,"processes",n)}function Nm(e,n){return ni(e,"terminals",n)}async function Ao(){return await Q.request("/api/skills/overview")}async function Gd(e){await Q.request("/api/skills",{method:"POST",body:JSON.stringify(e)})}async function Kd(e){await Q.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function zd(e){await Q.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}function Vd({triggerClassName:e="secondary-button",triggerLabel:n,triggerLeading:s}){const i=Pa(y=>{var q;return((q=y.session)==null?void 0:q.accessToken)??null}),o=l.useRef(null),[c,h]=l.useState(null),[f,k]=l.useState(!1),[p,g]=l.useState(null),[N,C]=l.useState(null),[I,H]=l.useState(null),[U,A]=l.useState(!1),[x,P]=l.useState(!1),[_,Y]=l.useState(null),[R,K]=l.useState("file"),[V,G]=l.useState("workspace"),[j,Z]=l.useState(""),[ee,E]=l.useState(()=>qs("workspace"));l.useEffect(()=>{let y=!0;if(!U)return;if(!i){h(null),C(null),H(null),k(!1);return}return(async()=>{k(!0);try{const le=await Ao();if(!y)return;h(le),C(null)}catch(le){if(!y)return;C(ps(le))}finally{y&&k(!1)}})(),()=>{y=!1}},[i,U]);async function ue(){const y=await Ao();h(y),C(null)}async function $(){if(i){g("refresh"),C(null),H(null);try{await ue(),H(r("settings.skillRefreshSuccess"))}catch(y){C(ps(y))}finally{g(null)}}}async function ce(y){if(i){g(Po(y)),C(null),H(null);try{await Kd({targetCli:y.targetCli,directoryPath:y.directoryPath,expectedContentHash:y.contentHash}),await ue(),H(r("settings.skillImportSuccess",{name:y.name,target:Nn(y.targetCli)}))}catch(q){C(ps(q))}finally{g(null)}}}async function D(y){if(!i)return;const q=y.bindings.filter(le=>le.enabled).map(le=>le.targetCli);if(q.length===0){C(r("settings.skillSyncTargetMissing"));return}g(Bo(y.skill.id)),C(null),H(null);try{await zd({skillId:y.skill.id,targetCli:q}),await ue(),H(r("settings.skillSyncSuccess",{name:y.skill.name}))}catch(le){C(ps(le))}finally{g(null)}}async function v(y){var le;const q=((le=y.target.files)==null?void 0:le[0])??null;if(y.target.value="",!!q){C(null),H(null);try{const O=await du(q),We=bl(q.name,O);Y(We),E(qs(V))}catch(O){C(ps(O))}}}async function S(){const y=Lo({sourceMode:R,fileDraft:_,pastedMarkdown:j});if(!i)return;if(!y){C(R==="paste"?r("settings.skillPasteEmpty"):r("settings.skillUploadEmpty"));return}const q=y.directoryName;if(!q){C(r("settings.skillUploadDirectoryInvalid"));return}const le=Pi(V).filter(O=>ee[O]).map(O=>O);if(le.length===0){C(r("settings.skillUploadTargetRequired"));return}g("upload"),C(null),H(null);try{await Gd({markdownContent:y.rawContent,scope:V,fileName:y.fileName,directoryName:q,targetCli:le}),await ue(),H(r("settings.skillUploadSuccess",{name:q})),ae(V),P(!1)}catch(O){C(ps(O))}finally{g(null)}}function J(y){G(y),E(qs(y))}function ke(y){K(y),Y(null),Z(""),E(qs(V)),C(null)}function we(y){E(q=>({...q,[y]:!q[y]}))}function se(){P(!0),C(null)}function oe(){P(!1),C(null),ae(V)}function ae(y){Y(null),Z(""),K("file"),E(qs(y))}const he=(c==null?void 0:c.summary)??{managedSkillCount:0,managedEntryCount:0},be=au((c==null?void 0:c.assistantRuntimeSkills)??[],(c==null?void 0:c.conflictedEntries)??[],(c==null?void 0:c.diagnostics)??[]),me=((c==null?void 0:c.conflictedEntries)??[]).filter(y=>!pl(y,(c==null?void 0:c.diagnostics)??[])),Ge=((c==null?void 0:c.diagnostics)??[]).filter(y=>!sr(y)),Ee=Lo({sourceMode:R,fileDraft:_,pastedMarkdown:j}),F=n??r("settings.skillManageAction");return t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:e,type:"button","data-open":U?"true":"false","aria-haspopup":"dialog","aria-expanded":U,onClick:()=>{A(!0)},children:[s,t.jsx("span",{children:F})]}),t.jsxs(Ue,{open:U,title:r("settings.skillConfigModalTitle"),description:r("settings.skillConfigModalDescription"),className:"settings-skill-modal",headerActions:t.jsxs("div",{className:"settings-skill-modal-actions",children:[t.jsx("button",{className:"secondary-button",type:"button",disabled:!i||f||p!==null,onClick:se,children:r("settings.skillCreateAction")}),t.jsx("button",{className:"secondary-button",type:"button",disabled:!i||f||p!==null,onClick:()=>{$()},children:p==="refresh"?r("common.loading"):r("settings.skillRefresh")})]}),onClose:()=>A(!1),children:[t.jsxs("section",{className:"settings-skill-summary-block",children:[t.jsxs("div",{className:"settings-skill-summary-grid",children:[t.jsx(Pr,{label:r("settings.skillSummaryManagedSkills"),value:String(he.managedSkillCount)}),t.jsx(Pr,{label:r("settings.skillSummaryManagedEntries"),value:String(he.managedEntryCount)}),t.jsx(Pr,{label:r("settings.skillSummaryConflictedEntries"),value:String(me.length)}),t.jsx(Pr,{label:r("settings.skillSummaryDiagnostics"),value:String(Ge.length)})]}),t.jsx("div",{className:"settings-release-meta",children:t.jsxs("span",{children:[r("settings.skillScannedAt"),": ",f?r("common.loading"):ou(c==null?void 0:c.scannedAt)]})}),I?t.jsx("p",{className:"settings-release-status",children:I}):null,N?t.jsx("p",{className:"settings-release-status",children:N}):null]}),t.jsx($s,{title:r("settings.skillManagedListTitle"),emptyText:r("settings.skillManagedEmpty"),items:(c==null?void 0:c.managedSkills)??[],renderItem:y=>{const q=Bo(y.skill.id);return t.jsxs("div",{className:"settings-skill-entry",children:[t.jsxs("div",{className:"settings-skill-entry-main",children:[t.jsx("strong",{className:"settings-skill-entry-title",children:y.skill.name}),t.jsx("p",{className:"settings-skill-entry-meta",children:nu(y.bindings)}),t.jsx("div",{className:"settings-skill-tags",children:y.bindings.map(le=>t.jsxs("span",{className:"settings-skill-tag","data-status":le.syncStatus,children:[Nn(le.targetCli)," · ",tu(le.syncStatus)]},`${y.skill.id}-${le.targetCli}`))})]}),t.jsx("div",{className:"settings-skill-entry-actions",children:t.jsx("button",{className:"secondary-button",type:"button",disabled:f||p!==null,onClick:()=>{D(y)},children:p===q?r("common.loading"):r("settings.skillSyncAction")})})]},y.skill.id)}}),t.jsx($s,{title:r("settings.skillUnmanagedListTitle"),emptyText:r("settings.skillUnmanagedEmpty"),items:(c==null?void 0:c.unmanagedEntries)??[],renderItem:y=>{const q=Po(y);return t.jsxs("div",{className:"settings-skill-entry",children:[t.jsxs("div",{className:"settings-skill-entry-main",children:[t.jsx("strong",{className:"settings-skill-entry-title",children:y.name}),t.jsx("p",{className:"settings-skill-entry-meta",children:su(y)})]}),t.jsx("div",{className:"settings-skill-entry-actions",children:t.jsx("button",{className:"secondary-button",type:"button",disabled:f||p!==null,onClick:()=>{ce(y)},children:p===q?r("common.loading"):r("settings.skillImportAction")})})]},`${y.targetCli}:${y.directoryPath}`)}}),t.jsx($s,{title:r("settings.skillAssistantRuntimeListTitle"),description:r("settings.skillAssistantRuntimeListDescription"),emptyText:r("settings.skillAssistantRuntimeEmpty"),items:be,renderItem:y=>t.jsx("div",{className:"settings-skill-entry",children:t.jsxs("div",{className:"settings-skill-entry-main",children:[t.jsx("strong",{className:"settings-skill-entry-title",children:y.name}),t.jsx("p",{className:"settings-skill-entry-meta",children:r("settings.skillAssistantRuntimeItemDescription")}),t.jsxs("p",{className:"settings-skill-entry-meta",children:[r("settings.skillAssistantRuntimeUsedBy"),": ",ml(y.usedByTargetCli)]}),t.jsxs("div",{className:"settings-skill-tags",children:[t.jsx("span",{className:"settings-skill-tag","data-status":"assistant-runtime",children:r("settings.skillTagAssistantOnly")}),y.usedByTargetCli.map(q=>t.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:Nn(q)},`${y.directoryName}:${q}`))]})]})},`${y.directoryName}:${y.sourcePath}`)}),t.jsx($s,{title:r("settings.skillConflictedListTitle"),emptyText:r("settings.skillConflictedEmpty"),items:me,renderItem:y=>{const q=lu(y,(c==null?void 0:c.diagnostics)??[]);return t.jsx("div",{className:"settings-skill-entry",children:t.jsxs("div",{className:"settings-skill-entry-main",children:[t.jsx("strong",{className:"settings-skill-entry-title",children:y.name}),t.jsx("p",{className:"settings-skill-entry-meta",children:ru(y)}),q.length>0?t.jsx("div",{className:"settings-skill-tags",children:q.map(le=>t.jsx("span",{className:"settings-skill-tag","data-status":le.status,children:le.label},le.key))}):null]})},`${y.targetCli}:${y.directoryPath}`)}}),t.jsx($s,{title:r("settings.skillDiagnosticsTitle"),emptyText:r("settings.skillDiagnosticsEmpty"),items:Ge,renderItem:y=>{const q=cu(y),le=iu(y);return t.jsx("div",{className:"settings-skill-entry",children:t.jsxs("div",{className:"settings-skill-entry-main",children:[t.jsx("strong",{className:"settings-skill-entry-title",children:le.title}),t.jsx("p",{className:"settings-skill-entry-meta",children:le.detail}),q.length>0?t.jsx("div",{className:"settings-skill-tags",children:q.map(O=>t.jsx("span",{className:"settings-skill-tag","data-status":O.status,children:O.label},O.key))}):null]})},`${y.targetCli}:${y.code}:${y.directoryPath??y.rootDir}`)}})]}),t.jsx(Ue,{open:x,title:r("settings.skillCreateModalTitle"),description:r("settings.skillCreateModalDescription"),className:"settings-skill-create-modal",onClose:oe,children:t.jsxs("section",{className:"settings-skill-section",children:[t.jsx("h3",{className:"settings-skill-section-title",children:r("settings.skillUploadSectionTitle")}),t.jsx("p",{className:"settings-skill-section-description",children:r("settings.skillUploadSectionDescription")}),t.jsxs("div",{className:"settings-skill-create-panel",children:[t.jsx("input",{ref:o,type:"file",accept:".md,text/markdown,text/plain",className:"settings-skill-upload-input",onChange:y=>{v(y)}}),t.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":r("settings.skillCreateSourceTabsLabel"),children:Zd.map(y=>{const q=R===y;return t.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":q,"data-active":q?"true":"false",onClick:()=>ke(y),children:eu(y)},y)})}),t.jsx("div",{className:"settings-skill-upload-targets",role:"radiogroup","aria-label":r("settings.skillUploadScopeLabel"),children:Jd.map(y=>t.jsxs("label",{className:"settings-skill-upload-target","data-selected":V===y?"true":"false",children:[t.jsx("input",{type:"radio",name:"skill-upload-scope",checked:V===y,onChange:()=>J(y)}),t.jsx("span",{children:Qd(y)})]},y))}),R==="file"?t.jsx("div",{className:"settings-skill-create-toolbar",children:t.jsx("button",{className:"secondary-button",type:"button",disabled:f||p!==null,onClick:()=>{var y;(y=o.current)==null||y.click()},children:r("settings.skillUploadPickAction")})}):t.jsxs("label",{className:"settings-skill-upload-field",children:[t.jsx("span",{children:r("settings.skillPasteLabel")}),t.jsx("textarea",{className:"settings-skill-create-textarea",value:j,onChange:y=>Z(y.target.value),placeholder:r("settings.skillPastePlaceholder")})]}),Ee?t.jsx("div",{className:"settings-skill-entry",children:t.jsxs("div",{className:"settings-skill-entry-main",children:[t.jsx("strong",{className:"settings-skill-entry-title",children:Ee.previewTitle}),t.jsxs("p",{className:"settings-skill-entry-meta",children:[r("settings.skillUploadPickedFile"),": ",Ee.fileName]})]})}):t.jsx("div",{className:"settings-skill-empty",children:R==="paste"?r("settings.skillPasteEmpty"):r("settings.skillUploadEmpty")}),t.jsxs("div",{className:"settings-skill-upload-field",children:[t.jsx("span",{children:r("settings.skillUploadTargetsLabel")}),t.jsx("div",{className:"settings-skill-upload-targets",children:Pi(V).map(y=>t.jsxs("label",{className:"settings-skill-upload-target","data-selected":ee[y]?"true":"false",children:[t.jsx("input",{type:"checkbox",checked:ee[y],onChange:()=>we(y)}),t.jsx("span",{children:Nn(y)})]},y))})]}),Ee!=null&&Ee.notes.length?t.jsx("div",{className:"settings-skill-tags",children:Ee.notes.map((y,q)=>t.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:y},`${Ee.fileName}:${q}`))}):null,N?t.jsx("p",{className:"settings-release-status",children:N}):null,t.jsx("div",{className:"settings-skill-create-actions",children:t.jsx("button",{className:"primary-button",type:"button",disabled:f||p!==null,onClick:()=>{S()},children:p==="upload"?r("common.loading"):r("settings.skillCreateSubmitAction")})})]})]})})]})}function $s({title:e,description:n,emptyText:s,items:i,renderItem:o}){return t.jsxs("section",{className:"settings-skill-section",children:[t.jsx("h3",{className:"settings-skill-section-title",children:e}),n?t.jsx("p",{className:"settings-skill-section-description",children:n}):null,i.length>0?t.jsx("div",{className:"settings-skill-entry-list",children:i.map(c=>o(c))}):t.jsx("div",{className:"settings-skill-empty",children:s})]})}function Pr({label:e,value:n}){return t.jsxs("div",{className:"settings-skill-summary-card",children:[t.jsx("span",{children:e}),t.jsx("strong",{children:n})]})}function Po(e){return`import:${e.targetCli}:${e.directoryPath}`}function Bo(e){return`sync:${e}`}const Xd=["codex","claude-code","gemini","opencode"],Yd=["codex","claude-code"],Jd=["workspace","assistant"],Zd=["file","paste"];function ps(e){return e instanceof Ba?e.message||r("settings.skillLoadFailed"):e instanceof Error?e.message:r("settings.skillLoadFailed")}function Nn(e){switch(e){case"claude-code":return r("settings.skillTargetClaudeCode");case"gemini":return r("settings.skillTargetGemini");case"opencode":return r("settings.skillTargetOpenCode");default:return r("settings.skillTargetCodex")}}function Qd(e){return e==="assistant"?r("settings.skillUploadScopeAssistant"):r("settings.skillUploadScopeWorkspace")}function eu(e){return e==="paste"?r("settings.skillCreateSourcePaste"):r("settings.skillCreateSourceFile")}function qs(e){return{codex:new Set(Pi(e)).has("codex"),"claude-code":!1,gemini:!1,opencode:!1}}function Pi(e){return e==="assistant"?Yd:Xd}function Lo({sourceMode:e,fileDraft:n,pastedMarkdown:s}){return e==="file"?n:s.trim()?bl(uu(s),s):null}function tu(e){switch(e){case"conflicted":return r("settings.skillBindingConflicted");case"failed":return r("settings.skillBindingFailed");case"pending":return r("settings.skillBindingPending");default:return r("settings.skillBindingSynced")}}function ml(e){return e.map(Nn).join(" / ")}function nu(e){const n=e.filter(s=>s.enabled);return n.length===0?r("settings.skillManagedItemNoTarget"):r("settings.skillManagedItemDescription",{targets:ml(n.map(s=>s.targetCli))})}function su(e){return r("settings.skillUnmanagedItemDescription",{target:Nn(e.targetCli)})}function ru(e){return r("settings.skillConflictedItemDescription",{target:Nn(e.targetCli)})}function iu(e){const n=Nn(e.targetCli);switch(e.code){case"SKILL_TARGET_ROOT_MISSING":return{title:r("settings.skillDiagnosticTargetMissingTitle",{target:n}),detail:r("settings.skillDiagnosticTargetMissingDetail",{target:n})};case"SKILL_TARGET_ROOT_INVALID":case"SKILL_TARGET_STAT_FAILED":case"SKILL_TARGET_READ_FAILED":return{title:r("settings.skillDiagnosticReadFailedTitle",{target:n}),detail:r("settings.skillDiagnosticReadFailedDetail",{target:n})};case"SKILL_TARGET_SKILL_MISSING":return{title:r("settings.skillDiagnosticSyncMissingTitle",{target:n}),detail:r("settings.skillDiagnosticSyncMissingDetail",{target:n})};default:return{title:r("settings.skillDiagnosticGenericTitle",{target:n}),detail:r("settings.skillDiagnosticGenericDetail",{target:n})}}}function ou(e){if(!e)return"-";const n=Date.parse(e);return Number.isNaN(n)?e:new Date(n).toLocaleString()}function au(e,n,s){if(e.length>0)return e.map(o=>({name:o.name,directoryName:o.directoryName,sourcePath:o.sourcePath,usedByTargetCli:o.usedByTargetCli}));const i=new Map;for(const o of n)pl(o,s)&&i.set(Do(o.targetCli,o.directoryPath),{name:o.name,directoryName:o.directoryName,sourcePath:o.directoryPath,usedByTargetCli:[o.targetCli]});for(const o of s){if(!sr(o))continue;const c=o.directoryPath??o.rootDir,h=Do(o.targetCli,c);i.has(h)||i.set(h,{name:o.directoryName??"codingns-assistant",directoryName:o.directoryName??"codingns-assistant",sourcePath:c,usedByTargetCli:[o.targetCli]})}return[...i.values()]}function Do(e,n){return`${e}:${n}`}function pl(e,n){return n.some(s=>sr(s)&&s.targetCli===e.targetCli&&s.directoryPath===e.directoryPath&&s.directoryName===e.directoryName)}function sr(e){return e.code==="SKILL_RESERVED_FOR_ASSISTANT_RUNTIME"}function lu(e,n){return n.find(i=>sr(i)&&i.targetCli===e.targetCli&&i.directoryName===e.directoryName&&i.directoryPath===e.directoryPath)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath}`,label:r("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function cu(e){return sr(e)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath??e.rootDir}`,label:r("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function bl(e,n){const s=[],i=n.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
|
|
3
|
-
`).trim();if(!i)throw new Error(r("settings.skillUploadContentEmpty"));i!==n.trim()&&s.push(r("settings.skillUploadNormalizedNote"));const o=kl(i),c=Bi(e)??Bi(o)??"";return c||s.push(r("settings.skillUploadDirectoryRequiredNote")),o||s.push(r("settings.skillUploadHeadingNote")),{fileName:e,rawContent:i,directoryName:c,previewTitle:o||hu(c||"skill"),notes:s}}async function du(e){if(typeof e.text=="function")return await e.text();if(typeof FileReader>"u")throw new Error(r("settings.skillUploadReadFailed"));return await new Promise((n,s)=>{const i=new FileReader;i.onerror=()=>{s(i.error??new Error(r("settings.skillUploadReadFailed")))},i.onload=()=>{if(typeof i.result=="string"){n(i.result);return}s(new Error(r("settings.skillUploadReadFailed")))},i.readAsText(e)})}function Bi(e){const i=(e.replace(/\\/g,"/").split("/").pop()??e).replace(/\.[A-Za-z0-9]+$/,"").trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-._]+|[-._]+$/g,"").toLowerCase();return i.length>0?i:null}function uu(e){const n=Bi(kl(e));return n?`${n}.md`:"pasted-skill.md"}function kl(e){var n,s;return((s=(n=e.match(/^#\s+(.+)$/m))==null?void 0:n[1])==null?void 0:s.trim())??""}function hu(e){return e.split(/[._-]+/).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")||e}function ro(e){var n,s;return e.runningState==="failed"||!!((n=e.lastErrorCode)!=null&&n.trim())||!!((s=e.lastErrorDetail)!=null&&s.trim())}function fu(e,n,s){return`${e} is-${gl(n,s)}`}function gl(e,n){n==null||n.isActive;const s=bu(e);return n!=null&&n.hasSubagents?s==="error"?"error":s==="unread"?"subagent-unread":s==="running"||s==="running_inferred"?"subagent-running":"subagent":s==="running_inferred"?"running-inferred":s.replace("_","-")}function mu(e){return e.runningState==="stale"?r("conversation.runtimeStale"):e.runningState==="unknown"?r("conversation.runtimeUnknown"):null}function pu(e,n){return n.runningState==="stale"?`${e} is-stale`:n.runningState==="unknown"?`${e} is-unknown`:null}function bu(e){return ro(e)?"error":e.runningState==="stale"?"stale":e.runningState==="unknown"?"unknown":e.activityState==="running"?ku(e)?"running_inferred":"running":e.activityState==="completed_unread"?"unread":"idle"}function ku(e){return e.activityResolutionSource==="inferred_log"||e.activitySource==="inferred"}function gu(e){return io(e)!==null}function wu(e){return e.isSubagent===!0&&!gu(e)}function io(e){return e.forkMethod==="reconstructed_message_fork"||e.forkMethod==="reconstructed_session_fork"?"reconstructed":e.forkMethod==="native_message_fork"||e.forkSourceType==="message"?"message":e.forkMethod==="native_session_fork"||e.forkSourceType==="session"?"session":null}function xu(e){const n=io(e);return n==="reconstructed"?r("shell.sessionForkReconstructed"):n==="message"?r("shell.sessionForkMessage"):n==="session"?r("shell.sessionForkSession"):null}function vu(e){return e.sessionKind==="annotation"?"annotation":null}function Cm(e){return vu(e)==="annotation"?r("conversation.actionSessionBadge"):null}const _o=48;function yu(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function oo(e,n){const s=yu(e)||n,i=s.length>_o?s.slice(0,_o).trimEnd():s;return{fullTitle:s,displayTitle:i}}function Br(e,n){return(n??"").localeCompare(e??"")}function Fo(e,n){return e.localeCompare(n,void 0,{numeric:!0,sensitivity:"base"})}function Lr(e){return(e==null?void 0:e.trim())??""}function ao(e,n,s){if(s==="updatedAt"){const h=Br(e.updatedAt,n.updatedAt);if(h!==0)return h}if(s==="title"){const h=Fo(Lr(e.title),Lr(n.title));if(h!==0)return h}else{const h=Br(e.createdAt,n.createdAt);if(h!==0)return h}const i=Br(e.updatedAt,n.updatedAt);if(i!==0)return i;const o=Br(e.createdAt,n.createdAt);if(o!==0)return o;const c=Fo(Lr(e.title),Lr(n.title));return c!==0?c:e.sessionId.localeCompare(n.sessionId)}function rr(e,n){return[...e].sort((s,i)=>ao(s,i,n))}function lo(e,n){return Array.isArray(e)?e.map(s=>({...s,sessions:rr(s.sessions,n),children:lo(s.children,n)})):[]}const xi=5,vi=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function Su(e){const n=Math.round(e.ratio*1e3)/10;return`${n.toFixed(n%1===0?0:1)}%`}function ju(e,n){const s=e.reduce((f,k)=>f+k.count,0);if(s<=0)return[];const o=e.slice(0,xi).map((f,k)=>({...f,key:f.type,ratio:f.count/s,color:vi[k]??vi[0]})),c=e.slice(xi);if(c.length===0)return o;const h=c.reduce((f,k)=>f+k.count,0);return o.push({key:"other",type:n,count:h,ratio:h/s,color:vi[xi]}),o}function Nu(e){if(e.length===0)return"conic-gradient(color-mix(in srgb, var(--border-primary) 78%, transparent) 0% 100%)";let n=0;return`conic-gradient(${e.map((i,o)=>{const c=n,h=o===e.length-1?1:Math.min(1,n+i.ratio);return n=h,`${i.color} ${Oo(c)} ${Oo(h)}`}).join(", ")})`}function Cu(e){return{"--workbench-manage-chart-background":Nu(e)}}function Oo(e){const n=Math.round(e*1e3)/10;return`${n.toFixed(n%1===0?0:1)}%`}const Tu=8,Iu=12,Ru=160,Ho=96;function Mu(e,n,s,i={}){const o=i.gapPx??Tu,c=i.viewportMarginPx??Iu,h=i.defaultWidthPx??Ru,f=i.estimatedHeightPx??Ho,k=i.minHeightPx??Ho,p=Math.max(0,s.width),g=Math.max(0,s.height),N=Math.max(0,g-c*2),C=Math.max(0,p-c*2),I=Dr(Math.max(n.width||h,h),0,C),H=Math.max(n.height||f,f),U=Math.max(0,p-e.x-c),A=Math.max(0,e.x-c),x=U<I&&A>U,P=Math.max(0,g-e.y-o-c),_=Math.max(0,e.y-o-c),Y=P<H&&_>P,K=Dr(Math.max(Y?_:P,k),0,N),V=Math.min(H,K),G=x?e.x-I:e.x,j=Math.max(c,p-c-I),Z=Y?e.y-o-V:e.y+o,ee=Math.max(c,g-c-V),E=Dr(G,c,j),ue=Dr(Z,c,ee),$=x||E<e.x?"right":"left";return{top:ue,left:E,width:I,maxHeight:Math.max(0,K),transformOrigin:`${Y?"bottom":"top"} ${$}`}}function Dr(e,n,s){return!Number.isFinite(e)||s<n?n:Math.min(Math.max(e,n),s)}const wl="workbench.navigation.snapshot",xl=1800*1e3,Eu="workbench.navigation.snapshot.host.";function vl(e){return`${Eu}${e}`}function Wu(e=xl,n=Qr(nn.getState())){if(n){const s=Jr(vl(n),e);if(s)return s}return Jr(wl,e)}function _r(e,n=Qr(nn.getState())){Ys(wl,e),n&&Ys(vl(n),e)}function Uo(e,n="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(s=>({workspace:s.workspace,sessions:rr(s.sessions,n),childWorktrees:Au(s.childWorktrees,n)}))}function Au(e,n){return lo(e,n)}function co(e){return{workspaceId:e.id,tone:"root",backgroundColor:e.backgroundColor??null,displayName:e.name,workspaceName:e.name,branchName:null,depth:0,rootWorkspaceId:e.id,rootDisplayName:e.name,parentWorkspaceId:null,parentDisplayName:null}}function Pu(e){const n=new Map;for(const s of e)n.set(s.workspace.id,co(s.workspace)),yl(n,s.childWorktrees??[],s.workspace,s.workspace);return Object.fromEntries(n)}function tn(e){if(e!=null&&e.backgroundColor)return{"--workspace-tone-color":e.backgroundColor}}function yl(e,n,s,i,o=i.name){var c;for(const h of n){const f=((c=h.meta.displayName)==null?void 0:c.trim())||h.workspace.name;e.set(h.workspace.id,{workspaceId:h.workspace.id,tone:"worktree",backgroundColor:h.workspace.backgroundColor??null,displayName:f,workspaceName:h.workspace.name,branchName:h.meta.branchName||null,depth:h.meta.depth,rootWorkspaceId:s.id,rootDisplayName:s.name,parentWorkspaceId:h.meta.parentWorkspaceId||i.id,parentDisplayName:o}),yl(e,h.children,s,h.workspace,f)}}const Bu="X-CodingNS-Assistant-Source",Lu="butler-ui",yi=new Map;async function sn(e,n={},s={}){const i=new Headers(n.headers);i.set(Bu,Lu);const o=Du();if(yi.get(o)===!1){if(s.unsupportedFallback!==void 0)return $o(s.unsupportedFallback);throw qo()}try{const h=await Q.request(e,{...n,headers:i});return yi.set(o,!0),h}catch(h){if(!_u(h))throw h;if(yi.set(o,!1),s.unsupportedFallback!==void 0)return $o(s.unsupportedFallback);throw qo()}}function Du(){return Aa()}function $o(e){return typeof e=="function"?e():e}function _u(e){return e instanceof Ba&&(e.status===404||e.status===405||e.status===501)}function qo(){return new Error("当前 Host 版本不支持新版助手接口,请先升级 Host。")}function Fu(){return Q.request("/api/butler/profile")}function Tm(e){return Q.request("/api/butler/profile/init",{method:"POST",body:JSON.stringify(e)})}function Im(e){return Q.request("/api/butler/profile",{method:"PATCH",body:JSON.stringify(e)})}function Rm(){return Q.request("/api/butler/control-session")}function Mm(){return Q.request("/api/butler/control-sessions")}function Em(e){return Q.request(`/api/butler/control-sessions/${encodeURIComponent(e)}`)}function Wm(e={}){var o;const n=new URLSearchParams;e.status&&n.set("status",e.status),(o=e.controlSessionId)!=null&&o.trim()&&n.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&n.set("limit",String(e.limit));const s=n.toString(),i=s?`/api/butler/control-timers?${s}`:"/api/butler/control-timers";return Q.request(i)}function Am(){return Q.request("/api/butler/control-session/reset",{method:"POST"})}function Pm(e={}){return Q.request("/api/butler/control-session/start",{method:"POST",body:JSON.stringify(e)})}function Bm(e){return Q.request("/api/butler/control-session/messages",{method:"POST",body:JSON.stringify(e)})}function Lm(e={}){var o;const n=new URLSearchParams;e.status&&n.set("status",e.status),(o=e.controlSessionId)!=null&&o.trim()&&n.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&n.set("limit",String(e.limit));const s=n.toString(),i=s?`/api/assistant/automations?${s}`:"/api/assistant/automations";return sn(i,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function Dm(e={}){var o;const n=new URLSearchParams;(o=e.controlSessionId)!=null&&o.trim()&&n.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&n.set("limit",String(e.limit));const s=n.toString(),i=s?`/api/assistant/automations/runs/recent?${s}`:"/api/assistant/automations/runs/recent";return sn(i,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function _m(e){return sn(`/api/assistant/automations/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function Fm(e,n){return sn(`/api/assistant/automations/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(n)})}function Om(e){return sn(`/api/assistant/automations/${encodeURIComponent(e)}/skip-wait`,{method:"POST",body:JSON.stringify({})})}function Hm(e={}){var o;const n=new URLSearchParams;e.status&&n.set("status",e.status),(o=e.controlSessionId)!=null&&o.trim()&&n.set("controlSessionId",e.controlSessionId.trim());const s=n.toString(),i=s?`/api/assistant/sandboxes?${s}`:"/api/assistant/sandboxes";return sn(i,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function Um(e){return sn(`/api/assistant/sandboxes/${encodeURIComponent(e.sandboxId)}/promote`,{method:"POST",body:JSON.stringify({mode:e.mode,projectName:e.projectName,defaultProvider:e.defaultProvider})})}function $m(e){return sn(`/api/assistant/sandboxes/${encodeURIComponent(e)}/expire`,{method:"POST",body:JSON.stringify({})})}function qm(e){return sn(`/api/assistant/sandboxes/${encodeURIComponent(e)}`,{method:"DELETE"})}function Gm(e){return Q.request(`/api/butler/control-timers/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function Km(){return Q.request("/api/butler/control-session/events")}function Ou(){return Q.request("/api/butler/overview")}function Hu(e={}){var o;const n=new URLSearchParams;(o=e.workspaceId)!=null&&o.trim()&&n.set("workspaceId",e.workspaceId.trim()),e.status&&n.set("status",e.status),e.riskLevel&&n.set("riskLevel",e.riskLevel);const s=n.toString(),i=s?`/api/butler/projects?${s}`:"/api/butler/projects";return Q.request(i)}function zm(e,n={}){const s=new URLSearchParams;n.enabled!==null&&n.enabled!==void 0&&s.set("enabled",String(n.enabled)),n.executionMode&&s.set("executionMode",n.executionMode);const i=s.toString(),o=i?`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans?${i}`:`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans`;return Q.request(o)}function Sl(e={}){var o,c;const n=new URLSearchParams;(o=e.workspaceId)!=null&&o.trim()&&n.set("workspaceId",e.workspaceId.trim()),(c=e.projectId)!=null&&c.trim()&&n.set("projectId",e.projectId.trim()),e.status&&n.set("status",e.status),e.itemType&&n.set("itemType",e.itemType);const s=n.toString(),i=s?`/api/butler/inbox?${s}`:"/api/butler/inbox";return Q.request(i)}function Uu(e){return Q.request("/api/butler/inbox",{method:"POST",body:JSON.stringify(e)})}function $u(e={}){var o,c;const n=new URLSearchParams;e.status&&n.set("status",e.status),(o=e.projectId)!=null&&o.trim()&&n.set("projectId",e.projectId.trim()),(c=e.sessionId)!=null&&c.trim()&&n.set("sessionId",e.sessionId.trim());const s=n.toString(),i=s?`/api/butler/follow-up-tasks?${s}`:"/api/butler/follow-up-tasks";return Q.request(i)}function Vm(e){return Q.request("/api/butler/follow-up-tasks",{method:"POST",body:JSON.stringify(e)})}function Xm(e){return Q.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}`)}function Ym(e){return Q.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}/cancel`,{method:"POST"})}function Jm(e,n){return Q.request(`/api/butler/projects/${encodeURIComponent(e)}/verifications/${encodeURIComponent(n)}/cancel`,{method:"POST"})}function Go(e,n){return Q.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({projectId:n.projectId,itemType:n.itemType,title:n.title,content:n.content,priority:n.priority,status:n.status})})}function Zm(e){return Q.request(`/api/butler/inbox/${encodeURIComponent(e)}/analyze`,{method:"POST",body:JSON.stringify({})})}function Qm(e){return Q.request(`/api/butler/inbox/${encodeURIComponent(e)}/start-session`,{method:"POST",body:JSON.stringify({})})}function qu(e){return Q.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"DELETE"})}function Gu(){return Q.request("/api/butler/notifications/archives")}function Ku(e,n){return Q.request(`/api/butler/notifications/archives/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({archived:n})})}function zu(e){const n=new URLSearchParams;return n.set("sessionId",e),Q.request(`/api/butler/session-target?${n.toString()}`)}function ep(e){const n=new URLSearchParams;return n.set("sessionId",e),Q.request(`/api/butler/session-action-context?${n.toString()}`)}function tp(e){return Q.request("/api/butler/actions/start-verification",{method:"POST",body:JSON.stringify(e)})}class Li extends Error{constructor(n,s){super(s),this.code=n,this.name="HostSwitchError"}}class Vu{constructor(){ge(this,"inFlight",null)}async switchHost(n){this.inFlight&&await this.inFlight;const s=this.performSwitch(n).finally(()=>{this.inFlight===s&&(this.inFlight=null)});this.inFlight=s,await s}async performSwitch(n){const s=nn.getState();if(Qr(s)===n)return;const i=ic(s,n);if(!i)throw new Li("HOST_NOT_FOUND",`找不到 HOST:${n}`);if(!(await oc(i.baseUrl)).reachable)throw new Li("HOST_UNREACHABLE",`目标 HOST 不可达:${i.baseUrl}`);const c=La(i.id);if(c)try{await Zs.loginForHost(i,{username:c.username,password:c.password})}catch{}const h=nn.getState(),f=new Date().toISOString();if(Da(i)){nn.updateRuntime({discoveredHosts:h.discoveredHosts.map(k=>k.id===n?{...k,lastConnectedAt:f,updatedAt:f}:k),activeDiscoveredHostId:n});return}Mi.setActiveDiscoveredHost(null),await nn.update({hosts:h.hosts.map(k=>k.id===n?{...k,lastConnectedAt:f,updatedAt:f}:k),activeHostId:n})}}const Xu=new Vu;function Yu({open:e,id:n,role:s="dialog",labelledBy:i,className:o,anchorRef:c,popoverRef:h,children:f,maxWidth:k=360,gap:p=10,viewportPadding:g=16}){const[N,C]=l.useState(null);if(l.useEffect(()=>{if(!e||typeof window>"u"||typeof document>"u"){C(null);return}let H=0;const U=()=>{const x=c.current;if(!x)return;const P=x.getBoundingClientRect(),_=Math.max(180,Math.min(k,window.innerWidth-g*2)),Y=Math.min(Math.max(g,P.right-_),Math.max(g,window.innerWidth-g-_)),R=P.top>=Math.min(240,window.innerHeight*.42),K=Math.round(R?P.top-p:P.bottom+p);C({top:K,left:Math.round(Y),width:_,placeAbove:R})},A=()=>{window.cancelAnimationFrame(H),H=window.requestAnimationFrame(U)};return U(),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),()=>{window.cancelAnimationFrame(H),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[c,p,k,e,g]),!e||!N||typeof document>"u")return null;const I={position:"fixed",top:N.top,left:N.left,width:N.width,maxWidth:`calc(100vw - ${g*2}px)`,zIndex:9999,transform:N.placeAbove?"translateY(-100%)":void 0};return tr.createPortal(t.jsx("div",{id:n,ref:h,role:s,"aria-labelledby":i,className:o,"data-placement":N.placeAbove?"top":"bottom",style:I,children:f}),document.body)}const Si={status:"idle",latencyMs:null};function jl({collapsed:e=!1}){const[n,s]=l.useState(!1),[i,o]=l.useState(!1),[c,h]=l.useState(""),[f,k]=l.useState(""),[p,g]=l.useState(""),[N,C]=l.useState(""),[I,H]=l.useState(null),[U,A]=l.useState(null),[x,P]=l.useState(null),[_,Y]=l.useState(!1),[R,K]=l.useState(Si),[V,G]=l.useState(null),j=l.useRef(null),Z=l.useRef(null),ee=l.useRef(null),E=l.useRef(null),ue=Hi(F=>F),$=Pa(F=>F.session),{showToast:ce}=Xn(),D=_a(ue),v=Qr(ue),S=fc(),J=ac(v),ke=l.useMemo(()=>Ko(ue.hosts,v),[v,ue.hosts]),we=l.useMemo(()=>Ko(Fa(ue),v),[v,ue]),se=l.useCallback(()=>{if(typeof window>"u")return;const F=j.current;if(!F)return;const y=F.getBoundingClientRect(),q=window.innerWidth,le=window.innerHeight,O=16,We=8,De=Math.min(320,Math.max(240,q-O*2)),Wt=Math.min(e?Math.max(O,y.right+We):Math.max(O,y.left),Math.max(O,q-De-O)),Je=i?440:240,gt=e?y.top:y.bottom+We,_e=Math.min(Math.max(O,gt),Math.max(O,le-Je-O));G({position:"fixed",top:_e,left:Wt,width:De,maxWidth:q-O*2})},[e,i]);l.useEffect(()=>{if(!n){G(null),Y(!1),K(Si);return}Mi.refresh();function F(q){var le,O,We;q.target instanceof Node&&!((le=j.current)!=null&&le.contains(q.target))&&!((O=Z.current)!=null&&O.contains(q.target))&&!((We=E.current)!=null&&We.contains(q.target))&&(s(!1),o(!1),Y(!1),P(null))}function y(q){q.key==="Escape"&&(s(!1),o(!1),Y(!1),P(null))}return window.addEventListener("pointerdown",F),window.addEventListener("keydown",y),window.addEventListener("resize",se),window.addEventListener("scroll",se,!0),se(),()=>{window.removeEventListener("pointerdown",F),window.removeEventListener("keydown",y),window.removeEventListener("resize",se),window.removeEventListener("scroll",se,!0)}},[n,se]),l.useEffect(()=>{if(!_||!n||(S==null?void 0:S.kind)!=="relay"){K(Si);return}let F=!1;const y=performance.now();return K({status:"probing",latencyMs:null}),Q.request("/api/client/runtime-config").then(()=>{F||K({status:"ready",latencyMs:performance.now()-y})}).catch(()=>{F||K({status:"error",latencyMs:null})}),()=>{F=!0}},[S==null?void 0:S.kind,_,n]);async function oe(F){if(I||U||F.id===v){s(!1);return}H(F.id);try{await Xu.switchHost(F.id),s(!1),o(!1),Y(!1),P(null)}catch(y){ce({title:eh(y,F.name),tone:"error"})}finally{H(null)}}async function ae(F){if(!(F.id===v||I||U)){if(x!==F.id){P(F.id);return}A(F.id);try{await nn.update({hosts:ue.hosts.filter(y=>y.id!==F.id)}),lc(F.id),Zs.clearHostSession(F.id),P(null),ce({title:r("shell.hostDeleteSuccess",{name:F.name})})}catch{ce({title:r("shell.hostDeleteFailed",{name:F.name}),tone:"error"})}finally{A(null)}}}async function he(){const F=p.trim();if((F.length>0||N.length>0)&&(!F||!N)){ce({title:r("shell.hostAddIncompleteCredentials"),tone:"error"});return}let q;try{q=cc(f)}catch{ce({title:r("shell.hostAddInvalidUrl"),tone:"error"});return}if(ue.hosts.some(We=>We.baseUrl===q)){ce({title:r("shell.hostAddDuplicate"),tone:"error"});return}const le=new Date().toISOString(),O={id:Qu(),name:c.trim()||Ju(q),baseUrl:q,kind:Zu(q),createdAt:le,updatedAt:le,lastConnectedAt:null,lastUserId:null,lastUsername:null};try{const We=Da(D)&&D.baseUrl===q;We&&Mi.setActiveDiscoveredHost(null),await nn.update({hosts:[...ue.hosts,O],activeHostId:We?O.id:ue.activeHostId}),F&&N&&dc({hostId:O.id,username:F,password:N}),be(),o(!1),P(null),ce({title:r("shell.hostAddSuccess",{name:O.name})})}catch{ce({title:r("shell.hostAddFailed"),tone:"error"})}}function be(){h(""),k(""),g(""),C("")}if(!D)return null;const me=$!=null&&$.user.username?`${D.baseUrl} · ${$.user.username}`:D.baseUrl,Ge=(S==null?void 0:S.kind)==="relay"?r("shell.hostSwitcherDetailStatusRelay"):r("shell.hostSwitcherDetailStatusDirect"),Ee=S?r(mc(S.kind)):r("common.unknown");return t.jsxs("div",{ref:j,className:"workbench-host-switcher-anchor","data-collapsed":e,children:[t.jsx("button",{type:"button",className:e?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":r("shell.hostSwitcherAriaLabel"),title:me,"aria-expanded":n,onClick:()=>{s(F=>!F),o(!1)},children:t.jsx(sh,{})}),n&&V&&typeof document<"u"?tr.createPortal(t.jsxs("div",{ref:Z,className:"workbench-host-switcher-menu",style:V,role:"menu","aria-label":r("shell.hostSwitcherTitle"),children:[t.jsx("div",{className:"workbench-host-switcher-menu-header",children:t.jsx("strong",{children:r("shell.hostSwitcherTitle")})}),t.jsxs("div",{className:"workbench-host-switcher-list",children:[t.jsx("div",{className:"workbench-host-switcher-section-label",children:r("shell.hostSwitcherSavedSection")}),ke.map(F=>{const y=F.id===v,q=y?($==null?void 0:$.user.username)??F.lastUsername??F.baseUrl:F.lastUsername??F.baseUrl;return t.jsxs("div",{className:"workbench-host-switcher-item","data-active":y,children:[t.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:I!==null||U!==null,onClick:()=>{oe(F)},children:[t.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[t.jsxs("span",{className:"workbench-host-switcher-item-title",children:[F.name,y?t.jsx("span",{className:"workbench-host-switcher-item-badge",children:r("shell.hostSwitcherCurrentBadge")}):null]}),t.jsx("span",{className:"workbench-host-switcher-item-meta",children:q})]}),t.jsx("span",{className:"workbench-host-switcher-item-trailing",children:I===F.id?r("shell.hostSwitcherSwitching"):y?t.jsx(Vo,{}):t.jsx(zo,{})})]}),y?t.jsx("button",{ref:ee,type:"button",className:"workbench-host-switcher-item-action","aria-label":r("shell.hostSwitcherDetailAriaLabel",{name:F.name}),"aria-expanded":_,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{Y(le=>!le),P(null)},children:r("shell.hostSwitcherDetailAction")}):t.jsx("button",{type:"button",className:"workbench-host-switcher-item-action","aria-label":r("shell.hostDeleteAriaLabel",{name:F.name}),title:x===F.id?r("shell.hostDeleteConfirmAction"):r("shell.hostDeleteAction"),"data-confirming":x===F.id,disabled:I!==null||U!==null,onClick:()=>{ae(F)},children:U===F.id?r("shell.hostDeleteBusy"):x===F.id?r("shell.hostDeleteConfirmAction"):t.jsx(ih,{})})]},F.id)}),we.length>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"workbench-host-switcher-section-label",children:r("shell.hostSwitcherDiscoveredSection")}),we.map(F=>{const y=F.id===v,q=La(F.id),le=y?($==null?void 0:$.user.username)??(q==null?void 0:q.username)??F.baseUrl:(q==null?void 0:q.username)??F.baseUrl;return t.jsxs("div",{className:"workbench-host-switcher-item","data-active":y,"data-discovered":"true",children:[t.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:I!==null||U!==null,onClick:()=>{oe(F)},children:[t.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[t.jsxs("span",{className:"workbench-host-switcher-item-title",children:[F.name,t.jsx("span",{className:"workbench-host-switcher-item-badge","data-tone":"discovered",children:r("shell.hostSwitcherDiscoveredBadge")}),y?t.jsx("span",{className:"workbench-host-switcher-item-badge",children:r("shell.hostSwitcherCurrentBadge")}):null]}),t.jsx("span",{className:"workbench-host-switcher-item-meta",children:le})]}),t.jsx("span",{className:"workbench-host-switcher-item-trailing",children:I===F.id?r("shell.hostSwitcherSwitching"):y?t.jsx(Vo,{}):t.jsx(zo,{})})]}),y?t.jsx("button",{ref:ee,type:"button",className:"workbench-host-switcher-item-action","aria-label":r("shell.hostSwitcherDetailAriaLabel",{name:F.name}),"aria-expanded":_,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{Y(O=>!O),P(null)},children:r("shell.hostSwitcherDetailAction")}):null]},F.id)})]}):null,ue.localHostDiscovery.status==="refreshing"?t.jsx("div",{className:"workbench-host-switcher-state-row",children:r("shell.hostDiscoveryRefreshing")}):null,ue.localHostDiscovery.status==="failed"?t.jsx("div",{className:"workbench-host-switcher-state-row","data-tone":"error",children:r("shell.hostDiscoveryFailed")}):null]}),i?t.jsxs("div",{className:"workbench-host-switcher-form",children:[t.jsxs("label",{className:"workbench-host-switcher-field",children:[t.jsx("span",{children:r("shell.hostSwitcherNameLabel")}),t.jsx("input",{value:c,onChange:F=>h(F.target.value),placeholder:r("shell.hostSwitcherNamePlaceholder")})]}),t.jsxs("label",{className:"workbench-host-switcher-field",children:[t.jsx("span",{children:r("shell.hostSwitcherUrlLabel")}),t.jsx("input",{value:f,onChange:F=>k(F.target.value),placeholder:r("shell.hostSwitcherUrlPlaceholder")})]}),t.jsxs("label",{className:"workbench-host-switcher-field",children:[t.jsx("span",{children:r("auth.username")}),t.jsx("input",{value:p,onChange:F=>g(F.target.value),autoComplete:"username"})]}),t.jsxs("label",{className:"workbench-host-switcher-field",children:[t.jsx("span",{children:r("auth.password")}),t.jsx("input",{type:"password",value:N,onChange:F=>C(F.target.value),autoComplete:"current-password"})]}),t.jsxs("div",{className:"workbench-host-switcher-form-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{o(!1),be()},children:r("common.cancel")}),t.jsx("button",{type:"button",className:"primary-button",onClick:()=>{he()},children:r("shell.hostSwitcherSaveAction")})]})]}):t.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{o(!0),P(null)},children:[t.jsx(rh,{}),r("shell.hostSwitcherAddAction")]}),t.jsxs(Yu,{open:_&&S!==null&&ee.current!==null,className:"workbench-host-switcher-detail-popover",anchorRef:ee,popoverRef:E,labelledBy:"workbench-host-switcher-detail-title",children:[t.jsx("div",{className:"workbench-host-switcher-detail-header",children:t.jsx("strong",{id:"workbench-host-switcher-detail-title",children:r("shell.hostSwitcherDetailTitle")})}),t.jsxs("div",{className:"workbench-host-switcher-detail-grid",children:[t.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[t.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailStatusLabel")}),t.jsx("span",{className:"workbench-host-switcher-detail-value",children:Ge})]}),t.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[t.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailRouteLabel")}),t.jsx("span",{className:"workbench-host-switcher-detail-value",children:Ee})]}),t.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[t.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailAddressLabel")}),t.jsx("span",{className:"workbench-host-switcher-detail-value","data-multiline":"true",children:(S==null?void 0:S.url)??D.baseUrl})]}),(S==null?void 0:S.kind)==="relay"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[t.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailLatencyLabel")}),t.jsx("span",{className:"workbench-host-switcher-detail-value",children:th(R)})]}),t.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[t.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailTrafficLabel")}),t.jsx("span",{className:"workbench-host-switcher-detail-value",children:nh(J.totalBytes)})]})]}):null]})]})]}),document.body):null]})}function Ko(e,n){return[...e].sort((s,i)=>{if(s.id===n)return-1;if(i.id===n)return 1;const o=s.lastConnectedAt??s.updatedAt??s.createdAt;return(i.lastConnectedAt??i.updatedAt??i.createdAt).localeCompare(o)})}function Ju(e){try{const n=new URL(e),s=n.pathname==="/"?"":n.pathname.replace(/\/+$/,"");return`${n.host}${s}`}catch{return e}}function Zu(e){try{const n=new URL(e).hostname.toLowerCase();return n==="localhost"||n==="127.0.0.1"||n==="::1"||n==="[::1]"?"local":/^10\./.test(n)||/^192\.168\./.test(n)||/^172\.(1[6-9]|2\d|3[0-1])\./.test(n)?"lan":"remote"}catch{return"custom"}}function Qu(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function eh(e,n){return e instanceof Li?e.code==="HOST_UNREACHABLE"?r("shell.hostSwitchUnreachable",{name:n}):r("shell.hostSwitchMissing"):r("shell.hostSwitchFailed")}function th(e){return e.status==="probing"?r("shell.hostSwitcherDetailLatencyLoading"):e.status==="error"?r("shell.hostSwitcherDetailUnavailable"):e.status==="ready"?`${Math.max(1,Math.round(e.latencyMs))} ms`:r("shell.hostSwitcherDetailUnavailable")}function nh(e){return!Number.isFinite(e)||e<1024?`${Math.max(0,Math.round(e))} B`:e<1024**2?`${(e/1024).toFixed(1)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}function sh(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[t.jsx("rect",{x:"4",y:"4.5",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("rect",{x:"4",y:"13",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("path",{d:"M11 7.75h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),t.jsx("path",{d:"M11 16.25h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),t.jsx("circle",{cx:"7.5",cy:"7.75",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"7.5",cy:"16.25",r:"1",fill:"currentColor",stroke:"none"})]})}function zo(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function Vo(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function rh(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M8 3.5v9M3.5 8h9",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function ih(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M3.5 4.5h9M6.5 2.75h3M5 4.5v7.25a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1V4.5M6.75 6.5v4M9.25 6.5v4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.35"})})}const Fr={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function oh({open:e,onClose:n,onCloned:s}){const{showToast:i}=Xn(),[o,c]=l.useState(!1),[h,f]=l.useState(Fr),[k,p]=l.useState(!1),[g,N]=l.useState(!1),[C,I]=l.useState(null),[H,U]=l.useState(""),[A,x]=l.useState(""),[P,_]=l.useState(null),[Y,R]=l.useState([]),[K,V]=l.useState([]),G=o||g;l.useEffect(()=>{!e&&!o&&(f(Fr),p(!1),I(null))},[o,e]);const j=l.useCallback(async D=>{N(!0),I(null);try{const v=await Oa(D);U(v.currentPath),x(v.currentPath),_(v.parentPath),R(v.roots),V(v.items),f(S=>({...S,parentPath:v.currentPath}))}catch(v){U(""),_(null),V([]),I(v instanceof Error?v.message:r("shell.importBrowserBrowseFailed"))}finally{N(!1)}},[]);function Z(){o||(p(!1),I(null),f(Fr),n())}function ee(){p(!0),j(h.parentPath||void 0)}function E(){o||(p(!1),I(null))}async function ue(D){D.preventDefault(),await j(A)}function $(){f(D=>({...D,parentPath:H})),p(!1),I(null)}async function ce(D){D.preventDefault();const v=h.repositoryUrl.trim(),S=h.parentPath.trim();if(!v){i({title:r("shell.cloneRepoRequired"),tone:"error"});return}if(!S){i({title:r("shell.clonePathRequired"),tone:"error"});return}c(!0);try{const J=await pc({repositoryUrl:v,parentPath:S,directoryName:h.directoryName.trim()||void 0,name:h.name.trim()||void 0,auth:h.authMode==="none"?{mode:"none"}:h.authMode==="basic"?{mode:"basic",username:h.username.trim(),password:h.password}:{mode:"token",username:h.username.trim()||void 0,token:h.token}});await(s==null?void 0:s(J)),f(Fr),p(!1),i({title:r("shell.cloneSuccess"),description:J.path,tone:"success"}),n()}catch(J){i({title:J instanceof Error?J.message:r("shell.cloneFailed"),tone:"error"})}finally{c(!1)}}return t.jsxs(t.Fragment,{children:[t.jsx(Ue,{open:e,title:r("shell.cloneWorkspaceTitle"),description:r("shell.cloneWorkspaceHint"),onClose:Z,children:t.jsxs("form",{className:"workbench-clone-form",onSubmit:D=>void ce(D),children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneRepositoryLabel")}),t.jsx("input",{type:"text",value:h.repositoryUrl,placeholder:r("shell.cloneRepositoryPlaceholder"),onChange:D=>f(v=>({...v,repositoryUrl:D.target.value}))})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneParentPathLabel")}),t.jsxs("div",{className:"workbench-modal-inline-field",children:[t.jsx("input",{type:"text",value:h.parentPath,placeholder:r("shell.cloneParentPathPlaceholder"),onChange:D=>f(v=>({...v,parentPath:D.target.value}))}),t.jsx("button",{type:"button",className:"secondary-button",disabled:o,onClick:ee,children:r("shell.clonePickDirectory")})]})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneDirectoryNameLabel")}),t.jsx("input",{type:"text",value:h.directoryName,placeholder:r("shell.cloneDirectoryNamePlaceholder"),onChange:D=>f(v=>({...v,directoryName:D.target.value}))})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.importNameLabel")}),t.jsx("input",{type:"text",value:h.name,placeholder:r("shell.importNamePlaceholder"),onChange:D=>f(v=>({...v,name:D.target.value}))})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneAuthModeLabel")}),t.jsxs("select",{value:h.authMode,onChange:D=>f(v=>({...v,authMode:D.target.value})),children:[t.jsx("option",{value:"none",children:r("shell.cloneAuthModeNone")}),t.jsx("option",{value:"basic",children:r("shell.cloneAuthModeBasic")}),t.jsx("option",{value:"token",children:r("shell.cloneAuthModeToken")})]})]}),h.authMode==="basic"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneUsernameLabel")}),t.jsx("input",{type:"text",value:h.username,placeholder:r("shell.cloneUsernamePlaceholder"),autoComplete:"username",onChange:D=>f(v=>({...v,username:D.target.value}))})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.clonePasswordLabel")}),t.jsx("input",{type:"password",value:h.password,placeholder:r("shell.clonePasswordPlaceholder"),autoComplete:"current-password",onChange:D=>f(v=>({...v,password:D.target.value}))})]})]}):null,h.authMode==="token"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneUsernameLabel")}),t.jsx("input",{type:"text",value:h.username,placeholder:r("shell.cloneTokenUsernamePlaceholder"),onChange:D=>f(v=>({...v,username:D.target.value}))})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.cloneTokenLabel")}),t.jsx("input",{type:"password",value:h.token,placeholder:r("shell.cloneTokenPlaceholder"),onChange:D=>f(v=>({...v,token:D.target.value}))})]})]}):null,t.jsx("p",{className:"workbench-import-hint",children:r("shell.cloneHint")}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:o,onClick:Z,children:r("common.cancel")}),t.jsx("button",{type:"submit",className:"primary-button",disabled:o,children:o?r("shell.cloneSubmitting"):r("shell.cloneSubmit")})]})]})}),t.jsxs(Ue,{open:e&&k,title:r("shell.cloneBrowserTitle"),description:r("shell.cloneBrowserDescription"),onClose:E,children:[t.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ue,children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.importBrowserCurrentPath")}),t.jsx("input",{type:"text",value:A,placeholder:r("shell.importPathPlaceholder"),onChange:D=>x(D.target.value)})]}),t.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:G||!P,onClick:()=>{P&&j(P)},children:r("shell.importBrowserOpenParent")}),t.jsx("button",{type:"submit",className:"secondary-button",disabled:G,children:r("shell.importBrowserOpenPath")})]})]}),t.jsxs("section",{className:"workbench-directory-browser-panel",children:[t.jsxs("div",{className:"workbench-directory-browser-section",children:[t.jsx("span",{className:"workbench-directory-browser-section-title",children:r("shell.importBrowserRoots")}),t.jsx("div",{className:"workbench-directory-browser-root-list",children:Y.map(D=>t.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:G,onClick:()=>{j(D.path)},children:D.name},D.path))})]}),t.jsx("div",{className:"workbench-directory-browser-current-path",children:H}),C?t.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:C}):null,g?t.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("common.loading")}):K.length>0?t.jsx("div",{className:"workbench-directory-browser-list",children:K.map(D=>t.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:G,onClick:()=>{j(D.path)},children:[t.jsx("span",{className:"workbench-directory-browser-item-name",children:D.name}),t.jsx("span",{className:"workbench-directory-browser-item-path",children:D.path})]},D.path))}):t.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("shell.importBrowserEmpty")})]}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:o,onClick:E,children:r("common.cancel")}),t.jsx("button",{type:"button",className:"primary-button",disabled:G||!H,onClick:$,children:r("shell.cloneBrowserSubmit")})]})]})]})}const ah="butler:inbox-updated";function ji(){typeof window>"u"||window.dispatchEvent(new Event(ah))}const Xo={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function Nl({active:e,preferredWorkspaceId:n,preferredSessionId:s,creationRequestId:i=0,initialDraft:o=null,compactComposer:c=!1,composerOpen:h=!0,onComposerOpenChange:f}){const{showToast:k}=Xn(),[p,g]=l.useState(!1),[N,C]=l.useState(!1),[I,H]=l.useState([]),[U,A]=l.useState([]),[x,P]=l.useState(null),[_,Y]=l.useState(null),[R,K]=l.useState(Xo),[V,G]=l.useState(!1),j=l.useMemo(()=>Jo(I,n,_),[_,n,I]),Z=l.useMemo(()=>V?U:U.filter(v=>v.status!=="closed"),[U,V]);l.useEffect(()=>{e&&ee()},[e,s]),l.useEffect(()=>{!e||x||K(v=>{const S=Qo({projects:j,currentProjectId:v.projectId,preferredProjectId:_,preferredWorkspaceId:n});return S===v.projectId?v:{...v,projectId:S}})},[e,x,_,n,j]),l.useEffect(()=>{!e||i<=0||(E(void 0,n,o,_),f==null||f(!0))},[e,i,o,f,_,n]);async function ee(){g(!0);try{const[v,S,J]=await Promise.all([Hu(),Sl(),s?zu(s).catch(()=>null):Promise.resolve(null)]),ke=(J==null?void 0:J.target.project.id)??null;Y(ke),H(v.items),A(S.items),x||E(v.items,n,i>0?o:null,ke)}catch(v){k({title:r("shell.butlerInboxLoadFailed"),description:v instanceof Error?v.message:void 0,tone:"error"})}finally{g(!1)}}function E(v=I,S=n,J=o,ke=_){var se,oe;const we=Jo(v,S,ke);P(null),K({...Xo,projectId:Qo({projects:we,preferredProjectId:ke,preferredWorkspaceId:S}),title:((se=J==null?void 0:J.title)==null?void 0:se.trim())??"",content:((oe=J==null?void 0:J.content)==null?void 0:oe.trim())??""})}function ue(v){P(v.id),K({projectId:v.projectId,itemType:v.itemType,title:v.title,content:v.content,status:v.status}),c&&(f==null||f(!0))}async function $(v){v.preventDefault(),C(!0);try{x?(await Go(x,{projectId:R.projectId,itemType:R.itemType,title:R.title,content:R.content,status:R.status,priority:"medium"}),k({title:r("shell.butlerInboxUpdated"),tone:"success"})):(await Uu({projectId:R.projectId,itemType:R.itemType,title:R.title,content:R.content,status:R.status,priority:"medium"}),k({title:r("shell.butlerInboxCreated"),tone:"success"})),ji(),await ee(),E(),c&&(f==null||f(!1))}catch(S){k({title:r("shell.butlerInboxSaveFailed"),description:S instanceof Error?S.message:void 0,tone:"error"})}finally{C(!1)}}async function ce(v){C(!0);try{await qu(v),k({title:r("shell.butlerInboxDeleted"),tone:"success"}),ji(),await ee(),x===v&&E()}catch(S){k({title:r("shell.butlerInboxDeleteFailed"),description:S instanceof Error?S.message:void 0,tone:"error"})}finally{C(!1)}}async function D(v,S){if(v.status!==S){C(!0);try{await Go(v.id,{status:S}),k({title:r("shell.butlerInboxUpdated"),tone:"success"}),ji(),await ee(),x===v.id&&K(J=>({...J,status:S}))}catch(J){k({title:r("shell.butlerInboxSaveFailed"),description:J instanceof Error?J.message:void 0,tone:"error"})}finally{C(!1)}}}return t.jsxs("div",{className:"workspace-inbox-modal",children:[c?null:t.jsx("section",{className:"workspace-inbox-panel",children:t.jsx(Yo,{selectableProjects:j,formState:R,saving:N,editingItemId:x,useMobilePicker:!1,onProjectChange:v=>{K(S=>({...S,projectId:v}))},onItemTypeChange:v=>{K(S=>({...S,itemType:v}))},onStatusChange:v=>{K(S=>({...S,status:v}))},onTitleChange:v=>{K(S=>({...S,title:v}))},onContentChange:v=>{K(S=>({...S,content:v}))},onCancel:()=>E(),onSubmit:$})}),t.jsxs("section",{className:"workspace-inbox-panel",children:[t.jsxs("header",{className:"workspace-inbox-panel-header",children:[t.jsxs("div",{children:[t.jsx("h3",{children:r("shell.butlerInboxListTitle")}),t.jsx("p",{children:r("shell.butlerInboxListDescription")})]}),t.jsxs("label",{className:"workspace-inbox-closed-toggle",children:[t.jsx("input",{type:"checkbox",checked:V,onChange:v=>G(v.target.checked)}),t.jsx("span",{children:r("shell.butlerInboxShowClosedAction")})]})]}),p?t.jsx("p",{className:"workspace-inbox-status",children:r("shell.butlerInboxLoading")}):null,!p&&Z.length===0?t.jsx("p",{className:"workspace-inbox-status",children:r("shell.butlerInboxEmpty")}):null,!p&&Z.length>0?t.jsx("div",{className:"workspace-inbox-list",children:Z.map(v=>t.jsxs("article",{className:"workspace-inbox-item",children:[t.jsxs("div",{className:"workspace-inbox-item-header",children:[t.jsxs("div",{children:[t.jsx("strong",{children:v.title}),t.jsx("p",{children:v.projectName})]}),t.jsxs("div",{className:"workspace-inbox-item-badges",children:[t.jsx("span",{className:"workspace-inbox-badge",children:ea(v.status)}),t.jsx("span",{className:"workspace-inbox-badge",children:hh(v.itemType)})]})]}),t.jsx("p",{className:"workspace-inbox-item-content",children:v.content}),t.jsxs("div",{className:"workspace-inbox-item-footer",children:[t.jsx("span",{children:fh(v.updatedAt)}),t.jsxs("div",{className:"workspace-inbox-item-actions",children:[t.jsx("div",{className:"workspace-inbox-status-quick-actions",role:"group","aria-label":r("shell.butlerInboxQuickStatusLabel"),children:["pending","in_progress","closed"].map(S=>{const J=v.status===S;return t.jsx("button",{type:"button",className:"secondary-button","data-active":J,disabled:N,onClick:()=>{D(v,S)},children:ea(S)},`${v.id}:${S}`)})}),t.jsx("button",{type:"button",className:"secondary-button",disabled:N,onClick:()=>ue(v),children:r("shell.butlerInboxEditAction")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:N,onClick:()=>{ce(v.id)},children:r("shell.butlerInboxDeleteAction")})]})]})]},v.id))}):null]}),c?t.jsx(Ue,{open:e&&h,title:x?r("shell.butlerInboxEditingTitle"):r("shell.butlerInboxCreateTitle"),description:r("shell.butlerInboxFormDescription"),className:"workspace-inbox-modal-card workspace-inbox-composer-modal-card",onClose:()=>{f==null||f(!1),E()},children:t.jsx("div",{className:"workspace-inbox-composer-modal-body",children:t.jsx(Yo,{selectableProjects:j,formState:R,saving:N,editingItemId:x,useMobilePicker:!0,onProjectChange:v=>{K(S=>({...S,projectId:v}))},onItemTypeChange:v=>{K(S=>({...S,itemType:v}))},onStatusChange:v=>{K(S=>({...S,status:v}))},onTitleChange:v=>{K(S=>({...S,title:v}))},onContentChange:v=>{K(S=>({...S,content:v}))},onCancel:()=>{f==null||f(!1),E()},onSubmit:$})})}):null]})}function Yo(e){const n=e.selectableProjects.map(o=>({value:o.id,label:o.name})),s=[{value:"task",label:r("shell.butlerInboxTypeTask")},{value:"bug",label:r("shell.butlerInboxTypeBug")},{value:"feature",label:r("shell.butlerInboxTypeFeature")},{value:"change",label:r("shell.butlerInboxTypeChange")}],i=[{value:"pending",label:r("shell.butlerInboxStatusPending")},{value:"in_progress",label:r("shell.butlerInboxStatusInProgress")},{value:"closed",label:r("shell.butlerInboxStatusClosed")}];return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"workspace-inbox-panel-header",children:[t.jsx("h3",{children:e.editingItemId?r("shell.butlerInboxEditingTitle"):r("shell.butlerInboxCreateTitle")}),t.jsx("p",{children:r("shell.butlerInboxFormDescription")})]}),e.selectableProjects.length===0?t.jsx("p",{className:"workspace-inbox-status",children:r("shell.butlerInboxProjectsEmpty")}):t.jsxs("form",{className:"workspace-inbox-form",onSubmit:e.onSubmit,children:[t.jsx("div",{className:"workspace-inbox-form-grid",children:e.useMobilePicker?t.jsxs(t.Fragment,{children:[t.jsx(Ni,{label:r("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:n,disabled:e.saving,onChange:e.onProjectChange}),t.jsx(Ni,{label:r("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:s,disabled:e.saving,onChange:e.onItemTypeChange}),t.jsx(Ni,{label:r("shell.butlerInboxStatusLabel"),value:e.formState.status,options:i,disabled:e.saving,onChange:e.onStatusChange})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.butlerInboxProjectLabel")}),t.jsx("select",{value:e.formState.projectId,disabled:e.saving,onChange:o=>e.onProjectChange(o.target.value),children:e.selectableProjects.map(o=>t.jsx("option",{value:o.id,children:o.name},o.id))})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.butlerInboxTypeLabel")}),t.jsxs("select",{value:e.formState.itemType,disabled:e.saving,onChange:o=>e.onItemTypeChange(o.target.value),children:[t.jsx("option",{value:"task",children:r("shell.butlerInboxTypeTask")}),t.jsx("option",{value:"bug",children:r("shell.butlerInboxTypeBug")}),t.jsx("option",{value:"feature",children:r("shell.butlerInboxTypeFeature")}),t.jsx("option",{value:"change",children:r("shell.butlerInboxTypeChange")})]})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.butlerInboxStatusLabel")}),t.jsxs("select",{value:e.formState.status,disabled:e.saving,onChange:o=>e.onStatusChange(o.target.value),children:[t.jsx("option",{value:"pending",children:r("shell.butlerInboxStatusPending")}),t.jsx("option",{value:"in_progress",children:r("shell.butlerInboxStatusInProgress")}),t.jsx("option",{value:"closed",children:r("shell.butlerInboxStatusClosed")})]})]})]})}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.butlerInboxTitleLabel")}),t.jsx("input",{value:e.formState.title,placeholder:r("shell.butlerInboxTitlePlaceholder"),disabled:e.saving,onChange:o=>e.onTitleChange(o.target.value)})]}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.butlerInboxContentLabel")}),t.jsx("textarea",{rows:4,value:e.formState.content,placeholder:r("shell.butlerInboxContentPlaceholder"),disabled:e.saving,onChange:o=>e.onContentChange(o.target.value)})]}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onCancel,children:e.editingItemId?r("shell.butlerInboxCancelEditAction"):r("common.cancel")}),t.jsx("button",{type:"submit",className:"primary-button",disabled:e.saving||!e.formState.projectId,children:e.editingItemId?r("shell.butlerInboxUpdateAction"):r("shell.butlerInboxCreateAction")})]})]})]})}function Ni({label:e,value:n,options:s,disabled:i,onChange:o}){const[c,h]=l.useState(!1),f=s.find(k=>k.value===n)??s[0]??null;return l.useEffect(()=>{if(!c)return;function k(p){p.key==="Escape"&&h(!1)}return window.addEventListener("keydown",k),()=>{window.removeEventListener("keydown",k)}},[c]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"workbench-modal-field workspace-inbox-mobile-picker",children:[t.jsx("span",{children:e}),t.jsxs("button",{type:"button",className:"workspace-inbox-mobile-picker-trigger","aria-label":e,"aria-haspopup":"dialog","aria-expanded":c,disabled:i||s.length===0,onClick:()=>h(!0),children:[t.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-value",children:(f==null?void 0:f.label)??""}),t.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-icon",children:t.jsx(dh,{expanded:c})})]})]}),t.jsx(lh,{open:c,title:e,options:s,selectedValue:n,onClose:()=>h(!1),onSelect:k=>{o(k),h(!1)}})]})}function lh({open:e,title:n,options:s,selectedValue:i,onClose:o,onSelect:c}){return e?t.jsx(bc,{open:e,title:n,kind:"picker",height:"half",className:"workspace-inbox-picker-sheet",cardClassName:"workspace-inbox-picker-sheet-card",bodyClassName:"workspace-inbox-picker-sheet-body",showHandle:!0,onClose:o,children:t.jsx(kc,{className:"workspace-inbox-picker-sheet-options",role:"listbox","aria-label":n,children:s.map(h=>{const f=h.value===i;return t.jsx(gc,{as:"button",className:"workspace-inbox-picker-option",role:"option","aria-selected":f,selected:f,trailing:t.jsx("span",{className:"workspace-inbox-picker-option-indicator","aria-hidden":"true",children:f?t.jsx(uh,{}):null}),onClick:()=>c(h.value),children:t.jsxs("span",{className:"workspace-inbox-picker-option-copy",children:[t.jsx("strong",{children:h.label}),h.description?t.jsx("span",{children:h.description}):null]})},h.value)})})}):null}function np({open:e,preferredWorkspaceId:n,preferredSessionId:s,creationRequestId:i=0,initialDraft:o=null,onClose:c,compactComposer:h=!1}){const[f,k]=l.useState(0),[p,g]=l.useState(!h);return l.useEffect(()=>{e||g(!h)},[h,e]),t.jsx(Ue,{open:e,title:r("shell.butlerInboxModalTitle"),description:r("shell.butlerInboxModalDescription"),className:"workspace-inbox-modal-card",showCloseButton:!h,headerActions:h?t.jsx("button",{type:"button",className:"workspace-inbox-modal-create-button","aria-label":r("shell.butlerInboxCreateAction"),title:r("shell.butlerInboxCreateAction"),onClick:()=>{k(N=>N+1),g(!0)},children:t.jsx(ch,{})}):void 0,onClose:c,children:t.jsx(Nl,{active:e,preferredWorkspaceId:n,preferredSessionId:s,creationRequestId:Math.max(i,f),initialDraft:o,compactComposer:h,composerOpen:p,onComposerOpenChange:g})})}function Jo(e,n,s){return[...e].filter(i=>i.lifecycleStatus!=="archived").sort((i,o)=>{const c=Zo(i,n,s),h=Zo(o,n,s);return c!==h?h-c:i.name.localeCompare(o.name,"zh-Hans-CN")})}function Zo(e,n,s){return s&&e.id===s?2:n&&e.workspaceId===n?1:0}function Qo({projects:e,currentProjectId:n,preferredProjectId:s,preferredWorkspaceId:i}){var c;if(n&&e.some(h=>h.id===n))return n;if(s&&e.some(h=>h.id===s))return s;const o=i?e.find(h=>h.workspaceId===i):null;return(o==null?void 0:o.id)||((c=e[0])==null?void 0:c.id)||""}function ch(){return t.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[t.jsx("path",{d:"M12 5v14"}),t.jsx("path",{d:"M5 12h14"})]})}function dh({expanded:e}){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true","data-expanded":e?"true":void 0,children:t.jsx("path",{d:"M3.5 6 8 10l4.5-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function uh(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M3.5 8.4 6.6 11.5 12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function hh(e){switch(e){case"bug":return r("shell.butlerInboxTypeBug");case"feature":return r("shell.butlerInboxTypeFeature");case"change":return r("shell.butlerInboxTypeChange");case"task":default:return r("shell.butlerInboxTypeTask")}}function ea(e){switch(e){case"in_progress":return r("shell.butlerInboxStatusInProgress");case"closed":return r("shell.butlerInboxStatusClosed");case"pending":default:return r("shell.butlerInboxStatusPending")}}function fh(e){return new Date(e).toLocaleString()}function mh({open:e,onClose:n,onImported:s}){const{showToast:i}=Xn(),[o,c]=l.useState(!1),[h,f]=l.useState(!1),[k,p]=l.useState(!1),[g,N]=l.useState(null),[C,I]=l.useState(""),[H,U]=l.useState(""),[A,x]=l.useState(null),[P,_]=l.useState([]),[Y,R]=l.useState([]),[K,V]=l.useState(!1),[G,j]=l.useState(""),Z=o||h||k,ee=l.useCallback(async S=>{c(!0),N(null);try{const J=await Oa(S);I(J.currentPath),U(J.currentPath),x(J.parentPath),_(J.roots),R(J.items)}catch(J){I(""),x(null),R([]),N(J instanceof Error?J.message:r("shell.importBrowserBrowseFailed"))}finally{c(!1)}},[]);l.useEffect(()=>{if(!e){V(!1),j(""),N(null);return}ee(C||void 0)},[ee,e]);function E(){Z||(V(!1),j(""),n())}async function ue(S){S.preventDefault(),await ee(H)}function $(){!C||Z||(j(""),V(!0))}function ce(){h||(V(!1),j(""))}async function D(S){S==null||S.preventDefault();const J=G.trim();if(!(!C||!J||Z)){f(!0),N(null);try{const ke=await xc({parentPath:C,directoryName:J});i({title:r("shell.importBrowserCreateDirectorySuccess"),description:ke.path,tone:"success"}),V(!1),j(""),await ee(ke.path)}catch(ke){const we=ke instanceof Error?ke.message:r("shell.importBrowserCreateDirectoryFailed");N(we),i({title:we,tone:"error"})}finally{f(!1)}}}async function v(){const S=C.trim();if(!(!S||Z)){p(!0),N(null);try{const J=await wc({path:S});i({title:r("shell.importSuccess"),description:J.path,tone:"success"}),n(),Promise.resolve().then(()=>s==null?void 0:s(J)).catch(ke=>{i({title:ke instanceof Error?ke.message:r("shell.navigationLoadFailed"),tone:"error"})})}catch(J){i({title:J instanceof Error?J.message:r("shell.importFailed"),tone:"error"})}finally{p(!1)}}}return t.jsxs(t.Fragment,{children:[t.jsxs(Ue,{open:e,title:r("shell.importBrowserTitle"),description:r("shell.importBrowserDescription"),onClose:E,children:[t.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ue,children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.importBrowserCurrentPath")}),t.jsx("input",{type:"text",value:H,placeholder:r("shell.importPathPlaceholder"),onChange:S=>U(S.target.value)})]}),t.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:Z||!A,onClick:()=>{A&&ee(A)},children:r("shell.importBrowserOpenParent")}),t.jsx("button",{type:"submit",className:"secondary-button",disabled:Z,children:r("shell.importBrowserOpenPath")}),t.jsx("button",{type:"button",className:"secondary-button",disabled:Z||!C,onClick:$,children:r("shell.importBrowserCreateDirectory")})]})]}),t.jsxs("section",{className:"workbench-directory-browser-panel",children:[t.jsxs("div",{className:"workbench-directory-browser-section",children:[t.jsx("span",{className:"workbench-directory-browser-section-title",children:r("shell.importBrowserRoots")}),t.jsx("div",{className:"workbench-directory-browser-root-list",children:P.map(S=>t.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:Z,onClick:()=>{ee(S.path)},children:S.name},S.path))})]}),t.jsx("div",{className:"workbench-directory-browser-current-path",children:C}),g?t.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:g}):null,o?t.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("common.loading")}):Y.length>0?t.jsx("div",{className:"workbench-directory-browser-list",children:Y.map(S=>t.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:Z,onClick:()=>{ee(S.path)},children:[t.jsx("span",{className:"workbench-directory-browser-item-name",children:S.name}),t.jsx("span",{className:"workbench-directory-browser-item-path",children:S.path})]},S.path))}):t.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("shell.importBrowserEmpty")})]}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:Z,onClick:E,children:r("common.cancel")}),t.jsx("button",{type:"button",className:"primary-button",disabled:Z||!C,onClick:()=>{v()},children:k?r("shell.importSubmitting"):r("shell.importBrowserSubmit")})]})]}),t.jsx(Ue,{open:e&&K,title:r("shell.importBrowserCreateDirectoryTitle"),description:r("shell.importBrowserCreateDirectoryDescription"),onClose:ce,children:t.jsxs("form",{className:"workbench-rename-form",onSubmit:S=>void D(S),children:[t.jsx("div",{className:"workbench-directory-browser-current-path",children:C}),t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.importBrowserCreateDirectoryLabel")}),t.jsx("input",{type:"text",value:G,placeholder:r("shell.importBrowserCreateDirectoryPlaceholder"),autoFocus:!0,onChange:S=>j(S.target.value)})]}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:h,onClick:ce,children:r("common.cancel")}),t.jsx("button",{type:"submit",className:"primary-button",disabled:h||!G.trim(),children:h?r("shell.importBrowserCreatingDirectory"):r("shell.importBrowserCreateDirectorySubmit")})]})]})})]})}function ph({onOpenSoftwareUpdate:e}){var i;const n=Hi(o=>o.platform),s=uc(o=>o.latestState);return n!=="desktop"||!(s!=null&&s.hasUpdate)?null:t.jsx("button",{className:"workbench-nav-update-badge",type:"button",title:((i=s.manifest)==null?void 0:i.version)??r("settings.releaseUpdateReady"),onClick:e,children:t.jsx("span",{className:"workbench-nav-update-badge-label",children:r("settings.releaseUpdateBadge")})})}const ta="workbench.left.width",na="workbench.right.width",sa="workbench.left.collapsed",ra="workbench.right.collapsed",Or="workbench.last.session.path",Ci="workbench.workspace.selected.id",ia="workbench.notifications.seen_at",bh=280,kh=320,oa=240,aa=280,la=520,ca=560,gh=200,Ti=20,Gs=40,Hr=5,wh=3e4,xh=12,da=60*1e3,vh=4e3,ua=220,ha=18,yh=6,bs="data-workbench-panel-resizing",Ur="data-workbench-window-resizing",Sh=180,jh="workbench:focus-composer",Nh=new Set(["starting","running","reconnecting","stale","unknown"]),Ch=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"],Th=["--workbench-titlebar-live-content-shift-y","--workbench-nav-toolbar-live-shift-y","--workbench-info-tabs-live-shift-y","--workbench-auxiliary-toolbar-button-live-shift-y","--workbench-conversation-header-main-live-shift-y","--workbench-conversation-header-actions-live-shift-y","--workbench-terminal-tabbar-live-shift-y","--workbench-collapsed-controls-live-shift-y","--workbench-collapsed-left-controls-live-shift-y","--workbench-collapsed-right-controls-live-shift-y"],Me={navToolbar:{selector:".workbench-nav-toolbar",variableName:"--workbench-nav-toolbar-live-shift-y"},infoTabs:{selector:".workbench-info-tabs",variableName:"--workbench-info-tabs-live-shift-y"},auxiliaryToolbarButton:{selector:".workbench-auxiliary-header > .workbench-nav-toolbar-button",variableName:"--workbench-auxiliary-toolbar-button-live-shift-y"},conversationHeaderMain:{selector:".conversation-header-main",variableName:"--workbench-conversation-header-main-live-shift-y"},conversationHeaderActions:{selector:".conversation-header-actions",variableName:"--workbench-conversation-header-actions-live-shift-y"},terminalTabbarMain:{selector:".terminal-tabbar-main",variableName:"--workbench-terminal-tabbar-live-shift-y"},collapsedLeftControls:{selector:'.workbench-collapsed-controls.left[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-left-controls-live-shift-y"},collapsedRightControls:{selector:'.workbench-collapsed-controls.right[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-right-controls-live-shift-y"}};function Cl(e,n){const s=e.getPropertyValue(n).trim();if(!s)return null;const i=Number.parseFloat(s);return Number.isFinite(i)?i:null}function Ih(e){return Math.round(e*100)/100}function Rh(e,n){const s=n.getBoundingClientRect();if(s.width<=0||s.height<=0)return null;const i=window.getComputedStyle(n);return i.display==="none"||i.visibility==="hidden"?null:s.top-e.top+s.height/2}function yn(e,n){const s=e.getBoundingClientRect(),o=Array.from(e.querySelectorAll(n)).map(c=>Rh(s,c)).filter(c=>c!==null);return o.length===0?null:o.reduce((c,h)=>c+h,0)/o.length}function Ht(e,n,s){const i=e.style.getPropertyValue(n).trim();if(s===null||!Number.isFinite(s)){i&&e.style.removeProperty(n);return}const o=`${Ih(s)}px`;i!==o&&e.style.setProperty(n,o)}function Ut(e,n,s,i){return i===null?null:(Cl(e,n)??0)+(s-i)}function fa(e){if(e)for(const n of Th)e.style.removeProperty(n)}function Mh(e){return Nh.has(e.runningState??"idle")||e.activityState==="running"}function Eh(e,n){const s=[];for(const i of[...n].sort()){const o=e.get(i);!o||o.size===0||s.push(`${i}:${[...o].sort().join(",")}`)}return s.join("|")}function Wh(e){var o,c;const n=((o=e.lastErrorCode)==null?void 0:o.trim())??"",s=((c=e.lastErrorDetail)==null?void 0:c.trim())??"",i=[n,s].filter(h=>h.length>0).join(" · ");return i?i.length<=ua?i:`${i.slice(0,ua-3)}...`:null}function Ah(e,n,s){var c,h,f,k,p,g,N,C,I,H,U,A;const i=new Map(e.projects.map(x=>[x.id,x.workspaceId])),o=[];for(const x of s){const P=x.title.trim()||x.projectName;if(x.assistantState.lifecycleStage==="analyzed"&&!((c=x.assistantState.linkedSessionId)!=null&&c.trim())&&x.assistantState.lastAnalyzedAt){o.push({id:`todo-analysis-completed:${x.id}:${x.assistantState.lastAnalyzedAt}`,kind:"todo_analyzed",title:r("shell.globalNotificationTodoAnalyzedTitle",{title:P}),body:((h=x.assistantState.analysisSummary)==null?void 0:h.trim())||((f=x.assistantState.generatedPrompt)==null?void 0:f.trim())||x.content,routePath:Vn(x.workspaceId),workspaceId:x.workspaceId,createdAt:x.assistantState.lastAnalyzedAt});continue}x.assistantState.lifecycleStage==="failed"&&o.push({id:`todo-analysis-failed:${x.id}:${x.updatedAt}`,kind:"todo_analyze_failed",title:r("shell.globalNotificationTodoAnalyzeFailedTitle",{title:P}),body:((k=x.assistantState.lastError)==null?void 0:k.trim())||x.content,routePath:Vn(x.workspaceId),workspaceId:x.workspaceId,createdAt:x.updatedAt})}for(const x of n){const P=((p=x.sessionTitle)==null?void 0:p.trim())||x.projectName,_=x.updatedAt||x.lastAutomationAt||x.createdAt;if(x.status==="waiting_user"){o.push({id:`follow-up-waiting:${x.id}`,kind:"follow_up_waiting_user",title:r("shell.globalNotificationFollowUpWaitingTitle",{title:P}),body:((g=x.waitingReason)==null?void 0:g.trim())||((N=x.lastAutomationSummary)==null?void 0:N.trim())||x.objective,routePath:$t(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:_});continue}if(x.status==="completed"){o.push({id:`follow-up-completed:${x.id}`,kind:"follow_up_completed",title:r("shell.globalNotificationFollowUpCompletedTitle",{title:P}),body:((C=x.lastAutomationSummary)==null?void 0:C.trim())||x.objective,routePath:$t(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:_});continue}x.status==="failed"&&o.push({id:`follow-up-failed:${x.id}`,kind:"follow_up_failed",title:r("shell.globalNotificationFollowUpFailedTitle",{title:P}),body:((I=x.lastAutomationSummary)==null?void 0:I.trim())||((H=x.waitingReason)==null?void 0:H.trim())||x.objective,routePath:$t(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:_})}for(const x of e.verifications){if(x.status!=="failed")continue;const P=x.projectId?i.get(x.projectId)??null:null,_=((U=x.targetRef)==null?void 0:U.trim())||x.verificationType;o.push({id:`verification-failed:${x.id}`,kind:"verification_failed",title:r("shell.globalNotificationVerificationFailedTitle",{title:_}),body:((A=x.summary)==null?void 0:A.trim())||r("shell.globalNotificationVerificationFailedFallback"),routePath:P?Vn(P):null,workspaceId:P,createdAt:x.finishedAt||x.startedAt||x.createdAt})}return o.sort((x,P)=>{const _=ma(x.kind)-ma(P.kind);return _!==0?_:Cn(P.createdAt)-Cn(x.createdAt)}).slice(0,xh)}function ma(e){switch(e){case"follow_up_waiting_user":return 0;case"todo_analyze_failed":return 1;case"follow_up_failed":return 2;case"verification_failed":return 3;case"todo_analyzed":return 4;case"follow_up_completed":return 5;default:return 9}}function Ph(e){switch(e){case"follow_up_waiting_user":return r("shell.globalNotificationKindWaitingUser");case"todo_analyzed":return r("shell.globalNotificationKindTodoAnalyzed");case"todo_analyze_failed":return r("shell.globalNotificationKindTodoAnalyzeFailed");case"follow_up_completed":return r("shell.globalNotificationKindFollowUpCompleted");case"follow_up_failed":return r("shell.globalNotificationKindFollowUpFailed");case"verification_failed":return r("shell.globalNotificationKindVerificationFailed");default:return r("shell.globalNotificationsPanelTitle")}}function Cn(e){if(!e)return 0;const n=new Date(e).getTime();return Number.isNaN(n)?0:n}function Bh(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function Lh(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function Dh(e,n){const s=new Set,i=(e==null?void 0:e.currentBranch)??"",o=((e==null?void 0:e.local)??[]).slice().sort((f,k)=>Number(k.current)-Number(f.current)||f.name.localeCompare(k.name)).map(f=>({value:f.name,current:f.current,recommended:f.name===i})).filter(f=>!f.value||s.has(f.value)?!1:(s.add(f.value),!0)),c=((e==null?void 0:e.remote)??[]).map(f=>({value:f.name})).filter(f=>!f.value||s.has(f.value)?!1:(s.add(f.value),!0)),h=n.map(f=>({value:f.name})).filter(f=>!f.value||s.has(f.value)?!1:(s.add(f.value),!0));return{localBranches:o,remoteBranches:c,tags:h}}function _h(e){return e.getBoundingClientRect()}function Fh(e,n){return n?Cn(e.createdAt)>Cn(n):!0}function Oh(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}function pa(e,n){var h,f;const s=["/workspaces/:workspaceId","/workspaces/:workspaceId/sessions","/workspaces/:workspaceId/sessions/:sessionId","/workspaces/:workspaceId/tools","/workspaces/:workspaceId/tools/files","/workspaces/:workspaceId/tools/git","/workspaces/:workspaceId/tools/processes","/workspaces/:workspaceId/terminals","/workspaces/:workspaceId/butler"];for(const k of s){const p=Se(k,e),g=(h=p==null?void 0:p.params.workspaceId)==null?void 0:h.trim();if(g)return g}const i=Js(e),o=(i==null?void 0:i.sessionId)??null;return!o||!Zl(o)?null:((f=new URLSearchParams(n).get("workspaceId"))==null?void 0:f.trim())||null}function Hh(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function Ii(e){return e==="mobile"?at():"/landing"}function Js(e){var c,h,f;const n=Se("/workspaces/:workspaceId/sessions/:sessionId",e),s=(c=n==null?void 0:n.params.sessionId)==null?void 0:c.trim();if(s)return{sessionId:s,workspaceId:((h=n==null?void 0:n.params.workspaceId)==null?void 0:h.trim())??null};const i=Se("/sessions/:sessionId",e),o=(f=i==null?void 0:i.params.sessionId)==null?void 0:f.trim();return o?{sessionId:o,workspaceId:null}:null}function Uh(e){return!!(Se("/sessions",e)||Se("/workspaces/:workspaceId/sessions",e))}function ba(e){return!!Js(e)}function $h(e){return!!(Se("/tools",e)||Se("/tools/files",e)||Se("/tools/git",e)||Se("/tools/processes",e)||Se("/workspaces/:workspaceId/tools",e)||Se("/workspaces/:workspaceId/tools/files",e)||Se("/workspaces/:workspaceId/tools/git",e)||Se("/workspaces/:workspaceId/tools/processes",e))}function Di(e){return!!(Se("/terminals",e)||Se("/workspaces/:workspaceId/terminals",e))}function Xr(e){return!!Se("/workspaces/:workspaceId/butler",e)}function qh(e,n){return Se("/workspaces/:workspaceId/debug",e)?Za(n):Se("/workspaces/:workspaceId",e)?Gt(n):Se("/workspaces/:workspaceId/tools/files",e)||Se("/tools/files",e)?el(n):Se("/workspaces/:workspaceId/tools/git",e)||Se("/tools/git",e)?tl(n):Se("/workspaces/:workspaceId/tools/processes",e)||Se("/tools/processes",e)?nl(n):Se("/workspaces/:workspaceId/tools",e)||Se("/tools",e)?Qa(n):Di(e)?vs(n):Xr(e)?Vn(n):Qs(n)}function Gh(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const Kh=l.lazy(async()=>({default:(await Ui(()=>import("./FileContextPanel--FVTxDrq.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))).FileContextPanel})),zh=l.lazy(async()=>({default:(await Ui(()=>import("./GitSidebar-DAiSi9oc.js"),__vite__mapDeps([10,1,2,3,4,11,5,7,6,8,9]))).GitSidebar})),Vh=l.lazy(async()=>({default:(await Ui(()=>import("./TerminalManagerPanel-DhuTEdzV.js"),__vite__mapDeps([12,1,2,6,3,4,5,13,14,8,9]))).TerminalManagerPanel}));function Xh(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function Et(e){return Ns(e)}function Yh(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function zs(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(Xh):[]}async function Tl(e,n){const s=await Mc(n,e);if(s.canStartSession===!1)throw new Error(s.limitations[0]??r("conversation.capabilityDenied"))}const Il=l.createContext(null);function _i(e){return wu(e)}function qt(e){return e.isArchived===!0}function si(e){var n;return((n=e.parentSessionId)==null?void 0:n.trim())||null}function uo(e,n){return Va(e,{getId:s=>s.sessionId,getParentId:si,compare:(s,i)=>ao(s,i,n)})}function Rl(e){return e.filter(n=>{if(qt(n))return!1;const s=si(n);if(!s)return!0;const i=e.find(o=>o.sessionId===s);return!i||!qt(i)})}function Jh(e){return e.flatMap(n=>{const s=Yh(n);return s?[s,...Xa(Et(n))]:[]})}function Zh(e,n,s){const i=new Set(Sn(Et(e)).sort((o,c)=>ao(o.item,c.item,s)).slice(0,n).map(o=>o.item.sessionId));return{...e,children:Ml(Et(e),i)}}function Ml(e,n){return e.flatMap(s=>{const i=Ml(Et(s),n);return!n.has(s.item.sessionId)&&i.length===0?[]:[{...s,children:i}]})}function $r(e,n,s,i=-1){if(e<=0)return 0;const o=i>=0?Math.max(n,i+1):n;return Math.min(e,Math.max(s??0,o))}function ka(e,n){const s=Object.keys(e),i=Object.keys(n);return s.length!==i.length?!1:s.every(o=>e[o]===n[o])}function Qh(e){const n=e.lastMessageAt??e.updatedAt;return n?new Date(n).toLocaleDateString():""}function ef(e){return ro(e)||e.syncStatus==="error"}function tf(e){var i,o;if(!ef(e))return null;const n=((i=e.lastErrorCode)==null?void 0:i.trim())??"",s=((o=e.lastErrorDetail)==null?void 0:o.replace(/\s+/g," ").trim())??"";return n&&s&&!s.includes(n)?`${n} · ${s}`:s||n||(e.syncStatus==="error"&&!ro(e)?r("conversation.syncStatusError"):r("conversation.runtimeErrorTitle"))}function nf(e,n=110){return e.length<=n?e:`${e.slice(0,Math.max(0,n-1)).trimEnd()}…`}function ri(e,n="compact"){return Rc(e,n)}const sf={position:"relative",zIndex:0},rf={zIndex:1};function El(e,n,s,i){const o=[],c=(i==null?void 0:i.trim())||n.name;s&&o.push(c);const h=Qh(e);return h&&o.push(h),o.join(" · ")||c}function ga(e,n){return fu("session-state-indicator",e,n)}function of(e,n){return gl(e,n)}function wa(e,n){try{const s=window.localStorage.getItem(e),i=s?Number(s):Number.NaN;return Number.isFinite(i)?i:n}catch{return n}}function xa(e,n){try{const s=window.localStorage.getItem(e);return s===null?n:s==="true"}catch{return n}}function va(e){var n;try{const s=(n=window.localStorage.getItem(e))==null?void 0:n.trim();return s||null}catch{return null}}function zn(e,n){try{window.localStorage.setItem(e,n)}catch{}}function af(e){try{window.localStorage.removeItem(e)}catch{}}function qr(e,n,s){return Math.max(n,Math.min(s,e))}function Gr(e){const n=Number.parseFloat(e);return Number.isFinite(n)?n:0}function lf(e){const n=window.getComputedStyle(e),s=Gr(n.getPropertyValue("--desktop-macos-titlebar-height")),i=Gr(n.getPropertyValue("--workbench-header-min-height")),o=Gr(n.getPropertyValue("--workbench-macos-titlebar-padding-top")),c=Gr(n.getPropertyValue("--workbench-macos-titlebar-padding-bottom"));return Math.max(s,i,40)+o+c+8}function ya(e,n){const s=n.getBoundingClientRect();return e>=s.top&&e<=s.top+lf(n)}function cf(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function df(){typeof window>"u"||window.dispatchEvent(new CustomEvent(jh))}function Wl(e,n){const s=n==null?void 0:n.trim();if(!s)return null;for(const i of e){if(i.workspace.id===s)return i;const o=Wl(i.children,s);if(o)return o}return null}function uf(e,n){const s=n==null?void 0:n.trim();if(!s)return null;for(const i of e){const o=Wl(i.childWorktrees,s);if(o)return o}return null}function Sa(e){return!e||!Array.isArray(e.items)?[]:e.items.filter(n=>{var s;return n.collapsed===!0&&((s=n.workspace)==null?void 0:s.id)}).map(n=>n.workspace.id)}function Ri(e,n){const s=new Set(n);return{items:e.map(i=>({workspace:i.workspace,sessions:i.sessions,childWorktrees:i.childWorktrees,collapsed:s.has(i.workspace.id)}))}}function Al(e,n,s){return e.map(i=>{const o=Rl(i.sessions);return{workspace:i.workspace,meta:i.meta,visibleSessions:o,archivedSessions:i.sessions.filter(c=>qt(c)&&!si(c)),visibleSessionTree:uo(o,s).filter(c=>!n.has(c.item.sessionId)&&!Yi(Et(c),h=>n.has(h.sessionId))),children:Al(i.children,n,s)}})}function Fi(e){return e.flatMap(n=>[n.workspace.id,...Fi(n.children)])}function Vs(e){return e.flatMap(n=>[...n.visibleSessionTree,...Vs(n.children)])}function hf(e,n){if(!n)return null;for(const s of e){if(s.workspace.id===n)return{workspace:s.workspace,visibleSessionTree:zs(s)};const i=Bl(s.childWorktrees,n);if(i)return i}return null}function Pl(e,n){for(const s of e){const i=Sn(s.visibleSessionTree).find(c=>c.item.sessionId===n);if(i)return i;const o=Pl(s.children,n);if(o)return o}return null}function Bl(e,n){for(const s of e){if(s.workspace.id===n)return{workspace:s.workspace,visibleSessionTree:s.visibleSessionTree};const i=Bl(s.children,n);if(i)return i}return null}function ff(e,n){if(!n)return null;for(const s of e){if(s.workspace.id===n)return{workspace:s.workspace,archivedSessions:s.archivedSessions};const i=Ll(s.childWorktrees,n);if(i)return i}return null}function ja(e,n){if(!n)return null;for(const s of e){if(s.workspace.id===n)return s.workspace;const i=Dl(s.childWorktrees,n);if(i)return i}return null}function Ll(e,n){for(const s of e){if(s.workspace.id===n)return{workspace:s.workspace,archivedSessions:s.archivedSessions};const i=Ll(s.children,n);if(i)return i}return null}function Dl(e,n){for(const s of e){if(s.workspace.id===n)return s.workspace;const i=Dl(s.children,n);if(i)return i}return null}function _l(e,n){for(const s of e){if(s.workspace.id===n)return[s.workspace.id];const i=_l(s.children,n);if(i.length>0)return[s.workspace.id,...i]}return[]}function Na(e){return e.flatMap(n=>[n.workspace.id,...Fl(n.childWorktrees)])}function Fl(e){return e.flatMap(n=>[n.workspace.id,...Fl(n.children)])}function mf(e,n=[]){if(e.tone!=="worktree")return e.rootDisplayName;if(n.length>0)return n.join(" / ");const s=[e.rootDisplayName];return e.parentDisplayName&&e.parentDisplayName!==e.rootDisplayName&&s.push(e.parentDisplayName),s.join(" / ")}function pf(e,n,s,i){if(n===s)return e;const o=e.findIndex(p=>p.workspace.id===n),c=e.findIndex(p=>p.workspace.id===s);if(o<0||c<0)return e;const h=[...e],[f]=h.splice(o,1);if(!f)return e;const k=h.findIndex(p=>p.workspace.id===s);return k<0?e:(h.splice(i==="before"?k:k+1,0,f),h.every((p,g)=>{var N;return p.workspace.id===((N=e[g])==null?void 0:N.workspace.id)})?e:h)}function bf(e,n){if(!Array.isArray(e.items)||n.size===0)return e;let s=!1;const i=e.items.map(o=>{let c=!1;const h=o.sessions.map(k=>{const p=n.get(k.sessionId);return p===void 0||qt(k)===p?k:(s=!0,c=!0,{...k,isArchived:p})}),f=Hl(o.childWorktrees??[],n,k=>{k&&(s=!0,c=!0)});return c?{...o,sessions:h,childWorktrees:f}:o});return s?{...e,items:i}:e}function kf(e,n){if(!(!Array.isArray(n.items)||e.size===0))for(const s of n.items){for(const i of s.sessions){const o=e.get(i.sessionId);o!==void 0&&qt(i)===o&&e.delete(i.sessionId)}Ul(e,s.childWorktrees??[])}}function gf(e,n,s){let i=!1;const o=e.map(c=>{if(c.workspace.id!==n.workspaceId){const{nodes:k,changed:p}=$l(c.childWorktrees,n,s);return p?(i=!0,{...c,childWorktrees:k}):c}const h=c.sessions.findIndex(k=>k.sessionId===n.sessionId),f=h>=0?c.sessions.map((k,p)=>p===h?n:k):[n,...c.sessions];return i=!0,{...c,sessions:rr(f,s)}});return i?o:e}function wf(e,n,s){let i=!1;const o=e.map(c=>{let h=!1;const f=c.sessions.map(p=>p.sessionId!==n?p:(i=!0,h=!0,{...p,lastSeenAt:p.lastSeenAt&&p.lastSeenAt>s?p.lastSeenAt:s,activityState:p.activityState==="completed_unread"?"idle":p.activityState})),k=ii(c.childWorktrees,p=>p.sessionId!==n?p:(i=!0,h=!0,{...p,lastSeenAt:p.lastSeenAt&&p.lastSeenAt>s?p.lastSeenAt:s,activityState:p.activityState==="completed_unread"?"idle":p.activityState}));return h?{...c,sessions:f,childWorktrees:k}:c});return i?o:e}function Ca(e,n,s){let i=!1;const o=e.map(c=>{let h=!1;const f=c.sessions.map(p=>p.sessionId!==n||p.isArchived===s?p:(i=!0,h=!0,{...p,isArchived:s})),k=ii(c.childWorktrees,p=>p.sessionId!==n||p.isArchived===s?p:(i=!0,h=!0,{...p,isArchived:s}));return h?{...c,sessions:f,childWorktrees:k}:c});return i?o:e}function Ta(e,n,s){let i=!1;const o=e.map(c=>{let h=!1;const f=c.sessions.map(p=>p.sessionId!==n||p.isFavorite===!0===s?p:(i=!0,h=!0,{...p,isFavorite:s})),k=ii(c.childWorktrees,p=>p.sessionId!==n||p.isFavorite===!0===s?p:(i=!0,h=!0,{...p,isFavorite:s}));return h?{...c,sessions:f,childWorktrees:k}:c});return i?o:e}function xf(e,n){return e.includes(n)?e.filter(s=>s!==n):[...e,n]}function vf(e){return e?e.slice(0,8):"--"}function Ia(e,n,s){return s?e.includes(n)?e:[...e,n]:e.includes(n)?e.filter(i=>i!==n):e}function Ol(e,n){const s=e.filter(i=>n.has(i));return s.length===e.length?e:s}function Hl(e,n,s){return e.map(i=>{let o=!1;const c=i.sessions.map(f=>{const k=n.get(f.sessionId);return k===void 0||qt(f)===k?f:(o=!0,{...f,isArchived:k})}),h=Hl(i.children,n,f=>{f&&(o=!0)});return s(o),o?{...i,sessions:c,children:h}:i})}function Ul(e,n){for(const s of n){for(const i of s.sessions){const o=e.get(i.sessionId);o!==void 0&&qt(i)===o&&e.delete(i.sessionId)}Ul(e,s.children)}}function $l(e,n,s){let i=!1;const o=e.map(c=>{if(c.workspace.id===n.workspaceId){const f=c.sessions.findIndex(p=>p.sessionId===n.sessionId),k=f>=0?c.sessions.map((p,g)=>g===f?n:p):[n,...c.sessions];return i=!0,{...c,sessions:rr(k,s)}}const h=$l(c.children,n,s);return h.changed?(i=!0,{...c,children:h.nodes}):c});return{nodes:i?o:[...e],changed:i}}function yf(e,n){return e.map(s=>({...s,sessions:rr(s.sessions,n),childWorktrees:lo(s.childWorktrees,n)}))}function ii(e,n){let s=!1;const i=e.map(o=>{let c=!1;const h=o.sessions.map(k=>{const p=n(k);return p!==k&&(c=!0,s=!0),p}),f=ii(o.children,n);return f!==o.children&&(c=!0,s=!0),c?{...o,sessions:h,children:f}:o});return s?i:[...e]}function Oi(e){return`workspace-management.summary.${e}`}function ql(e){return`git-sidebar.snapshot.${e}`}function Gl(e,n){const s=e.repoRoot??null;return{workspaceId:e.id,name:e.name,path:e.path,git:{isRepository:!!s,repoRoot:s,currentBranch:null,commitCount:null,remotes:[],error:null},codeComposition:{scannedFileCount:0,truncated:!1,items:[],error:null}}}function Kl(e,n){const s=e.git.repoRoot??n.repoRoot??null;return{...e,workspaceId:n.id,name:n.name,path:n.path,git:{...e.git,isRepository:e.git.isRepository||!!s,repoRoot:s}}}function zl(e,n){var o,c,h;const s=((o=n.status)==null?void 0:o.snapshot.repoRoot)??e.git.repoRoot,i=((c=n.status)==null?void 0:c.snapshot.branch)??((h=n.branches)==null?void 0:h.currentBranch)??e.git.currentBranch??null;return{...e,git:{...e.git,isRepository:e.git.isRepository||!!s,repoRoot:s,currentBranch:i,error:null}}}function Vl({count:e,className:n="workbench-skeleton-lines"}){return t.jsx("div",{className:n,"aria-hidden":"true",children:Array.from({length:e},(s,i)=>t.jsx("span",{className:"skeleton-line"},i))})}function Sf(){return t.jsx("div",{className:"workbench-nav-loading","aria-hidden":"true",children:Array.from({length:3},(e,n)=>t.jsxs("section",{className:"workbench-skeleton-card",children:[t.jsxs("div",{className:"workbench-skeleton-heading",children:[t.jsx("span",{className:"skeleton-line short"}),t.jsx("span",{className:"skeleton-line tiny"})]}),t.jsx("div",{className:"workbench-skeleton-list",children:Array.from({length:3},(s,i)=>t.jsxs("div",{className:"workbench-skeleton-session",children:[t.jsx("span",{className:"workbench-skeleton-dot"}),t.jsx(Vl,{count:2,className:"workbench-skeleton-lines compact"})]},i))})]},n))})}function Kr(){return t.jsx("section",{className:"workbench-info-skeleton","aria-hidden":"true",children:Array.from({length:4},(e,n)=>t.jsxs("article",{className:"workbench-info-skeleton-card",children:[t.jsx("span",{className:"skeleton-line short"}),t.jsx(Vl,{count:3})]},n))})}function jf({side:e,collapsed:n}){const s=e==="left"?8.5:15.5,i=e==="left"?n?"12 9 15 12 12 15":"15 9 12 12 15 15":n?"12 9 9 12 12 15":"9 9 12 12 9 15";return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),t.jsx("line",{x1:s,y1:"4",x2:s,y2:"20"}),t.jsx("polyline",{points:i})]})}function Ra({ariaLabel:e,side:n,collapsed:s,className:i="panel-icon-button",onClick:o}){return t.jsx("button",{className:i,type:"button","aria-label":e,title:e,onClick:o,children:t.jsx(jf,{side:n,collapsed:s})})}function Xs({expanded:e}){return t.jsx("svg",{className:e?"workbench-chevron":"workbench-chevron collapsed",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Nf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),t.jsx("polyline",{points:"7 10 12 15 17 10"}),t.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function Cf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"}),t.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),t.jsx("line",{x1:"8",y1:"14",x2:"12",y2:"14"}),t.jsx("circle",{cx:"17.5",cy:"15.5",r:"2.5"})]})}function Tf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("path",{d:"M7.5 10.2a4.5 4.5 0 1 1 9 0v3.1c0 .8.3 1.6.9 2.2l.8.8H5.8l.8-.8c.6-.6.9-1.4.9-2.2z",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M10 18.5a2 2 0 0 0 4 0",strokeLinecap:"round"})]})}function Xl(e){return t.jsx("div",{className:"workbench-notification-anchor",children:t.jsxs("button",{type:"button",className:e.collapsed?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":r("shell.globalNotificationsAction"),title:r("shell.globalNotificationsAction"),"aria-expanded":e.open,onClick:e.onToggle,children:[t.jsx(Tf,{}),e.unreadCount>0?t.jsx("span",{className:"workbench-notification-badge","aria-label":r("shell.globalNotificationsUnreadAria",{count:String(e.unreadCount)}),children:e.unreadCount>99?"99+":e.unreadCount}):null]})})}function If(e){const[n,s]=l.useState("notifications");l.useEffect(()=>{e.open&&s("notifications")},[e.open]);const i=l.useMemo(()=>e.notifications.filter(o=>e.showArchivedNotifications||!e.archivedNotificationIds.has(o.id)),[e.archivedNotificationIds,e.notifications,e.showArchivedNotifications]);return t.jsxs(Ue,{open:e.open,title:r("shell.globalNotificationsPanelTitle"),description:r("shell.globalNotificationsPanelDescription"),className:"workbench-notification-modal-card workspace-inbox-modal-card",showCloseButton:!1,onClose:e.onClose,children:[t.jsxs("div",{className:"workbench-notification-tabs",role:"tablist","aria-label":r("shell.globalNotificationsPanelTitle"),children:[t.jsx("button",{type:"button",className:n==="notifications"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":n==="notifications",onClick:()=>s("notifications"),children:r("shell.globalNotificationsAction")}),t.jsx("button",{type:"button",className:n==="inbox"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":n==="inbox",onClick:()=>s("inbox"),children:r("shell.butlerInboxAction")})]}),t.jsx("div",{className:"workbench-notification-content","data-tab":n,children:n==="notifications"?t.jsxs("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":r("shell.globalNotificationsAction"),children:[t.jsx("div",{className:"workbench-notification-toolbar",children:t.jsxs("label",{className:"workbench-notification-filter",children:[t.jsx("input",{type:"checkbox",checked:e.showArchivedNotifications,onChange:o=>e.onToggleShowArchivedNotifications(o.target.checked)}),t.jsx("span",{children:r("shell.globalNotificationsShowArchived")})]})}),i.length>0?t.jsx("div",{className:"workbench-notification-list",children:i.map(o=>{const c=e.archivedNotificationIds.has(o.id);return t.jsxs("article",{className:"workbench-notification-item","data-archived":c,children:[t.jsxs("button",{type:"button",className:"workbench-notification-item-content",onClick:()=>{e.onSelectNotification(o)},children:[t.jsx("span",{className:"workbench-notification-item-kind",children:Ph(o.kind)}),t.jsx("strong",{children:o.title}),t.jsx("p",{children:o.body})]}),t.jsxs("div",{className:"workbench-notification-item-side",children:[t.jsx("time",{children:Oh(o.createdAt)}),t.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(c){e.onUnarchiveNotification(o.id);return}e.onArchiveNotification(o.id)},children:c?r("shell.globalNotificationsRemoveArchiveAction"):r("shell.globalNotificationsArchiveAction")})]})]},o.id)})}):t.jsx("p",{className:"workbench-notification-empty",children:r("shell.globalNotificationsEmpty")})]}):t.jsx("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":r("shell.butlerInboxAction"),children:t.jsx(Nl,{active:e.open&&n==="inbox",preferredWorkspaceId:e.preferredWorkspaceId,preferredSessionId:e.preferredSessionId})})}),t.jsx("div",{className:"workbench-modal-actions workbench-notification-footer-actions",children:t.jsx("button",{type:"button",className:"secondary-button",onClick:e.onClose,children:r("common.close")})})]})}function Rf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function Mf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("circle",{cx:"11",cy:"11",r:"7"}),t.jsx("line",{x1:"20",y1:"20",x2:"16.65",y2:"16.65"})]})}function Ef(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Wf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),t.jsx("path",{d:"M7 9l3 3-3 3"}),t.jsx("path",{d:"M13 15h4"})]})}function Af(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"3"}),t.jsx("circle",{cx:"9",cy:"11",r:"1"}),t.jsx("circle",{cx:"15",cy:"11",r:"1"}),t.jsx("path",{d:"M8 15h8"}),t.jsx("path",{d:"M12 5V3"})]})}function Pf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("path",{d:"M12 4.5 13.6 8l3.9.4-2.9 2.7.8 3.9L12 13.2 8.6 15l.8-3.9-2.9-2.7L10.4 8 12 4.5Z"}),t.jsx("path",{d:"m18.5 4.5.5 1.3 1.3.5-1.3.5-.5 1.3-.5-1.3-1.3-.5 1.3-.5.5-1.3Z"})]})}function Yl(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),t.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),t.jsx("polyline",{points:"14 9 11 12 14 15"})]})}function Bf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("circle",{cx:"18",cy:"6",r:"3"}),t.jsx("circle",{cx:"6",cy:"6",r:"3"}),t.jsx("circle",{cx:"18",cy:"18",r:"3"}),t.jsx("path",{d:"M6 9v6a3 3 0 0 0 3 3h3"}),t.jsx("line",{x1:"18",y1:"9",x2:"18",y2:"15"})]})}function Lf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function Df(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("rect",{x:"4",y:"5",width:"6",height:"6",rx:"1.5"}),t.jsx("rect",{x:"14",y:"5",width:"6",height:"6",rx:"1.5"}),t.jsx("rect",{x:"4",y:"13",width:"6",height:"6",rx:"1.5"}),t.jsx("path",{d:"M14 16l2 2 4-4"})]})}function _f(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("rect",{x:"4",y:"6",width:"10",height:"12",rx:"2"}),t.jsx("path",{d:"M10 12h8"}),t.jsx("path",{d:"M15 8l4 4-4 4"})]})}function Ff({selected:e}){return e?t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"}),t.jsx("path",{d:"M8 12.5l2.8 2.8L16.5 9.5"})]}):t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"})})}function Jl({active:e,className:n}){return e?t.jsx("svg",{className:n,width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.5",children:t.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})}):t.jsx("svg",{className:n,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:t.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})})}function Of(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("path",{d:"M3 7h18"}),t.jsx("path",{d:"M5 7l1 12h12l1-12"}),t.jsx("path",{d:"M9 11h6"}),t.jsx("path",{d:"M8 4h8l1 3H7l1-3z"})]})}function Hf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("path",{d:"M12 20h9"}),t.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}function Uf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M8 6V4h8v2"}),t.jsx("path",{d:"M6 6l1 14h10l1-14"}),t.jsx("path",{d:"M10 11v5"}),t.jsx("path",{d:"M14 11v5"})]})}function $f(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[t.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),t.jsx("path",{d:"M9 13h6"})]})}function qf(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[t.jsx("circle",{cx:"12",cy:"12",r:"9"}),t.jsx("path",{d:"M9.7 9.4a2.5 2.5 0 1 1 4.1 2c-.8.7-1.8 1.2-1.8 2.6",strokeLinecap:"round"}),t.jsx("circle",{cx:"12",cy:"17.2",r:"1",fill:"currentColor",stroke:"none"})]})}function Gf({open:e,mode:n,keyword:s,codeWorkspaceId:i,codeResults:o,codeLoading:c,codeError:h,workspaceOptions:f,sessionResults:k,onClose:p,onModeChange:g,onKeywordChange:N,onCodeWorkspaceChange:C,onCodeSearch:I,onOpenSession:H}){const U=s.trim().length>0&&i.trim().length>0;return t.jsx(Ue,{open:e,title:r("shell.searchModalTitle"),description:r("shell.searchModalDescription"),onClose:p,children:t.jsxs("div",{className:"workbench-search-modal",children:[t.jsxs("div",{className:"workbench-search-mode-switch",role:"tablist","aria-label":r("shell.searchModeLabel"),children:[t.jsx("button",{type:"button",className:n==="sessions"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":n==="sessions",onClick:()=>g("sessions"),children:r("shell.searchModeSessions")}),t.jsx("button",{type:"button",className:n==="code"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":n==="code",onClick:()=>g("code"),children:r("shell.searchModeCode")})]}),n==="sessions"?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.searchKeywordLabel")}),t.jsx("input",{type:"text",value:s,placeholder:r("shell.searchSessionPlaceholder"),autoFocus:!0,onChange:A=>N(A.target.value)})]}),t.jsx("div",{className:"workbench-search-results",children:s.trim().length===0?t.jsx("p",{className:"workbench-search-empty",children:r("shell.searchSessionHint")}):k.length>0?k.map(A=>{const x=oo(A.session.title,r("common.unknown"));return t.jsxs("button",{type:"button",className:"workbench-search-result-item",onClick:()=>H(A.session.sessionId),children:[t.jsx("span",{className:"workbench-search-result-title",title:x.fullTitle,children:x.displayTitle}),t.jsxs("span",{className:"workbench-search-result-meta",children:[A.workspace.name," · ",ri(A.session.provider,"full")]})]},A.session.sessionId)}):t.jsx("p",{className:"workbench-search-empty",children:r("shell.searchSessionEmpty")})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.searchWorkspaceLabel")}),t.jsx("select",{value:i,onChange:A=>C(A.target.value),children:f.map(A=>t.jsx("option",{value:A.id,children:A.name},A.id))})]}),t.jsxs("form",{className:"workbench-search-code-form",onSubmit:A=>{A.preventDefault(),I()},children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.searchKeywordLabel")}),t.jsx("input",{type:"text",value:s,placeholder:r("shell.searchCodePlaceholder"),autoFocus:!0,onChange:A=>N(A.target.value)})]}),t.jsx("button",{type:"submit",className:"primary-button",disabled:!U||c,children:c?r("common.loading"):r("shell.searchSubmit")})]}),t.jsxs("div",{className:"workbench-search-results",children:[h?t.jsx("p",{className:"status-text","data-tone":"error",children:h}):null,!h&&s.trim().length===0?t.jsx("p",{className:"workbench-search-empty",children:r("shell.searchCodeHint")}):null,!h&&s.trim().length>0&&!c&&o.length===0?t.jsx("p",{className:"workbench-search-empty",children:r("shell.searchCodeEmpty")}):null,o.map(A=>t.jsxs("div",{className:"workbench-search-result-item static",children:[t.jsx("span",{className:"workbench-search-result-title",children:A.name}),t.jsx("span",{className:"workbench-search-result-meta",children:A.path})]},`${A.path}-${A.kind}`))]})]})]})})}function Kf({menuKey:e,session:n,workspace:s,workspaceContext:i,isActive:o,isFavorite:c,menuOpen:h,menuAnchorPoint:f,showWorkspaceName:k,depth:p=0,showActions:g=!0,hasSubagents:N=!1,subagentListExpanded:C=!1,selectionMode:I=!1,selected:H=!1,onToggleSelect:U,onToggleSubagents:A,onOpen:x,onRename:P,onOpenContextMenu:_,onToggleFavorite:Y,onArchive:R,onDelete:K,onCloseMenu:V}){var oe;const G=Tn(),j=qa(n.provider).supportsSessionDelete===!0,Z=_i(n)?((oe=n.subagentLabel)==null?void 0:oe.trim())||r("shell.subagentBadge"):null,ee=oo(n.title,r("common.unknown")),E=tf(n),ue=E?nf(E):null,$=mu(n),ce=$?pu("session-activity-badge",n):null,D=io(n),v=xu(n),S=l.useRef(null),[J,ke]=l.useState(null);l.useLayoutEffect(()=>{if(G.isDesktop||!h||!f||typeof window>"u"){ke(null);return}const ae=()=>{var be,me;const he=Mu(f,{width:((be=S.current)==null?void 0:be.offsetWidth)??0,height:((me=S.current)==null?void 0:me.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:j&&K?216:168});ke({position:"fixed",top:`${Math.round(he.top)}px`,left:`${Math.round(he.left)}px`,width:`${Math.round(he.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(he.maxHeight)}px`,transformOrigin:he.transformOrigin})};return ae(),window.addEventListener("resize",ae),window.addEventListener("scroll",ae,!0),()=>{window.removeEventListener("resize",ae),window.removeEventListener("scroll",ae,!0)}},[f,h,G.isDesktop]);async function we(){await Hc([{id:`rename:${n.sessionId}`,label:r("shell.renameAction"),onSelect:P},{id:`favorite:${n.sessionId}`,label:c?r("shell.unfavoriteAction"):r("shell.favoriteAction"),onSelect:Y},{id:`archive:${n.sessionId}`,label:r("shell.archiveAction"),onSelect:R},...j&&K?[{id:`delete:${n.sessionId}`,label:r("shell.deleteSessionAction"),onSelect:K}]:[]])}const se=!G.isDesktop&&h&&typeof document<"u"?tr.createPortal(t.jsxs("div",{ref:S,className:"workbench-session-menu","data-menu-key":e,role:"menu","aria-label":r("shell.sessionMoreAction"),onClick:ae=>ae.stopPropagation(),style:J??{position:"fixed",top:0,left:0,visibility:"hidden"},children:[t.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{P(),V()},children:[t.jsx(Hf,{}),t.jsx("span",{children:r("shell.renameAction")})]}),t.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{Y(),V()},children:[t.jsx(Jl,{active:c}),t.jsx("span",{children:c?r("shell.unfavoriteAction"):r("shell.favoriteAction")})]}),t.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{R(),V()},children:[t.jsx(Of,{}),t.jsx("span",{children:r("shell.archiveAction")})]}),j&&K?t.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{K(),V()},children:[t.jsx(Uf,{}),t.jsx("span",{children:r("shell.deleteSessionAction")})]}):null]}),document.body):null;return t.jsxs("article",{className:"workbench-session-card","data-active":o,"data-depth":p,"data-subagent":_i(n),"data-workspace-tone":i.tone,"data-worktree-depth":i.depth,"data-has-subagents":N,"data-selecting":I,"data-selected":H,style:tn(i),onContextMenu:ae=>{if(!(I||!g||!_)){if(ae.preventDefault(),ae.stopPropagation(),G.isDesktop){we();return}_({x:ae.clientX,y:ae.clientY})}},children:[t.jsxs("div",{className:"workbench-session-main",children:[I?t.jsx("span",{className:"workbench-session-selection-indicator","data-selected":H,"aria-hidden":"true",children:t.jsx(Ff,{selected:H})}):N?t.jsxs("button",{type:"button",className:"workbench-session-subagent-toggle",style:rf,"data-indicator-variant":of(n,{hasSubagents:!0,isActive:o}),"aria-label":C?r("shell.subagentCollapse"):r("shell.subagentExpand"),title:C?r("shell.subagentCollapse"):r("shell.subagentExpand"),"aria-expanded":C,onClick:ae=>{ae.stopPropagation(),A==null||A()},children:[t.jsx("span",{className:ga(n,{hasSubagents:!0,isActive:o}),"data-activity-source":n.activitySource,"aria-hidden":"true"}),t.jsx("span",{className:"workbench-session-subagent-toggle-icon","aria-hidden":"true",children:t.jsx(Xs,{expanded:C})})]}):t.jsx("span",{className:ga(n,{isActive:o}),"data-activity-source":n.activitySource,"aria-hidden":"true"}),t.jsx("button",{type:"button",className:"workbench-session-link",style:N?sf:void 0,"data-active":o,"aria-pressed":I?H:void 0,onClick:I?U:x,onKeyDown:ae=>{if(I||!g||!_||ae.key!=="ContextMenu"&&!(ae.shiftKey&&ae.key==="F10"))return;if(ae.preventDefault(),ae.stopPropagation(),G.isDesktop){we();return}const he=ae.currentTarget.getBoundingClientRect();_({x:he.right,y:he.bottom})},children:t.jsxs("div",{className:"workbench-session-link-copy",children:[t.jsxs("div",{className:"session-title-row",children:[t.jsx("span",{className:"session-title",title:ee.fullTitle,children:ee.displayTitle}),Z?t.jsx("span",{className:"session-subagent-badge",children:Z}):null,v&&D?t.jsx("span",{className:`session-fork-badge ${D}`,children:v}):null]}),t.jsxs("div",{className:"session-meta-row",children:[t.jsx("span",{className:"session-meta",children:El(n,s,k,i.displayName)}),$&&ce?t.jsx("span",{className:ce,children:$}):null,t.jsx("span",{className:`session-provider-badge ${n.provider}`,children:ri(n.provider)})]}),ue?t.jsx("div",{className:"session-error-row",title:E??void 0,children:t.jsx("span",{className:"session-error-text",children:ue})}):null]})})]}),se]})}function Ma({workspaceGroups:e,workspaceVisualContextMap:n,sessionDisplaySortMode:s,favoriteSessions:i,favoriteSessionIds:o,activeWorkspaceId:c,isConversationActive:h,isTerminalActive:f,isButlerActive:k,isSearchOpen:p,navigationLoading:g,navigationError:N,activeSessionId:C,onRefreshNavigation:I,onSessionUpdated:H,onNavigateConversation:U,onNavigateTerminals:A,onNavigateButler:x,onOpenSearch:P,onOpenSettings:_,onSelectWorkspace:Y,onToggleWorkspaceCollapse:R,onStartWorkspaceReorder:K,onPreviewWorkspaceReorder:V,onCommitWorkspaceReorder:G,allowWorkspaceReorder:j,subscribeGitSnapshot:Z,requestGitRefresh:ee,subscribeWorkspaceManagementSnapshot:E,requestWorkspaceManagementRefresh:ue,onToggleFavoriteSession:$,onArchiveSession:ce,onUnarchiveSession:D,workspaceManagementStateById:v,setWorkspaceManagementStateById:S,unreadNotificationCount:J,notificationPanelOpen:ke,onToggleNotificationPanel:we,onClose:se,onToggleCollapse:oe}){var Gn;const ae=er(),he=Tn(),be=ul(he),{showToast:me}=Xn(),Ge=Hi(d=>d),Ee=((Gn=_a(Ge))==null?void 0:Gn.name)??"",F=Ge.hosts.length+Fa(Ge).length>1&&Ee.length>0,[y,q]=l.useState(!1),[le,O]=l.useState(!1),[We,ut]=l.useState(!1),[De,Wt]=l.useState([]),[Je,gt]=l.useState(null),[_e,ir]=l.useState(null),[lt,or]=l.useState(null),[Fe,Yn]=l.useState(null),[Te,Kt]=l.useState(null),[ct,Cs]=l.useState(null),[At,zt]=l.useState(!1),[Ze,In]=l.useState(!1),[wt,Rn]=l.useState(""),[Ts,rn]=l.useState(""),[Jn,xe]=l.useState(""),[Vt,Pe]=l.useState({localBranches:[],remoteBranches:[],tags:[]}),[Qe,Ke]=l.useState(!1),[Is,et]=l.useState(-1),[Mn,En]=l.useState(!1),[Zn,Wn]=l.useState(!1),[Pt,An]=l.useState(null),[xt,Rs]=l.useState(null),[oi,Pn]=l.useState(null),[ai,Xt]=l.useState(null),[Bn,vt]=l.useState(null),[on,ar]=l.useState(null),[Yt,an]=l.useState(null),[Qn,lr]=l.useState(null),[li,tt]=l.useState(Ti),[yt,je]=l.useState({}),[es,ln]=l.useState({}),[Ln,cn]=l.useState([]),[dn,Jt]=l.useState({expandedWorkspaceIds:[],collapsedWorkspaceIds:[]}),[nt,St]=l.useState(null),[jt,Zt]=l.useState(""),[un,cr]=l.useState(null),[it,Bt]=l.useState(null),[Nt,st]=l.useState([]),[Dn,ts]=l.useState(!1),[Ms,ns]=l.useState({}),[ze,ot]=l.useState(null),Ve=l.useRef(null),Ct=l.useRef(null),Lt=l.useRef(null),ss=l.useRef(new Map),hn=l.useRef(null),fn=l.useRef(null),ht=l.useRef(null),dr=l.useMemo(()=>new Set(dn.expandedWorkspaceIds),[dn.expandedWorkspaceIds]),rs=l.useMemo(()=>new Set(dn.collapsedWorkspaceIds),[dn.collapsedWorkspaceIds]),_n=ze!==null,Tt=j&&he.isDesktop&&he.ui.osFamily==="macos",Xe=l.useCallback(()=>{an(null),lr(null)},[]),ur=l.useCallback((d,m)=>{an(d),lr(m)},[]),Ie=ja(e,Te)??((ct==null?void 0:ct.id)===Te?ct:null),Es=Jn.trim().toLowerCase(),mn=l.useMemo(()=>[{key:"localBranches",label:r("shell.createWorktreeBaseRefLocalGroup"),items:Vt.localBranches},{key:"remoteBranches",label:r("shell.createWorktreeBaseRefRemoteGroup"),items:Vt.remoteBranches},{key:"tags",label:r("shell.createWorktreeBaseRefTagGroup"),items:Vt.tags}].map(m=>({...m,items:m.items.filter(w=>Es?w.value.toLowerCase().includes(Es):!0)})).filter(m=>m.items.length>0),[Es,Vt]),dt=l.useMemo(()=>mn.flatMap(d=>d.items),[mn]),Ws=Ie?`create-worktree-base-ref-listbox-${Ie.id}`:"create-worktree-base-ref-listbox",ft=ff(e,ai),Ye=ft?gn(ft.workspace):null,pn=l.useMemo(()=>hf(e,it),[it,e]),is=l.useMemo(()=>pn?Jh(pn.visibleSessionTree):[],[pn]),pe=l.useMemo(()=>is.map(d=>d.sessionId),[is]),rt=l.useMemo(()=>new Set(pe),[pe]),Re=l.useMemo(()=>new Set(Nt),[Nt]),hr=pe.length>0&&Nt.length===pe.length;l.useEffect(()=>{S(d=>{const m=Na(e),w=new Set(m),M={};Object.entries(d).forEach(([X,ve])=>{w.has(X)&&(M[X]=ve)}),m.forEach(X=>{const ve=ja(e,X);if(!ve)return;const Oe=Jr(Oi(X),da),Ae=Jr(ql(X),da),$e=M[X];let Rt=Kl(($e==null?void 0:$e.detail)??Oe??Gl(ve),ve);(Ae!=null&&Ae.status||Ae!=null&&Ae.branches)&&(Rt=zl(Rt,{status:Ae.status??null,branches:Ae.branches??null})),M[X]={detail:Rt,loading:!1,error:null}});const W=Object.keys(d),ne=Object.keys(M);return W.length===ne.length&&ne.every(X=>d[X]===M[X])?d:M})},[e]);const os=l.useCallback(async d=>{await I(),await he.bridge.showNotification(r("shell.importSuccess"),d.path)},[I,he.bridge]),as=l.useCallback(async d=>{await I(),await he.bridge.showNotification(r("shell.cloneSuccess"),d.path)},[I,he.bridge]);function Dt(d){if(De.includes(d)){Wt(w=>w.filter(M=>M!==d));return}Wt(w=>[...w,d]),Z(d),ee(d),E(d),ue(d)}async function Fn(d,m){if(Ms[d])return;const w=(m==null?void 0:m.trim().toUpperCase())??null;ns(M=>({...M,[d]:!0}));try{await Ua(d,{backgroundColor:w}),await I()}catch(M){me({title:M instanceof Error?M.message:r("shell.manageWorkspaceColorSaveFailed"),tone:"error"})}finally{ns(M=>({...M,[d]:!1}))}}async function fr(){if(!(!Je||_e)){ir(Je.id);try{await Ac(Je.id),Wt(d=>d.filter(m=>m!==Je.id)),S(d=>{const m={...d};return delete m[Je.id],m}),gt(null),await I(),me({title:r("shell.manageWorkspaceRemoveSuccess"),tone:"success"})}catch(d){me({title:d instanceof Error?d.message:r("shell.manageWorkspaceRemoveFailed"),tone:"error"})}finally{ir(null)}}}l.useEffect(()=>{if(!Yt)return;function d(m){const w=m.target;w instanceof HTMLElement&&w.closest(".workbench-session-menu")||Xe()}return window.addEventListener("pointerdown",d),()=>{window.removeEventListener("pointerdown",d)}},[Xe,Yt]),l.useEffect(()=>{if(!it){Nt.length>0&&st([]);return}if(!pn){Bt(null),st([]);return}st(d=>Ol(d,rt))},[pn,rt,it,Nt.length]),l.useEffect(()=>{it&&pe.length===0&&(Bt(null),st([]))},[pe.length,it]),l.useEffect(()=>{const d=new Set(Na(e)),m=new Set(e.flatMap(w=>Fi(w.childWorktrees)));Wt(w=>w.filter(M=>d.has(M))),Jt(w=>({expandedWorkspaceIds:w.expandedWorkspaceIds.filter(M=>m.has(M)),collapsedWorkspaceIds:w.collapsedWorkspaceIds.filter(M=>m.has(M))})),gt(w=>w&&d.has(w.id)?w:null),ns(w=>Object.fromEntries(Object.entries(w).filter(([M,W])=>W&&d.has(M))))},[e]),l.useEffect(()=>{const d=i.findIndex(m=>m.session.sessionId===C);tt(m=>{const w=$r(i.length,Ti,m,d);return w===m?m:w})},[C,i]),l.useEffect(()=>{je(d=>{const m={};for(const w of e){const M=zs(w),W=M.findIndex(ne=>ne.item.sessionId===C||ks([ne],C??"",X=>X.sessionId).length>0);m[w.workspace.id]=$r(M.length,Gs,d[w.workspace.id],W);for(const ne of Vs(w.childWorktrees)){ne.item.sessionId===C||ks([ne],C??"",Ae=>Ae.sessionId).length>0;const X=ne.item.workspaceId;if(m[X]!==void 0)continue;const ve=Vs(w.childWorktrees).filter(Ae=>Ae.item.workspaceId===X&&Ae.depth===0),Oe=ve.findIndex(Ae=>Ae.item.sessionId===C||ks([Ae],C??"",$e=>$e.sessionId).length>0);m[X]=$r(ve.length,Gs,d[X],Oe)}}return ka(d,m)?d:m})},[C,e]),l.useEffect(()=>{ln(d=>{const m={};for(const w of e)for(const M of[...zs(w),...Vs(w.childWorktrees)])for(const W of Sn(Et(M))){const ne=Et(W);if(ne.length===0)continue;const X=Sn(ne),ve=X.findIndex(Oe=>Oe.item.sessionId===C);m[W.item.sessionId]=$r(X.length,Hr,d[W.item.sessionId],ve)}return ka(d,m)?d:m})},[C,e]),l.useEffect(()=>{if(!C)return;const d=e.flatMap(m=>[...ks(zs(m),C,w=>w.sessionId),...Vs(m.childWorktrees).flatMap(w=>ks([w],C,M=>M.sessionId))]);d.length!==0&&cn(m=>{const w=new Set(m);let M=!1;for(const W of d)w.has(W)||(w.add(W),M=!0);return M?Array.from(w):m})},[C,e]),l.useEffect(()=>{if(!c)return;const d=[];for(const m of e){const w=_l(m.childWorktrees,c);w.length!==0&&d.push(...w)}d.length>0&&Jt(m=>{const w=new Set(m.expandedWorkspaceIds);let M=!1;for(const W of d)w.has(W)||(w.add(W),M=!0);return M?{expandedWorkspaceIds:Array.from(w),collapsedWorkspaceIds:m.collapsedWorkspaceIds}:m})},[c,e]),l.useEffect(()=>{if(!Te){Cs(null),zt(!1),In(!1),Rn(""),rn(""),xe(""),Ke(!1),et(-1),En(!1),Pe({localBranches:[],remoteBranches:[],tags:[]}),Wn(!1),An(null);return}zt(!1),Rn(""),rn(""),xe(""),Ke(!1),et(-1),En(!1),Pe({localBranches:[],remoteBranches:[],tags:[]}),Wn(!1),An(null)},[Te]),l.useEffect(()=>{const d=Ie;if(!At||!d)return;let m=!1;const w=d.id;return Wn(!0),An(null),Promise.all([Fc(w),Oc(w)]).then(([M,W])=>{m||Pe(Dh(M,W))}).catch(()=>{m||(Pe({localBranches:[],remoteBranches:[],tags:[]}),An(r("shell.createWorktreeBaseRefLoadFailed")))}).finally(()=>{m||Wn(!1)}),()=>{m=!0}},[Ie==null?void 0:Ie.id,At]),l.useLayoutEffect(()=>{if(!Qe||!Ve.current){Rs(null),Pn(null);return}const d=()=>{const w=Ve.current;if(!w)return;const M=_h(w);Rs({top:M.bottom+8,left:M.left,width:M.width})};d();const m=w=>{var W,ne;const M=w.target;M instanceof Node&&((W=Ve.current)!=null&&W.contains(M)||(ne=Ct.current)!=null&&ne.contains(M)||(Ke(!1),et(-1)))};return window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),window.addEventListener("pointerdown",m),()=>{window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0),window.removeEventListener("pointerdown",m)}},[dt.length,Qe]),l.useLayoutEffect(()=>{if(!Qe||!Ct.current){Pn(null);return}const d=Ct.current,m=()=>{const M=Math.ceil(d.getBoundingClientRect().height);Pn(W=>W===M?W:M)};if(m(),typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>{m()});return w.observe(d),()=>{w.disconnect()}},[Qe,mn,Zn,Pt]);function As(){q(!0)}function Ps(){O(!0)}function ls(){zt(!1),Rn(""),rn(""),xe(""),Ke(!1),et(-1),En(!1)}function bn(d,m){const w=d.getBoundingClientRect();return m<=w.top+w.height/2?"before":"after"}function Le(){Lt.current!==null&&(cancelAnimationFrame(Lt.current),Lt.current=null),ot(null)}function mt(d){const m=(d==null?void 0:d.commit)??!1,w=(d==null?void 0:d.preserveClickSuppression)??!1,M=hn.current,W=fn.current;hn.current=null,fn.current=null,W==null||W(),M!=null&&M.dragging&&(Le(),m&&G(),!w&&ht.current===M.workspaceId&&(ht.current=null))}function cs(d){if(ht.current===d){ht.current=null;return}R(d)}function Bs(d,m){if(m){ss.current.set(d,m);return}ss.current.delete(d)}function Ls(d,m){for(const[w,M]of ss.current){const W=M.getBoundingClientRect();if(d>=W.left&&d<=W.right&&m>=W.top&&m<=W.bottom)return{workspaceId:w,element:M}}return null}function re(d,m){var ve;if(!Tt||d.button!==0)return;mt();const w=d.currentTarget,M={pointerId:d.pointerId,workspaceId:m,startX:d.clientX,startY:d.clientY,pointerTarget:w,dragging:!1};hn.current=M,(ve=w.setPointerCapture)==null||ve.call(w,d.pointerId);const W=Oe=>{Ds(Oe)},ne=Oe=>{kn(Oe.pointerId,{commit:!0,preserveClickSuppression:!0})},X=Oe=>{kn(Oe.pointerId,{commit:!1,preserveClickSuppression:!1})};fn.current=()=>{w.removeEventListener("pointermove",W),w.removeEventListener("pointerup",ne),w.removeEventListener("pointercancel",X),window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",ne),window.removeEventListener("pointercancel",X)},w.addEventListener("pointermove",W),w.addEventListener("pointerup",ne),w.addEventListener("pointercancel",X),window.addEventListener("pointermove",W,{passive:!1}),window.addEventListener("pointerup",ne),window.addEventListener("pointercancel",X)}function Ds(d){const m=hn.current;if(!m||m.pointerId!==d.pointerId)return;if(!m.dragging){if(Math.hypot(d.clientX-m.startX,d.clientY-m.startY)<yh)return;m.dragging=!0,ht.current=m.workspaceId,K(),ot(m.workspaceId)}d.preventDefault();const w=Ls(d.clientX,d.clientY);!w||w.workspaceId===m.workspaceId||V(m.workspaceId,w.workspaceId,bn(w.element,d.clientY))}function kn(d,m){var M,W;const w=hn.current;!w||w.pointerId!==d||((W=(M=w.pointerTarget).releasePointerCapture)==null||W.call(M,d),mt(m))}function ds(d){Ds(d)}function On(d){kn(d.pointerId,{commit:!0,preserveClickSuppression:!0})}function ci(d){kn(d.pointerId,{commit:!1,preserveClickSuppression:!1})}function Hn(d,m){d.dataTransfer.effectAllowed="move",d.dataTransfer.setData("text/plain",m),K(),Lt.current!==null&&cancelAnimationFrame(Lt.current),Lt.current=requestAnimationFrame(()=>{Lt.current=null,ot(m)})}function pt(d,m){const w=ze||d.dataTransfer.getData("text/plain");!w||w===m||(d.preventDefault(),d.dataTransfer.dropEffect="move",V(w,m,bn(d.currentTarget,d.clientY)))}function Be(d){d.preventDefault()}function Un(){Le(),G()}l.useEffect(()=>()=>{mt()},[]);function mr(d){return es[d]??Hr}function _s(d){return Ln.includes(d)}function bt(d){return yt[d]??Gs}function pr(){tt(d=>Math.min(i.length,d+Ti))}function $n(d,m){je(w=>({...w,[d]:Math.min(m,(w[d]??Gs)+Gs)}))}function It(d){ln(m=>({...m,[d]:(m[d]??Hr)+Hr}))}function br(d){cn(m=>m.includes(d)?m.filter(w=>w!==d):[...m,d])}function qn(d,m){return rs.has(d)?!1:m||dr.has(d)}function Fs(d,m){const w=!qn(d,m);Jt(M=>{const W=M.expandedWorkspaceIds.filter(X=>X!==d),ne=M.collapsedWorkspaceIds.filter(X=>X!==d);return w?{expandedWorkspaceIds:[...W,d],collapsedWorkspaceIds:ne}:{expandedWorkspaceIds:W,collapsedWorkspaceIds:[...ne,d]}})}function di(d){for(const m of e){const w=Sn(uo(m.visibleSessions,s)).find(M=>M.item.sessionId===d)??Pl(m.childWorktrees,d);if(w)return Et(w)}return[]}function kr(d,m){const w=gn(d);return t.jsxs("button",{type:"button",className:"workbench-archive-folder","data-workspace-tone":w.tone,style:tn(w),onClick:()=>Xt(d.id),children:[t.jsxs("span",{className:"workbench-archive-folder-main",children:[t.jsx($f,{}),t.jsx("span",{children:r("shell.archiveFolderLabel")})]}),t.jsx("span",{className:"workbench-section-counter",children:m.length})]})}function Os(){return t.jsxs("div",{className:"workbench-workspace-batch-toolbar",children:[t.jsx("span",{className:"workbench-workspace-batch-label",children:r("shell.batchSelectionMode")}),t.jsxs("span",{className:"workbench-workspace-batch-counter",children:[Nt.length,"/",pe.length]}),t.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:mi,children:hr?r("shell.clearSelectedSessions"):r("shell.selectAllSessions")}),t.jsx("button",{type:"button",className:"workbench-workspace-batch-action primary",disabled:Nt.length===0||Dn,onClick:()=>{vr()},children:Dn?r("shell.batchArchiving"):r("shell.batchArchiveAction")}),t.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:hi,children:r("common.cancel")})]})}function gr(d,m="workbench-workspace-actions"){return t.jsxs("div",{className:m,children:[t.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.switchWorkspace"),title:r("shell.switchWorkspace"),"aria-pressed":c===d,onClick:()=>{Y(d),se==null||se()},children:t.jsx(_f,{})}),t.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.batchSelectSessions"),title:r("shell.batchSelectSessions"),onClick:()=>ui(d),children:t.jsx(Df,{})}),t.jsx("button",{type:"button",className:"workbench-workspace-icon-button workbench-workspace-create","aria-label":r("shell.createSession"),title:r("shell.createSession"),onClick:()=>Kt(d),children:t.jsx(Rf,{})})]})}function wr(d){const m=d.visibleSessionTree,M=new Set(Fi(d.children)).has(c??""),W=d.workspace.id===c||M,ne=_n||!qn(d.workspace.id,W),X=gn(d.workspace);return t.jsxs("section",{className:"workbench-workspace-group","data-worktree-node":"true","data-batch-active":it===d.workspace.id,"data-worktree-depth":d.meta.depth,"data-workspace-tone":"worktree",style:tn(X),children:[t.jsxs("div",{className:"workbench-workspace-header minimal",children:[t.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":ne?r("shell.worktreeExpand"):r("shell.worktreeCollapse"),onClick:()=>Fs(d.workspace.id,W),children:[t.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:t.jsx(Xs,{expanded:!ne})}),t.jsxs("span",{children:[t.jsx("strong",{children:d.meta.displayName||d.workspace.name}),t.jsx("span",{className:"session-meta",children:d.meta.branchName})]})]}),it===d.workspace.id?Os():gr(d.workspace.id)]}),ne?null:t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"workbench-session-list","data-workspace-tone":X.tone,style:tn(X),children:[m.length===0?t.jsx("p",{className:"workbench-session-empty",children:r("shell.emptyWorkspaceSessions")}):m.slice(0,bt(d.workspace.id)).map(ve=>us({node:ve,workspace:d.workspace,workspaceContext:X,menuKeyPrefix:`worktree:${d.workspace.id}`,showWorkspaceName:!1,selectionMode:it===d.workspace.id,favoriteEnabled:!0})),m.length>bt(d.workspace.id)?t.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>$n(d.workspace.id,m.length),children:r("shell.sessionExpandMore")}):null]}),d.children.length>0?t.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:d.children.map(ve=>wr(ve))}):null,kr(d.workspace,d.archivedSessions)]})]},d.workspace.id)}function us(d){const{node:m,workspace:w,workspaceContext:M,menuKeyPrefix:W,showWorkspaceName:ne,selectionMode:X,favoriteEnabled:ve,ancestorExpanded:Oe=!1,allowToggle:Ae=m.depth===0,ancestorHasNextSiblings:$e=[],hasNextSibling:Rt=!1,isFirstSibling:_t=!1}=d,Ne=m.item,wn=Et(m),Ft=Oe||_s(Ne.sessionId),Ce=Ft&&Ae,Cr=Ce?Zh(m,mr(Ne.sessionId),s):m,ms=Ft?Et(Cr):[],Tr=Sn(wn).length,Ir=Sn(ms).length,Rr=Ce&&Ir<Tr,Mr=m.depth>0?[...$e,Rt]:[...$e];return t.jsxs("div",{className:"workbench-session-tree-node",children:[t.jsxs("div",{className:"workbench-session-tree-row",style:{"--workbench-session-tree-depth":m.depth},children:[m.depth>0?t.jsxs("div",{className:"workbench-session-tree-guides","aria-hidden":"true",children:[$e.map((xn,vn)=>xn?t.jsx("span",{className:"workbench-session-tree-guide-column",style:{"--workbench-session-tree-level":vn+1}},`${Ne.sessionId}:ancestor:${vn}`):null),t.jsx("span",{className:"workbench-session-tree-guide-branch","data-continue":Rt,"data-first":_t,style:{"--workbench-session-tree-level":m.depth},children:t.jsx("span",{className:"workbench-session-tree-guide-branch-horizontal"})})]}):null,t.jsx(Kf,{menuKey:`${W}:${Ne.sessionId}`,session:Ne,workspace:w,workspaceContext:M,isActive:Ne.sessionId===C,isFavorite:ve&&o.has(Ne.sessionId),menuOpen:Yt===`${W}:${Ne.sessionId}`,showWorkspaceName:ne,depth:m.depth,showActions:ve,hasSubagents:Ae&&wn.length>0,subagentListExpanded:Ft,selectionMode:X,selected:Re.has(Ne.sessionId),onToggleSelect:()=>fi(Ne.sessionId),onToggleSubagents:()=>br(Ne.sessionId),onOpen:()=>{ae($t(w.id,Ne.sessionId)),se==null||se()},onRename:()=>Hs(Ne,w),menuAnchorPoint:Yt===`${W}:${Ne.sessionId}`?Qn:null,onOpenContextMenu:xn=>ur(`${W}:${Ne.sessionId}`,xn),onToggleFavorite:()=>hs(Ne.sessionId),onArchive:()=>fs(Ne.sessionId),onDelete:qa(Ne.provider).supportsSessionDelete===!0?()=>{Xe(),vt({session:Ne,workspace:w})}:void 0,onCloseMenu:Xe})]}),wn.length>0&&Ft?t.jsxs("div",{className:"workbench-subsession-list",children:[ms.map((xn,vn)=>us({node:xn,workspace:w,workspaceContext:M,menuKeyPrefix:W,showWorkspaceName:ne,selectionMode:X,favoriteEnabled:ve,ancestorExpanded:!0,allowToggle:!1,ancestorHasNextSiblings:Mr,hasNextSibling:vn<ms.length-1,isFirstSibling:vn===0})),Rr?t.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>It(Ne.sessionId),children:r("shell.subagentExpandMore")}):null]}):null]},Ne.sessionId)}function ui(d){Xe(),Bt(d),st([])}function hi(){Bt(null),st([])}function fi(d){st(m=>xf(m,d))}function mi(){st(d=>d.length===pe.length?[]:pe)}async function pi(d,m){or(d),Yn(m);try{await Tl(d,m),Kt(null),ae(sl(d,m)),se==null||se()}catch(w){me({title:w instanceof Error?w.message:r("shell.startSessionFailed"),tone:"error"})}finally{or(null),Yn(null)}}async function Qt(d){if(d.preventDefault(),!Ie||Ze)return;const m=wt.trim(),w=Ts.trim(),M=Jn.trim();if(!m){me({title:r("shell.createWorktreeBranchRequired"),tone:"error"});return}if(!Bh(m)){me({title:r("shell.createWorktreeBranchInvalid"),tone:"error"});return}In(!0);try{const W=await Pc({sourceWorkspaceId:Ie.id,branchName:m,displayName:w||void 0,baseRef:M||void 0});Cs(W.workspace),Y(W.workspace.id),await I(),Kt(W.workspace.id),ls(),me({title:r("shell.createWorktreeSucceeded",{name:W.meta.displayName||W.workspace.name}),tone:"success"})}catch(W){me({title:W instanceof Error?W.message:r("shell.createWorktreeFailed"),tone:"error"})}finally{In(!1)}}async function hs(d){const m=o.has(d);Xe();try{await $(d),me({title:m?r("shell.favoriteRemoved"):r("shell.favoriteAdded"),tone:"success"})}catch(w){me({title:w instanceof Error?w.message:r("shell.favoriteToggleFailed"),tone:"error"})}}async function fs(d){Xe();try{await ce(d),me({title:r("shell.archiveAdded"),tone:"success"})}catch(m){me({title:m instanceof Error?m.message:r("shell.navigationLoadFailed"),tone:"error"})}}async function xr(){if(!Bn||on)return;const{session:d,workspace:m}=Bn;ar(d.sessionId),Xe();try{await Wc(d.sessionId),st(w=>w.filter(M=>M!==d.sessionId)),vt(null),C===d.sessionId&&ae(m.id?Qs(m.id):at()),await I(),me({title:r("shell.deleteSessionSuccess"),tone:"success"})}catch(w){me({title:w instanceof Error?w.message:r("shell.deleteSessionFailed"),tone:"error"})}finally{ar(null)}}async function vr(){if(!(Nt.length===0||Dn)){Xe(),ts(!0);try{const d=[...Nt],m=await Promise.allSettled(d.map(async W=>({sessionId:W,session:await Ha(W,!0)}))),w=[];let M=0;for(const W of m){if(W.status==="fulfilled"){w.push(W.value.sessionId),H(W.value.session);continue}M+=1}w.length>0&&(await I(),st(W=>W.filter(ne=>!w.includes(ne)))),M>0?me({title:w.length>0?r("shell.batchArchivePartialFailed"):r("shell.batchArchiveFailed"),tone:"error"}):me({title:r("shell.batchArchiveSuccess"),tone:"success"})}catch(d){me({title:d instanceof Error?d.message:r("shell.batchArchiveFailed"),tone:"error"})}finally{ts(!1)}}}async function yr(d){Xe();try{await D(d),me({title:r("shell.archiveRestored"),tone:"success"})}catch(m){me({title:m instanceof Error?m.message:r("shell.navigationLoadFailed"),tone:"error"})}}function Hs(d,m){Xe(),St({session:d,workspace:m}),Zt(d.title)}async function Sr(d){if(d.preventDefault(),!nt)return;const m=jt.trim();if(m){cr(nt.session.sessionId);try{const w=await $a(nt.session.sessionId,m);H(w),St(null),Zt(""),me({title:r("shell.renameSuccess"),tone:"success"})}catch(w){me({title:w instanceof Error?w.message:r("shell.renameFailed"),tone:"error"})}finally{cr(null)}}}const jr=i.slice(0,li),Nr=jr.length<i.length;function gn(d){return n[d.id]??co(d)}function Us(d,m,w,M,W=[]){var Ft;const ne=De.includes(d.id),X=v[d.id]??{detail:null,loading:!1,error:null},ve=_e===d.id,Oe=Ms[d.id]===!0,Ae=(Ft=X.detail)!=null&&Ft.git.remotes.length?X.detail.git.remotes.map(Ce=>`${Ce.name}: ${Ce.url}`).join(" · "):r("shell.manageWorkspaceNoRemote"),$e=X.detail?ju(X.detail.codeComposition.items,r("shell.manageWorkspaceCodeCompositionOther")):[],Rt=$e.length>0?Cu($e):void 0,_t=gn(d),Ne=mf(_t,W),wn=[...W,_t.displayName];return t.jsxs("article",{className:"workbench-manage-item","data-workspace-tone":_t.tone,"data-worktree-node":M,style:tn(_t),children:[t.jsxs("button",{type:"button",className:"workbench-manage-item-toggle","aria-expanded":ne,onClick:()=>Dt(d.id),children:[t.jsxs("span",{className:"workbench-manage-item-heading",children:[t.jsx(Xs,{expanded:ne}),t.jsxs("span",{className:"workbench-manage-item-heading-copy",children:[t.jsx("strong",{children:_t.displayName}),t.jsx("span",{className:"workbench-manage-item-tree-path",children:Ne})]})]}),t.jsx("span",{className:"workbench-section-counter",children:m})]}),ne?t.jsxs("div",{className:"workbench-manage-item-body",children:[t.jsxs("div",{className:"workbench-manage-detail-block",children:[t.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspacePathLabel")}),t.jsx("p",{className:"workbench-manage-detail-value",children:d.path})]}),M?t.jsxs("div",{className:"workbench-manage-detail-block",children:[t.jsxs("div",{className:"workbench-manage-detail-header",children:[t.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceColorLabel")}),t.jsxs("div",{className:"workbench-manage-color-actions",children:[t.jsx("div",{className:"workbench-manage-color-palette","aria-label":r("shell.manageWorkspaceColorLabel"),children:Ch.map(Ce=>t.jsx("button",{type:"button",className:"workbench-manage-color-swatch","aria-label":r("shell.manageWorkspaceColorSelectSwatch",{color:Ce}),"aria-pressed":d.backgroundColor===Ce,disabled:Oe,"data-selected":d.backgroundColor===Ce,style:{backgroundColor:Ce},onClick:()=>{Fn(d.id,Ce)}},Ce))}),t.jsx("button",{type:"button",className:"ghost-button",disabled:Oe||!d.backgroundColor,onClick:()=>{Fn(d.id,null)},children:r("shell.manageWorkspaceColorClearAction")})]})]}),t.jsx("p",{className:"workbench-manage-hint",children:d.backgroundColor??r("shell.manageWorkspaceColorUnset")})]}):null,X.loading&&X.detail===null?t.jsx("p",{className:"workbench-manage-status status-text",children:r("shell.manageWorkspaceLoading")}):null,X.error?t.jsx("p",{className:"workbench-manage-status status-text","data-tone":"error",children:X.error}):null,X.detail?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"workbench-manage-detail-block",children:t.jsxs("div",{className:"workbench-manage-detail-header",children:[t.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceGitCommitCount")}),t.jsx("strong",{className:"workbench-manage-detail-accent",children:X.detail.git.commitCount??"--"})]})}),t.jsxs("div",{className:"workbench-manage-detail-block",children:[t.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceGitInfoLabel")}),X.detail.git.isRepository?t.jsxs("div",{className:"workbench-manage-kv-list",children:[t.jsxs("div",{className:"workbench-manage-kv-item",children:[t.jsx("span",{children:r("shell.manageWorkspaceRepoRoot")}),t.jsx("span",{children:X.detail.git.repoRoot??"--"})]}),t.jsxs("div",{className:"workbench-manage-kv-item",children:[t.jsx("span",{children:r("shell.manageWorkspaceCurrentBranch")}),t.jsx("span",{children:X.detail.git.currentBranch??"--"})]}),t.jsxs("div",{className:"workbench-manage-kv-item",children:[t.jsx("span",{children:r("shell.manageWorkspaceRemoteLabel")}),t.jsx("span",{children:Ae})]})]}):t.jsx("p",{className:"workbench-section-empty",children:X.detail.git.error??r("shell.manageWorkspaceNotGit")})]}),t.jsxs("div",{className:"workbench-manage-detail-block",children:[t.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceCodeCompositionLabel")}),$e.length>0?t.jsxs("div",{className:"workbench-manage-type-chart",children:[t.jsxs("div",{className:"workbench-manage-type-chart-ring",style:Rt,"aria-hidden":"true",children:[t.jsx("strong",{className:"workbench-manage-type-chart-total",children:X.detail.codeComposition.scannedFileCount}),t.jsx("span",{className:"workbench-manage-type-chart-caption",children:r("shell.manageWorkspaceCodeCompositionFiles")})]}),t.jsx("div",{className:"workbench-manage-type-list",children:$e.map(Ce=>t.jsxs("div",{className:"workbench-manage-type-item",children:[t.jsxs("span",{className:"workbench-manage-type-meta",children:[t.jsx("span",{className:"workbench-manage-type-swatch",style:{backgroundColor:Ce.color},"aria-hidden":"true"}),t.jsx("span",{className:"workbench-manage-type-name",children:Ce.type})]}),t.jsxs("span",{children:[Ce.count," · ",Su(Ce)]})]},Ce.key))})]}):t.jsx("p",{className:"workbench-section-empty",children:X.detail.codeComposition.error??r("shell.manageWorkspaceNoCodeComposition")}),X.detail.codeComposition.truncated?t.jsx("p",{className:"workbench-manage-hint",children:r("shell.manageWorkspaceCodeTruncated",{count:X.detail.codeComposition.scannedFileCount})}):null]})]}):null,t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ut(!1),ae(Za(d.id))},children:r("shell.workspaceDetailDebugOpenPageAction")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!_e,onClick:()=>gt(d),children:ve?r("shell.manageWorkspaceRemoving"):r("shell.manageWorkspaceRemoveAction")})]})]}):null,w.length>0?t.jsx("div",{className:"workbench-manage-children",children:w.map(Ce=>Us(Ce.workspace,Ce.visibleSessions.length+Ce.archivedSessions.length,Ce.children,!0,wn))}):null]},d.id)}return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"workbench-nav-header","data-window-drag-handle":"workbench-nav-header","data-tauri-drag-region":be,children:t.jsxs("div",{className:"workbench-nav-toolbar","data-tauri-drag-region":be,children:[oe?t.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":r("shell.hideSessionSidebar"),title:r("shell.hideSessionSidebar"),onClick:oe,children:t.jsx(Yl,{})}):null,t.jsx(jl,{}),t.jsx(Xl,{unreadCount:J,open:ke,onToggle:we})]})}),t.jsxs("div",{className:"workbench-nav-body",children:[t.jsxs("div",{className:"workbench-nav-segment",children:[t.jsxs("div",{className:"workbench-nav-segment-tabs",role:"tablist","aria-label":r("shell.centerTabsLabel"),children:[t.jsxs("div",{className:"workbench-nav-segment-pair",children:[t.jsxs("button",{type:"button",className:h?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":h,onClick:U,children:[t.jsx(Ef,{}),t.jsx("span",{children:r("shell.conversationEntry")})]}),t.jsxs("button",{type:"button",className:k?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":k,onClick:x,children:[t.jsx(Af,{}),t.jsx("span",{children:r("shell.butlerEntry")})]})]}),t.jsxs("button",{type:"button",className:f?"workbench-nav-segment-button active":"workbench-nav-segment-button",role:"tab","aria-selected":f,onClick:A,children:[t.jsx(Wf,{}),t.jsx("span",{children:r("shell.terminalsEntry")})]})]}),t.jsx(Vd,{triggerClassName:"workbench-nav-segment-button",triggerLabel:r("shell.skillsEntry"),triggerLeading:t.jsx(Pf,{})}),t.jsxs("button",{type:"button",className:"workbench-nav-segment-button","data-open":p,"aria-haspopup":"dialog","aria-expanded":p,onClick:P,children:[t.jsx(Mf,{}),t.jsx("span",{children:r("shell.searchEntry")})]})]}),N?t.jsx("div",{className:"workbench-status-row",children:t.jsx("p",{className:"status-text","data-tone":"error",children:N})}):null,i.length>0?t.jsxs("section",{className:"workbench-section-block workbench-favorite-section",children:[t.jsxs("div",{className:"workbench-section-heading",children:[t.jsxs("div",{className:"workbench-section-heading-main",children:[t.jsx(Jl,{active:!0,className:"workbench-favorite-heading-icon"}),t.jsx("span",{children:r("shell.favoriteSectionTitle")})]}),t.jsx("span",{className:"workbench-section-counter",children:i.length})]}),t.jsxs("div",{className:"workbench-session-list",children:[jr.map(d=>{const m=di(d.session.sessionId);return t.jsx("div",{children:us({node:{item:d.session,depth:0,children:m},workspace:d.workspace,workspaceContext:gn(d.workspace),menuKeyPrefix:"favorite",showWorkspaceName:!0,selectionMode:!1,favoriteEnabled:!0})},d.session.sessionId)}),Nr?t.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:pr,children:r("shell.favoriteExpandMore")}):null]})]}):null,g&&e.length===0?t.jsx(Sf,{}):null,!g&&!N&&e.length===0?t.jsx("div",{className:"workbench-empty-state minimal",children:t.jsx("p",{children:r("shell.emptyNavigationBody")})}):null,t.jsxs("section",{className:"workbench-section-block workbench-workspace-section",children:[t.jsxs("div",{className:"workbench-section-heading",children:[t.jsx("div",{className:"workbench-section-heading-main",children:t.jsx("span",{children:r("shell.workspaceSectionTitle")})}),t.jsxs("div",{className:"workbench-section-actions",children:[t.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.manageWorkspaceAction"),title:r("shell.manageWorkspaceAction"),onClick:()=>ut(!0),children:t.jsx(Cf,{})}),t.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.importWorkspaceTitle"),title:r("shell.importWorkspaceTitle"),onClick:As,children:t.jsx(Nf,{})}),t.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.cloneWorkspaceTitle"),title:r("shell.cloneWorkspaceTitle"),onClick:Ps,children:t.jsx(Bf,{})})]})]}),e.map(d=>{const m=zs(d),w=ze===d.workspace.id,M=d.isCollapsed||_n;return t.jsxs("section",{className:"workbench-workspace-group",ref:W=>Bs(d.workspace.id,W),"data-workspace-group-id":d.workspace.id,"data-batch-active":it===d.workspace.id,"data-dragging":w,onDragOver:W=>pt(W,d.workspace.id),onDrop:Be,children:[t.jsxs("div",{className:"workbench-workspace-header minimal",children:[t.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":M?r("shell.workspaceExpand"):r("shell.workspaceCollapse"),draggable:j&&!Tt,onClick:()=>cs(d.workspace.id),onPointerDown:Tt?W=>re(W,d.workspace.id):void 0,onPointerMove:Tt?ds:void 0,onPointerUp:Tt?On:void 0,onPointerCancel:Tt?ci:void 0,onDragStart:j&&!Tt?W=>Hn(W,d.workspace.id):void 0,onDragEnd:j&&!Tt?Un:void 0,"data-reorder-enabled":j?"true":void 0,children:[t.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:t.jsx(Xs,{expanded:!M})}),t.jsx("strong",{children:d.workspace.name})]}),it===d.workspace.id?Os():gr(d.workspace.id)]}),M?null:t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"workbench-session-list",children:[m.length===0?t.jsx("p",{className:"workbench-session-empty",children:r("shell.emptyWorkspaceSessions")}):m.slice(0,bt(d.workspace.id)).map(W=>us({node:W,workspace:d.workspace,workspaceContext:gn(d.workspace),menuKeyPrefix:`workspace:${d.workspace.id}`,showWorkspaceName:!1,selectionMode:it===d.workspace.id,favoriteEnabled:!0})),m.length>bt(d.workspace.id)?t.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>$n(d.workspace.id,m.length),children:r("shell.sessionExpandMore")}):null]}),d.childWorktrees.length>0?t.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:d.childWorktrees.map(W=>wr(W))}):null,kr(d.workspace,d.archivedSessions)]})]},d.workspace.id)})]})]}),t.jsx("div",{className:"workbench-nav-footer minimal",children:t.jsxs("div",{className:"workbench-nav-footer-actions",children:[t.jsxs("button",{className:"settings-entry-button workbench-nav-settings-button",type:"button",onClick:_,title:F?`${r("settings.title")} · ${Ee}`:r("settings.title"),children:[t.jsx(Lf,{}),t.jsx("span",{className:"settings-entry-label",children:r("settings.title")}),F?t.jsx("span",{className:"workbench-nav-settings-host-badge",title:Ee,children:Ee}):null]}),t.jsx(ph,{onOpenSoftwareUpdate:()=>ae("/settings/software-update")})]})}),t.jsx(Ue,{open:We,title:r("shell.manageWorkspaceTitle"),className:"workbench-manage-workspaces-modal",description:r("shell.manageWorkspaceDescription"),headerActions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:As,children:r("shell.manageWorkspaceImportAction")}),t.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:Ps,children:r("shell.manageWorkspaceCloneAction")})]}),onClose:()=>{_e||ut(!1)},children:e.length>0?t.jsx("div",{className:"workbench-manage-list",children:e.map(d=>Us(d.workspace,d.visibleSessions.length+d.archivedSessions.length,d.childWorktrees,!1))}):t.jsx("p",{className:"workbench-section-empty",children:r("shell.manageWorkspaceEmpty")})}),t.jsxs(Ue,{open:Bn!==null,title:r("shell.deleteSessionConfirmTitle"),description:r("shell.deleteSessionConfirmDescription"),onClose:()=>{on||vt(null)},children:[t.jsx("p",{className:"workbench-section-empty",children:Bn?Bn.session.title:""}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:!!on,onClick:()=>vt(null),children:r("common.cancel")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!on,onClick:()=>{xr()},children:on?r("common.loading"):r("shell.deleteSessionAction")})]})]}),t.jsxs(Ue,{open:Je!==null,title:r("shell.manageWorkspaceRemoveConfirmTitle"),description:r("shell.manageWorkspaceRemoveConfirmDescription"),onClose:()=>{_e||gt(null)},children:[t.jsx("p",{className:"workbench-section-empty",children:Je?r("shell.manageWorkspaceRemoveConfirmTarget",{name:Je.name}):""}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:!!_e,onClick:()=>gt(null),children:r("common.cancel")}),t.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!_e,onClick:()=>{fr()},children:_e?r("shell.manageWorkspaceRemoving"):r("shell.manageWorkspaceRemoveConfirmAction")})]})]}),t.jsx(oh,{open:le,onClose:()=>O(!1),onCloned:as}),t.jsx(mh,{open:y,onClose:()=>q(!1),onImported:os}),t.jsx(Ue,{open:Ie!==null,title:r("shell.createSessionModalTitle"),className:"workbench-create-session-modal",description:Ie?`${r("shell.createSessionTarget")} · ${Ie.name}`:r("shell.createSessionModalDescription"),headerActions:t.jsx("button",{type:"button",className:"secondary-button create-session-worktree-trigger",disabled:Ze||!!lt,onClick:()=>zt(!0),children:r("shell.createWorktreeAction")}),onClose:()=>Kt(null),children:t.jsxs("section",{className:"create-session-modal-section",children:[t.jsxs("div",{className:"create-session-modal-section-header",children:[t.jsx("strong",{children:r("shell.createSessionProviderLabel")}),t.jsx("span",{children:r("shell.providerOptionHint")})]}),t.jsx(Ec,{disabled:!!lt||Ze,workspaceId:(Ie==null?void 0:Ie.id)??null,pendingProvider:lt===(Ie==null?void 0:Ie.id)?Fe??null:null,onSelect:d=>{Ie&&pi(Ie.id,d)}})]})}),t.jsx(Ue,{open:Ie!==null&&At,title:r("shell.createWorktreeAction"),className:"workbench-create-worktree-modal",headerActions:t.jsx("button",{type:"button",className:Mn?"workbench-modal-help-button active":"workbench-modal-help-button","aria-label":r("shell.createWorktreeHelpAction"),title:r("shell.createWorktreeHelpAction"),"aria-pressed":Mn,onClick:()=>En(d=>!d),children:t.jsx(qf,{})}),description:Ie?`${r("shell.createWorktreeSectionDescription")} ${r("shell.createSessionTarget")} · ${Ie.name}`:r("shell.createWorktreeSectionDescription"),onClose:ls,children:t.jsxs("form",{className:"create-session-worktree-form",onSubmit:Qt,children:[Mn?t.jsxs("section",{className:"create-session-worktree-help-card","aria-label":r("shell.createWorktreeHelpTitle"),children:[t.jsx("strong",{children:r("shell.createWorktreeHelpTitle")}),t.jsxs("div",{className:"create-session-worktree-help-grid",children:[t.jsxs("article",{children:[t.jsx("h3",{children:r("shell.createWorktreeHelpBranchTitle")}),t.jsx("p",{children:r("shell.createWorktreeHelpBranchBody")})]}),t.jsxs("article",{children:[t.jsx("h3",{children:r("shell.createWorktreeHelpDisplayNameTitle")}),t.jsx("p",{children:r("shell.createWorktreeHelpDisplayNameBody")})]}),t.jsxs("article",{children:[t.jsx("h3",{children:r("shell.createWorktreeHelpBaseRefTitle")}),t.jsx("p",{children:r("shell.createWorktreeHelpBaseRefBody")})]})]})]}):null,t.jsxs("label",{className:"create-session-worktree-field",children:[t.jsx("span",{children:r("shell.createWorktreeBranchLabel")}),t.jsx("input",{className:"settings-text-input",value:wt,placeholder:r("shell.createWorktreeBranchPlaceholder"),onChange:d=>{const m=d.target.value;Lh(m)&&Rn(m)}})]}),t.jsxs("label",{className:"create-session-worktree-field",children:[t.jsx("span",{children:r("shell.createWorktreeDisplayNameLabel")}),t.jsx("input",{className:"settings-text-input",value:Ts,placeholder:r("shell.createWorktreeDisplayNamePlaceholder"),onChange:d=>rn(d.target.value)})]}),t.jsxs("label",{className:"create-session-worktree-field",children:[t.jsx("span",{children:r("shell.createWorktreeBaseRefLabel")}),t.jsx("div",{className:"create-session-worktree-combobox",ref:Ve,onBlurCapture:d=>{var w,M;const m=d.relatedTarget;m instanceof Node&&((w=Ve.current)!=null&&w.contains(m)||(M=Ct.current)!=null&&M.contains(m))||(Ke(!1),et(-1))},children:t.jsxs("div",{className:"create-session-worktree-combobox-input-wrap",children:[t.jsx("input",{className:"settings-text-input create-session-worktree-combobox-input",role:"combobox","aria-autocomplete":"list","aria-expanded":Qe,"aria-controls":Ws,value:Jn,placeholder:r("shell.createWorktreeBaseRefPlaceholder"),onFocus:()=>{Ke(!0),et(dt.length>0?0:-1)},onChange:d=>{xe(d.target.value),Ke(!0),et(dt.length>0?0:-1)},onKeyDown:d=>{if(d.key==="ArrowDown"){if(d.preventDefault(),!Qe){Ke(!0);return}dt.length>0&&et(m=>m>=dt.length-1?0:m+1);return}if(d.key==="ArrowUp"){if(d.preventDefault(),!Qe){Ke(!0);return}dt.length>0&&et(m=>m<=0?dt.length-1:m-1);return}if(d.key==="Enter"&&Qe&&Is>=0){d.preventDefault();const m=dt[Is];m&&(xe(m.value),Ke(!1),et(-1));return}d.key==="Escape"&&Ke(!1)}}),t.jsx("button",{type:"button",className:"create-session-worktree-combobox-toggle","aria-label":r("shell.createWorktreeBaseRefToggle"),"aria-expanded":Qe,onClick:()=>{Ke(d=>!d),et(!Qe&&dt.length>0?0:-1)},children:t.jsx(Xs,{expanded:Qe})})]})}),t.jsx("span",{className:"create-session-worktree-field-hint",children:Zn?r("shell.createWorktreeBaseRefLoading"):Pt||r("shell.createWorktreeBaseRefHint",{localCount:Vt.localBranches.length,remoteCount:Vt.remoteBranches.length,tagCount:Vt.tags.length})})]}),Qe&&xt&&typeof document<"u"?tr.createPortal(t.jsxs("div",{className:"create-session-worktree-combobox-floating-layer",children:[t.jsx("div",{className:"create-session-worktree-combobox-floating-backdrop",style:{"--create-worktree-combobox-top":`${xt.top}px`,"--create-worktree-combobox-left":`${xt.left}px`,"--create-worktree-combobox-width":`${xt.width}px`,"--create-worktree-combobox-height":`${oi??0}px`}}),t.jsx("div",{ref:Ct,className:"create-session-worktree-combobox-popover floating",style:{"--create-worktree-combobox-top":`${xt.top}px`,"--create-worktree-combobox-left":`${xt.left}px`,"--create-worktree-combobox-width":`${xt.width}px`},children:Zn?t.jsx("p",{className:"create-session-worktree-combobox-empty",children:r("shell.createWorktreeBaseRefLoading")}):Pt?t.jsx("p",{className:"create-session-worktree-combobox-empty",children:Pt}):mn.length>0?t.jsx("div",{id:Ws,className:"create-session-worktree-combobox-list",role:"listbox",children:mn.map(d=>t.jsxs("section",{className:"create-session-worktree-combobox-group","aria-label":d.label,children:[t.jsx("header",{className:"create-session-worktree-combobox-group-title",children:d.label}),t.jsx("div",{className:"create-session-worktree-combobox-group-options",children:d.items.map(m=>{const w=dt.findIndex(ne=>ne.value===m.value),M=Jn===m.value,W=Is===w;return t.jsxs("button",{type:"button",role:"option",className:"create-session-worktree-combobox-option","aria-selected":M,"data-highlighted":W,onMouseDown:ne=>ne.preventDefault(),onMouseEnter:()=>et(w),onClick:()=>{xe(m.value),Ke(!1),et(-1)},children:[t.jsx("span",{className:"create-session-worktree-combobox-option-label",children:m.value}),t.jsxs("span",{className:"create-session-worktree-combobox-option-badges",children:[m.current?t.jsx("span",{className:"create-session-worktree-combobox-badge",children:r("shell.createWorktreeBaseRefCurrentBadge")}):null,m.recommended?t.jsx("span",{className:"create-session-worktree-combobox-badge recommended",children:r("shell.createWorktreeBaseRefRecommendedBadge")}):null]})]},`${d.key}:${m.value}`)})})]},d.key))}):t.jsx("p",{className:"create-session-worktree-combobox-empty",children:r("shell.createWorktreeBaseRefEmpty")})})]}),document.body):null,t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:Ze,onClick:ls,children:r("common.cancel")}),t.jsx("button",{type:"submit",className:"primary-button",disabled:Ze,children:Ze?r("shell.createWorktreeSubmitting"):r("shell.createWorktreeSubmit")})]})]})}),t.jsx(Ue,{open:ft!==null,title:r("shell.archiveModalTitle"),description:ft?`${ft.workspace.name} · ${r("shell.archiveModalDescription")}`:r("shell.archiveModalDescription"),onClose:()=>Xt(null),children:ft&&ft.archivedSessions.length>0?t.jsx("div",{className:"workbench-archive-list","data-workspace-tone":(Ye==null?void 0:Ye.tone)??"root",style:tn(Ye),children:ft.archivedSessions.map(d=>{const m=oo(d.title,r("common.unknown"));return t.jsxs("article",{className:"workbench-archive-item","data-workspace-tone":(Ye==null?void 0:Ye.tone)??"root",style:tn(Ye),children:[t.jsxs("div",{className:"workbench-archive-item-main",children:[t.jsx("strong",{title:m.fullTitle,children:m.displayTitle}),t.jsxs("p",{children:[El(d,ft.workspace,!1)," ·"," ",ri(d.provider)]})]}),t.jsx("button",{type:"button",className:"secondary-button",onClick:()=>yr(d.sessionId),children:r("shell.unarchiveAction")})]},d.sessionId)})}):t.jsx("p",{className:"workbench-section-empty",children:r("shell.archiveEmpty")})}),t.jsx(Ue,{open:nt!==null,title:r("shell.renameModalTitle"),description:r("shell.renameModalDescription"),onClose:()=>{un||(St(null),Zt(""))},children:t.jsxs("form",{className:"workbench-rename-form",onSubmit:Sr,children:[t.jsxs("label",{className:"workbench-modal-field",children:[t.jsx("span",{children:r("shell.renameInputLabel")}),t.jsx("input",{type:"text",value:jt,placeholder:r("shell.renameInputPlaceholder"),maxLength:120,autoFocus:!0,onChange:d=>Zt(d.target.value)})]}),t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:!!un,onClick:()=>{St(null),Zt("")},children:r("common.cancel")}),t.jsx("button",{type:"submit",className:"primary-button",disabled:!jt.trim()||un===(nt==null?void 0:nt.session.sessionId),children:un===(nt==null?void 0:nt.session.sessionId)?r("shell.renamingSession"):r("common.save")})]})]})})]})}function Ea({panelReady:e,activeTab:n,fileRevealRequest:s,onTabChange:i,onToggleCollapse:o,currentSessionId:c,activeWorkspaceId:h,navigationGroups:f,workspaceContext:k,worktreeMeta:p,worktreeMergeState:g,onRefreshWorktreeMergePreview:N,onApplyWorktreeMerge:C,onCleanupWorktree:I}){var ue;const H=h??((ue=f[0])==null?void 0:ue.workspace.id)??null,U=Tn(),A=ul(U),{showToast:x}=Xn(),P=l.useRef(null),_=l.useRef(null),Y=U.isDesktop&&U.bridge.supported,R=Y&&!!h,K=Y&&!!H,V=Y&&!!H,G=typeof globalThis<"u"&&"PointerEvent"in globalThis,j=l.useCallback(async($,ce,D)=>{if($==="files"){const S=await Ud(U,{workspaceId:ce,sessionId:D,focusOwner:"file-context-panel"});S.ok||x({title:S.detail??r("conversation.filePanelOpenExternalFailed"),tone:"error"});return}if($==="git"){const S=await $d(U,{workspaceId:ce,focusOwner:"git-sidebar"});S.ok||x({title:S.detail??r("git.openExternalFailed"),tone:"error"});return}const v=await qd(U,{workspaceId:ce,focusOwner:"terminal-manager-panel"});v.ok||x({title:v.detail??r("terminalManager.openExternalFailed"),tone:"error"})},[U,x]),Z=l.useCallback(($,ce)=>{if($.button!==0||!Y)return;const D=ce==="files"?h:ce==="git"||ce==="terminals"?H:null;if(!D)return;const v=ce==="files"?c:null;P.current={tab:ce,startX:$.clientX,startY:$.clientY,workspaceId:D,sessionId:v,detached:!1,preview:null};const S=se=>{var be;const oe=P.current;if(!oe)return;const ae=Math.abs(se.clientX-oe.startX),he=Math.abs(se.clientY-oe.startY);!oe.detached&&Math.max(ae,he)<ha||(oe.detached||(oe.detached=!0,_.current=oe.tab,oe.preview=Wo({title:oe.tab==="files"?r("shell.filesEntry"):oe.tab==="git"?r("shell.gitEntry"):r("shell.terminalManagerEntry"),x:se.clientX,y:se.clientY})),(be=oe.preview)==null||be.updatePosition(se.clientX,se.clientY))},J=se=>{var ae;const oe=(ae=P.current)==null?void 0:ae.preview;se&&(oe==null||oe.cancel()),window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",ke),window.removeEventListener("blur",we),P.current=null},ke=async()=>{var oe;const se=P.current;J(!1),se!=null&&se.detached&&(await((oe=se.preview)==null?void 0:oe.complete()),await j(se.tab,se.workspaceId,se.sessionId))},we=()=>{J(!0)};window.addEventListener("mousemove",S),window.addEventListener("mouseup",ke),window.addEventListener("blur",we)},[h,Y,c,H,j]),ee=l.useCallback(($,ce)=>{if($.button!==0||!Y)return;const D=ce==="files"?h:ce==="git"||ce==="terminals"?H:null;if(!D)return;const v=$.currentTarget,S=$.pointerId;v.setPointerCapture(S);const J=ce==="files"?c:null;P.current={tab:ce,startX:$.clientX,startY:$.clientY,workspaceId:D,sessionId:J,detached:!1,preview:null};const ke=he=>{var Ee;if(he.pointerId!==S)return;const be=P.current;if(!be)return;const me=Math.abs(he.clientX-be.startX),Ge=Math.abs(he.clientY-be.startY);!be.detached&&Math.max(me,Ge)<ha||(be.detached||(be.detached=!0,_.current=be.tab,be.preview=Wo({title:be.tab==="files"?r("shell.filesEntry"):be.tab==="git"?r("shell.gitEntry"):r("shell.terminalManagerEntry"),x:he.clientX,y:he.clientY})),(Ee=be.preview)==null||Ee.updatePosition(he.clientX,he.clientY))},we=he=>{var me;const be=(me=P.current)==null?void 0:me.preview;he&&(be==null||be.cancel()),v.removeEventListener("pointermove",ke),v.removeEventListener("pointerup",se),v.removeEventListener("pointercancel",oe),v.removeEventListener("lostpointercapture",oe),window.removeEventListener("blur",ae),P.current=null,v.hasPointerCapture(S)&&v.releasePointerCapture(S)},se=async he=>{var me;if(he.pointerId!==S)return;const be=P.current;we(!1),be!=null&&be.detached&&(await((me=be.preview)==null?void 0:me.complete()),await j(be.tab,be.workspaceId,be.sessionId))},oe=he=>{he.pointerId===S&&we(!0)},ae=()=>{we(!0)};v.addEventListener("pointermove",ke),v.addEventListener("pointerup",se),v.addEventListener("pointercancel",oe),v.addEventListener("lostpointercapture",oe),window.addEventListener("blur",ae)},[h,Y,c,H,j]),E=l.useCallback($=>{if(_.current===$){_.current=null;return}i($)},[i]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"workbench-auxiliary-header","data-workspace-tone":(k==null?void 0:k.tone)??"root",style:tn(k),"data-window-drag-handle":"workbench-auxiliary-header","data-tauri-drag-region":A,children:[o?t.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":r("shell.hideInfoSidebar"),title:r("shell.hideInfoSidebar"),onClick:o,children:t.jsx(Yl,{})}):null,t.jsxs("div",{className:"workbench-info-tabs",role:"tablist","aria-label":r("shell.infoTabsLabel"),"data-tauri-drag-region":A,children:[t.jsx("button",{className:n==="files"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":n==="files",title:R?"拖拽标签到独立窗口":void 0,onPointerDown:$=>ee($,"files"),onMouseDown:G?void 0:$=>Z($,"files"),onClick:()=>E("files"),children:r("shell.filesEntry")}),t.jsx("button",{className:n==="git"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":n==="git",title:K?"拖拽标签到独立窗口":void 0,onPointerDown:$=>ee($,"git"),onMouseDown:G?void 0:$=>Z($,"git"),onClick:()=>E("git"),children:r("shell.gitEntry")}),t.jsx("button",{className:n==="terminals"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":n==="terminals",title:V?"拖拽标签到独立窗口":void 0,onPointerDown:$=>ee($,"terminals"),onMouseDown:G?void 0:$=>Z($,"terminals"),onClick:()=>E("terminals"),children:r("shell.terminalManagerEntry")})]})]}),t.jsxs("div",{className:"workbench-auxiliary-body",children:[e?null:t.jsx(Kr,{}),e&&n==="git"&&p?t.jsx(zf,{meta:p,state:g,onRefresh:()=>N(p.workspaceId,!0),onApply:()=>C(p.workspaceId),onCleanup:()=>I(p)}):null,e&&n==="files"?h?t.jsx(l.Suspense,{fallback:t.jsx(Kr,{}),children:t.jsx(Kh,{sessionId:c,workspaceId:h,externalRevealRequest:s})}):t.jsx("section",{className:"workbench-empty-state minimal",children:t.jsx("p",{children:r("shell.filesPanelEmpty")})}):null,e&&n==="git"?H?t.jsx(l.Suspense,{fallback:t.jsx(Kr,{}),children:t.jsx(zh,{workspaceId:H})}):t.jsx("section",{className:"workbench-empty-state minimal",children:t.jsx("p",{children:r("shell.gitPanelEmpty")})}):null,e&&n==="terminals"?t.jsx(l.Suspense,{fallback:t.jsx(Kr,{}),children:t.jsx(Vh,{currentWorkspaceId:h,navigationGroups:f})}):null]})]})}function zf({meta:e,state:n,onRefresh:s,onApply:i,onCleanup:o}){const[c,h]=l.useState(!1),f=(n==null?void 0:n.preview)??null,k=(n==null?void 0:n.loading)??!1,p=(n==null?void 0:n.applying)??!1,g=(n==null?void 0:n.cleaning)??!1,N=f!==null,C=(f==null?void 0:f.alreadyMerged)===!0,I=new Set((f==null?void 0:f.blockers.map(E=>E.code))??[]),H=I.size>0||!!(n!=null&&n.error),U=C&&!H,A=(f==null?void 0:f.canMerge)===!0&&!k&&!p&&!g&&!U,x=U&&!k&&!p&&!g&&!I.has("SOURCE_DIRTY")&&!I.has("HAS_ACTIVE_CHILDREN"),P=k||p||g?"loading":H?"blocked":U?"merged":f!=null&&f.canMerge?"ready":N?"blocked":"idle",_=(f==null?void 0:f.targetWorkspace.name)??r("common.unknown"),Y=(f==null?void 0:f.sourceBranchName)??e.branchName,R=(f==null?void 0:f.targetBranchName)??e.baseRef??r("common.unknown"),K=Xf({t:r,hasPreview:N,showMergedState:U,isMerged:C,canMerge:(f==null?void 0:f.canMerge)===!0,ahead:(f==null?void 0:f.ahead)??0,blockerCodeSet:I}),V=k?r("shell.worktreeMergePreviewLoading"):p?r("shell.worktreeMergeApplying"):g?r("shell.worktreeCleanupRunning"):U?r("shell.worktreeMergeAlreadyMerged"):f!=null&&f.canMerge?r("shell.worktreeMergeReady"):N?r("shell.worktreeMergeBlocked"):r("shell.worktreeMergePreviewIdle"),G=[r("shell.worktreeMergeCurrentBranch",{branch:Y}),r("shell.worktreeMergeParentBranch",{branch:R}),r("shell.worktreeMergeTargetWorkspace",{name:_}),f?r("shell.worktreeMergeAheadBehind",{ahead:f.ahead,behind:f.behind}):r("shell.worktreeMergeAheadBehindPending"),f!=null&&f.mergeBaseCommit?r("shell.worktreeMergeBaseCommit",{commit:vf(f.mergeBaseCommit)}):null].filter(E=>!!E),j=`worktree-merge-panel-details-${e.workspaceId}`,Z=c?r("shell.worktreeMergeCollapseDetails"):r("shell.worktreeMergeExpandDetails"),ee=Vf({t:r,loading:k,applying:p,cleaning:g,hasPreview:N,canMerge:(f==null?void 0:f.canMerge)===!0,showMergedState:U,blockerCodeSet:I});return l.useEffect(()=>{h(!1)},[e.workspaceId]),t.jsxs("section",{className:"worktree-merge-panel","data-state":P,children:[t.jsxs("button",{type:"button",className:"worktree-merge-panel-summary","aria-label":Z,"aria-expanded":c,"aria-controls":j,onClick:()=>{h(E=>!E)},children:[t.jsx("span",{className:"worktree-merge-panel-summary-label",children:r("shell.worktreeMergePanelLabel")}),t.jsx("span",{className:"worktree-merge-panel-summary-main",children:t.jsx("span",{className:"worktree-merge-panel-summary-tags",children:ee.map(E=>t.jsx("span",{className:"worktree-merge-panel-summary-tag","data-state":P,children:E},E))})}),t.jsx("span",{className:"worktree-merge-panel-summary-toggle",children:Z})]}),c?t.jsxs("div",{id:j,className:"worktree-merge-panel-details",children:[t.jsx("div",{className:"worktree-merge-panel-detail-head",children:t.jsx("span",{className:"worktree-merge-panel-status","data-state":P,children:V})}),t.jsx("div",{className:"worktree-merge-panel-meta",children:G.map(E=>t.jsx("span",{children:E},E))}),N?t.jsx("div",{className:"worktree-merge-panel-checklist","aria-label":r("shell.worktreeMergeChecklistTitle"),children:K.map(E=>t.jsxs("div",{className:"worktree-merge-panel-checklist-item","data-state":E.state,children:[t.jsx("span",{className:"worktree-merge-panel-checklist-marker","aria-hidden":"true",children:E.state==="done"?"✓":E.state==="blocked"?"!":"·"}),t.jsxs("span",{className:"worktree-merge-panel-checklist-copy",children:[t.jsx("strong",{children:E.label}),E.detail?t.jsx("span",{children:E.detail}):null]})]},E.key))}):null,n!=null&&n.error?t.jsx("p",{className:"worktree-merge-panel-error status-text","data-tone":"error",children:n.error}):null,f!=null&&f.conflictPaths.length?t.jsxs("div",{className:"worktree-merge-panel-conflicts",children:[t.jsx("span",{className:"worktree-merge-panel-conflicts-label",children:r("shell.worktreeMergeConflictLabel")}),t.jsx("div",{className:"worktree-merge-panel-conflict-list",children:f.conflictPaths.map(E=>t.jsx("code",{children:E},E))})]}):null,t.jsxs("div",{className:"worktree-merge-panel-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:k||p||g,onClick:s,children:N?r("shell.worktreeMergePreviewRefresh"):r("shell.worktreeMergePreviewAction")}),t.jsx("button",{type:"button",className:"primary-button",disabled:!A,onClick:i,children:p?r("shell.worktreeMergeApplying"):r("shell.worktreeMergeApplyAction")}),t.jsx("button",{type:"button",className:"secondary-button worktree-merge-panel-cleanup-button",disabled:!x,onClick:o,children:g?r("shell.worktreeCleanupRunning"):r("shell.worktreeCleanupAction")})]})]}):null]})}function Vf(e){const{t:n,loading:s,applying:i,cleaning:o,hasPreview:c,canMerge:h,showMergedState:f,blockerCodeSet:k}=e;if(s)return[n("shell.worktreeMergeCompactChecking")];if(i)return[n("shell.worktreeMergeCompactMerging")];if(o)return[n("shell.worktreeMergeCompactCleaning")];const p=[];return k.has("SOURCE_NOT_ACTIVE")&&p.push(n("shell.worktreeMergeCompactInactive")),k.has("SOURCE_DIRTY")&&p.push(n("shell.worktreeMergeCompactDirty")),k.has("TARGET_DIRTY")&&p.push(n("shell.worktreeMergeCompactTargetDirty")),k.has("HAS_CONFLICTS")&&p.push(n("shell.worktreeMergeCompactConflict")),k.has("HAS_ACTIVE_CHILDREN")&&p.push(n("shell.worktreeMergeCompactChildren")),p.length>0?p:h?[n("shell.worktreeMergeCompactReady")]:f?[n("shell.worktreeMergeCompactMerged")]:c?k.has("NO_COMMITS_TO_MERGE")?[n("shell.worktreeMergeCompactNoCommits")]:[n("shell.worktreeMergeCompactBlocked")]:[n("shell.worktreeMergeCompactPending")]}function Xf(e){const{t:n,hasPreview:s,showMergedState:i,isMerged:o,canMerge:c,ahead:h,blockerCodeSet:f}=e,k=f.has("SOURCE_NOT_ACTIVE"),p=f.has("SOURCE_DIRTY"),g=f.has("TARGET_DIRTY"),N=f.has("HAS_ACTIVE_CHILDREN"),C=f.has("HAS_CONFLICTS"),I=s&&!o&&(f.has("NO_COMMITS_TO_MERGE")||h<=0),H=i?{key:"merge-result",label:n("shell.worktreeMergeChecklistResultMerged"),detail:n("shell.worktreeMergeMergedHint"),state:"done"}:c?{key:"merge-result",label:n("shell.worktreeMergeChecklistResultReady"),detail:n("shell.worktreeMergeChecklistResultReadyDetail"),state:"done"}:s?{key:"merge-result",label:n("shell.worktreeMergeChecklistResultBlocked"),detail:n("shell.worktreeMergeChecklistResultBlockedDetail"),state:"blocked"}:{key:"merge-result",label:n("shell.worktreeMergeChecklistResultPending"),detail:null,state:"pending"};return[{key:"source-state",label:n("shell.worktreeMergeChecklistSourceState"),detail:s&&k?n("shell.worktreeMergeChecklistSourceStateBlocked"):null,state:s?k?"blocked":"done":"pending"},{key:"clean-source",label:n("shell.worktreeMergeChecklistSourceClean"),detail:s&&p?n("shell.worktreeMergeChecklistSourceCleanBlocked"):null,state:s?p?"blocked":"done":"pending"},{key:"clean-target",label:n("shell.worktreeMergeChecklistTargetClean"),detail:s&&g?n("shell.worktreeMergeChecklistTargetCleanBlocked"):null,state:s?g?"blocked":"done":"pending"},{key:"children",label:n("shell.worktreeMergeChecklistChildren"),detail:s&&N?n("shell.worktreeMergeChecklistChildrenBlocked"):null,state:s?N?"blocked":"done":"pending"},{key:"commits",label:n("shell.worktreeMergeChecklistCommits"),detail:I?n(o?"shell.worktreeMergeMergedDirtyHint":"shell.worktreeMergeChecklistCommitsBlocked"):null,state:I?o?"done":"blocked":s?"done":"pending"},{key:"conflicts",label:n("shell.worktreeMergeChecklistConflicts"),detail:C?n("shell.worktreeMergeChecklistConflictsBlocked"):null,state:C?"blocked":s?"done":"pending"},H]}function sp({shellMode:e="desktop"}){var Ne,wn,Ft,Ce,Cr,ms,Tr,Ir,Rr,Mr,xn,vn,ho,fo,mo;const n=ei(),s=er(),i=Tn(),{showToast:o}=Xn(),c=Er(a=>a.sessionDisplaySortMode),h=Er(a=>a.notificationPreferences.notifyOnPermissionRequest),f=Er(a=>a.notificationPreferences.notifyOnSessionCompleted),k=Er(a=>a.notificationPreferences.notifyOnSessionFailed),p=l.useRef(Wu(xl)),g=l.useRef(0),N=l.useRef((((wn=(Ne=p.current)==null?void 0:Ne.items)==null?void 0:wn.length)??0)>0),C=l.useRef(new Map),I=l.useRef(!1),H=l.useRef(null),U=l.useRef(0),A=l.useRef(null),x=l.useRef(null),P=l.useRef(new Set),_=l.useRef(new Set),Y=l.useRef(new Set),R=l.useRef(new Set),K=l.useRef(null),V=l.useRef(null),G=l.useRef(null),j=l.useRef(null),Z=l.useRef(null),ee=l.useRef(null),E=l.useRef(null),ue=l.useRef(null),$=l.useRef(0),ce=l.useRef(0),D=l.useRef(o),v=l.useRef(i.bridge),S=l.useRef(null),J=l.useRef(0),ke=l.useRef(0),we=l.useRef(null),se=l.useRef(null),oe=l.useRef(null),ae=l.useRef(!1),he=l.useRef(!1),be=l.useRef(!1),me=l.useRef(new Map),Ge=l.useRef(!1),Ee=l.useRef(new Map),F=l.useRef(""),y=l.useRef([]),q=l.useRef(c),le=l.useRef(null),[O,We]=l.useState(()=>Uo(p.current,c)),ut=l.useRef(O),[De,Wt]=l.useState(()=>{var a,u;return(((u=(a=p.current)==null?void 0:a.items)==null?void 0:u.length)??0)===0}),[Je,gt]=l.useState(null),[_e,ir]=l.useState(()=>qr(wa(ta,bh),oa,la)),[lt,or]=l.useState(()=>qr(wa(na,kh),aa,ca)),[Fe,Yn]=l.useState(()=>xa(sa,!1)),[Te,Kt]=l.useState(()=>xa(ra,!1)),[ct,Cs]=l.useState(null),[At,zt]=l.useState(()=>Sa(p.current)),[Ze,In]=l.useState(()=>va(Ci)),[wt,Rn]=l.useState(!1),[Ts,rn]=l.useState("files"),[Jn,xe]=l.useState(!1),[Vt,Pe]=l.useState(!1),[Qe,Ke]=l.useState(null),[Is,et]=l.useState({}),[Mn,En]=l.useState(!1),[Zn,Wn]=l.useState("sessions"),[Pt,An]=l.useState(""),[xt,Rs]=l.useState(""),[oi,Pn]=l.useState(!1),[ai,Xt]=l.useState(null),[Bn,vt]=l.useState([]),[on,ar]=l.useState(null),[Yt,an]=l.useState({}),Qn=dl(i),lr=l.useCallback(a=>{if(Qn)return;const u=S.current;u&&(!Ai(i,a.button,a.target)||!ya(a.clientY,u)||Wd({platform:i,button:a.button,target:a.target,clientX:a.clientX,clientY:a.clientY}))},[i,Qn]),li=l.useCallback(a=>{if(Qn)return;const u=S.current;u&&(!Ai(i,a.button,a.target)||!ya(a.clientY,u)||i.bridge.setWindowState("toggle-zoom"))},[i,Qn]),[tt,yt]=l.useState({}),[je,es]=l.useState(null),[ln,Ln]=l.useState(!1),[cn,dn]=l.useState([]),[Jt,nt]=l.useState(()=>new Set),[St,jt]=l.useState(!1),[Zt,un]=l.useState(!1),[cr,it]=l.useState(0),[Bt,Nt]=l.useState(()=>va(ia)),st=e==="desktop"&&i.isDesktop&&i.ui.osFamily==="macos"&&i.ui.prefersOverlayTitlebar,{theme:Dn}=hc();l.useEffect(()=>{D.current=o},[o]),l.useEffect(()=>{if(typeof document>"u")return;const{documentElement:a,body:u}=document,b=document.getElementById("root");if(!st){a.removeAttribute("data-workbench-macos-vibrancy"),u==null||u.removeAttribute("data-workbench-macos-vibrancy");return}const T=a.style.background,B=(u==null?void 0:u.style.background)??"",L=(b==null?void 0:b.style.background)??"";return a.setAttribute("data-workbench-macos-vibrancy","true"),u==null||u.setAttribute("data-workbench-macos-vibrancy","true"),a.style.background="transparent",u==null||u.style.setProperty("background","transparent"),b==null||b.style.setProperty("background","transparent"),()=>{a.removeAttribute("data-workbench-macos-vibrancy"),u==null||u.removeAttribute("data-workbench-macos-vibrancy"),a.style.background=T,u&&(u.style.background=B),b instanceof HTMLElement&&(b.style.background=L)}},[st]),l.useEffect(()=>()=>{oe.current!==null&&window.clearTimeout(oe.current)},[]),l.useEffect(()=>{var B;if(typeof document>"u")return;const{documentElement:a,body:u}=document;if(!ct){a.removeAttribute(bs),u==null||u.removeAttribute(bs);return}const b=a.style.cursor,T=(u==null?void 0:u.style.cursor)??"";return a.setAttribute(bs,ct),u==null||u.setAttribute(bs,ct),a.style.cursor="col-resize",u==null||u.style.setProperty("cursor","col-resize"),(B=window.getSelection())==null||B.removeAllRanges(),()=>{a.removeAttribute(bs),u==null||u.removeAttribute(bs),a.style.cursor=b,u&&(u.style.cursor=T)}},[ct]),l.useEffect(()=>{q.current=c,We(a=>yf(a,c))},[c]),l.useEffect(()=>{ut.current=O},[O]),l.useEffect(()=>{v.current=i.bridge},[i.bridge]),l.useEffect(()=>{J.current=_e},[_e]),l.useEffect(()=>{ke.current=lt},[lt]),l.useEffect(()=>()=>{we.current!==null&&window.cancelAnimationFrame(we.current)},[]);const ts=l.useCallback(async()=>{const a=$.current+1;$.current=a;try{const u=await Fu();if(a!==$.current)return;if(!u.initialized){dn([]),nt(new Set);return}const[b,T,B,L]=await Promise.all([Ou(),$u(),Sl(),Gu()]);if(a!==$.current)return;dn(Ah(b.overview,T.items,B.items)),nt(new Set(L.items.map(te=>te.notificationId)))}catch{if(a!==$.current)return;dn([]),nt(new Set)}},[]),Ms=l.useCallback(a=>{const u=a.map(b=>b.createdAt).sort((b,T)=>Cn(T)-Cn(b))[0]??null;u&&Nt(b=>b&&Cn(b)>=Cn(u)?b:u)},[]);l.useEffect(()=>{Bt&&zn(ia,Bt)},[Bt]),l.useEffect(()=>{ts();const a=window.setInterval(()=>{ts()},wh);return()=>{window.clearInterval(a)}},[ts]),l.useEffect(()=>{qe("workbench.layout_mounted",{path:n.pathname,search:n.search})},[n.pathname,n.search]),l.useEffect(()=>{var a,u;qe("workbench.cached_snapshot_loaded",{cached:!!p.current,workspaceCount:((a=p.current)==null?void 0:a.items.length)??0,sessionCount:((u=p.current)==null?void 0:u.items.reduce((b,T)=>b+T.sessions.length,0))??0})},[]);function ns(a){var T;if(!a||!Array.isArray(a.items))return;kf(C.current,a);const u=bf(a,C.current);qe("workbench.apply_snapshot",{workspaceCount:u.items.length,sessionCount:u.items.reduce((B,L)=>B+L.sessions.length,0),currentSessionId:((T=Js(n.pathname))==null?void 0:T.sessionId)??null});const b=Uo(u,q.current);p.current=u,_r(u),ut.current=b,We(b),zt(Sa(u)),gt(null)}const ze=l.useCallback(async()=>{const a=g.current+1;g.current=a,Wt(u=>u||!N.current),qe("workbench.refresh_navigation.start",{requestId:a,hasNavigationData:N.current});try{const u=await vc();if(a!==g.current){qe("workbench.refresh_navigation.stale",{requestId:a});return}ns(u)}catch(u){if(a!==g.current)return;gt(u instanceof Error?u.message:r("shell.navigationLoadFailed")),D.current({title:u instanceof Error?u.message:r("shell.navigationLoadFailed"),tone:"error"})}finally{qe("workbench.refresh_navigation.end",{requestId:a,success:a===g.current}),a===g.current&&Wt(!1)}},[]),ot=l.useCallback(a=>{We(u=>{const b=gf(u,a,q.current);return ut.current=b,b})},[]),Ve=l.useCallback(()=>{var a;(a=x.current)==null||a.requestRefresh()},[]),Ct=l.useCallback((a,u)=>{s($t(a,u))},[s]),Lt=l.useCallback((a,u,b)=>{var T;K.current={workspaceId:a,paths:u,knownRevisionByPath:b==null?void 0:b.knownRevisionByPath},(T=x.current)==null||T.subscribeFileTree(a,u,b)},[]),ss=l.useCallback((a,u,b)=>{var T;V.current={workspaceId:a,paths:u,knownRevisionByPath:b==null?void 0:b.knownRevisionByPath},(T=x.current)==null||T.requestFileTreeRefresh(a,u,b)},[]),hn=l.useCallback(a=>(P.current.add(a),()=>{P.current.delete(a)}),[]),fn=l.useCallback((a,u)=>{var b;G.current={workspaceId:a,knownRevision:u==null?void 0:u.knownRevision},(b=x.current)==null||b.subscribeGit(a,u)},[]),ht=l.useCallback((a,u)=>{var b;j.current={workspaceId:a,knownRevision:u==null?void 0:u.knownRevision},(b=x.current)==null||b.requestGitRefresh(a,u)},[]),dr=l.useCallback(a=>(_.current.add(a),()=>{_.current.delete(a)}),[]),rs=l.useCallback((a,u)=>{var b;Z.current={workspaceId:a,knownRevision:u==null?void 0:u.knownRevision},(b=x.current)==null||b.subscribeWorkspaceManagement(a,u)},[]),_n=l.useCallback((a,u)=>{var b;ee.current={workspaceId:a,knownRevision:u==null?void 0:u.knownRevision},an(T=>{var B;return{...T,[a]:{detail:((B=T[a])==null?void 0:B.detail)??null,loading:!0,error:null}}}),(b=x.current)==null||b.requestWorkspaceManagementRefresh(a,u)},[]),Tt=l.useCallback(a=>(Y.current.add(a),()=>{Y.current.delete(a)}),[]),Xe=l.useCallback(async(a,u=!1)=>{const b=a.trim();if(!b)return;let T=!0;if(yt(B=>{const L=B[b];return!u&&(L!=null&&L.loading)?(T=!1,B):{...B,[b]:{preview:(L==null?void 0:L.preview)??null,loading:!0,applying:(L==null?void 0:L.applying)??!1,cleaning:(L==null?void 0:L.cleaning)??!1,error:null}}}),!!T)try{const B=await yc(b);yt(L=>{var te,fe;return{...L,[b]:{preview:B,loading:!1,applying:((te=L[b])==null?void 0:te.applying)??!1,cleaning:((fe=L[b])==null?void 0:fe.cleaning)??!1,error:null}}})}catch(B){yt(L=>{var te,fe,de;return{...L,[b]:{preview:((te=L[b])==null?void 0:te.preview)??null,loading:!1,applying:((fe=L[b])==null?void 0:fe.applying)??!1,cleaning:((de=L[b])==null?void 0:de.cleaning)??!1,error:B instanceof Error?B.message:r("shell.worktreeMergePreviewFailed")}}})}},[]),ur=l.useCallback(async a=>{const u=a.trim();if(u){yt(b=>{var T,B;return{...b,[u]:{preview:((T=b[u])==null?void 0:T.preview)??null,loading:!1,applying:!0,cleaning:((B=b[u])==null?void 0:B.cleaning)??!1,error:null}}});try{const b=await Sc(u);yt(T=>{var B;return{...T,[u]:{preview:b.preview,loading:!1,applying:!1,cleaning:((B=T[u])==null?void 0:B.cleaning)??!1,error:null}}}),Ve(),ze(),Xe(u,!0),ht(b.preview.targetWorkspace.id),D.current({title:b.applied?r("shell.worktreeMergeApplySuccess"):r("shell.worktreeMergeAlreadyMerged"),tone:"success"})}catch(b){yt(T=>{var B,L;return{...T,[u]:{preview:((B=T[u])==null?void 0:B.preview)??null,loading:!1,applying:!1,cleaning:((L=T[u])==null?void 0:L.cleaning)??!1,error:b instanceof Error?b.message:r("shell.worktreeMergeApplyFailed")}}}),D.current({title:b instanceof Error?b.message:r("shell.worktreeMergeApplyFailed"),tone:"error"})}}},[Xe,ze,ht,Ve]),Ie=l.useCallback(async a=>{var T,B;const u=a.workspaceId,b=ln&&((B=(T=tt[u])==null?void 0:T.preview)==null?void 0:B.alreadyMerged)===!0;yt(L=>{var te;return{...L,[u]:{preview:((te=L[u])==null?void 0:te.preview)??null,loading:!1,applying:!1,cleaning:!0,error:null}}});try{const L=await jc(u,{deleteBranch:b});if(yt(te=>{var fe;return{...te,[u]:{preview:((fe=te[u])==null?void 0:fe.preview)??null,loading:!1,applying:!1,cleaning:!1,error:null}}}),Ln(!1),es(te=>(te==null?void 0:te.workspaceId)===u?null:te),Ve(),await ze(),s(Gt(a.parentWorkspaceId),{replace:!0}),L.branchDeleted){D.current({title:r("shell.worktreeCleanupDeleteBranchSuccess",{branch:L.deletedBranchName||a.branchName}),tone:"success"});return}if(L.branchDeleteRequested){D.current({title:r("shell.worktreeCleanupDeleteBranchPartialFailed",{branch:a.branchName}),description:L.branchDeleteError||void 0,tone:"warning"});return}D.current({title:r("shell.worktreeCleanupSuccess"),tone:"success"})}catch(L){yt(te=>{var fe;return{...te,[u]:{preview:((fe=te[u])==null?void 0:fe.preview)??null,loading:!1,applying:!1,cleaning:!1,error:L instanceof Error?L.message:r("shell.worktreeCleanupFailed")}}}),D.current({title:L instanceof Error?L.message:r("shell.worktreeCleanupFailed"),tone:"error"})}},[ln,s,ze,Ve,tt]),Es=l.useCallback(a=>{Ln(!1),es(a)},[]),mn=l.useCallback((a,u)=>{var b;E.current={workspaceId:a,knownRevision:u==null?void 0:u.knownRevision},(b=x.current)==null||b.subscribeTerminalManager(a,u)},[]),dt=l.useCallback((a,u)=>{var b;ue.current={workspaceId:a,knownRevision:u==null?void 0:u.knownRevision},(b=x.current)==null||b.requestTerminalManagerRefresh(a,u)},[]),Ws=l.useCallback(a=>(R.current.add(a),()=>{R.current.delete(a)}),[]),ft=l.useCallback((a,u)=>{We(b=>wf(b,a,u??new Date().toISOString()))},[]),Ye=l.useCallback(async(a,u)=>{C.current.set(a,u),We(b=>Ca(b,a,u));try{const b=await Ha(a,u),T=qt(b);T===u?C.current.set(a,T):C.current.delete(a),ot(b),Ve(),ze()}catch(b){throw C.current.delete(a),We(T=>Ca(T,a,!u)),b}},[ze,Ve,ot]),pn=l.useCallback((a,u)=>{qe("workbench.set_session_workspace",{sessionId:a,workspaceId:u}),et(b=>{if(!u){if(!(a in b))return b;const T={...b};return delete T[a],T}return b[a]===u?b:{...b,[a]:u}})},[]);l.useEffect(()=>{N.current=O.length>0},[O]),l.useEffect(()=>{qe("workbench.navigation_state",{navigationLoading:De,workspaceCount:O.length,sessionCount:O.reduce((a,u)=>a+u.sessions.length,0)})},[O,De]),l.useEffect(()=>{A.current!==null&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>{var z;A.current=null,!(I.current||N.current)&&(qe("workbench.refresh_navigation.ws_fallback_triggered"),(z=x.current)==null||z.requestRefresh())},1200);const a=new Cd({onConnectionChange:z=>{z==="connected"&&Nc(),z==="reconnect_failed"&&!N.current&&(gt(r("shell.navigationLoadFailed")),D.current({id:"workbench-navigation-connection",title:r("shell.navigationLoadFailed"),tone:"warning",durationMs:3600}))},onSnapshot:z=>{I.current=!0,qe("workbench.ws_snapshot_received",{workspaceCount:z.items.length,sessionCount:z.items.reduce((ye,Mt)=>ye+Mt.sessions.length,0)}),A.current!==null&&(window.clearTimeout(A.current),A.current=null),ns(z),Wt(!1)},onFileTreeSnapshot:z=>{P.current.forEach(ye=>ye(z))},onGitSnapshot:z=>{Ys(ql(z.workspaceId),{revision:z.revision??null,status:z.status,history:z.history,historyTotalCount:z.historyTotalCount,historyNextCursor:z.historyNextCursor,branches:z.branches}),an(ye=>{var en;const Mt=((en=O.find(Ql=>Ql.workspace.id===z.workspaceId))==null?void 0:en.workspace)??null;if(!Mt)return ye;const Ot=ye[z.workspaceId],He=zl(Kl((Ot==null?void 0:Ot.detail)??Gl(Mt),Mt),z);return Ys(Oi(z.workspaceId),He),{...ye,[z.workspaceId]:{detail:He,loading:!1,error:null}}}),_.current.forEach(ye=>ye(z))},onWorkspaceManagementSnapshot:z=>{Ys(Oi(z.workspaceId),z),an(ye=>({...ye,[z.workspaceId]:{detail:z,loading:!1,error:null}})),Y.current.forEach(ye=>ye(z))},onTerminalManagerSnapshot:z=>{R.current.forEach(ye=>ye(z))},onUnauthorized:()=>{Zs.clear(),s("/login",{replace:!0})}});a.primeWorkbenchSnapshot(p.current),x.current=a;const u=K.current,b=V.current,T=G.current,B=j.current,L=Z.current,te=ee.current,fe=E.current,de=ue.current;return u&&a.subscribeFileTree(u.workspaceId,u.paths,{knownRevisionByPath:u.knownRevisionByPath}),T&&a.subscribeGit(T.workspaceId,{knownRevision:T.knownRevision}),L&&a.subscribeWorkspaceManagement(L.workspaceId,{knownRevision:L.knownRevision}),fe&&a.subscribeTerminalManager(fe.workspaceId,{knownRevision:fe.knownRevision}),b&&a.requestFileTreeRefresh(b.workspaceId,b.paths,{knownRevisionByPath:b.knownRevisionByPath}),B&&a.requestGitRefresh(B.workspaceId,{knownRevision:B.knownRevision}),te&&a.requestWorkspaceManagementRefresh(te.workspaceId,{knownRevision:te.knownRevision}),de&&a.requestTerminalManagerRefresh(de.workspaceId,{knownRevision:de.knownRevision}),a.start(),()=>{A.current!==null&&(window.clearTimeout(A.current),A.current=null),x.current===a&&(x.current=null),a.close()}},[s]),l.useEffect(()=>{zn(ta,String(_e))},[_e]),l.useEffect(()=>{zn(na,String(lt))},[lt]),l.useEffect(()=>{zn(sa,String(Fe))},[Fe]),l.useEffect(()=>{zn(ra,String(Te))},[Te]),l.useEffect(()=>{if(!Ze){af(Ci);return}zn(Ci,Ze)},[Ze]),l.useEffect(()=>{if(wt||Te)return;const a=window.setTimeout(()=>{Rn(!0)},gh);return()=>{window.clearTimeout(a)}},[wt,Te]);const is=Js(n.pathname),pe=(is==null?void 0:is.sessionId)??null,rt=pe?Zl(pe):!1,Re=l.useMemo(()=>$c(O),[O]),hr=l.useMemo(()=>new Set(O.map(a=>a.workspace.id)),[O]),os=l.useMemo(()=>new Set(At),[At]),as=l.useMemo(()=>Re.filter(a=>a.session.isFavorite===!0).map(a=>a.session.sessionId),[Re]),Dt=l.useMemo(()=>new Set(as),[as]),Fn=l.useCallback(a=>{const u=Ri(a,At);p.current=u,_r(u),ut.current=a,We(a)},[At]),fr=l.useCallback(a=>{const u=!os.has(a),b=Ia(At,a,u),T=Ri(O,b);p.current=T,_r(T),zt(b),Ua(a,{collapsed:u}).catch(B=>{const L=Ia(b,a,!u),te=Ri(O,L);p.current=te,_r(te),zt(L),D.current({title:B instanceof Error?B.message:r("shell.workspaceCollapseStateSaveFailed"),tone:"error"})})},[os,At,O]),As=l.useCallback(()=>{le.current={originalGroups:ut.current}},[]),Ps=l.useCallback((a,u,b)=>{const T=ut.current,B=pf(T,a,u,b);B!==T&&Fn(B)},[Fn]),ls=l.useCallback(()=>{const a=le.current;le.current=null;const u=ut.current;a&&(a.originalGroups.length===u.length&&a.originalGroups.every((b,T)=>{var B;return b.workspace.id===((B=u[T])==null?void 0:B.workspace.id)})||Cc({workspaceIds:u.map(b=>b.workspace.id)}).catch(b=>{Fn(a.originalGroups),D.current({title:b instanceof Error?b.message:r("shell.workspaceReorderFailed"),tone:"error"})}))},[Fn]);l.useEffect(()=>{const a=new Map;if(Re.forEach(({session:u})=>{a.set(u.sessionId,{activityState:u.activityState,completedAt:u.completedAt??null,runningState:u.runningState??null})}),!be.current){be.current=!0,me.current=a;return}Re.forEach(({session:u})=>{var te;if(u.sessionId===pe)return;const b=me.current.get(u.sessionId);if(!b)return;const T=b.activityState!=="completed_unread"&&u.activityState==="completed_unread",B=((te=u.title)==null?void 0:te.trim())||r("common.unknown");if(f&&T){const fe=r("conversation.backgroundCompletionToastDescription",{title:B});D.current({id:`workbench-session-completed-${u.sessionId}-${u.completedAt??"unknown"}`,title:r("conversation.backgroundCompletionToastTitle"),description:fe,tone:"success",durationMs:8e3,action:{label:r("shell.contextOpenSession"),onClick:()=>Ct(u.workspaceId,u.sessionId)}}),v.current.showNotification(r("conversation.backgroundCompletionToastTitle"),fe)}const L=b.runningState!=="failed"&&(u.runningState??null)==="failed";if(k&&L){const fe=Wh(u)??r("conversation.runtimeFailed"),de=r("conversation.backgroundFailureToastDescription",{title:B,detail:fe});D.current({id:`workbench-session-failed-${u.sessionId}-${u.updatedAt}`,title:r("conversation.backgroundFailureToastTitle"),description:de,tone:"error",durationMs:8e3,action:{label:r("shell.contextOpenSession"),onClick:()=>Ct(u.workspaceId,u.sessionId)}}),v.current.showNotification(r("conversation.backgroundFailureToastTitle"),de)}}),me.current=a},[pe,Re,f,k,Ct]),l.useEffect(()=>{y.current=Re.map(a=>a.session).filter(a=>a.sessionId!==pe&&Mh(a)).map(a=>{var u;return{sessionId:a.sessionId,workspaceId:a.workspaceId,title:((u=a.title)==null?void 0:u.trim())||r("common.unknown")}})},[pe,Re]),l.useEffect(()=>{let a=!1,u=null;const b=()=>{u=window.setTimeout(()=>{T().finally(()=>{a||b()})},vh)},T=async()=>{var de;const B=y.current;if(B.length===0){Ge.current||(Ge.current=!0),F.current="";return}const L=new Set(B.map(z=>z.sessionId)),te=await Promise.all(B.map(async z=>{try{const ye=await Ic(z.sessionId);return{session:z,items:ye.items}}catch{return{session:z,items:null}}}));if(a)return;for(const z of te){if(!z.items)continue;const ye=z.items.filter(He=>He.status==="pending"),Mt=new Set(ye.map(He=>He.id)),Ot=Ee.current.get(z.session.sessionId)??new Set;Ge.current&&ye.forEach(He=>{if(Ot.has(He.id)||!h)return;const en=r("conversation.backgroundPermissionToastDescription",{title:z.session.title,requestTitle:He.title});D.current({id:`workbench-permission-request-${He.id}`,title:r("conversation.permissionRequestToastTitle"),description:en,tone:"warning",durationMs:8e3,action:{label:r("shell.contextOpenSession"),onClick:()=>Ct(z.session.workspaceId,z.session.sessionId)}}),v.current.showNotification(r("conversation.permissionRequestToastTitle"),en)}),Ee.current.set(z.session.sessionId,Mt)}for(const[z,ye]of Ee.current.entries())!L.has(z)&&ye.size===0&&Ee.current.delete(z);const fe=Eh(Ee.current,L);Ge.current&&fe!==F.current&&((de=x.current)==null||de.requestRefresh()),F.current=fe,Ge.current=!0};return T().finally(()=>{a||b()}),()=>{a=!0,u!==null&&window.clearTimeout(u)}},[h,Ct]),l.useEffect(()=>{if(De&&O.length===0)return;const a=new Set(O.map(u=>u.workspace.id));zt(u=>Ol(u,a)),In(u=>u&&a.has(u)?u:null)},[O,De]);const bn=Re.find(a=>a.session.sessionId===pe)??null,Le=(bn==null?void 0:bn.workspace.id)??(pe?Is[pe]??null:null),mt=pa(n.pathname,n.search),cs=mt&&hr.has(mt)?mt:null,Bs=Ze&&hr.has(Ze)?Ze:null,Ls=Le??cs??Bs??null,re=Ls??((Ft=O[0])==null?void 0:Ft.workspace.id)??null,Ds=l.useCallback(a=>{if(a){const u=Re.find(b=>b.workspace.id===a)??null;if(u)return u}return Re[0]??null},[Re]),kn=l.useCallback(a=>{const u=typeof window>"u"?null:window.localStorage.getItem(Or);if(!u)return null;const b=u.split("?")[0]??u,T=Js(b);if(!T)return window.localStorage.removeItem(Or),null;const B=T.sessionId,L=Re.find(fe=>fe.session.sessionId===B)??null,te=T.workspaceId??(L==null?void 0:L.workspace.id)??null;return L&&(!a||te===a)?$t(L.workspace.id,L.session.sessionId):(window.localStorage.removeItem(Or),null)},[Re]),ds=l.useMemo(()=>cn.filter(a=>!Jt.has(a.id)),[Jt,cn]),On=l.useMemo(()=>ds.filter(a=>Fh(a,Bt)).length,[ds,Bt]);l.useEffect(()=>{St&&Ms(ds)},[ds,Ms,St]);const ci=l.useCallback(a=>{jt(!1),a.routePath&&s(a.routePath)},[s]),Hn=l.useCallback(async(a,u)=>{const b=ce.current+1;ce.current=b;try{const T=await Ku(a,u);if(b!==ce.current)return;nt(B=>{const L=new Set(B);return T.item?L.add(T.item.notificationId):L.delete(a),L})}catch(T){if(b!==ce.current)return;D.current({title:r("shell.globalNotificationsArchiveFailed"),description:T instanceof Error?T.message:void 0,tone:"error"})}},[]);l.useEffect(()=>{Le&&In(a=>a===Le?a:Le)},[Le]),l.useEffect(()=>{var L;if(De)return;const a=((L=O[0])==null?void 0:L.workspace.id)??null,u=cs??a??Bs,b=pe&&!rt?Ds(u):null,T=pe&&!rt?kn(u):null,B=b?$t(b.workspace.id,b.session.sessionId):null;if(mt&&!cs){s(T??B??(a?qh(n.pathname,a):Ii(e)),{replace:!0});return}if(pe&&!rt&&!Le){s(T??B??(a?Qs(a):Ii(e)),{replace:!0});return}},[pe,Ds,rt,n.pathname,s,O,De,kn,mt,Le,e,Bs,cs]),l.useEffect(()=>{qe("workbench.current_workspace_resolved",{currentSessionId:pe,sessionWorkspaceId:Le,routeWorkspaceId:mt,currentWorkspaceId:re,source:Le?bn?"navigation":"sessionWorkspaceMap":mt?"route":Ze?"workspaceSelection":"navigationFallback"})},[bn,pe,re,mt,Ze,Le]),l.useEffect(()=>{qe("workbench.info_panel_state",{infoPanelReady:wt,rightCollapsed:Te,currentWorkspaceId:re,sessionWorkspaceId:Le,currentSessionId:pe})},[pe,re,wt,Te,Le]);const pt=Di(n.pathname)?"terminals":Xr(n.pathname)?"butler":"conversation",Be=e==="mobile",Un=Ii(e),mr=l.useMemo(()=>O.map(a=>{const u=Rl(a.sessions);return{workspace:a.workspace,visibleSessions:u,archivedSessions:a.sessions.filter(b=>qt(b)&&!si(b)),visibleSessionTree:uo(u,c).filter(b=>!Dt.has(b.item.sessionId)&&!Yi(Et(b),T=>Dt.has(T.sessionId))),childWorktrees:Al(a.childWorktrees,Dt,c),isCollapsed:os.has(a.workspace.id)}}),[os,Dt,O,c]),_s=l.useMemo(()=>Pu(O),[O]),bt=l.useMemo(()=>uf(O,re),[re,O]),pr=l.useMemo(()=>re?(bt==null?void 0:bt.workspace)??O.map(a=>a.workspace).find(a=>a.id===re)??null:null,[re,bt,O]),$n=(bt==null?void 0:bt.meta)??null,It=(re?_s[re]??null:null)??(pr?co(pr):null),br=$n?tt[$n.workspaceId]??null:null,qn=l.useMemo(()=>Re.filter(a=>Dt.has(a.session.sessionId)&&!qt(a.session)&&!_i(a.session)),[Dt,Re]),Fs=n.pathname.startsWith("/settings")?"settings":Xr(n.pathname)?"terminals":Di(n.pathname)?"butler":$h(n.pathname)?n.pathname.endsWith("/tools/processes")||n.pathname==="/tools/processes"?"butler":"sessions":Uh(n.pathname)||ba(n.pathname)?"sessions":"workspaces",di=Be&&(Fs==="sessions"&&ba(n.pathname)||Xr(n.pathname)),kr=ti({isNativeMobile:i.isNativeMobile,viewportClass:i.viewportClass}),Os=nr({viewportClass:i.viewportClass,activeEntry:Fs,hasNavigationPanel:Be,hasAuxiliaryPanel:Be,preferCompactLayout:kr}),gr=Be&&al(Os),wr=Be&&ll(Os),us=l.useMemo(()=>O.map(a=>a.workspace),[O]),ui=l.useMemo(()=>{const a=Pt.trim().toLowerCase();return a?Re.filter(u=>{const b=(u.session.title||"").toLowerCase(),T=u.workspace.name.toLowerCase(),B=ri(u.session.provider,"full").toLowerCase();return b.includes(a)||T.includes(a)||B.includes(a)}):[]},[Re,Pt]);l.useEffect(()=>{var u;const a=re??((u=O[0])==null?void 0:u.workspace.id)??"";a&&Rs(b=>b&&O.some(B=>B.workspace.id===b)?b:a)},[re,O]),l.useEffect(()=>{pe&&!rt&&Le&&zn(Or,`${n.pathname}${n.search}`)},[pe,rt,n.pathname,n.search,Le]),l.useEffect(()=>{if(pe&&rt){H.current=`${n.pathname}${n.search}`;return}pe&&!rt&&(H.current=null)},[pe,rt,n.pathname,n.search]),l.useEffect(()=>{Be||(xe(!1),Pe(!1))},[Be]),l.useEffect(()=>{!Be||De||!Hh(n.pathname)||Ls||(xe(!1),Pe(!1),s(Un,{replace:!0}))},[Ls,Be,n.pathname,s,De,Un]);function hi(){if(Be){xe(!0);return}Yn(!1)}function fi(){if(Qt(),Be){Pe(!0);return}Kt(!1)}function mi(){if(Be){xe(a=>!a);return}Yn(a=>!a)}function pi(){if(Qt(),Be){Pe(a=>!a);return}Kt(a=>!a)}function Qt(){Rn(!0)}function hs(a){In(a),Qt(),pe&&Le!==a&&s(Un)}const fs=l.useCallback(async a=>{var T;const u=((T=Re.find(B=>B.session.sessionId===a))==null?void 0:T.session)??null,b=(u==null?void 0:u.isFavorite)!==!0;We(B=>Ta(B,a,b));try{const B=await Tc(a,b);ot(B),Ve()}catch(B){throw We(L=>Ta(L,a,!b)),B}},[Re,Ve,ot]),xr=l.useCallback((a,u)=>{Tl(a,u).then(()=>{s(sl(a,u))}).catch(b=>{o({title:b instanceof Error?b.message:r("shell.startSessionFailed"),tone:"error"})})},[s,o]),vr=l.useCallback(a=>{var T;const u=((T=a.workspaceId)==null?void 0:T.trim())||re,b=Gh(a.filePath);return!u||!b?!1:(Qt(),rn("files"),Be?(xe(!1),Pe(!0)):Kt(!1),ar({requestId:U.current+1,workspaceId:u,filePath:b,openViewer:a.openViewer===!0}),U.current+=1,!0)},[re,Be]),yr=l.useCallback(async(a,u)=>{const b=await $a(a,u.trim());return ot(b),b},[ot]);function Hs(a){En(!0)}function Sr(){En(!1),Wn("sessions"),An(""),Xt(null),vt([]),Pn(!1)}async function jr(){const a=Pt.trim();if(!a||!xt.trim()){vt([]),Xt(null);return}Pn(!0),Xt(null);try{const u=await _c(xt,a);vt(u.items)}catch(u){vt([]),Xt(u instanceof Error?u.message:r("shell.searchCodeFailed"))}finally{Pn(!1)}}function Nr(a,u){const b=S.current;b&&(b.style.setProperty("--workbench-left-width",`${a}px`),b.style.setProperty("--workbench-left-current-width",Fe?"0px":`${a}px`),b.style.setProperty("--workbench-right-width",`${u}px`),b.style.setProperty("--workbench-right-current-width",Te?"0px":`${u}px`))}function gn(a={}){return{leftWidth:a.leftWidth??(Fe?0:J.current),rightWidth:a.rightWidth??(ne&&!Te?ke.current:0),leftCollapsed:a.leftCollapsed??Fe,rightCollapsed:a.rightCollapsed??(!ne||Te),prefersDarkAppearance:a.prefersDarkAppearance??Dn!=="light",isResizing:a.isResizing??ct!==null}}function Us(a,u){var fe;u.preventDefault(),u.stopPropagation(),(fe=window.getSelection())==null||fe.removeAllRanges();const b=u.clientX,T=a==="left"?_e:lt;Cs(a);const B=()=>{const de=se.current;if(se.current=null,de!==null){if(a==="left"){J.current=de,ir(z=>z===de?z:de),Nr(de,ke.current);return}ke.current=de,or(z=>z===de?z:de),Nr(J.current,de)}};function L(de){var Ot;de.preventDefault(),(Ot=window.getSelection())==null||Ot.removeAllRanges();const z=de.clientX-b,ye=a==="left"?qr(T+z,oa,la):qr(T-z,aa,ca),Mt=a==="left"?J.current:ke.current;ye===Mt&&se.current===null||(se.current=ye,we.current===null&&(we.current=window.requestAnimationFrame(()=>{we.current=null,B()})))}function te(){document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",te),we.current!==null&&(window.cancelAnimationFrame(we.current),we.current=null),B(),Cs(z=>z===a?null:z);const de=gn({isResizing:!1});$e.current=de,i.bridge.syncNativeSidebarLayout(de)}document.addEventListener("mousemove",L,{passive:!1}),document.addEventListener("mouseup",te)}function Gn(){if(m())return;if(Re.length===0){s(Un);return}const a=$t(Re[0].workspace.id,Re[0].session.sessionId);s(a)}function d(){if(!m(re)){if(re){s(Qs(re));return}s(Un)}}function m(a){if(pe&&Le)return a&&Le&&Le!==a?!1:(s(`${n.pathname}${n.search}`),!0);if(H.current){if(a){const[b,T=""]=H.current.split("?"),B=pa(b??H.current,T?`?${T}`:"");if(B&&B!==a)return!1}return s(H.current),!0}const u=kn(a);return u?(s(u),!0):!1}l.useEffect(()=>{if(typeof window>"u")return;function a(u){if(!(u.metaKey||u.ctrlKey)){u.key==="Escape"&&(xe(!1),Pe(!1));return}if(cf(u.target))return;const T=u.key.toLowerCase();if(!u.shiftKey&&T==="b"){u.preventDefault(),mi();return}if(u.shiftKey&&T==="i"){u.preventDefault(),pi();return}if(!u.shiftKey&&T===","){u.preventDefault(),s("/settings");return}if(!u.shiftKey&&T==="1"){u.preventDefault(),Gn();return}if(!u.shiftKey&&T==="2"){u.preventDefault(),s(re?vs(re):at());return}if(!u.shiftKey&&T==="k"){u.preventDefault(),df();return}u.shiftKey&&T==="r"&&(u.preventDefault(),ze())}return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[s,ze,Be,Gn]);const w=l.useMemo(()=>({shellMode:e,navigationGroups:O,navigationLoading:De,navigationError:Je,currentWorkspaceId:re,currentSessionId:pe,favoriteSessionIds:as,favoriteSessions:qn,globalNotifications:cn,archivedNotificationIds:Array.from(Jt),showArchivedNotifications:Zt,unreadNotificationCount:On,refreshNavigation:ze,requestNavigationRefresh:Ve,openNotificationPanel:()=>{jt(!0)},closeNotificationPanel:()=>{jt(!1)},setShowArchivedNotifications:un,archiveNotification:a=>{Hn(a,!0)},unarchiveNotification:a=>{Hn(a,!1)},setAuxiliaryPanel:Ke,subscribeFileTree:Lt,requestFileTreeRefresh:ss,addFileTreeSnapshotListener:hn,subscribeGitSnapshot:fn,requestGitRefresh:ht,addGitSnapshotListener:dr,subscribeWorkspaceManagementSnapshot:rs,requestWorkspaceManagementRefresh:_n,addWorkspaceManagementSnapshotListener:Tt,workspaceManagementStateById:Yt,subscribeTerminalManagerSnapshot:mn,requestTerminalManagerRefresh:dt,addTerminalManagerSnapshotListener:Ws,selectWorkspace:hs,toggleFavoriteSession:fs,archiveSession:a=>Ye(a,!0),unarchiveSession:a=>Ye(a,!1),renameSession:yr,startDraftSession:xr,markNavigationSessionSeen:ft,upsertNavigationSession:ot,setSessionWorkspace:pn,revealWorkspaceFile:vr}),[hn,dr,Tt,Ws,Ye,pe,re,cn,as,qn,hs,Jt,ft,Je,O,De,On,ss,ht,_n,ze,Ve,un,Ke,dt,yr,Zt,Yt,e,xr,pn,Lt,fn,rs,mn,Hn,fs,ot,vr]),M={"--workbench-left-width":`${_e}px`,"--workbench-left-current-width":Fe?"0px":`${_e}px`,"--workbench-right-width":`${lt}px`,"--workbench-right-current-width":Te?"0px":`${lt}px`},W=pt==="butler"?Qe:t.jsx(Ea,{panelReady:wt,activeTab:Ts,fileRevealRequest:on,onTabChange:a=>{Qt(),rn(a)},currentSessionId:rt?null:pe,activeWorkspaceId:re,navigationGroups:O,workspaceContext:It,worktreeMeta:$n,worktreeMergeState:br,onRefreshWorktreeMergePreview:Xe,onApplyWorktreeMerge:ur,onCleanupWorktree:Ie}),ne=W!==null,X=i.isDesktop&&i.ui.osFamily==="macos"&&i.ui.prefersOverlayTitlebar;l.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const{documentElement:a,body:u}=document,b=()=>{oe.current!==null&&(window.clearTimeout(oe.current),oe.current=null);const B=ae.current;ae.current=!1,a.removeAttribute(Ur),u==null||u.removeAttribute(Ur),B&&he.current&&(he.current=!1,it(L=>L+1))};if(!X){b();return}const T=()=>{ae.current=!0,a.setAttribute(Ur,"true"),u==null||u.setAttribute(Ur,"true"),oe.current!==null&&window.clearTimeout(oe.current),oe.current=window.setTimeout(()=>{b()},Sh)};return window.addEventListener("resize",T),()=>{window.removeEventListener("resize",T),b()}},[X]);const ve=l.useMemo(()=>({leftWidth:Fe?0:_e,rightWidth:ne&&!Te?lt:0,leftCollapsed:Fe,rightCollapsed:!ne||Te,prefersDarkAppearance:Dn!=="light",isResizing:ct!==null}),[ct,Fe,_e,Te,lt,ne,Dn]),Oe=l.useDeferredValue(ve),Ae=ct===null?Oe:ve,$e=l.useRef(ve);l.useEffect(()=>{$e.current=ve},[ve]),l.useEffect(()=>{if(typeof window>"u")return;let a=null;const u=()=>{a=null,i.bridge.syncNativeSidebarLayout(Ae)},b=()=>{a!==null&&window.cancelAnimationFrame(a),a=window.requestAnimationFrame(u)};return st?(b(),()=>{a!==null&&window.cancelAnimationFrame(a)}):(i.bridge.syncNativeSidebarLayout({leftWidth:0,rightWidth:0,leftCollapsed:!0,rightCollapsed:!0,prefersDarkAppearance:!1,isResizing:!1}),()=>{a!==null&&window.cancelAnimationFrame(a)})},[Ae,i.bridge,st]),l.useLayoutEffect(()=>{const a=S.current;if(!a||!X||typeof window>"u"){fa(a);return}let u=null,b=null;const T=new Set([a]),B=()=>{he.current=!1;const te=window.getComputedStyle(a),fe=Cl(te,"--desktop-macos-traffic-light-center-y");if(fe===null){fa(a);return}const de={navToolbar:yn(a,Me.navToolbar.selector),infoTabs:yn(a,Me.infoTabs.selector),auxiliaryToolbarButton:yn(a,Me.auxiliaryToolbarButton.selector),conversationHeaderMain:yn(a,Me.conversationHeaderMain.selector),conversationHeaderActions:yn(a,Me.conversationHeaderActions.selector),terminalTabbarMain:yn(a,Me.terminalTabbarMain.selector),collapsedLeftControls:yn(a,Me.collapsedLeftControls.selector),collapsedRightControls:yn(a,Me.collapsedRightControls.selector)},z=[de.infoTabs,de.conversationHeaderMain,de.conversationHeaderActions,de.terminalTabbarMain].filter(He=>He!==null),ye=[de.collapsedLeftControls,de.collapsedRightControls].filter(He=>He!==null),Mt=ye.length>0?Ut(te,"--workbench-collapsed-controls-live-shift-y",fe,ye.reduce((He,en)=>He+en,0)/ye.length):null,Ot=z.length>0?Ut(te,"--workbench-titlebar-live-content-shift-y",fe,z.reduce((He,en)=>He+en,0)/z.length):null;Ht(a,"--workbench-titlebar-live-content-shift-y",Ot),Ht(a,"--workbench-collapsed-controls-live-shift-y",Mt),Ht(a,Me.navToolbar.variableName,Ut(te,Me.navToolbar.variableName,fe,de.navToolbar)),Ht(a,Me.infoTabs.variableName,Ut(te,Me.infoTabs.variableName,fe,de.infoTabs)),Ht(a,Me.auxiliaryToolbarButton.variableName,Ut(te,Me.auxiliaryToolbarButton.variableName,fe,de.auxiliaryToolbarButton)),Ht(a,Me.conversationHeaderMain.variableName,Ut(te,Me.conversationHeaderMain.variableName,fe,de.conversationHeaderMain)),Ht(a,Me.conversationHeaderActions.variableName,Ut(te,Me.conversationHeaderActions.variableName,fe,de.conversationHeaderActions)),Ht(a,Me.terminalTabbarMain.variableName,Ut(te,Me.terminalTabbarMain.variableName,fe,de.terminalTabbarMain)),Ht(a,Me.collapsedLeftControls.variableName,Ut(te,Me.collapsedLeftControls.variableName,fe,de.collapsedLeftControls)),Ht(a,Me.collapsedRightControls.variableName,Ut(te,Me.collapsedRightControls.variableName,fe,de.collapsedRightControls))},L=()=>{if(ae.current){he.current=!0;return}u!==null&&window.cancelAnimationFrame(u),u=window.requestAnimationFrame(()=>{u=null,B()})};if(L(),typeof ResizeObserver<"u"){b=new ResizeObserver(()=>{L()});for(const te of Object.values(Me))for(const fe of a.querySelectorAll(te.selector))T.add(fe);for(const te of T)b.observe(te)}return window.addEventListener("resize",L),()=>{u!==null&&window.cancelAnimationFrame(u),window.removeEventListener("resize",L),b==null||b.disconnect()}},[pt,wt,Fe,n.pathname,n.search,Te,ne,X,cr]);const Rt=Be?t.jsx(Ma,{workspaceGroups:mr,workspaceVisualContextMap:_s,sessionDisplaySortMode:c,favoriteSessions:qn,favoriteSessionIds:Dt,activeWorkspaceId:re,isConversationActive:pt==="conversation",isTerminalActive:pt==="terminals",isButlerActive:pt==="butler",isSearchOpen:Mn,navigationLoading:De,navigationError:Je,activeSessionId:pe,onRefreshNavigation:ze,onSessionUpdated:ot,onNavigateConversation:Gn,onNavigateTerminals:()=>{xe(!1),s(re?vs(re):at())},onNavigateButler:()=>{xe(!1),s(re?Vn(re):at())},onOpenSearch:()=>{xe(!1),Hs()},onOpenSettings:()=>{xe(!1),s("/settings")},onSelectWorkspace:hs,onToggleWorkspaceCollapse:fr,onStartWorkspaceReorder:As,onPreviewWorkspaceReorder:Ps,onCommitWorkspaceReorder:ls,allowWorkspaceReorder:!1,subscribeGitSnapshot:fn,requestGitRefresh:ht,subscribeWorkspaceManagementSnapshot:rs,requestWorkspaceManagementRefresh:_n,onToggleFavoriteSession:fs,onArchiveSession:a=>Ye(a,!0),onUnarchiveSession:a=>Ye(a,!1),workspaceManagementStateById:Yt,setWorkspaceManagementStateById:an,unreadNotificationCount:On,notificationPanelOpen:St,onToggleNotificationPanel:()=>{jt(a=>!a)},onClose:()=>xe(!1)}):null,_t=Be&&ne?W:null;return t.jsxs(Il.Provider,{value:w,children:[Be?t.jsx(t.Fragment,{children:t.jsx(bd,{activeEntry:Fs,presentation:di?"conversation-focus":"default",navigationPanel:Rt,auxiliaryPanel:_t,onOpenNavigation:()=>{Pe(!1),xe(!0)},onOpenSearch:()=>{xe(!1),Pe(!1),Hs()},onOpenAuxiliary:()=>{ne&&(Qt(),xe(!1),Pe(!0))},onNavigateWorkspaces:()=>{xe(!1),Pe(!1),s(at())},onNavigateTerminals:()=>{xe(!1),Pe(!1),s(re?vs(re):at())},onNavigateButler:()=>{xe(!1),Pe(!1),s(re?Vn(re):at())},onNavigateSessions:()=>{xe(!1),Pe(!1),d()},onNavigateToolFiles:()=>{xe(!1),Pe(!1),s(re?el(re):at())},onNavigateToolGit:()=>{xe(!1),Pe(!1),s(re?tl(re):at())},onNavigateToolProcesses:()=>{xe(!1),Pe(!1),s(re?nl(re):at())},onNavigateSettings:()=>{xe(!1),Pe(!1),s("/settings")},children:t.jsx(po,{})})}):t.jsx("div",{className:"workbench-shell",ref:S,style:M,onMouseDownCapture:lr,onDoubleClickCapture:li,"data-nav-loading":De,"data-left-collapsed":Fe,"data-right-collapsed":Te,"data-info-ready":wt,"data-runtime-platform":i.platform,"data-os-family":i.ui.osFamily,"data-overlay-titlebar":i.ui.prefersOverlayTitlebar,children:t.jsxs("div",{className:"workbench-body-shell",children:[t.jsx("aside",{className:"workbench-nav surface-card","data-collapsed":Fe,children:t.jsx(Ma,{workspaceGroups:mr,workspaceVisualContextMap:_s,sessionDisplaySortMode:c,favoriteSessions:qn,favoriteSessionIds:Dt,activeWorkspaceId:re,isConversationActive:pt==="conversation",isTerminalActive:pt==="terminals",isButlerActive:pt==="butler",isSearchOpen:Mn,navigationLoading:De,navigationError:Je,activeSessionId:pe,onRefreshNavigation:ze,onSessionUpdated:ot,onNavigateConversation:Gn,onNavigateTerminals:()=>s(re?vs(re):at()),onNavigateButler:()=>s(re?Vn(re):at()),onOpenSearch:()=>Hs(),onOpenSettings:()=>s("/settings"),onSelectWorkspace:hs,onToggleWorkspaceCollapse:fr,onStartWorkspaceReorder:As,onPreviewWorkspaceReorder:Ps,onCommitWorkspaceReorder:ls,allowWorkspaceReorder:!0,subscribeGitSnapshot:fn,requestGitRefresh:ht,subscribeWorkspaceManagementSnapshot:rs,requestWorkspaceManagementRefresh:_n,onToggleFavoriteSession:fs,onArchiveSession:a=>Ye(a,!0),onUnarchiveSession:a=>Ye(a,!1),workspaceManagementStateById:Yt,setWorkspaceManagementStateById:an,unreadNotificationCount:On,notificationPanelOpen:St,onToggleNotificationPanel:()=>{jt(a=>!a)},onToggleCollapse:()=>Yn(!0)})}),t.jsx("div",{className:"workbench-side-resizer","data-side":"left","data-collapsed":Fe,role:"separator","aria-label":r("shell.leftResizerLabel"),onMouseDown:Fe?void 0:a=>Us("left",a)}),t.jsxs("div",{className:"workbench-main-shell",children:[t.jsxs("div",{className:"workbench-collapsed-rail","aria-hidden":!Fe&&!Te,children:[t.jsxs("div",{className:"workbench-collapsed-controls left","data-visible":Fe,children:[t.jsx(Ra,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:r("shell.showSessionSidebar"),side:"left",collapsed:!0,onClick:hi}),t.jsx(jl,{collapsed:!0}),t.jsx(Xl,{unreadCount:On,open:St,onToggle:()=>{jt(a=>!a)},collapsed:!0})]}),ne?t.jsx("div",{className:"workbench-collapsed-controls right","data-visible":Te,children:t.jsx(Ra,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:r("shell.showInfoSidebar"),side:"right",collapsed:!0,onClick:fi})}):null]}),t.jsx(po,{})]}),ne?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"workbench-side-resizer","data-side":"right","data-collapsed":Te,role:"separator","aria-label":r("shell.rightResizerLabel"),onMouseDown:Te?void 0:a=>Us("right",a)}),t.jsx("aside",{className:"workbench-auxiliary surface-card","data-workspace-tone":(It==null?void 0:It.tone)??"root","data-worktree-depth":(It==null?void 0:It.depth)??0,"data-collapsed":Te,"data-custom-panel":pt==="butler",style:tn(It),children:pt==="butler"?t.jsx("div",{className:"workbench-auxiliary-custom-panel",children:Qe}):t.jsx(Ea,{panelReady:wt,activeTab:Ts,fileRevealRequest:on,onTabChange:a=>{Qt(),rn(a)},onToggleCollapse:()=>Kt(!0),currentSessionId:rt?null:pe,activeWorkspaceId:re,navigationGroups:O,workspaceContext:It,worktreeMeta:$n,worktreeMergeState:br,onRefreshWorktreeMergePreview:Xe,onApplyWorktreeMerge:ur,onCleanupWorktree:Es})})]}):null]})}),t.jsx(If,{open:St,notifications:cn,archivedNotificationIds:Jt,showArchivedNotifications:Zt,onClose:()=>jt(!1),onToggleShowArchivedNotifications:un,onArchiveNotification:a=>{Hn(a,!0)},onUnarchiveNotification:a=>{Hn(a,!1)},onSelectNotification:ci,preferredWorkspaceId:re,preferredSessionId:rt?null:pe}),t.jsx(Gf,{open:Mn,mode:Zn,keyword:Pt,codeWorkspaceId:xt,codeResults:Bn,codeLoading:oi,codeError:ai,workspaceOptions:us,sessionResults:ui,onClose:Sr,onModeChange:a=>{Wn(a),Xt(null),vt([])},onKeywordChange:a=>{An(a),Zn==="code"&&!a.trim()&&(vt([]),Xt(null))},onCodeWorkspaceChange:a=>Rs(a),onCodeSearch:()=>{jr()},onOpenSession:a=>{Sr();const u=Re.find(b=>b.session.sessionId===a)??null;s(u?$t(u.workspace.id,a):at())}}),t.jsxs(Ue,{open:je!==null,title:r("shell.worktreeCleanupModalTitle"),description:r("shell.worktreeCleanupModalDescription"),onClose:()=>{var a;je&&((a=tt[je.workspaceId])!=null&&a.cleaning)||(Ln(!1),es(null))},children:[t.jsx("p",{className:"workbench-section-empty",children:je?r("shell.worktreeCleanupConfirm",{name:je.displayName||je.branchName}):""}),je?t.jsxs("div",{className:"worktree-cleanup-modal-options",children:[t.jsxs("label",{className:"conversation-selection-checkbox worktree-cleanup-modal-option",children:[t.jsx("input",{type:"checkbox",checked:ln,disabled:!!((Ce=tt[je.workspaceId])!=null&&Ce.cleaning)||((ms=(Cr=tt[je.workspaceId])==null?void 0:Cr.preview)==null?void 0:ms.alreadyMerged)!==!0,onChange:a=>Ln(a.target.checked)}),t.jsx("span",{children:r("shell.worktreeCleanupDeleteBranchLabel",{branch:je.branchName})})]}),((Ir=(Tr=tt[je.workspaceId])==null?void 0:Tr.preview)==null?void 0:Ir.alreadyMerged)!==!0?t.jsx("p",{className:"conversation-selection-hint worktree-cleanup-modal-hint",children:r("shell.worktreeCleanupDeleteBranchHint")}):null]}):null,t.jsxs("div",{className:"workbench-modal-actions",children:[t.jsx("button",{type:"button",className:"secondary-button",disabled:!!(je&&((Rr=tt[je.workspaceId])!=null&&Rr.cleaning)),onClick:()=>{Ln(!1),es(null)},children:r("common.cancel")}),t.jsx("button",{type:"button",className:ln&&je&&((xn=(Mr=tt[je.workspaceId])==null?void 0:Mr.preview)==null?void 0:xn.alreadyMerged)===!0?"secondary-button workbench-danger-button":"primary-button",disabled:!je||!!(je&&((vn=tt[je.workspaceId])!=null&&vn.cleaning)),onClick:()=>{je&&Ie(je)},children:je&&((ho=tt[je.workspaceId])!=null&&ho.cleaning)?r("shell.worktreeCleanupRunning"):ln&&je&&((mo=(fo=tt[je.workspaceId])==null?void 0:fo.preview)==null?void 0:mo.alreadyMerged)===!0?r("shell.worktreeCleanupDeleteBranchAction"):r("shell.worktreeCleanupAction")})]})]}),Be?t.jsxs(t.Fragment,{children:[gr?null:t.jsx(Wa,{isOpen:Jn,side:"left",onClose:()=>xe(!1),children:Rt}),wr?null:t.jsx(Wa,{isOpen:Vt,side:"right",onClose:()=>Pe(!1),children:_t})]}):null]})}function Wa({isOpen:e,side:n,onClose:s,children:i,className:o,overlayClassName:c}){if(!e)return null;const h=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:["mobile-nav-overlay","open",c].filter(Boolean).join(" "),onClick:s,role:"button",tabIndex:0,"aria-label":r("common.back"),onKeyDown:f=>{f.key==="Escape"&&s()}}),t.jsx("div",{className:["mobile-nav-drawer",n,"open",o].filter(Boolean).join(" "),children:i})]});return typeof document>"u"?h:tr.createPortal(h,document.body)}function rp(){return l.useContext(Il)??{navigationGroups:[],navigationLoading:!1,navigationError:null,shellMode:"desktop",currentWorkspaceId:null,currentSessionId:null,favoriteSessionIds:[],favoriteSessions:[],globalNotifications:[],archivedNotificationIds:[],showArchivedNotifications:!1,unreadNotificationCount:0,refreshNavigation:async()=>{},requestNavigationRefresh:()=>{},openNotificationPanel:()=>{},closeNotificationPanel:()=>{},setShowArchivedNotifications:()=>{},archiveNotification:()=>{},unarchiveNotification:()=>{},setAuxiliaryPanel:()=>{},subscribeFileTree:()=>{},requestFileTreeRefresh:()=>{},addFileTreeSnapshotListener:()=>()=>{},subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{},subscribeWorkspaceManagementSnapshot:()=>{},requestWorkspaceManagementRefresh:()=>{},addWorkspaceManagementSnapshotListener:()=>()=>{},workspaceManagementStateById:{},subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{},selectWorkspace:()=>{},toggleFavoriteSession:async()=>{},archiveSession:async()=>{},unarchiveSession:async()=>{},renameSession:async()=>{throw new Error("workbench shell unavailable")},startDraftSession:()=>{},setSessionWorkspace:()=>{},upsertNavigationSession:()=>{},markNavigationSessionSeen:()=>{},revealWorkspaceFile:()=>!1}}function Zl(e){return e.startsWith("draft-")}export{at as $,mu as A,ah as B,pu as C,ro as D,Mu as E,fu as F,Pu as G,ym as H,Sn as I,Ns as J,ks as K,ep as L,Ym as M,Jm as N,tp as O,Vm as P,io as Q,xu as R,vu as S,Cm as T,ul as U,tn as V,Cd as W,qe as X,$c as Y,co as Z,Sm as _,sp as a,Yi as a0,Nd as a1,jm as a2,Nm as a3,Tm as a4,Im as a5,Pm as a6,Bm as a7,Am as a8,Em as a9,_c as aA,om as aB,am as aC,Hc as aD,sm as aE,mm as aF,km as aG,Fc as aH,vm as aI,pm as aJ,hm as aK,bm as aL,fm as aM,xm as aN,wm as aO,gm as aP,lm as aQ,rm as aR,Za as aS,Rm as aa,Km as ab,Mm as ac,Hm as ad,Xm as ae,Zm as af,Qm as ag,Gm as ah,_m as ai,Fm as aj,Om as ak,Um as al,$m as am,qm as an,Yu as ao,Wm as ap,Lm as aq,Dm as ar,zm as as,Wu as at,Xu as au,Li as av,cm as aw,um as ax,dm as ay,im as az,$t as b,mh as c,oh as d,np as e,Ou as f,Fu as g,Sl as h,wu as i,Qs as j,vs as k,$u as l,Uo as m,Qa as n,Vn as o,nl as p,Gt as q,Jr as r,ju as s,Cu as t,rp as u,el as v,Ys as w,tl as x,Su as y,oo as z};
|