@jingyi0605/codingns 0.6.0 → 0.6.5
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 +240 -2
- package/dist/public/assets/AdaptiveButlerPage-CfsUVZKl.js +3 -0
- package/dist/public/assets/{App-BZvapsi8.js → App-B9HcTkMT.js} +3 -3
- package/dist/public/assets/{BootstrapPage-gHSoa4JN.js → BootstrapPage-BgLdZEKQ.js} +1 -1
- package/dist/public/assets/ConversationPage-Cj8go7L0.js +4 -0
- package/dist/public/assets/{DesktopDetachPreviewPage-4eMRxiBW.js → DesktopDetachPreviewPage-YCBnyC58.js} +1 -1
- package/dist/public/assets/DesktopWindowPage-CrvndE23.js +2 -0
- package/dist/public/assets/FileContextPanel-CdC7GGw5.js +1 -0
- package/dist/public/assets/GitSidebar-z2SBinQh.js +6 -0
- package/dist/public/assets/MobileCreateSessionSheet-Cb2HM-y3.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-Bwv8Ovm_.js → MobileTopHeaderFrame-etF2HKlm.js} +1 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-CuGJ31kb.js +1 -0
- package/dist/public/assets/{RelayConnectEntryPage-D_4YL-YH.js → RelayConnectEntryPage-BB6DbGtP.js} +1 -1
- package/dist/public/assets/{ServerSettingsModal-CMSm3BZU.js → ServerSettingsModal-Bl1sacZg.js} +1 -1
- package/dist/public/assets/SessionIndexPage-NbF9gJnp.js +1 -0
- package/dist/public/assets/SettingsPage-DGsmQpLv.js +1 -0
- package/dist/public/assets/TerminalManagerPanel-BOm8Hi_v.js +1 -0
- package/dist/public/assets/{TerminalPage-DaooFaJ4.js → TerminalPage-B5JNFU6w.js} +19 -19
- package/dist/public/assets/TerminalRuntimeFallbackModal-CM3LRKOJ.js +1 -0
- package/dist/public/assets/{ToolFilesPage-CGxBvYG0.js → ToolFilesPage-GSqKQsj_.js} +1 -1
- package/dist/public/assets/ToolGitPage-BVFWMMQp.js +1 -0
- package/dist/public/assets/ToolProcessesPage-DZ456fYz.js +1 -0
- package/dist/public/assets/ToolsHomePage-DsJp0y8A.js +1 -0
- package/dist/public/assets/WorkbenchLandingPage-DyPei0e-.js +1 -0
- package/dist/public/assets/WorkbenchLayout-DlbgBT3n.js +4 -0
- package/dist/public/assets/WorkbenchModal-LNfB69qx.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-BsxumYx5.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-DhQo_0vu.css +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-CaXj5zVI.js +1 -0
- package/dist/public/assets/WorkspaceDetailPage-DOexuuaw.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-DkCHNjKD.js +1 -0
- package/dist/public/assets/{client-runtime-manager-BZpL17fc.js → client-runtime-manager-6OoYHXGd.js} +1 -1
- package/dist/public/assets/{file-tree-icon-Db5LXC8h.js → file-tree-icon-9pt1OStn.js} +1 -1
- package/dist/public/assets/index-BwlbvwaA.css +1 -0
- package/dist/public/assets/index-DSw-TkQL.js +42 -0
- package/dist/public/assets/legna-code-6TqgZ4Ls.png +0 -0
- package/dist/public/assets/{login-direct-candidate-resolver-1mxe_Oh8.js → login-direct-candidate-resolver-CLlYtBRq.js} +1 -1
- package/dist/public/assets/model-switch-api-C-l8-E1S.js +1 -0
- package/dist/public/assets/{preferences-service-DWnzl5a0.js → preferences-service-BCcfYP_d.js} +1 -1
- package/dist/public/assets/{relay-entry-C5_Iay0I.js → relay-entry-BmLkMKuq.js} +1 -1
- package/dist/public/assets/session-runtime-machine-DgtvREca.js +21 -0
- package/dist/public/assets/{terminal-runtime-meta-cdtWVfCm.js → terminal-runtime-meta-0h-75uRy.js} +1 -1
- package/dist/public/assets/useRegisteredDebugTemplates-rBVmAqh3.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +2 -0
- package/dist/server/config/env.js +7 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +4 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.js +12 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
- package/dist/server/modules/butler/butler-control-session-service.d.ts +4 -1
- package/dist/server/modules/butler/butler-control-session-service.js +17 -1
- package/dist/server/modules/butler/butler-control-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-profile-service.d.ts +3 -1
- package/dist/server/modules/butler/butler-profile-service.js +16 -4
- package/dist/server/modules/butler/butler-profile-service.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/opencli/opencli-bridge-skill-service.d.ts +12 -0
- package/dist/server/modules/opencli/opencli-bridge-skill-service.js +124 -0
- package/dist/server/modules/opencli/opencli-bridge-skill-service.js.map +1 -0
- package/dist/server/modules/opencli/opencli-catalog-service.d.ts +50 -0
- package/dist/server/modules/opencli/opencli-catalog-service.js +345 -0
- package/dist/server/modules/opencli/opencli-catalog-service.js.map +1 -0
- package/dist/server/modules/opencli/opencli-controller.d.ts +13 -0
- package/dist/server/modules/opencli/opencli-controller.js +30 -0
- package/dist/server/modules/opencli/opencli-controller.js.map +1 -0
- package/dist/server/modules/opencli/opencli-health-service.d.ts +28 -0
- package/dist/server/modules/opencli/opencli-health-service.js +106 -0
- package/dist/server/modules/opencli/opencli-health-service.js.map +1 -0
- package/dist/server/modules/opencli/opencli-install-discovery.d.ts +23 -0
- package/dist/server/modules/opencli/opencli-install-discovery.js +130 -0
- package/dist/server/modules/opencli/opencli-install-discovery.js.map +1 -0
- package/dist/server/modules/opencli/opencli-management-service.d.ts +59 -0
- package/dist/server/modules/opencli/opencli-management-service.js +152 -0
- package/dist/server/modules/opencli/opencli-management-service.js.map +1 -0
- package/dist/server/modules/opencli/opencli-runtime-builder.d.ts +11 -0
- package/dist/server/modules/opencli/opencli-runtime-builder.js +214 -0
- package/dist/server/modules/opencli/opencli-runtime-builder.js.map +1 -0
- package/dist/server/modules/opencli/opencli-runtime-layout.d.ts +3 -0
- package/dist/server/modules/opencli/opencli-runtime-layout.js +11 -0
- package/dist/server/modules/opencli/opencli-runtime-layout.js.map +1 -0
- package/dist/server/modules/opencli/opencli-runtime-profile-service.d.ts +29 -0
- package/dist/server/modules/opencli/opencli-runtime-profile-service.js +104 -0
- package/dist/server/modules/opencli/opencli-runtime-profile-service.js.map +1 -0
- package/dist/server/modules/opencli/opencli-runtime-resolver.d.ts +29 -0
- package/dist/server/modules/opencli/opencli-runtime-resolver.js +110 -0
- package/dist/server/modules/opencli/opencli-runtime-resolver.js.map +1 -0
- package/dist/server/modules/opencli/opencli-session-prompt-service.d.ts +11 -0
- package/dist/server/modules/opencli/opencli-session-prompt-service.js +66 -0
- package/dist/server/modules/opencli/opencli-session-prompt-service.js.map +1 -0
- package/dist/server/modules/parallel-sessions/parallel-session-controller.d.ts +4 -0
- package/dist/server/modules/parallel-sessions/parallel-session-controller.js +7 -0
- package/dist/server/modules/parallel-sessions/parallel-session-controller.js.map +1 -1
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.d.ts +6 -1
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.js +36 -2
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.js.map +1 -1
- 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-catalog-service.d.ts +46 -0
- package/dist/server/modules/provider/provider-catalog-service.js +249 -0
- package/dist/server/modules/provider/provider-catalog-service.js.map +1 -0
- package/dist/server/modules/provider/provider-controller.d.ts +20 -2
- package/dist/server/modules/provider/provider-controller.js +65 -5
- package/dist/server/modules/provider/provider-controller.js.map +1 -1
- package/dist/server/modules/provider/provider-disabled.d.ts +8 -0
- package/dist/server/modules/provider/provider-disabled.js +45 -0
- package/dist/server/modules/provider/provider-disabled.js.map +1 -0
- package/dist/server/modules/provider/provider-discovery-helper-client.d.ts +3 -0
- package/dist/server/modules/provider/provider-discovery-helper-client.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-helper-process.js +4 -4
- package/dist/server/modules/provider/provider-discovery-helper-process.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-runtime.d.ts +1 -1
- package/dist/server/modules/provider/provider-discovery-runtime.js +17 -9
- package/dist/server/modules/provider/provider-discovery-runtime.js.map +1 -1
- package/dist/server/modules/sessions/claude-compatible-provider-registry.d.ts +16 -0
- package/dist/server/modules/sessions/claude-compatible-provider-registry.js +91 -0
- package/dist/server/modules/sessions/claude-compatible-provider-registry.js.map +1 -0
- 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 +1 -0
- package/dist/server/modules/sessions/codex-app-server-helper-client.js +10 -0
- package/dist/server/modules/sessions/codex-app-server-helper-client.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 +18 -2
- package/dist/server/modules/sessions/session-history-service.js +330 -29
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-router-service.js +9 -4
- package/dist/server/modules/sessions/session-live-runtime-router-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-service.d.ts +22 -5
- package/dist/server/modules/sessions/session-live-runtime-service.js +350 -122
- 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-permission-request-service.d.ts +5 -2
- package/dist/server/modules/sessions/session-permission-request-service.js +26 -27
- package/dist/server/modules/sessions/session-permission-request-service.js.map +1 -1
- package/dist/server/modules/sessions/session-provider-config-service.d.ts +82 -0
- package/dist/server/modules/sessions/session-provider-config-service.js +925 -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/skills/skill-manager-service.d.ts +5 -0
- package/dist/server/modules/skills/skill-manager-service.js +26 -0
- package/dist/server/modules/skills/skill-manager-service.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-process-handlers.d.ts +1 -0
- package/dist/server/modules/tasks/task-helper-process-handlers.js +1 -1
- package/dist/server/modules/tasks/task-helper-process-handlers.js.map +1 -1
- package/dist/server/routes/opencli.d.ts +3 -0
- package/dist/server/routes/opencli.js +7 -0
- package/dist/server/routes/opencli.js.map +1 -0
- package/dist/server/routes/providers.js +4 -2
- package/dist/server/routes/providers.js.map +1 -1
- package/dist/server/server/create-server.d.ts +8 -0
- package/dist/server/server/create-server.js +48 -12
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/storage/repositories/opencli-catalog-entry-repository.d.ts +9 -0
- package/dist/server/storage/repositories/opencli-catalog-entry-repository.js +85 -0
- package/dist/server/storage/repositories/opencli-catalog-entry-repository.js.map +1 -0
- package/dist/server/storage/repositories/opencli-provider-repository.d.ts +8 -0
- package/dist/server/storage/repositories/opencli-provider-repository.js +88 -0
- package/dist/server/storage/repositories/opencli-provider-repository.js.map +1 -0
- package/dist/server/storage/repositories/opencli-runtime-profile-repository.d.ts +11 -0
- package/dist/server/storage/repositories/opencli-runtime-profile-repository.js +127 -0
- package/dist/server/storage/repositories/opencli-runtime-profile-repository.js.map +1 -0
- package/dist/server/storage/repositories/provider-control-repository.d.ts +9 -0
- package/dist/server/storage/repositories/provider-control-repository.js +51 -0
- package/dist/server/storage/repositories/provider-control-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/sqlite/client.js +72 -0
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +71 -0
- package/dist/server/types/domain.d.ts +56 -0
- 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/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/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 +41 -21
- 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 +15 -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 +167 -10
- 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/AdaptiveButlerPage-uFwDdN-F.js +0 -3
- package/dist/public/assets/ConversationPage-z3sXtKZ7.js +0 -4
- package/dist/public/assets/DesktopWindowPage-CZcoGApB.js +0 -2
- package/dist/public/assets/FileContextPanel-C3qex8bb.js +0 -1
- package/dist/public/assets/GitSidebar-BK6H16XU.js +0 -6
- package/dist/public/assets/MobileCreateSessionSheet-BYfbvK8o.js +0 -1
- package/dist/public/assets/MobileSheet-Ckug8hTb.js +0 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-RqWrBdn2.js +0 -1
- package/dist/public/assets/SessionIndexPage-DuK10DL5.js +0 -1
- package/dist/public/assets/SettingsPage-fyD-xaHL.js +0 -1
- package/dist/public/assets/TerminalManagerPanel-CCLr1Ypk.js +0 -1
- package/dist/public/assets/TerminalRuntimeFallbackModal-aUzjEBwP.js +0 -1
- package/dist/public/assets/ToolGitPage-C264yjS9.js +0 -1
- package/dist/public/assets/ToolProcessesPage-BOP4A1cb.js +0 -1
- package/dist/public/assets/ToolsHomePage-CQxGiKQA.js +0 -1
- package/dist/public/assets/WorkbenchLandingPage-CvAY68ca.js +0 -1
- package/dist/public/assets/WorkbenchLayout-DGm8Tc5M.js +0 -3
- package/dist/public/assets/WorkbenchModal-0tPIIhca.js +0 -1
- package/dist/public/assets/WorkbenchShellRoute-BF0nHWOk.css +0 -1
- package/dist/public/assets/WorkbenchShellRoute-DBBOsJo9.js +0 -1
- package/dist/public/assets/WorkspaceDebugDetailPage-CDerFYd2.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-BlJc1CHE.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-BUsKJ3lv.js +0 -1
- package/dist/public/assets/default-session-permission-mode-DT4SGiwp.js +0 -1
- package/dist/public/assets/index-BZLcEHW3.js +0 -42
- package/dist/public/assets/index-BbspQPC2.css +0 -1
- package/dist/public/assets/session-runtime-machine-DdLeDqQr.js +0 -17
- package/dist/public/assets/useRegisteredDebugTemplates-oFAQNIqh.js +0 -1
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var _r=Object.defineProperty;var Or=(t,e,s)=>e in t?_r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var Ie=(t,e,s)=>Or(t,typeof e!="symbol"?e+"":e,s);import{t as o,b as a,u as Dr,j as r,m as Yt,A as Hr,_ as Ws}from"./index-BZLcEHW3.js";import{W as Fr,D as bs}from"./WorkbenchModal-0tPIIhca.js";import{l as Br,m as Wr,n as bt,o as Tn,p as qr,q as Dt,a as Mt,s as ws,t as qt,v as Cn,w as En,S as Ur,x as Ss,y as Vr,z as Xr,A as Gr,B as $r,C as Yr,D as zr,E as cs,F as qs,G as Qr,H as Kr,I as Zr,J as Jr,K as jn,L as ei,N as An,f as zt,O as ti,P as si,u as ni,e as xs,Q as ri,i as ii,j as oi,R as ai}from"./MobileSheet-Ckug8hTb.js";import{g as $e}from"./default-session-permission-mode-DT4SGiwp.js";import{f as Ze,u as Je,e as Pt,g as at,h as Is,c as li}from"./App-BZvapsi8.js";import{u as lt,e as Us,b as Oe,Q as ci,R as ui,S as di,T as hi,U as mi,I as pi,r as Vs,V as he,w as fi,X as gi,i as Ms,Y as Ft,K as ys,Z as vi,_ as Ht,$ as Ps,a0 as us,a1 as Xs,G as bi,a2 as wi,E as Si,a3 as xi,a4 as Nn,a5 as it,a6 as Ii,a7 as ds,k as St,a8 as Mi,a9 as yi,aa as Pi,ab as ki,n as Ri,A as ct,ac as Ln,ad as _n,ae as On,af as Dn,C as Hn,ag as Ti,f as Ut,ah as Fn,P as Bn,ai as Ci,aj as Ei,ak as Gs,M as Wn,al as ji,L as Ai,J as Ni}from"./WorkbenchLayout-DGm8Tc5M.js";import{B as Li,M as _i,m as gt,c as $s,a as qn,i as Oi,r as Ys,b as hs,R as Di,g as Hi,p as Un,P as Vn,d as ks,C as Rs,e as Fi}from"./session-runtime-machine-DdLeDqQr.js";import{FileContextPanel as Xn}from"./FileContextPanel-C3qex8bb.js";import{GitSidebar as Gn}from"./GitSidebar-BK6H16XU.js";import{TerminalManagerPanel as $n}from"./TerminalManagerPanel-CCLr1Ypk.js";import{TerminalPage as Bi}from"./TerminalPage-DaooFaJ4.js";import{f as Yn,a as Vt,M as zn}from"./MobileWorkspaceSwitcherHeader-RqWrBdn2.js";import{w as xt,r as Qt,a as zs,b as Qs}from"./styles-DRVvx_kv.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-C5_Iay0I.js";import"./file-tree-icon-Db5LXC8h.js";import"./terminal-runtime-meta-cdtWVfCm.js";import"./TerminalRuntimeFallbackModal-aUzjEBwP.js";import"./MobileTopHeaderFrame-Bwv8Ovm_.js";function Ts({connectionState:t,onReconnect:e}){const{showToast:s,dismissToast:n}=Ze(),i=Br(),c=i?o(Wr(i.kind)):null;return a.useEffect(()=>{if(t==="connected"||t==="closed"){n("conversation-connection-state");return}if(t==="reconnect_failed"){s({id:"conversation-connection-state",title:o("conversation.connectionReconnectFailed"),description:c?o("conversation.reconnectFailedExplainWithRoute",{route:c}):o("conversation.reconnectFailedExplain"),tone:"warning",durationMs:null,action:{label:o("conversation.reconnectButton"),onClick:e}});return}s({id:"conversation-connection-state",title:o("conversation.connectionReconnecting"),description:c?o("conversation.reconnectExplainWithRoute",{route:c}):o("conversation.reconnectExplain"),tone:"info",durationMs:3200})},[c,t,n,e,s]),null}const At="provider-default",Wi=420,qi=520,Ui=32,Vi=48;function Xi(t){if(typeof document>"u")return!1;const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly","true"),e.style.position="fixed",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),e.focus(),e.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(e)}}async function Gi(t,e){var s;if(!(e.isDesktop&&(await e.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((s=navigator.clipboard)!=null&&s.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!Xi(t))throw new Error(o("conversation.copyContentFailed"))}}function Nt(t,e,s){return Math.min(Math.max(t,e),s)}function Kt(t){return t&&Dt.includes(t)?t:"codex"}function ms(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function Ks(t){var s,n;const e=ms(t);return((n=(s=e==null?void 0:e.closest("[data-message-id]"))==null?void 0:s.getAttribute("data-message-id"))==null?void 0:n.trim())||null}function $i(t,e){return[e.trim()||o("conversation.selectionActionDefaultPrompt"),"",o("conversation.selectionActionQuotedLabel"),"```text",t.trim(),"```"].join(`
|
|
3
|
-
`)}function Zt(t){if(typeof window>"u")return null;const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return null;const s=e.getRangeAt(0),n=ms(s.startContainer),i=ms(s.endContainer);if(!n||!i||!t.contains(n)||!t.contains(i))return null;const c=e.toString().trim();if(!c)return null;const l=s.getBoundingClientRect();if(!l.width&&!l.height)return null;const u=Ks(s.startContainer),d=Ks(s.endContainer);return{text:c,sourceMessageId:u&&u===d?u:null,rect:{left:l.left,top:l.top,right:l.right,bottom:l.bottom,width:l.width,height:l.height}}}function Yi({containerRef:t,session:e,currentCapabilities:s}){const n=Je(),i=Pt(),{showToast:c}=Ze(),{shellMode:l,requestNavigationRefresh:u,selectWorkspace:d,upsertNavigationSession:w}=lt(),g=Dr(p=>p.profile.providers),[v,F]=a.useState(null),[A,M]=a.useState(!1),[x,V]=a.useState(""),[_,f]=a.useState(!1),[b,$]=a.useState(Kt(e==null?void 0:e.provider)),[X,k]=a.useState(At),[z,R]=a.useState(null),[N,B]=a.useState({}),[Q,Y]=a.useState(!1),[ue,de]=a.useState(!1),[ne,me]=a.useState(!1),[T,E]=a.useState(0),[y,L]=a.useState(null),[D,j]=a.useState(()=>({width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight})),O=a.useRef(!1),W=a.useRef(!1),se=a.useRef(null),q=a.useRef(null),ae=l==="mobile"||i.isMobile,P=a.useMemo(()=>p=>{var U,ie;return((ie=(U=g[p])==null?void 0:U.defaultModel)==null?void 0:ie.trim())||At},[g]),K=a.useMemo(()=>b===(e==null?void 0:e.provider)&&s?s:z??bt(b),[s,z,b,e==null?void 0:e.provider]),le=a.useMemo(()=>{var U;const p=bt(b).modelOptions??[];return(U=K.modelOptions)!=null&&U.length?K.modelOptions:p},[K.modelOptions,b]),I=a.useMemo(()=>le.find(p=>p.id===X)??le[0]??null,[le,X]),Se=a.useMemo(()=>{const p=N[b]??(b===(e==null?void 0:e.provider)?s:z);return!p||p.canStartSession!==!1?null:p.limitations[0]??o("conversation.capabilityDenied")},[s,z,N,b,e==null?void 0:e.provider]),te=a.useMemo(()=>{var fe;if(!v||typeof window>"u")return null;const p=(fe=t.current)==null?void 0:fe.getBoundingClientRect(),U=p?Math.max(80,p.left+80):96,ie=p?Math.min(D.width-80,p.right-80):D.width-96,ee=p?Math.max(12,p.top+12):12,ge=p?Math.max(ee,p.bottom-48):Math.max(12,D.height-48),Te=v.rect.left+v.rect.width/2;return{left:Nt(Te,U,Math.max(U,ie)),top:Nt(v.rect.top-48,ee,ge)}},[t,v,D.height,D.width]),Z=a.useMemo(()=>{var Xe;if(!v||typeof window>"u")return null;const p=(Xe=t.current)==null?void 0:Xe.getBoundingClientRect(),U=(p==null?void 0:p.left)??0,ie=(p==null?void 0:p.right)??D.width,ee=(p==null?void 0:p.top)??0,ge=(p==null?void 0:p.bottom)??D.height;if(ae)return{left:D.width/2,top:D.height/2,width:Math.min(420,Math.max(280,D.width-24)),maxHeight:Math.max(260,D.height-Ui),transform:"translate(-50%, -50%)"};const Te=Math.max(280,Math.min(D.width-24,ie-U-24)),fe=Math.min(420,Te),Me=v.rect.left+v.rect.width/2,ve=Math.max(12,U+12),De=Math.max(ve,Math.min(D.width-fe-12,ie-fe-12)),Ve=Math.min(qi,Math.max(280,ge-ee-24),Math.max(280,D.height-24)),et=Math.max(12,ee+12),ut=Math.max(et,Math.min(D.height-Ve-12,ge-Ve-12)),Ye=v.rect.top-Wi-18;return{left:Nt(Me-fe/2,ve,De),top:Nt(Ye,et,ut),width:fe,maxHeight:Ve}},[t,ae,v,D.height,D.width]);a.useEffect(()=>{if(typeof window>"u")return;const p=()=>{j({width:window.innerWidth,height:window.innerHeight})};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[]),a.useEffect(()=>{if(!e){q.current!==null&&typeof window<"u"&&(window.clearTimeout(q.current),q.current=null),se.current=null,W.current=!1,F(null),M(!1);return}const p=Kt(e.provider);$(p),k(P(p))},[P,e]),a.useEffect(()=>{if(!e||!t.current||typeof window>"u"){q.current!==null&&(window.clearTimeout(q.current),q.current=null),se.current=null,W.current=!1,F(null);return}const p=t.current,U=ve=>{O.current||(se.current=ve,F(ve),ve||M(!1))},ie=()=>{q.current!==null&&(window.clearTimeout(q.current),q.current=null)},ee=(ve,De)=>{if(se.current=ve,ie(),De!=null&&De.immediate){U(ve);return}q.current=window.setTimeout(()=>{q.current=null,U(se.current)},Vi)},ge=()=>{const ve=Zt(p);if(W.current){se.current=ve;return}ee(ve)},Te=()=>{const ve=Zt(p);if(W.current){se.current=ve;return}ee(ve,{immediate:!0})},fe=ve=>{!(ve.target instanceof Node)||!p.contains(ve.target)||(W.current=!0,ie())},Me=()=>{W.current&&(W.current=!1,ee(Zt(p)))};return document.addEventListener("pointerdown",fe),document.addEventListener("selectionchange",ge),window.addEventListener("pointerup",Me),window.addEventListener("pointercancel",Me),window.addEventListener("mouseup",Me),window.addEventListener("touchend",Me),window.addEventListener("resize",Te),window.addEventListener("scroll",Te,!0),()=>{ie(),document.removeEventListener("pointerdown",fe),document.removeEventListener("selectionchange",ge),window.removeEventListener("pointerup",Me),window.removeEventListener("pointercancel",Me),window.removeEventListener("mouseup",Me),window.removeEventListener("touchend",Me),window.removeEventListener("resize",Te),window.removeEventListener("scroll",Te,!0)}},[t,e]),a.useEffect(()=>{(!A||!(v!=null&&v.sourceMessageId))&&f(!1)},[A,v==null?void 0:v.sourceMessageId]),a.useEffect(()=>{if(!A||!e)return;let p=!1;return b===e.provider&&s?(Y(!1),R(s),()=>{p=!0}):(Y(!0),R(bt(b)),Tn(b,e.workspaceId).then(U=>{p||R(U)}).catch(()=>{p||R(bt(b))}).finally(()=>{p||Y(!1)}),()=>{p=!0})},[A,s,b,e]),a.useEffect(()=>{if(!A||!e){B({});return}let p=!1;return qr(Dt,e.workspaceId).then(U=>{p||B(U)}),()=>{p=!0}},[A,e]),a.useEffect(()=>{if(!A||!e)return;const p=Dt.filter(ie=>{const ee=N[ie];return!ee||ee.canStartSession!==!1});if(p.length===0||p.includes(b))return;const U=p[0];$(U),k(P(U))},[A,P,N,b,e]),a.useEffect(()=>{var U;const p=P(b);if(!le.some(ie=>ie.id===X)){if(le.some(ie=>ie.id===p)){k(p);return}k(((U=le[0])==null?void 0:U.id)??At)}},[le,P,X,b]),a.useEffect(()=>{if(!A){O.current=!1;return}O.current=!0},[A]),a.useEffect(()=>{if(typeof window>"u")return;const p=U=>{U.key==="Escape"&&(M(!1),F(null),O.current=!1)};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[]);async function H(){if(v)try{await Gi(v.text,i),c({title:o("conversation.copyContentSuccess"),tone:"success"})}catch(p){c({title:p instanceof Error?p.message:o("conversation.copyContentFailed"),tone:"error"})}}function G(){v&&(L({title:"",content:v.text}),E(p=>p+1),me(!0),M(!1),F(null),O.current=!1)}function pe(){if(!v||!e)return;const p=Kt(e.provider);$(p),k(P(p)),V(""),f(!1),M(!0)}async function Ce(){var p,U,ie,ee;if(!(!v||!e)){if(Se){c({title:Se,tone:"error"});return}de(!0);try{const ge=$i(v.text,x),Te=(I==null?void 0:I.id)===At?null:(I==null?void 0:I.id)??null;let fe=null;if(_&&v.sourceMessageId)fe=await ws(e.sessionId,{sourceType:"message",sourceMessageId:v.sourceMessageId,strategy:"auto",targetProvider:b,sessionKind:"annotation",annotationSourceMessageId:v.sourceMessageId,annotationSourceText:v.text}),w(fe),await qt(fe.sessionId,{content:ge,clientRequestId:((U=(p=globalThis.crypto)==null?void 0:p.randomUUID)==null?void 0:U.call(p))??`selection-action-${Date.now()}-${Math.random().toString(16).slice(2)}`,model:Te,permissionMode:$e()});else{const Me=await Cn({workspaceId:e.workspaceId,provider:b,content:ge,clientRequestId:((ee=(ie=globalThis.crypto)==null?void 0:ie.randomUUID)==null?void 0:ee.call(ie))??`selection-action-${Date.now()}-${Math.random().toString(16).slice(2)}`,model:Te,permissionMode:$e(),parentSessionId:e.sessionId,sessionKind:"annotation",annotationSourceMessageId:v.sourceMessageId??null,annotationSourceText:v.text});fe=Me.session??await En(Me.sessionId)}w(fe),u(),d(fe.workspaceId),n(Oe(fe.workspaceId,fe.sessionId)),M(!1),F(null),O.current=!1}catch(ge){c({title:ge instanceof Error?ge.message:o("conversation.selectionActionFailed"),tone:"error"})}finally{de(!1)}}}function Re(p=!1){M(!1),O.current=!1,p&&F(null)}return!e||!v||!te||typeof document>"u"?r.jsx(Us,{open:ne,preferredWorkspaceId:(e==null?void 0:e.workspaceId)??null,preferredSessionId:(e==null?void 0:e.sessionId)??null,creationRequestId:T,initialDraft:y,onClose:()=>me(!1)}):r.jsxs(r.Fragment,{children:[at.createPortal(r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"conversation-selection-toolbar",style:te,onMouseDown:p=>p.preventDefault(),children:[r.jsx("button",{type:"button",className:"conversation-selection-action",onClick:()=>void H(),children:o("conversation.copyAction")}),r.jsx("button",{type:"button",className:"conversation-selection-action",onClick:G,children:o("conversation.selectionTodoAction")}),r.jsx("button",{type:"button",className:"conversation-selection-action is-primary",onClick:pe,children:o("conversation.selectionActionButton")})]}),A&&Z?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`conversation-selection-dialog-backdrop${ae?" is-mobile":""}`,onMouseDown:()=>Re(!1)}),r.jsxs("div",{className:`conversation-selection-action-dialog workbench-modal-card surface-card${ae?" is-centered":""}`,style:Z,role:"dialog","aria-modal":"true","aria-label":o("conversation.selectionActionButton"),onMouseDown:p=>p.stopPropagation(),children:[r.jsxs("div",{className:"conversation-selection-action-dialog-header workbench-modal-header",children:[r.jsx("div",{className:"workbench-modal-title-wrap",children:r.jsx("h2",{children:o("conversation.selectionActionButton")})}),r.jsx("button",{type:"button",className:"conversation-selection-action-dialog-close workbench-modal-close","aria-label":o("common.close"),onClick:()=>Re(!1),children:"×"})]}),r.jsx("p",{className:"conversation-selection-action-dialog-quote",children:v.text}),r.jsxs("label",{className:"conversation-selection-field workbench-modal-field",children:[r.jsx("span",{children:o("conversation.selectionActionPromptLabel")}),r.jsx("textarea",{value:x,rows:4,placeholder:o("conversation.selectionActionPromptPlaceholder"),onChange:p=>V(p.target.value)})]}),r.jsxs("label",{className:"conversation-selection-checkbox",children:[r.jsx("input",{type:"checkbox",checked:_,disabled:!v.sourceMessageId,onChange:p=>f(p.target.checked)}),r.jsx("span",{children:o("conversation.selectionActionIncludeContext")})]}),v.sourceMessageId?null:r.jsx("p",{className:"conversation-selection-hint",children:o("conversation.selectionActionContextUnavailable")}),Se?r.jsx("p",{className:"conversation-selection-hint",children:Se}):null,r.jsxs("div",{className:"conversation-selection-grid",children:[r.jsxs("label",{className:"conversation-selection-field workbench-modal-field",children:[r.jsx("span",{children:o("conversation.forkTargetProviderLabel")}),r.jsx("select",{value:b,onChange:p=>{const U=p.target.value;$(U),k(P(U))},children:Dt.map(p=>{var U;return r.jsx("option",{value:p,disabled:((U=N[p])==null?void 0:U.canStartSession)===!1,children:Mt(p,"full")},p)})})]}),r.jsxs("label",{className:"conversation-selection-field workbench-modal-field",children:[r.jsx("span",{children:o("conversation.forkTargetModelLabel")}),r.jsx("select",{value:X,disabled:Q||!!Se,onChange:p=>k(p.target.value),children:le.map(p=>r.jsx("option",{value:p.id,children:p.name},p.id))})]})]}),r.jsxs("div",{className:"conversation-selection-actions",children:[r.jsx("button",{type:"button",className:"secondary-button",onClick:()=>Re(!1),children:o("common.cancel")}),r.jsx("button",{type:"button",className:"primary-button",disabled:ue||!!Se,onClick:()=>void Ce(),children:ue?o("conversation.sendingState"):o("conversation.selectionActionSubmit")})]})]})]}):null]}),document.body),r.jsx(Us,{open:ne,preferredWorkspaceId:e.workspaceId,preferredSessionId:e.sessionId,creationRequestId:T,initialDraft:y,onClose:()=>me(!1)})]})}const vt=5,zi=["codex","claude-code"];function Qn(){return[{id:"recommended",label:o("conversation.butlerCompletionTemplateRecommendedLabel"),description:o("conversation.butlerCompletionTemplateRecommendedDescription"),value:o("conversation.butlerCompletionTemplateRecommendedValue")},{id:"spec-finish",label:o("conversation.butlerCompletionTemplateSpecLabel"),description:o("conversation.butlerCompletionTemplateSpecDescription"),value:o("conversation.butlerCompletionTemplateSpecValue")},{id:"bugfix",label:o("conversation.butlerCompletionTemplateBugfixLabel"),description:o("conversation.butlerCompletionTemplateBugfixDescription"),value:o("conversation.butlerCompletionTemplateBugfixValue")}]}function Jt(){var t;return((t=Qn()[0])==null?void 0:t.value)??""}function Zs(t){return t==="claude-code"?"claude-code":"codex"}function Qi(t){return t==="codex"||t==="claude-code"}function Kn({session:t,showTrigger:e=!0,openRequestKey:s=0}){const{showToast:n}=Ze(),{requestNavigationRefresh:i}=lt(),c=a.useId(),l=a.useId(),u=a.useId(),d=a.useId(),[w,g]=a.useState(!1),[v,F]=a.useState(!1),[A,M]=a.useState(null),[x,V]=a.useState(null),[_,f]=a.useState(null),[b,$]=a.useState(Zs(t==null?void 0:t.provider)),[X,k]=a.useState(""),[z,R]=a.useState(()=>Jt()),[N,B]=a.useState(vt),[Q,Y]=a.useState(!1),[ue,de]=a.useState(0),ne=Qn(),me=a.useMemo(()=>{var P;return((P=t==null?void 0:t.title)==null?void 0:P.trim())||null},[t==null?void 0:t.title]),T=a.useMemo(()=>A?{workspaceId:A.workspaceId,project:A.project,session:A.session}:null,[A]),E=(A==null?void 0:A.latestFollowUpTask)??null,y=(A==null?void 0:A.latestVerificationRun)??null,L=E&&(E.status==="active"||E.status==="waiting_user")?E:null,D=y&&(y.status==="queued"||y.status==="running")?y:null;a.useEffect(()=>{g(!1),Y(!1),V(null),M(null),k(""),$(Zs(t==null?void 0:t.provider)),R(Jt()),B(vt)},[t==null?void 0:t.sessionId]),a.useEffect(()=>{if(!(t!=null&&t.sessionId)){F(!1);return}let P=!1;return F(!0),V(null),ci(t.sessionId).then(K=>{P||M(K.context)}).catch(K=>{P||(M(null),V(K instanceof Error?K.message:o("conversation.butlerActionLoadFailed")))}).finally(()=>{P||F(!1)}),()=>{P=!0}},[ue,t==null?void 0:t.sessionId]);function j(){v||de(P=>P+1)}function O(){!A&&!v&&j()}if(a.useEffect(()=>{e||s<=0||(g(!0),O())},[v,s,e,A]),!(t!=null&&t.sessionId))return null;async function W(){if(!T){O();return}const P=X.trim(),K=z.trim();if(!P){n({title:o("conversation.butlerFollowUpObjectiveRequired"),tone:"warning"});return}if(!K){n({title:o("conversation.butlerFollowUpCompletionCriteriaRequired"),tone:"warning"});return}f("follow-up");try{const le=await mi({projectId:T.project.id,butlerSessionId:T.session.id,providerId:b,objective:P,completionCriteria:K,maxAutoContinueCount:N});M(I=>I&&{...I,latestFollowUpTask:le.task}),i(),n({title:o("conversation.butlerFollowUpStarted"),description:o("conversation.butlerFollowUpStartedDescription",{projectName:T.project.name}),tone:"success"}),k(""),R(Jt()),B(vt),g(!1)}catch(le){n({title:o("conversation.butlerFollowUpFailed"),description:le instanceof Error?le.message:void 0,tone:"error"})}finally{f(null)}}async function se(){if(E){f("follow-up");try{const P=await ui(E.id);M(K=>K&&{...K,latestFollowUpTask:P.task}),i(),n({title:o("conversation.butlerFollowUpStopped"),description:o("conversation.butlerFollowUpStoppedDescription"),tone:"success"}),g(!1)}catch(P){n({title:o("conversation.butlerFollowUpStopFailed"),description:P instanceof Error?P.message:void 0,tone:"error"})}finally{f(null)}}}async function q(){if(!T){O();return}f("verification");try{const P=await hi({projectId:T.project.id,butlerSessionId:T.session.id,verificationType:"browser",targetRef:me||T.session.title||T.project.name});M(K=>K&&{...K,latestVerificationRun:P.result.run}),i(),n({title:o("conversation.butlerVerificationStarted"),description:o("conversation.butlerVerificationStartedDescription",{projectName:T.project.name}),tone:"success"}),g(!1)}catch(P){n({title:o("conversation.butlerVerificationFailed"),description:P instanceof Error?P.message:void 0,tone:"error"})}finally{f(null)}}async function ae(){if(y){f("verification");try{const P=await di(y.projectId,y.id);M(K=>K&&{...K,latestVerificationRun:P.run}),i(),n({title:o("conversation.butlerVerificationStopped"),description:o("conversation.butlerVerificationStoppedDescription"),tone:"success"}),g(!1)}catch(P){n({title:o("conversation.butlerVerificationStopFailed"),description:P instanceof Error?P.message:void 0,tone:"error"})}finally{f(null)}}}return r.jsxs(r.Fragment,{children:[e?r.jsxs("div",{className:"conversation-butler-entry",onMouseEnter:()=>{Y(!0),O()},onMouseLeave:()=>{Y(!1)},children:[r.jsx("button",{type:"button",className:"conversation-header-ai-button","aria-label":o("conversation.butlerActionButton"),title:o("conversation.butlerActionButton"),onFocus:()=>{Y(!0),O()},onBlur:()=>{Y(!1)},onClick:()=>{g(!0),O()},children:r.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:r.jsx(Li,{})})}),Q?r.jsxs("div",{className:"conversation-butler-analysis-popover",role:"status","aria-live":"polite",children:[r.jsx("strong",{children:o("conversation.butlerAnalysisTitle")}),v?r.jsx("p",{children:o("conversation.butlerActionLoading")}):x?r.jsx("p",{children:x}):E?r.jsxs(r.Fragment,{children:[r.jsxs("p",{children:[o("conversation.butlerAnalysisObjectiveLabel"),":",E.objective]}),r.jsxs("p",{children:[o("conversation.butlerAnalysisStatusLabel"),":",Js(E.status)]}),r.jsxs("p",{children:[o("conversation.butlerAnalysisSummaryLabel"),":",E.lastAutomationSummary||E.waitingReason||o("conversation.butlerAnalysisEmpty")]}),E.waitingReason?r.jsxs("p",{children:[o("conversation.butlerAnalysisWaitingReasonLabel"),":",E.waitingReason]}):null]}):r.jsx("p",{children:o("conversation.butlerAnalysisEmpty")})]}):null]}):null,r.jsx(Fr,{open:w,title:o("conversation.butlerActionModalTitle"),description:o("conversation.butlerActionModalDescription"),className:"conversation-butler-modal-card",footer:!v&&!x&&T?r.jsxs(Ss,{children:[r.jsx("button",{type:"button",className:"secondary-button",disabled:_!==null,onClick:()=>{q()},children:o("conversation.butlerVerificationAction")}),r.jsx("button",{type:"button",className:"primary-button",disabled:_!==null,onClick:()=>{W()},children:o("conversation.butlerFollowUpAction")})]}):void 0,onClose:()=>{_||g(!1)},children:r.jsxs("div",{className:"conversation-butler-modal",children:[v?r.jsx("p",{className:"conversation-butler-modal-hint",children:o("conversation.butlerActionLoading")}):null,!v&&x?r.jsx("p",{className:"conversation-butler-modal-error",children:x}):null,!v&&!x&&T?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"conversation-butler-target-grid",children:[r.jsxs("div",{className:"conversation-butler-target-card",children:[r.jsx("span",{children:o("conversation.butlerActionProjectLabel")}),r.jsx("strong",{children:T.project.name})]}),r.jsxs("div",{className:"conversation-butler-target-card",children:[r.jsx("span",{children:o("conversation.butlerActionSessionLabel")}),r.jsx("strong",{children:T.session.title||me||T.session.sessionId})]})]}),r.jsxs("div",{className:"conversation-butler-follow-up-grid",children:[r.jsxs("div",{className:"workbench-modal-field conversation-butler-modal-field",children:[r.jsxs("div",{className:"conversation-butler-field-heading",children:[r.jsx("label",{children:o("conversation.butlerFollowUpProviderLabel")}),r.jsx("small",{children:o("conversation.butlerFollowUpProviderHint")})]}),r.jsx(Ur,{workspaceId:T.workspaceId,providers:zi,selectedProvider:b,disabled:_!==null,onSelect:P=>{Qi(P)&&$(P)}})]}),r.jsxs("div",{className:"workbench-modal-field conversation-butler-modal-field conversation-butler-round-limit-field",children:[r.jsxs("div",{className:"conversation-butler-field-heading",children:[r.jsx("label",{htmlFor:d,children:o("conversation.butlerFollowUpRoundLimitLabel")}),r.jsx("small",{children:o("conversation.butlerFollowUpRoundLimitHint")})]}),r.jsx("input",{id:d,type:"number",min:1,max:20,value:N,disabled:_!==null,onChange:P=>{const K=Number.parseInt(P.target.value,10);B(Number.isFinite(K)?K:vt)}})]})]}),r.jsxs("div",{className:"workbench-modal-field conversation-butler-modal-field",children:[r.jsx("label",{htmlFor:c,children:o("conversation.butlerFollowUpObjectiveLabel")}),r.jsx("textarea",{id:c,rows:3,value:X,placeholder:o("conversation.butlerFollowUpObjectivePlaceholder"),disabled:_!==null,onChange:P=>{k(P.target.value)}})]}),r.jsxs("div",{className:"workbench-modal-field conversation-butler-modal-field",children:[r.jsxs("div",{className:"conversation-butler-field-heading",children:[r.jsx("label",{htmlFor:l,children:o("conversation.butlerFollowUpCompletionCriteriaLabel")}),r.jsx("small",{id:u,children:o("conversation.butlerCompletionTemplateSectionHint")})]}),r.jsx("textarea",{id:l,rows:3,value:z,placeholder:o("conversation.butlerFollowUpCompletionCriteriaPlaceholder"),"aria-describedby":u,disabled:_!==null,onChange:P=>{R(P.target.value)}}),r.jsx("div",{className:"conversation-butler-preset-grid",role:"group","aria-label":o("conversation.butlerCompletionTemplateSectionLabel"),children:ne.map(P=>r.jsxs("button",{type:"button",className:"conversation-butler-preset-card","data-selected":z.trim()===P.value,"aria-pressed":z.trim()===P.value,disabled:_!==null,onClick:()=>{R(P.value)},children:[r.jsx("strong",{children:P.label}),r.jsx("span",{children:P.description})]},P.id))})]}),L||D?r.jsxs("div",{className:"conversation-butler-meta-grid",children:[L?r.jsxs("div",{className:"conversation-butler-target-card conversation-butler-current-task-card",children:[r.jsx("span",{children:o("conversation.butlerCurrentFollowUpLabel")}),r.jsx("strong",{children:Js(L.status)}),r.jsx("small",{children:o("conversation.butlerCurrentFollowUpProgress",{current:L.autoContinueCount,max:L.maxAutoContinueCount??vt})}),r.jsx("button",{type:"button",className:"workbench-secondary-button",disabled:_!==null,onClick:()=>{se()},children:o("conversation.butlerStopFollowUpAction")})]}):null,D?r.jsxs("div",{className:"conversation-butler-target-card conversation-butler-current-task-card",children:[r.jsx("span",{children:o("conversation.butlerCurrentVerificationLabel")}),r.jsx("strong",{children:Ki(D.status)}),r.jsx("small",{children:D.targetRef||D.verificationType}),r.jsx("button",{type:"button",className:"workbench-secondary-button",disabled:_!==null,onClick:()=>{ae()},children:o("conversation.butlerStopVerificationAction")})]}):null]}):null]}):null]})})]})}function Js(t){switch(t){case"waiting_user":return o("shell.butlerAutomationStatusWaitingUser");case"completed":return o("shell.butlerAutomationStatusCompleted");case"failed":return o("shell.butlerAutomationStatusFailed");case"cancelled":return o("shell.butlerAutomationStatusCancelled");case"active":default:return o("shell.butlerAutomationStatusActive")}}function Ki(t){switch(t){case"queued":case"running":return o("shell.butlerAutomationStatusActive");case"passed":case"skipped":return o("shell.butlerAutomationStatusCompleted");case"failed":return o("shell.butlerAutomationStatusFailed");case"cancelled":default:return o("shell.butlerAutomationStatusCancelled")}}const Zi=340;function Ji({session:t,onOpenBranchTree:e}){const s=Je(),n=Is(),i=a.useRef(null),c=a.useRef(null),[l,u]=a.useState(!1),[d,w]=a.useState(null),[g,v]=a.useState(null),[F,A]=a.useState(0);a.useEffect(()=>{u(!1),w(null)},[n.pathname,n.search]),a.useLayoutEffect(()=>{if(!l||!d||typeof window>"u"){v(null);return}const k=()=>{var B,Q;const N=pi(d,{width:((B=c.current)==null?void 0:B.offsetWidth)??0,height:((Q=c.current)==null?void 0:Q.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:Zi});v({position:"fixed",left:`${Math.round(N.left)}px`,top:`${Math.round(N.top)}px`,width:`${Math.round(N.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(N.maxHeight)}px`,transformOrigin:N.transformOrigin})},z=N=>{var Q,Y;const B=N.target;B&&!((Q=c.current)!=null&&Q.contains(B))&&!((Y=i.current)!=null&&Y.contains(B))&&x()},R=N=>{N.key==="Escape"&&x()};return k(),window.addEventListener("pointerdown",z),window.addEventListener("keydown",R),window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),()=>{window.removeEventListener("pointerdown",z),window.removeEventListener("keydown",R),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0)}},[d,l]);function M(){var z;const k=(z=i.current)==null?void 0:z.getBoundingClientRect();k&&(w({x:k.right,y:k.bottom}),u(!0))}function x(){u(!1),w(null)}function V(k){s(k),x()}function _(k){const z=new URLSearchParams(n.search);z.set("toolPanel",k),V(`${n.pathname}?${z.toString()}`)}function f(){if(l){x();return}M()}function b(k){k.key!=="ContextMenu"&&!(k.shiftKey&&k.key==="F10")||(k.preventDefault(),k.stopPropagation(),M())}if(!t)return null;const $=[{key:"assistant",label:o("shell.butlerEntry"),onSelect:()=>{A(k=>k+1),x()}},...e?[{key:"branch",label:o("conversation.branchAction"),onSelect:()=>{e(),x()}}]:[],{key:"files",label:o("shell.filesEntry"),onSelect:()=>{_("files")}},{key:"git",label:o("shell.gitEntry"),onSelect:()=>{_("git")}},{key:"processes",label:o("shell.mobileConversationToolProcessesTab"),onSelect:()=>{_("processes")}}],X=l&&typeof document<"u"?at.createPortal(r.jsx("div",{ref:c,className:"session-action-menu mobile-conversation-action-menu surface-card",role:"menu","aria-label":o("conversation.moreSessionActions"),style:g??{position:"fixed",top:0,left:0,visibility:"hidden"},onClick:k=>k.stopPropagation(),children:$.map(k=>r.jsx("button",{type:"button",className:"session-action-menu-item mobile-conversation-action-menu-item",role:"menuitem",onClick:k.onSelect,children:k.label},k.key))}),document.body):null;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"mobile-conversation-session-actions",children:[r.jsx("button",{ref:i,type:"button",className:"conversation-header-ai-button mobile-conversation-more-button","aria-label":o("conversation.moreSessionActions"),title:o("conversation.moreSessionActions"),"aria-haspopup":"menu","aria-expanded":l,onClick:f,onKeyDown:b,children:r.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:r.jsx(_i,{})})}),r.jsx(Kn,{session:t,showTrigger:!1,openRequestKey:F})]}),X]})}function Zn({items:t,deletingQueueItemId:e=null,steeringQueueItemId:s=null,canSteer:n=!1,onDelete:i,onSteer:c}){return t.length===0?null:r.jsxs("section",{className:"queued-message-list","aria-label":o("conversation.queueTitle"),children:[r.jsx("div",{className:"queued-message-list__header",children:r.jsx("h2",{children:`${o("conversation.queueTitle")} · ${t.length}`})}),r.jsx("div",{className:"queued-message-list__items",children:t.map((l,u)=>{const d=l.status==="queued"||l.status==="failed",w=n&&typeof c=="function"&&(l.status==="queued"||l.status==="failed");return r.jsxs("article",{className:"queued-message-item",children:[r.jsxs("div",{className:"queued-message-item__main",children:[r.jsx("span",{className:"queued-message-item__order","aria-hidden":"true",children:u+1}),r.jsx("p",{className:"queued-message-item__content",title:l.content||o("conversation.queueImageOnly"),children:l.content||o("conversation.queueImageOnly")}),r.jsx("span",{className:`queued-message-item__status queued-message-item__status--${l.status}`,children:l.status==="failed"?o("conversation.queueStatusFailed"):o("conversation.queueStatusQueued")}),r.jsxs("div",{className:"queued-message-item__actions",children:[w?r.jsx("button",{type:"button",className:"queued-message-item__action queued-message-item__action--steer",onClick:()=>void c(l.id),disabled:s===l.id,"aria-label":o("conversation.queueSteer"),title:o("conversation.queueSteer"),children:s===l.id?o("conversation.queueSteering"):o("conversation.queueSteer")}):null,d?r.jsx("button",{type:"button",className:"queued-message-item__action queued-message-item__action--delete",onClick:()=>void i(l.id),disabled:e===l.id,"aria-label":o("conversation.queueDelete"),title:o("conversation.queueDelete"),children:e===l.id?"…":"×"}):null]})]}),l.errorDetail?r.jsx("p",{className:"queued-message-item__error",children:l.errorDetail}):null]},l.id)})})]})}const eo=30,es=80,wt=60,Jn=600,en=300*1e3,to=600,so=5e3,no=1e4;class er{constructor(e,s={}){Ie(this,"state");Ie(this,"listeners",new Set);Ie(this,"realtimeClient",null);Ie(this,"historyBootstrapFallbackTimer",null);Ie(this,"historyBootstrapEnvelopeReceived",!1);Ie(this,"markSeenTimer",null);Ie(this,"markSeenInFlight",!1);Ie(this,"lastMarkSeenRequestAt",0);Ie(this,"seenWatermark",null);Ie(this,"runtimeRefreshTimer",null);Ie(this,"runtimeRefreshMode",null);Ie(this,"replaceSnapshotSeedOnBackfill",!1);Ie(this,"olderHistoryPrefetchCursor",null);Ie(this,"olderHistoryPrefetchPromise",null);Ie(this,"prefetchedOlderHistoryPage",null);Ie(this,"pendingReplyDebugTraces",[]);Ie(this,"hasAuthoritativeBootstrapMessages");Ie(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));Ie(this,"getState",()=>this.state);var l;this.sessionId=e,this.options=s;const n=Vs(os(e),en);this.hasAuthoritativeBootstrapMessages=(((l=s.bootstrapMessages)==null?void 0:l.length)??0)>0;const i=Lt(s.initialSession??null,(n==null?void 0:n.session)??null),c=gt((n==null?void 0:n.messages)??[],this.sessionId,s.bootstrapMessages??[]);this.replaceSnapshotSeedOnBackfill=!this.hasAuthoritativeBootstrapMessages&&((n==null?void 0:n.messages.length)??0)>0&&((n==null?void 0:n.messages.length)??0)<=wt&&((n==null?void 0:n.pagesLoaded)??0)<=1,this.state=$s({session:i,capabilities:(n==null?void 0:n.capabilities)??null,runtimeHasActiveRun:(n==null?void 0:n.runtimeHasActiveRun)??null,runtimeCanInterrupt:(n==null?void 0:n.runtimeCanInterrupt)??null,contextUsage:(n==null?void 0:n.contextUsage)??null,messages:c,permissionRequests:(n==null?void 0:n.permissionRequests)??[],queuedMessages:(n==null?void 0:n.queuedMessages)??[],olderCursor:(n==null?void 0:n.olderCursor)??null,hasOlderMessages:(n==null?void 0:n.hasOlderMessages)??!1,lastCursor:(n==null?void 0:n.lastCursor)??null,interruptSource:(n==null?void 0:n.interruptSource)??null,pagesLoaded:(n==null?void 0:n.pagesLoaded)??0}),this.seenWatermark=(i==null?void 0:i.lastSeenAt)??null}async initialize(){this.historyBootstrapEnvelopeReceived=!1,this.clearHistoryBootstrapFallbackTimer(),this.clearOlderHistoryPrefetch();const e=this.options.bootstrapMessages??[],s=gt(this.state.messages,this.sessionId,e),n=this.hasAuthoritativeBootstrapMessages;this.patch({messages:s,historyState:lo(this.state.session,n?s.length:0),loadingOlderMessages:!1,olderCursor:n?null:this.state.olderCursor,hasOlderMessages:rt({session:this.state.session,loadedMessageCount:s.length,olderCursor:n?null:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages}),pagesLoaded:n?Math.max(this.state.pagesLoaded,1):this.state.pagesLoaded,errorCode:null,errorDetail:null}),this.shouldRefreshSessionDetail()&&this.refreshSessionMetadata(),this.shouldRefreshRuntimeSnapshot()&&this.refreshRuntimeSnapshot("bootstrap"),this.refreshPermissionRequests(),this.refreshQueue();try{this.startRealtime(),n&&this.scheduleMarkSeen()}catch(i){this.handleError(i)}}async reload(){var s,n;this.clearHistoryBootstrapFallbackTimer(),this.historyBootstrapEnvelopeReceived=!1,this.clearOlderHistoryPrefetch(),(s=this.realtimeClient)==null||s.close(),this.realtimeClient=null;const e=Vs(os(this.sessionId),en);this.state=$s({session:Lt(this.options.initialSession??null,(e==null?void 0:e.session)??null),capabilities:(e==null?void 0:e.capabilities)??null,runtimeHasActiveRun:(e==null?void 0:e.runtimeHasActiveRun)??null,runtimeCanInterrupt:(e==null?void 0:e.runtimeCanInterrupt)??null,contextUsage:(e==null?void 0:e.contextUsage)??null,messages:gt((e==null?void 0:e.messages)??[],this.sessionId,this.options.bootstrapMessages??[]),permissionRequests:(e==null?void 0:e.permissionRequests)??[],queuedMessages:(e==null?void 0:e.queuedMessages)??[],olderCursor:(e==null?void 0:e.olderCursor)??null,hasOlderMessages:(e==null?void 0:e.hasOlderMessages)??!1,lastCursor:(e==null?void 0:e.lastCursor)??null,pagesLoaded:(e==null?void 0:e.pagesLoaded)??0}),this.seenWatermark=((n=this.state.session)==null?void 0:n.lastSeenAt)??null,this.replaceSnapshotSeedOnBackfill=!this.hasAuthoritativeBootstrapMessages&&((e==null?void 0:e.messages.length)??0)>0&&((e==null?void 0:e.messages.length)??0)<=wt&&((e==null?void 0:e.pagesLoaded)??0)<=1,this.emit(),await this.initialize()}applyNavigationSession(e){if(!e||e.sessionId!==this.sessionId)return;const s=Lt(this.state.session,e);s!==this.state.session&&this.patch({session:s,hasOlderMessages:rt({session:s,loadedMessageCount:this.state.messages.length,olderCursor:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages})})}async sendMessage(e,s){const n=cn();this.beginPendingReplyDebugTrace("send_live",n,e.length);const i=qn(this.sessionId,e,n,(s==null?void 0:s.attachmentMeta)??[],(s==null?void 0:s.attachments)??[],ro(this.state.messages,this.state.session));this.patch({messages:Oi(this.state.messages,i),session:We(this.state.session,"running"),runtimeHasActiveRun:un(this.state.session,this.state.capabilities)?!0:this.state.runtimeHasActiveRun,runtimeCanInterrupt:dn(this.state.session,this.state.capabilities)?!0:this.state.runtimeCanInterrupt});try{const c=await this.sendMessageWithFallback(e,n,s);this.markPendingReplyDebugTraceResponseReady(n,{returnedMessageId:c.message.messageId,returnedProviderSessionId:c.message.providerSessionId}),this.patch({messages:Ys(this.state.messages,this.sessionId,c.message,n)})}catch(c){throw this.failPendingReplyDebugTrace(n,c),this.patch({messages:hs(this.state.messages,n),session:We(this.state.session,"failed"),runtimeHasActiveRun:!1,runtimeCanInterrupt:!1}),c}}async retryMessage(e){const s=this.state.messages.find(n=>n.clientRequestId===e);if(s){this.patch({messages:this.state.messages.map(n=>n.clientRequestId===e?{...n,deliveryState:"sending"}:n),runtimeHasActiveRun:un(this.state.session,this.state.capabilities)?!0:this.state.runtimeHasActiveRun,runtimeCanInterrupt:dn(this.state.session,this.state.capabilities)?!0:this.state.runtimeCanInterrupt}),this.beginPendingReplyDebugTrace("retry_live",e,s.content.length);try{const n=await this.sendMessageWithFallback(s.content,e,{attachments:s.attachmentPayloads??[],attachmentMeta:s.attachments});this.markPendingReplyDebugTraceResponseReady(e,{returnedMessageId:n.message.messageId,returnedProviderSessionId:n.message.providerSessionId}),this.patch({messages:Ys(this.state.messages,this.sessionId,n.message,e)})}catch(n){throw this.failPendingReplyDebugTrace(e,n),this.patch({messages:hs(this.state.messages,e),session:We(this.state.session,"failed")}),n}}}async enqueueMessage(e,s){const n=cn();try{const i=await Vr(this.sessionId,{content:e,clientRequestId:n,model:(s==null?void 0:s.model)??null,reasoningLevel:(s==null?void 0:s.reasoningLevel)??null,permissionMode:$e(),attachments:(s==null?void 0:s.attachments)??[]});this.patch({queuedMessages:So(this.state.queuedMessages,i)}),await this.refreshQueue()}catch(i){throw i}}async deleteQueuedMessage(e){await Xr(this.sessionId,e),await this.refreshQueue()}async steerQueuedMessage(e){await Gr(this.sessionId,e),await this.refreshRuntimeSnapshot("queue_steer")}async interrupt(){await $r(this.sessionId),this.patch({session:We(this.state.session,"interrupted"),runtimeHasActiveRun:!1,runtimeCanInterrupt:!1,interruptSource:"user",errorCode:null,errorDetail:null})}async replyPermissionRequest(e,s){if(!(this.state.permissionRequests.find(c=>c.id===e)??null))return;const i=await Yr(this.sessionId,e,s);this.patch({permissionRequests:as(this.state.permissionRequests,i)})}reconnect(){var e;(e=this.realtimeClient)==null||e.reconnectNow()}async loadOlderMessages(){var e;if(!(this.state.historyState!=="ready"||this.state.loadingOlderMessages||!this.state.olderCursor)){this.patch({loadingOlderMessages:!0,errorCode:null,errorDetail:null});try{const s=this.state.olderCursor,n=await this.takePrefetchedOlderHistoryPage(s);if(n&&this.state.olderCursor===s){this.applyOlderHistoryPage(n,"prefetch_cache");return}if(!((e=this.realtimeClient)==null?void 0:e.requestOlderMessages(s,es)))throw new Error("REALTIME_NOT_CONNECTED")}catch(s){const n=s instanceof Error?s.message:"unknown";this.patch({loadingOlderMessages:!1,errorCode:"HISTORY_LOAD_MORE_FAILED",errorDetail:n})}}}destroy(){var e;this.clearHistoryBootstrapFallbackTimer(),this.clearOlderHistoryPrefetch(),(e=this.realtimeClient)==null||e.close(),this.realtimeClient=null,this.pendingReplyDebugTraces.length=0,this.markSeenTimer!==null&&(window.clearTimeout(this.markSeenTimer),this.markSeenTimer=null),this.runtimeRefreshTimer!==null&&(window.clearTimeout(this.runtimeRefreshTimer),this.runtimeRefreshTimer=null),this.runtimeRefreshMode=null}startRealtime(){var s;if(!((s=Yt.getState().session)==null?void 0:s.accessToken)){Yt.clear();return}this.realtimeClient=new Di({sessionId:this.sessionId,cursor:this.state.lastCursor,limit:wt,onSubscribed:()=>{he("session_send.realtime_subscribed",{sessionId:this.sessionId,lastCursor:this.state.lastCursor}),this.patch({connectionState:"connected",hasOlderMessages:rt({session:this.state.session,loadedMessageCount:this.state.messages.length,olderCursor:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages})}),this.scheduleHistoryBootstrapFallback()},onConnectionChange:n=>{var c;const i=this.state.connectionState;if(this.patch({connectionState:n,session:n==="reconnecting"&&Fe((c=this.state.session)==null?void 0:c.runningState)?We(this.state.session,"reconnecting"):this.state.session}),n==="connected"){this.clearRuntimeRefreshTimer("poll"),i!=="closed"&&i!=="connected"&&this.patch({errorCode:null,errorDetail:null});return}this.scheduleRuntimeRefresh("poll","connection_state_change")},onEnvelope:n=>{var u,d;this.historyBootstrapEnvelopeReceived=!0,this.clearHistoryBootstrapFallbackTimer();const i=n.type==="session.backfill"&&this.replaceSnapshotSeedOnBackfill,{messages:c,replacedSnapshotSeed:l}=this.mergeHistoryMessages(n.messages,i,n.type==="session.backfill"?"realtime_backfill":"realtime_delta");this.patch({messages:c,lastCursor:n.cursor,historyState:"ready",olderCursor:n.type==="session.backfill"&&!l&&this.state.pagesLoaded>1?this.state.olderCursor:n.olderCursor??this.state.olderCursor,hasOlderMessages:n.type==="session.backfill"?!l&&this.state.pagesLoaded>1?this.state.hasOlderMessages:!!n.olderCursor:rt({session:this.state.session,loadedMessageCount:c.length,olderCursor:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages}),pagesLoaded:n.type==="session.backfill"?!l&&this.state.pagesLoaded>1?this.state.pagesLoaded:Math.max(this.state.pagesLoaded,c.length>0?1:0):this.state.pagesLoaded,session:We(this.state.session,rn(n.type,(u=this.state.session)==null?void 0:u.runningState))}),(d=this.realtimeClient)==null||d.updateCursor(n.cursor),this.scheduleMarkSeen(),this.scheduleOlderHistoryPrefetch(n.type==="session.backfill"?"backfill":"delta"),this.state.queuedMessages.length>0&&this.refreshQueue()},onOlderHistory:n=>{this.applyOlderHistoryPage({messages:n.messages,nextCursor:n.olderCursor},"realtime")},onRuntimeMessage:n=>{this.handleRuntimeMessage(n)},onActivity:n=>{this.handleActivity(n)},onRuntimeStatus:n=>{this.handleRuntimeStatus(n)},onRuntimeError:n=>{this.handleRuntimeError(n)},onInterrupted:n=>{this.handleInterrupted(n)},onPermissionRequest:n=>{this.handlePermissionRequest(n)},onPermissionRequestResolved:n=>{this.handlePermissionRequestResolved(n)},onError:n=>{this.patch({loadingOlderMessages:!1,errorCode:n.error_code,errorDetail:n.detail})},onUnauthorized:()=>{Yt.clear()}}),this.realtimeClient.start()}patch(e){let s=e;Object.prototype.hasOwnProperty.call(e,"session")&&(this.syncSeenWatermark(e.session??null),s={...e,session:this.applySeenWatermark(e.session??null)}),this.state={...this.state,...s},(Object.prototype.hasOwnProperty.call(s,"session")||Object.prototype.hasOwnProperty.call(s,"capabilities")||Object.prototype.hasOwnProperty.call(s,"contextUsage")||Object.prototype.hasOwnProperty.call(s,"messages")||Object.prototype.hasOwnProperty.call(s,"permissionRequests")||Object.prototype.hasOwnProperty.call(s,"queuedMessages"))&&this.persistSnapshot(),this.emit()}mergeHistoryMessages(e,s,n){const i=s&&this.replaceSnapshotSeedOnBackfill&&io(this.state.messages,e),c=i?this.state.messages.filter(u=>u.deliveryState!=="sent"):this.state.messages,l=gt(c,this.sessionId,e);return this.logCodexMergeDebug(n,this.state.messages,e,l,{replacedSnapshotSeedAttempted:s,replacedSnapshotSeed:i,baseMessageCount:c.length}),i&&(this.replaceSnapshotSeedOnBackfill=!1),{messages:l,replacedSnapshotSeed:i}}handleError(e){this.clearHistoryBootstrapFallbackTimer();const s=e instanceof Error?e.message:"unknown";this.patch({historyState:"error",errorCode:"RUNTIME_INIT_FAILED",errorDetail:s})}scheduleMarkSeen(){if(this.markSeenTimer!==null)return;const e=this.getTargetSeenAt();if(this.markSeenInFlight||e===null)return;const s=this.getMarkSeenThrottleDelayMs(),n=Math.max(to,s);this.markSeenTimer=window.setTimeout(()=>{this.markSeenTimer=null;const i=this.getTargetSeenAt();i!==null&&(he("session_seen.start",{sessionId:this.sessionId,targetSeenAt:i,seenWatermark:this.seenWatermark}),this.markSeenInFlight=!0,this.lastMarkSeenRequestAt=Date.now(),zr(this.sessionId).then(()=>{var c,l;this.bumpSeenWatermark(i),this.patch({session:tn(this.state.session,i)}),(l=(c=this.options).onSeen)==null||l.call(c,this.sessionId,i),he("session_seen.end",{sessionId:this.sessionId,seenWatermark:this.seenWatermark})}).catch(()=>{he("session_seen.error",{sessionId:this.sessionId,targetSeenAt:i})}).finally(()=>{this.markSeenInFlight=!1,this.shouldMarkSeen()&&this.scheduleMarkSeen()}))},n)}clearRuntimeRefreshTimer(e){this.runtimeRefreshTimer!==null&&(e&&this.runtimeRefreshMode!==e||(window.clearTimeout(this.runtimeRefreshTimer),this.runtimeRefreshTimer=null,this.runtimeRefreshMode=null))}scheduleHistoryBootstrapFallback(){this.historyBootstrapEnvelopeReceived||this.historyBootstrapFallbackTimer!==null||(this.historyBootstrapFallbackTimer=window.setTimeout(()=>{this.historyBootstrapFallbackTimer=null,!this.historyBootstrapEnvelopeReceived&&this.resolveHistoryBootstrapFallback()},350))}clearHistoryBootstrapFallbackTimer(){this.historyBootstrapFallbackTimer!==null&&(window.clearTimeout(this.historyBootstrapFallbackTimer),this.historyBootstrapFallbackTimer=null)}async resolveHistoryBootstrapFallback(){try{const e=Math.min(Jn,Math.max(wt,this.state.messages.length,eo)),s=await cs(this.sessionId,null,e,"backward");if(this.historyBootstrapEnvelopeReceived)return;this.historyBootstrapEnvelopeReceived=!0;const{messages:n,replacedSnapshotSeed:i}=this.mergeHistoryMessages(s.messages,this.replaceSnapshotSeedOnBackfill,"http_bootstrap_fallback");this.patch({messages:n,historyState:"ready",olderCursor:!i&&this.state.pagesLoaded>1?this.state.olderCursor:s.nextCursor,hasOlderMessages:!i&&this.state.pagesLoaded>1?this.state.hasOlderMessages:rt({session:this.state.session,loadedMessageCount:n.length,olderCursor:s.nextCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages}),lastCursor:s.cursor??this.state.lastCursor,pagesLoaded:!i&&this.state.pagesLoaded>1?this.state.pagesLoaded:n.length>0?Math.max(this.state.pagesLoaded,1):this.state.pagesLoaded,errorCode:null,errorDetail:null}),this.scheduleMarkSeen(),this.scheduleOlderHistoryPrefetch("bootstrap_fallback")}catch{}}applyOlderHistoryPage(e,s){const{messages:n}=this.mergeHistoryMessages(e.messages,!1,s==="realtime"?"older_history_realtime":"older_history_prefetch_cache");this.patch({messages:n,historyState:"ready",loadingOlderMessages:!1,olderCursor:e.nextCursor,hasOlderMessages:!!e.nextCursor,pagesLoaded:this.state.pagesLoaded+1,errorCode:null,errorDetail:null}),he("session.history_older.applied",{sessionId:this.sessionId,source:s,messageCount:e.messages.length,nextCursor:e.nextCursor}),this.scheduleOlderHistoryPrefetch(s)}scheduleOlderHistoryPrefetch(e){var n;const s=this.state.olderCursor;this.state.historyState!=="ready"||this.state.loadingOlderMessages||!s||((n=this.prefetchedOlderHistoryPage)==null?void 0:n.requestedCursor)!==s&&(this.olderHistoryPrefetchPromise&&this.olderHistoryPrefetchCursor===s||this.prefetchOlderHistoryPage(s,e))}async prefetchOlderHistoryPage(e,s){var i;if(((i=this.prefetchedOlderHistoryPage)==null?void 0:i.requestedCursor)===e)return this.prefetchedOlderHistoryPage.page;if(this.olderHistoryPrefetchPromise&&this.olderHistoryPrefetchCursor===e)return this.olderHistoryPrefetchPromise;this.olderHistoryPrefetchCursor=e,he("session.history_older.prefetch.start",{sessionId:this.sessionId,requestedCursor:e,reason:s,limit:es});const n=cs(this.sessionId,e,es,"backward").then(c=>(this.state.olderCursor===e&&(this.prefetchedOlderHistoryPage={requestedCursor:e,page:c}),he("session.history_older.prefetch.end",{sessionId:this.sessionId,requestedCursor:e,messageCount:c.messages.length,nextCursor:c.nextCursor}),c)).catch(c=>(he("session.history_older.prefetch.error",{sessionId:this.sessionId,requestedCursor:e,message:c instanceof Error?c.message:"unknown"}),null)).finally(()=>{this.olderHistoryPrefetchPromise===n&&(this.olderHistoryPrefetchPromise=null),this.olderHistoryPrefetchCursor===e&&(this.olderHistoryPrefetchCursor=null)});return this.olderHistoryPrefetchPromise=n,n}async takePrefetchedOlderHistoryPage(e){var s;if(((s=this.prefetchedOlderHistoryPage)==null?void 0:s.requestedCursor)===e){const n=this.prefetchedOlderHistoryPage.page;return this.prefetchedOlderHistoryPage=null,he("session.history_older.prefetch.hit",{sessionId:this.sessionId,requestedCursor:e,messageCount:n.messages.length,nextCursor:n.nextCursor}),n}if(this.olderHistoryPrefetchPromise&&this.olderHistoryPrefetchCursor===e){const n=await this.olderHistoryPrefetchPromise;return!n||this.state.olderCursor!==e?null:(this.prefetchedOlderHistoryPage=null,he("session.history_older.prefetch.await_hit",{sessionId:this.sessionId,requestedCursor:e,messageCount:n.messages.length,nextCursor:n.nextCursor}),n)}return null}clearOlderHistoryPrefetch(){this.olderHistoryPrefetchCursor=null,this.olderHistoryPrefetchPromise=null,this.prefetchedOlderHistoryPage=null}scheduleRuntimeRefresh(e,s){var n,i;if(!Fe((n=this.state.session)==null?void 0:n.runningState)){this.clearRuntimeRefreshTimer();return}e==="poll"&&this.state.connectionState==="connected"||(this.clearRuntimeRefreshTimer(),this.runtimeRefreshMode=e,he("session_runtime.refresh.schedule",{sessionId:this.sessionId,mode:e,reason:s,connectionState:this.state.connectionState,runningState:((i=this.state.session)==null?void 0:i.runningState)??null}),this.runtimeRefreshTimer=window.setTimeout(()=>{const c=this.runtimeRefreshMode??e;this.runtimeRefreshTimer=null,this.runtimeRefreshMode=null,this.refreshRuntimeState(c,s)},e==="poll"?no:1200))}async refreshRuntimeState(e,s){var n,i,c,l,u;he("session_runtime.refresh.start",{sessionId:this.sessionId,mode:e,reason:s,connectionState:this.state.connectionState,runningState:((n=this.state.session)==null?void 0:n.runningState)??null});try{const d=await qs(this.sessionId),w=rs(this.state.runtimeHasActiveRun,d.runningState,d.hasActiveRun),g=is(this.state.runtimeCanInterrupt,d.runningState,w,d.canInterrupt);this.patch({session:sn(this.state.session,d),runtimeHasActiveRun:w,runtimeCanInterrupt:g,contextUsage:d.contextUsage,...ss(d,this.state.interruptSource)}),await this.refreshQueue();const v=e==="poll"&&this.state.connectionState!=="connected"&&Fe((i=this.state.session)==null?void 0:i.runningState);he("session_runtime.refresh.end",{sessionId:this.sessionId,mode:e,reason:s,connectionState:this.state.connectionState,runningState:((c=this.state.session)==null?void 0:c.runningState)??null,continuePolling:v}),v&&this.scheduleRuntimeRefresh("poll","connection_poll")}catch(d){he("session_runtime.refresh.error",{sessionId:this.sessionId,mode:e,reason:s,connectionState:this.state.connectionState,runningState:((l=this.state.session)==null?void 0:l.runningState)??null,message:d instanceof Error?d.message:"unknown"}),e==="poll"&&this.state.connectionState!=="connected"&&Fe((u=this.state.session)==null?void 0:u.runningState)&&this.scheduleRuntimeRefresh("poll","connection_poll_retry")}}async refreshSessionMetadata(){const e=[];this.state.session===null&&e.push(En(this.sessionId).then(s=>{this.patch({session:Lt(s,this.state.session)})}).catch(()=>{})),nn(this.state.capabilities)&&e.push(Qr(this.sessionId).then(s=>{this.patch({capabilities:s})}).catch(()=>{})),e.length!==0&&await Promise.allSettled(e)}async refreshPermissionRequests(){try{const e=await Kr(this.sessionId);this.patch({permissionRequests:e.items})}catch{return}}shouldRefreshSessionDetail(){return this.state.session===null||nn(this.state.capabilities)||this.state.session.runningState===null}shouldRefreshRuntimeSnapshot(){return this.state.contextUsage===null||bo(this.state.session,this.state.runtimeHasActiveRun,this.state.runtimeCanInterrupt)}async refreshRuntimeSnapshot(e){he("session_runtime.snapshot.start",{sessionId:this.sessionId,reason:e});try{const s=await qs(this.sessionId),n=rs(this.state.runtimeHasActiveRun,s.runningState,s.hasActiveRun),i=is(this.state.runtimeCanInterrupt,s.runningState,n,s.canInterrupt);this.patch({session:sn(this.state.session,s),runtimeHasActiveRun:n,runtimeCanInterrupt:i,contextUsage:s.contextUsage,...ss(s,this.state.interruptSource)}),await this.refreshQueue(),he("session_runtime.snapshot.end",{sessionId:this.sessionId,reason:e,hasContextUsage:s.contextUsage!==null})}catch(s){he("session_runtime.snapshot.error",{sessionId:this.sessionId,reason:e,message:s instanceof Error?s.message:"unknown"})}}async refreshQueue(){try{const e=await Zr(this.sessionId);this.patch({queuedMessages:e.items})}catch{return}}async sendMessageWithFallback(e,s,n){var i;try{return await qt(this.sessionId,{content:e,clientRequestId:s,model:(n==null?void 0:n.model)??null,reasoningLevel:(n==null?void 0:n.reasoningLevel)??null,permissionMode:$e(),attachments:(n==null?void 0:n.attachments)??[]})}catch(c){if(!(c instanceof Hr)||c.status!==404&&c.status!==405||(((i=n==null?void 0:n.attachments)==null?void 0:i.length)??0)>0)throw c;return he("session_send.live_fallback",{sessionId:this.sessionId,clientRequestId:s,reason:c.message}),Jr(this.sessionId,{content:e,clientRequestId:s,permissionMode:$e()})}}handleRuntimeStatus(e){var n;const s=ts((n=this.state.session)==null?void 0:n.runningState,e.status);this.patch({session:We(this.state.session,s),runtimeHasActiveRun:Fe(s)?this.state.runtimeHasActiveRun??!0:!1,runtimeCanInterrupt:Fe(s)?this.state.runtimeCanInterrupt:!1,interruptSource:s==="interrupted"?e.interruptSource??this.state.interruptSource:s==="completed"||s==="failed"?null:this.state.interruptSource,errorCode:null,errorDetail:s===e.status?e.detail:this.state.errorDetail}),yt(s)&&(this.completePendingReplyDebugTraceWithoutAssistant("session_send.client_terminal_before_message",{status:e.status,detail:e.detail}),this.clearRuntimeRefreshTimer(),this.refreshQueue(),this.refreshRuntimeSnapshot("runtime_terminal"))}handleActivity(e){const s=rs(this.state.runtimeHasActiveRun,e.runningState,e.hasActiveRun),n=is(this.state.runtimeCanInterrupt,e.runningState,s,e.canInterrupt);if(this.patch({session:uo(this.state.session,e),runtimeHasActiveRun:s,runtimeCanInterrupt:n,...ss(e,this.state.interruptSource)}),yt(e.runningState)){this.clearRuntimeRefreshTimer(),this.refreshQueue();return}(e.runningState==="stale"||e.runningState==="unknown")&&this.scheduleRuntimeRefresh("tail","activity_watchdog")}handleRuntimeMessage(e){var n;e.message.role==="assistant"&&this.completePendingReplyDebugTrace(e);const s=gt(this.state.messages,this.sessionId,[e.message]);this.logCodexMergeDebug("runtime_message",this.state.messages,[e.message],s,{runtimeSource:e.source}),this.patch({messages:s,historyState:"ready",hasOlderMessages:rt({session:this.state.session,loadedMessageCount:s.length,olderCursor:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages}),session:We(this.state.session,rn("session.delta",(n=this.state.session)==null?void 0:n.runningState))}),this.scheduleMarkSeen(),this.state.queuedMessages.length>0&&this.refreshQueue()}handleRuntimeError(e){var n;const s=ts((n=this.state.session)==null?void 0:n.runningState,"failed");this.completePendingReplyDebugTraceWithoutAssistant("session_send.client_runtime_error",{errorCode:e.error_code,detail:e.detail}),this.clearRuntimeRefreshTimer(),this.patch({session:We(this.state.session,s),runtimeHasActiveRun:!1,runtimeCanInterrupt:!1,interruptSource:null,errorCode:s==="failed"?e.error_code:this.state.errorCode,errorDetail:s==="failed"?e.detail:this.state.errorDetail}),this.refreshQueue()}handleInterrupted(e){var n;const s=ts((n=this.state.session)==null?void 0:n.runningState,"interrupted");this.completePendingReplyDebugTraceWithoutAssistant("session_send.client_interrupted",{detail:e.detail}),this.clearRuntimeRefreshTimer(),this.patch({session:We(this.state.session,s),runtimeHasActiveRun:!1,runtimeCanInterrupt:!1,interruptSource:s==="interrupted"?e.interruptSource??this.state.interruptSource:this.state.interruptSource,errorCode:s==="interrupted"?null:this.state.errorCode,errorDetail:s==="interrupted"?e.detail:this.state.errorDetail}),this.refreshQueue()}handlePermissionRequest(e){this.patch({permissionRequests:as(this.state.permissionRequests,e.request)})}handlePermissionRequestResolved(e){this.patch({permissionRequests:as(this.state.permissionRequests,e.request)})}shouldMarkSeen(){return this.getTargetSeenAt()!==null}getTargetSeenAt(){const e=[...this.state.messages].reverse().find(n=>n.role!=="user");if(!e)return null;const s=this.seenWatermark;return s?e.timestamp>s?e.timestamp:null:e.timestamp}syncSeenWatermark(e){e!=null&&e.lastSeenAt&&this.bumpSeenWatermark(e.lastSeenAt)}bumpSeenWatermark(e){this.seenWatermark&&this.seenWatermark>=e||(this.seenWatermark=e)}getMarkSeenThrottleDelayMs(){return this.lastMarkSeenRequestAt<=0?0:Math.max(0,so-(Date.now()-this.lastMarkSeenRequestAt))}applySeenWatermark(e){return!e||!this.seenWatermark?e:tn(e,this.seenWatermark)}emit(){for(const e of this.listeners)e()}persistSnapshot(){fi(os(this.sessionId),{session:this.state.session,capabilities:this.state.capabilities,runtimeHasActiveRun:this.state.runtimeHasActiveRun,runtimeCanInterrupt:this.state.runtimeCanInterrupt,contextUsage:this.state.contextUsage,messages:wo(this.state.messages),permissionRequests:this.state.permissionRequests,queuedMessages:this.state.queuedMessages,olderCursor:this.state.olderCursor,hasOlderMessages:this.state.hasOlderMessages,lastCursor:this.state.lastCursor,pagesLoaded:this.state.pagesLoaded,interruptSource:this.state.interruptSource})}beginPendingReplyDebugTrace(e,s,n){const i={mode:e,clientRequestId:s,startedAtMs:performance.now(),responseReadyAtMs:null,contentLength:n};this.pendingReplyDebugTraces.push(i),he(`session_send.${e}.client_start`,{sessionId:this.sessionId,clientRequestId:s,contentLength:n})}markPendingReplyDebugTraceResponseReady(e,s={}){const n=this.pendingReplyDebugTraces.find(i=>i.clientRequestId===e);!n||n.responseReadyAtMs!==null||(n.responseReadyAtMs=performance.now(),he(`session_send.${n.mode}.client_response`,{sessionId:this.sessionId,clientRequestId:e,durationMs:Math.round(n.responseReadyAtMs-n.startedAtMs),...s}))}failPendingReplyDebugTrace(e,s){const n=this.pendingReplyDebugTraces.find(i=>i.clientRequestId===e);n&&(he(`session_send.${n.mode}.client_error`,{sessionId:this.sessionId,clientRequestId:e,durationMs:Math.round(performance.now()-n.startedAtMs),error:s instanceof Error?s.message:String(s)}),this.removePendingReplyDebugTrace(n.clientRequestId))}completePendingReplyDebugTrace(e){const s=this.pendingReplyDebugTraces[0];if(!s)return;const n=performance.now();he(`session_send.${s.mode}.first_assistant_message`,{sessionId:this.sessionId,clientRequestId:s.clientRequestId,durationMs:Math.round(n-s.startedAtMs),responseToAssistantMs:s.responseReadyAtMs===null?null:Math.round(n-s.responseReadyAtMs),messageId:e.message.messageId,kind:e.message.kind,contentLength:e.message.content.length}),this.removePendingReplyDebugTrace(s.clientRequestId)}completePendingReplyDebugTraceWithoutAssistant(e,s={}){const n=this.pendingReplyDebugTraces[0];n&&(he(e,{sessionId:this.sessionId,clientRequestId:n.clientRequestId,durationMs:Math.round(performance.now()-n.startedAtMs),responseReady:n.responseReadyAtMs!==null,...s}),this.removePendingReplyDebugTrace(n.clientRequestId))}removePendingReplyDebugTrace(e){const s=this.pendingReplyDebugTraces.findIndex(n=>n.clientRequestId===e);s<0||this.pendingReplyDebugTraces.splice(s,1)}logCodexMergeDebug(e,s,n,i,c={}){const l=n.filter(mo);if(l.length===0)return;const u=an(s),d=an(i);gi("session.messages.merge",{sessionId:this.sessionId,source:e,beforeCount:s.length,incomingCount:n.length,afterCount:i.length,incoming:l.slice(0,5).map(fo),beforeDuplicateGroupCount:u.length,afterDuplicateGroupCount:d.length,afterDuplicateGroups:d.slice(0,3),...c})}}function ce(t,e){const[s,n]=a.useState(()=>e(t.getState()));return a.useEffect(()=>(n(e(t.getState())),t.subscribe(()=>{n(e(t.getState()))})),[e,t]),s}function tr(t){const e=t==null?void 0:t.messageCount;return typeof e=="number"&&Number.isFinite(e)?e:null}function ro(t,e){const s=Hi(t),n=tr(e);return n===null?s:Math.max(s,n+1)}function io(t,e){const s=oo(e);if(!s)return!1;const n=ao(t);return n?Cs(s.sequence,s.timestamp,n.sequence,n.timestamp)>=0:!0}function oo(t){let e=null;for(const s of t)(!e||Cs(s.sequence,s.timestamp,e.sequence,e.timestamp)>0)&&(e=s);return e}function ao(t){let e=null;for(const s of t)s.deliveryState==="sent"&&(!e||Cs(s.sequence,s.timestamp,e.sequence,e.timestamp)>0)&&(e=s);return e}function Cs(t,e,s,n){return t!==s?t-s:e.localeCompare(n)}function lo(t,e){return e>0?"ready":"loading"}function co(t,e){const s=tr(t);return s!==null?s>e:e>=wt}function rt(t){return t.olderCursor?!0:t.pagesLoaded>1?t.currentHasOlderMessages:co(t.session,t.loadedMessageCount)}function We(t,e){return t&&{...t,runningState:e,activityState:nr(t,e,t.completedAt??null,Fe(e))}}function tn(t,e){return!t||t.lastSeenAt&&t.lastSeenAt>=e?t:{...t,lastSeenAt:e,activityState:t.activityState==="completed_unread"?"idle":t.activityState}}function sn(t,e){return sr(t,{runningState:e.runningState,activityResolutionSource:e.activityResolutionSource,activityConfidence:e.activityConfidence,runId:e.runId,detail:e.detail,interruptSource:e.interruptSource,errorCode:e.errorCode,errorDetail:e.errorDetail,hasActiveRun:e.hasActiveRun,updatedAt:e.updatedAt,watchdogTriggeredAt:e.watchdogTriggeredAt})}function uo(t,e){return sr(t,e)}function sr(t,e){if(!t)return t;const s=ho(e.activityResolutionSource),n=yt(e.runningState)?ns(t.completedAt,e.updatedAt):null,i=e.runningState==="completed"||e.runningState==="interrupted"||e.runningState==="failed"?ns(t.lastEventAt,e.updatedAt):e.updatedAt;return{...t,runningState:e.runningState,activitySource:s,activityResolutionSource:e.activityResolutionSource,activityConfidence:e.activityConfidence,runId:e.runId,lastEventAt:i,completedAt:n,lastErrorCode:e.runningState==="failed"?e.errorCode??t.lastErrorCode:null,lastErrorDetail:e.runningState==="failed"?e.errorDetail??e.detail??t.lastErrorDetail:null,watchdogTriggeredAt:e.watchdogTriggeredAt,updatedAt:ns(t.updatedAt,e.updatedAt)??e.updatedAt,activityState:nr(t,e.runningState,n,e.hasActiveRun)}}function nr(t,e,s,n){return n||Fe(e)?"running":s&&(!t.lastSeenAt||s>t.lastSeenAt)?"completed_unread":t.activityState==="running"||t.activityState==="completed_unread"?"idle":t.activityState??"idle"}function Fe(t){return t==="starting"||t==="running"||t==="reconnecting"}function yt(t){return t==="completed"||t==="interrupted"||t==="failed"}function nn(t){if(t===null)return!0;const e=t.modelOptions??[];return e.length===0?!0:e.every(s=>s.usesProviderDefault===!0)}function rn(t,e){return t==="session.backfill"?e??"idle":e==="completed"||e==="interrupted"||e==="failed"?e:"running"}function ts(t,e){return yt(t)?t:e}function ss(t,e){return t.runningState==="failed"?{interruptSource:null,errorCode:t.errorCode,errorDetail:t.errorDetail??t.detail}:t.runningState==="interrupted"?{interruptSource:t.interruptSource??null,errorCode:null,errorDetail:t.detail}:t.runningState==="completed"?{interruptSource:null,errorCode:null,errorDetail:t.detail}:{interruptSource:e,errorCode:null,errorDetail:null}}function ho(t){return t==="authoritative_runtime"||t==="authoritative_provider_event"?"runtime":t==="inferred_log"?"inferred":"none"}function mo(t){return t.provider==="codex"&&(t.role==="assistant"||t.role==="tool")}function po(t){return t.rawRef.startsWith("codex://")&&t.deliveryState==="sent"&&(t.role==="assistant"||t.role==="tool")}function fo(t){var e;return{id:t.messageId,rawRef:t.rawRef,role:t.role,kind:t.kind??(t.role==="tool"?"tool_result":"text"),sequence:t.sequence,timestamp:t.timestamp,callId:((e=t.toolCall)==null?void 0:e.callId)??null,contentPreview:rr(t.content,t.kind??"text")}}function on(t){var e;return{id:t.id,rawRef:t.rawRef,role:t.role,kind:t.kind,sequence:t.sequence,timestamp:t.timestamp,callId:((e=t.toolCall)==null?void 0:e.callId)??null,contentPreview:rr(t.content,t.kind)}}function an(t){const e=new Map;for(const n of t){if(!po(n))continue;const i=go(n),c=e.get(i);if(c){c.push(n);continue}e.set(i,[n])}const s=[];for(const[n,i]of e.entries()){const c=[...i].sort((u,d)=>u.sequence!==d.sequence?u.sequence-d.sequence:u.timestamp.localeCompare(d.timestamp));let l=[];for(const u of c){const d=l.at(-1)??null;if(!d||vo(d,u)){l.push(u);continue}l.length>1&&s.push({signature:n,messages:l.map(on)}),l=[u]}l.length>1&&s.push({signature:n,messages:l.map(on)})}return s}function go(t){var i,c;if(t.kind==="tool_call"||t.kind==="tool_result")return[t.role,t.kind,((i=t.toolCall)==null?void 0:i.callId)??"",((c=t.toolCall)==null?void 0:c.name)??""].join(":");const e=Un(t.content),s=ps(e.text),n=e.inlineImages.map(l=>l.url).join("|");return[t.role,t.kind,s,n].join(":")}function vo(t,e){const s=ln(t.timestamp),n=ln(e.timestamp);return Math.abs(s-n)<=120*1e3&&Math.abs(t.sequence-e.sequence)<=8}function rr(t,e){return e==="text"||e==="thinking"?ps(Un(t).text).slice(0,160):ps(t).slice(0,160)}function ps(t){return t.replace(/\r\n/g,`
|
|
4
|
-
`).trimEnd()}function ln(t){const e=Date.parse(t);return Number.isFinite(e)?e:0}function ns(t,e){return t?e?t>=e?t:e:t:e??null}function cn(){var t,e;if(typeof((t=globalThis.crypto)==null?void 0:t.randomUUID)=="function")return globalThis.crypto.randomUUID();if(typeof((e=globalThis.crypto)==null?void 0:e.getRandomValues)=="function"){const s=new Uint8Array(16);globalThis.crypto.getRandomValues(s),s[6]=s[6]&15|64,s[8]=s[8]&63|128;const n=Array.from(s,i=>i.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}return`fallback-${Date.now()}-${Math.random().toString(16).slice(2,10)}`}function ir(t,e){return e&&(!t||t.provider===e.provider)?e:null}function un(t,e){const s=ir(t,e);return s?!!s.canSendMessage:t?jn(t.provider):!1}function dn(t,e){const s=ir(t,e);return s?!(!s.supportsInterrupt||(t==null?void 0:t.provider)==="claude-code"&&t.activitySource==="inferred"):t?t.provider==="codex"||t.provider==="opencode"?!0:t.provider==="claude-code"&&t.activitySource!=="inferred":!1}function bo(t,e,s){return e===!0||s===!0?!0:t?t.activityState==="running"||t.runningState==="starting"||t.runningState==="running"||t.runningState==="reconnecting"||t.runningState==="stale"||t.runningState==="unknown":!1}function rs(t,e,s){return s?!0:t===!0&&Fe(e)}function is(t,e,s,n){return n?!0:t===!0&&(s||Fe(e))}function os(t){return`session-runtime.snapshot.${t}`}function wo(t){return t.filter(e=>e.deliveryState==="sent").slice(-Jn)}function So(t,e){const s=t.filter(n=>n.id!==e.id);return s.push(e),s.sort((n,i)=>n.orderIndex-i.orderIndex),s}function as(t,e){const s=t.filter(n=>n.id!==e.id);return s.push(e),s.sort((n,i)=>n.status!==i.status?n.status==="pending"?-1:1:i.createdAt.localeCompare(n.createdAt)),s}function Lt(t,e){if(!t)return e;if(!e||hn(t,e)||mn(t,e))return t;if(hn(e,t)||mn(e,t))return e;const s=Date.parse(t.updatedAt||t.lastMessageAt||t.createdAt),n=Date.parse(e.updatedAt||e.lastMessageAt||e.createdAt);return!Number.isFinite(s)||!Number.isFinite(n)?e:s>=n?t:e}function hn(t,e){return pn(t)&&!pn(e)&&t.lastEventAt===e.lastEventAt&&t.lastMessageAt===e.lastMessageAt&&t.completedAt===e.completedAt}function mn(t,e){if(!fn(t)||fn(e))return!1;const s=t.completedAt??t.lastEventAt??null;return s?(!e.lastEventAt||e.lastEventAt<=s)&&(!e.completedAt||e.completedAt<=s):!1}function pn(t){return t.activityState==="running"||Fe(t.runningState)}function fn(t){return yt(t.runningState)}function or(t){const{sending:e,setSending:s,session:n,runtimeHasActiveRun:i,runtimeCanInterrupt:c}=t,l=a.useRef(!1);a.useEffect(()=>{if(!e){l.current=!1;return}if(xo(n,i,c)){l.current=!0;return}l.current&&(l.current=!1,s(!1))},[c,i,e,n,s])}function xo(t,e,s){return e===!0||s===!0||(t==null?void 0:t.runningState)==="stale"||(t==null?void 0:t.runningState)==="unknown"?!0:Ms(t)}const Io=1.5,Mo=24,yo=72,Po=296,ko=16,gn={2:496,3:408,4:344};function Ro(t){return gn[t]??gn[4]}function To({memberCount:t,currentWidth:e,monitorWidth:s}){if(t<2||e<=0||s<=0)return e;const n=Po,i=Math.max(0,t-1)*ko,c=Math.max(0,(e-n-i)/t),l=Ro(t);if(c>=l-16)return e;const u=n+i+t*l,d=Math.min(e*Io,Math.max(e,s-yo)),w=Math.min(Math.max(e,u),d);return w<=e+Mo?e:w}const Co=560,Eo=240,vn=920,bn=760,Es=360,js=320,Ae=16,wn=428,jo=404,qe=12;function It(t,e){if(typeof window>"u")return t;const s=Math.max(0,window.innerWidth-Ae*2),n=Math.max(0,window.innerHeight-Ae*2),i=Math.min((e==null?void 0:e.minWidth)??Es,s),c=Math.min((e==null?void 0:e.minHeight)??js,n),l=Math.max(i,s),u=Math.max(c,n),d=Math.min(Math.max(t.width,i),l),w=Math.min(Math.max(t.height,c),u),g=Math.min(Math.max(t.x,Ae),Math.max(Ae,window.innerWidth-d-Ae)),v=Math.min(Math.max(t.y,Ae),Math.max(Ae,window.innerHeight-w-Ae));return{x:g,y:v,width:d,height:w}}function Ao(t){if(typeof window>"u")return{x:Ae,y:Ae,width:vn,height:bn};const e=Math.min(vn,Math.max(Es,window.innerWidth-Ae*2)),s=Math.min(bn,Math.max(js,window.innerHeight-Ae*2));return It({x:((t==null?void 0:t.right)??window.innerWidth-Ae)-e+28,y:Math.max(((t==null?void 0:t.bottom)??48)+8,Ae),width:e,height:s})}function No(t){return!t||t.width<=0||t.height<=0?null:It({x:t.left,y:t.top,width:t.width,height:t.height},{minWidth:Math.min(Es,t.width),minHeight:Math.min(js,t.height)})}function Lo(t){if(typeof window>"u")return{x:qe,y:qe,width:wn};const e=Math.min(wn,Math.max(jo,window.innerWidth-qe*2));return{x:Math.min(Math.max(((t==null?void 0:t.right)??window.innerWidth-qe)-e,qe),Math.max(qe,window.innerWidth-e-qe)),y:Math.max(qe,((t==null?void 0:t.bottom)??qe)+8),width:e}}function _o({groupId:t,currentSessionId:e}){var y,L,D;const s=Je(),n=Pt(),{showToast:i}=Ze(),{navigationGroups:c,requestNavigationRefresh:l}=lt(),u=a.useMemo(()=>Ft(c),[c]),d=a.useMemo(()=>new Map(u.map(j=>[j.session.sessionId,j])),[u]),w=a.useMemo(()=>ys(c),[c]),[g,v]=a.useState(null),[F,A]=a.useState(!0),[M,x]=a.useState(null),[V,_]=a.useState(null),[f,b]=a.useState(null),[$,X]=a.useState(null),[k,z]=a.useState(!1),[R,N]=a.useState(!1),B=a.useRef(null),Q=a.useRef(null);a.useEffect(()=>{let j=!1;async function O(){A(!0),x(null);try{const W=await ei(t);if(j)return;v(W)}catch(W){if(j)return;x(W instanceof Error?W.message:o("shell.parallelGroupLoadFailed"))}finally{j||A(!1)}}return O(),()=>{j=!0}},[t]),a.useEffect(()=>{vi(t)&&ne()},[t]),a.useEffect(()=>()=>{Q.current!==null&&window.clearTimeout(Q.current)},[]);const Y=a.useMemo(()=>g?g.members.slice().sort((j,O)=>j.member.ordinal-O.member.ordinal).map(j=>{const O=d.get(j.session.sessionId),W=(O==null?void 0:O.session)??j.session;return{session:W,workspaceId:(O==null?void 0:O.workspace.id)??Ht(W,j.sessionIsolatedWorkspace),ordinal:j.member.ordinal,memberPrompt:j.member.memberPrompt,model:j.member.model,sessionIsolatedWorkspace:j.sessionIsolatedWorkspace}}):[],[g,d]);a.useEffect(()=>{if(!n.isDesktop||n.ui.osFamily!=="macos"&&n.ui.osFamily!=="windows"||Y.length<2)return;const j=`${t}:${Y.length}`;if(B.current===j)return;B.current=j;let O=!1;async function W(){try{const se=await Ws(()=>import("./window-BVUB8gMK.js").then(G=>G.w),__vite__mapDeps([0,1])),q=await Ws(()=>import("./window-BVUB8gMK.js").then(G=>G.d),__vite__mapDeps([0,1])),ae=se.getCurrentWindow(),P=await ae.innerSize(),K=await ae.scaleFactor(),le=await se.currentMonitor();if(O||K<=0)return;const I=P.width/K,Se=P.height/K,te=le?le.workArea.size.width/le.scaleFactor:I*1.5,Z=To({memberCount:Y.length,currentWidth:I,monitorWidth:te});if(Z<=I+24)return;const H=10;await new Promise(G=>window.setTimeout(G,56));for(let G=1;G<=H;G+=1){if(O)return;const pe=G/H,Ce=1-Math.pow(1-pe,3),Re=I+(Z-I)*Ce;await ae.setSize(new q.LogicalSize(Re,Se)),await new Promise(p=>window.setTimeout(p,Eo/H))}}catch{return}}return W(),()=>{O=!0}},[t,Y.length,n.isDesktop,n.ui.osFamily]);async function ue(j){b(j);try{const O=await si(j);await l(),v(W=>W&&{...W,members:W.members.map(se=>{var q;return((q=se.sessionIsolatedWorkspace)==null?void 0:q.id)===j?{...se,sessionIsolatedWorkspace:{...se.sessionIsolatedWorkspace,workspaceId:O.workspace.id,lifecycleStatus:"promoted",promotedAt:O.record.promotedAt}}:se})}),i({title:o("shell.parallelWorkspacePromotedBadge"),tone:"success"})}catch(O){i({title:O instanceof Error?O.message:o("shell.parallelGroupLoadFailed"),tone:"error"})}finally{b(null)}}async function de(j){if($)return;const O=j.trim();if(!O)return;const W=Y.find(q=>q.session.sessionId!==O)??null,se=(g==null?void 0:g.group.workspaceId)??(W==null?void 0:W.workspaceId)??null;X(O);try{await ti(O),ds(O,null),_(q=>q===O?null:q),v(q=>q&&{...q,members:q.members.filter(ae=>ae.session.sessionId!==O)}),await l(),e===O&&(W?s(Oe(W.workspaceId,W.session.sessionId)):se&&s(St(se))),i({title:o("shell.deleteSessionSuccess"),tone:"success"})}catch(q){i({title:q instanceof Error?q.message:o("shell.deleteSessionFailed"),tone:"error"})}finally{X(null)}}function ne(){z(!0),Q.current!==null&&window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{z(!1),Q.current=null},Co)}if(F&&!g)return r.jsx("main",{className:"workbench-page conversation-page-shell parallel-conversation-page",children:r.jsx("section",{className:"parallel-conversation-empty-state",children:r.jsx("strong",{children:o("shell.parallelCreateSubmitting")})})});if(M&&!g)return r.jsx("main",{className:"workbench-page conversation-page-shell parallel-conversation-page",children:r.jsxs("section",{className:"parallel-conversation-empty-state error",children:[r.jsx("strong",{children:o("shell.parallelGroupLoadFailed")}),r.jsx("p",{children:M})]})});if(Y.length===0)return r.jsx("main",{className:"workbench-page conversation-page-shell parallel-conversation-page",children:r.jsx("section",{className:"parallel-conversation-empty-state",children:r.jsx("strong",{children:o("shell.parallelGroupEmpty")})})});const me=((y=w[(g==null?void 0:g.group.workspaceId)??""])==null?void 0:y.displayName)??(g==null?void 0:g.group.workspaceId)??o("common.unknown"),T=Y.find(j=>j.session.sessionId===(g==null?void 0:g.group.anchorSessionId))??Y[0]??null,E=Y.length<4;return r.jsxs("main",{className:"workbench-page conversation-page-shell parallel-conversation-page","data-parallel-count":Y.length,"data-parallel-entering":k?"true":void 0,children:[r.jsx("header",{className:"parallel-conversation-group-header",children:r.jsxs("div",{className:"parallel-conversation-group-titlebar",children:[r.jsxs("div",{className:"parallel-conversation-group-titlemain",children:[r.jsx("span",{className:"session-parallel-badge",children:o("shell.parallelGroupBadge")}),r.jsx("strong",{children:((L=g==null?void 0:g.group.sharedPrompt)==null?void 0:L.trim())||o("common.unknown")})]}),r.jsx("button",{type:"button",className:"secondary-button parallel-conversation-group-add-button","aria-label":o("shell.parallelAppendAction"),title:o("shell.parallelAppendAction"),disabled:!E,onClick:()=>{E&&N(!0)},children:r.jsx("span",{"aria-hidden":"true",children:"+"})})]})}),r.jsx("div",{className:"parallel-conversation-grid",children:Y.map(j=>{const O=w[j.workspaceId]??Ps({id:j.workspaceId,name:j.session.workspaceId,path:j.session.workspaceId,repoRoot:j.session.workspaceId});return r.jsx(Oo,{entry:j,isCurrent:j.session.sessionId===e,workspaceContext:O,infoOpen:V===j.session.sessionId,promotingWorkspaceId:f,onCloseInfo:()=>{_(null)},onToggleInfo:()=>{_(W=>W===j.session.sessionId?null:j.session.sessionId)},onPromoteWorkspace:ue,onRemoveSession:de,removingSessionId:$},j.session.sessionId)})}),r.jsx(us,{open:R,source:g?{kind:"group",groupId:g.group.id,workspaceId:g.group.workspaceId,workspaceName:me,sharedPrompt:((D=g.group.sharedPrompt)==null?void 0:D.trim())||"",currentMemberCount:Y.length,defaultProvider:(T==null?void 0:T.session.provider)??"codex"}:null,onClose:()=>N(!1),onCreated:async j=>{v(j),N(!1),ne(),await l(),i({title:o("shell.parallelAppendSucceeded"),tone:"success"})}})]})}function Oo({entry:t,isCurrent:e,workspaceContext:s,infoOpen:n,onCloseInfo:i,onToggleInfo:c,onPromoteWorkspace:l,promotingWorkspaceId:u,onRemoveSession:d,removingSessionId:w}){var ft,Pe,Ee,Be,st,nt;const g=Je(),v=Pt(),{showToast:F}=Ze(),{navigationGroups:A,requestNavigationRefresh:M,selectWorkspace:x,upsertNavigationSession:V,markNavigationSessionSeen:_}=lt(),f=t.session.sessionId,b=a.useRef(null),$=a.useRef(null),[X,k]=a.useState(!1),[z,R]=a.useState(null),[N,B]=a.useState(null),[Q,Y]=a.useState(null),[ue,de]=a.useState(null),[ne,me]=a.useState(!1),[T,E]=a.useState("files"),[y,L]=a.useState(!1),[D,j]=a.useState(null),[O,W]=a.useState(null),se=a.useRef(null),q=a.useRef(null),ae=a.useRef(null),P=a.useRef(null),K=a.useRef(null),le=a.useRef(null),[I,Se]=a.useState(()=>Xs(f));(!b.current||$.current!==f)&&((ft=b.current)==null||ft.destroy(),b.current=new er(f,{initialSession:t.session,bootstrapMessages:[],onSeen:(m,C)=>{_(m,C)}}),$.current=f);const te=b.current,Z=ce(te,m=>m.session),H=ce(te,m=>m.capabilities),G=ce(te,m=>m.runtimeHasActiveRun),pe=ce(te,m=>m.runtimeCanInterrupt),Ce=ce(te,m=>m.messages),Re=ce(te,m=>m.permissionRequests),p=ce(te,m=>m.queuedMessages),U=ce(te,m=>m.contextUsage),ie=ce(te,m=>m.historyState),ee=ce(te,m=>m.interruptSource),ge=ce(te,m=>m.loadingOlderMessages),Te=ce(te,m=>m.hasOlderMessages),fe=ce(te,m=>m.connectionState),Me=An(H)&&(Z==null?void 0:Z.provider)===(H==null?void 0:H.provider),ve=p.some(m=>m.status==="queued"||m.status==="dispatching"),De=X&&!ue,Ve=Ms(Z),et=Ve||G===!0||De?!0:G,ut=pe===!0||De?!0:pe,Ye=Ve||De;or({sending:X,setSending:k,session:Z,runtimeHasActiveRun:G,runtimeCanInterrupt:pe});const Xe=bi((Z==null?void 0:Z.parallelGroup)??t.session.parallelGroup),dt=wi({groupId:((Pe=(Z==null?void 0:Z.parallelGroup)??t.session.parallelGroup)==null?void 0:Pe.groupId)??"parallel-group",ordinal:t.ordinal,overrideColor:I}),kt=Si((Z==null?void 0:Z.parallelGroup)??t.session.parallelGroup),ye=(Z==null?void 0:Z.sessionIsolatedWorkspace)??t.sessionIsolatedWorkspace,be=xi(ye),Ne=((Ee=U==null?void 0:U.modelId)==null?void 0:Ee.trim())||((Be=t.model)==null?void 0:Be.trim())||o("shell.parallelPaneModelFallback"),oe=((st=t.memberPrompt)==null?void 0:st.trim())||o("shell.parallelPanePromptFallback"),ze=t.workspaceId,re=Nn(Z??t.session,ye),Ge=re===ze?(s==null?void 0:s.displayName)??ze:be??oe,ke=w===f,Rt=n&&O?{...it(s)??{},...Xe??{},...dt,left:`${O.x}px`,top:`${O.y}px`,width:`${O.width}px`}:void 0,tt=ne&&D?{...it(s)??{},...Xe??{},...dt,left:`${D.x}px`,top:`${D.y}px`,width:`${D.width}px`,height:`${D.height}px`}:void 0;a.useEffect(()=>{te.applyNavigationSession(t.session)},[t.session,te]),a.useEffect(()=>(te.initialize(),()=>{var m;(m=b.current)==null||m.destroy(),b.current=null}),[te]),a.useEffect(()=>{Se(Xs(f)),me(!1),L(!1),j(null),W(null),E("files")},[f]),a.useEffect(()=>{if(!n)return;const m=C=>{var we,je,Le;const xe=C.target;xe instanceof HTMLElement&&((we=q.current)!=null&&we.contains(xe)||(je=P.current)!=null&&je.contains(xe)||(Le=K.current)!=null&&Le.contains(xe)||i())};return window.addEventListener("pointerdown",m),()=>{window.removeEventListener("pointerdown",m)}},[n,i]),a.useEffect(()=>{if(!n){W(null);return}const m=()=>{var C;W(Lo(((C=ae.current)==null?void 0:C.getBoundingClientRect())??null))};return m(),window.addEventListener("resize",m),window.addEventListener("scroll",m,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0)}},[n]),a.useEffect(()=>{if(!ne)return;const m=()=>{j(C=>C&&It(C))};return window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[ne]);async function ht(){if(re===ze&&x(ze),v.isDesktop&&v.bridge.supported){const m=await ki(v,{workspaceId:re,workspaceName:Ge,focusOwner:"terminal-page"});m.ok||F({title:m.detail??o("terminalManager.openExternalFailed"),tone:"error"});return}g(Ri(re))}async function Tt(){if(!(!v.isDesktop||!v.bridge.supported)){if(T==="files"){const m=await Mi(v,{workspaceId:re,workspaceName:Ge,sessionId:f,focusOwner:"file-context-panel"});m.ok||F({title:m.detail??o("conversation.filePanelOpenExternalFailed"),tone:"error"});return}if(T==="git"){const m=await yi(v,{workspaceId:re,workspaceName:Ge,focusOwner:"git-sidebar"});m.ok||F({title:m.detail??o("git.openExternalFailed"),tone:"error"});return}if(T==="processes"){const m=await Pi(v,{workspaceId:re,workspaceName:Ge,focusOwner:"terminal-manager-panel"});m.ok||F({title:m.detail??o("terminalManager.openExternalFailed"),tone:"error"});return}await ht()}}function Xt(){var m,C;me(!0),j(No(((m=se.current)==null?void 0:m.getBoundingClientRect())??null)??Ao(((C=le.current)==null?void 0:C.getBoundingClientRect())??null))}function mt(m){if(m.button!==0||!D)return;m.preventDefault();const C=m.clientX,xe=m.clientY,we=D,je=He=>{j(It({...we,x:we.x+(He.clientX-C),y:we.y+(He.clientY-xe)}))},Le=()=>{window.removeEventListener("pointermove",je),window.removeEventListener("pointerup",Le)};window.addEventListener("pointermove",je),window.addEventListener("pointerup",Le)}function pt(m){if(m.button!==0||!D)return;m.preventDefault(),m.stopPropagation();const C=m.clientX,xe=m.clientY,we=D,je=He=>{j(It({...we,width:we.width+(He.clientX-C),height:we.height+(He.clientY-xe)}))},Le=()=>{window.removeEventListener("pointermove",je),window.removeEventListener("pointerup",Le)};window.addEventListener("pointermove",je),window.addEventListener("pointerup",Le)}async function Ct(m,C){var je,Le;const xe=ue;if(!xe){await te.sendMessage(m,{model:C==null?void 0:C.model,reasoningLevel:C==null?void 0:C.reasoningLevel,attachments:C==null?void 0:C.attachments}),M();return}let we=null;try{we=await ws(f,{sourceType:"message",sourceMessageId:xe.sourceMessageId,sourceMessageSnapshot:xe.sourceMessageSnapshot,strategy:"auto",targetProvider:xe.targetProvider}),V(we),await qt(we.sessionId,{content:m,clientRequestId:((Le=(je=globalThis.crypto)==null?void 0:je.randomUUID)==null?void 0:Le.call(je))??`fork-${Date.now()}-${Math.random().toString(16).slice(2)}`,model:xe.targetModel,reasoningLevel:(C==null?void 0:C.reasoningLevel)??null,permissionMode:$e(),attachments:(C==null?void 0:C.attachments)??[]}),de(null),M(),x(we.workspaceId),g(Oe(we.workspaceId,we.sessionId))}catch(He){throw we&&(V(we),M()),He}}const Et=ne&&typeof document<"u"?at.createPortal(r.jsxs("div",{ref:K,className:"parallel-pane-tools-popover","data-parallel-pane-layer":f,"data-pinned":y?"true":void 0,"data-workspace-tone":(s==null?void 0:s.tone)??"root",style:tt,children:[r.jsxs("div",{className:"parallel-pane-tools-toolbar",children:[r.jsxs("div",{className:"parallel-pane-tools-drag-handle",onPointerDown:mt,children:[r.jsx("span",{className:"parallel-pane-tools-drag-dots","aria-hidden":"true",children:r.jsx(Fo,{})}),r.jsx("span",{children:o("shell.parallelPaneToolsAction")})]}),r.jsx("div",{className:"parallel-pane-tools-tabs",role:"tablist","aria-label":o("shell.parallelPaneToolsAction"),children:["files","git","processes","terminals"].map(m=>r.jsx("button",{type:"button",role:"tab","aria-selected":T===m,className:"parallel-pane-tools-tab",onClick:()=>{E(m)},children:m==="files"?o("shell.filesEntry"):m==="git"?o("shell.gitEntry"):m==="processes"?o("shell.parallelPaneProcessesEntry"):o("shell.terminalsEntry")},m))}),r.jsxs("div",{className:"parallel-pane-tools-actions",children:[r.jsx("button",{type:"button",className:`conversation-header-ai-button${y?" active":""}`,"aria-label":o("shell.parallelPanePinAction"),title:o("shell.parallelPanePinAction"),"aria-pressed":y,onClick:()=>{L(m=>!m)},children:r.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:r.jsx(Bo,{})})}),v.isDesktop&&v.bridge.supported?r.jsx("button",{type:"button",className:"conversation-header-ai-button","aria-label":o("shell.parallelPaneDetachAction"),title:o("shell.parallelPaneDetachAction"),onClick:()=>{Tt()},children:r.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:r.jsx(Wo,{})})}):null,r.jsx("button",{type:"button",className:"conversation-header-ai-button","aria-label":o("common.close"),title:o("common.close"),onClick:()=>{me(!1)},children:r.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:r.jsx(qo,{})})})]})]}),r.jsx("div",{className:"parallel-pane-tools-body","data-panel":T,children:T==="files"?r.jsx(Xn,{className:"parallel-pane-tools-surface",hideHeading:!0,sessionId:f,workspaceId:re}):T==="git"?r.jsx(Gn,{className:"parallel-pane-tools-surface",panelActive:!0,workspaceId:re}):T==="processes"?r.jsx($n,{className:"parallel-pane-tools-surface parallel-pane-tools-process-panel",currentWorkspaceId:re,navigationGroups:A}):r.jsx(Bi,{embeddedMode:!0,externalWindowWorkspaceId:re,workbenchShellOverrides:{navigationGroups:A,currentWorkspaceId:re,selectWorkspace:x}})}),r.jsx("button",{type:"button",className:"parallel-pane-tools-resize-handle","aria-label":o("shell.parallelPaneResizeAction"),title:o("shell.parallelPaneResizeAction"),onPointerDown:pt,children:r.jsx("span",{"aria-hidden":"true",children:r.jsx(Uo,{})})})]}),document.body):null,jt=n&&typeof document<"u"?at.createPortal(r.jsxs("div",{ref:P,className:"parallel-pane-info-popover","data-parallel-pane-layer":f,"data-workspace-tone":(s==null?void 0:s.tone)??"root",style:Rt,children:[r.jsx("strong",{className:"parallel-pane-info-title",children:o("shell.parallelPaneInfoTitle")}),r.jsx(zt,{children:r.jsxs("dl",{className:"parallel-pane-info-list",children:[r.jsxs("div",{children:[r.jsx("dt",{children:o("shell.createSessionProviderLabel")}),r.jsx("dd",{children:Mt((Z??t.session).provider,"full")})]}),r.jsxs("div",{children:[r.jsx("dt",{children:o("shell.parallelPaneModelFallback")}),r.jsx("dd",{children:Ne})]}),r.jsxs("div",{children:[r.jsx("dt",{children:o("shell.parallelPaneIsolatedWorkspaceTitle")}),r.jsx("dd",{children:be??o("common.unknown")})]})]})}),r.jsx(zt,{heading:o("shell.parallelPaneColorPaletteLabel"),description:o("shell.parallelPaneColorPaletteDescription"),actions:r.jsx("button",{type:"button",className:"ghost-button parallel-pane-color-reset",disabled:!I||ke,onClick:()=>{ds(f,null),Se(null)},children:o("shell.parallelPaneColorPaletteReset")}),children:r.jsx("div",{className:"workbench-manage-color-palette parallel-pane-color-palette","aria-label":o("shell.parallelPaneColorPaletteLabel"),children:Ii.map(m=>r.jsx("button",{type:"button",className:"workbench-manage-color-swatch","aria-label":o("shell.manageWorkspaceColorSelectSwatch",{color:m}),"aria-pressed":I===m,"data-selected":I===m,disabled:ke,style:{backgroundColor:m},onClick:()=>{const C=ds(f,m);Se(C)}},m))})}),r.jsx(zt,{heading:o("shell.parallelPaneIsolatedWorkspaceTitle"),description:(ye==null?void 0:ye.lifecycleStatus)==="active"?o("shell.parallelPanePromoteDescription"):(ye==null?void 0:ye.lifecycleStatus)==="promoted"?o("shell.parallelPaneRemovePromotedDescription"):o("shell.parallelPaneRemoveDescription"),children:r.jsxs(Ss,{align:"start",className:"parallel-pane-action-row",children:[(ye==null?void 0:ye.lifecycleStatus)==="active"?r.jsx("button",{type:"button",className:"secondary-button parallel-pane-promote-action",disabled:u===ye.id||ke,onClick:()=>{const m=ye==null?void 0:ye.id;m&&l(m)},children:u===ye.id?o("shell.parallelPanePromoting"):o("shell.parallelPanePromoteAction")}):null,r.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:ke,onClick:()=>{d(f)},children:ke?o("shell.parallelPaneRemoving"):o("shell.parallelPaneRemoveAction")})]})})]}),document.body):null;return r.jsxs(r.Fragment,{children:[r.jsxs("article",{ref:se,className:"parallel-conversation-pane","data-current":e?"true":void 0,"data-workspace-tone":(s==null?void 0:s.tone)??"root","data-parallel-role":((nt=(Z==null?void 0:Z.parallelGroup)??t.session.parallelGroup)==null?void 0:nt.role)??void 0,style:{...it(s)??{},...Xe??{},...dt},children:[r.jsxs("header",{ref:q,className:"parallel-conversation-pane-header",children:[r.jsx("span",{className:"parallel-conversation-pane-connector","aria-hidden":"true"}),r.jsxs("div",{className:"parallel-conversation-pane-heading",children:[kt?r.jsx("span",{className:"session-parallel-badge",children:kt}):null,r.jsx("p",{className:"parallel-conversation-pane-subtitle",title:oe,children:oe}),r.jsxs("div",{className:"parallel-conversation-pane-meta",children:[r.jsx("span",{className:`session-provider-badge ${(Z??t.session).provider}`,children:Mt((Z??t.session).provider)}),r.jsx("span",{className:"parallel-conversation-pane-model",children:Ne})]})]}),r.jsxs("div",{className:"parallel-conversation-pane-actions",children:[r.jsx("button",{ref:ae,type:"button",className:"conversation-header-ai-button","aria-label":o("shell.parallelPaneInfoAction"),title:o("shell.parallelPaneInfoAction"),"aria-expanded":n,onClick:()=>{me(!1),c()},children:r.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:r.jsx(Do,{})})}),r.jsx("button",{ref:le,type:"button",className:`conversation-header-ai-button${ne?" active":""}`,"aria-label":o("shell.parallelPaneToolsAction"),title:o("shell.parallelPaneToolsAction"),"aria-expanded":ne,onClick:()=>{i(),Xt()},children:r.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:r.jsx(Ho,{})})})]})]}),r.jsxs("div",{className:"parallel-conversation-pane-body",children:[r.jsx(Ts,{connectionState:fe,onReconnect:()=>te.reconnect()}),r.jsx(Vn,{requests:Re,replyingRequestId:z,onReply:async(m,C)=>{R(m);try{await te.replyPermissionRequest(m,C)}catch(xe){F({title:o("conversation.permissionRequestReplyFailed"),description:xe instanceof Error?xe.message:void 0,tone:"error"})}finally{R(null)}}}),r.jsx("div",{className:"parallel-conversation-pane-timeline",children:r.jsx(ks,{sessionId:f,messages:Ce,historyState:ie,loadingOlderMessages:ge,hasOlderMessages:Te,provider:(Z==null?void 0:Z.provider)??t.session.provider,interruptedSource:ee,runtimeThinkingPlaceholder:null,followTailUpdates:!0,onLoadOlderMessages:()=>{te.loadOlderMessages()},onRetryMessage:m=>{te.retryMessage(m)},onForkMessage:m=>{const C=Z??t.session;de({sourceMessageId:m.id,sourceMessageSnapshot:{role:m.role,kind:m.kind??(m.role==="tool"?"tool_result":"text"),content:m.content},content:m.content,sourceProvider:C.provider,workspaceId:C.workspaceId,targetProvider:C.provider,targetModel:null})}})}),r.jsx(Zn,{items:p,deletingQueueItemId:N,steeringQueueItemId:Q,canSteer:Me,onDelete:async m=>{B(m);try{await te.deleteQueuedMessage(m)}finally{B(null)}},onSteer:async m=>{Y(m);try{await te.steerQueuedMessage(m),M()}finally{Y(null)}}}),r.jsx(Rs,{capabilities:H,draftStorageId:f,initialModel:t.model,forkDraft:ue,onClearForkDraft:()=>de(null),onForkDraftChange:m=>de(m),hasActiveRun:et,contextUsage:U,taskProvider:(Z??t.session).provider,taskMessages:Ce,hasPendingQueuedMessages:ve,canInterrupt:ut,isSubmitting:X,isRunning:Ye,onInterrupt:async()=>{await te.interrupt(),M()},onSend:async(m,C)=>{k(!0);try{await Ct(m,{model:C==null?void 0:C.model,reasoningLevel:C==null?void 0:C.reasoningLevel,attachments:C==null?void 0:C.attachments})}finally{k(!1)}},onQueueSend:async(m,C)=>{k(!0);try{ue?await Ct(m,{model:C==null?void 0:C.model,reasoningLevel:C==null?void 0:C.reasoningLevel,attachments:C==null?void 0:C.attachments}):await te.enqueueMessage(m,{model:C==null?void 0:C.model,reasoningLevel:C==null?void 0:C.reasoningLevel,attachments:C==null?void 0:C.attachments})}finally{k(!1)}}})]})]}),jt,Et]})}function Do(){return r.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[r.jsx("circle",{cx:"8",cy:"8",r:"5.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),r.jsx("path",{d:"M8 6.1H8.01M7.35 7.6H8V10.3H8.65",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.4"})]})}function Ho(){return r.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[r.jsx("rect",{x:"2.5",y:"2.5",width:"4.2",height:"4.2",rx:"1.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),r.jsx("rect",{x:"9.3",y:"2.5",width:"4.2",height:"4.2",rx:"1.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),r.jsx("rect",{x:"2.5",y:"9.3",width:"4.2",height:"4.2",rx:"1.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),r.jsx("rect",{x:"9.3",y:"9.3",width:"4.2",height:"4.2",rx:"1.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Fo(){return r.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[r.jsx("circle",{cx:"5",cy:"4.5",r:"0.9",fill:"currentColor"}),r.jsx("circle",{cx:"11",cy:"4.5",r:"0.9",fill:"currentColor"}),r.jsx("circle",{cx:"5",cy:"8",r:"0.9",fill:"currentColor"}),r.jsx("circle",{cx:"11",cy:"8",r:"0.9",fill:"currentColor"}),r.jsx("circle",{cx:"5",cy:"11.5",r:"0.9",fill:"currentColor"}),r.jsx("circle",{cx:"11",cy:"11.5",r:"0.9",fill:"currentColor"})]})}function Bo(){return r.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:r.jsx("path",{d:"M10.9 3.1 12.9 5.1 10.9 6.1v2.1l-2.1 2.1v2.6l-.8-.8-.8.8v-2.6L5 8.2V6.1L3.1 5.1l2-2h5.8Z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.1"})})}function Wo(){return r.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[r.jsx("path",{d:"M5 3.1H3.8A1.3 1.3 0 0 0 2.5 4.4v7.8a1.3 1.3 0 0 0 1.3 1.3h7.8a1.3 1.3 0 0 0 1.3-1.3V11",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.2"}),r.jsx("path",{d:"M8.1 3.1h4.4v4.4M12.3 3.3 7 8.6",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.2"})]})}function qo(){return r.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:r.jsx("path",{d:"M4.5 4.5 11.5 11.5M11.5 4.5 4.5 11.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"1.3"})})}function Uo(){return r.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:r.jsx("path",{d:"M6.5 12.2 12.2 6.5M9 12.4 12.4 9M11.4 12.4 12.4 11.4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.1"})})}const ot=196,Ke=82,Sn=28,xn=24,ar=34,fs=18,Vo=332,_t=360,Bt=840,In=18,Xo=.22,Go=2.4,$o=6;function Yo(t,e){return(e.lastMessageAt??e.updatedAt).localeCompare(t.lastMessageAt??t.updatedAt)}function lr(t,e,s){var A,M;if(!e)return null;const n=t.find(x=>x.workspace.id===e);if(!n)return null;const i=new Map(n.sessions.map(x=>[x.sessionId,x])),c=i.get(s)??null;if(!c)return null;const l=new Map;for(const x of n.sessions){const V=((A=x.parentSessionId)==null?void 0:A.trim())||null;if(!V)continue;const _=l.get(V)??[];l.set(V,[..._,x.sessionId])}const u=new Set,d=new Set;let w=c,g=c.sessionId;for(;w&&!d.has(w.sessionId);){u.add(w.sessionId),d.add(w.sessionId),g=w.sessionId;const x=((M=w.parentSessionId)==null?void 0:M.trim())||null;w=x?i.get(x)??null:null}const v=cr(g,0,i,l,new Set),F=Qo(v);return{root:v,current:c,currentPathIds:u,relatedSessionIds:F,sessionsById:i}}function zo(t){return((t==null?void 0:t.relatedSessionIds.size)??0)>1}function cr(t,e,s,n,i){const c=s.get(t);if(!c)throw new Error(`Session ${t} not found`);const l=new Set(i);l.add(t);const u=[...n.get(t)??[]].filter(d=>!l.has(d)).sort((d,w)=>{const g=s.get(d),v=s.get(w);return!g||!v?0:Yo(g,v)});return{session:c,depth:e,children:u.map(d=>cr(d,e+1,s,n,l))}}function Qo(t){const e=new Set;function s(n){e.add(n.session.sessionId),n.children.forEach(s)}return s(t),e}function ur(t){const e=Hn(t),s=t.lastMessageAt??t.updatedAt,n=s?new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(s)):null;return[Mt(t.provider),n,e].filter(Boolean).join(" · ")}function dr(t){return t.isArchived===!0}function Ko(t){return[...t].sort((e,s)=>e.sequence-s.sequence).filter(e=>e.content.trim().length>0||e.kind==="tool_call"||e.kind==="tool_result")}function hr(t,e){return t<=0||e<=0?1:Math.min(1,t/e)}function Zo(t,e,s,n){const i=hr(t,s),c=s*i,l=n*i,u=c<t?(t-c)/2:0;return{scale:i,offsetX:u,offsetY:0,shellWidth:Math.max(t,c),shellHeight:l}}function gs(t,e,s){return Math.min(s,Math.max(e,t))}function Jo(t,e,s,n){if(t<=0||e<=0||s<=0||n<=0)return 1;const i=Math.max(1,t-In*2),c=Math.max(1,e-In*2);return Math.min(1,i/s,c/n)}function Wt(t,e,s,n,i){const c=n*t.scale,l=i*t.scale,u=(e-c)/2,d=(s-l)/2,w=c<=e?u:gs(t.offsetX,e-c,0),g=l<=s?d:gs(t.offsetY,s-l,0);return{scale:t.scale,offsetX:w,offsetY:g}}function Ot(t,e,s,n){const i=Jo(t,e,s,n);return Wt({scale:i,offsetX:(t-s*i)/2,offsetY:(e-n*i)/2},t,e,s,n)}function ea(t,e,s,n,i,c,l,u){const d=(s-t.offsetX)/t.scale,w=(n-t.offsetY)/t.scale;return Wt({scale:e,offsetX:s-d*e,offsetY:n-w*e},i,c,l,u)}function ta(t){var s;const e=t.content.trim();if(e.length>0){const n=e.replace(/\s+/g," ").trim();return n.length<=160?n:`${n.slice(0,157)}...`}return(s=t.toolCall)!=null&&s.name?`${t.toolCall.name} ${o("conversation.branchTreeToolMessageFallback")}`:o("conversation.branchTreeMessageEmpty")}function sa(t){switch(t.role){case"assistant":return o("conversation.roleAssistant");case"system":return o("conversation.roleSystem");case"tool":return o("conversation.roleTool");case"user":default:return o("conversation.roleUser")}}function vs(t,e){const s=e.get(t.session.sessionId);if(s!==void 0)return s;if(t.children.length===0)return e.set(t.session.sessionId,ot),ot;const n=t.children.reduce((c,l,u)=>{const d=c+vs(l,e);return u===0?d:d+fs},0),i=Math.max(ot,n);return e.set(t.session.sessionId,i),i}function na(t){const e=new Map,s=[],n=new Map;function i(u,d,w){const g=vs(u,e),v=d+g/2,F=xn+w*(Ke+ar),A=v-ot/2,M=u.children.reduce((f,b,$)=>{const X=f+vs(b,e);return $===0?X:X+fs},0);let x=d+Math.max(0,(g-M)/2);const V=u.children.map(f=>{const b=i(f,x,w+1);return x+=b.subtreeWidth+fs,b}),_={node:u,children:V,x:A,y:F,centerX:v,centerY:F+Ke/2,subtreeWidth:g};return s.push(_),n.set(u.session.sessionId,_),_}const c=i(t,Sn,0),l=s.reduce((u,d)=>Math.max(u,d.y+Ke),0);return{root:c,nodes:s,bySessionId:n,width:c.subtreeWidth+Sn*2,height:l+xn}}function ra(t){return Math.max(0,Math.min(255,Number.parseFloat(t)))}function ia(t){const e=t.trim();if(e.startsWith("#")){const n=e.slice(1);if(n.length===3){const[i,c,l]=n.split("").map(u=>Number.parseInt(u.repeat(2),16));return{r:i,g:c,b:l}}if(n.length>=6)return{r:Number.parseInt(n.slice(0,2),16),g:Number.parseInt(n.slice(2,4),16),b:Number.parseInt(n.slice(4,6),16)}}const s=e.match(/rgba?\(([^)]+)\)/i);if(s){const[n,i,c]=s[1].split(",").map(l=>ra(l));return{r:n,g:i,b:c}}return null}function Ue(t,e,s){const n=ia(t);return n?`rgba(${n.r}, ${n.g}, ${n.b}, ${e})`:s}function oa(t,e,s,n,i,c){const l=t.getContext("2d");if(!l)return;const u=l,d=window.devicePixelRatio||1;t.width=Math.max(1,Math.floor(e.width*d)),t.height=Math.max(1,Math.floor(e.height*d)),t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,u.setTransform(d,0,0,d,0,0),u.clearRect(0,0,e.width,e.height);const w=window.getComputedStyle(t),g=w.getPropertyValue("--accent").trim()||"#3b82f6",v=w.getPropertyValue("--border-primary").trim()||"#d4d8df",F=w.getPropertyValue("--bg-surface").trim()||"#ffffff";if(!c){const M=u.createLinearGradient(0,0,e.width,e.height);M.addColorStop(0,Ue(F,.38,"rgba(255, 255, 255, 0.38)")),M.addColorStop(1,Ue(g,.05,"rgba(59, 130, 246, 0.05)")),u.fillStyle=M,u.fillRect(0,0,e.width,e.height)}function A(M){for(const x of M.children){const V=n.has(M.node.session.sessionId)&&n.has(x.node.session.sessionId),_=M.node.session.sessionId===i||x.node.session.sessionId===i;u.beginPath(),u.moveTo(M.centerX,M.y+Ke-10);const f=M.y+Ke+ar*.52;u.bezierCurveTo(M.centerX,f,x.centerX,f,x.centerX,x.y+10),u.lineWidth=_?3:V?2.5:1.5,u.strokeStyle=_?Ue(g,.52,"rgba(59, 130, 246, 0.52)"):V?Ue(g,.32,"rgba(59, 130, 246, 0.32)"):Ue(v,.72,"rgba(148, 163, 184, 0.72)"),u.stroke(),u.beginPath(),u.arc(x.centerX,x.y,_?4.5:3.5,0,Math.PI*2),u.fillStyle=_?Ue(g,.9,"rgba(59, 130, 246, 0.9)"):Ue(v,.78,"rgba(148, 163, 184, 0.78)"),u.fill(),A(x)}}A(e.root);for(const M of e.nodes){const x=M.node.session.sessionId===s,V=M.node.session.sessionId===i,_=n.has(M.node.session.sessionId);if(!x&&!V&&!_)continue;const f=u.createRadialGradient(M.centerX,M.centerY,10,M.centerX,M.centerY,V?90:64);f.addColorStop(0,Ue(g,V?.22:.14,"rgba(59, 130, 246, 0.22)")),f.addColorStop(1,"rgba(59, 130, 246, 0)"),u.fillStyle=f,u.beginPath(),u.ellipse(M.centerX,M.centerY,ot*.72,Ke*.9,0,0,Math.PI*2),u.fill(),(V||x)&&(u.beginPath(),u.arc(M.centerX,M.y+12,V?6:5,0,Math.PI*2),u.fillStyle=Ue(g,.94,"rgba(59, 130, 246, 0.94)"),u.fill())}}function aa(t,e,s){const n=Math.min(Vo,e-24),i=t.left+t.width/2-n/2,c=Math.max(12,Math.min(e-n-12,i)),d=s-t.bottom-12<220&&t.top>_t?Math.max(12,t.top-_t-12):Math.max(12,Math.min(s-_t-12,t.bottom+12));return{width:n,left:c,top:d,maxHeight:Math.min(_t,s-24)}}function la({model:t,selectedSession:e,selectedTreeNode:s,previewEntry:n,onClose:i,onOpenSession:c}){const l=ct(e.title,o("common.unknown")),u=e.sessionId===t.current.sessionId,d=dr(e),w=Ln(s.session),g=_n(s.session),v=On(s.session),F=Dn(s.session);return r.jsxs("div",{className:"conversation-branch-preview-popover",role:"dialog","aria-label":`${o("conversation.branchTreePreviewTitle")} ${l.fullTitle}`,children:[r.jsxs("div",{className:"conversation-branch-preview-popover-header",children:[r.jsxs("div",{className:"conversation-branch-preview-card-title-row",children:[r.jsx("strong",{title:l.fullTitle,children:l.displayTitle}),u?r.jsx("span",{className:"conversation-branch-current-badge",children:o("conversation.branchTreeCurrentBadge")}):null,d?r.jsx("span",{className:"conversation-branch-archived-badge",children:o("conversation.branchTreeArchivedBadge")}):null]}),r.jsx("button",{type:"button",className:"conversation-branch-preview-close","aria-label":o("common.close"),onClick:i,children:"x"})]}),r.jsx("p",{className:"conversation-branch-preview-popover-meta",children:ur(e)}),g&&w||F&&v?r.jsxs("div",{className:"conversation-branch-badge-row",children:[F&&v?r.jsx("span",{className:`session-fork-badge ${v}`,children:F}):null,g&&w?r.jsx("span",{className:`session-fork-badge ${w}`,children:g}):null]}):null,r.jsx("div",{className:"conversation-branch-preview-messages",children:n.status==="loading"?r.jsx("p",{className:"conversation-branch-empty",children:o("conversation.branchTreePreviewLoading")}):n.status==="error"?r.jsx("p",{className:"conversation-branch-empty",children:n.error||o("conversation.branchTreePreviewFailed")}):n.messages.length>0?n.messages.map(A=>r.jsxs("article",{className:"conversation-branch-preview-message",children:[r.jsxs("div",{className:"conversation-branch-preview-message-meta",children:[r.jsx("span",{children:sa(A)}),r.jsx("span",{children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(A.timestamp))})]}),r.jsx("p",{children:ta(A)})]},`${e.sessionId}:${A.messageId}`)):r.jsx("p",{className:"conversation-branch-empty",children:o("conversation.branchTreePreviewEmpty")})}),r.jsx("div",{className:"conversation-branch-preview-actions",children:r.jsx("button",{type:"button",className:"secondary-button",disabled:u,onClick:()=>c(e),children:u?o("conversation.branchTreeCurrentAction"):o("conversation.branchTreeSwitchAction")})})]})}function ca({layout:t,model:e,selectedSessionId:s,onSelectSession:n,onBackgroundClick:i,stageScale:c,desktopStageLayout:l,transform:u,isMobileViewport:d,viewportRef:w,onRegisterNodeElement:g,onViewportTouchStart:v,onViewportTouchMove:F,onViewportTouchEnd:A}){const M=a.useRef(null);return a.useEffect(()=>{const x=M.current;x&&oa(x,t,e.current.sessionId,e.currentPathIds,s,d)},[d,t,e.current.sessionId,e.currentPathIds,s]),r.jsx("div",{ref:w,className:"conversation-branch-canvas-viewport","data-scaled":c<.999,"data-mobile":d,onClick:x=>{x.target===x.currentTarget&&(i==null||i())},onTouchStart:v,onTouchMove:F,onTouchEnd:A,onTouchCancel:A,children:r.jsx("div",{className:"conversation-branch-canvas-stage-shell",style:{width:d?"100%":l.shellWidth,height:d?"100%":l.shellHeight},onClick:x=>{x.target===x.currentTarget&&(i==null||i())},children:r.jsxs("div",{className:"conversation-branch-canvas-stage",style:{width:t.width,height:t.height,transform:u?`translate(${u.offsetX}px, ${u.offsetY}px) scale(${u.scale})`:`translate(${l.offsetX}px, ${l.offsetY}px) scale(${l.scale})`,transformOrigin:"top left"},onClick:()=>{if(i){i();return}n(null)},children:[r.jsx("canvas",{ref:M,className:"conversation-branch-canvas",width:t.width,height:t.height,"aria-hidden":"true"}),t.nodes.map(x=>{const V=ct(x.node.session.title,o("common.unknown")),_=Ln(x.node.session),f=_n(x.node.session),b=On(x.node.session),$=Dn(x.node.session),X=x.node.session.sessionId===e.current.sessionId,k=x.node.session.sessionId===s,z=e.currentPathIds.has(x.node.session.sessionId),R=dr(x.node.session);return r.jsx("button",{ref:N=>g(x.node.session.sessionId,N),type:"button",className:"conversation-branch-smart-card conversation-branch-canvas-node","data-current":X,"data-selected":k,"data-current-path":z,"data-archived":R,style:{left:x.x,top:x.y,width:ot,minHeight:Ke},"aria-pressed":k,onClick:N=>{N.stopPropagation(),n(x.node.session.sessionId)},children:r.jsxs("div",{className:"conversation-branch-smart-card-main",children:[r.jsxs("div",{className:"conversation-branch-smart-card-title-row",children:[r.jsx("strong",{title:V.fullTitle,children:V.displayTitle}),X?r.jsx("span",{className:"conversation-branch-current-badge",children:o("conversation.branchTreeCurrentBadge")}):null,R?r.jsx("span",{className:"conversation-branch-archived-badge",children:o("conversation.branchTreeArchivedBadge")}):null]}),r.jsx("p",{children:ur(x.node.session)}),f&&_||$&&b?r.jsxs("div",{className:"conversation-branch-badge-row",children:[$&&b?r.jsx("span",{className:`session-fork-badge ${b}`,children:$}):null,f&&_?r.jsx("span",{className:`session-fork-badge ${_}`,children:f}):null]}):null]})},x.node.session.sessionId)})]})})})}function Mn({model:t,onOpenSession:e,onClose:s}){const n=a.useMemo(()=>na(t.root),[t.root]),i=a.useRef(null),c=a.useRef(new Map),[l,u]=a.useState(null),[d,w]=a.useState(0),[g,v]=a.useState(0),[F,A]=a.useState(null),[M,x]=a.useState({}),V=a.useRef(new Set),[_,f]=a.useState(typeof window<"u"?window.innerWidth<=Bt:!1),[b,$]=a.useState(null),X=a.useRef({mode:"idle",startDistance:0,startScale:1,startOffsetX:0,startOffsetY:0,startTouchX:0,startTouchY:0,anchorX:0,anchorY:0,moved:!1});a.useEffect(()=>{const T=i.current;if(!T)return;const E=T;function y(){w(E.clientWidth),v(E.clientHeight),f(window.innerWidth<=Bt)}if(y(),typeof ResizeObserver>"u")return window.addEventListener("resize",y),()=>window.removeEventListener("resize",y);const L=new ResizeObserver(y);return L.observe(T),()=>L.disconnect()},[]),a.useEffect(()=>{u(null)},[t.current.sessionId,t.root.session.sessionId]);const k=a.useMemo(()=>hr(d,n.width),[d,n.width]),z=a.useMemo(()=>Zo(d,g,n.width,n.height),[g,d,n.height,n.width]);a.useEffect(()=>{if(!_||d<=0||g<=0){$(null);return}$(T=>T?Wt(T,d,g,n.width,n.height):Ot(d,g,n.width,n.height))},[g,d,_,n.height,n.width]);const R=l?t.sessionsById.get(l)??null:null,N=R?n.bySessionId.get(R.sessionId)??null:null,B=R?M[R.sessionId]??{status:"idle",messages:[],error:null}:null,Q=_&&!!s,Y=!!s&&!Q;a.useEffect(()=>{if(!l){A(null);return}const T=l;function E(){const y=c.current.get(T);if(!y){A(null);return}A(y.getBoundingClientRect())}return E(),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[l,k]),a.useEffect(()=>{if(!_)return;const T=l;if(!T)return;const E=window.requestAnimationFrame(()=>{const y=c.current.get(T);y&&A(y.getBoundingClientRect())});return()=>window.cancelAnimationFrame(E)},[_,b,l]),a.useEffect(()=>{if(!(R!=null&&R.sessionId)||(B==null?void 0:B.status)==="ready"||V.current.has(R.sessionId))return;let T=!1;return V.current.add(R.sessionId),x(E=>{var y;return{...E,[R.sessionId]:{status:"loading",messages:((y=E[R.sessionId])==null?void 0:y.messages)??[],error:null}}}),cs(R.sessionId,null,6,"backward").then(E=>{V.current.delete(R.sessionId),!T&&x(y=>({...y,[R.sessionId]:{status:"ready",messages:Ko(E.messages),error:null}}))}).catch(E=>{V.current.delete(R.sessionId),!T&&x(y=>{var L;return{...y,[R.sessionId]:{status:"error",messages:((L=y[R.sessionId])==null?void 0:L.messages)??[],error:E instanceof Error?E.message:o("conversation.branchTreePreviewFailed")}}})}),()=>{T=!0}},[R==null?void 0:R.sessionId]);function ue(T){!_||d<=0||g<=0||$(E=>{const y=E??Ot(d,g,n.width,n.height);return Wt(T(y),d,g,n.width,n.height)})}function de(T){if(!_)return;const E=T.currentTarget.getBoundingClientRect();if(T.touches.length>=2){const D=T.touches[0],j=T.touches[1],O=Math.hypot(j.clientX-D.clientX,j.clientY-D.clientY),W=(D.clientX+j.clientX)/2-E.left,se=(D.clientY+j.clientY)/2-E.top,q=b??Ot(d,g,n.width,n.height);X.current={mode:"pinch",startDistance:O,startScale:q.scale,startOffsetX:q.offsetX,startOffsetY:q.offsetY,startTouchX:W,startTouchY:se,anchorX:W,anchorY:se,moved:!1};return}const y=T.touches[0],L=b??Ot(d,g,n.width,n.height);X.current={mode:"pan",startDistance:0,startScale:L.scale,startOffsetX:L.offsetX,startOffsetY:L.offsetY,startTouchX:y.clientX,startTouchY:y.clientY,anchorX:0,anchorY:0,moved:!1}}function ne(T){if(!_)return;const E=X.current;if(T.touches.length>=2){const O=T.currentTarget.getBoundingClientRect(),W=T.touches[0],se=T.touches[1],q=Math.hypot(se.clientX-W.clientX,se.clientY-W.clientY);if(q<=0||E.startDistance<=0)return;T.preventDefault();const ae=(W.clientX+se.clientX)/2-O.left,P=(W.clientY+se.clientY)/2-O.top,K=gs(E.startScale*(q/E.startDistance),Xo,Go);X.current={...E,mode:"pinch",moved:!0,anchorX:ae,anchorY:P},ue(le=>ea({...le,scale:E.startScale,offsetX:E.startOffsetX,offsetY:E.startOffsetY},K,ae,P,d,g,n.width,n.height));return}if(E.mode!=="pan"||T.touches.length!==1)return;const y=T.touches[0],L=y.clientX-E.startTouchX,D=y.clientY-E.startTouchY;(E.moved||Math.hypot(L,D)>=$o)&&(T.preventDefault(),X.current={...E,moved:!0},ue(O=>({...O,offsetX:E.startOffsetX+L,offsetY:E.startOffsetY+D})))}function me(){X.current={mode:"idle",startDistance:0,startScale:(b==null?void 0:b.scale)??1,startOffsetX:(b==null?void 0:b.offsetX)??0,startOffsetY:(b==null?void 0:b.offsetY)??0,startTouchX:0,startTouchY:0,anchorX:0,anchorY:0,moved:!1}}return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:`conversation-branch-tree-pane${s?" conversation-branch-dialog":""}${Q?" conversation-branch-dialog-mobile-bare":""}`,role:s?"dialog":void 0,"aria-modal":s?"true":void 0,"aria-label":s?o("conversation.branchTreeTitle"):void 0,children:[Y?r.jsx("div",{className:"conversation-branch-tree-pane-header",children:r.jsxs("div",{className:"conversation-branch-tree-pane-topbar",children:[r.jsxs("div",{className:"conversation-branch-tree-pane-heading",children:[r.jsx("h3",{children:o("conversation.branchTreeMapTitle")}),r.jsx("p",{children:o("conversation.branchTreeMapDescription")})]}),s?r.jsx("button",{type:"button",className:"conversation-branch-pane-close","aria-label":o("common.close"),onClick:s,children:"x"}):null]})}):null,r.jsxs("div",{className:"conversation-branch-canvas-shell",children:[Q?r.jsx("button",{type:"button",className:"conversation-branch-pane-close conversation-branch-mobile-floating-close","aria-label":o("common.close"),onClick:s,children:"x"}):null,Q?null:r.jsx("div",{className:"conversation-branch-canvas-tip",children:o("conversation.branchTreePreviewDescription")}),r.jsx(ca,{layout:n,model:t,selectedSessionId:l,onSelectSession:u,onBackgroundClick:Q?s:void 0,stageScale:k,desktopStageLayout:z,transform:_?b:null,isMobileViewport:_,viewportRef:i,onRegisterNodeElement:(T,E)=>{if(E){c.current.set(T,E);return}c.current.delete(T)},onViewportTouchStart:de,onViewportTouchMove:ne,onViewportTouchEnd:me})]})]}),R&&N&&B&&F&&typeof document<"u"?at.createPortal(r.jsx("div",{className:"conversation-branch-preview-floating",style:aa(F,window.innerWidth,window.innerHeight),children:r.jsx(la,{model:t,selectedSession:R,selectedTreeNode:N.node,previewEntry:B,onClose:()=>u(null),onOpenSession:e})}),document.body):null]})}function ua({open:t,navigationGroups:e,workspaceId:s,sessionId:n,onClose:i,onOpenSession:c}){const l=a.useMemo(()=>lr(e,s,n),[e,n,s]),[u,d]=a.useState(typeof window<"u"?window.innerWidth>Bt:!0);return a.useEffect(()=>{if(typeof window>"u")return;function w(){d(window.innerWidth>Bt)}return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[]),!t||!l||typeof document>"u"?null:u?r.jsx(bs,{open:t,title:o("conversation.branchTreeMapTitle"),description:o("conversation.branchTreeMapDescription"),size:"regular",layout:"viewer",bodyClassName:"conversation-branch-modal-body",onClose:i,children:r.jsx(Mn,{model:l,onOpenSession:c})}):at.createPortal(r.jsxs("div",{className:"workbench-modal-layer conversation-branch-panel-layer",children:[r.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":o("common.close"),onClick:i}),r.jsx(Mn,{model:l,onOpenSession:c,onClose:i})]}),document.body)}function da(t){const e=t.trim().length;return e<=16?"xl":e<=26?"lg":e<=38?"md":"sm"}function mr({session:t,actions:e,workspaceContext:s=null}){const n=Pt(),i=Ti(n);if(!t)return r.jsxs("header",{className:"conversation-header conversation-header-skeleton","aria-hidden":"true","data-window-drag-handle":"conversation-header","data-tauri-drag-region":i,children:[r.jsxs("div",{className:"conversation-header-main","data-tauri-drag-region":i,children:[r.jsx("span",{className:"skeleton-line short"}),r.jsx("span",{className:"skeleton-line long"})]}),e?r.jsx("div",{className:"conversation-header-actions",children:e}):null]});const c=ct(t.title,o("conversation.titleFallback")),l=da(c.displayTitle);return r.jsxs("header",{className:"conversation-header","data-workspace-tone":(s==null?void 0:s.tone)??"root",style:it(s),"data-window-drag-handle":"conversation-header","data-tauri-drag-region":i,children:[r.jsx("div",{className:"conversation-header-main","data-tauri-drag-region":i,children:r.jsx("h1",{className:`conversation-title is-${l}`,title:c.fullTitle,"data-tauri-drag-region":i,children:c.displayTitle})}),e?r.jsx("div",{className:"conversation-header-actions",children:e}):null]})}function ha(t,e,s){if(!e)return null;const n=t.find(l=>l.workspace.id===e);if(!n)return null;const i=Ft([n]).filter(l=>!l.session.isArchived&&!Ut(l.session)),c=i.findIndex(l=>l.session.sessionId===s);return c<0?null:i[c+1]??null}const ma=15e3,yn=.6,ls=.6,Pn=8,pa=36,fa=48,ga=96,va=320,ba="workbench:focus-composer";function dl(){const{sessionId:t="",workspaceId:e}=li(),s=Is(),n=Je(),i=a.useMemo(()=>new URLSearchParams(s.search),[s.search]),c=Pa(i.get("toolPanel")),l=(e==null?void 0:e.trim())||null,u=a.useMemo(()=>Ma(t,l,i),[l,i,t]),d=a.useMemo(()=>Ba(t,s.state),[s.state,t]);return u?r.jsx(Ia,{draft:u,navigate:n,initialToolPanel:c}):r.jsx(wa,{sessionId:t,bootstrapMessages:d,initialToolPanel:c})}function wa({sessionId:t,bootstrapMessages:e,initialToolPanel:s}){var Ds,Hs,Fs;const{shellMode:n,navigationGroups:i,requestNavigationRefresh:c,selectWorkspace:l,setSessionWorkspace:u,markNavigationSessionSeen:d,favoriteSessions:w,archiveSession:g,unarchiveSession:v,startDraftSession:F,upsertNavigationSession:A}=lt(),M=Je(),x=a.useRef(null),V=a.useRef(null),[_,f]=a.useState(!1),[b,$]=a.useState(null),[X,k]=a.useState(!1),[z,R]=a.useState(!1),[N,B]=a.useState(null),[Q,Y]=a.useState(!1),[ue,de]=a.useState(!1),[ne,me]=a.useState(null),[T,E]=a.useState(!1),y=a.useMemo(()=>{var h;return((h=Ft(i).find(S=>S.session.sessionId===t))==null?void 0:h.session)??null},[i,t]);(!x.current||V.current!==t)&&((Ds=x.current)==null||Ds.destroy(),x.current=new er(t,{initialSession:y,bootstrapMessages:e,onSeen:(h,S)=>{d(h,S)}}),V.current=t);const L=x.current,{showToast:D,dismissToast:j}=Ze(),O=ni(h=>h.notificationPreferences.notifyOnPermissionRequest),W=Pt(),se=xs(),q=a.useRef(null),ae=a.useRef(null),P=a.useRef(null),K=a.useRef((y==null?void 0:y.runningState)??null),le=a.useRef(new Set),I=ce(L,h=>h.session),Se=ce(L,h=>h.capabilities),te=ce(L,h=>h.runtimeHasActiveRun),Z=ce(L,h=>h.runtimeCanInterrupt),H=ce(L,h=>h.messages),G=ce(L,h=>h.permissionRequests),pe=ce(L,h=>h.queuedMessages),Ce=ce(L,h=>h.contextUsage),Re=ce(L,h=>h.historyState),p=ce(L,h=>h.errorCode),U=ce(L,h=>h.errorDetail),ie=ce(L,h=>h.interruptSource),ee=ce(L,h=>h.loadingOlderMessages),ge=ce(L,h=>h.hasOlderMessages),Te=ce(L,h=>h.connectionState),[fe,Me]=a.useState(null),[ve,De]=a.useState(null),Ve=Ms(I),et=An(Se)&&(I==null?void 0:I.provider)===(Se==null?void 0:Se.provider),ut=pe.some(h=>h.status==="queued"||h.status==="dispatching"),Ye=_&&!ne,Xe=te===!0||Ye?!0:te,dt=Z===!0||Ye?!0:Z,kt=Ve||Ye;or({sending:_,setSending:f,session:I,runtimeHasActiveRun:te,runtimeCanInterrupt:Z});const ye=La({sessionId:t,provider:(I==null?void 0:I.provider)??null,runningState:(I==null?void 0:I.runningState)??null,activityState:(I==null?void 0:I.activityState)??null,runtimeHasActiveRun:te,messages:H})?o("conversation.runtimeThinkingPlaceholder",{provider:o("conversation.providerCodex")}):null,be=n!=="mobile",Ne=Mr(!be),oe=I??y??null,ze=(I==null?void 0:I.sessionIsolatedWorkspace)??(y==null?void 0:y.sessionIsolatedWorkspace)??null,re=oe?Ht(oe,ze):null,Ge=oe?Nn(oe,ze):null,ke=xr({enabled:!be,initialPanel:s,workspaceId:Ge,suspendMainGesture:!be&&Ne.isVisible}),Rt=a.useMemo(()=>new Set(w.map(h=>h.session.sessionId)),[w]),tt=a.useMemo(()=>i.map(h=>h.workspace),[i]),ht=a.useMemo(()=>Ft(i),[i]),Tt=a.useMemo(()=>Yn(i),[i]),Xt=a.useMemo(()=>ys(i),[i]),mt=a.useMemo(()=>fr(i,re,Rt),[Rt,re,i]),pt=a.useMemo(()=>gr(w,i),[w,i]),[Ct,Et]=a.useState([]),jt=a.useMemo(()=>[...pt,...mt],[pt,mt]),ft=a.useMemo(()=>re?tt.find(h=>h.id===re)??null:null,[re,tt]),Pe=(re?Xt[re]??null:null)??(ft?Ps(ft):null),Ee=a.useMemo(()=>Vt(i,re),[re,i]),Be=Tt.find(h=>h.workspace.id===re)??(Ee?{workspace:Ee.workspace,label:Ee.workspace.name,subtitle:Ee.workspace.path}:null),st=a.useMemo(()=>ha(i,re,t),[re,i,t]),nt=(I==null?void 0:I.provider)??(y==null?void 0:y.provider)??null,m=a.useMemo(()=>{var h;return ct(((h=I??y)==null?void 0:h.title)??null,o("conversation.titleFallback"))},[y,I]),C=be,xe=C&&Ci(oe)?((Hs=oe==null?void 0:oe.parallelGroup)==null?void 0:Hs.groupId)??null:null,we=be?null:Sr(Ne.mainGestureHandlers,ke.mainGestureHandlers);a.useEffect(()=>{const h=Bn(jt,t,S=>S.session.sessionId);h.length!==0&&Et(S=>{const J=new Set(S);let _e=!1;for(const Qe of h)J.has(Qe)||(J.add(Qe),_e=!0);return _e?Array.from(J):S})},[jt,t]);const Le=a.useMemo(()=>Ua(oe,H),[oe,H]),He=(oe==null?void 0:oe.workspaceId)??(y==null?void 0:y.workspaceId)??null,Rr=a.useMemo(()=>lr(i,He,t),[He,i,t]),Tr=zo(Rr),As=!!(oe&&He&&Tr),Ns=()=>{de(!0)},Gt=a.useMemo(()=>(Ee==null?void 0:Ee.sessions.filter(h=>h.isArchived===!0&&!Ut(h)))??[],[Ee]),Cr=a.useRef(null),Ls=a.useRef(null),$t=a.useRef(null),_s=a.useRef(null),[Er,jr]=a.useState(null),{composerPortalTarget:Ar}=Fn();a.useEffect(()=>{L.applyNavigationSession(y)},[y,L]),a.useEffect(()=>(L.initialize(),()=>{L.destroy()}),[L]),a.useEffect(()=>(u(t,(I==null?void 0:I.workspaceId)??null),()=>{u(t,null)}),[I==null?void 0:I.workspaceId,t,u]),a.useEffect(()=>{de(!1),me(null)},[t]),a.useEffect(()=>()=>{P.current!==null&&(window.clearTimeout(P.current),P.current=null)},[]),a.useEffect(()=>{var J;if(p!=="SESSION_NOT_FOUND"&&p!=="WORKSPACE_NOT_FOUND")return;j("conversation-runtime-error");const h=(I==null?void 0:I.workspaceId)??(y==null?void 0:y.workspaceId)??((J=i[0])==null?void 0:J.workspace.id)??null,S=(h?ht.find(_e=>_e.workspace.id===h)??null:null)??ht[0]??null;M(S?Oe(S.workspace.id,S.session.sessionId):h?St(h):n==="mobile"?Ei():"/landing",{replace:!0})},[j,ht,M,i,y==null?void 0:y.workspaceId,p,I==null?void 0:I.workspaceId,n]),a.useEffect(()=>{if(p==="SESSION_NOT_FOUND"||p==="WORKSPACE_NOT_FOUND"){P.current!==null&&(window.clearTimeout(P.current),P.current=null),ae.current=null,q.current=null,j("conversation-runtime-error");return}if(!p||!U){P.current!==null&&(window.clearTimeout(P.current),P.current=null),ae.current=null,q.current=null,j("conversation-runtime-error");return}const h=`${p}:${U}`;if(!(q.current===h||ae.current===h)){if(P.current!==null&&(window.clearTimeout(P.current),P.current=null),Sa((I==null?void 0:I.provider)??null,p,U)){ae.current=h,P.current=window.setTimeout(()=>{ae.current=null,P.current=null,q.current=h,D({id:"conversation-runtime-error",title:o("conversation.runtimeErrorTitle"),description:U,tone:"error",durationMs:null})},ma);return}ae.current=null,q.current=h,D({id:"conversation-runtime-error",title:o("conversation.runtimeErrorTitle"),description:U,tone:"error",durationMs:null})}},[j,p,U,I==null?void 0:I.provider,D]),a.useEffect(()=>{const h=K.current,S=(I==null?void 0:I.runningState)??null;(h==="starting"||h==="running"||h==="reconnecting")&&S==="completed"&&se.trigger("success"),K.current=S},[se,I==null?void 0:I.runningState]),a.useEffect(()=>{const h=G.filter(J=>J.status==="pending"),S=(I==null?void 0:I.workspaceId)??(y==null?void 0:y.workspaceId)??null;for(const J of h)le.current.has(J.id)||(le.current.add(J.id),O&&(D({id:`permission-request-${J.id}`,title:o("conversation.permissionRequestToastTitle"),description:J.title,tone:"warning",durationMs:8e3,action:S?{label:o("shell.contextOpenSession"),onClick:()=>{M(Oe(S,t))}}:void 0}),W.bridge.showNotification(o("conversation.permissionRequestToastTitle"),J.title)))},[y==null?void 0:y.workspaceId,M,O,G,W.bridge,I==null?void 0:I.workspaceId,t,D]),br($t,Er,!be,t),wr($t,_s,!be,t);async function Os(h,S){var Qe,Bs;const J=ne;if(!J){await L.sendMessage(h,{model:S==null?void 0:S.model,reasoningLevel:S==null?void 0:S.reasoningLevel,attachments:S==null?void 0:S.attachments,attachmentMeta:S==null?void 0:S.attachmentMeta}),c();return}let _e=null;try{_e=await ws(t,{sourceType:"message",sourceMessageId:J.sourceMessageId,sourceMessageSnapshot:J.sourceMessageSnapshot,strategy:"auto",targetProvider:J.targetProvider}),A(_e),await qt(_e.sessionId,{content:h,clientRequestId:((Bs=(Qe=globalThis.crypto)==null?void 0:Qe.randomUUID)==null?void 0:Bs.call(Qe))??`fork-${Date.now()}-${Math.random().toString(16).slice(2)}`,model:J.targetModel,reasoningLevel:(S==null?void 0:S.reasoningLevel)??null,permissionMode:$e(),attachments:(S==null?void 0:S.attachments)??[]}),me(null),c(),l(_e.workspaceId),xt("preview"),M(Oe(_e.workspaceId,_e.sessionId)),D({title:o("conversation.forkMessageSucceeded"),tone:"success"})}catch(Lr){throw _e&&(A(_e),c()),Lr}}function Nr(h){l(h),M(St(h))}return be&&xe?r.jsxs(r.Fragment,{children:[r.jsx(_o,{groupId:xe,currentSessionId:t}),r.jsx(us,{open:T,source:oe?{kind:"session",sessionId:t,workspaceId:oe.workspaceId,workspaceName:(Pe==null?void 0:Pe.displayName)??oe.workspaceId,sessionTitle:oe.title,defaultProvider:oe.provider}:null,onClose:()=>E(!1),onCreated:async h=>{h.members.forEach(J=>{A(J.session)}),Gs(h.group.id),await c();const S=h.members.find(J=>J.session.sessionId===h.group.anchorSessionId)??h.members[0]??null;if(S){const J=Ht(S.session,S.sessionIsolatedWorkspace);l(J),M(Oe(J,S.session.sessionId))}E(!1),D({title:o("shell.parallelCreateSucceeded"),tone:"success"})}})]}):r.jsxs(r.Fragment,{children:[r.jsxs("main",{ref:$t,className:"workbench-page conversation-page-shell mobile-page-fixed-root mobile-conversation-page","data-mobile-shell":!be,"data-preview-mode":be?void 0:Ne.displayMode,"data-preview-dragging":be?void 0:Ne.isDragging,"data-workspace-tone":(Pe==null?void 0:Pe.tone)??"root","data-worktree-depth":(Pe==null?void 0:Pe.depth)??0,"data-tool-panel-open":be?void 0:ke.isOpen,style:{...be?{}:Ne.pageStyle,...it(Pe)??{}},children:[be?r.jsx(mr,{session:I??y,workspaceContext:Pe,actions:r.jsxs(r.Fragment,{children:[As?r.jsx(Aa,{onOpenBranchTree:Ns}):null,oe?r.jsx("button",{type:"button",className:"conversation-header-ai-button","aria-label":o("shell.parallelCreateAction"),title:o("shell.parallelCreateAction"),onClick:()=>E(!0),children:r.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:r.jsx(Na,{})})}):null,r.jsx(Kn,{session:I??y})]})}):null,be?null:r.jsx(zn,{containerRef:_s,className:"mobile-conversation-page-header",gestureHandlers:we??void 0,currentWorkspace:Be?{id:Be.workspace.id,name:Be.label,path:Be.subtitle}:tt[0]??null,workspaces:tt,workspaceOptions:Tt,onSelectWorkspace:Nr,heading:m.fullTitle,trailing:r.jsxs("div",{className:"mobile-conversation-toolbar-main",children:[r.jsx("span",{className:"mobile-conversation-toolbar-title",title:m.fullTitle,children:m.displayTitle}),r.jsx(Ji,{session:I??y,onOpenBranchTree:As?Ns:void 0})]})}),be?null:r.jsx(yr,{visible:!ke.isOpen&&Ne.isVisible,widthPx:Ne.previewWidthPx,isDragging:Ne.isDragging,gestureHandlers:Ne.railGestureHandlers,activeSessionId:t,createSessionActionLabel:re&&nt?o("shell.createSession"):void 0,favoriteItems:pt,items:mt,expandedRootIds:Ct,workspaceSectionLabel:(Be==null?void 0:Be.label)??o("shell.mobileConversationCurrentWorkspaceSection"),onCreateSession:re&&nt?()=>{F(re,nt)}:void 0,archiveCurrentActionLabel:o("shell.archiveCurrentSessionAction"),archiveFolderActionLabel:Gt.length>0?o("shell.archiveFolderLabel"):void 0,onArchiveActiveSession:()=>{k(!0)},onOpenArchiveFolder:Gt.length>0?()=>{R(!0)}:void 0,onToggleSubsessions:h=>{Et(S=>S.includes(h)?S.filter(J=>J!==h):[...S,h])},onActivate:h=>{Ne.closePreview(),l(h.workspace.id),M(Oe(h.workspace.id,h.session.sessionId))}}),r.jsx("div",{className:"mobile-conversation-stage",...we??{},children:r.jsxs("div",{ref:Cr,className:"mobile-conversation-main",children:[r.jsx(Ts,{connectionState:Te,onReconnect:()=>L.reconnect()}),r.jsx(Vn,{requests:G,replyingRequestId:b,onReply:async(h,S)=>{$(h);try{await L.replyPermissionRequest(h,S)}catch(J){D({title:o("conversation.permissionRequestReplyFailed"),description:J instanceof Error?J.message:void 0,tone:"error"})}finally{$(null)}}}),r.jsx("div",{ref:Ls,className:"conversation-timeline-shell",children:r.jsx(ks,{sessionId:t,messages:Le,historyState:Re,loadingOlderMessages:ee,hasOlderMessages:ge,provider:(I==null?void 0:I.provider)??null,interruptedSource:ie,runtimeThinkingPlaceholder:ye,onLoadOlderMessages:()=>{L.loadOlderMessages()},onRetryMessage:h=>{L.retryMessage(h)},onForkMessage:h=>{I&&(me({sourceMessageId:h.id,sourceMessageSnapshot:{role:h.role,kind:h.kind??(h.role==="tool"?"tool_result":"text"),content:h.content},content:h.content,sourceProvider:I.provider,workspaceId:I.workspaceId,targetProvider:I.provider,targetModel:null}),xa())}})}),r.jsx(Yi,{containerRef:Ls,session:I??y??null,currentCapabilities:Se}),r.jsx(Zn,{items:pe,deletingQueueItemId:fe,steeringQueueItemId:ve,canSteer:et,onDelete:async h=>{Me(h);try{await L.deleteQueuedMessage(h)}finally{Me(null)}},onSteer:async h=>{De(h);try{await L.steerQueuedMessage(h),c()}finally{De(null)}}}),ke.isOpen?null:r.jsx(Rs,{capabilities:Se,draftStorageId:t,forkDraft:ne,onClearForkDraft:()=>me(null),onForkDraftChange:h=>me(h),panelRef:be?void 0:jr,portalContainer:be?null:Ar,hasActiveRun:Xe,contextUsage:Ce,taskProvider:((Fs=I??y)==null?void 0:Fs.provider)??null,taskMessages:H,hasPendingQueuedMessages:ut,canInterrupt:dt,isSubmitting:_,isRunning:kt,onInterrupt:async()=>{await L.interrupt(),c()},onSend:async(h,S)=>{f(!0);try{await Os(h,{model:S==null?void 0:S.model,reasoningLevel:S==null?void 0:S.reasoningLevel,attachments:S==null?void 0:S.attachments,attachmentMeta:S==null?void 0:S.attachmentMeta})}finally{f(!1)}},onQueueSend:async(h,S)=>{f(!0);try{ne?await Os(h,{model:S==null?void 0:S.model,reasoningLevel:S==null?void 0:S.reasoningLevel,attachments:S==null?void 0:S.attachments,attachmentMeta:S==null?void 0:S.attachmentMeta}):await L.enqueueMessage(h,{model:S==null?void 0:S.model,reasoningLevel:S==null?void 0:S.reasoningLevel,attachments:S==null?void 0:S.attachments,attachmentMeta:S==null?void 0:S.attachmentMeta})}finally{f(!1)}}})]})}),!be&&Ge?r.jsx(Ir,{activePanel:ke.activePanel,open:ke.isOpen,sessionId:t,workspaceId:Ge,navigationGroups:i,onClose:()=>{ke.closePanel()},onSelectPanel:h=>{ke.selectPanel(h)},onSelectPanelBySwipe:h=>{if(h===null){ke.closePanel();return}ke.selectPanel(h)}}):null]}),r.jsx(ua,{open:ue,navigationGroups:i,workspaceId:He,sessionId:t,onClose:()=>de(!1),onOpenSession:h=>{de(!1),l(h.workspaceId),xt("preview"),M(Oe(h.workspaceId,h.sessionId))}}),r.jsx(ja,{open:X,busy:Q,onClose:()=>{Q||k(!1)},onConfirm:async()=>{if(!Q){Y(!0);try{if(await g(t),k(!1),D({title:o("shell.archiveAdded"),tone:"success"}),re){if(l(re),xt("preview"),st){M(Oe(st.workspace.id,st.session.sessionId));return}M(St(re));return}M("/workspaces")}catch(h){D({title:h instanceof Error?h.message:o("shell.navigationLoadFailed"),tone:"error"})}finally{Y(!1)}}}}),r.jsx(kr,{open:z,workspaceName:(Ee==null?void 0:Ee.workspace.name)??null,sessions:Gt,restoringSessionId:N,onClose:()=>{N||R(!1)},onRestore:async h=>{B(h);try{await v(h),D({title:o("shell.archiveRestored"),tone:"success"})}catch(S){D({title:S instanceof Error?S.message:o("shell.navigationLoadFailed"),tone:"error"})}finally{B(null)}}}),C?r.jsx(us,{open:T,source:oe?{kind:"session",sessionId:t,workspaceId:oe.workspaceId,workspaceName:(Pe==null?void 0:Pe.displayName)??oe.workspaceId,sessionTitle:oe.title,defaultProvider:oe.provider}:null,onClose:()=>E(!1),onCreated:async h=>{h.members.forEach(J=>{A(J.session)}),Gs(h.group.id),await c();const S=h.members.find(J=>J.session.sessionId===h.group.anchorSessionId)??h.members[0]??null;if(S){const J=Ht(S.session,S.sessionIsolatedWorkspace);l(J),M(Oe(J,S.session.sessionId))}E(!1),D({title:o("shell.parallelCreateSucceeded"),tone:"success"})}}):null]})}function Sa(t,e,s){return t!=="opencode"?!1:e==="OPENCODE_REQUEST_TIMEOUT"||e==="PROVIDER_RUNTIME_TIMEOUT"||/\bSERVER_TIMEOUT\b/i.test(s)||/timeout/i.test(s)||/超时/.test(s)}function xa(){typeof window>"u"||window.dispatchEvent(new CustomEvent(ba))}function Ia({draft:t,navigate:e,initialToolPanel:s}){const{shellMode:n,navigationGroups:i,requestNavigationRefresh:c,selectWorkspace:l,setSessionWorkspace:u,upsertNavigationSession:d,favoriteSessions:w,unarchiveSession:g,startDraftSession:v}=lt(),[F,A]=a.useState(!1),[M,x]=a.useState([]),V=a.useMemo(()=>bt(t.provider),[t.provider]),[_,f]=a.useState(V),b=n!=="mobile",{showToast:$}=Ze(),X=a.useMemo(()=>ya(t),[t]),k=Mr(!b),z=xr({enabled:!b,initialPanel:s,sessionId:t.sessionId,workspaceId:t.workspaceId,suspendMainGesture:!b&&k.isVisible}),R=a.useMemo(()=>new Set(w.map(H=>H.session.sessionId)),[w]),N=a.useMemo(()=>i.map(H=>H.workspace),[i]),B=a.useMemo(()=>Yn(i),[i]),Q=a.useMemo(()=>ys(i),[i]),Y=a.useMemo(()=>N.find(H=>H.id===t.workspaceId)??null,[t.workspaceId,N]),ue=Q[t.workspaceId]??(Y?Ps(Y):null),de=a.useMemo(()=>ct(X.title??null,o("conversation.titleFallback")),[X]),ne=a.useMemo(()=>fr(i,t.workspaceId,R),[t.workspaceId,R,i]),me=a.useMemo(()=>gr(w,i),[w,i]),[T,E]=a.useState([]),y=a.useMemo(()=>[...me,...ne],[me,ne]),L=a.useMemo(()=>Vt(i,t.workspaceId),[t.workspaceId,i]),D=a.useMemo(()=>(L==null?void 0:L.sessions.filter(H=>H.isArchived===!0&&!Ut(H)))??[],[L]),j=B.find(H=>H.workspace.id===t.workspaceId)??(L?{workspace:L.workspace,label:L.workspace.name,subtitle:L.workspace.path}:null),O=b?null:Sr(k.mainGestureHandlers,z.mainGestureHandlers),[W,se]=a.useState(!1),[q,ae]=a.useState(null),P=a.useRef(null),K=a.useRef(null),le=a.useRef(null),[I,Se]=a.useState(null),{composerPortalTarget:te}=Fn();a.useEffect(()=>{const H=Bn(y,t.sessionId,G=>G.session.sessionId);H.length!==0&&E(G=>{const pe=new Set(G);let Ce=!1;for(const Re of H)pe.has(Re)||(pe.add(Re),Ce=!0);return Ce?Array.from(pe):G})},[t.sessionId,y]),a.useEffect(()=>(u(t.sessionId,t.workspaceId),()=>{u(t.sessionId,null)}),[t.sessionId,t.workspaceId,u]),a.useEffect(()=>{let H=!1;return f(V),Tn(t.provider,t.workspaceId).then(G=>{H||f(G)}).catch(()=>{}),()=>{H=!0}},[t.provider,t.workspaceId,V]),br(K,I,!b,t.sessionId),wr(K,le,!b,t.sessionId);function Z(H){l(H),e(St(H))}return r.jsx(r.Fragment,{children:r.jsxs("main",{ref:K,className:"workbench-page conversation-page-shell mobile-page-fixed-root mobile-conversation-page","data-mobile-shell":!b,"data-preview-mode":b?void 0:k.displayMode,"data-preview-dragging":b?void 0:k.isDragging,"data-workspace-tone":(ue==null?void 0:ue.tone)??"root","data-worktree-depth":(ue==null?void 0:ue.depth)??0,"data-tool-panel-open":b?void 0:z.isOpen,style:{...b?{}:k.pageStyle,...it(ue)??{}},children:[b?r.jsx(mr,{session:X,workspaceContext:ue}):null,b?null:r.jsx(zn,{containerRef:le,className:"mobile-conversation-page-header",gestureHandlers:O??void 0,currentWorkspace:j?{id:j.workspace.id,name:j.label,path:j.subtitle}:N[0]??null,workspaces:N,workspaceOptions:B,onSelectWorkspace:Z,heading:de.fullTitle,trailing:r.jsx("span",{className:"mobile-conversation-toolbar-title",title:de.fullTitle,children:de.displayTitle})}),b?null:r.jsx(yr,{visible:!z.isOpen&&k.isVisible,widthPx:k.previewWidthPx,isDragging:k.isDragging,gestureHandlers:k.railGestureHandlers,activeSessionId:t.sessionId,createSessionActionLabel:o("shell.createSession"),favoriteItems:me,items:ne,expandedRootIds:T,workspaceSectionLabel:(j==null?void 0:j.label)??o("shell.mobileConversationCurrentWorkspaceSection"),onCreateSession:()=>{v(t.workspaceId,t.provider)},archiveFolderActionLabel:D.length>0?o("shell.archiveFolderLabel"):void 0,onOpenArchiveFolder:D.length>0?()=>{se(!0)}:void 0,onToggleSubsessions:H=>{E(G=>G.includes(H)?G.filter(pe=>pe!==H):[...G,H])},onActivate:H=>{k.closePreview(),l(H.workspace.id),e(Oe(H.workspace.id,H.session.sessionId))}}),r.jsx("div",{className:"mobile-conversation-stage",...O??{},children:r.jsxs("div",{ref:P,className:"mobile-conversation-main",children:[r.jsx(Ts,{connectionState:"closed",onReconnect:()=>{}}),r.jsx("div",{className:"conversation-timeline-shell",children:r.jsx(ks,{sessionId:t.sessionId,messages:M,historyState:"ready",loadingOlderMessages:!1,hasOlderMessages:!1,provider:t.provider,runtimeThinkingPlaceholder:null,onLoadOlderMessages:()=>{},onRetryMessage:()=>{}})}),z.isOpen?null:r.jsx(Rs,{capabilities:_,draftStorageId:t.sessionId,panelRef:b?void 0:Se,portalContainer:b?null:te,contextUsage:null,taskProvider:t.provider,taskMessages:M,isSubmitting:F,isRunning:!1,onSend:async(H,G)=>{var Re,p,U,ie;const pe=qa();x(ee=>[...ee,qn(t.sessionId,H,pe,(G==null?void 0:G.attachmentMeta)??[],(G==null?void 0:G.attachments)??[])]),A(!0);const Ce=performance.now();he("session_send.start_live.client_start",{draftSessionId:t.sessionId,workspaceId:t.workspaceId,provider:t.provider,clientRequestId:pe,contentLength:H.length});try{const ee=await Cn({workspaceId:t.workspaceId,provider:t.provider,content:H,clientRequestId:pe,model:(G==null?void 0:G.model)??null,reasoningLevel:(G==null?void 0:G.reasoningLevel)??null,permissionMode:$e(),attachments:(G==null?void 0:G.attachments)??[]});he("session_send.start_live.client_response",{draftSessionId:t.sessionId,sessionId:ee.sessionId,workspaceId:((Re=ee.session)==null?void 0:Re.workspaceId)??t.workspaceId,provider:ee.provider,clientRequestId:pe,durationMs:Math.round(performance.now()-Ce),returnedMessageId:((p=ee.message)==null?void 0:p.messageId)??null}),ee.session&&d(ee.session);const ge=((ie=(U=ee.session)==null?void 0:U.workspaceId)==null?void 0:ie.trim())||t.workspaceId;u(ee.sessionId,ge),xt("preview"),e(Oe(ge,ee.sessionId),{replace:!0,state:ee.message?{bootstrap:{sessionId:ee.sessionId,messages:[ee.message]}}:null}),c()}catch(ee){throw he("session_send.start_live.client_error",{draftSessionId:t.sessionId,workspaceId:t.workspaceId,provider:t.provider,clientRequestId:pe,durationMs:Math.round(performance.now()-Ce),error:ee instanceof Error?ee.message:String(ee)}),x(ge=>hs(ge,pe)),ee}finally{A(!1)}}})]})}),b?null:r.jsx(Ir,{activePanel:z.activePanel,open:z.isOpen,sessionId:t.sessionId,workspaceId:t.workspaceId,navigationGroups:i,onClose:()=>{z.closePanel()},onSelectPanel:H=>{z.selectPanel(H)},onSelectPanelBySwipe:H=>{if(H===null){z.closePanel();return}z.selectPanel(H)}}),r.jsx(kr,{open:W,workspaceName:(L==null?void 0:L.workspace.name)??null,sessions:D,restoringSessionId:q,onClose:()=>{q||se(!1)},onRestore:async H=>{ae(H);try{await g(H),$({title:o("shell.archiveRestored"),tone:"success"})}catch(G){$({title:G instanceof Error?G.message:o("shell.navigationLoadFailed"),tone:"error"})}finally{ae(null)}}})]})})}function Ma(t,e,s,n=null){var l,u;if(!Fa(t))return null;const i=e??((l=s.get("workspaceId"))==null?void 0:l.trim())??null,c=((u=s.get("provider"))==null?void 0:u.trim())??n??null;return!i||!jn(c)?null:{sessionId:t,workspaceId:i,provider:c}}function ya(t){const e=new Date().toISOString();return{sessionId:t.sessionId,workspaceId:t.workspaceId,provider:t.provider,providerSessionId:`draft://${t.sessionId}`,rawStoreRef:`draft://${t.sessionId}`,parentSessionId:null,isSubagent:!1,subagentLabel:null,isArchived:!1,title:ri(t.provider),messageCount:0,lastMessageAt:null,createdAt:e,updatedAt:e,syncStatus:"idle",syncCursor:null,lastSyncAt:null,lastErrorCode:null,lastErrorDetail:null,resumedAt:null,runningState:"idle",activitySource:"none",lastEventAt:null,completedAt:null,lastSeenAt:null,activityState:"idle"}}function pr(t){const e=new Map(t.map(i=>[i.sessionId,i])),s=new Map,n=i=>{const c=s.get(i.sessionId);if(typeof c=="boolean")return c;if(i.isArchived)return s.set(i.sessionId,!1),!1;const l=Ai(i,{mode:"mobile"});if(!l)return s.set(i.sessionId,!0),!0;const u=e.get(l);if(!u)return s.set(i.sessionId,!0),!0;const d=n(u);return s.set(i.sessionId,d),d};return t.filter(i=>n(i))}function fr(t,e,s){if(!e)return[];const n=Vt(t,e);if(!n)return[];const i=pr(n.sessions).map(l=>({session:l,workspace:n.workspace}));return Wn(i,{mode:"mobile"}).filter(l=>!s.has(l.item.session.sessionId)&&!ji(l.children,u=>s.has(u.session.sessionId)))}function gr(t,e){return t.filter(s=>!Ut(s.session)).flatMap(s=>{const n=Vt(e,s.workspace.id);if(!n)return[];const i=Wn(pr(n.sessions).map(l=>({session:l,workspace:n.workspace})),{mode:"mobile"}),c=vr(i,s.session.sessionId);return c?[c]:[]})}function vr(t,e){for(const s of t){if(s.item.session.sessionId===e)return s;const n=vr(s.children,e);if(n)return n}return null}function br(t,e,s,n){a.useEffect(()=>{const i=t.current;if(!s||!i){i&&i.style.removeProperty("--mobile-conversation-composer-height");return}if(!e){i.style.removeProperty("--mobile-conversation-composer-height");return}const c=i,l=e;function u(){!t.current||!l.isConnected||c.style.setProperty("--mobile-conversation-composer-height",`${l.offsetHeight}px`)}u();const d=typeof ResizeObserver<"u"?new ResizeObserver(u):null;return d==null||d.observe(l),window.addEventListener("resize",u),()=>{d==null||d.disconnect(),window.removeEventListener("resize",u),i.style.removeProperty("--mobile-conversation-composer-height")}},[e,s,n,t])}function wr(t,e,s,n){a.useEffect(()=>{const i=t.current,c=e.current;if(!s||!i){i&&i.style.removeProperty("--mobile-conversation-page-header-height");return}if(!c){i.style.removeProperty("--mobile-conversation-page-header-height");return}const l=i,u=c;function d(){!t.current||!u.isConnected||l.style.setProperty("--mobile-conversation-page-header-height",`${u.offsetHeight}px`)}d();const w=typeof ResizeObserver<"u"?new ResizeObserver(d):null;return w==null||w.observe(u),window.addEventListener("resize",d),()=>{w==null||w.disconnect(),window.removeEventListener("resize",d),i.style.removeProperty("--mobile-conversation-page-header-height")}},[s,e,n,t])}function Pa(t){return t==="files"||t==="git"||t==="processes"?t:null}function Sr(...t){const e=t.filter(Boolean);return{onTouchStart(s){e.forEach(n=>n.onTouchStart(s))},onTouchMove(s){e.forEach(n=>n.onTouchMove(s))},onTouchEnd(s){e.forEach(n=>n.onTouchEnd(s))},onTouchCancel(s){e.forEach(n=>n.onTouchCancel(s))}}}function xr(t){const e=Is(),s=Je(),n=xs(),i=a.useRef(null),[c,l]=a.useState(()=>t.initialPanel??zs()),u=t.initialPanel??c,d=t.enabled&&t.workspaceId!==null&&t.initialPanel!==null;a.useEffect(()=>{if(!t.enabled){i.current=null;return}const f=t.initialPanel??zs();l(f),Qs(f)},[t.enabled,t.initialPanel]);function w(f,b){const $=new URLSearchParams(e.search);f?($.set("toolPanel",f),l(f),Qs(f)):$.delete("toolPanel");const X=$.toString();s({pathname:e.pathname,search:X?`?${X}`:""},{replace:(b==null?void 0:b.replace)??!1})}function g(f){n.trigger("selection"),w(f,{replace:d})}function v(){d&&(n.trigger("gesture"),w(null,{replace:!0}))}function F(f){if(!t.enabled||!t.workspaceId)return;const b=f??u;n.trigger("gesture"),w(b)}function A(f){if(!t.enabled||f.changedTouches.length!==1){i.current=null;return}if(ka(f.target)){i.current=null;return}const b=f.changedTouches[0];i.current={x:b.clientX,y:b.clientY}}function M(f){const b=i.current;if(i.current=null,!b||f.changedTouches.length!==1||d||t.suspendMainGesture)return;const $=f.changedTouches[0],X=$.clientX-b.x,k=$.clientY-b.y;X>-56||Math.abs(X)<=Math.abs(k)*1.15||F()}function x(f){const b=i.current;if(i.current=null,!b||f.changedTouches.length!==1||!d)return;const $=f.changedTouches[0],X=$.clientX-b.x,k=$.clientY-b.y;X<56||Math.abs(X)<=Math.abs(k)*1.15||v()}return{activePanel:u,closePanel:v,isOpen:d,mainGestureHandlers:{onTouchStart:A,onTouchMove:()=>{},onTouchEnd:M,onTouchCancel:()=>{i.current=null}},openPanel:F,panelGestureHandlers:{onTouchStart:A,onTouchMove:()=>{},onTouchEnd:x,onTouchCancel:()=>{i.current=null}},selectPanel:g}}function Ir(t){const e=a.useRef(null);if(!t.open)return null;function s(i){if(i.changedTouches.length!==1){e.current=null;return}if(Ra(i.target)){e.current=null;return}const c=i.changedTouches[0];e.current={x:c.clientX,y:c.clientY}}function n(i){const c=e.current;if(e.current=null,!c||i.changedTouches.length!==1)return;const l=i.changedTouches[0],u=l.clientX-c.x,d=l.clientY-c.y;if(Math.abs(u)<56||Math.abs(u)<=Math.abs(d)*1.15)return;const w=["files","git","processes"],g=w.indexOf(t.activePanel);if(u<0){t.onSelectPanelBySwipe(w[Math.min(w.length-1,g+1)]??t.activePanel);return}if(g===0){t.onSelectPanelBySwipe(null);return}t.onSelectPanelBySwipe(w[Math.max(0,g-1)]??t.activePanel)}return r.jsxs("section",{className:"mobile-conversation-tool-panel","data-panel":t.activePanel,onTouchStart:s,onTouchEnd:n,onTouchCancel:()=>{e.current=null},children:[r.jsxs("header",{className:"mobile-conversation-tool-panel-header","data-preview-gesture":"ignore",children:[r.jsx("button",{type:"button",className:"mobile-conversation-tool-panel-back","aria-label":o("shell.mobileConversationToolCloseAction"),title:o("shell.mobileConversationToolCloseAction"),onClick:t.onClose,children:r.jsx("span",{"aria-hidden":"true",children:"‹"})}),r.jsx("div",{className:"mobile-conversation-tool-panel-tabs",role:"tablist","aria-label":o("shell.mobileConversationToolTabsLabel"),children:["files","git","processes"].map(i=>r.jsx("button",{type:"button",role:"tab","aria-selected":t.activePanel===i,className:"mobile-conversation-tool-panel-tab",onClick:()=>{t.onSelectPanel(i)},children:i==="files"?o("shell.filesEntry"):i==="git"?o("shell.gitEntry"):o("shell.mobileConversationToolProcessesTab")},i))})]}),r.jsx("div",{className:"mobile-conversation-tool-panel-body",children:t.activePanel==="files"?r.jsx(Xn,{className:"mobile-conversation-tool-surface",hideHeading:!0,sessionId:t.sessionId,workspaceId:t.workspaceId}):t.activePanel==="git"?r.jsx(Gn,{className:"mobile-conversation-tool-surface",panelActive:!0,workspaceId:t.workspaceId}):r.jsx($n,{className:"mobile-conversation-tool-surface mobile-tool-native-panel mobile-tool-process-panel",currentWorkspaceId:t.workspaceId,navigationGroups:t.navigationGroups})})]})}function ka(t){return t instanceof Element?!!t.closest("input, textarea, select, option, label, button, a, [contenteditable='true'], [data-preview-gesture='ignore']"):!1}function Ra(t){return t instanceof Element?!!t.closest("input, textarea, select, option, [contenteditable='true']"):!1}function Mr(t){const e=xs(),[s,n]=a.useState(()=>t?Qt():"immersive"),[i,c]=a.useState(()=>kn()),[l,u]=a.useState(()=>t&&Qt()==="preview"?"default":"closed"),d=a.useRef(l),w=a.useRef(null);a.useEffect(()=>{d.current=l},[l]),a.useEffect(()=>{if(!t){w.current=null,d.current="closed",u("closed"),n("immersive");return}const R=Qt();n(R),u(R==="preview"?"default":"closed")},[t]),a.useEffect(()=>{t&&xt(s)},[t,s]),a.useEffect(()=>{if(typeof window>"u")return;function R(){c(kn())}return R(),window.addEventListener("resize",R),()=>{window.removeEventListener("resize",R)}},[]);function g(R){d.current=R,u(R)}function v(R="default"){g(R),n("preview")}function F(){g("closed"),n("immersive")}function A(){g("expanded"),n("preview")}function M(){if(d.current!=="closed"){e.trigger("gesture"),F();return}e.trigger("gesture"),v()}function x(R,N){const B=N.touches[0]??N.changedTouches[0];if(!t||!B){w.current=null;return}if(Ca(N.target)){w.current=null;return}if(R==="main"){if(d.current==="closed"&&B.clientX>ga){w.current=null;return}}else if(d.current==="closed"){w.current=null;return}w.current={source:R,intent:R==="rail"?"rail":d.current==="closed"?"open":"close",startX:B.clientX,startY:B.clientY,lastX:B.clientX,lastY:B.clientY,horizontalLocked:!1}}function V(R){const N=w.current,B=R.touches[0];if(!t||!N||!B)return;const Q=B.clientX-N.startX,Y=B.clientY-N.startY;if(N.lastX=B.clientX,N.lastY=B.clientY,!N.horizontalLocked){if(Math.abs(Q)<Pn&&Math.abs(Y)<Pn)return;if(Math.abs(Q)<=Math.abs(Y)){w.current=null;return}if(N.intent==="open"&&Q<=0){w.current=null;return}if(N.intent==="close"&&Q>=0){w.current=null;return}N.horizontalLocked=!0}}function _(R){var Y;const N=w.current;if(w.current=null,!(N!=null&&N.horizontalLocked))return;const B=(Y=R==null?void 0:R.changedTouches)==null?void 0:Y[0];B&&(N.lastX=B.clientX,N.lastY=B.clientY);const Q=N.lastX-N.startX;if(N.intent==="open"){Q>=pa&&(e.trigger("gesture"),v("default"));return}if(N.intent==="close"){Q<=-34&&(e.trigger("gesture"),F());return}if(Q<=-34){e.trigger("gesture"),F();return}Q>=fa&&d.current==="default"&&(e.trigger("gesture"),A())}const f=l==="expanded"?ls:l==="default"?yn:0,b=Math.round(i*f*100)/100,$=f===0?0:f/ls,X={"--mobile-conversation-preview-default-width":`${Math.round(i*yn*100)/100}px`,"--mobile-conversation-preview-max-width":`${Math.round(i*ls*100)/100}px`,"--mobile-conversation-preview-width":`${b}px`,"--mobile-conversation-preview-progress":$.toFixed(4)};return{closePreview:F,displayMode:l==="closed"?"immersive":"preview",isDragging:!1,isVisible:l!=="closed",mainGestureHandlers:{onTouchStart:R=>x("main",R),onTouchMove:V,onTouchEnd:_,onTouchCancel:_},pageStyle:X,previewWidthPx:b,railGestureHandlers:{onTouchStart:R=>x("rail",R),onTouchMove:V,onTouchEnd:_,onTouchCancel:_},togglePreview:M}}function yr({visible:t,widthPx:e,isDragging:s,gestureHandlers:n,activeSessionId:i,createSessionActionLabel:c,favoriteItems:l,items:u,expandedRootIds:d,workspaceSectionLabel:w,onCreateSession:g,archiveCurrentActionLabel:v,archiveFolderActionLabel:F,onArchiveActiveSession:A,onOpenArchiveFolder:M,onToggleSubsessions:x,onActivate:V}){if(!t)return null;function _(f,b){const{workspaceName:$,ancestorExpanded:X=!1,ancestorHasNextSiblings:k=[],hasNextSibling:z=!1,isFirstSibling:R=!1}=b??{},N=f.item.session.sessionId,B=f.children,Q=f.depth===0&&B.length>0,Y=X||Q&&d.includes(N),ue=f.depth>0?[...k,z]:[...k];return r.jsxs("div",{className:"mobile-conversation-preview-tree-node",children:[r.jsxs("div",{className:"mobile-conversation-preview-tree-row",style:{"--mobile-preview-tree-depth":f.depth},children:[f.depth>0?r.jsxs("div",{className:"mobile-conversation-preview-guides","aria-hidden":"true",children:[k.map((de,ne)=>de?r.jsx("span",{className:"mobile-conversation-preview-guide-column",style:{"--mobile-preview-tree-level":ne+1}},`${N}:ancestor:${ne}`):null),r.jsx("span",{className:"mobile-conversation-preview-guide-branch","data-continue":z,"data-first":R,style:{"--mobile-preview-tree-level":f.depth},children:r.jsx("span",{className:"mobile-conversation-preview-guide-branch-horizontal"})})]}):null,r.jsx(Ta,{entry:f.item,activeSessionId:i,hasSubsessions:Q,subsessionsExpanded:Y,workspaceName:$,onToggleSubsessions:Q?()=>{x(N)}:void 0,onActivate:V})]}),B.length>0&&Y?r.jsx("div",{className:"mobile-conversation-preview-children",children:B.map((de,ne)=>_(de,{workspaceName:$,ancestorExpanded:!0,ancestorHasNextSiblings:ue,hasNextSibling:ne<B.length-1,isFirstSibling:ne===0}))}):null]},`${f.item.workspace.id}:${N}`)}return r.jsxs("aside",{className:"mobile-conversation-preview-rail terminal-mobile-list-rail surface-card","data-dragging":s,style:{width:`${e}px`,maxWidth:`${e}px`},...n,children:[c&&g?r.jsx("div",{className:"mobile-conversation-preview-topbar terminal-mobile-list-footer",children:r.jsxs("button",{type:"button",className:"mobile-conversation-preview-create-button workbench-import-toggle terminal-mobile-list-create",onClick:g,children:[r.jsx("span",{className:"workbench-import-toggle-symbol","aria-hidden":"true",children:"+"}),r.jsx("span",{className:"workbench-import-toggle-label",children:c})]})}):null,r.jsxs("div",{className:"mobile-conversation-preview-body terminal-mobile-list-body",children:[l.length>0?r.jsxs("section",{className:"mobile-conversation-preview-group mobile-conversation-preview-list-favorites terminal-mobile-list-group terminal-mobile-list-group-pinned",children:[r.jsxs("div",{className:"mobile-conversation-preview-group-heading terminal-mobile-list-group-heading",children:[r.jsx("span",{children:o("shell.favoriteSectionTitle")}),r.jsx("span",{className:"workbench-section-counter",children:l.length})]}),r.jsx("div",{className:"mobile-conversation-preview-list mobile-conversation-preview-list-static terminal-mobile-session-list",children:l.map(f=>r.jsx("div",{children:_(f,{workspaceName:f.item.workspace.name})},`favorite:${f.item.workspace.id}:${f.item.session.sessionId}`))})]}):null,r.jsxs("section",{className:"mobile-conversation-preview-group mobile-conversation-preview-group-workspace terminal-mobile-list-group terminal-mobile-list-group-workspace",children:[r.jsxs("div",{className:"mobile-conversation-preview-group-heading terminal-mobile-list-group-heading",children:[r.jsx("span",{children:w}),r.jsx("span",{className:"workbench-section-counter",children:u.length})]}),u.length===0?r.jsx("div",{className:"workbench-session-empty",children:o("shell.emptyWorkspaceSessions")}):r.jsx("div",{className:"mobile-conversation-preview-list terminal-mobile-session-list","data-preview-gesture":"ignore",children:u.map(f=>_(f))})]})]}),v&&A||F&&M?r.jsxs("div",{className:"mobile-conversation-preview-actions terminal-mobile-list-footer",children:[v&&A?r.jsx("button",{type:"button",className:"mobile-conversation-preview-archive-button workbench-import-toggle",onClick:()=>{A()},children:v}):null,F&&M?r.jsx("button",{type:"button",className:"mobile-conversation-preview-archive-button workbench-import-toggle",onClick:M,children:F}):null]}):null]})}function Ta({entry:t,activeSessionId:e,hasSubsessions:s=!1,subsessionsExpanded:n=!1,onActivate:i,onToggleSubsessions:c,workspaceName:l}){const u=t.session.sessionId===e;return r.jsxs("article",{className:"mobile-conversation-preview-entry terminal-mobile-session-card","data-active":u,children:[s?r.jsx("button",{type:"button",className:"mobile-conversation-preview-toggle","aria-label":n?o("shell.subagentCollapse"):o("shell.subagentExpand"),title:n?o("shell.subagentCollapse"):o("shell.subagentExpand"),"aria-expanded":n,onClick:d=>{d.stopPropagation(),c==null||c()},children:r.jsx("span",{className:Rn(t.session,{isActive:u,hasSubsessions:s}),"aria-hidden":"true"})}):r.jsx("span",{className:Rn(t.session,{isActive:u,hasSubsessions:s}),"aria-hidden":"true"}),r.jsx("button",{type:"button",className:"mobile-conversation-preview-item terminal-mobile-session-primary","data-active":u,onClick:()=>i(t),children:r.jsxs("div",{className:"mobile-conversation-preview-item-body",children:[r.jsx("span",{className:"mobile-conversation-preview-item-title",children:t.session.title||o("common.unknown")}),r.jsx("span",{className:"mobile-conversation-preview-item-meta",children:Pr(t.session,l)})]})})]})}function kn(){return typeof window>"u"?390:Math.max(window.innerWidth||390,320)}function Ca(t){return t instanceof Element?!!t.closest("input, textarea, select, option, label, [contenteditable='true'], [data-preview-gesture='ignore']"):!1}function Rn(t,e){const s=Ni("mobile-conversation-preview-indicator",t,{hasSubagents:e.hasSubsessions});return s.endsWith(" is-idle")&&e.isActive?"mobile-conversation-preview-indicator is-active":s}function Pr(t,e){const s=Hn(t);return[e??null,Mt(t.provider),Ea(t.lastMessageAt??t.updatedAt),s].filter(Boolean).join(" · ")}function Ea(t){return t?new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):o("common.unknown")}function ja({open:t,busy:e,onClose:s,onConfirm:n}){return r.jsx(bs,{open:t,title:o("shell.archiveConfirmTitle"),description:o("shell.archiveConfirmDescription"),size:"narrow",layout:"confirm",dismissible:!e,showCloseButton:!1,footer:r.jsxs(Ss,{children:[r.jsx("button",{type:"button",className:"secondary-button",disabled:e,onClick:s,children:o("common.cancel")}),r.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:e,onClick:()=>{n()},children:o("shell.archiveAction")})]}),onClose:s,children:r.jsx(r.Fragment,{})})}function kr({open:t,workspaceName:e,sessions:s,restoringSessionId:n,onClose:i,onRestore:c}){return r.jsx(bs,{open:t,title:o("shell.archiveModalTitle"),description:e?`${e} · ${o("shell.archiveModalDescription")}`:o("shell.archiveModalDescription"),size:"regular",layout:"list",dismissible:!n,showCloseButton:!1,onClose:i,children:s.length>0?r.jsx(ii,{className:"workbench-archive-list",children:s.map(l=>{const u=ct(l.title,o("common.unknown"));return r.jsx(oi,{className:"workbench-archive-item",trailing:r.jsx("button",{type:"button",className:"secondary-button",disabled:n===l.sessionId,onClick:()=>{c(l.sessionId)},children:o("shell.unarchiveAction")}),children:r.jsxs("div",{className:"workbench-archive-item-main",children:[r.jsx("strong",{title:u.fullTitle,children:u.displayTitle}),r.jsx("p",{children:Pr(l)})]})},l.sessionId)})}):r.jsx(ai,{title:o("shell.archiveEmpty"),compact:!0,className:"workbench-section-empty"})})}function Aa(t){return r.jsx("button",{type:"button",className:"conversation-header-ai-button","aria-label":o("conversation.branchTreeAction"),title:o("conversation.branchTreeAction"),onClick:t.onOpenBranchTree,children:r.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:r.jsx(Fi,{})})})}function Na(){return r.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[r.jsx("path",{d:"M4 3.25a1.75 1.75 0 1 1 0 3.5a1.75 1.75 0 0 1 0-3.5Zm0 6a1.75 1.75 0 1 1 0 3.5a1.75 1.75 0 0 1 0-3.5Zm8-3a1.75 1.75 0 1 1 0 3.5a1.75 1.75 0 0 1 0-3.5Z",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),r.jsx("path",{d:"M5.75 5h2.15c1.35 0 2.45 1.1 2.45 2.45v.1M5.75 11h2.15c1.35 0 2.45-1.1 2.45-2.45V8.4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.4"})]})}function La(t){const e=_a(t),[s,n]=a.useState(e==="show"),i=a.useRef(null);return a.useEffect(()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null),n(e==="show")},[t.sessionId]),a.useEffect(()=>{if(e==="show"){i.current!==null&&(window.clearTimeout(i.current),i.current=null),n(!0);return}if(e==="hide_immediately"){i.current!==null&&(window.clearTimeout(i.current),i.current=null),n(!1);return}!s||i.current!==null||(i.current=window.setTimeout(()=>{i.current=null,n(!1)},va))},[e,s]),a.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]),s}function _a(t){const{provider:e,runningState:s,activityState:n,runtimeHasActiveRun:i,messages:c}=t;if(e!=="codex")return"hide_immediately";const l=Ha(c);return l<0||Da(c,l)?"hide_immediately":Oa(s,n,i)?"show":"hide_deferred"}function Oa(t,e,s){return s===!0||e==="running"||t==="starting"||t==="running"||t==="reconnecting"}function Da(t,e){return t.slice(e+1).some(s=>s.role==="assistant"&&(s.kind==="text"||s.kind==="thinking"))}function Ha(t){let e=-1;for(let s=t.length-1;s>=0;s-=1){const n=t[s];if(n.role==="user"&&n.kind==="text"){e=s;break}}return e}function Fa(t){return t.startsWith("draft-")}function Ba(t,e){if(!e||typeof e!="object")return[];const s=e.bootstrap;if(!s||typeof s!="object")return[];const n=s.sessionId,i=s.messages;return n!==t||!Array.isArray(i)?[]:i.filter(Wa)}function Wa(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.messageId=="string"&&typeof e.provider=="string"&&typeof e.providerSessionId=="string"&&typeof e.role=="string"&&typeof e.content=="string"&&typeof e.timestamp=="string"&&typeof e.sequence=="number"&&typeof e.rawRef=="string"}function qa(){const t=globalThis.crypto;return t&&typeof t.randomUUID=="function"?t.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`}function Ua(t,e){var i;if(!t||t.forkSourceType!=="message"||typeof t.inheritedPrefixMessageCount!="number"||t.inheritedPrefixMessageCount<0)return e;const s=((i=t.createdAt)==null?void 0:i.trim())||"";if(s.length===0)return e;const n=Math.max(0,t.inheritedPrefixMessageCount);return e.filter(c=>c.sequence<=n?!0:c.timestamp>=s)}export{dl as ConversationPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{b as a,m as R,_ as N,j as s,t as l}from"./index-BZLcEHW3.js";import{u as D,g as L}from"./MobileSheet-Ckug8hTb.js";import{FileContextPanel as E}from"./FileContextPanel-C3qex8bb.js";import{GitSidebar as j}from"./GitSidebar-BK6H16XU.js";import{TerminalManagerPanel as q}from"./TerminalManagerPanel-CCLr1Ypk.js";import{TerminalPage as y}from"./TerminalPage-DaooFaJ4.js";import{W as O,m as v}from"./WorkbenchLayout-DGm8Tc5M.js";import{c as F,u as C,e as P,N as _}from"./App-BZvapsi8.js";import"./WorkbenchModal-0tPIIhca.js";import"./file-tree-icon-Db5LXC8h.js";import"./default-session-permission-mode-DT4SGiwp.js";import"./terminal-runtime-meta-cdtWVfCm.js";import"./TerminalRuntimeFallbackModal-aUzjEBwP.js";import"./MobileWorkspaceSwitcherHeader-RqWrBdn2.js";import"./MobileTopHeaderFrame-Bwv8Ovm_.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-C5_Iay0I.js";function $(n){return{navigationGroups:n,subscribeFileTree:()=>{},requestFileTreeRefresh:()=>{},addFileTreeSnapshotListener:()=>()=>{},subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function U(){return{subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function z(){return{subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function A(n,p){return{navigationGroups:p,currentWorkspaceId:n,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function T(n){return n.kind==="files"?l("shell.filesEntry"):n.kind==="git"?l("shell.gitEntry"):n.kind==="processes"?l("shell.terminalManagerEntry"):n.kind==="terminals"?l("shell.terminalsEntry"):n.kind}function K(n,p){var e;const i=n.workspaceName??(n.workspaceId?((e=p.find(h=>h.workspace.id===n.workspaceId))==null?void 0:e.workspace.name)??null:null),u=T(n);return i?`CodingNS - ${u}(${i})`:`CodingNS - ${u}`}function ue(){const{windowId:n}=F(),p=C(),i=P(),u=D(t=>t.sessionDisplaySortMode),[e,h]=a.useState(null),[W,f]=a.useState(!0),[S,b]=a.useState(null),[o,w]=a.useState([]),[r,g]=a.useState(null);a.useEffect(()=>{let t=!1;async function d(){if(!n){h(null),f(!1),b(l("desktopWindow.invalidWindowId"));return}f(!0),b(null);const c=await i.bridge.getWindowDescriptor(n),k=c.ok?c.value??null:i.windows.getDescriptor(n);if(!t){if(!k){h(null),f(!1),b(c.detail??l("desktopWindow.loadDescriptorFailed"));return}i.windows.registerDescriptor(k),i.windows.markWindowOpen(k.windowId),h(k),f(!1)}}return d(),()=>{t=!0}},[i,n]),a.useEffect(()=>{if(!(e!=null&&e.workspaceId)){w([]);return}let t=!1;async function d(){try{const c=await L();if(t)return;w(v(c,u))}catch{if(t)return;w([])}}return d(),()=>{t=!0}},[e==null?void 0:e.workspaceId,u]),a.useEffect(()=>{if(!e){g(null);return}const t=new O({onConnectionChange:()=>{},onSnapshot:d=>{w(v(d,u))},onUnauthorized:()=>{R.clear(),p(`/login?returnTo=${encodeURIComponent(`/desktop-window/${e.windowId}`)}`,{replace:!0})}});return g(t),t.start(),()=>{t.close(),g(null)}},[e,p,u]),a.useEffect(()=>{if(!i.isDesktop||!i.bridge.supported||!e||e.mode!=="external")return;const t=K(e,o);document.title=t,N(async()=>{const{getCurrentWindow:d}=await import("./window-BVUB8gMK.js").then(c=>c.w);return{getCurrentWindow:d}},__vite__mapDeps([0,1])).then(({getCurrentWindow:d})=>d().setTitle(t)).catch(()=>{})},[e,o,i.bridge.supported,i.isDesktop]);const M=a.useMemo(()=>r?{navigationGroups:o,subscribeFileTree:r.subscribeFileTree.bind(r),requestFileTreeRefresh:r.requestFileTreeRefresh.bind(r),addFileTreeSnapshotListener:r.addFileTreeSnapshotListener.bind(r),subscribeGitSnapshot:r.subscribeGit.bind(r),requestGitRefresh:r.requestGitRefresh.bind(r),addGitSnapshotListener:r.addGitSnapshotListener.bind(r)}:$(o),[o,r]),x=a.useMemo(()=>r?{subscribeGitSnapshot:r.subscribeGit.bind(r),requestGitRefresh:r.requestGitRefresh.bind(r),addGitSnapshotListener:r.addGitSnapshotListener.bind(r)}:U(),[r]),I=a.useMemo(()=>r?{subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:z(),[r]),G=a.useMemo(()=>r?{navigationGroups:o,currentWorkspaceId:(e==null?void 0:e.workspaceId)??null,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:A((e==null?void 0:e.workspaceId)??null,o),[e==null?void 0:e.workspaceId,o,r]);if(!i.isDesktop)return s.jsx(_,{to:"/",replace:!0});if(W)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:l("common.loading")})});if(S)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:S})});if(!e)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:l("desktopWindow.loadDescriptorFailed")})});let m=null;return e.kind==="files"?m=s.jsx(E,{sessionId:e.sessionId,workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:M}):e.kind==="git"?m=s.jsx(j,{workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:x}):e.kind==="processes"?m=s.jsx(q,{currentWorkspaceId:e.workspaceId,navigationGroups:o,externalWindowMode:!0,workbenchShellOverrides:I}):e.kind==="terminals"&&(m=s.jsx(y,{externalWindowMode:!0,externalWindowWorkspaceId:e.workspaceId,workbenchShellOverrides:G})),m?s.jsx("main",{className:"desktop-window-page",children:s.jsx("div",{className:"desktop-window-body","data-window-kind":e.kind,"aria-label":T(e),children:m})}):s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:l("desktopWindow.unsupportedKind",{kind:e.kind})})})}export{ue as DesktopWindowPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as c,j as n,t as o,A as Yn}from"./index-BZLcEHW3.js";import{f as Qn,e as wi,g as Ni}from"./App-BZvapsi8.js";import{aj as Di,u as Ei,h as ki,x as Mi}from"./MobileSheet-Ckug8hTb.js";import{aQ as Ri,r as en,w as wt,aR as _i,u as Ti,V as ke,aS as Fi,aT as yt,aU as Ve,aV as Ai,aW as Li,aX as Bi}from"./WorkbenchLayout-DGm8Tc5M.js";import{W as Ln}from"./WorkbenchModal-0tPIIhca.js";import{a as Mt,b as Rt,F as Wi}from"./file-tree-icon-Db5LXC8h.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-C5_Iay0I.js";const $i=new Set([".ds_store","thumbs.db","ehthumbs.db","desktop.ini",".spotlight-v100",".trashes",".fseventsd","__macosx","$recycle.bin","system volume information",".apdisk",".appledouble",".temporaryitems"]),Oi=["._"];function xt(t){return t.split(/[/\\]/).filter(Boolean).pop()??t}function Hi(t){const i=t.trim().toLowerCase();return i?$i.has(i)||Oi.some(l=>i.startsWith(l)):!1}function nn(t,i,l){return l?[...t]:t.filter(r=>!Hi(i(r)))}function Nt(t,i){return nn(t,l=>l.name,i)}function Ui(t,i){return i?t:Object.entries(t).reduce((l,[r,h])=>(l[r]=Nt(h,!1),l),{})}async function Qt(t,i){const[l,r]=await Promise.all([Ri(i),Di(t)]);return zi(l.changes,r.items)}function zi(t,i){const l=new Set(i.map(r=>Et(r.path)));return t.filter(r=>l.has(Et(r.path))||r.oldPath!==null&&l.has(Et(r.oldPath)))}function Vi(t){const i=Bn("","");for(const l of t){const r=Et(l.path),h=r.split("/").filter(Boolean);let d=i;h.forEach((p,y)=>{const C=h.slice(0,y+1).join("/");if(y===h.length-1){d.children.set(`file:${C}`,{kind:"file",name:p,path:r,change:l});return}const F=`directory:${C}`,_=d.children.get(F);if(_&&_.kind==="directory"){d=_;return}const Q=Bn(p,C);d.children.set(F,Q),d=Q})}return In(Jn([...i.children.values()]))}function Zn(t,i){const l=t.oldPath?`${t.oldPath} -> ${t.path}`:t.path;return an(t)?`${l} ${i}`:l}function an(t){return t.status==="D"||t.stagedStatus==="D"||t.worktreeStatus==="D"}function Dt(t){return t.split("/").filter(Boolean).pop()??t}function Et(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function Bn(t,i){return{kind:"directory",name:t,path:i,children:new Map}}function Jn(t){return[...t].sort((i,l)=>i.kind!==l.kind?i.kind==="directory"?-1:1:i.name.localeCompare(l.name,"zh-CN")).map(i=>i.kind==="directory"?{kind:"directory",name:i.name,path:i.path,children:Jn([...i.children.values()])}:i)}function In(t){return t.map(i=>{var p;if(i.kind!=="directory")return i;const l=In(i.children);let r=i.name,h=i.path,d=l;for(;d.length===1&&((p=d[0])==null?void 0:p.kind)==="directory";){const y=d[0];r=`${r}/${y.name}`,h=y.path,d=y.children}return{kind:"directory",name:r,path:h,children:d}})}const Ki=450,Gi=60*1e3,Wn=20,$n=16;function Xi({sessionId:t,workspaceId:i,showSystemFiles:l,selectedPath:r,refreshVersion:h,onCountChange:d,onSelectFile:p,onOpenFile:y}){const[C,F]=c.useState("tree"),[_,Q]=c.useState([]),[he,V]=c.useState(!0),[me,pe]=c.useState(!1),[K,ft]=c.useState([]),M=c.useRef(null),{showToast:Ce}=Qn();c.useEffect(()=>{const v=en(gt(i,t),Gi);F("tree"),Q(v??[]),V(v===null),pe(!1),ft([]),M.current=null},[t,i]),c.useEffect(()=>{let v=!1;async function b(){V(!0);try{const w=await Qt(t,i);v||(Q(w),wt(gt(i,t),w))}catch(w){v||Ce({title:Zt(w,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{v||V(!1)}}return b(),()=>{v=!0}},[h,t,Ce,i]);async function Tt(){V(!0);try{const v=await Qt(t,i);Q(v),wt(gt(i,t),v)}catch(v){Ce({title:Zt(v,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{V(!1)}}async function je(){if(Me.length!==0){pe(!0);try{await _i(i,Me.map(b=>b.path));const v=await Qt(t,i);Q(v),wt(gt(i,t),v),Ce({title:o("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(v){Ce({title:Zt(v,o("git.stageFailed")),tone:"error"})}finally{pe(!1)}}}function E(v){ft(b=>b.includes(v)?b.filter(w=>w!==v):[...b,v])}function A(v){const b=Date.now(),w=M.current;return M.current={filePath:v,timestamp:b},(w==null?void 0:w.filePath)===v&&b-w.timestamp<=Ki}async function O(v,b){if(b&&A(v)){await y(v),M.current=null;return}b||(M.current=null),await p(v)}const k=c.useMemo(()=>nn(_,v=>Dt(v.path),l),[_,l]),Me=k.filter(v=>!v.staged),G=Vi(k),Re=new Set(K);return c.useEffect(()=>{d==null||d(k.length)},[d,k.length]),n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"file-panel-session-toolbar",children:[n.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":o("conversation.filePanelSessionViewLabel"),children:[n.jsx("button",{className:C==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":C==="tree",onClick:()=>F("tree"),children:o("conversation.filePanelSessionTreeView")}),n.jsx("button",{className:C==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":C==="list",onClick:()=>F("list"),children:o("conversation.filePanelSessionListView")})]}),n.jsxs("div",{className:"file-panel-session-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Tt(),disabled:he||me,children:o("conversation.filePanelRefresh")}),n.jsx("button",{className:"primary-button",type:"button",onClick:()=>void je(),disabled:me||Me.length===0,children:o("conversation.filePanelSessionStageAll")})]})]}),n.jsxs("div",{className:"file-panel-session-summary",children:[n.jsx("span",{children:`${o("conversation.filePanelSessionSummary")} ${k.length}`}),n.jsx("span",{children:`${o("conversation.filePanelSessionUnstagedSummary")} ${Me.length}`})]}),n.jsx("div",{className:"file-tree",children:he?n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionLoading")}):k.length===0?n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionEmpty")}):C==="tree"?ei({nodes:G,depth:0,collapsedPathSet:Re,selectedPath:r,onToggleTreePath:E,onFileClick:O}):qi({items:k,selectedPath:r,onFileClick:O})})]})}function ei({nodes:t,depth:i,collapsedPathSet:l,selectedPath:r,onToggleTreePath:h,onFileClick:d}){return t.map(p=>{if(p.kind==="directory"){const y=!l.has(p.path);return n.jsxs("div",{className:"file-tree-node",children:[n.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":y,style:{paddingInlineStart:`${Wn+i*$n}px`},onClick:()=>h(p.path),children:[n.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:y?"v":">"}),n.jsx("span",{className:"file-tree-label",children:p.name})]}),y?n.jsx("div",{className:"file-tree-children",children:ei({nodes:p.children,depth:i+1,collapsedPathSet:l,selectedPath:r,onToggleTreePath:h,onFileClick:d})}):null]},`session-directory:${p.path}`)}return n.jsx("div",{className:"file-tree-node",children:n.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":r===p.change.path,"data-kind":"file",style:{paddingInlineStart:`${Wn+i*$n}px`},onClick:()=>void d(p.change.path,!an(p.change)),children:[n.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(p.name),"aria-hidden":"true",children:Mt(p.name)}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:p.name}),n.jsx("span",{className:"file-tree-path",children:Zn(p.change,o("conversation.filePanelSessionDeleted"))})]}),n.jsxs("span",{className:"file-session-item-meta",children:[n.jsx("span",{className:"file-session-badge","data-status":p.change.status,children:p.change.status}),n.jsx("span",{className:"file-session-badge subtle",children:p.change.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-file:${p.path}`)})}function qi({items:t,selectedPath:i,onFileClick:l}){return t.map(r=>n.jsx("div",{className:"file-session-list-item",children:n.jsxs("button",{className:"file-session-list-button",type:"button","data-active":i===r.path,onClick:()=>void l(r.path,!an(r)),children:[n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(Dt(r.path)),"aria-hidden":"true",children:Mt(Dt(r.path))}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:Dt(r.path)}),n.jsx("span",{className:"file-tree-path",children:Zn(r,o("conversation.filePanelSessionDeleted"))})]}),n.jsxs("span",{className:"file-session-item-meta",children:[n.jsx("span",{className:"file-session-badge","data-status":r.status,children:r.status}),n.jsx("span",{className:"file-session-badge subtle",children:r.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-list:${r.path}`))}function gt(t,i){return`file-panel.session-changes.${t}.${i}`}function Zt(t,i){return t instanceof Yn?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??i):i}const g="",Yi=450,te=8,Pt=4,Qi=176,Zi=120,Ji=300*1e3,Ii=60*1e3,On=1600,ea=20,ta=16;function Ga({className:t,sessionId:i,workspaceId:l,hideHeading:r=!1,hideTabs:h=!1,externalRevealRequest:d=null,externalWindowMode:p=!1,workbenchShellOverrides:y}){var Tn,Fn;const C=Ti(),{navigationGroups:F,subscribeFileTree:_,requestFileTreeRefresh:Q,addFileTreeSnapshotListener:he,subscribeGitSnapshot:V,requestGitRefresh:me,addGitSnapshotListener:pe}={...C,...y},[K,ft]=c.useState({}),[M,Ce]=c.useState([]),[Tt,je]=c.useState([]),[E,A]=c.useState(g),[O,k]=c.useState([]),[Me,G]=c.useState(null),[Re,v]=c.useState(!1),[b,w]=c.useState(!1),[N,dt]=c.useState(!1),[Ge,Xe]=c.useState(!1),[L,qe]=c.useState(""),[Ft,X]=c.useState(null),[ht,mt]=c.useState(!1),[Se,Ye]=c.useState(null),[q,Qe]=c.useState("workspace"),[sn,_e]=c.useState(0),[on,At]=c.useState(0),[Ze,Z]=c.useState(!1),[Je,B]=c.useState(!1),[ie,H]=c.useState(null),[be,Te]=c.useState(null),[W,Fe]=c.useState(null),[P,Lt]=c.useState(null),[S,Ie]=c.useState(null),[Bt,Ae]=c.useState(""),[rn,cn]=c.useState([]),[J,Wt]=c.useState(!1),[oi,ve]=c.useState(null),un=c.useId(),ae=c.useRef({}),le=c.useRef({}),T=c.useRef([]),I=c.useRef(g),et=c.useRef(!1),tt=c.useRef(null),fn=c.useRef(null),dn=c.useRef(null),$t=c.useRef(null),hn=c.useRef(null),mn=c.useRef(null),ye=c.useRef(0),se=c.useRef(new Map),{showToast:j}=Qn(),nt=wi(),ee=Ei(e=>e.showSystemFiles),it=!!(i!=null&&i.trim()),pn=r&&nt.isMobile;c.useEffect(()=>{ke("file_panel.props",{sessionId:i,workspaceId:l,externalWindowMode:p})},[p,i,l]),c.useEffect(()=>{I.current=E},[E]);function we(e){ft(a=>{const s=typeof e=="function"?e(a):e;return ae.current=s,s})}function Le(e){Ce(a=>{const s=typeof e=="function"?e(a):e;return T.current=s,s})}c.useEffect(()=>{var f,m;if(zt(),!l){zt(),et.current=!1,ae.current={},le.current={},T.current=[],I.current=g,we({}),Le([]),je([]),A(g),Xe(!1),qe(""),X(null),mt(!1),v(!1),Wt(!1),ve(null),k([]),G(null),H(null),Te(null),Fe(null),Ie(null),Ae("");return}et.current=!0;const e=en(Kn(l),Ji);ke("file_panel.workspace_snapshot",{workspaceId:l,cached:!!e,cachedRootItems:((m=(f=e==null?void 0:e.treeCache)==null?void 0:f[g])==null?void 0:m.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const a=xa((e==null?void 0:e.activeDirectoryPath)??g,(e==null?void 0:e.treeCache)??{}),s=Vn((e==null?void 0:e.expandedDirectories)??[],a),u=St((e==null?void 0:e.treeCache)??{},a,s);ae.current=u,le.current=Gn((e==null?void 0:e.treeRevisionByPath)??{},u),T.current=s,I.current=a,we(u),Le(s),je([]),A(a),v(!1),w(!1),Xe(!1),qe(""),X(null),mt(!1),queueMicrotask(()=>{et.current=!1})},[l]),c.useEffect(()=>{if(!d||d.workspaceId!==l)return;const e=()=>{if(mn.current===d.requestId)return;mn.current=d.requestId,Qe("workspace"),(d.openViewer?He(d.filePath):re(d.filePath)).catch(s=>{j({title:ne(s,o("conversation.filePanelOpenFailed")),tone:"error"})})};if(et.current){queueMicrotask(e);return}e()},[d,He,re,j,l]),c.useEffect(()=>{if(l)return he(e=>{e.workspaceId===l&&(le.current={...le.current,[e.path]:typeof e.revision=="string"?e.revision:null},we(a=>({...a,[e.path]:e.items})),e.path===g&&v(!1),je(a=>a.filter(s=>s!==e.path)),ui(e.path,e.items))})},[he,l]),c.useEffect(()=>()=>{zt()},[]),c.useEffect(()=>{l&&_(l,It(T.current,I.current),{knownRevisionByPath:le.current})},[E,M,_,l]),c.useEffect(()=>{k([]),G(null),Ye(null),ve(null),_e(0),Z(!1),B(!1),H(null),Te(null),Fe(null),Ie(null),Ae(""),tt.current=null,ye.current+=1},[i]),c.useEffect(()=>{!it&&q==="session"&&Qe("workspace")},[q,it]),c.useEffect(()=>{h&&q!=="workspace"&&Qe("workspace")},[q,h]),c.useEffect(()=>{if(!Ze&&!Je&&!ie)return;function e(s){var x,D,ue;if(!(s.target instanceof Node))return;const u=((x=fn.current)==null?void 0:x.contains(s.target))??!1,f=((D=dn.current)==null?void 0:D.contains(s.target))??!1,m=((ue=$t.current)==null?void 0:ue.contains(s.target))??!1;!u&&!f&&!m&&(Z(!1),B(!1),H(null),Te(null))}function a(s){s.key==="Escape"&&(Z(!1),B(!1),H(null),Te(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",a)}},[Ze,Je,ie]),c.useLayoutEffect(()=>{if(!ie||typeof window>"u"){Te(null);return}const e=ie;function a(){const u=$t.current;if(!u)return;const f=u.getBoundingClientRect();Te(ca({x:e.positionX,y:e.positionY},{width:f.width||Qi,height:f.height||u.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}a();const s=window.requestAnimationFrame(a);return window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}},[ie]),c.useEffect(()=>{if(!l)return;const e=Vn(M,E),a=St(K,E,e);wt(Kn(l),{treeCache:a,treeRevisionByPath:Gn(le.current,a),expandedDirectories:e,activeDirectoryPath:E})},[E,M,K,l]),c.useEffect(()=>{if(et.current)return;const e=St(K,E,M);Pa(K,e)||we(e)},[E,M,K]),c.useEffect(()=>{let e=!1;const a=(l==null?void 0:l.trim())??null;async function s(f){if(!a)return;const m=Nt(ae.current[g]??[],ee),x=(f==null?void 0:f.silent)!==!0&&m.length===0;x&&v(!0),ke("file_panel.load_root_tree.start",{sessionId:i,workspaceId:a,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:m.length});try{const D=await Ut(g,{force:!0});e||(ke("file_panel.load_root_tree.end",{sessionId:i,workspaceId:a,itemCount:D.length}),we(ue=>({...St(ue,I.current,T.current),[g]:D})))}catch(D){!e&&!Xn(D)&&j({title:ne(D,o("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&x&&v(!1)}}if(Nt(ae.current[g]??[],ee).length>0){const f=window.setTimeout(()=>{a&&(_(a,It(T.current,I.current),{knownRevisionByPath:le.current}),s({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return s(),()=>{e=!0}},[i,ee,j,l]),c.useEffect(()=>{if(!l||!i){At(0);return}const e=en(Ca(l,i),Ii);ke("file_panel.session_change_count.snapshot",{sessionId:i,workspaceId:l,cached:e!==null,cachedCount:e}),At(e??0)},[i,sn,l]),c.useEffect(()=>{if(!l){cn([]);return}const e=l.trim();V(e),me(e)},[l,V,me]),c.useEffect(()=>{if(!l)return;const e=l.trim();return pe(a=>{var s;a.workspaceId===e&&cn(((s=a.status)==null?void 0:s.changes)??[])})},[pe,l]);const pt=c.useMemo(()=>nn(rn,e=>xt(e.path),ee),[rn,ee]),$=c.useMemo(()=>{const e=new Map,a=new Set;for(const s of pt){const u=s.path.replace(/\\/g,"/"),f=s.worktreeStatus??s.stagedStatus??s.status;e.set(u,f);const m=u.split("/");for(let x=1;x<m.length;x++)a.add(m.slice(0,x).join("/"))}return{statusByPath:e,changedDirs:a}},[pt]),Ne=c.useMemo(()=>Ui(K,ee),[ee,K]),De=c.useMemo(()=>Ft===null?null:Nt(Ft,ee),[Ft,ee]),Be=Ne[g]??[],oe=Ge&&De!==null,bt=c.useMemo(()=>J?tn(Be,Ne,$.statusByPath,$.changedDirs):Be,[$.changedDirs,$.statusByPath,Be,J,Ne]),ri=c.useMemo(()=>oe?(De??[]).map(e=>z(e.path,e.kind)):ti(bt,Ne,M,J,$.statusByPath,$.changedDirs),[M,$.changedDirs,$.statusByPath,oe,J,De,Ne,bt]),We=((Tn=F.find(e=>e.workspace.id===l))==null?void 0:Tn.workspace)??null,R=zn(O),Ot=(R==null?void 0:R.path)??null,xe=(R==null?void 0:R.kind)==="file"?R.path:null,vt=c.useMemo(()=>new Set(O.map(e=>e.path)),[O]),at=c.useMemo(()=>jt(O),[O]),Ht=!!(We!=null&&We.path&&O.length===1&&Ot),bn=O.length===1&&(R==null?void 0:R.kind)==="file",vn=at.length>0,Ee=at.length>0,lt=!!(P!=null&&P.items.length&&l),yn=!!l&&O.length===1&&R!==null,xn=!!((xe?de(xe):E)&&M.length),gn=P?P.mode==="copy"?o("conversation.filePanelClipboardCopyReady",{count:P.items.length}):o("conversation.filePanelClipboardCutReady",{count:P.items.length}):null,U=S?ha(S):null;async function Pn(e,a=!1){if(!l)return[];if(!a){const s=ae.current[e];if(s)return s}e===g?v(!0):je(s=>kt(s,e));try{const s=await Ut(e,{force:a});return we(u=>({...u,[e]:s})),s}catch(s){throw Xn(s)||j({title:ne(s,o("conversation.filePanelLoadFailed")),tone:"error"}),s}finally{e===g?v(!1):je(s=>s.filter(u=>u!==e))}}async function ge(e){if(!l)return;const a=(e==null?void 0:e.activeDirectoryPath)??I.current,s=(e==null?void 0:e.expandedDirectories)??T.current,u=ga(ae.current,a,s);ke("file_panel.refresh_tree_cache.start",{sessionId:i,workspaceId:l,targetDirectories:u});const m=(await Promise.all(u.map(async x=>{const D=await Ut(x,{force:!0});return[x,D]}))).reduce((x,[D,ue])=>(x[D]=ue,x),{});ke("file_panel.refresh_tree_cache.end",{sessionId:i,workspaceId:l,targetDirectories:u,directoryCount:Object.keys(m).length}),we(m)}async function Ut(e,a){if(!l)return[];if(!(a!=null&&a.force)){const u=ae.current[e];if(u)return u}const s=It(kt(T.current,e),e||I.current);return _(l,s,{knownRevisionByPath:le.current}),Q(l,[e],{knownRevisionByPath:le.current}),ci(e,On,{allowCached:(a==null?void 0:a.force)!==!0})}function ci(e,a=On,s){const u=ae.current[e];return(s==null?void 0:s.allowCached)!==!1&&u?Promise.resolve(u):new Promise((f,m)=>{const x=window.setTimeout(()=>{fi(e,x),m(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},a),D=se.current.get(e)??[];se.current.set(e,[...D,{resolve:f,reject:m,timerId:x}])})}function ui(e,a){const s=se.current.get(e)??[];s.length!==0&&(se.current.delete(e),s.forEach(u=>{window.clearTimeout(u.timerId),u.resolve(a)}))}function fi(e,a){const u=(se.current.get(e)??[]).filter(f=>f.timerId!==a);if(u.length===0){se.current.delete(e);return}se.current.set(e,u)}function zt(){for(const[e,a]of se.current.entries())a.forEach(s=>{window.clearTimeout(s.timerId),s.reject(new Error(`FILE_TREE_ABORTED:${e}`))});se.current.clear()}function $e(e){k([e]),G(e.path)}function st(e){A(e.kind==="directory"?e.path:de(e.path))}function di(e){const a=aa(ri,Me,e);k(a),G(e.path),st(e)}function hi(e){const a=ia(O,e),s=zn(a);k(a),G(e.path),s&&st(s)}function Cn(e){$e(e),st(e)}function Oe(e,a){if(a!=null&&a.shiftKey){di(e);return}if(Ct(a)){hi(e);return}Cn(e)}async function ot(e,a=!1){const s=ut(e,a);if(!s.length){A(g);return}Le(u=>li(u,s)),A(s[s.length-1]??g);for(const u of s)try{await Pn(u)}catch{return}}async function re(e){const a=z(e,"file");$e(a),st(a),await ot(e)}async function He(e){Ye(e),ve(null),tt.current=null,ye.current+=1,re(e);const a=ye.current,s=e.replace(/\\/g,"/"),u=$.statusByPath.get(s);if(l&&u&&u!=="?"&&u!=="D")try{const f=await Fi(l,e,!1);ye.current===a&&ve(f.content||null)}catch{ye.current===a&&ve(null)}}function jn(e){const a=Date.now(),s=tt.current;return tt.current={filePath:e,timestamp:a},(s==null?void 0:s.filePath)===e&&a-s.timestamp<=Yi}function Pe(){tt.current=null}async function mi(e,a){const s=z(e,"file");if(a!=null&&a.shiftKey||Ct(a)){Pe(),Oe(s,a);return}if(jn(e)){await He(e);return}Oe(s,a),await ot(e)}function Sn(){Xe(!1),qe(""),X(null),Pe()}async function pi(e,a){const s=z(e.path,e.kind);if(a!=null&&a.shiftKey||Ct(a)){Pe(),Oe(s,a);return}if(e.kind==="directory"){Sn(),Oe(s,a),await wn(e.path);return}if(jn(e.path)){Sn(),await He(e.path);return}await re(e.path)}async function wn(e){if($e(z(e,"directory")),A(e),!T.current.includes(e))try{await Pn(e),Le(a=>kt(a,e))}catch{}}async function Nn(e){if($e(z(e,"directory")),A(e),T.current.includes(e)){Dn(e);return}await wn(e)}function Dn(e){Le(a=>a.filter(s=>s!==e&&!s.startsWith(`${e}/`))),A(de(e)),k([]),G(null)}async function En(){if(!l)return;const e=l;try{if(me(e),await ge(),xe&&await ot(xe),oe&&L.trim()){const a=await Ve(e,L.trim());X(a.items)}}catch(a){j({title:ne(a,o("conversation.filePanelLoadFailed")),tone:"error"})}}async function bi(e){if(e==null||e.preventDefault(),!l||!L.trim()){X(null);return}mt(!0);try{const a=await Ve(l,L.trim());X(a.items)}catch(a){j({title:ne(a,o("conversation.filePanelSearchFailed")),tone:"error"})}finally{mt(!1)}}function kn(){if(Ge){Xe(!1),qe(""),X(null);return}Xe(!0)}function Y(e){B(!1),e()}function Mn(){var e;(e=hn.current)==null||e.click()}async function vi(e){var m;const a=((m=e.target.files)==null?void 0:m[0])??null;if(e.target.value="",!a||!l)return;const s=na(a.name);if(!s){j({title:o("conversation.filePanelUploadFailed"),tone:"error"});return}const u=Hn(E,R),f=Un(u,s);dt(!0);try{const x=await ma(a);await Ai({workspaceId:l,path:f,contentBase64:x}),await ge(),await re(f),j({title:o("conversation.filePanelUploadSuccess",{name:s}),tone:"success"})}catch(x){j({title:ne(x,o("conversation.filePanelUploadFailed")),tone:"error"})}finally{dt(!1)}}async function Vt(e=xe){if(!(!l||!e)){dt(!0);try{const a=await Li(l,e),s=pa(a.contentBase64);ba(a.fileName,new Blob([s],{type:"application/octet-stream"})),j({title:o("conversation.filePanelDownloadSuccess",{name:a.fileName}),tone:"success"})}catch(a){j({title:ne(a,o("conversation.filePanelDownloadFailed")),tone:"error"})}finally{dt(!1)}}}function Rn(){const e=xe?de(xe):E;!e||!T.current.includes(e)||Dn(e)}function Kt(){Ie(null),Ae("")}function Gt(){b||Kt()}function Ue(e,a=Hn(E,R)){if(!l)return;const s=a,u=s?`${s}/`:"";Z(!1),B(!1),H(null),Ie({mode:e,baseDirectory:s}),Ae(u)}function Xt(e=R){!l||!e||(Z(!1),B(!1),H(null),Ie({mode:"rename",target:e}),Ae(e.path))}async function yi(e){if(e==null||e.preventDefault(),!l||!S)return;const a=(Bt??"").trim();if(a){if(S.mode==="rename"&&Ke(S.target.path)===Ke(a)){Gt();return}w(!0);try{if(S.mode==="rename"){const s=S.target.path,u=z(a,S.target.kind),f=Se?ai(Se,s,a):null;if(await yt({workspaceId:l,opType:"rename",srcPath:s,dstPath:a}),P&&Lt({...P,items:da(P.items,s,a)}),Kt(),Pe(),await ge(),S.target.kind==="directory"?(await ot(a,!0),$e(u),A(a)):await re(a),f!==Se&&(ye.current+=1,Ye(f),ve(null)),oe&&L.trim()){const m=await Ve(l,L.trim());X(m.items)}_e(m=>m+1),j({title:o("conversation.filePanelRenameSuccess",{name:xt(a)||a}),tone:"success"});return}if(await yt({workspaceId:l,opType:S.mode,dstPath:a,content:S.mode==="create_file"?"":void 0}),Kt(),await ge(),S.mode==="create_directory"?(await ot(a,!0),$e(z(a,"directory")),A(a)):await re(a),oe&&L.trim()){const s=await Ve(l,L.trim());X(s.items)}_e(s=>s+1)}catch(s){j({title:ne(s,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}}function ce(e,a=at){var u;if(a.length===0)return;const s=jt(a);Lt({mode:e,items:s}),k(s),G(((u=s[s.length-1])==null?void 0:u.path)??null),j({title:e==="copy"?o("conversation.filePanelCopySelectionSuccess",{count:s.length}):o("conversation.filePanelCutSelectionSuccess",{count:s.length}),tone:"success"}),H(null)}async function rt(e=oa(R,E)){if(!l||!P||!P.items.length)return;const a=e??g,s=P.items.map(u=>({source:u,destinationPath:Un(a,xt(u.path)||u.path)}));w(!0);try{for(const m of s)P.mode==="cut"&&Ke(m.source.path)===Ke(m.destinationPath)||await yt({workspaceId:l,opType:P.mode==="copy"?"copy":"move",srcPath:m.source.path,dstPath:m.destinationPath});const u=s.map(m=>z(m.destinationPath,m.source.kind)),f=u[u.length-1]??null;if(P.mode==="cut"&&Lt(null),k(u),G((f==null?void 0:f.path)??null),f&&st(f),Pe(),await ge({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?de(f.path):I.current,expandedDirectories:T.current}),oe&&L.trim()){const m=await Ve(l,L.trim());X(m.items)}_e(m=>m+1),j({title:o("conversation.filePanelPasteSuccess",{count:u.length}),tone:"success"}),H(null)}catch(u){await ge().catch(()=>{}),j({title:ne(u,o("conversation.filePanelPasteFailed")),tone:"error"})}finally{w(!1)}}function qt(e=at){!e.length||b||(Fe(jt(e)),H(null))}async function xi(){var a,s;if(!l||!(W!=null&&W.length))return;const e=jt(W);w(!0);try{for(const m of e)await yt({workspaceId:l,opType:"delete",srcPath:m.path});const u=ra(E,e),f=T.current.filter(m=>!e.some(x=>x.kind==="directory"&&_t(x.path,m)));if(Se&&e.some(m=>_t(m.path,Se))&&(ye.current+=1,Ye(null),ve(null)),Fe(null),k([]),G(null),I.current=u,T.current=f,A(u),Le(f),Pe(),await ge({activeDirectoryPath:u,expandedDirectories:f}),oe&&L.trim()){const m=await Ve(l,L.trim());X(m.items)}_e(m=>m+1),j({title:e.length===1?o("conversation.filePanelDeleteSuccess",{name:xt(((a=e[0])==null?void 0:a.path)??"")||((s=e[0])==null?void 0:s.path)||""}):o("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(u){j({title:ne(u,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}async function ze(e,a=R){const s=(We==null?void 0:We.path)??"",u=(a==null?void 0:a.path)??null;if(u===null||!s){Z(!1);return}try{const f=fa(s),m=e==="absolute"?ua(s,u,f):Ke(u,f);await va(m,nt),j({title:e==="absolute"?o("conversation.filePanelCopyAbsolutePathSuccess"):o("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){j({title:f instanceof Error?f.message:o("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{Z(!1),H(null)}}function gi(e,a,s){return[{id:`open-${e.path}`,label:e.kind==="directory"?M.includes(e.path)?o("conversation.filePanelCollapseDirectory"):o("conversation.filePanelExpandDirectory"):o("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){Nn(e.path);return}He(e.path)}},{id:`download-${e.path}`,label:o("conversation.filePanelDownload"),disabled:e.kind!=="file"||N,onSelect:()=>{Vt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:o("conversation.filePanelNewFile"),disabled:!l||b||N,onSelect:()=>{Ue("create_file",s)}},{id:`create-directory-${e.path}`,label:o("conversation.filePanelNewDirectory"),disabled:!l||b||N,onSelect:()=>{Ue("create_directory",s)}},{id:`rename-${e.path}`,label:o("conversation.filePanelRenameMove"),disabled:a.length!==1||b||N,onSelect:()=>Xt(e)},{id:`copy-${e.path}`,label:o("conversation.filePanelCopy"),disabled:a.length===0,onSelect:()=>ce("copy",a)},{id:`cut-${e.path}`,label:o("conversation.filePanelCut"),disabled:a.length===0,onSelect:()=>ce("cut",a)},{id:`paste-${e.path}`,label:o("conversation.filePanelPaste"),disabled:!lt,onSelect:()=>{rt(s)}},{id:`copy-relative-${e.path}`,label:o("conversation.filePanelCopyRelativePath"),onSelect:()=>{ze("relative",e)}},{id:`copy-absolute-${e.path}`,label:o("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{ze("absolute",e)}},{id:`delete-${e.path}`,label:o("conversation.filePanelDelete"),disabled:a.length===0||b||N,onSelect:()=>qt(a)}]}async function _n(e,a){if(nt.isMobile)return;e.preventDefault();const s=z(a.path,a.kind),u=vt.has(s.path)?at:[s],f=s.kind==="directory"?s.path:de(s.path);vt.has(s.path)||Cn(s);const m=gi(s,u,f);if(nt.isDesktop){await Bi(m);return}nt.isWeb&&(Z(!1),B(!1),H({positionX:e.clientX,positionY:e.clientY,items:m}))}c.useEffect(()=>{if(q!=="workspace")return;function e(a){if(!la(a)||a.altKey||a.shiftKey||sa(a.target))return;const s=a.key.toLowerCase();if(s==="c"&&Ee){a.preventDefault(),ce("copy");return}if(s==="x"&&Ee){a.preventDefault(),ce("cut");return}s==="v"&<&&(a.preventDefault(),rt())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[q,Ee,lt,ce,rt]);function Yt(e,a){return n.jsx(n.Fragment,{children:e.map(s=>{const u=z(s.path,s.kind),f=s.kind==="directory",m=f&&M.includes(s.path),x=f&&Tt.includes(s.path),D=Ne[s.path]??[],ue=J?tn(D,Ne,$.statusByPath,$.changedDirs):D,Ci=vt.has(s.path),ji=Ot===s.path,ct=$.statusByPath.get(s.path.replace(/\\/g,"/")),An=f&&$.changedDirs.has(s.path.replace(/\\/g,"/")),Si=(P==null?void 0:P.mode)==="cut"&&P.items.some(fe=>fe.path===s.path);return n.jsxs("div",{className:"file-tree-node",children:[n.jsxs("button",{className:"file-tree-item",type:"button","data-active":ji,"data-selected":Ci,"data-cut-pending":Si||void 0,"data-kind":s.kind,"aria-expanded":f?m:void 0,style:{paddingInlineStart:`${ea+a*ta}px`},onClick:fe=>{if(f){if(fe.shiftKey||Ct(fe)){Pe(),Oe(u,fe);return}Pe(),Oe(u,fe),Nn(s.path);return}mi(s.path,fe)},onContextMenu:fe=>{_n(fe,s)},children:[n.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:m?"v":">"}),f?null:n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(s.name),"aria-hidden":"true",children:Mt(s.name)}),n.jsx("span",{className:"file-tree-label","data-status":ct??void 0,"data-has-changes":An||void 0,children:s.name}),!f&&ct?n.jsx("span",{className:"git-status-badge","data-status":ct,"aria-label":ct,children:ct}):null,f&&An?n.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,x?n.jsx("span",{className:"file-tree-meta",children:o("common.loading")}):null]}),f&&m?n.jsx("div",{className:"file-tree-children",children:x&&!D.length?n.jsx("p",{className:"file-tree-empty",children:o("common.loading")}):ue.length?Yt(ue,a+1):n.jsx("p",{className:"file-tree-empty",children:o("conversation.filePanelEmptyDirectory")})}):null]},`${s.kind}-${s.path}`)})})}function Pi(e){return n.jsx(n.Fragment,{children:e.map(a=>{const s=a.kind==="directory",u=vt.has(a.path),f=Ot===a.path;return n.jsx("div",{className:"file-tree-node",children:n.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":f,"data-selected":u,"data-kind":a.kind,onClick:m=>{pi(a,m)},onContextMenu:m=>{_n(m,a)},children:[n.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),s?null:n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(a.name),"aria-hidden":"true",children:Mt(a.name)}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:a.name}),n.jsx("span",{className:"file-tree-path",children:a.path})]})]})},`search-${a.kind}-${a.path}`)})})}return n.jsx("section",{className:["conversation-panel","surface-card","file-panel",t].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:l?n.jsxs(n.Fragment,{children:[n.jsx(Wi,{workspaceId:l,filePath:Se,open:Se!==null,onClose:()=>{ye.current+=1,Ye(null),ve(null)},onSaved:async e=>{await ge(),await re(e),_e(a=>a+1)},diffContent:oi}),r?null:n.jsx("div",{className:"file-panel-heading-row",children:n.jsx("h2",{className:"file-panel-heading",children:o("conversation.filePanelTitle")})}),h?null:n.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":o("conversation.filePanelTitle"),children:[n.jsx("button",{className:q==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":q==="workspace",onClick:()=>Qe("workspace"),children:o("conversation.filePanelWorkspaceTab")}),n.jsxs("button",{className:q==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":q==="session",onClick:()=>{it&&Qe("session")},disabled:!it,children:[o("conversation.filePanelSessionTab"),n.jsx("span",{className:"file-panel-tab-badge","aria-label":`${o("conversation.filePanelSessionTab")} ${on}`,children:on})]})]}),q==="workspace"?n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:hn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void vi(e)}),pn?n.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":o("conversation.filePanelTitle"),children:n.jsxs("div",{className:"file-mobile-action-shell",ref:dn,children:[n.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":o("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":Je,"data-active":Je,onClick:()=>{Z(!1),B(e=>!e)},children:[n.jsx("span",{children:o("conversation.filePanelActionsMenu")}),n.jsx(Aa,{})]}),Je?n.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":o("conversation.filePanelActionsMenu"),children:[n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ce("copy")),disabled:!Ee,children:o("conversation.filePanelCopy")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ce("cut")),disabled:!Ee,children:o("conversation.filePanelCut")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>rt()),disabled:!lt||b||N,children:o("conversation.filePanelPaste")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),kn()},children:Ge?o("conversation.filePanelHideSearch"):o("conversation.filePanelShowSearch")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),Wt(e=>!e)},disabled:pt.length===0,children:J?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(En),disabled:Re||b||ht,children:o("conversation.filePanelRefresh")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),Rn()},disabled:!xn,children:o("conversation.filePanelCollapseCurrent")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),Mn()},disabled:b||N,children:o("conversation.filePanelUpload")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(Vt),disabled:!bn||N,children:o("conversation.filePanelDownload")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(Xt),disabled:!yn||b||N,children:o("conversation.filePanelRenameMove")}),n.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>Y(qt),disabled:!vn||b||N,children:o("conversation.filePanelDelete")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Ue("create_file")),disabled:b||N,children:o("conversation.filePanelNewFile")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Ue("create_directory")),disabled:b||N,children:o("conversation.filePanelNewDirectory")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ze("absolute")),disabled:!Ht,children:o("conversation.filePanelCopyAbsolutePath")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ze("relative")),disabled:!Ht,children:o("conversation.filePanelCopyRelativePath")})]}):null]})}):n.jsxs("div",{className:"file-panel-toolbar","aria-label":o("conversation.filePanelTitle"),children:[n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopy"),"aria-label":o("conversation.filePanelCopy"),onClick:()=>ce("copy"),disabled:!Ee,children:n.jsx(Na,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCut"),"aria-label":o("conversation.filePanelCut"),onClick:()=>ce("cut"),disabled:!Ee,children:n.jsx(Da,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelPaste"),"aria-label":o("conversation.filePanelPaste"),onClick:()=>void rt(),disabled:!lt||b||N,children:n.jsx(Ea,{})}),n.jsxs("div",{className:"file-toolbar-menu-shell",ref:fn,children:[n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopyPath"),"aria-label":o("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":Ze,"data-active":Ze,onClick:()=>{B(!1),Z(e=>!e)},disabled:!Ht,children:n.jsx(wa,{})}),Ze?n.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[n.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void ze("absolute"),children:o("conversation.filePanelCopyAbsolutePath")}),n.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void ze("relative"),children:o("conversation.filePanelCopyRelativePath")})]}):null]}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCollapseCurrent"),"aria-label":o("conversation.filePanelCollapseCurrent"),onClick:Rn,disabled:!xn,children:n.jsx(ja,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelRefresh"),"aria-label":o("conversation.filePanelRefresh"),onClick:()=>void En(),disabled:Re||b||ht,children:n.jsx(Sa,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),"data-active":Ge,onClick:kn,disabled:Re,children:n.jsx(qn,{})}),pt.length>0?n.jsx("button",{className:"file-toolbar-button",type:"button",title:J?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges"),"aria-label":J?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges"),"data-active":J,onClick:()=>Wt(e=>!e),children:n.jsx(La,{})}):null,n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelUpload"),"aria-label":o("conversation.filePanelUpload"),onClick:Mn,disabled:b||N,children:n.jsx(Ma,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelDownload"),"aria-label":o("conversation.filePanelDownload"),onClick:()=>void Vt(),disabled:!bn||N,children:n.jsx(Ra,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelRenameMove"),"aria-label":o("conversation.filePanelRenameMove"),onClick:()=>Xt(),disabled:!yn||b||N,children:n.jsx(Fa,{})}),n.jsx("button",{className:"file-toolbar-button danger",type:"button",title:o("conversation.filePanelDelete"),"aria-label":o("conversation.filePanelDelete"),onClick:()=>qt(),disabled:!vn||b||N,children:n.jsx(_a,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewFile"),"aria-label":o("conversation.filePanelNewFile"),onClick:()=>void Ue("create_file"),disabled:b||N,children:n.jsx(ka,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewDirectory"),"aria-label":o("conversation.filePanelNewDirectory"),onClick:()=>void Ue("create_directory"),disabled:b||N,children:n.jsx(Ta,{})})]}),ie&&typeof document<"u"?Ni.createPortal(n.jsx("div",{className:"file-web-context-menu",ref:$t,role:"menu","aria-label":o("conversation.filePanelActionsMenu"),style:{left:`${(be==null?void 0:be.left)??Math.max(8,ie.positionX)}px`,top:`${(be==null?void 0:be.top)??Math.max(8,ie.positionY)}px`,maxHeight:be?`${be.maxHeight}px`:void 0},children:ie.items.map(e=>n.jsx("button",{className:["file-web-context-menu-item",e.label===o("conversation.filePanelDelete")?"danger":""].filter(Boolean).join(" "),type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>{H(null),e.onSelect()},children:e.label},e.id))}),document.body):null,gn?n.jsx("p",{className:"file-panel-clipboard-status","data-mode":P==null?void 0:P.mode,children:gn}):null,Ge?n.jsxs("form",{className:"file-toolbar-search",onSubmit:e=>void bi(e),children:[n.jsx("input",{value:L,onChange:e=>qe(e.target.value),placeholder:o("conversation.filePanelSearchPlaceholder")}),pn?n.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":o("conversation.filePanelSearchButton"),disabled:ht,children:o("conversation.filePanelSearchButton")}):n.jsx("button",{className:"file-toolbar-button",type:"submit",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),disabled:ht,children:n.jsx(qn,{})})]}):null,n.jsx("div",{className:"file-tree","data-search-mode":oe,children:Re&&Be.length===0?n.jsx("p",{className:"file-tree-status status-text",children:o("common.loading")}):oe?De!=null&&De.length?Pi(De):n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSearchEmpty")}):J?bt.length?Yt(bt,0):n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelNoChanges")}):Be.length?Yt(Be,0):n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelEmptyDirectory")})}),n.jsx(Ln,{open:S!==null,title:(U==null?void 0:U.title)??"",description:U==null?void 0:U.description,onClose:Gt,children:n.jsxs("form",{className:"workbench-rename-form",onSubmit:e=>void yi(e),children:[n.jsx(ki,{label:o("conversation.filePanelPathFieldLabel"),htmlFor:un,description:(S==null?void 0:S.mode)==="rename"?S.target.path:(S==null?void 0:S.baseDirectory)||void 0,children:n.jsx("input",{id:un,type:"text",value:Bt??"",placeholder:o("conversation.filePanelPathFieldPlaceholder"),autoFocus:!0,onChange:e=>Ae(e.target.value)})}),n.jsxs(Mi,{children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:b,onClick:Gt,children:o("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:b||!(Bt??"").trim(),children:b?(U==null?void 0:U.pendingLabel)??o("common.loading"):(U==null?void 0:U.submitLabel)??o("common.save")})]})]})}),n.jsxs(Ln,{open:W!==null,title:o("conversation.filePanelDeleteConfirmTitle"),description:o("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{b||Fe(null)},children:[n.jsx("p",{className:"workbench-section-empty",children:W!=null&&W.length?W.length===1?((Fn=W[0])==null?void 0:Fn.kind)==="directory"?o("conversation.filePanelDeleteDirectoryConfirm",{path:W[0].path}):o("conversation.filePanelDeleteFileConfirm",{path:W[0].path}):o("conversation.filePanelDeleteSelectionConfirm",{count:W.length}):""}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:b,onClick:()=>Fe(null),children:o("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:b,onClick:()=>{xi()},children:b?o("conversation.filePanelDeleting"):o("conversation.filePanelDelete")})]})]})]}):it&&i?n.jsx(Xi,{sessionId:i,workspaceId:l,showSystemFiles:ee,selectedPath:xe,refreshVersion:sn,onCountChange:At,onSelectFile:re,onOpenFile:He}):n.jsx("section",{className:"file-panel-section",children:n.jsx("p",{className:"status-text",children:o("conversation.filePanelSessionNoSession")})})]}):n.jsx("section",{className:"file-panel-section",children:n.jsx("p",{className:"status-text",children:o("conversation.filePanelNoWorkspace")})})})}function de(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):g}function ut(t,i=!1){const l=t.split("/").filter(Boolean),r=i?l.length:l.length-1,h=[];for(let d=0;d<r;d+=1)h.push(l.slice(0,d+1).join("/"));return h}function Hn(t,i){return t||((i==null?void 0:i.kind)==="directory"?i.path:i!=null&&i.path?de(i.path):g)}function Un(t,i){return t?`${t}/${i}`:i}function na(t){var i;return((i=t.split(/[/\\]/).pop())==null?void 0:i.trim())??""}function z(t,i){return{path:t,kind:i}}function zn(t){return t[t.length-1]??null}function ia(t,i){return t.findIndex(r=>r.path===i.path)>=0?t.filter(r=>r.path!==i.path):[...t,i]}function aa(t,i,l){const r=t.findIndex(y=>y.path===l.path);if(r<0)return[l];const h=i?t.findIndex(y=>y.path===i):r;if(h<0)return[l];const d=Math.min(h,r),p=Math.max(h,r);return t.slice(d,p+1)}function Ct(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function la(t){return t.ctrlKey||t.metaKey}function sa(t){if(!(t instanceof HTMLElement))return!1;const i=t.tagName.toLowerCase();return i==="input"||i==="textarea"||i==="select"||t.isContentEditable}function jt(t){const i=[...new Map(t.map(r=>[r.path,r])).values()].sort((r,h)=>r.path.localeCompare(h.path)),l=[];for(const r of i)l.some(h=>h.kind==="directory"&&_t(h.path,r.path))||l.push(r);return l}function oa(t,i){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?de(t.path):i}function ra(t,i){let l=t;for(;l&&i.some(r=>r.kind==="directory"&&_t(r.path,l));)l=de(l);return l}function ti(t,i,l,r,h,d){const p=[];for(const y of t){if(p.push(z(y.path,y.kind)),y.kind!=="directory"||!l.includes(y.path))continue;const C=i[y.path]??[],F=r?tn(C,i,h,d):C;p.push(...ti(F,i,l,r,h,d))}return p}function ca(t,i,l){const r=Math.max(0,l.width),h=Math.max(0,l.height),d=Math.max(0,h-te*2),p=Math.max(0,r-te*2),y=Math.min(Math.max(i.width,0),p),C=Math.max(0,h-t.y-Pt-te),F=Math.max(0,t.y-Pt-te),_=C<i.height&&F>C,he=Jt(Math.max(_?F:C,Zi),0,d),V=Math.min(Math.max(i.height,0),he),me=_?t.y-Pt-V:t.y+Pt,pe=Math.max(te,h-te-V),K=Math.max(te,r-te-y);return{top:Jt(me,te,pe),left:Jt(t.x,te,K),maxHeight:Math.max(0,he)}}function Jt(t,i,l){return!Number.isFinite(t)||l<i?i:Math.min(Math.max(t,i),l)}function Ke(t,i="posix"){return t?ni(t,i):"."}function ua(t,i,l){const r=ni(t,l),h=Ke(i,l).replace(/^\.[/\\]?/,"");if(!h)return r;const d=ii(l),p=h.replace(/^[/\\]+/,"");return p?r.endsWith("/")||r.endsWith("\\")?`${r}${p}`:`${r}${d}${p}`:r}function fa(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function ni(t,i){return t&&(ii(i)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function ii(t){return t==="windows"?"\\":"/"}function _t(t,i){return i===t||i.startsWith(`${t}/`)}function ai(t,i,l){return t===i?l:t.startsWith(`${i}/`)?`${l}${t.slice(i.length)}`:t}function da(t,i,l){return t.map(r=>({...r,path:ai(r.path,i,l)}))}function ha(t){return t.mode==="create_file"?{title:o("conversation.filePanelNewFile"),description:o("conversation.filePanelCreateFileDescription"),submitLabel:o("conversation.filePanelCreateFileSubmit"),pendingLabel:o("conversation.filePanelCreatingFile")}:t.mode==="create_directory"?{title:o("conversation.filePanelNewDirectory"),description:o("conversation.filePanelCreateDirectoryDescription"),submitLabel:o("conversation.filePanelCreateDirectorySubmit"),pendingLabel:o("conversation.filePanelCreatingDirectory")}:{title:o("conversation.filePanelRenameMove"),description:o("conversation.filePanelRenameDescription"),submitLabel:o("conversation.filePanelRenameSubmit"),pendingLabel:o("conversation.filePanelRenaming")}}async function ma(t){const i=await t.arrayBuffer(),l=new Uint8Array(i),r=32768;let h="";for(let d=0;d<l.length;d+=r){const p=l.subarray(d,d+r);h+=String.fromCharCode(...p)}return btoa(h)}function pa(t){const i=atob(t),l=new Uint8Array(i.length);for(let r=0;r<i.length;r+=1)l[r]=i.charCodeAt(r);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}function ba(t,i){if(typeof document>"u")throw new Error(o("conversation.filePanelDownloadFailed"));const l=window.URL.createObjectURL(i),r=document.createElement("a");r.href=l,r.download=t,document.body.append(r),r.click(),r.remove(),window.URL.revokeObjectURL(l)}async function va(t,i){var l;if(!(i.isDesktop&&(await i.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((l=navigator.clipboard)!=null&&l.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!ya(t))throw new Error(o("conversation.filePanelCopyPathFailed"))}}function ya(t){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const i=document.createElement("textarea");i.value=t,i.setAttribute("readonly","true"),i.style.position="fixed",i.style.top="-9999px",i.style.left="-9999px",i.style.opacity="0",document.body.appendChild(i),i.focus(),i.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(i)}}function xa(t,i){return t&&ut(t,!0).every(h=>h in i)?t:g}function Vn(t,i){if(!i)return[];const l=ut(i,!0);return t.filter(r=>l.includes(r))}function St(t,i,l){const r=ln(i,l);return Object.entries(t).reduce((h,[d,p])=>(r.has(d)&&(h[d]=p),h),{})}function ga(t,i,l){const h=[...ln(i,l)].filter(d=>d===g||d in t);return h.length?h:[g]}function ln(t,i){const l=new Set([g]),r=li(i,ut(t,!0));for(const h of r){l.add(h);for(const d of ut(h,!0))l.add(d)}return l}function Pa(t,i){const l=Object.keys(t),r=Object.keys(i);return l.length!==r.length?!1:l.every(h=>t[h]===i[h])}function kt(t,i){return t.includes(i)?t:[...t,i]}function li(t,i){return i.reduce((l,r)=>kt(l,r),t)}function Kn(t){return`file-panel.workspace-tree.${t}`}function Ca(t,i){return`file-panel.session-change-count.${t}.${i}`}function Gn(t,i){return Object.fromEntries(Object.keys(i).map(l=>[l,t[l]??null]))}function It(t,i){return[...ln(i,t)]}function ne(t,i){return t instanceof Yn?t.message:i}function Xn(t){return t instanceof Error&&(t.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")||t.message.startsWith("FILE_TREE_ABORTED:"))}function ja(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function Sa(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M12.8 5.2A5.5 5.5 0 1 0 13.5 8h-1.8A3.7 3.7 0 1 1 10.6 5l-1.4 1.4h4V2l-1.4 1.4z",fill:"currentColor"})})}function qn(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M11.2 10.1l3 3-1.1 1.1-3-3a5 5 0 1 1 1.1-1.1zM6.8 10.3a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z",fill:"currentColor"})})}function wa(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M3.5 4.3h5.2v1.4H4.9v5.4H3.5zm3.8-2.1h5.2v9.5H7.3z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Na(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Da(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M4.2 4.2a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm0 5.4a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm1-3.2 6.6 5.6M5.2 9.6l6.6-5.6",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})}function Ea(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function ka(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ma(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ra(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"m5.5 8.5 2.5 2.5 2.5-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function _a(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.5 4.5h9M6.2 2.5h3.6l.6 1.4H13v1.2H3V3.9h2.6zM5.2 5.7v6.1m2.8-6.1v6.1m2.8-6.1v6.1M4.4 13.5h7.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ta(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Fa(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.2 11.9h2.2l5.9-5.9-2.2-2.2-5.9 5.9zM8.3 3.8l2.2 2.2M2.8 13.2h10.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Aa(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function La(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function tn(t,i,l,r){const h=[];for(const d of t){const p=d.path.replace(/\\/g,"/");d.kind==="file"?l.has(p)&&h.push(d):si(p,i,l,r)&&h.push(d)}return h}function si(t,i,l,r,h){const d=h??new Set;if(d.has(t))return!1;d.add(t);const p=i[t];if(!p)return r.has(t);for(const y of p){const C=y.path.replace(/\\/g,"/");if(y.kind==="file"){if(l.has(C))return!0}else if(si(C,i,l,r,d))return!0}return!1}export{Ga as FileContextPanel};
|