@jingyi0605/codingns 0.9.6 → 0.9.7
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/dist/public/assets/{AdaptiveButlerPage-khJQh6a_.js → AdaptiveButlerPage-DclGPzEx.js} +2 -2
- package/dist/public/assets/{App-If9gThKM.js → App-BxX5mm9o.js} +3 -3
- package/dist/public/assets/{BootstrapPage-DcfYtoLC.js → BootstrapPage-Bl21SsuW.js} +1 -1
- package/dist/public/assets/{ConversationPage-Bfb7GLTM.js → ConversationPage-CmiVCV0q.js} +7 -7
- package/dist/public/assets/{DesktopDetachPreviewPage-CXUPMcBz.js → DesktopDetachPreviewPage-uaOHVsjV.js} +1 -1
- package/dist/public/assets/{DesktopModal-bMdI1jEe.js → DesktopModal-BxsogpLf.js} +1 -1
- package/dist/public/assets/{DesktopWindowPage-D1xwgS-7.js → DesktopWindowPage-Bubfw1nC.js} +1 -1
- package/dist/public/assets/{FileContextPanel-C4syif3B.js → FileContextPanel-DrYWcTkp.js} +1 -1
- package/dist/public/assets/{GitSidebar-DduL9aTV.js → GitSidebar-CQsfJqun.js} +1 -1
- package/dist/public/assets/{MobileCreateSessionSheet-DWPBsEx8.js → MobileCreateSessionSheet-CqtmfVNo.js} +1 -1
- package/dist/public/assets/{MobileSheet-BXvQPkxt.js → MobileSheet-C5IVmUsO.js} +1 -1
- package/dist/public/assets/{MobileTopHeaderFrame-vdYOyaaB.js → MobileTopHeaderFrame-EoBm3-X0.js} +1 -1
- package/dist/public/assets/{MobileWorkspaceSwitcherHeader-DT330cAx.js → MobileWorkspaceSwitcherHeader-BC8MMQs_.js} +1 -1
- package/dist/public/assets/{PluginAccessOverview-C77TeZTK.js → PluginAccessOverview-CrQiQxxZ.js} +1 -1
- package/dist/public/assets/{PluginContainerPage-DdSwOCw-.js → PluginContainerPage-_2u-9thM.js} +1 -1
- package/dist/public/assets/{PluginDetailPage-BK1yTzvO.js → PluginDetailPage-F9cKjSCp.js} +1 -1
- package/dist/public/assets/{PluginsListPage-DAAwSc6W.js → PluginsListPage-BOhcua_4.js} +1 -1
- package/dist/public/assets/{RelayConnectEntryPage-4Yyo2p8b.js → RelayConnectEntryPage-Ck_uZLzj.js} +1 -1
- package/dist/public/assets/{ServerSettingsModal-C_DEisHs.js → ServerSettingsModal-ICd82a_x.js} +1 -1
- package/dist/public/assets/SessionIndexPage-Cox6P6dw.js +1 -0
- package/dist/public/assets/{SettingsPage-CDAVsPr3.js → SettingsPage-BI5cM3j5.js} +1 -1
- package/dist/public/assets/{TerminalManagerPanel-4OR47vcf.js → TerminalManagerPanel-DiVhBQhf.js} +1 -1
- package/dist/public/assets/{TerminalPage-Pvx396YX.js → TerminalPage-DUMUO7Ng.js} +1 -1
- package/dist/public/assets/{TerminalRuntimeFallbackModal-KvG6k4AQ.js → TerminalRuntimeFallbackModal-DGPR_CMh.js} +1 -1
- package/dist/public/assets/{ToolFilesPage-DrYHk0N-.js → ToolFilesPage-m88CAp-r.js} +1 -1
- package/dist/public/assets/{ToolGitPage-Dz1q-Ns_.js → ToolGitPage-DCYpfTsb.js} +1 -1
- package/dist/public/assets/{ToolProcessesPage-CRhphOmM.js → ToolProcessesPage-Bk5ulsyq.js} +1 -1
- package/dist/public/assets/{ToolsHomePage-BJSDLR6T.js → ToolsHomePage-BrTwfjI7.js} +1 -1
- package/dist/public/assets/{WorkbenchLandingPage-BlkxdOLC.js → WorkbenchLandingPage-q4AAmdMV.js} +1 -1
- package/dist/public/assets/{WorkbenchLayout-D-U7ghT0.js → WorkbenchLayout-DD8b-m2G.js} +66 -61
- package/dist/public/assets/{WorkbenchModal-xbx1o6MO.js → WorkbenchModal-CsZeLArg.js} +1 -1
- package/dist/public/assets/WorkbenchShellRoute-BaiW_vfb.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-CxKYZ6uF.css +1 -0
- package/dist/public/assets/{WorkspaceDebugDetailPage-B4ol2_a5.js → WorkspaceDebugDetailPage-BcUUDEyw.js} +1 -1
- package/dist/public/assets/WorkspaceDetailPage-zEZ1VARA.js +1 -0
- package/dist/public/assets/{WorkspaceHomePage-tmCafatd.js → WorkspaceHomePage-CR0rqS4e.js} +1 -1
- package/dist/public/assets/{client-runtime-manager-Bwau7p1v.js → client-runtime-manager-BgGugw8T.js} +1 -1
- package/dist/public/assets/{index-_OCkVmfl.js → index-CFyk1rgJ.js} +5 -5
- package/dist/public/assets/index-CrU73EIV.css +1 -0
- package/dist/public/assets/{login-direct-candidate-resolver-CKUQ07IA.js → login-direct-candidate-resolver-ty2uOY5y.js} +1 -1
- package/dist/public/assets/{plugin-permission-copy-DIVk5jNp.js → plugin-permission-copy-iK3faI3n.js} +1 -1
- package/dist/public/assets/{plugins-api-DHJVvPZw.js → plugins-api-CmV7aDGA.js} +1 -1
- package/dist/public/assets/{preferences-service-CyxxeBmS.js → preferences-service-BoSmT_ny.js} +1 -1
- package/dist/public/assets/{relay-entry-B5GmiOrR.js → relay-entry-C8k5qsl5.js} +1 -1
- package/dist/public/assets/styles-BhKoKfQ_.css +1 -0
- package/dist/public/assets/{terminal-runtime-meta-DBsyT35T.js → terminal-runtime-meta-okQIDzfA.js} +1 -1
- package/dist/public/assets/{useRegisteredDebugTemplates-wCGD2SLW.js → useRegisteredDebugTemplates-B_vXUtSe.js} +1 -1
- package/dist/public/assets/{workbench-navigation-RyUjchbD.js → workbench-navigation-DoDaQR4z.js} +1 -1
- package/dist/public/index.html +2 -2
- package/dist/server/modules/provider/provider-discovery-runtime.js +16 -1
- package/dist/server/modules/provider/provider-discovery-runtime.js.map +1 -1
- package/dist/server/modules/sessions/codex-app-server-helper-client.js +14 -0
- package/dist/server/modules/sessions/codex-app-server-helper-client.js.map +1 -1
- package/dist/server/modules/sessions/codex-app-server-helper-process.js +59 -0
- package/dist/server/modules/sessions/codex-app-server-helper-process.js.map +1 -1
- package/dist/server/modules/sessions/codex-session-title-generator.d.ts +19 -0
- package/dist/server/modules/sessions/codex-session-title-generator.js +295 -0
- package/dist/server/modules/sessions/codex-session-title-generator.js.map +1 -0
- package/dist/server/modules/sessions/session-history-service.d.ts +5 -0
- package/dist/server/modules/sessions/session-history-service.js +183 -0
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/tasks/task-types.d.ts +1 -0
- package/dist/server/modules/tasks/task-types.js +1 -0
- package/dist/server/modules/tasks/task-types.js.map +1 -1
- package/dist/server/modules/workspace/affairs-lightweight-session-service.js +13 -9
- package/dist/server/modules/workspace/affairs-lightweight-session-service.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +7 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +596 -6
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +249 -6
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/types.d.ts +11 -0
- package/package.json +1 -1
- package/dist/public/assets/SessionIndexPage-DyMikN_x.js +0 -1
- package/dist/public/assets/WorkbenchShellRoute-DyWSCHz_.js +0 -1
- package/dist/public/assets/WorkbenchShellRoute-htbkGbtW.css +0 -1
- package/dist/public/assets/WorkspaceDetailPage-DMakfmHR.js +0 -1
- package/dist/public/assets/index-DmUJ8tIw.css +0 -1
- package/dist/public/assets/styles-DkbkRgWw.css +0 -1
- /package/dist/public/assets/{styles-JKFlsYFv.js → styles-DwSuZo1w.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as d,j as e}from"./index-
|
|
1
|
+
import{b as d,j as e}from"./index-CFyk1rgJ.js";function c(){return d.useEffect(()=>{const t=document.documentElement.style.background,s=document.body.style.background;return document.documentElement.style.background="transparent",document.body.style.background="transparent",()=>{document.documentElement.style.background=t,document.body.style.background=s}},[]),e.jsx("main",{className:"desktop-detach-preview-page","aria-hidden":"true",children:e.jsxs("section",{className:"desktop-detach-preview-card",children:[e.jsx("header",{className:"desktop-detach-preview-bar",children:e.jsx("strong",{className:"desktop-detach-preview-title",children:"小窗口"})}),e.jsx("div",{className:"desktop-detach-preview-body",children:e.jsx("span",{className:"desktop-detach-preview-badge"})})]})})}export{c as DesktopDetachPreviewPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,t as j,b as d}from"./index-
|
|
1
|
+
import{j as e,t as j,b as d}from"./index-CFyk1rgJ.js";import{g as L}from"./App-BxX5mm9o.js";function C(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true",children:e.jsx("path",{d:"M4.2 4.2l7.6 7.6M11.8 4.2l-7.6 7.6",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})})}function O({className:a,"aria-label":r,...o}){return e.jsx("button",{type:"button",className:a?`workbench-modal-close ${a}`:"workbench-modal-close","aria-label":r??j("common.close"),...o,children:e.jsx(C,{})})}function R({open:a,title:r,description:o,hideHeader:l=!1,size:c="compact",layout:s="form",dismissible:n=!0,closeOnBackdrop:v=!0,closeOnEscape:y=!0,backdropVisible:E=!0,className:i,bodyClassName:u,titleClassName:N,titleRef:D,titleProps:I,headerActions:m,beforeCloseButton:M,footer:b,showCloseButton:h=!0,onClose:t,children:g}){const k=d.useId(),f=d.useId(),x=n&&v,w=n&&y,$=!n;return d.useEffect(()=>{if(!a||!w)return;function p(B){B.key==="Escape"&&t()}return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[w,t,a]),!a||typeof document>"u"?null:L.createPortal(e.jsxs("div",{className:"workbench-modal-layer desktop-modal-layer","data-fullscreen":c==="full"?"true":void 0,"data-layout":s,"data-backdrop-visible":E?"true":"false",children:[e.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":j("common.close"),disabled:!x,onClick:()=>{x&&t()}}),e.jsxs("section",{className:`workbench-modal-card surface-card desktop-modal-card${i?` ${i}`:""}`,"data-size":c,"data-layout":s,role:"dialog","aria-modal":"true","aria-labelledby":l?void 0:k,"aria-label":l?r:void 0,"aria-describedby":!l&&o?f:void 0,children:[l?null:e.jsxs("div",{className:"workbench-modal-header",children:[e.jsxs("div",{className:"workbench-modal-title-wrap",children:[e.jsx("h2",{id:k,className:N,ref:D,...I,children:r}),o?e.jsx("p",{id:f,children:o}):null]}),m||h?e.jsxs("div",{className:"workbench-modal-header-actions",children:[m,M,h?e.jsx(O,{disabled:$,onClick:()=>{n&&t()}}):null]}):null]}),e.jsx("div",{className:u?`workbench-modal-body ${u}`:"workbench-modal-body",children:g}),b?e.jsx("div",{className:"workbench-modal-footer",children:b}):null]})]}),document.body)}export{R as D,O as M};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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 c,m as F,_ as q,j as t,t as d}from"./index-
|
|
2
|
+
import{b as c,m as F,_ as q,j as t,t as d}from"./index-CFyk1rgJ.js";import{r as O,u as C,W as _,m as I,F as $,g as A}from"./WorkbenchLayout-DD8b-m2G.js";import{FileContextPanel as U}from"./FileContextPanel-DrYWcTkp.js";import{GitSidebar as V}from"./GitSidebar-CQsfJqun.js";import{TerminalManagerPanel as z}from"./TerminalManagerPanel-DiVhBQhf.js";import{TerminalPage as B}from"./TerminalPage-DUMUO7Ng.js";import{b as H,a as K}from"./workbench-navigation-DoDaQR4z.js";import{c as J,u as Q,e as X,N as W}from"./App-BxX5mm9o.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./DesktopModal-BxsogpLf.js";import"./WorkbenchModal-CsZeLArg.js";import"./relay-entry-C8k5qsl5.js";import"./MobileSheet-C5IVmUsO.js";import"./terminal-runtime-meta-okQIDzfA.js";import"./TerminalRuntimeFallbackModal-DGPR_CMh.js";import"./MobileWorkspaceSwitcherHeader-BC8MMQs_.js";import"./MobileTopHeaderFrame-EoBm3-X0.js";function Y(n){return{navigationGroups:n,subscribeFileTree:()=>{},requestFileTreeRefresh:()=>{},addFileTreeSnapshotListener:()=>()=>{},subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function Z(){return{subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function ee(){return{subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function re(n,a){return{navigationGroups:a,currentWorkspaceId:n,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function x(n){return n.kind==="file-preview"?d("conversation.fileViewerWindowTitle"):n.kind==="files"?d("shell.filesEntry"):n.kind==="git"?d("shell.gitEntry"):n.kind==="processes"?d("shell.terminalManagerEntry"):n.kind==="terminals"?d("shell.terminalsEntry"):n.kind==="affairs"?d("shell.workbenchModeAffairs"):n.kind==="code"?d("shell.workbenchModeCode"):n.kind}function T(n,a){var s;return n.workspaceName??(n.workspaceId?((s=a.find(o=>o.workspace.id===n.workspaceId))==null?void 0:s.workspace.name)??null:null)}function j(n){const a=(n==null?void 0:n.trim().replace(/\\/g,"/"))??"";return a?a.split("/").filter(Boolean).at(-1)??a:null}function ne(n){var o,l;const a=((o=n.payload.routePath)==null?void 0:o.trim())??"";if(a)return a;const s=((l=n.workspaceId)==null?void 0:l.trim())??"";return s?H(s):null}function te(n){var o,l;const a=((o=n.payload.routePath)==null?void 0:o.trim())??"";return a||(((l=n.workspaceId)==null?void 0:l.trim())??""?K():null)}function ie(n,a){const s=T(n,a);if(n.kind==="file-preview"){const l=j(n.payload.filePath)??x(n);return s?`${l}(${s})`:l}const o=x(n);return s?`CodingNS - ${o}(${s})`:`CodingNS - ${o}`}function xe(){var N;const{windowId:n}=J(),a=Q(),s=X(),o=O(s),l=C(i=>i.sessionDisplaySortMode),[e,b]=c.useState(null),[D,w]=c.useState(!0),[M,v]=c.useState(null),[u,f]=c.useState([]),[r,S]=c.useState(null);c.useEffect(()=>{let i=!1;async function p(){if(!n){b(null),w(!1),v(d("desktopWindow.invalidWindowId"));return}w(!0),v(null);const h=await s.bridge.getWindowDescriptor(n),g=h.ok?h.value??null:s.windows.getDescriptor(n);if(!i){if(!g){b(null),w(!1),v(h.detail??d("desktopWindow.loadDescriptorFailed"));return}s.windows.registerDescriptor(g),s.windows.markWindowOpen(g.windowId),b(g),w(!1)}}return p(),()=>{i=!0}},[s,n]),c.useEffect(()=>{if(!(e!=null&&e.workspaceId)){f([]);return}let i=!1;async function p(){try{const h=await A();if(i)return;f(I(h,l))}catch{if(i)return;f([])}}return p(),()=>{i=!0}},[e==null?void 0:e.workspaceId,l]),c.useEffect(()=>{if(!e){S(null);return}const i=new _({onConnectionChange:()=>{},onSnapshot:p=>{f(I(p,l))},onUnauthorized:()=>{F.clear(),a(`/login?returnTo=${encodeURIComponent(`/desktop-window/${e.windowId}`)}`,{replace:!0})}});return S(i),i.start(),()=>{i.close(),S(null)}},[e,a,l]),c.useEffect(()=>{if(!s.isDesktop||!s.bridge.supported||!e||e.mode!=="external")return;const i=ie(e,u);document.title=i,q(async()=>{const{getCurrentWindow:p}=await import("./window-BVUB8gMK.js").then(h=>h.w);return{getCurrentWindow:p}},__vite__mapDeps([0,1])).then(({getCurrentWindow:p})=>p().setTitle(i)).catch(()=>{})},[e,u,s.bridge.supported,s.isDesktop]);const R=c.useMemo(()=>r?{navigationGroups:u,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)}:Y(u),[u,r]),G=c.useMemo(()=>r?{subscribeGitSnapshot:r.subscribeGit.bind(r),requestGitRefresh:r.requestGitRefresh.bind(r),addGitSnapshotListener:r.addGitSnapshotListener.bind(r)}:Z(),[r]),P=c.useMemo(()=>r?{subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:ee(),[r]),y=c.useMemo(()=>r?{navigationGroups:u,currentWorkspaceId:(e==null?void 0:e.workspaceId)??null,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:re((e==null?void 0:e.workspaceId)??null,u),[e==null?void 0:e.workspaceId,u,r]);if(!s.isDesktop)return t.jsx(W,{to:"/",replace:!0});if(D)return t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:d("common.loading")})});if(M)return t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:M})});if(!e)return t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:d("desktopWindow.loadDescriptorFailed")})});if(e.kind==="code"){const i=ne(e);return i?t.jsx(W,{to:i,replace:!0}):t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:d("desktopWindow.invalidCodeTarget")})})}if(e.kind==="affairs"){const i=te(e);return i?t.jsx(W,{to:i,replace:!0}):t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:d("desktopWindow.invalidAffairsTarget")})})}let m=null;if(e.kind==="file-preview"){const i=((N=e.payload.filePath)==null?void 0:N.trim())??"";T(e,u),m=i?t.jsx($,{workspaceId:e.workspaceId,filePath:i,open:!0,chrome:"window",windowTitle:j(i)??i,onClose:()=>void s.bridge.setWindowState("close"),onSaved:()=>{}}):t.jsx("p",{className:"status-text",children:d("desktopWindow.invalidFilePreviewTarget")})}else e.kind==="files"?m=t.jsx(U,{sessionId:e.sessionId,workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:R}):e.kind==="git"?m=t.jsx(V,{workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:G}):e.kind==="processes"?m=t.jsx(z,{currentWorkspaceId:e.workspaceId,navigationGroups:u,externalWindowMode:!0,workbenchShellOverrides:P}):e.kind==="terminals"&&(m=t.jsx(B,{externalWindowMode:!0,externalWindowWorkspaceId:e.workspaceId,workbenchShellOverrides:y}));if(!m)return t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:d("desktopWindow.unsupportedKind",{kind:e.kind})})});const k=x(e),L=T(e,u),E=e.mode==="external"&&e.kind==="processes";return t.jsxs("main",{className:"desktop-window-page",children:[E?t.jsx("header",{className:"desktop-window-drag-header","data-window-kind":e.kind,"data-window-drag-handle":"desktop-window-drag-header","data-tauri-drag-region":o,"aria-label":k,children:t.jsxs("div",{className:"desktop-window-drag-header-copy","data-tauri-drag-region":o,children:[t.jsx("span",{className:"desktop-window-drag-header-tag","data-tauri-drag-region":o,children:k}),t.jsx("strong",{"data-tauri-drag-region":o,children:L??k})]})}):null,t.jsx("div",{className:"desktop-window-body","data-window-kind":e.kind,"aria-label":k,children:m})]})}export{xe as DesktopWindowPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as c,F as tn,j as i,t as r,G as ft,A as In}from"./index-_OCkVmfl.js";import{f as ei,e as _i,g as Fi}from"./App-If9gThKM.js";import{bG as Ai,bH as Li,bI as ti,bJ as nn,bK as Bi,bL as Mt,bM as Rt,b as Wi,u as $i,Y as _e,bN as Qt,bO as Oi,bP as Hi,bQ as Vi,bR as ut,bS as gt,bT as Xe,bU as Ui,bV as zi,bW as Ki,bX as Gi,bY as Xi}from"./WorkbenchLayout-D-U7ghT0.js";import{d as qi,M as Yi}from"./workbench-navigation-RyUjchbD.js";import{W as $n}from"./WorkbenchModal-xbx1o6MO.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./DesktopModal-bMdI1jEe.js";import"./relay-entry-B5GmiOrR.js";import"./MobileSheet-BXvQPkxt.js";async function Nt(t,n){const[l,s]=await Promise.all([Ai(n),Li(t)]);return Ji(l.changes,s.items)}function Ji(t,n){const l=new Set(n.map(s=>Et(s.path)));return t.filter(s=>l.has(Et(s.path))||s.oldPath!==null&&l.has(Et(s.oldPath)))}function Qi(t){const n=On("","");for(const l of t){const s=Et(l.path),m=s.split("/").filter(Boolean);let h=n;m.forEach((b,x)=>{const j=m.slice(0,x+1).join("/");if(x===m.length-1){h.children.set(`file:${j}`,{kind:"file",name:b,path:s,change:l});return}const _=`directory:${j}`,M=h.children.get(_);if(M&&M.kind==="directory"){h=M;return}const Z=On(b,j);h.children.set(_,Z),h=Z})}return ai(ii([...n.children.values()]))}function ni(t,n){const l=t.oldPath?`${t.oldPath} -> ${t.path}`:t.path;return ln(t)?`${l} ${n}`:l}function ln(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 On(t,n){return{kind:"directory",name:t,path:n,children:new Map}}function ii(t){return[...t].sort((n,l)=>n.kind!==l.kind?n.kind==="directory"?-1:1:n.name.localeCompare(l.name,"zh-CN")).map(n=>n.kind==="directory"?{kind:"directory",name:n.name,path:n.path,children:ii([...n.children.values()])}:n)}function ai(t){return t.map(n=>{var b;if(n.kind!=="directory")return n;const l=ai(n.children);let s=n.name,m=n.path,h=l;for(;h.length===1&&((b=h[0])==null?void 0:b.kind)==="directory";){const x=h[0];s=`${s}/${x.name}`,m=x.path,h=x.children}return{kind:"directory",name:s,path:m,children:h}})}const Zi=450,Ii=60*1e3,Hn=20,Vn=16;function ea({sessionId:t,workspaceId:n,showSystemFiles:l,selectedPath:s,refreshVersion:m,onCountChange:h,onSelectFile:b,onOpenFile:x}){const[j,_]=c.useState("tree"),[M,Z]=c.useState([]),[ye,K]=c.useState(!0),[xe,ge]=c.useState(!1),[G,ht]=c.useState([]),E=c.useRef(null),_t=ti(),{showToast:Ne}=ei();c.useEffect(()=>{const p=tn(Ct(n,t),Ii);_("tree"),Z(p??[]),K(p===null),ge(!1),ht([]),E.current=null},[t,n]),c.useEffect(()=>{let p=!1;async function w(){K(!0);try{const v=await Nt(t,n);p||(Z(v),ft(Ct(n,t),v))}catch(v){p||Ne({title:Zt(v,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{p||K(!1)}}return w(),()=>{p=!0}},[m,t,Ne,n]);async function De(){K(!0);try{const p=await Nt(t,n);Z(p),ft(Ct(n,t),p)}catch(p){Ne({title:Zt(p,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{K(!1)}}async function D(){if(R.length!==0){ge(!0);try{await Bi(n,R.map(w=>w.path));const p=await Nt(t,n);Z(p),ft(Ct(n,t),p),Ne({title:r("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(p){Ne({title:Zt(p,r("git.stageFailed")),tone:"error"})}finally{ge(!1)}}}function F(p){ht(w=>w.includes(p)?w.filter(v=>v!==p):[...w,p])}function X(p){const w=Date.now(),v=E.current;return E.current={filePath:p,timestamp:w},(v==null?void 0:v.filePath)===p&&w-v.timestamp<=Zi}async function $(p,w){if(w&&X(p)){await x(p),E.current=null;return}w||(E.current=null),await b(p)}const ie=c.useMemo(()=>nn(M,p=>Dt(p.path),l),[M,l]),R=ie.filter(p=>!p.staged),Fe=Qi(ie),ae=new Set(G);return c.useEffect(()=>{h==null||h(ie.length)},[h,ie.length]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"file-panel-session-toolbar",children:[i.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":r("conversation.filePanelSessionViewLabel"),children:[i.jsx("button",{className:j==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":j==="tree",onClick:()=>_("tree"),children:r("conversation.filePanelSessionTreeView")}),i.jsx("button",{className:j==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":j==="list",onClick:()=>_("list"),children:r("conversation.filePanelSessionListView")})]}),i.jsxs("div",{className:"file-panel-session-actions",children:[i.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void De(),disabled:ye||xe,children:r("conversation.filePanelRefresh")}),i.jsx("button",{className:"primary-button",type:"button",onClick:()=>void D(),disabled:xe||R.length===0,children:r("conversation.filePanelSessionStageAll")})]})]}),i.jsxs("div",{className:"file-panel-session-summary",children:[i.jsx("span",{children:`${r("conversation.filePanelSessionSummary")} ${ie.length}`}),i.jsx("span",{children:`${r("conversation.filePanelSessionUnstagedSummary")} ${R.length}`})]}),i.jsx("div",{ref:_t,className:"file-tree","data-scrollbar-autohide":"true",children:ye?i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionLoading")}):ie.length===0?i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionEmpty")}):j==="tree"?li({nodes:Fe,depth:0,collapsedPathSet:ae,selectedPath:s,onToggleTreePath:F,onFileClick:$}):ta({items:ie,selectedPath:s,onFileClick:$})})]})}function li({nodes:t,depth:n,collapsedPathSet:l,selectedPath:s,onToggleTreePath:m,onFileClick:h}){return t.map(b=>{if(b.kind==="directory"){const x=!l.has(b.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":x,style:{paddingInlineStart:`${Hn+n*Vn}px`},onClick:()=>m(b.path),children:[i.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:x?"v":">"}),i.jsx("span",{className:"file-tree-label",children:b.name})]}),x?i.jsx("div",{className:"file-tree-children",children:li({nodes:b.children,depth:n+1,collapsedPathSet:l,selectedPath:s,onToggleTreePath:m,onFileClick:h})}):null]},`session-directory:${b.path}`)}return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":s===b.change.path,"data-kind":"file",style:{paddingInlineStart:`${Hn+n*Vn}px`},onClick:()=>void h(b.change.path,!ln(b.change)),children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),i.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(b.name),"aria-hidden":"true",children:Mt(b.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:b.name}),i.jsx("span",{className:"file-tree-path",children:ni(b.change,r("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":b.change.status,children:b.change.status}),i.jsx("span",{className:"file-session-badge subtle",children:b.change.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-file:${b.path}`)})}function ta({items:t,selectedPath:n,onFileClick:l}){return t.map(s=>i.jsx("div",{className:"file-session-list-item",children:i.jsxs("button",{className:"file-session-list-button",type:"button","data-active":n===s.path,onClick:()=>void l(s.path,!ln(s)),children:[i.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(Dt(s.path)),"aria-hidden":"true",children:Mt(Dt(s.path))}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:Dt(s.path)}),i.jsx("span",{className:"file-tree-path",children:ni(s,r("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":s.status,children:s.status}),i.jsx("span",{className:"file-session-badge subtle",children:s.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-list:${s.path}`))}function Ct(t,n){return`file-panel.session-changes.${t}.${n}`}function Zt(t,n){return t instanceof In?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??n):n}const g="",na=450,ne=8,Pt=4,ia=176,aa=120,la=300*1e3,oa=60*1e3,Un=1600,ra=220,sa=20,ca=16;function ua(){if(typeof document>"u")return;const t=document.querySelector(".workbench-modal-card.file-viewer-modal"),n=t==null?void 0:t.getBoundingClientRect();if(!(!n||n.width<=0||n.height<=0))return{width:Math.round(n.width),height:Math.round(n.height),minWidth:720,minHeight:480}}function nl({className:t,sessionId:n,workspaceId:l,hideHeading:s=!1,hideTabs:m=!1,externalRevealRequest:h=null,externalWindowMode:b=!1,workbenchShellOverrides:x}){var Ln,Bn;const j=Wi(),{navigationGroups:_,subscribeFileTree:M,requestFileTreeRefresh:Z,addFileTreeSnapshotListener:ye,subscribeGitSnapshot:K,requestGitRefresh:xe,addGitSnapshotListener:ge}={...j,...x},[G,ht]=c.useState({}),[E,_t]=c.useState([]),[Ne,De]=c.useState([]),[D,F]=c.useState(g),[X,$]=c.useState([]),[ie,R]=c.useState(null),[Fe,ae]=c.useState(!1),[p,w]=c.useState(!1),[v,mt]=c.useState(!1),[Ye,Je]=c.useState(!1),[A,Qe]=c.useState(""),[Ft,q]=c.useState(null),[pt,bt]=c.useState(!1),[le,Ae]=c.useState(null),[O,Ze]=c.useState("workspace"),[rn,Ee]=c.useState(0),[sn,At]=c.useState(0),[Ie,I]=c.useState(!1),[et,L]=c.useState(!1),[oe,H]=c.useState(null),[Ce,Le]=c.useState(null),[B,Be]=c.useState(null),[C,Lt]=c.useState(null),[S,tt]=c.useState(null),[Bt,We]=c.useState(""),[cn,un]=c.useState([]),[ee,Wt]=c.useState(!1),[hi,re]=c.useState(null),fn=c.useId(),se=c.useRef({}),Y=c.useRef({}),T=c.useRef([]),te=c.useRef(g),nt=c.useRef(!1),it=c.useRef(null),mi=ti(),dn=c.useRef(null),hn=c.useRef(null),$t=c.useRef(null),mn=c.useRef(null),pn=c.useRef(null),ce=c.useRef(0),ue=c.useRef(new Map),{showToast:P}=ei(),Pe=_i(),V=$i(e=>e.showSystemFiles),$e=!!(n!=null&&n.trim()),bn=s&&Pe.isMobile;c.useEffect(()=>{_e("file_panel.props",{sessionId:n,workspaceId:l,externalWindowMode:b})},[b,n,l]),c.useEffect(()=>{te.current=D},[D]);function Ot(e){At(e),!(!l||!n)&&ft(Yn(l,n),e)}async function vn(){if(!l||!n){Ot(0);return}const e=await Nt(n,l),a=nn(e,o=>ut(o.path),V).length;Ot(a)}function ke(e){ht(a=>{const o=typeof e=="function"?e(a):e;return se.current=o,o})}function Oe(e){_t(a=>{const o=typeof e=="function"?e(a):e;return T.current=o,o})}c.useEffect(()=>{var f,d;if(zt(),!l){zt(),nt.current=!1,se.current={},Y.current={},T.current=[],te.current=g,ke({}),Oe([]),De([]),F(g),Je(!1),Qe(""),q(null),bt(!1),ae(!1),Wt(!1),re(null),$([]),R(null),H(null),Le(null),Be(null),tt(null),We("");return}nt.current=!0;const e=tn(qn(l),la);_e("file_panel.workspace_snapshot",{workspaceId:l,cached:!!e,cachedRootItems:((d=(f=e==null?void 0:e.treeCache)==null?void 0:f[g])==null?void 0:d.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const a=Ea((e==null?void 0:e.activeDirectoryPath)??g,(e==null?void 0:e.treeCache)??{}),o=Xn((e==null?void 0:e.expandedDirectories)??[],a),u=St((e==null?void 0:e.treeCache)??{},a,o);se.current=u,Y.current=Jn((e==null?void 0:e.treeRevisionByPath)??{},u),T.current=o,te.current=a,ke(u),Oe(o),De([]),F(a),ae(!1),w(!1),Je(!1),Qe(""),q(null),bt(!1),queueMicrotask(()=>{nt.current=!1})},[l]),c.useEffect(()=>{if(!h||h.workspaceId!==l)return;const e=()=>{if(pn.current===h.requestId)return;pn.current=h.requestId,Ze("workspace"),(h.openViewer?ze(h.filePath):he(h.filePath)).catch(o=>{P({title:Q(o,r("conversation.filePanelOpenFailed")),tone:"error"})})};if(nt.current){queueMicrotask(e);return}e()},[h,ze,he,P,l]),c.useEffect(()=>{if(l)return ye(e=>{e.workspaceId===l&&(Y.current={...Y.current,[e.path]:typeof e.revision=="string"?e.revision:null},ke(a=>({...a,[e.path]:e.items})),e.path===g&&ae(!1),De(a=>a.filter(o=>o!==e.path)),wn(e.path,e.items))})},[ye,l]),c.useEffect(()=>()=>{zt()},[]),c.useEffect(()=>{l&&M(l,en(T.current,te.current),{knownRevisionByPath:Y.current})},[D,E,M,l]),c.useEffect(()=>{$([]),R(null),Ae(null),re(null),Ee(0),I(!1),L(!1),H(null),Le(null),Be(null),tt(null),We(""),it.current=null,ce.current+=1},[n]),c.useEffect(()=>{!$e&&O==="session"&&Ze("workspace")},[O,$e]),c.useEffect(()=>{m&&O!=="workspace"&&Ze("workspace")},[O,m]),c.useEffect(()=>{if(!Ie&&!et&&!oe)return;function e(o){var y,N,pe;if(!(o.target instanceof Node))return;const u=((y=dn.current)==null?void 0:y.contains(o.target))??!1,f=((N=hn.current)==null?void 0:N.contains(o.target))??!1,d=((pe=$t.current)==null?void 0:pe.contains(o.target))??!1;!u&&!f&&!d&&(I(!1),L(!1),H(null),Le(null))}function a(o){o.key==="Escape"&&(I(!1),L(!1),H(null),Le(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",a)}},[Ie,et,oe]),c.useLayoutEffect(()=>{if(!oe||typeof window>"u"){Le(null);return}const e=oe;function a(){const u=$t.current;if(!u)return;const f=u.getBoundingClientRect();Le(ya({x:e.positionX,y:e.positionY},{width:f.width||ia,height:f.height||u.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}a();const o=window.requestAnimationFrame(a);return window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{window.cancelAnimationFrame(o),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}},[oe]),c.useEffect(()=>{if(!l)return;const e=Xn(E,D),a=St(G,D,e);ft(qn(l),{treeCache:a,treeRevisionByPath:Jn(Y.current,a),expandedDirectories:e,activeDirectoryPath:D})},[D,E,G,l]),c.useEffect(()=>{if(nt.current)return;const e=St(G,D,E);Ma(G,e)||ke(e)},[D,E,G]),c.useEffect(()=>{let e=!1;const a=(l==null?void 0:l.trim())??null;async function o(f){if(!a)return;const d=Qt(se.current[g]??[],V),y=(f==null?void 0:f.silent)!==!0&&d.length===0;y&&ae(!0),_e("file_panel.load_root_tree.start",{sessionId:n,workspaceId:a,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:d.length});try{const N=await Ut(g,{force:!0});e||(_e("file_panel.load_root_tree.end",{sessionId:n,workspaceId:a,itemCount:N.length}),ke(pe=>({...St(pe,te.current,T.current),[g]:N})))}catch(N){!e&&!Qn(N)&&P({title:Q(N,r("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&y&&ae(!1)}}if(Qt(se.current[g]??[],V).length>0){const f=window.setTimeout(()=>{a&&(M(a,en(T.current,te.current),{knownRevisionByPath:Y.current}),o({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return o(),()=>{e=!0}},[n,V,P,l]),c.useEffect(()=>{if(!l||!n){At(0);return}const e=tn(Yn(l,n),oa);_e("file_panel.session_change_count.snapshot",{sessionId:n,workspaceId:l,cached:e!==null,cachedCount:e}),At(e??0);let a=!1;return vn().catch(()=>{}),()=>{a=!0}},[n,rn,V,l]),c.useEffect(()=>{if(!l){un([]);return}const e=l.trim();K(e),xe(e)},[l,K,xe]),c.useEffect(()=>{if(!l)return;const e=l.trim();return ge(a=>{var o;a.workspaceId===e&&un(((o=a.status)==null?void 0:o.changes)??[])})},[ge,l]);const vt=c.useMemo(()=>nn(cn,e=>ut(e.path),V),[cn,V]),W=c.useMemo(()=>{const e=new Map,a=new Set;for(const o of vt){const u=o.path.replace(/\\/g,"/"),f=o.worktreeStatus??o.stagedStatus??o.status;e.set(u,f);const d=u.split("/");for(let y=1;y<d.length;y++)a.add(d.slice(0,y).join("/"))}return{statusByPath:e,changedDirs:a}},[vt]),Me=c.useMemo(()=>Oi(G,V),[V,G]),Re=c.useMemo(()=>Ft===null?null:Qt(Ft,V),[Ft,V]),He=Me[g]??[],fe=Ye&&Re!==null,yt=c.useMemo(()=>ee?an(He,Me,W.statusByPath,W.changedDirs):He,[W.changedDirs,W.statusByPath,He,ee,Me]),pi=c.useMemo(()=>fe?(Re??[]).map(e=>z(e.path,e.kind)):oi(yt,Me,E,ee,W.statusByPath,W.changedDirs),[E,W.changedDirs,W.statusByPath,fe,ee,Re,Me,yt]),de=((Ln=_.find(e=>e.workspace.id===l))==null?void 0:Ln.workspace)??null,k=Gn(X),Ht=(k==null?void 0:k.path)??null,je=(k==null?void 0:k.kind)==="file"?k.path:null,xt=c.useMemo(()=>new Set(X.map(e=>e.path)),[X]),at=c.useMemo(()=>wt(X),[X]),Vt=!!(de!=null&&de.path&&X.length===1&&Ht),yn=X.length===1&&(k==null?void 0:k.kind)==="file",xn=at.length>0,Te=at.length>0,lt=!!(C!=null&&C.items.length&&l),gn=!!l&&X.length===1&&k!==null,Cn=!!((je?ve(je):D)&&E.length),Pn=C?C.mode==="copy"?r("conversation.filePanelClipboardCopyReady",{count:C.items.length}):r("conversation.filePanelClipboardCutReady",{count:C.items.length}):null,U=S?Pa(S):null;async function jn(e,a=!1){if(!l)return[];if(!a){const o=se.current[e];if(o)return o}e===g?ae(!0):De(o=>kt(o,e));try{const o=await Ut(e,{force:a});return ke(u=>({...u,[e]:o})),o}catch(o){throw Qn(o)||P({title:Q(o,r("conversation.filePanelLoadFailed")),tone:"error"}),o}finally{e===g?ae(!1):De(o=>o.filter(u=>u!==e))}}async function we(e){if(!l)return;const a=(e==null?void 0:e.activeDirectoryPath)??te.current,o=(e==null?void 0:e.expandedDirectories)??T.current,u=ka(se.current,a,o);_e("file_panel.refresh_tree_cache.start",{sessionId:n,workspaceId:l,targetDirectories:u});const d=(await Promise.all(u.map(async y=>{const N=await Ut(y,{force:!0});return[y,N]}))).reduce((y,[N,pe])=>(y[N]=pe,y),{});_e("file_panel.refresh_tree_cache.end",{sessionId:n,workspaceId:l,targetDirectories:u,directoryCount:Object.keys(d).length}),ke(d)}async function Ut(e,a){if(!l)return[];if(!(a!=null&&a.force)){const d=se.current[e];if(d)return d}const o=en(kt(T.current,e),e||te.current);M(l,o,{knownRevisionByPath:Y.current}),Z(l,[e],{knownRevisionByPath:Y.current});const u=bi(e,Un,{allowCached:(a==null?void 0:a.force)!==!0}),f=Ra(ra).then(async()=>{if(!l)return[];const y=(await Gi(l,e||void 0)).items;return Y.current={...Y.current,[e]:null},wn(e,y),y});try{return await Promise.race([u,f])}catch(d){if(!fi(d))throw d;return await f}}function bi(e,a=Un,o){const u=se.current[e];return(o==null?void 0:o.allowCached)!==!1&&u?Promise.resolve(u):new Promise((f,d)=>{const y=window.setTimeout(()=>{vi(e,y),d(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},a),N=ue.current.get(e)??[];ue.current.set(e,[...N,{resolve:f,reject:d,timerId:y}])})}function wn(e,a){const o=ue.current.get(e)??[];o.length!==0&&(ue.current.delete(e),o.forEach(u=>{window.clearTimeout(u.timerId),u.resolve(a)}))}function vi(e,a){const u=(ue.current.get(e)??[]).filter(f=>f.timerId!==a);if(u.length===0){ue.current.delete(e);return}ue.current.set(e,u)}function zt(){for(const[e,a]of ue.current.entries())a.forEach(o=>{window.clearTimeout(o.timerId),o.reject(new Error(`FILE_TREE_ABORTED:${e}`))});ue.current.clear()}function Ve(e){$([e]),R(e.path)}function ot(e){F(e.kind==="directory"?e.path:ve(e.path))}function yi(e){const a=ha(pi,ie,e);$(a),R(e.path),ot(e)}function xi(e){const a=da(X,e),o=Gn(a);$(a),R(e.path),o&&ot(o)}function Sn(e){Ve(e),ot(e)}function Ue(e,a){if(a!=null&&a.shiftKey){yi(e);return}if(jt(a)){xi(e);return}Sn(e)}async function rt(e,a=!1){const o=dt(e,a);if(!o.length){F(g);return}Oe(u=>ui(u,o)),F(o[o.length-1]??g);for(const u of o)try{await jn(u)}catch{return}}async function he(e){const a=z(e,"file");Ve(a),ot(a),await rt(e)}async function ze(e){Ae(e),re(null),it.current=null,ce.current+=1,he(e),await gi(e)}async function gi(e){const a=ce.current,o=e.replace(/\\/g,"/"),u=W.statusByPath.get(o);if(l&&u&&u!=="?"&&u!=="D")try{const f=await Hi(l,e,!1);ce.current===a&&re(f.content||null)}catch{ce.current===a&&re(null)}}async function Ci(e){if(!l)return;const a=ua(),o=await Ui(Pe,{workspaceId:l,workspaceName:(de==null?void 0:de.name)??null,sessionId:n??null,filePath:e,bounds:a});if(!o.ok){P({title:o.detail??r("conversation.fileViewerOpenInWindowFailed"),tone:"error"});return}ce.current+=1,Ae(null),re(null)}function Nn(e){const a=Date.now(),o=it.current;return it.current={filePath:e,timestamp:a},(o==null?void 0:o.filePath)===e&&a-o.timestamp<=na}function Se(){it.current=null}async function Pi(e,a){const o=z(e,"file");if(a!=null&&a.shiftKey||jt(a)){Se(),Ue(o,a);return}if(Nn(e)){await ze(e);return}Ue(o,a),await rt(e)}function Dn(){Je(!1),Qe(""),q(null),Se()}async function ji(e,a){const o=z(e.path,e.kind);if(a!=null&&a.shiftKey||jt(a)){Se(),Ue(o,a);return}if(e.kind==="directory"){Dn(),Ue(o,a),await En(e.path);return}if(Nn(e.path)){Dn(),await ze(e.path);return}await he(e.path)}async function En(e){if(Ve(z(e,"directory")),F(e),!T.current.includes(e))try{await jn(e),Oe(a=>kt(a,e))}catch{}}async function kn(e){if(Ve(z(e,"directory")),F(e),T.current.includes(e)){Mn(e);return}await En(e)}function Mn(e){Oe(a=>a.filter(o=>o!==e&&!o.startsWith(`${e}/`))),F(ve(e)),$([]),R(null)}async function Rn(){if(!l)return;const e=l;try{if(xe(e),await we(),je&&await rt(je),fe&&A.trim()){const a=await Xe(e,A.trim());q(a.items)}if($e&&n)if(O==="session")Ee(a=>a+1);else try{await vn()}catch(a){P({title:Q(a,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}}catch(a){P({title:Q(a,r("conversation.filePanelLoadFailed")),tone:"error"})}}async function wi(e){if(e==null||e.preventDefault(),!l||!A.trim()){q(null);return}bt(!0);try{const a=await Xe(l,A.trim());q(a.items)}catch(a){P({title:Q(a,r("conversation.filePanelSearchFailed")),tone:"error"})}finally{bt(!1)}}function Tn(){if(Ye){Je(!1),Qe(""),q(null);return}Je(!0)}function J(e){L(!1),e()}function _n(){var e;(e=mn.current)==null||e.click()}async function Si(e){var d;const a=((d=e.target.files)==null?void 0:d[0])??null;if(e.target.value="",!a||!l)return;const o=fa(a.name);if(!o){P({title:r("conversation.filePanelUploadFailed"),tone:"error"});return}const u=zn(D,k),f=Kn(u,o);mt(!0);try{const y=await ja(a);await zi({workspaceId:l,path:f,contentBase64:y}),await we(),await he(f),P({title:r("conversation.filePanelUploadSuccess",{name:o}),tone:"success"})}catch(y){P({title:Q(y,r("conversation.filePanelUploadFailed")),tone:"error"})}finally{mt(!1)}}async function Kt(e=je){if(!(!l||!e)){mt(!0);try{const a=await Ki(l,e),o=wa(a.contentBase64);Sa(a.fileName,new Blob([o],{type:"application/octet-stream"})),P({title:r("conversation.filePanelDownloadSuccess",{name:a.fileName}),tone:"success"})}catch(a){P({title:Q(a,r("conversation.filePanelDownloadFailed")),tone:"error"})}finally{mt(!1)}}}function Fn(){const e=je?ve(je):D;!e||!T.current.includes(e)||Mn(e)}function Gt(){tt(null),We("")}function Xt(){p||Gt()}function Ke(e,a=zn(D,k)){if(!l)return;const o=a,u=o?`${o}/`:"";I(!1),L(!1),H(null),tt({mode:e,baseDirectory:o}),We(u)}function qt(e=k){!l||!e||(I(!1),L(!1),H(null),tt({mode:"rename",target:e}),We(e.path))}async function Ni(e){if(e==null||e.preventDefault(),!l||!S)return;const a=(Bt??"").trim();if(a){if(S.mode==="rename"&&qe(S.target.path)===qe(a)){Xt();return}w(!0);try{if(S.mode==="rename"){const o=S.target.path,u=z(a,S.target.kind),f=le?ci(le,o,a):null;if(await gt({workspaceId:l,opType:"rename",srcPath:o,dstPath:a}),C&&Lt({...C,items:Ca(C.items,o,a)}),Gt(),Se(),await we(),S.target.kind==="directory"?(await rt(a,!0),Ve(u),F(a)):await he(a),f!==le&&(ce.current+=1,Ae(f),re(null)),fe&&A.trim()){const d=await Xe(l,A.trim());q(d.items)}Ee(d=>d+1),P({title:r("conversation.filePanelRenameSuccess",{name:ut(a)||a}),tone:"success"});return}if(await gt({workspaceId:l,opType:S.mode,dstPath:a,content:S.mode==="create_file"?"":void 0}),Gt(),await we(),S.mode==="create_directory"?(await rt(a,!0),Ve(z(a,"directory")),F(a)):await he(a),fe&&A.trim()){const o=await Xe(l,A.trim());q(o.items)}Ee(o=>o+1)}catch(o){P({title:Q(o,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}}function me(e,a=at){var u;if(a.length===0)return;const o=wt(a);Lt({mode:e,items:o}),$(o),R(((u=o[o.length-1])==null?void 0:u.path)??null),P({title:e==="copy"?r("conversation.filePanelCopySelectionSuccess",{count:o.length}):r("conversation.filePanelCutSelectionSuccess",{count:o.length}),tone:"success"}),H(null)}async function st(e=ba(k,D)){if(!l||!C||!C.items.length)return;const a=e??g,o=C.items.map(u=>({source:u,destinationPath:Kn(a,ut(u.path)||u.path)}));w(!0);try{for(const d of o)C.mode==="cut"&&qe(d.source.path)===qe(d.destinationPath)||await gt({workspaceId:l,opType:C.mode==="copy"?"copy":"move",srcPath:d.source.path,dstPath:d.destinationPath});const u=o.map(d=>z(d.destinationPath,d.source.kind)),f=u[u.length-1]??null;if(C.mode==="cut"&&Lt(null),$(u),R((f==null?void 0:f.path)??null),f&&ot(f),Se(),await we({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?ve(f.path):te.current,expandedDirectories:T.current}),fe&&A.trim()){const d=await Xe(l,A.trim());q(d.items)}Ee(d=>d+1),P({title:r("conversation.filePanelPasteSuccess",{count:u.length}),tone:"success"}),H(null)}catch(u){await we().catch(()=>{}),P({title:Q(u,r("conversation.filePanelPasteFailed")),tone:"error"})}finally{w(!1)}}function Yt(e=at){!e.length||p||(Be(wt(e)),H(null))}async function Di(){var a,o;if(!l||!(B!=null&&B.length))return;const e=wt(B);w(!0);try{for(const d of e)await gt({workspaceId:l,opType:"delete",srcPath:d.path});const u=va(D,e),f=T.current.filter(d=>!e.some(y=>y.kind==="directory"&&Tt(y.path,d)));if(le&&e.some(d=>Tt(d.path,le))&&(ce.current+=1,Ae(null),re(null)),Be(null),$([]),R(null),te.current=u,T.current=f,F(u),Oe(f),Se(),await we({activeDirectoryPath:u,expandedDirectories:f}),fe&&A.trim()){const d=await Xe(l,A.trim());q(d.items)}Ee(d=>d+1),P({title:e.length===1?r("conversation.filePanelDeleteSuccess",{name:ut(((a=e[0])==null?void 0:a.path)??"")||((o=e[0])==null?void 0:o.path)||""}):r("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(u){P({title:Q(u,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}async function Ge(e,a=k){const o=(de==null?void 0:de.path)??"",u=(a==null?void 0:a.path)??null;if(u===null||!o){I(!1);return}try{const f=ga(o),d=e==="absolute"?xa(o,u,f):qe(u,f);await Na(d,Pe),P({title:e==="absolute"?r("conversation.filePanelCopyAbsolutePathSuccess"):r("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){P({title:f instanceof Error?f.message:r("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{I(!1),H(null)}}function Ei(e,a,o){return[{id:`open-${e.path}`,label:e.kind==="directory"?E.includes(e.path)?r("conversation.filePanelCollapseDirectory"):r("conversation.filePanelExpandDirectory"):r("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){kn(e.path);return}ze(e.path)}},{id:`download-${e.path}`,label:r("conversation.filePanelDownload"),disabled:e.kind!=="file"||v,onSelect:()=>{Kt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:r("conversation.filePanelNewFile"),disabled:!l||p||v,onSelect:()=>{Ke("create_file",o)}},{id:`create-directory-${e.path}`,label:r("conversation.filePanelNewDirectory"),disabled:!l||p||v,onSelect:()=>{Ke("create_directory",o)}},{id:`rename-${e.path}`,label:r("conversation.filePanelRenameMove"),disabled:a.length!==1||p||v,onSelect:()=>qt(e)},{id:`copy-${e.path}`,label:r("conversation.filePanelCopy"),disabled:a.length===0,onSelect:()=>me("copy",a)},{id:`cut-${e.path}`,label:r("conversation.filePanelCut"),disabled:a.length===0,onSelect:()=>me("cut",a)},{id:`paste-${e.path}`,label:r("conversation.filePanelPaste"),disabled:!lt,onSelect:()=>{st(o)}},{id:`copy-relative-${e.path}`,label:r("conversation.filePanelCopyRelativePath"),onSelect:()=>{Ge("relative",e)}},{id:`copy-absolute-${e.path}`,label:r("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{Ge("absolute",e)}},{id:`delete-${e.path}`,label:r("conversation.filePanelDelete"),disabled:a.length===0||p||v,onSelect:()=>Yt(a)}]}async function An(e,a){if(Pe.isMobile)return;e.preventDefault();const o=z(a.path,a.kind),u=xt.has(o.path)?at:[o],f=o.kind==="directory"?o.path:ve(o.path);xt.has(o.path)||Sn(o);const d=Ei(o,u,f);if(Pe.isDesktop){await Xi(d);return}Pe.isWeb&&(I(!1),L(!1),H({positionX:e.clientX,positionY:e.clientY,items:d}))}c.useEffect(()=>{if(O!=="workspace")return;function e(a){if(!ma(a)||a.altKey||a.shiftKey||pa(a.target))return;const o=a.key.toLowerCase();if(o==="c"&&Te){a.preventDefault(),me("copy");return}if(o==="x"&&Te){a.preventDefault(),me("cut");return}o==="v"&<&&(a.preventDefault(),st())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[O,Te,lt,me,st]);function Jt(e,a){return i.jsx(i.Fragment,{children:e.map(o=>{const u=z(o.path,o.kind),f=o.kind==="directory",d=f&&E.includes(o.path),y=f&&Ne.includes(o.path),N=Me[o.path]??[],pe=ee?an(N,Me,W.statusByPath,W.changedDirs):N,Mi=xt.has(o.path),Ri=Ht===o.path,ct=W.statusByPath.get(o.path.replace(/\\/g,"/")),Wn=f&&W.changedDirs.has(o.path.replace(/\\/g,"/")),Ti=(C==null?void 0:C.mode)==="cut"&&C.items.some(be=>be.path===o.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-active":Ri,"data-selected":Mi,"data-cut-pending":Ti||void 0,"data-kind":o.kind,"aria-expanded":f?d:void 0,style:{paddingInlineStart:`${sa+a*ca}px`},onClick:be=>{if(f){if(be.shiftKey||jt(be)){Se(),Ue(u,be);return}Se(),Ue(u,be),kn(o.path);return}Pi(o.path,be)},onContextMenu:be=>{An(be,o)},children:[i.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:d?"v":">"}),f?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(o.name),"aria-hidden":"true",children:Mt(o.name)}),i.jsx("span",{className:"file-tree-label","data-status":ct??void 0,"data-has-changes":Wn||void 0,children:o.name}),!f&&ct?i.jsx("span",{className:"git-status-badge","data-status":ct,"aria-label":ct,children:ct}):null,f&&Wn?i.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,y?i.jsx("span",{className:"file-tree-meta",children:r("common.loading")}):null]}),f&&d?i.jsx("div",{className:"file-tree-children",children:y&&!N.length?i.jsx("p",{className:"file-tree-empty",children:r("common.loading")}):pe.length?Jt(pe,a+1):i.jsx("p",{className:"file-tree-empty",children:r("conversation.filePanelEmptyDirectory")})}):null]},`${o.kind}-${o.path}`)})})}function ki(e){return i.jsx(i.Fragment,{children:e.map(a=>{const o=a.kind==="directory",u=xt.has(a.path),f=Ht===a.path;return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":f,"data-selected":u,"data-kind":a.kind,onClick:d=>{ji(a,d)},onContextMenu:d=>{An(d,a)},children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),o?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(a.name),"aria-hidden":"true",children:Mt(a.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:a.name}),i.jsx("span",{className:"file-tree-path",children:a.path})]})]})},`search-${a.kind}-${a.path}`)})})}return i.jsx("section",{className:["conversation-panel","surface-card","file-panel",t].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:l?i.jsxs(i.Fragment,{children:[i.jsx(Vi,{workspaceId:l,filePath:le,open:le!==null,onClose:()=>{ce.current+=1,Ae(null),re(null)},onSaved:async e=>{await we(),await he(e),Ee(a=>a+1)},diffContent:hi,showDetachAction:Pe.isDesktop&&Pe.bridge.supported,onDetach:()=>{le&&Ci(le)}}),s?null:i.jsx("div",{className:"file-panel-heading-row",children:i.jsx("h2",{className:"file-panel-heading",children:r("conversation.filePanelTitle")})}),m?null:i.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":r("conversation.filePanelTitle"),children:[i.jsx("button",{className:O==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="workspace",onClick:()=>Ze("workspace"),children:r("conversation.filePanelWorkspaceTab")}),i.jsxs("button",{className:O==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="session",onClick:()=>{$e&&Ze("session")},disabled:!$e,children:[r("conversation.filePanelSessionTab"),i.jsx("span",{className:"file-panel-tab-badge","aria-label":`${r("conversation.filePanelSessionTab")} ${sn}`,children:sn})]})]}),O==="workspace"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:mn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void Si(e)}),bn?i.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":r("conversation.filePanelTitle"),children:i.jsxs("div",{className:"file-mobile-action-shell",ref:hn,children:[i.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":r("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":et,"data-active":et,onClick:()=>{I(!1),L(e=>!e)},children:[i.jsx("span",{children:r("conversation.filePanelActionsMenu")}),i.jsx(za,{})]}),et?i.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":r("conversation.filePanelActionsMenu"),children:[i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>me("copy")),disabled:!Te,children:r("conversation.filePanelCopy")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>me("cut")),disabled:!Te,children:r("conversation.filePanelCut")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>st()),disabled:!lt||p||v,children:r("conversation.filePanelPaste")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Tn()},children:Ye?r("conversation.filePanelHideSearch"):r("conversation.filePanelShowSearch")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Wt(e=>!e)},disabled:vt.length===0,children:ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(Rn),disabled:Fe||p||pt,children:r("conversation.filePanelRefresh")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Fn()},disabled:!Cn,children:r("conversation.filePanelCollapseCurrent")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),_n()},disabled:p||v,children:r("conversation.filePanelUpload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(Kt),disabled:!yn||v,children:r("conversation.filePanelDownload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(qt),disabled:!gn||p||v,children:r("conversation.filePanelRenameMove")}),i.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>J(Yt),disabled:!xn||p||v,children:r("conversation.filePanelDelete")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>Ke("create_file")),disabled:p||v,children:r("conversation.filePanelNewFile")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>Ke("create_directory")),disabled:p||v,children:r("conversation.filePanelNewDirectory")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>Ge("absolute")),disabled:!Vt,children:r("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>J(()=>Ge("relative")),disabled:!Vt,children:r("conversation.filePanelCopyRelativePath")})]}):null]})}):i.jsxs("div",{className:"file-panel-toolbar","aria-label":r("conversation.filePanelTitle"),children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopy"),"aria-label":r("conversation.filePanelCopy"),onClick:()=>me("copy"),disabled:!Te,children:i.jsx(Aa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCut"),"aria-label":r("conversation.filePanelCut"),onClick:()=>me("cut"),disabled:!Te,children:i.jsx(La,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelPaste"),"aria-label":r("conversation.filePanelPaste"),onClick:()=>void st(),disabled:!lt||p||v,children:i.jsx(Ba,{})}),i.jsxs("div",{className:"file-toolbar-menu-shell",ref:dn,children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopyPath"),"aria-label":r("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":Ie,"data-active":Ie,onClick:()=>{L(!1),I(e=>!e)},disabled:!Vt,children:i.jsx(Fa,{})}),Ie?i.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ge("absolute"),children:r("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ge("relative"),children:r("conversation.filePanelCopyRelativePath")})]}):null]}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCollapseCurrent"),"aria-label":r("conversation.filePanelCollapseCurrent"),onClick:Fn,disabled:!Cn,children:i.jsx(Ta,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRefresh"),"aria-label":r("conversation.filePanelRefresh"),onClick:()=>void Rn(),disabled:Fe||p||pt,children:i.jsx(_a,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),"data-active":Ye,onClick:Tn,disabled:Fe,children:i.jsx(Zn,{})}),vt.length>0?i.jsx("button",{className:"file-toolbar-button",type:"button",title:ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"aria-label":ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"data-active":ee,onClick:()=>Wt(e=>!e),children:i.jsx(Ka,{})}):null,i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelUpload"),"aria-label":r("conversation.filePanelUpload"),onClick:_n,disabled:p||v,children:i.jsx($a,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelDownload"),"aria-label":r("conversation.filePanelDownload"),onClick:()=>void Kt(),disabled:!yn||v,children:i.jsx(Oa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRenameMove"),"aria-label":r("conversation.filePanelRenameMove"),onClick:()=>qt(),disabled:!gn||p||v,children:i.jsx(Ua,{})}),i.jsx("button",{className:"file-toolbar-button danger",type:"button",title:r("conversation.filePanelDelete"),"aria-label":r("conversation.filePanelDelete"),onClick:()=>Yt(),disabled:!xn||p||v,children:i.jsx(Ha,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewFile"),"aria-label":r("conversation.filePanelNewFile"),onClick:()=>void Ke("create_file"),disabled:p||v,children:i.jsx(Wa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewDirectory"),"aria-label":r("conversation.filePanelNewDirectory"),onClick:()=>void Ke("create_directory"),disabled:p||v,children:i.jsx(Va,{})})]}),oe&&typeof document<"u"?Fi.createPortal(i.jsx("div",{className:"file-web-context-menu",ref:$t,role:"menu","aria-label":r("conversation.filePanelActionsMenu"),style:{left:`${(Ce==null?void 0:Ce.left)??Math.max(8,oe.positionX)}px`,top:`${(Ce==null?void 0:Ce.top)??Math.max(8,oe.positionY)}px`,maxHeight:Ce?`${Ce.maxHeight}px`:void 0},children:oe.items.map(e=>i.jsx("button",{className:["file-web-context-menu-item",e.label===r("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,Pn?i.jsx("p",{className:"file-panel-clipboard-status","data-mode":C==null?void 0:C.mode,children:Pn}):null,Ye?i.jsxs("form",{className:"file-toolbar-search",onSubmit:e=>void wi(e),children:[i.jsx("input",{value:A,onChange:e=>Qe(e.target.value),placeholder:r("conversation.filePanelSearchPlaceholder")}),bn?i.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":r("conversation.filePanelSearchButton"),disabled:pt,children:r("conversation.filePanelSearchButton")}):i.jsx("button",{className:"file-toolbar-button",type:"submit",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),disabled:pt,children:i.jsx(Zn,{})})]}):null,i.jsx("div",{ref:mi,className:"file-tree","data-search-mode":fe,"data-scrollbar-autohide":"true",children:Fe&&He.length===0?i.jsx("p",{className:"file-tree-status status-text",children:r("common.loading")}):fe?Re!=null&&Re.length?ki(Re):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSearchEmpty")}):ee?yt.length?Jt(yt,0):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelNoChanges")}):He.length?Jt(He,0):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelEmptyDirectory")})}),i.jsx($n,{open:S!==null,title:(U==null?void 0:U.title)??"",description:U==null?void 0:U.description,onClose:Xt,children:i.jsxs("form",{className:"workbench-rename-form",onSubmit:e=>void Ni(e),children:[i.jsx(qi,{label:r("conversation.filePanelPathFieldLabel"),htmlFor:fn,description:(S==null?void 0:S.mode)==="rename"?S.target.path:(S==null?void 0:S.baseDirectory)||void 0,children:i.jsx("input",{id:fn,type:"text",value:Bt??"",placeholder:r("conversation.filePanelPathFieldPlaceholder"),autoFocus:!0,onChange:e=>We(e.target.value)})}),i.jsxs(Yi,{children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:Xt,children:r("common.cancel")}),i.jsx("button",{type:"submit",className:"primary-button",disabled:p||!(Bt??"").trim(),children:p?(U==null?void 0:U.pendingLabel)??r("common.loading"):(U==null?void 0:U.submitLabel)??r("common.save")})]})]})}),i.jsxs($n,{open:B!==null,title:r("conversation.filePanelDeleteConfirmTitle"),description:r("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{p||Be(null)},children:[i.jsx("p",{className:"workbench-section-empty",children:B!=null&&B.length?B.length===1?((Bn=B[0])==null?void 0:Bn.kind)==="directory"?r("conversation.filePanelDeleteDirectoryConfirm",{path:B[0].path}):r("conversation.filePanelDeleteFileConfirm",{path:B[0].path}):r("conversation.filePanelDeleteSelectionConfirm",{count:B.length}):""}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>Be(null),children:r("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{Di()},children:p?r("conversation.filePanelDeleting"):r("conversation.filePanelDelete")})]})]})]}):$e&&n?i.jsx(ea,{sessionId:n,workspaceId:l,showSystemFiles:V,selectedPath:je,refreshVersion:rn,onCountChange:Ot,onSelectFile:he,onOpenFile:ze}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:r("conversation.filePanelSessionNoSession")})})]}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:r("conversation.filePanelNoWorkspace")})})})}function ve(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):g}function dt(t,n=!1){const l=t.split("/").filter(Boolean),s=n?l.length:l.length-1,m=[];for(let h=0;h<s;h+=1)m.push(l.slice(0,h+1).join("/"));return m}function zn(t,n){return t||((n==null?void 0:n.kind)==="directory"?n.path:n!=null&&n.path?ve(n.path):g)}function Kn(t,n){return t?`${t}/${n}`:n}function fa(t){var n;return((n=t.split(/[/\\]/).pop())==null?void 0:n.trim())??""}function z(t,n){return{path:t,kind:n}}function Gn(t){return t[t.length-1]??null}function da(t,n){return t.findIndex(s=>s.path===n.path)>=0?t.filter(s=>s.path!==n.path):[...t,n]}function ha(t,n,l){const s=t.findIndex(x=>x.path===l.path);if(s<0)return[l];const m=n?t.findIndex(x=>x.path===n):s;if(m<0)return[l];const h=Math.min(m,s),b=Math.max(m,s);return t.slice(h,b+1)}function jt(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function ma(t){return t.ctrlKey||t.metaKey}function pa(t){if(!(t instanceof HTMLElement))return!1;const n=t.tagName.toLowerCase();return n==="input"||n==="textarea"||n==="select"||t.isContentEditable}function wt(t){const n=[...new Map(t.map(s=>[s.path,s])).values()].sort((s,m)=>s.path.localeCompare(m.path)),l=[];for(const s of n)l.some(m=>m.kind==="directory"&&Tt(m.path,s.path))||l.push(s);return l}function ba(t,n){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?ve(t.path):n}function va(t,n){let l=t;for(;l&&n.some(s=>s.kind==="directory"&&Tt(s.path,l));)l=ve(l);return l}function oi(t,n,l,s,m,h){const b=[];for(const x of t){if(b.push(z(x.path,x.kind)),x.kind!=="directory"||!l.includes(x.path))continue;const j=n[x.path]??[],_=s?an(j,n,m,h):j;b.push(...oi(_,n,l,s,m,h))}return b}function ya(t,n,l){const s=Math.max(0,l.width),m=Math.max(0,l.height),h=Math.max(0,m-ne*2),b=Math.max(0,s-ne*2),x=Math.min(Math.max(n.width,0),b),j=Math.max(0,m-t.y-Pt-ne),_=Math.max(0,t.y-Pt-ne),M=j<n.height&&_>j,ye=It(Math.max(M?_:j,aa),0,h),K=Math.min(Math.max(n.height,0),ye),xe=M?t.y-Pt-K:t.y+Pt,ge=Math.max(ne,m-ne-K),G=Math.max(ne,s-ne-x);return{top:It(xe,ne,ge),left:It(t.x,ne,G),maxHeight:Math.max(0,ye)}}function It(t,n,l){return!Number.isFinite(t)||l<n?n:Math.min(Math.max(t,n),l)}function qe(t,n="posix"){return t?ri(t,n):"."}function xa(t,n,l){const s=ri(t,l),m=qe(n,l).replace(/^\.[/\\]?/,"");if(!m)return s;const h=si(l),b=m.replace(/^[/\\]+/,"");return b?s.endsWith("/")||s.endsWith("\\")?`${s}${b}`:`${s}${h}${b}`:s}function ga(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function ri(t,n){return t&&(si(n)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function si(t){return t==="windows"?"\\":"/"}function Tt(t,n){return n===t||n.startsWith(`${t}/`)}function ci(t,n,l){return t===n?l:t.startsWith(`${n}/`)?`${l}${t.slice(n.length)}`:t}function Ca(t,n,l){return t.map(s=>({...s,path:ci(s.path,n,l)}))}function Pa(t){return t.mode==="create_file"?{title:r("conversation.filePanelNewFile"),description:r("conversation.filePanelCreateFileDescription"),submitLabel:r("conversation.filePanelCreateFileSubmit"),pendingLabel:r("conversation.filePanelCreatingFile")}:t.mode==="create_directory"?{title:r("conversation.filePanelNewDirectory"),description:r("conversation.filePanelCreateDirectoryDescription"),submitLabel:r("conversation.filePanelCreateDirectorySubmit"),pendingLabel:r("conversation.filePanelCreatingDirectory")}:{title:r("conversation.filePanelRenameMove"),description:r("conversation.filePanelRenameDescription"),submitLabel:r("conversation.filePanelRenameSubmit"),pendingLabel:r("conversation.filePanelRenaming")}}async function ja(t){const n=await t.arrayBuffer(),l=new Uint8Array(n),s=32768;let m="";for(let h=0;h<l.length;h+=s){const b=l.subarray(h,h+s);m+=String.fromCharCode(...b)}return btoa(m)}function wa(t){const n=atob(t),l=new Uint8Array(n.length);for(let s=0;s<n.length;s+=1)l[s]=n.charCodeAt(s);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}function Sa(t,n){if(typeof document>"u")throw new Error(r("conversation.filePanelDownloadFailed"));const l=window.URL.createObjectURL(n),s=document.createElement("a");s.href=l,s.download=t,document.body.append(s),s.click(),s.remove(),window.URL.revokeObjectURL(l)}async function Na(t,n){var l;if(!(n.isDesktop&&(await n.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((l=navigator.clipboard)!=null&&l.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!Da(t))throw new Error(r("conversation.filePanelCopyPathFailed"))}}function Da(t){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.left="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n)}}function Ea(t,n){return t&&dt(t,!0).every(m=>m in n)?t:g}function Xn(t,n){if(!n)return[];const l=dt(n,!0);return t.filter(s=>l.includes(s))}function St(t,n,l){const s=on(n,l);return Object.entries(t).reduce((m,[h,b])=>(s.has(h)&&(m[h]=b),m),{})}function ka(t,n,l){const m=[...on(n,l)].filter(h=>h===g||h in t);return m.length?m:[g]}function on(t,n){const l=new Set([g]),s=ui(n,dt(t,!0));for(const m of s){l.add(m);for(const h of dt(m,!0))l.add(h)}return l}function Ma(t,n){const l=Object.keys(t),s=Object.keys(n);return l.length!==s.length?!1:l.every(m=>t[m]===n[m])}function kt(t,n){return t.includes(n)?t:[...t,n]}function ui(t,n){return n.reduce((l,s)=>kt(l,s),t)}function qn(t){return`file-panel.workspace-tree.${t}`}function Yn(t,n){return`file-panel.session-change-count.${t}.${n}`}function Jn(t,n){return Object.fromEntries(Object.keys(n).map(l=>[l,t[l]??null]))}function en(t,n){return[...on(n,t)]}function Q(t,n){return t instanceof In?t.message:n}function fi(t){return t instanceof Error&&t.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")}function Qn(t){return fi(t)||t instanceof Error&&t.message.startsWith("FILE_TREE_ABORTED:")}function Ra(t){return new Promise(n=>{window.setTimeout(n,t)})}function Ta(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function _a(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 Zn(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 Fa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.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"}),i.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Aa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function La(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 Ba(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Wa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function $a(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.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 Ha(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 Va(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ua(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 za(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function Ka(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function an(t,n,l,s){const m=[];for(const h of t){const b=h.path.replace(/\\/g,"/");h.kind==="file"?l.has(b)&&m.push(h):di(b,n,l,s)&&m.push(h)}return m}function di(t,n,l,s,m){const h=m??new Set;if(h.has(t))return!1;h.add(t);const b=n[t];if(!b)return s.has(t);for(const x of b){const j=x.path.replace(/\\/g,"/");if(x.kind==="file"){if(l.has(j))return!0}else if(di(j,n,l,s,h))return!0}return!1}export{nl as FileContextPanel};
|
|
1
|
+
import{b as c,F as tn,j as i,t as r,G as ft,A as In}from"./index-CFyk1rgJ.js";import{f as ei,e as _i,g as Fi}from"./App-BxX5mm9o.js";import{bI as Ai,bJ as Li,bK as ti,bL as nn,bM as Bi,bN as Mt,bO as Rt,b as Wi,u as $i,Y as _e,bP as Jt,bQ as Oi,bR as Hi,bS as Vi,bT as ut,bU as gt,bV as Xe,bW as Ui,bX as zi,bY as Ki,bZ as Gi,b_ as Xi}from"./WorkbenchLayout-DD8b-m2G.js";import{d as qi,M as Yi}from"./workbench-navigation-DoDaQR4z.js";import{W as $n}from"./WorkbenchModal-CsZeLArg.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./DesktopModal-BxsogpLf.js";import"./relay-entry-C8k5qsl5.js";import"./MobileSheet-C5IVmUsO.js";async function Nt(t,n){const[l,s]=await Promise.all([Ai(n),Li(t)]);return Zi(l.changes,s.items)}function Zi(t,n){const l=new Set(n.map(s=>Et(s.path)));return t.filter(s=>l.has(Et(s.path))||s.oldPath!==null&&l.has(Et(s.oldPath)))}function Ji(t){const n=On("","");for(const l of t){const s=Et(l.path),m=s.split("/").filter(Boolean);let h=n;m.forEach((b,x)=>{const j=m.slice(0,x+1).join("/");if(x===m.length-1){h.children.set(`file:${j}`,{kind:"file",name:b,path:s,change:l});return}const _=`directory:${j}`,M=h.children.get(_);if(M&&M.kind==="directory"){h=M;return}const Q=On(b,j);h.children.set(_,Q),h=Q})}return ai(ii([...n.children.values()]))}function ni(t,n){const l=t.oldPath?`${t.oldPath} -> ${t.path}`:t.path;return ln(t)?`${l} ${n}`:l}function ln(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 On(t,n){return{kind:"directory",name:t,path:n,children:new Map}}function ii(t){return[...t].sort((n,l)=>n.kind!==l.kind?n.kind==="directory"?-1:1:n.name.localeCompare(l.name,"zh-CN")).map(n=>n.kind==="directory"?{kind:"directory",name:n.name,path:n.path,children:ii([...n.children.values()])}:n)}function ai(t){return t.map(n=>{var b;if(n.kind!=="directory")return n;const l=ai(n.children);let s=n.name,m=n.path,h=l;for(;h.length===1&&((b=h[0])==null?void 0:b.kind)==="directory";){const x=h[0];s=`${s}/${x.name}`,m=x.path,h=x.children}return{kind:"directory",name:s,path:m,children:h}})}const Qi=450,Ii=60*1e3,Hn=20,Vn=16;function ea({sessionId:t,workspaceId:n,showSystemFiles:l,selectedPath:s,refreshVersion:m,onCountChange:h,onSelectFile:b,onOpenFile:x}){const[j,_]=c.useState("tree"),[M,Q]=c.useState([]),[ye,K]=c.useState(!0),[xe,ge]=c.useState(!1),[G,ht]=c.useState([]),E=c.useRef(null),_t=ti(),{showToast:Ne}=ei();c.useEffect(()=>{const p=tn(Ct(n,t),Ii);_("tree"),Q(p??[]),K(p===null),ge(!1),ht([]),E.current=null},[t,n]),c.useEffect(()=>{let p=!1;async function w(){K(!0);try{const v=await Nt(t,n);p||(Q(v),ft(Ct(n,t),v))}catch(v){p||Ne({title:Qt(v,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{p||K(!1)}}return w(),()=>{p=!0}},[m,t,Ne,n]);async function De(){K(!0);try{const p=await Nt(t,n);Q(p),ft(Ct(n,t),p)}catch(p){Ne({title:Qt(p,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{K(!1)}}async function D(){if(R.length!==0){ge(!0);try{await Bi(n,R.map(w=>w.path));const p=await Nt(t,n);Q(p),ft(Ct(n,t),p),Ne({title:r("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(p){Ne({title:Qt(p,r("git.stageFailed")),tone:"error"})}finally{ge(!1)}}}function F(p){ht(w=>w.includes(p)?w.filter(v=>v!==p):[...w,p])}function X(p){const w=Date.now(),v=E.current;return E.current={filePath:p,timestamp:w},(v==null?void 0:v.filePath)===p&&w-v.timestamp<=Qi}async function $(p,w){if(w&&X(p)){await x(p),E.current=null;return}w||(E.current=null),await b(p)}const ie=c.useMemo(()=>nn(M,p=>Dt(p.path),l),[M,l]),R=ie.filter(p=>!p.staged),Fe=Ji(ie),ae=new Set(G);return c.useEffect(()=>{h==null||h(ie.length)},[h,ie.length]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"file-panel-session-toolbar",children:[i.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":r("conversation.filePanelSessionViewLabel"),children:[i.jsx("button",{className:j==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":j==="tree",onClick:()=>_("tree"),children:r("conversation.filePanelSessionTreeView")}),i.jsx("button",{className:j==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":j==="list",onClick:()=>_("list"),children:r("conversation.filePanelSessionListView")})]}),i.jsxs("div",{className:"file-panel-session-actions",children:[i.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void De(),disabled:ye||xe,children:r("conversation.filePanelRefresh")}),i.jsx("button",{className:"primary-button",type:"button",onClick:()=>void D(),disabled:xe||R.length===0,children:r("conversation.filePanelSessionStageAll")})]})]}),i.jsxs("div",{className:"file-panel-session-summary",children:[i.jsx("span",{children:`${r("conversation.filePanelSessionSummary")} ${ie.length}`}),i.jsx("span",{children:`${r("conversation.filePanelSessionUnstagedSummary")} ${R.length}`})]}),i.jsx("div",{ref:_t,className:"file-tree","data-scrollbar-autohide":"true",children:ye?i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionLoading")}):ie.length===0?i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionEmpty")}):j==="tree"?li({nodes:Fe,depth:0,collapsedPathSet:ae,selectedPath:s,onToggleTreePath:F,onFileClick:$}):ta({items:ie,selectedPath:s,onFileClick:$})})]})}function li({nodes:t,depth:n,collapsedPathSet:l,selectedPath:s,onToggleTreePath:m,onFileClick:h}){return t.map(b=>{if(b.kind==="directory"){const x=!l.has(b.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":x,style:{paddingInlineStart:`${Hn+n*Vn}px`},onClick:()=>m(b.path),children:[i.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:x?"v":">"}),i.jsx("span",{className:"file-tree-label",children:b.name})]}),x?i.jsx("div",{className:"file-tree-children",children:li({nodes:b.children,depth:n+1,collapsedPathSet:l,selectedPath:s,onToggleTreePath:m,onFileClick:h})}):null]},`session-directory:${b.path}`)}return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":s===b.change.path,"data-kind":"file",style:{paddingInlineStart:`${Hn+n*Vn}px`},onClick:()=>void h(b.change.path,!ln(b.change)),children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),i.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(b.name),"aria-hidden":"true",children:Mt(b.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:b.name}),i.jsx("span",{className:"file-tree-path",children:ni(b.change,r("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":b.change.status,children:b.change.status}),i.jsx("span",{className:"file-session-badge subtle",children:b.change.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-file:${b.path}`)})}function ta({items:t,selectedPath:n,onFileClick:l}){return t.map(s=>i.jsx("div",{className:"file-session-list-item",children:i.jsxs("button",{className:"file-session-list-button",type:"button","data-active":n===s.path,onClick:()=>void l(s.path,!ln(s)),children:[i.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(Dt(s.path)),"aria-hidden":"true",children:Mt(Dt(s.path))}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:Dt(s.path)}),i.jsx("span",{className:"file-tree-path",children:ni(s,r("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":s.status,children:s.status}),i.jsx("span",{className:"file-session-badge subtle",children:s.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-list:${s.path}`))}function Ct(t,n){return`file-panel.session-changes.${t}.${n}`}function Qt(t,n){return t instanceof In?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??n):n}const g="",na=450,ne=8,Pt=4,ia=176,aa=120,la=300*1e3,oa=60*1e3,Un=1600,ra=220,sa=20,ca=16;function ua(){if(typeof document>"u")return;const t=document.querySelector(".workbench-modal-card.file-viewer-modal"),n=t==null?void 0:t.getBoundingClientRect();if(!(!n||n.width<=0||n.height<=0))return{width:Math.round(n.width),height:Math.round(n.height),minWidth:720,minHeight:480}}function nl({className:t,sessionId:n,workspaceId:l,hideHeading:s=!1,hideTabs:m=!1,externalRevealRequest:h=null,externalWindowMode:b=!1,workbenchShellOverrides:x}){var Ln,Bn;const j=Wi(),{navigationGroups:_,subscribeFileTree:M,requestFileTreeRefresh:Q,addFileTreeSnapshotListener:ye,subscribeGitSnapshot:K,requestGitRefresh:xe,addGitSnapshotListener:ge}={...j,...x},[G,ht]=c.useState({}),[E,_t]=c.useState([]),[Ne,De]=c.useState([]),[D,F]=c.useState(g),[X,$]=c.useState([]),[ie,R]=c.useState(null),[Fe,ae]=c.useState(!1),[p,w]=c.useState(!1),[v,mt]=c.useState(!1),[Ye,Ze]=c.useState(!1),[A,Je]=c.useState(""),[Ft,q]=c.useState(null),[pt,bt]=c.useState(!1),[le,Ae]=c.useState(null),[O,Qe]=c.useState("workspace"),[rn,Ee]=c.useState(0),[sn,At]=c.useState(0),[Ie,I]=c.useState(!1),[et,L]=c.useState(!1),[oe,H]=c.useState(null),[Ce,Le]=c.useState(null),[B,Be]=c.useState(null),[C,Lt]=c.useState(null),[S,tt]=c.useState(null),[Bt,We]=c.useState(""),[cn,un]=c.useState([]),[ee,Wt]=c.useState(!1),[hi,re]=c.useState(null),fn=c.useId(),se=c.useRef({}),Y=c.useRef({}),T=c.useRef([]),te=c.useRef(g),nt=c.useRef(!1),it=c.useRef(null),mi=ti(),dn=c.useRef(null),hn=c.useRef(null),$t=c.useRef(null),mn=c.useRef(null),pn=c.useRef(null),ce=c.useRef(0),ue=c.useRef(new Map),{showToast:P}=ei(),Pe=_i(),V=$i(e=>e.showSystemFiles),$e=!!(n!=null&&n.trim()),bn=s&&Pe.isMobile;c.useEffect(()=>{_e("file_panel.props",{sessionId:n,workspaceId:l,externalWindowMode:b})},[b,n,l]),c.useEffect(()=>{te.current=D},[D]);function Ot(e){At(e),!(!l||!n)&&ft(Yn(l,n),e)}async function vn(){if(!l||!n){Ot(0);return}const e=await Nt(n,l),a=nn(e,o=>ut(o.path),V).length;Ot(a)}function ke(e){ht(a=>{const o=typeof e=="function"?e(a):e;return se.current=o,o})}function Oe(e){_t(a=>{const o=typeof e=="function"?e(a):e;return T.current=o,o})}c.useEffect(()=>{var f,d;if(zt(),!l){zt(),nt.current=!1,se.current={},Y.current={},T.current=[],te.current=g,ke({}),Oe([]),De([]),F(g),Ze(!1),Je(""),q(null),bt(!1),ae(!1),Wt(!1),re(null),$([]),R(null),H(null),Le(null),Be(null),tt(null),We("");return}nt.current=!0;const e=tn(qn(l),la);_e("file_panel.workspace_snapshot",{workspaceId:l,cached:!!e,cachedRootItems:((d=(f=e==null?void 0:e.treeCache)==null?void 0:f[g])==null?void 0:d.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const a=Ea((e==null?void 0:e.activeDirectoryPath)??g,(e==null?void 0:e.treeCache)??{}),o=Xn((e==null?void 0:e.expandedDirectories)??[],a),u=St((e==null?void 0:e.treeCache)??{},a,o);se.current=u,Y.current=Zn((e==null?void 0:e.treeRevisionByPath)??{},u),T.current=o,te.current=a,ke(u),Oe(o),De([]),F(a),ae(!1),w(!1),Ze(!1),Je(""),q(null),bt(!1),queueMicrotask(()=>{nt.current=!1})},[l]),c.useEffect(()=>{if(!h||h.workspaceId!==l)return;const e=()=>{if(pn.current===h.requestId)return;pn.current=h.requestId,Qe("workspace"),(h.openViewer?ze(h.filePath):he(h.filePath)).catch(o=>{P({title:J(o,r("conversation.filePanelOpenFailed")),tone:"error"})})};if(nt.current){queueMicrotask(e);return}e()},[h,ze,he,P,l]),c.useEffect(()=>{if(l)return ye(e=>{e.workspaceId===l&&(Y.current={...Y.current,[e.path]:typeof e.revision=="string"?e.revision:null},ke(a=>({...a,[e.path]:e.items})),e.path===g&&ae(!1),De(a=>a.filter(o=>o!==e.path)),wn(e.path,e.items))})},[ye,l]),c.useEffect(()=>()=>{zt()},[]),c.useEffect(()=>{l&&M(l,en(T.current,te.current),{knownRevisionByPath:Y.current})},[D,E,M,l]),c.useEffect(()=>{$([]),R(null),Ae(null),re(null),Ee(0),I(!1),L(!1),H(null),Le(null),Be(null),tt(null),We(""),it.current=null,ce.current+=1},[n]),c.useEffect(()=>{!$e&&O==="session"&&Qe("workspace")},[O,$e]),c.useEffect(()=>{m&&O!=="workspace"&&Qe("workspace")},[O,m]),c.useEffect(()=>{if(!Ie&&!et&&!oe)return;function e(o){var y,N,pe;if(!(o.target instanceof Node))return;const u=((y=dn.current)==null?void 0:y.contains(o.target))??!1,f=((N=hn.current)==null?void 0:N.contains(o.target))??!1,d=((pe=$t.current)==null?void 0:pe.contains(o.target))??!1;!u&&!f&&!d&&(I(!1),L(!1),H(null),Le(null))}function a(o){o.key==="Escape"&&(I(!1),L(!1),H(null),Le(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",a)}},[Ie,et,oe]),c.useLayoutEffect(()=>{if(!oe||typeof window>"u"){Le(null);return}const e=oe;function a(){const u=$t.current;if(!u)return;const f=u.getBoundingClientRect();Le(ya({x:e.positionX,y:e.positionY},{width:f.width||ia,height:f.height||u.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}a();const o=window.requestAnimationFrame(a);return window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{window.cancelAnimationFrame(o),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}},[oe]),c.useEffect(()=>{if(!l)return;const e=Xn(E,D),a=St(G,D,e);ft(qn(l),{treeCache:a,treeRevisionByPath:Zn(Y.current,a),expandedDirectories:e,activeDirectoryPath:D})},[D,E,G,l]),c.useEffect(()=>{if(nt.current)return;const e=St(G,D,E);Ma(G,e)||ke(e)},[D,E,G]),c.useEffect(()=>{let e=!1;const a=(l==null?void 0:l.trim())??null;async function o(f){if(!a)return;const d=Jt(se.current[g]??[],V),y=(f==null?void 0:f.silent)!==!0&&d.length===0;y&&ae(!0),_e("file_panel.load_root_tree.start",{sessionId:n,workspaceId:a,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:d.length});try{const N=await Ut(g,{force:!0});e||(_e("file_panel.load_root_tree.end",{sessionId:n,workspaceId:a,itemCount:N.length}),ke(pe=>({...St(pe,te.current,T.current),[g]:N})))}catch(N){!e&&!Jn(N)&&P({title:J(N,r("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&y&&ae(!1)}}if(Jt(se.current[g]??[],V).length>0){const f=window.setTimeout(()=>{a&&(M(a,en(T.current,te.current),{knownRevisionByPath:Y.current}),o({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return o(),()=>{e=!0}},[n,V,P,l]),c.useEffect(()=>{if(!l||!n){At(0);return}const e=tn(Yn(l,n),oa);_e("file_panel.session_change_count.snapshot",{sessionId:n,workspaceId:l,cached:e!==null,cachedCount:e}),At(e??0);let a=!1;return vn().catch(()=>{}),()=>{a=!0}},[n,rn,V,l]),c.useEffect(()=>{if(!l){un([]);return}const e=l.trim();K(e),xe(e)},[l,K,xe]),c.useEffect(()=>{if(!l)return;const e=l.trim();return ge(a=>{var o;a.workspaceId===e&&un(((o=a.status)==null?void 0:o.changes)??[])})},[ge,l]);const vt=c.useMemo(()=>nn(cn,e=>ut(e.path),V),[cn,V]),W=c.useMemo(()=>{const e=new Map,a=new Set;for(const o of vt){const u=o.path.replace(/\\/g,"/"),f=o.worktreeStatus??o.stagedStatus??o.status;e.set(u,f);const d=u.split("/");for(let y=1;y<d.length;y++)a.add(d.slice(0,y).join("/"))}return{statusByPath:e,changedDirs:a}},[vt]),Me=c.useMemo(()=>Oi(G,V),[V,G]),Re=c.useMemo(()=>Ft===null?null:Jt(Ft,V),[Ft,V]),He=Me[g]??[],fe=Ye&&Re!==null,yt=c.useMemo(()=>ee?an(He,Me,W.statusByPath,W.changedDirs):He,[W.changedDirs,W.statusByPath,He,ee,Me]),pi=c.useMemo(()=>fe?(Re??[]).map(e=>z(e.path,e.kind)):oi(yt,Me,E,ee,W.statusByPath,W.changedDirs),[E,W.changedDirs,W.statusByPath,fe,ee,Re,Me,yt]),de=((Ln=_.find(e=>e.workspace.id===l))==null?void 0:Ln.workspace)??null,k=Gn(X),Ht=(k==null?void 0:k.path)??null,je=(k==null?void 0:k.kind)==="file"?k.path:null,xt=c.useMemo(()=>new Set(X.map(e=>e.path)),[X]),at=c.useMemo(()=>wt(X),[X]),Vt=!!(de!=null&&de.path&&X.length===1&&Ht),yn=X.length===1&&(k==null?void 0:k.kind)==="file",xn=at.length>0,Te=at.length>0,lt=!!(C!=null&&C.items.length&&l),gn=!!l&&X.length===1&&k!==null,Cn=!!((je?ve(je):D)&&E.length),Pn=C?C.mode==="copy"?r("conversation.filePanelClipboardCopyReady",{count:C.items.length}):r("conversation.filePanelClipboardCutReady",{count:C.items.length}):null,U=S?Pa(S):null;async function jn(e,a=!1){if(!l)return[];if(!a){const o=se.current[e];if(o)return o}e===g?ae(!0):De(o=>kt(o,e));try{const o=await Ut(e,{force:a});return ke(u=>({...u,[e]:o})),o}catch(o){throw Jn(o)||P({title:J(o,r("conversation.filePanelLoadFailed")),tone:"error"}),o}finally{e===g?ae(!1):De(o=>o.filter(u=>u!==e))}}async function we(e){if(!l)return;const a=(e==null?void 0:e.activeDirectoryPath)??te.current,o=(e==null?void 0:e.expandedDirectories)??T.current,u=ka(se.current,a,o);_e("file_panel.refresh_tree_cache.start",{sessionId:n,workspaceId:l,targetDirectories:u});const d=(await Promise.all(u.map(async y=>{const N=await Ut(y,{force:!0});return[y,N]}))).reduce((y,[N,pe])=>(y[N]=pe,y),{});_e("file_panel.refresh_tree_cache.end",{sessionId:n,workspaceId:l,targetDirectories:u,directoryCount:Object.keys(d).length}),ke(d)}async function Ut(e,a){if(!l)return[];if(!(a!=null&&a.force)){const d=se.current[e];if(d)return d}const o=en(kt(T.current,e),e||te.current);M(l,o,{knownRevisionByPath:Y.current}),Q(l,[e],{knownRevisionByPath:Y.current});const u=bi(e,Un,{allowCached:(a==null?void 0:a.force)!==!0}),f=Ra(ra).then(async()=>{if(!l)return[];const y=(await Gi(l,e||void 0)).items;return Y.current={...Y.current,[e]:null},wn(e,y),y});try{return await Promise.race([u,f])}catch(d){if(!fi(d))throw d;return await f}}function bi(e,a=Un,o){const u=se.current[e];return(o==null?void 0:o.allowCached)!==!1&&u?Promise.resolve(u):new Promise((f,d)=>{const y=window.setTimeout(()=>{vi(e,y),d(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},a),N=ue.current.get(e)??[];ue.current.set(e,[...N,{resolve:f,reject:d,timerId:y}])})}function wn(e,a){const o=ue.current.get(e)??[];o.length!==0&&(ue.current.delete(e),o.forEach(u=>{window.clearTimeout(u.timerId),u.resolve(a)}))}function vi(e,a){const u=(ue.current.get(e)??[]).filter(f=>f.timerId!==a);if(u.length===0){ue.current.delete(e);return}ue.current.set(e,u)}function zt(){for(const[e,a]of ue.current.entries())a.forEach(o=>{window.clearTimeout(o.timerId),o.reject(new Error(`FILE_TREE_ABORTED:${e}`))});ue.current.clear()}function Ve(e){$([e]),R(e.path)}function ot(e){F(e.kind==="directory"?e.path:ve(e.path))}function yi(e){const a=ha(pi,ie,e);$(a),R(e.path),ot(e)}function xi(e){const a=da(X,e),o=Gn(a);$(a),R(e.path),o&&ot(o)}function Sn(e){Ve(e),ot(e)}function Ue(e,a){if(a!=null&&a.shiftKey){yi(e);return}if(jt(a)){xi(e);return}Sn(e)}async function rt(e,a=!1){const o=dt(e,a);if(!o.length){F(g);return}Oe(u=>ui(u,o)),F(o[o.length-1]??g);for(const u of o)try{await jn(u)}catch{return}}async function he(e){const a=z(e,"file");Ve(a),ot(a),await rt(e)}async function ze(e){Ae(e),re(null),it.current=null,ce.current+=1,he(e),await gi(e)}async function gi(e){const a=ce.current,o=e.replace(/\\/g,"/"),u=W.statusByPath.get(o);if(l&&u&&u!=="?"&&u!=="D")try{const f=await Hi(l,e,!1);ce.current===a&&re(f.content||null)}catch{ce.current===a&&re(null)}}async function Ci(e){if(!l)return;const a=ua(),o=await Ui(Pe,{workspaceId:l,workspaceName:(de==null?void 0:de.name)??null,sessionId:n??null,filePath:e,bounds:a});if(!o.ok){P({title:o.detail??r("conversation.fileViewerOpenInWindowFailed"),tone:"error"});return}ce.current+=1,Ae(null),re(null)}function Nn(e){const a=Date.now(),o=it.current;return it.current={filePath:e,timestamp:a},(o==null?void 0:o.filePath)===e&&a-o.timestamp<=na}function Se(){it.current=null}async function Pi(e,a){const o=z(e,"file");if(a!=null&&a.shiftKey||jt(a)){Se(),Ue(o,a);return}if(Nn(e)){await ze(e);return}Ue(o,a),await rt(e)}function Dn(){Ze(!1),Je(""),q(null),Se()}async function ji(e,a){const o=z(e.path,e.kind);if(a!=null&&a.shiftKey||jt(a)){Se(),Ue(o,a);return}if(e.kind==="directory"){Dn(),Ue(o,a),await En(e.path);return}if(Nn(e.path)){Dn(),await ze(e.path);return}await he(e.path)}async function En(e){if(Ve(z(e,"directory")),F(e),!T.current.includes(e))try{await jn(e),Oe(a=>kt(a,e))}catch{}}async function kn(e){if(Ve(z(e,"directory")),F(e),T.current.includes(e)){Mn(e);return}await En(e)}function Mn(e){Oe(a=>a.filter(o=>o!==e&&!o.startsWith(`${e}/`))),F(ve(e)),$([]),R(null)}async function Rn(){if(!l)return;const e=l;try{if(xe(e),await we(),je&&await rt(je),fe&&A.trim()){const a=await Xe(e,A.trim());q(a.items)}if($e&&n)if(O==="session")Ee(a=>a+1);else try{await vn()}catch(a){P({title:J(a,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}}catch(a){P({title:J(a,r("conversation.filePanelLoadFailed")),tone:"error"})}}async function wi(e){if(e==null||e.preventDefault(),!l||!A.trim()){q(null);return}bt(!0);try{const a=await Xe(l,A.trim());q(a.items)}catch(a){P({title:J(a,r("conversation.filePanelSearchFailed")),tone:"error"})}finally{bt(!1)}}function Tn(){if(Ye){Ze(!1),Je(""),q(null);return}Ze(!0)}function Z(e){L(!1),e()}function _n(){var e;(e=mn.current)==null||e.click()}async function Si(e){var d;const a=((d=e.target.files)==null?void 0:d[0])??null;if(e.target.value="",!a||!l)return;const o=fa(a.name);if(!o){P({title:r("conversation.filePanelUploadFailed"),tone:"error"});return}const u=zn(D,k),f=Kn(u,o);mt(!0);try{const y=await ja(a);await zi({workspaceId:l,path:f,contentBase64:y}),await we(),await he(f),P({title:r("conversation.filePanelUploadSuccess",{name:o}),tone:"success"})}catch(y){P({title:J(y,r("conversation.filePanelUploadFailed")),tone:"error"})}finally{mt(!1)}}async function Kt(e=je){if(!(!l||!e)){mt(!0);try{const a=await Ki(l,e),o=wa(a.contentBase64);Sa(a.fileName,new Blob([o],{type:"application/octet-stream"})),P({title:r("conversation.filePanelDownloadSuccess",{name:a.fileName}),tone:"success"})}catch(a){P({title:J(a,r("conversation.filePanelDownloadFailed")),tone:"error"})}finally{mt(!1)}}}function Fn(){const e=je?ve(je):D;!e||!T.current.includes(e)||Mn(e)}function Gt(){tt(null),We("")}function Xt(){p||Gt()}function Ke(e,a=zn(D,k)){if(!l)return;const o=a,u=o?`${o}/`:"";I(!1),L(!1),H(null),tt({mode:e,baseDirectory:o}),We(u)}function qt(e=k){!l||!e||(I(!1),L(!1),H(null),tt({mode:"rename",target:e}),We(e.path))}async function Ni(e){if(e==null||e.preventDefault(),!l||!S)return;const a=(Bt??"").trim();if(a){if(S.mode==="rename"&&qe(S.target.path)===qe(a)){Xt();return}w(!0);try{if(S.mode==="rename"){const o=S.target.path,u=z(a,S.target.kind),f=le?ci(le,o,a):null;if(await gt({workspaceId:l,opType:"rename",srcPath:o,dstPath:a}),C&&Lt({...C,items:Ca(C.items,o,a)}),Gt(),Se(),await we(),S.target.kind==="directory"?(await rt(a,!0),Ve(u),F(a)):await he(a),f!==le&&(ce.current+=1,Ae(f),re(null)),fe&&A.trim()){const d=await Xe(l,A.trim());q(d.items)}Ee(d=>d+1),P({title:r("conversation.filePanelRenameSuccess",{name:ut(a)||a}),tone:"success"});return}if(await gt({workspaceId:l,opType:S.mode,dstPath:a,content:S.mode==="create_file"?"":void 0}),Gt(),await we(),S.mode==="create_directory"?(await rt(a,!0),Ve(z(a,"directory")),F(a)):await he(a),fe&&A.trim()){const o=await Xe(l,A.trim());q(o.items)}Ee(o=>o+1)}catch(o){P({title:J(o,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}}function me(e,a=at){var u;if(a.length===0)return;const o=wt(a);Lt({mode:e,items:o}),$(o),R(((u=o[o.length-1])==null?void 0:u.path)??null),P({title:e==="copy"?r("conversation.filePanelCopySelectionSuccess",{count:o.length}):r("conversation.filePanelCutSelectionSuccess",{count:o.length}),tone:"success"}),H(null)}async function st(e=ba(k,D)){if(!l||!C||!C.items.length)return;const a=e??g,o=C.items.map(u=>({source:u,destinationPath:Kn(a,ut(u.path)||u.path)}));w(!0);try{for(const d of o)C.mode==="cut"&&qe(d.source.path)===qe(d.destinationPath)||await gt({workspaceId:l,opType:C.mode==="copy"?"copy":"move",srcPath:d.source.path,dstPath:d.destinationPath});const u=o.map(d=>z(d.destinationPath,d.source.kind)),f=u[u.length-1]??null;if(C.mode==="cut"&&Lt(null),$(u),R((f==null?void 0:f.path)??null),f&&ot(f),Se(),await we({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?ve(f.path):te.current,expandedDirectories:T.current}),fe&&A.trim()){const d=await Xe(l,A.trim());q(d.items)}Ee(d=>d+1),P({title:r("conversation.filePanelPasteSuccess",{count:u.length}),tone:"success"}),H(null)}catch(u){await we().catch(()=>{}),P({title:J(u,r("conversation.filePanelPasteFailed")),tone:"error"})}finally{w(!1)}}function Yt(e=at){!e.length||p||(Be(wt(e)),H(null))}async function Di(){var a,o;if(!l||!(B!=null&&B.length))return;const e=wt(B);w(!0);try{for(const d of e)await gt({workspaceId:l,opType:"delete",srcPath:d.path});const u=va(D,e),f=T.current.filter(d=>!e.some(y=>y.kind==="directory"&&Tt(y.path,d)));if(le&&e.some(d=>Tt(d.path,le))&&(ce.current+=1,Ae(null),re(null)),Be(null),$([]),R(null),te.current=u,T.current=f,F(u),Oe(f),Se(),await we({activeDirectoryPath:u,expandedDirectories:f}),fe&&A.trim()){const d=await Xe(l,A.trim());q(d.items)}Ee(d=>d+1),P({title:e.length===1?r("conversation.filePanelDeleteSuccess",{name:ut(((a=e[0])==null?void 0:a.path)??"")||((o=e[0])==null?void 0:o.path)||""}):r("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(u){P({title:J(u,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}async function Ge(e,a=k){const o=(de==null?void 0:de.path)??"",u=(a==null?void 0:a.path)??null;if(u===null||!o){I(!1);return}try{const f=ga(o),d=e==="absolute"?xa(o,u,f):qe(u,f);await Na(d,Pe),P({title:e==="absolute"?r("conversation.filePanelCopyAbsolutePathSuccess"):r("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){P({title:f instanceof Error?f.message:r("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{I(!1),H(null)}}function Ei(e,a,o){return[{id:`open-${e.path}`,label:e.kind==="directory"?E.includes(e.path)?r("conversation.filePanelCollapseDirectory"):r("conversation.filePanelExpandDirectory"):r("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){kn(e.path);return}ze(e.path)}},{id:`download-${e.path}`,label:r("conversation.filePanelDownload"),disabled:e.kind!=="file"||v,onSelect:()=>{Kt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:r("conversation.filePanelNewFile"),disabled:!l||p||v,onSelect:()=>{Ke("create_file",o)}},{id:`create-directory-${e.path}`,label:r("conversation.filePanelNewDirectory"),disabled:!l||p||v,onSelect:()=>{Ke("create_directory",o)}},{id:`rename-${e.path}`,label:r("conversation.filePanelRenameMove"),disabled:a.length!==1||p||v,onSelect:()=>qt(e)},{id:`copy-${e.path}`,label:r("conversation.filePanelCopy"),disabled:a.length===0,onSelect:()=>me("copy",a)},{id:`cut-${e.path}`,label:r("conversation.filePanelCut"),disabled:a.length===0,onSelect:()=>me("cut",a)},{id:`paste-${e.path}`,label:r("conversation.filePanelPaste"),disabled:!lt,onSelect:()=>{st(o)}},{id:`copy-relative-${e.path}`,label:r("conversation.filePanelCopyRelativePath"),onSelect:()=>{Ge("relative",e)}},{id:`copy-absolute-${e.path}`,label:r("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{Ge("absolute",e)}},{id:`delete-${e.path}`,label:r("conversation.filePanelDelete"),disabled:a.length===0||p||v,onSelect:()=>Yt(a)}]}async function An(e,a){if(Pe.isMobile)return;e.preventDefault();const o=z(a.path,a.kind),u=xt.has(o.path)?at:[o],f=o.kind==="directory"?o.path:ve(o.path);xt.has(o.path)||Sn(o);const d=Ei(o,u,f);if(Pe.isDesktop){await Xi(d);return}Pe.isWeb&&(I(!1),L(!1),H({positionX:e.clientX,positionY:e.clientY,items:d}))}c.useEffect(()=>{if(O!=="workspace")return;function e(a){if(!ma(a)||a.altKey||a.shiftKey||pa(a.target))return;const o=a.key.toLowerCase();if(o==="c"&&Te){a.preventDefault(),me("copy");return}if(o==="x"&&Te){a.preventDefault(),me("cut");return}o==="v"&<&&(a.preventDefault(),st())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[O,Te,lt,me,st]);function Zt(e,a){return i.jsx(i.Fragment,{children:e.map(o=>{const u=z(o.path,o.kind),f=o.kind==="directory",d=f&&E.includes(o.path),y=f&&Ne.includes(o.path),N=Me[o.path]??[],pe=ee?an(N,Me,W.statusByPath,W.changedDirs):N,Mi=xt.has(o.path),Ri=Ht===o.path,ct=W.statusByPath.get(o.path.replace(/\\/g,"/")),Wn=f&&W.changedDirs.has(o.path.replace(/\\/g,"/")),Ti=(C==null?void 0:C.mode)==="cut"&&C.items.some(be=>be.path===o.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-active":Ri,"data-selected":Mi,"data-cut-pending":Ti||void 0,"data-kind":o.kind,"aria-expanded":f?d:void 0,style:{paddingInlineStart:`${sa+a*ca}px`},onClick:be=>{if(f){if(be.shiftKey||jt(be)){Se(),Ue(u,be);return}Se(),Ue(u,be),kn(o.path);return}Pi(o.path,be)},onContextMenu:be=>{An(be,o)},children:[i.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:d?"v":">"}),f?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(o.name),"aria-hidden":"true",children:Mt(o.name)}),i.jsx("span",{className:"file-tree-label","data-status":ct??void 0,"data-has-changes":Wn||void 0,children:o.name}),!f&&ct?i.jsx("span",{className:"git-status-badge","data-status":ct,"aria-label":ct,children:ct}):null,f&&Wn?i.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,y?i.jsx("span",{className:"file-tree-meta",children:r("common.loading")}):null]}),f&&d?i.jsx("div",{className:"file-tree-children",children:y&&!N.length?i.jsx("p",{className:"file-tree-empty",children:r("common.loading")}):pe.length?Zt(pe,a+1):i.jsx("p",{className:"file-tree-empty",children:r("conversation.filePanelEmptyDirectory")})}):null]},`${o.kind}-${o.path}`)})})}function ki(e){return i.jsx(i.Fragment,{children:e.map(a=>{const o=a.kind==="directory",u=xt.has(a.path),f=Ht===a.path;return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":f,"data-selected":u,"data-kind":a.kind,onClick:d=>{ji(a,d)},onContextMenu:d=>{An(d,a)},children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),o?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(a.name),"aria-hidden":"true",children:Mt(a.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:a.name}),i.jsx("span",{className:"file-tree-path",children:a.path})]})]})},`search-${a.kind}-${a.path}`)})})}return i.jsx("section",{className:["conversation-panel","surface-card","file-panel",t].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:l?i.jsxs(i.Fragment,{children:[i.jsx(Vi,{workspaceId:l,filePath:le,open:le!==null,onClose:()=>{ce.current+=1,Ae(null),re(null)},onSaved:async e=>{await we(),await he(e),Ee(a=>a+1)},diffContent:hi,showDetachAction:Pe.isDesktop&&Pe.bridge.supported,onDetach:()=>{le&&Ci(le)}}),s?null:i.jsx("div",{className:"file-panel-heading-row",children:i.jsx("h2",{className:"file-panel-heading",children:r("conversation.filePanelTitle")})}),m?null:i.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":r("conversation.filePanelTitle"),children:[i.jsx("button",{className:O==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="workspace",onClick:()=>Qe("workspace"),children:r("conversation.filePanelWorkspaceTab")}),i.jsxs("button",{className:O==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="session",onClick:()=>{$e&&Qe("session")},disabled:!$e,children:[r("conversation.filePanelSessionTab"),i.jsx("span",{className:"file-panel-tab-badge","aria-label":`${r("conversation.filePanelSessionTab")} ${sn}`,children:sn})]})]}),O==="workspace"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:mn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void Si(e)}),bn?i.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":r("conversation.filePanelTitle"),children:i.jsxs("div",{className:"file-mobile-action-shell",ref:hn,children:[i.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":r("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":et,"data-active":et,onClick:()=>{I(!1),L(e=>!e)},children:[i.jsx("span",{children:r("conversation.filePanelActionsMenu")}),i.jsx(za,{})]}),et?i.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":r("conversation.filePanelActionsMenu"),children:[i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>me("copy")),disabled:!Te,children:r("conversation.filePanelCopy")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>me("cut")),disabled:!Te,children:r("conversation.filePanelCut")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>st()),disabled:!lt||p||v,children:r("conversation.filePanelPaste")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Tn()},children:Ye?r("conversation.filePanelHideSearch"):r("conversation.filePanelShowSearch")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Wt(e=>!e)},disabled:vt.length===0,children:ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(Rn),disabled:Fe||p||pt,children:r("conversation.filePanelRefresh")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Fn()},disabled:!Cn,children:r("conversation.filePanelCollapseCurrent")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),_n()},disabled:p||v,children:r("conversation.filePanelUpload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(Kt),disabled:!yn||v,children:r("conversation.filePanelDownload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(qt),disabled:!gn||p||v,children:r("conversation.filePanelRenameMove")}),i.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>Z(Yt),disabled:!xn||p||v,children:r("conversation.filePanelDelete")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>Ke("create_file")),disabled:p||v,children:r("conversation.filePanelNewFile")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>Ke("create_directory")),disabled:p||v,children:r("conversation.filePanelNewDirectory")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>Ge("absolute")),disabled:!Vt,children:r("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>Ge("relative")),disabled:!Vt,children:r("conversation.filePanelCopyRelativePath")})]}):null]})}):i.jsxs("div",{className:"file-panel-toolbar","aria-label":r("conversation.filePanelTitle"),children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopy"),"aria-label":r("conversation.filePanelCopy"),onClick:()=>me("copy"),disabled:!Te,children:i.jsx(Aa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCut"),"aria-label":r("conversation.filePanelCut"),onClick:()=>me("cut"),disabled:!Te,children:i.jsx(La,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelPaste"),"aria-label":r("conversation.filePanelPaste"),onClick:()=>void st(),disabled:!lt||p||v,children:i.jsx(Ba,{})}),i.jsxs("div",{className:"file-toolbar-menu-shell",ref:dn,children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopyPath"),"aria-label":r("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":Ie,"data-active":Ie,onClick:()=>{L(!1),I(e=>!e)},disabled:!Vt,children:i.jsx(Fa,{})}),Ie?i.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ge("absolute"),children:r("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ge("relative"),children:r("conversation.filePanelCopyRelativePath")})]}):null]}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCollapseCurrent"),"aria-label":r("conversation.filePanelCollapseCurrent"),onClick:Fn,disabled:!Cn,children:i.jsx(Ta,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRefresh"),"aria-label":r("conversation.filePanelRefresh"),onClick:()=>void Rn(),disabled:Fe||p||pt,children:i.jsx(_a,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),"data-active":Ye,onClick:Tn,disabled:Fe,children:i.jsx(Qn,{})}),vt.length>0?i.jsx("button",{className:"file-toolbar-button",type:"button",title:ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"aria-label":ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"data-active":ee,onClick:()=>Wt(e=>!e),children:i.jsx(Ka,{})}):null,i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelUpload"),"aria-label":r("conversation.filePanelUpload"),onClick:_n,disabled:p||v,children:i.jsx($a,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelDownload"),"aria-label":r("conversation.filePanelDownload"),onClick:()=>void Kt(),disabled:!yn||v,children:i.jsx(Oa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRenameMove"),"aria-label":r("conversation.filePanelRenameMove"),onClick:()=>qt(),disabled:!gn||p||v,children:i.jsx(Ua,{})}),i.jsx("button",{className:"file-toolbar-button danger",type:"button",title:r("conversation.filePanelDelete"),"aria-label":r("conversation.filePanelDelete"),onClick:()=>Yt(),disabled:!xn||p||v,children:i.jsx(Ha,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewFile"),"aria-label":r("conversation.filePanelNewFile"),onClick:()=>void Ke("create_file"),disabled:p||v,children:i.jsx(Wa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewDirectory"),"aria-label":r("conversation.filePanelNewDirectory"),onClick:()=>void Ke("create_directory"),disabled:p||v,children:i.jsx(Va,{})})]}),oe&&typeof document<"u"?Fi.createPortal(i.jsx("div",{className:"file-web-context-menu",ref:$t,role:"menu","aria-label":r("conversation.filePanelActionsMenu"),style:{left:`${(Ce==null?void 0:Ce.left)??Math.max(8,oe.positionX)}px`,top:`${(Ce==null?void 0:Ce.top)??Math.max(8,oe.positionY)}px`,maxHeight:Ce?`${Ce.maxHeight}px`:void 0},children:oe.items.map(e=>i.jsx("button",{className:["file-web-context-menu-item",e.label===r("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,Pn?i.jsx("p",{className:"file-panel-clipboard-status","data-mode":C==null?void 0:C.mode,children:Pn}):null,Ye?i.jsxs("form",{className:"file-toolbar-search",onSubmit:e=>void wi(e),children:[i.jsx("input",{value:A,onChange:e=>Je(e.target.value),placeholder:r("conversation.filePanelSearchPlaceholder")}),bn?i.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":r("conversation.filePanelSearchButton"),disabled:pt,children:r("conversation.filePanelSearchButton")}):i.jsx("button",{className:"file-toolbar-button",type:"submit",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),disabled:pt,children:i.jsx(Qn,{})})]}):null,i.jsx("div",{ref:mi,className:"file-tree","data-search-mode":fe,"data-scrollbar-autohide":"true",children:Fe&&He.length===0?i.jsx("p",{className:"file-tree-status status-text",children:r("common.loading")}):fe?Re!=null&&Re.length?ki(Re):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSearchEmpty")}):ee?yt.length?Zt(yt,0):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelNoChanges")}):He.length?Zt(He,0):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelEmptyDirectory")})}),i.jsx($n,{open:S!==null,title:(U==null?void 0:U.title)??"",description:U==null?void 0:U.description,onClose:Xt,children:i.jsxs("form",{className:"workbench-rename-form",onSubmit:e=>void Ni(e),children:[i.jsx(qi,{label:r("conversation.filePanelPathFieldLabel"),htmlFor:fn,description:(S==null?void 0:S.mode)==="rename"?S.target.path:(S==null?void 0:S.baseDirectory)||void 0,children:i.jsx("input",{id:fn,type:"text",value:Bt??"",placeholder:r("conversation.filePanelPathFieldPlaceholder"),autoFocus:!0,onChange:e=>We(e.target.value)})}),i.jsxs(Yi,{children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:Xt,children:r("common.cancel")}),i.jsx("button",{type:"submit",className:"primary-button",disabled:p||!(Bt??"").trim(),children:p?(U==null?void 0:U.pendingLabel)??r("common.loading"):(U==null?void 0:U.submitLabel)??r("common.save")})]})]})}),i.jsxs($n,{open:B!==null,title:r("conversation.filePanelDeleteConfirmTitle"),description:r("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{p||Be(null)},children:[i.jsx("p",{className:"workbench-section-empty",children:B!=null&&B.length?B.length===1?((Bn=B[0])==null?void 0:Bn.kind)==="directory"?r("conversation.filePanelDeleteDirectoryConfirm",{path:B[0].path}):r("conversation.filePanelDeleteFileConfirm",{path:B[0].path}):r("conversation.filePanelDeleteSelectionConfirm",{count:B.length}):""}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>Be(null),children:r("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{Di()},children:p?r("conversation.filePanelDeleting"):r("conversation.filePanelDelete")})]})]})]}):$e&&n?i.jsx(ea,{sessionId:n,workspaceId:l,showSystemFiles:V,selectedPath:je,refreshVersion:rn,onCountChange:Ot,onSelectFile:he,onOpenFile:ze}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:r("conversation.filePanelSessionNoSession")})})]}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:r("conversation.filePanelNoWorkspace")})})})}function ve(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):g}function dt(t,n=!1){const l=t.split("/").filter(Boolean),s=n?l.length:l.length-1,m=[];for(let h=0;h<s;h+=1)m.push(l.slice(0,h+1).join("/"));return m}function zn(t,n){return t||((n==null?void 0:n.kind)==="directory"?n.path:n!=null&&n.path?ve(n.path):g)}function Kn(t,n){return t?`${t}/${n}`:n}function fa(t){var n;return((n=t.split(/[/\\]/).pop())==null?void 0:n.trim())??""}function z(t,n){return{path:t,kind:n}}function Gn(t){return t[t.length-1]??null}function da(t,n){return t.findIndex(s=>s.path===n.path)>=0?t.filter(s=>s.path!==n.path):[...t,n]}function ha(t,n,l){const s=t.findIndex(x=>x.path===l.path);if(s<0)return[l];const m=n?t.findIndex(x=>x.path===n):s;if(m<0)return[l];const h=Math.min(m,s),b=Math.max(m,s);return t.slice(h,b+1)}function jt(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function ma(t){return t.ctrlKey||t.metaKey}function pa(t){if(!(t instanceof HTMLElement))return!1;const n=t.tagName.toLowerCase();return n==="input"||n==="textarea"||n==="select"||t.isContentEditable}function wt(t){const n=[...new Map(t.map(s=>[s.path,s])).values()].sort((s,m)=>s.path.localeCompare(m.path)),l=[];for(const s of n)l.some(m=>m.kind==="directory"&&Tt(m.path,s.path))||l.push(s);return l}function ba(t,n){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?ve(t.path):n}function va(t,n){let l=t;for(;l&&n.some(s=>s.kind==="directory"&&Tt(s.path,l));)l=ve(l);return l}function oi(t,n,l,s,m,h){const b=[];for(const x of t){if(b.push(z(x.path,x.kind)),x.kind!=="directory"||!l.includes(x.path))continue;const j=n[x.path]??[],_=s?an(j,n,m,h):j;b.push(...oi(_,n,l,s,m,h))}return b}function ya(t,n,l){const s=Math.max(0,l.width),m=Math.max(0,l.height),h=Math.max(0,m-ne*2),b=Math.max(0,s-ne*2),x=Math.min(Math.max(n.width,0),b),j=Math.max(0,m-t.y-Pt-ne),_=Math.max(0,t.y-Pt-ne),M=j<n.height&&_>j,ye=It(Math.max(M?_:j,aa),0,h),K=Math.min(Math.max(n.height,0),ye),xe=M?t.y-Pt-K:t.y+Pt,ge=Math.max(ne,m-ne-K),G=Math.max(ne,s-ne-x);return{top:It(xe,ne,ge),left:It(t.x,ne,G),maxHeight:Math.max(0,ye)}}function It(t,n,l){return!Number.isFinite(t)||l<n?n:Math.min(Math.max(t,n),l)}function qe(t,n="posix"){return t?ri(t,n):"."}function xa(t,n,l){const s=ri(t,l),m=qe(n,l).replace(/^\.[/\\]?/,"");if(!m)return s;const h=si(l),b=m.replace(/^[/\\]+/,"");return b?s.endsWith("/")||s.endsWith("\\")?`${s}${b}`:`${s}${h}${b}`:s}function ga(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function ri(t,n){return t&&(si(n)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function si(t){return t==="windows"?"\\":"/"}function Tt(t,n){return n===t||n.startsWith(`${t}/`)}function ci(t,n,l){return t===n?l:t.startsWith(`${n}/`)?`${l}${t.slice(n.length)}`:t}function Ca(t,n,l){return t.map(s=>({...s,path:ci(s.path,n,l)}))}function Pa(t){return t.mode==="create_file"?{title:r("conversation.filePanelNewFile"),description:r("conversation.filePanelCreateFileDescription"),submitLabel:r("conversation.filePanelCreateFileSubmit"),pendingLabel:r("conversation.filePanelCreatingFile")}:t.mode==="create_directory"?{title:r("conversation.filePanelNewDirectory"),description:r("conversation.filePanelCreateDirectoryDescription"),submitLabel:r("conversation.filePanelCreateDirectorySubmit"),pendingLabel:r("conversation.filePanelCreatingDirectory")}:{title:r("conversation.filePanelRenameMove"),description:r("conversation.filePanelRenameDescription"),submitLabel:r("conversation.filePanelRenameSubmit"),pendingLabel:r("conversation.filePanelRenaming")}}async function ja(t){const n=await t.arrayBuffer(),l=new Uint8Array(n),s=32768;let m="";for(let h=0;h<l.length;h+=s){const b=l.subarray(h,h+s);m+=String.fromCharCode(...b)}return btoa(m)}function wa(t){const n=atob(t),l=new Uint8Array(n.length);for(let s=0;s<n.length;s+=1)l[s]=n.charCodeAt(s);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}function Sa(t,n){if(typeof document>"u")throw new Error(r("conversation.filePanelDownloadFailed"));const l=window.URL.createObjectURL(n),s=document.createElement("a");s.href=l,s.download=t,document.body.append(s),s.click(),s.remove(),window.URL.revokeObjectURL(l)}async function Na(t,n){var l;if(!(n.isDesktop&&(await n.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((l=navigator.clipboard)!=null&&l.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!Da(t))throw new Error(r("conversation.filePanelCopyPathFailed"))}}function Da(t){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.left="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n)}}function Ea(t,n){return t&&dt(t,!0).every(m=>m in n)?t:g}function Xn(t,n){if(!n)return[];const l=dt(n,!0);return t.filter(s=>l.includes(s))}function St(t,n,l){const s=on(n,l);return Object.entries(t).reduce((m,[h,b])=>(s.has(h)&&(m[h]=b),m),{})}function ka(t,n,l){const m=[...on(n,l)].filter(h=>h===g||h in t);return m.length?m:[g]}function on(t,n){const l=new Set([g]),s=ui(n,dt(t,!0));for(const m of s){l.add(m);for(const h of dt(m,!0))l.add(h)}return l}function Ma(t,n){const l=Object.keys(t),s=Object.keys(n);return l.length!==s.length?!1:l.every(m=>t[m]===n[m])}function kt(t,n){return t.includes(n)?t:[...t,n]}function ui(t,n){return n.reduce((l,s)=>kt(l,s),t)}function qn(t){return`file-panel.workspace-tree.${t}`}function Yn(t,n){return`file-panel.session-change-count.${t}.${n}`}function Zn(t,n){return Object.fromEntries(Object.keys(n).map(l=>[l,t[l]??null]))}function en(t,n){return[...on(n,t)]}function J(t,n){return t instanceof In?t.message:n}function fi(t){return t instanceof Error&&t.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")}function Jn(t){return fi(t)||t instanceof Error&&t.message.startsWith("FILE_TREE_ABORTED:")}function Ra(t){return new Promise(n=>{window.setTimeout(n,t)})}function Ta(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function _a(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 Fa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.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"}),i.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Aa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function La(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 Ba(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Wa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function $a(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.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 Ha(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 Va(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ua(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.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 za(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function Ka(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function an(t,n,l,s){const m=[];for(const h of t){const b=h.path.replace(/\\/g,"/");h.kind==="file"?l.has(b)&&m.push(h):di(b,n,l,s)&&m.push(h)}return m}function di(t,n,l,s,m){const h=m??new Set;if(h.has(t))return!1;h.add(t);const b=n[t];if(!b)return s.has(t);for(const x of b){const j=x.path.replace(/\\/g,"/");if(x.kind==="file"){if(l.has(j))return!0}else if(di(j,n,l,s,h))return!0}return!1}export{nl as FileContextPanel};
|