@jingyi0605/codingns 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/public/assets/{AdaptiveButlerPage-SffCV4Vb.js → AdaptiveButlerPage-uFwDdN-F.js} +3 -3
- package/dist/public/assets/App-BZvapsi8.js +30 -0
- package/dist/public/assets/App-CcDXqFl1.css +1 -0
- package/dist/public/assets/{BootstrapPage--zExdgfM.js → BootstrapPage-gHSoa4JN.js} +1 -1
- package/dist/public/assets/ConversationPage-z3sXtKZ7.js +4 -0
- package/dist/public/assets/{DesktopDetachPreviewPage-DvI9CIKi.js → DesktopDetachPreviewPage-4eMRxiBW.js} +1 -1
- package/dist/public/assets/DesktopWindowPage-CZcoGApB.js +2 -0
- package/dist/public/assets/FileContextPanel-C3qex8bb.js +1 -0
- package/dist/public/assets/GitSidebar-BK6H16XU.js +6 -0
- package/dist/public/assets/{MobileCreateSessionSheet-CXSKMnYn.js → MobileCreateSessionSheet-BYfbvK8o.js} +1 -1
- package/dist/public/assets/MobileSheet-Ckug8hTb.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-BWorAJ1C.js → MobileTopHeaderFrame-Bwv8Ovm_.js} +1 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-RqWrBdn2.js +1 -0
- package/dist/public/assets/RelayConnectEntryPage-D_4YL-YH.js +1 -0
- package/dist/public/assets/ServerSettingsModal-CMSm3BZU.js +1 -0
- package/dist/public/assets/SessionIndexPage-DuK10DL5.js +1 -0
- package/dist/public/assets/SettingsPage-fyD-xaHL.js +1 -0
- package/dist/public/assets/TerminalManagerPanel-CCLr1Ypk.js +1 -0
- package/dist/public/assets/{TerminalPage-CvnHXBhw.js → TerminalPage-DaooFaJ4.js} +19 -19
- package/dist/public/assets/{TerminalRuntimeFallbackModal-D7Aq186N.js → TerminalRuntimeFallbackModal-aUzjEBwP.js} +1 -1
- package/dist/public/assets/ToolFilesPage-CGxBvYG0.js +1 -0
- package/dist/public/assets/ToolGitPage-C264yjS9.js +1 -0
- package/dist/public/assets/ToolProcessesPage-BOP4A1cb.js +1 -0
- package/dist/public/assets/ToolsHomePage-CQxGiKQA.js +1 -0
- package/dist/public/assets/WorkbenchLandingPage-CvAY68ca.js +1 -0
- package/dist/public/assets/WorkbenchLayout-DGm8Tc5M.js +3 -0
- package/dist/public/assets/{WorkbenchModal-B09hC9b5.js → WorkbenchModal-0tPIIhca.js} +1 -1
- package/dist/public/assets/{WorkbenchShellRoute-DsW4mBTX.css → WorkbenchShellRoute-BF0nHWOk.css} +1 -1
- package/dist/public/assets/WorkbenchShellRoute-DBBOsJo9.js +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-CDerFYd2.js +1 -0
- package/dist/public/assets/WorkspaceDetailPage-BlJc1CHE.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-BUsKJ3lv.js +1 -0
- package/dist/public/assets/client-runtime-manager-BZpL17fc.js +1 -0
- package/dist/public/assets/{default-session-permission-mode-D0wZ9Jek.js → default-session-permission-mode-DT4SGiwp.js} +1 -1
- package/dist/public/assets/file-tree-icon-Db5LXC8h.js +31 -0
- package/dist/public/assets/index-BZLcEHW3.js +42 -0
- package/dist/public/assets/index-BbspQPC2.css +1 -0
- package/dist/public/assets/login-direct-candidate-resolver-1mxe_Oh8.js +1 -0
- package/dist/public/assets/{preferences-service-gOt2ZjKZ.js → preferences-service-DWnzl5a0.js} +1 -1
- package/dist/public/assets/relay-entry-C5_Iay0I.js +1 -0
- package/dist/public/assets/session-runtime-machine-DdLeDqQr.js +17 -0
- package/dist/public/assets/{styles-BWPBZvze.css → styles-CsEMfdaS.css} +1 -1
- package/dist/public/assets/{terminal-runtime-meta-BMT-rSEe.js → terminal-runtime-meta-cdtWVfCm.js} +1 -1
- package/dist/public/assets/{useRegisteredDebugTemplates-zMcEOGca.js → useRegisteredDebugTemplates-oFAQNIqh.js} +1 -1
- package/dist/public/assets/window-BVUB8gMK.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +2 -0
- package/dist/server/config/env.js +39 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/modules/client/npm-global-package-service.d.ts +7 -1
- package/dist/server/modules/client/npm-global-package-service.js +149 -43
- package/dist/server/modules/client/npm-global-package-service.js.map +1 -1
- package/dist/server/modules/client/service-update-task-service.js +6 -2
- package/dist/server/modules/client/service-update-task-service.js.map +1 -1
- package/dist/server/modules/client/service-update-types.d.ts +2 -0
- package/dist/server/modules/git/git-controller.d.ts +3 -0
- package/dist/server/modules/git/git-controller.js +3 -0
- package/dist/server/modules/git/git-controller.js.map +1 -1
- package/dist/server/modules/git/git-read-service.js +47 -1
- package/dist/server/modules/git/git-read-service.js.map +1 -1
- package/dist/server/modules/git/git-write-service.d.ts +4 -0
- package/dist/server/modules/git/git-write-service.js +24 -0
- package/dist/server/modules/git/git-write-service.js.map +1 -1
- package/dist/server/modules/git/types.d.ts +1 -0
- package/dist/server/modules/git/workspace-repo-guard.d.ts +2 -0
- package/dist/server/modules/git/workspace-repo-guard.js +24 -10
- package/dist/server/modules/git/workspace-repo-guard.js.map +1 -1
- package/dist/server/modules/parallel-sessions/parallel-session-controller.d.ts +53 -0
- package/dist/server/modules/parallel-sessions/parallel-session-controller.js +70 -0
- package/dist/server/modules/parallel-sessions/parallel-session-controller.js.map +1 -0
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.d.ts +83 -0
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.js +591 -0
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.js.map +1 -0
- package/dist/server/modules/parallel-sessions/session-isolated-workspace-service.d.ts +56 -0
- package/dist/server/modules/parallel-sessions/session-isolated-workspace-service.js +483 -0
- package/dist/server/modules/parallel-sessions/session-isolated-workspace-service.js.map +1 -0
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-packets.d.ts +16 -1
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-packets.js.map +1 -1
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.d.ts +2 -1
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.js +18 -0
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.js.map +1 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-candidate-endpoints.d.ts +2 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-candidate-endpoints.js +129 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-candidate-endpoints.js.map +1 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-client-context.d.ts +13 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-client-context.js +2 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-client-context.js.map +1 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.d.ts +6 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.js +110 -10
- package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.js.map +1 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.d.ts +16 -4
- package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js +220 -102
- package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js.map +1 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.d.ts +4 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js +257 -162
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js.map +1 -1
- package/dist/server/modules/sessions/codex-app-server-helper-client.d.ts +3 -0
- package/dist/server/modules/sessions/codex-app-server-helper-client.js +56 -45
- package/dist/server/modules/sessions/codex-app-server-helper-client.js.map +1 -1
- package/dist/server/modules/sessions/codex-app-server-helper-process.js +21 -2
- package/dist/server/modules/sessions/codex-app-server-helper-process.js.map +1 -1
- package/dist/server/modules/sessions/session-activity-inspector.js +6 -8
- package/dist/server/modules/sessions/session-activity-inspector.js.map +1 -1
- package/dist/server/modules/sessions/session-history-service.d.ts +11 -1
- package/dist/server/modules/sessions/session-history-service.js +204 -21
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-service.d.ts +8 -0
- package/dist/server/modules/sessions/session-live-runtime-service.js +208 -25
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
- package/dist/server/modules/workbench/codex-archive-watcher.d.ts +16 -0
- package/dist/server/modules/workbench/codex-archive-watcher.js +50 -0
- package/dist/server/modules/workbench/codex-archive-watcher.js.map +1 -0
- package/dist/server/modules/workbench/workbench-service.d.ts +43 -4
- package/dist/server/modules/workbench/workbench-service.js +72 -9
- package/dist/server/modules/workbench/workbench-service.js.map +1 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.d.ts +1 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js +26 -3
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js.map +1 -1
- package/dist/server/modules/workspace/workspace-service.d.ts +3 -1
- package/dist/server/modules/workspace/workspace-service.js +10 -2
- package/dist/server/modules/workspace/workspace-service.js.map +1 -1
- package/dist/server/modules/worktree/worktree-base-ref-resolver.d.ts +20 -0
- package/dist/server/modules/worktree/worktree-base-ref-resolver.js +111 -0
- package/dist/server/modules/worktree/worktree-base-ref-resolver.js.map +1 -0
- package/dist/server/modules/worktree/worktree-cleanup-service.js +9 -3
- package/dist/server/modules/worktree/worktree-cleanup-service.js.map +1 -1
- package/dist/server/modules/worktree/worktree-manager.d.ts +0 -1
- package/dist/server/modules/worktree/worktree-manager.js +14 -20
- package/dist/server/modules/worktree/worktree-manager.js.map +1 -1
- package/dist/server/routes/git.js +1 -0
- package/dist/server/routes/git.js.map +1 -1
- package/dist/server/routes/parallel-groups.d.ts +3 -0
- package/dist/server/routes/parallel-groups.js +9 -0
- package/dist/server/routes/parallel-groups.js.map +1 -0
- package/dist/server/server/create-server.d.ts +8 -0
- package/dist/server/server/create-server.js +48 -9
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/server/workbench-runtime-terminal-sync.d.ts +14 -0
- package/dist/server/server/workbench-runtime-terminal-sync.js +17 -0
- package/dist/server/server/workbench-runtime-terminal-sync.js.map +1 -0
- package/dist/server/storage/repositories/parallel-session-group-repository.d.ts +11 -0
- package/dist/server/storage/repositories/parallel-session-group-repository.js +131 -0
- package/dist/server/storage/repositories/parallel-session-group-repository.js.map +1 -0
- package/dist/server/storage/repositories/parallel-session-member-repository.d.ts +12 -0
- package/dist/server/storage/repositories/parallel-session-member-repository.js +150 -0
- package/dist/server/storage/repositories/parallel-session-member-repository.js.map +1 -0
- package/dist/server/storage/repositories/session-isolated-workspace-repository.d.ts +15 -0
- package/dist/server/storage/repositories/session-isolated-workspace-repository.js +230 -0
- package/dist/server/storage/repositories/session-isolated-workspace-repository.js.map +1 -0
- package/dist/server/storage/sqlite/schema.sql +73 -0
- package/dist/server/types/domain.d.ts +72 -0
- package/dist/server/ws/workbench-ws-hub.d.ts +3 -1
- package/dist/server/ws/workbench-ws-hub.js +189 -20
- package/dist/server/ws/workbench-ws-hub.js.map +1 -1
- package/dist/server/ws/ws-server.js +141 -8
- package/dist/server/ws/ws-server.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +67 -6
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.d.ts +3 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js +46 -22
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +558 -309
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js +29 -5
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js.map +1 -1
- package/package.json +1 -1
- package/dist/public/assets/App-DUAg5urj.css +0 -1
- package/dist/public/assets/App-WOLwMld_.js +0 -30
- package/dist/public/assets/ConversationPage-D9pzRmOg.js +0 -2
- package/dist/public/assets/DesktopWindowPage-D8FpOSLE.js +0 -2
- package/dist/public/assets/FileContextPanel-C8T7oqRN.js +0 -1
- package/dist/public/assets/GitSidebar-Bze7DNnc.js +0 -6
- package/dist/public/assets/MobileSheet-Gzc14EpR.js +0 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-DOr4pTUq.js +0 -1
- package/dist/public/assets/ServerSettingsModal-BYB0GvTl.js +0 -1
- package/dist/public/assets/SessionIndexPage-CR3IARXX.js +0 -1
- package/dist/public/assets/SettingsPage-B_BQtnwE.js +0 -1
- package/dist/public/assets/TerminalManagerPanel-PQ-EM64j.js +0 -1
- package/dist/public/assets/ToolFilesPage-Qzkc6K2I.js +0 -1
- package/dist/public/assets/ToolGitPage-BdNDN-cV.js +0 -1
- package/dist/public/assets/ToolProcessesPage-EXJ9DHWI.js +0 -1
- package/dist/public/assets/ToolsHomePage-CjF3CWzR.js +0 -1
- package/dist/public/assets/WorkbenchLandingPage-DZPk4SmX.js +0 -1
- package/dist/public/assets/WorkbenchLayout-rwQib5In.js +0 -3
- package/dist/public/assets/WorkbenchShellRoute-Cerk5uK7.js +0 -1
- package/dist/public/assets/WorkspaceDebugDetailPage-Bcq8s-Ma.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-DNAa8pKr.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-BoiLuACV.js +0 -1
- package/dist/public/assets/client-runtime-manager-CRQ-F5d2.js +0 -1
- package/dist/public/assets/file-tree-icon-Dp_xhVfD.js +0 -31
- package/dist/public/assets/index-C2G8Gmf1.js +0 -42
- package/dist/public/assets/index-CpPTUeA3.css +0 -1
- package/dist/public/assets/session-runtime-machine-Dq3pW-UF.js +0 -17
- package/dist/public/assets/window-BWqRixxq.js +0 -1
- /package/dist/public/assets/{styles-CSUx5LGe.js → styles-DRVvx_kv.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as c,j as n,t as o,A as Yn}from"./index-BZLcEHW3.js";import{f as Qn,e as wi,g as Ni}from"./App-BZvapsi8.js";import{aj as Di,u as Ei,h as ki,x as Mi}from"./MobileSheet-Ckug8hTb.js";import{aQ as Ri,r as en,w as wt,aR as _i,u as Ti,V as ke,aS as Fi,aT as yt,aU as Ve,aV as Ai,aW as Li,aX as Bi}from"./WorkbenchLayout-DGm8Tc5M.js";import{W as Ln}from"./WorkbenchModal-0tPIIhca.js";import{a as Mt,b as Rt,F as Wi}from"./file-tree-icon-Db5LXC8h.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-C5_Iay0I.js";const $i=new Set([".ds_store","thumbs.db","ehthumbs.db","desktop.ini",".spotlight-v100",".trashes",".fseventsd","__macosx","$recycle.bin","system volume information",".apdisk",".appledouble",".temporaryitems"]),Oi=["._"];function xt(t){return t.split(/[/\\]/).filter(Boolean).pop()??t}function Hi(t){const i=t.trim().toLowerCase();return i?$i.has(i)||Oi.some(l=>i.startsWith(l)):!1}function nn(t,i,l){return l?[...t]:t.filter(r=>!Hi(i(r)))}function Nt(t,i){return nn(t,l=>l.name,i)}function Ui(t,i){return i?t:Object.entries(t).reduce((l,[r,h])=>(l[r]=Nt(h,!1),l),{})}async function Qt(t,i){const[l,r]=await Promise.all([Ri(i),Di(t)]);return zi(l.changes,r.items)}function zi(t,i){const l=new Set(i.map(r=>Et(r.path)));return t.filter(r=>l.has(Et(r.path))||r.oldPath!==null&&l.has(Et(r.oldPath)))}function Vi(t){const i=Bn("","");for(const l of t){const r=Et(l.path),h=r.split("/").filter(Boolean);let d=i;h.forEach((p,y)=>{const C=h.slice(0,y+1).join("/");if(y===h.length-1){d.children.set(`file:${C}`,{kind:"file",name:p,path:r,change:l});return}const F=`directory:${C}`,_=d.children.get(F);if(_&&_.kind==="directory"){d=_;return}const Q=Bn(p,C);d.children.set(F,Q),d=Q})}return In(Jn([...i.children.values()]))}function Zn(t,i){const l=t.oldPath?`${t.oldPath} -> ${t.path}`:t.path;return an(t)?`${l} ${i}`:l}function an(t){return t.status==="D"||t.stagedStatus==="D"||t.worktreeStatus==="D"}function Dt(t){return t.split("/").filter(Boolean).pop()??t}function Et(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function Bn(t,i){return{kind:"directory",name:t,path:i,children:new Map}}function Jn(t){return[...t].sort((i,l)=>i.kind!==l.kind?i.kind==="directory"?-1:1:i.name.localeCompare(l.name,"zh-CN")).map(i=>i.kind==="directory"?{kind:"directory",name:i.name,path:i.path,children:Jn([...i.children.values()])}:i)}function In(t){return t.map(i=>{var p;if(i.kind!=="directory")return i;const l=In(i.children);let r=i.name,h=i.path,d=l;for(;d.length===1&&((p=d[0])==null?void 0:p.kind)==="directory";){const y=d[0];r=`${r}/${y.name}`,h=y.path,d=y.children}return{kind:"directory",name:r,path:h,children:d}})}const Ki=450,Gi=60*1e3,Wn=20,$n=16;function Xi({sessionId:t,workspaceId:i,showSystemFiles:l,selectedPath:r,refreshVersion:h,onCountChange:d,onSelectFile:p,onOpenFile:y}){const[C,F]=c.useState("tree"),[_,Q]=c.useState([]),[he,V]=c.useState(!0),[me,pe]=c.useState(!1),[K,ft]=c.useState([]),M=c.useRef(null),{showToast:Ce}=Qn();c.useEffect(()=>{const v=en(gt(i,t),Gi);F("tree"),Q(v??[]),V(v===null),pe(!1),ft([]),M.current=null},[t,i]),c.useEffect(()=>{let v=!1;async function b(){V(!0);try{const w=await Qt(t,i);v||(Q(w),wt(gt(i,t),w))}catch(w){v||Ce({title:Zt(w,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{v||V(!1)}}return b(),()=>{v=!0}},[h,t,Ce,i]);async function Tt(){V(!0);try{const v=await Qt(t,i);Q(v),wt(gt(i,t),v)}catch(v){Ce({title:Zt(v,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{V(!1)}}async function je(){if(Me.length!==0){pe(!0);try{await _i(i,Me.map(b=>b.path));const v=await Qt(t,i);Q(v),wt(gt(i,t),v),Ce({title:o("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(v){Ce({title:Zt(v,o("git.stageFailed")),tone:"error"})}finally{pe(!1)}}}function E(v){ft(b=>b.includes(v)?b.filter(w=>w!==v):[...b,v])}function A(v){const b=Date.now(),w=M.current;return M.current={filePath:v,timestamp:b},(w==null?void 0:w.filePath)===v&&b-w.timestamp<=Ki}async function O(v,b){if(b&&A(v)){await y(v),M.current=null;return}b||(M.current=null),await p(v)}const k=c.useMemo(()=>nn(_,v=>Dt(v.path),l),[_,l]),Me=k.filter(v=>!v.staged),G=Vi(k),Re=new Set(K);return c.useEffect(()=>{d==null||d(k.length)},[d,k.length]),n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"file-panel-session-toolbar",children:[n.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":o("conversation.filePanelSessionViewLabel"),children:[n.jsx("button",{className:C==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":C==="tree",onClick:()=>F("tree"),children:o("conversation.filePanelSessionTreeView")}),n.jsx("button",{className:C==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":C==="list",onClick:()=>F("list"),children:o("conversation.filePanelSessionListView")})]}),n.jsxs("div",{className:"file-panel-session-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Tt(),disabled:he||me,children:o("conversation.filePanelRefresh")}),n.jsx("button",{className:"primary-button",type:"button",onClick:()=>void je(),disabled:me||Me.length===0,children:o("conversation.filePanelSessionStageAll")})]})]}),n.jsxs("div",{className:"file-panel-session-summary",children:[n.jsx("span",{children:`${o("conversation.filePanelSessionSummary")} ${k.length}`}),n.jsx("span",{children:`${o("conversation.filePanelSessionUnstagedSummary")} ${Me.length}`})]}),n.jsx("div",{className:"file-tree",children:he?n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionLoading")}):k.length===0?n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionEmpty")}):C==="tree"?ei({nodes:G,depth:0,collapsedPathSet:Re,selectedPath:r,onToggleTreePath:E,onFileClick:O}):qi({items:k,selectedPath:r,onFileClick:O})})]})}function ei({nodes:t,depth:i,collapsedPathSet:l,selectedPath:r,onToggleTreePath:h,onFileClick:d}){return t.map(p=>{if(p.kind==="directory"){const y=!l.has(p.path);return n.jsxs("div",{className:"file-tree-node",children:[n.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":y,style:{paddingInlineStart:`${Wn+i*$n}px`},onClick:()=>h(p.path),children:[n.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:y?"v":">"}),n.jsx("span",{className:"file-tree-label",children:p.name})]}),y?n.jsx("div",{className:"file-tree-children",children:ei({nodes:p.children,depth:i+1,collapsedPathSet:l,selectedPath:r,onToggleTreePath:h,onFileClick:d})}):null]},`session-directory:${p.path}`)}return n.jsx("div",{className:"file-tree-node",children:n.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":r===p.change.path,"data-kind":"file",style:{paddingInlineStart:`${Wn+i*$n}px`},onClick:()=>void d(p.change.path,!an(p.change)),children:[n.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(p.name),"aria-hidden":"true",children:Mt(p.name)}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:p.name}),n.jsx("span",{className:"file-tree-path",children:Zn(p.change,o("conversation.filePanelSessionDeleted"))})]}),n.jsxs("span",{className:"file-session-item-meta",children:[n.jsx("span",{className:"file-session-badge","data-status":p.change.status,children:p.change.status}),n.jsx("span",{className:"file-session-badge subtle",children:p.change.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-file:${p.path}`)})}function qi({items:t,selectedPath:i,onFileClick:l}){return t.map(r=>n.jsx("div",{className:"file-session-list-item",children:n.jsxs("button",{className:"file-session-list-button",type:"button","data-active":i===r.path,onClick:()=>void l(r.path,!an(r)),children:[n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(Dt(r.path)),"aria-hidden":"true",children:Mt(Dt(r.path))}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:Dt(r.path)}),n.jsx("span",{className:"file-tree-path",children:Zn(r,o("conversation.filePanelSessionDeleted"))})]}),n.jsxs("span",{className:"file-session-item-meta",children:[n.jsx("span",{className:"file-session-badge","data-status":r.status,children:r.status}),n.jsx("span",{className:"file-session-badge subtle",children:r.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-list:${r.path}`))}function gt(t,i){return`file-panel.session-changes.${t}.${i}`}function Zt(t,i){return t instanceof Yn?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??i):i}const g="",Yi=450,te=8,Pt=4,Qi=176,Zi=120,Ji=300*1e3,Ii=60*1e3,On=1600,ea=20,ta=16;function Ga({className:t,sessionId:i,workspaceId:l,hideHeading:r=!1,hideTabs:h=!1,externalRevealRequest:d=null,externalWindowMode:p=!1,workbenchShellOverrides:y}){var Tn,Fn;const C=Ti(),{navigationGroups:F,subscribeFileTree:_,requestFileTreeRefresh:Q,addFileTreeSnapshotListener:he,subscribeGitSnapshot:V,requestGitRefresh:me,addGitSnapshotListener:pe}={...C,...y},[K,ft]=c.useState({}),[M,Ce]=c.useState([]),[Tt,je]=c.useState([]),[E,A]=c.useState(g),[O,k]=c.useState([]),[Me,G]=c.useState(null),[Re,v]=c.useState(!1),[b,w]=c.useState(!1),[N,dt]=c.useState(!1),[Ge,Xe]=c.useState(!1),[L,qe]=c.useState(""),[Ft,X]=c.useState(null),[ht,mt]=c.useState(!1),[Se,Ye]=c.useState(null),[q,Qe]=c.useState("workspace"),[sn,_e]=c.useState(0),[on,At]=c.useState(0),[Ze,Z]=c.useState(!1),[Je,B]=c.useState(!1),[ie,H]=c.useState(null),[be,Te]=c.useState(null),[W,Fe]=c.useState(null),[P,Lt]=c.useState(null),[S,Ie]=c.useState(null),[Bt,Ae]=c.useState(""),[rn,cn]=c.useState([]),[J,Wt]=c.useState(!1),[oi,ve]=c.useState(null),un=c.useId(),ae=c.useRef({}),le=c.useRef({}),T=c.useRef([]),I=c.useRef(g),et=c.useRef(!1),tt=c.useRef(null),fn=c.useRef(null),dn=c.useRef(null),$t=c.useRef(null),hn=c.useRef(null),mn=c.useRef(null),ye=c.useRef(0),se=c.useRef(new Map),{showToast:j}=Qn(),nt=wi(),ee=Ei(e=>e.showSystemFiles),it=!!(i!=null&&i.trim()),pn=r&&nt.isMobile;c.useEffect(()=>{ke("file_panel.props",{sessionId:i,workspaceId:l,externalWindowMode:p})},[p,i,l]),c.useEffect(()=>{I.current=E},[E]);function we(e){ft(a=>{const s=typeof e=="function"?e(a):e;return ae.current=s,s})}function Le(e){Ce(a=>{const s=typeof e=="function"?e(a):e;return T.current=s,s})}c.useEffect(()=>{var f,m;if(zt(),!l){zt(),et.current=!1,ae.current={},le.current={},T.current=[],I.current=g,we({}),Le([]),je([]),A(g),Xe(!1),qe(""),X(null),mt(!1),v(!1),Wt(!1),ve(null),k([]),G(null),H(null),Te(null),Fe(null),Ie(null),Ae("");return}et.current=!0;const e=en(Kn(l),Ji);ke("file_panel.workspace_snapshot",{workspaceId:l,cached:!!e,cachedRootItems:((m=(f=e==null?void 0:e.treeCache)==null?void 0:f[g])==null?void 0:m.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const a=xa((e==null?void 0:e.activeDirectoryPath)??g,(e==null?void 0:e.treeCache)??{}),s=Vn((e==null?void 0:e.expandedDirectories)??[],a),u=St((e==null?void 0:e.treeCache)??{},a,s);ae.current=u,le.current=Gn((e==null?void 0:e.treeRevisionByPath)??{},u),T.current=s,I.current=a,we(u),Le(s),je([]),A(a),v(!1),w(!1),Xe(!1),qe(""),X(null),mt(!1),queueMicrotask(()=>{et.current=!1})},[l]),c.useEffect(()=>{if(!d||d.workspaceId!==l)return;const e=()=>{if(mn.current===d.requestId)return;mn.current=d.requestId,Qe("workspace"),(d.openViewer?He(d.filePath):re(d.filePath)).catch(s=>{j({title:ne(s,o("conversation.filePanelOpenFailed")),tone:"error"})})};if(et.current){queueMicrotask(e);return}e()},[d,He,re,j,l]),c.useEffect(()=>{if(l)return he(e=>{e.workspaceId===l&&(le.current={...le.current,[e.path]:typeof e.revision=="string"?e.revision:null},we(a=>({...a,[e.path]:e.items})),e.path===g&&v(!1),je(a=>a.filter(s=>s!==e.path)),ui(e.path,e.items))})},[he,l]),c.useEffect(()=>()=>{zt()},[]),c.useEffect(()=>{l&&_(l,It(T.current,I.current),{knownRevisionByPath:le.current})},[E,M,_,l]),c.useEffect(()=>{k([]),G(null),Ye(null),ve(null),_e(0),Z(!1),B(!1),H(null),Te(null),Fe(null),Ie(null),Ae(""),tt.current=null,ye.current+=1},[i]),c.useEffect(()=>{!it&&q==="session"&&Qe("workspace")},[q,it]),c.useEffect(()=>{h&&q!=="workspace"&&Qe("workspace")},[q,h]),c.useEffect(()=>{if(!Ze&&!Je&&!ie)return;function e(s){var x,D,ue;if(!(s.target instanceof Node))return;const u=((x=fn.current)==null?void 0:x.contains(s.target))??!1,f=((D=dn.current)==null?void 0:D.contains(s.target))??!1,m=((ue=$t.current)==null?void 0:ue.contains(s.target))??!1;!u&&!f&&!m&&(Z(!1),B(!1),H(null),Te(null))}function a(s){s.key==="Escape"&&(Z(!1),B(!1),H(null),Te(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",a)}},[Ze,Je,ie]),c.useLayoutEffect(()=>{if(!ie||typeof window>"u"){Te(null);return}const e=ie;function a(){const u=$t.current;if(!u)return;const f=u.getBoundingClientRect();Te(ca({x:e.positionX,y:e.positionY},{width:f.width||Qi,height:f.height||u.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}a();const s=window.requestAnimationFrame(a);return window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}},[ie]),c.useEffect(()=>{if(!l)return;const e=Vn(M,E),a=St(K,E,e);wt(Kn(l),{treeCache:a,treeRevisionByPath:Gn(le.current,a),expandedDirectories:e,activeDirectoryPath:E})},[E,M,K,l]),c.useEffect(()=>{if(et.current)return;const e=St(K,E,M);Pa(K,e)||we(e)},[E,M,K]),c.useEffect(()=>{let e=!1;const a=(l==null?void 0:l.trim())??null;async function s(f){if(!a)return;const m=Nt(ae.current[g]??[],ee),x=(f==null?void 0:f.silent)!==!0&&m.length===0;x&&v(!0),ke("file_panel.load_root_tree.start",{sessionId:i,workspaceId:a,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:m.length});try{const D=await Ut(g,{force:!0});e||(ke("file_panel.load_root_tree.end",{sessionId:i,workspaceId:a,itemCount:D.length}),we(ue=>({...St(ue,I.current,T.current),[g]:D})))}catch(D){!e&&!Xn(D)&&j({title:ne(D,o("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&x&&v(!1)}}if(Nt(ae.current[g]??[],ee).length>0){const f=window.setTimeout(()=>{a&&(_(a,It(T.current,I.current),{knownRevisionByPath:le.current}),s({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return s(),()=>{e=!0}},[i,ee,j,l]),c.useEffect(()=>{if(!l||!i){At(0);return}const e=en(Ca(l,i),Ii);ke("file_panel.session_change_count.snapshot",{sessionId:i,workspaceId:l,cached:e!==null,cachedCount:e}),At(e??0)},[i,sn,l]),c.useEffect(()=>{if(!l){cn([]);return}const e=l.trim();V(e),me(e)},[l,V,me]),c.useEffect(()=>{if(!l)return;const e=l.trim();return pe(a=>{var s;a.workspaceId===e&&cn(((s=a.status)==null?void 0:s.changes)??[])})},[pe,l]);const pt=c.useMemo(()=>nn(rn,e=>xt(e.path),ee),[rn,ee]),$=c.useMemo(()=>{const e=new Map,a=new Set;for(const s of pt){const u=s.path.replace(/\\/g,"/"),f=s.worktreeStatus??s.stagedStatus??s.status;e.set(u,f);const m=u.split("/");for(let x=1;x<m.length;x++)a.add(m.slice(0,x).join("/"))}return{statusByPath:e,changedDirs:a}},[pt]),Ne=c.useMemo(()=>Ui(K,ee),[ee,K]),De=c.useMemo(()=>Ft===null?null:Nt(Ft,ee),[Ft,ee]),Be=Ne[g]??[],oe=Ge&&De!==null,bt=c.useMemo(()=>J?tn(Be,Ne,$.statusByPath,$.changedDirs):Be,[$.changedDirs,$.statusByPath,Be,J,Ne]),ri=c.useMemo(()=>oe?(De??[]).map(e=>z(e.path,e.kind)):ti(bt,Ne,M,J,$.statusByPath,$.changedDirs),[M,$.changedDirs,$.statusByPath,oe,J,De,Ne,bt]),We=((Tn=F.find(e=>e.workspace.id===l))==null?void 0:Tn.workspace)??null,R=zn(O),Ot=(R==null?void 0:R.path)??null,xe=(R==null?void 0:R.kind)==="file"?R.path:null,vt=c.useMemo(()=>new Set(O.map(e=>e.path)),[O]),at=c.useMemo(()=>jt(O),[O]),Ht=!!(We!=null&&We.path&&O.length===1&&Ot),bn=O.length===1&&(R==null?void 0:R.kind)==="file",vn=at.length>0,Ee=at.length>0,lt=!!(P!=null&&P.items.length&&l),yn=!!l&&O.length===1&&R!==null,xn=!!((xe?de(xe):E)&&M.length),gn=P?P.mode==="copy"?o("conversation.filePanelClipboardCopyReady",{count:P.items.length}):o("conversation.filePanelClipboardCutReady",{count:P.items.length}):null,U=S?ha(S):null;async function Pn(e,a=!1){if(!l)return[];if(!a){const s=ae.current[e];if(s)return s}e===g?v(!0):je(s=>kt(s,e));try{const s=await Ut(e,{force:a});return we(u=>({...u,[e]:s})),s}catch(s){throw Xn(s)||j({title:ne(s,o("conversation.filePanelLoadFailed")),tone:"error"}),s}finally{e===g?v(!1):je(s=>s.filter(u=>u!==e))}}async function ge(e){if(!l)return;const a=(e==null?void 0:e.activeDirectoryPath)??I.current,s=(e==null?void 0:e.expandedDirectories)??T.current,u=ga(ae.current,a,s);ke("file_panel.refresh_tree_cache.start",{sessionId:i,workspaceId:l,targetDirectories:u});const m=(await Promise.all(u.map(async x=>{const D=await Ut(x,{force:!0});return[x,D]}))).reduce((x,[D,ue])=>(x[D]=ue,x),{});ke("file_panel.refresh_tree_cache.end",{sessionId:i,workspaceId:l,targetDirectories:u,directoryCount:Object.keys(m).length}),we(m)}async function Ut(e,a){if(!l)return[];if(!(a!=null&&a.force)){const u=ae.current[e];if(u)return u}const s=It(kt(T.current,e),e||I.current);return _(l,s,{knownRevisionByPath:le.current}),Q(l,[e],{knownRevisionByPath:le.current}),ci(e,On,{allowCached:(a==null?void 0:a.force)!==!0})}function ci(e,a=On,s){const u=ae.current[e];return(s==null?void 0:s.allowCached)!==!1&&u?Promise.resolve(u):new Promise((f,m)=>{const x=window.setTimeout(()=>{fi(e,x),m(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},a),D=se.current.get(e)??[];se.current.set(e,[...D,{resolve:f,reject:m,timerId:x}])})}function ui(e,a){const s=se.current.get(e)??[];s.length!==0&&(se.current.delete(e),s.forEach(u=>{window.clearTimeout(u.timerId),u.resolve(a)}))}function fi(e,a){const u=(se.current.get(e)??[]).filter(f=>f.timerId!==a);if(u.length===0){se.current.delete(e);return}se.current.set(e,u)}function zt(){for(const[e,a]of se.current.entries())a.forEach(s=>{window.clearTimeout(s.timerId),s.reject(new Error(`FILE_TREE_ABORTED:${e}`))});se.current.clear()}function $e(e){k([e]),G(e.path)}function st(e){A(e.kind==="directory"?e.path:de(e.path))}function di(e){const a=aa(ri,Me,e);k(a),G(e.path),st(e)}function hi(e){const a=ia(O,e),s=zn(a);k(a),G(e.path),s&&st(s)}function Cn(e){$e(e),st(e)}function Oe(e,a){if(a!=null&&a.shiftKey){di(e);return}if(Ct(a)){hi(e);return}Cn(e)}async function ot(e,a=!1){const s=ut(e,a);if(!s.length){A(g);return}Le(u=>li(u,s)),A(s[s.length-1]??g);for(const u of s)try{await Pn(u)}catch{return}}async function re(e){const a=z(e,"file");$e(a),st(a),await ot(e)}async function He(e){Ye(e),ve(null),tt.current=null,ye.current+=1,re(e);const a=ye.current,s=e.replace(/\\/g,"/"),u=$.statusByPath.get(s);if(l&&u&&u!=="?"&&u!=="D")try{const f=await Fi(l,e,!1);ye.current===a&&ve(f.content||null)}catch{ye.current===a&&ve(null)}}function jn(e){const a=Date.now(),s=tt.current;return tt.current={filePath:e,timestamp:a},(s==null?void 0:s.filePath)===e&&a-s.timestamp<=Yi}function Pe(){tt.current=null}async function mi(e,a){const s=z(e,"file");if(a!=null&&a.shiftKey||Ct(a)){Pe(),Oe(s,a);return}if(jn(e)){await He(e);return}Oe(s,a),await ot(e)}function Sn(){Xe(!1),qe(""),X(null),Pe()}async function pi(e,a){const s=z(e.path,e.kind);if(a!=null&&a.shiftKey||Ct(a)){Pe(),Oe(s,a);return}if(e.kind==="directory"){Sn(),Oe(s,a),await wn(e.path);return}if(jn(e.path)){Sn(),await He(e.path);return}await re(e.path)}async function wn(e){if($e(z(e,"directory")),A(e),!T.current.includes(e))try{await Pn(e),Le(a=>kt(a,e))}catch{}}async function Nn(e){if($e(z(e,"directory")),A(e),T.current.includes(e)){Dn(e);return}await wn(e)}function Dn(e){Le(a=>a.filter(s=>s!==e&&!s.startsWith(`${e}/`))),A(de(e)),k([]),G(null)}async function En(){if(!l)return;const e=l;try{if(me(e),await ge(),xe&&await ot(xe),oe&&L.trim()){const a=await Ve(e,L.trim());X(a.items)}}catch(a){j({title:ne(a,o("conversation.filePanelLoadFailed")),tone:"error"})}}async function bi(e){if(e==null||e.preventDefault(),!l||!L.trim()){X(null);return}mt(!0);try{const a=await Ve(l,L.trim());X(a.items)}catch(a){j({title:ne(a,o("conversation.filePanelSearchFailed")),tone:"error"})}finally{mt(!1)}}function kn(){if(Ge){Xe(!1),qe(""),X(null);return}Xe(!0)}function Y(e){B(!1),e()}function Mn(){var e;(e=hn.current)==null||e.click()}async function vi(e){var m;const a=((m=e.target.files)==null?void 0:m[0])??null;if(e.target.value="",!a||!l)return;const s=na(a.name);if(!s){j({title:o("conversation.filePanelUploadFailed"),tone:"error"});return}const u=Hn(E,R),f=Un(u,s);dt(!0);try{const x=await ma(a);await Ai({workspaceId:l,path:f,contentBase64:x}),await ge(),await re(f),j({title:o("conversation.filePanelUploadSuccess",{name:s}),tone:"success"})}catch(x){j({title:ne(x,o("conversation.filePanelUploadFailed")),tone:"error"})}finally{dt(!1)}}async function Vt(e=xe){if(!(!l||!e)){dt(!0);try{const a=await Li(l,e),s=pa(a.contentBase64);ba(a.fileName,new Blob([s],{type:"application/octet-stream"})),j({title:o("conversation.filePanelDownloadSuccess",{name:a.fileName}),tone:"success"})}catch(a){j({title:ne(a,o("conversation.filePanelDownloadFailed")),tone:"error"})}finally{dt(!1)}}}function Rn(){const e=xe?de(xe):E;!e||!T.current.includes(e)||Dn(e)}function Kt(){Ie(null),Ae("")}function Gt(){b||Kt()}function Ue(e,a=Hn(E,R)){if(!l)return;const s=a,u=s?`${s}/`:"";Z(!1),B(!1),H(null),Ie({mode:e,baseDirectory:s}),Ae(u)}function Xt(e=R){!l||!e||(Z(!1),B(!1),H(null),Ie({mode:"rename",target:e}),Ae(e.path))}async function yi(e){if(e==null||e.preventDefault(),!l||!S)return;const a=(Bt??"").trim();if(a){if(S.mode==="rename"&&Ke(S.target.path)===Ke(a)){Gt();return}w(!0);try{if(S.mode==="rename"){const s=S.target.path,u=z(a,S.target.kind),f=Se?ai(Se,s,a):null;if(await yt({workspaceId:l,opType:"rename",srcPath:s,dstPath:a}),P&&Lt({...P,items:da(P.items,s,a)}),Kt(),Pe(),await ge(),S.target.kind==="directory"?(await ot(a,!0),$e(u),A(a)):await re(a),f!==Se&&(ye.current+=1,Ye(f),ve(null)),oe&&L.trim()){const m=await Ve(l,L.trim());X(m.items)}_e(m=>m+1),j({title:o("conversation.filePanelRenameSuccess",{name:xt(a)||a}),tone:"success"});return}if(await yt({workspaceId:l,opType:S.mode,dstPath:a,content:S.mode==="create_file"?"":void 0}),Kt(),await ge(),S.mode==="create_directory"?(await ot(a,!0),$e(z(a,"directory")),A(a)):await re(a),oe&&L.trim()){const s=await Ve(l,L.trim());X(s.items)}_e(s=>s+1)}catch(s){j({title:ne(s,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}}function ce(e,a=at){var u;if(a.length===0)return;const s=jt(a);Lt({mode:e,items:s}),k(s),G(((u=s[s.length-1])==null?void 0:u.path)??null),j({title:e==="copy"?o("conversation.filePanelCopySelectionSuccess",{count:s.length}):o("conversation.filePanelCutSelectionSuccess",{count:s.length}),tone:"success"}),H(null)}async function rt(e=oa(R,E)){if(!l||!P||!P.items.length)return;const a=e??g,s=P.items.map(u=>({source:u,destinationPath:Un(a,xt(u.path)||u.path)}));w(!0);try{for(const m of s)P.mode==="cut"&&Ke(m.source.path)===Ke(m.destinationPath)||await yt({workspaceId:l,opType:P.mode==="copy"?"copy":"move",srcPath:m.source.path,dstPath:m.destinationPath});const u=s.map(m=>z(m.destinationPath,m.source.kind)),f=u[u.length-1]??null;if(P.mode==="cut"&&Lt(null),k(u),G((f==null?void 0:f.path)??null),f&&st(f),Pe(),await ge({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?de(f.path):I.current,expandedDirectories:T.current}),oe&&L.trim()){const m=await Ve(l,L.trim());X(m.items)}_e(m=>m+1),j({title:o("conversation.filePanelPasteSuccess",{count:u.length}),tone:"success"}),H(null)}catch(u){await ge().catch(()=>{}),j({title:ne(u,o("conversation.filePanelPasteFailed")),tone:"error"})}finally{w(!1)}}function qt(e=at){!e.length||b||(Fe(jt(e)),H(null))}async function xi(){var a,s;if(!l||!(W!=null&&W.length))return;const e=jt(W);w(!0);try{for(const m of e)await yt({workspaceId:l,opType:"delete",srcPath:m.path});const u=ra(E,e),f=T.current.filter(m=>!e.some(x=>x.kind==="directory"&&_t(x.path,m)));if(Se&&e.some(m=>_t(m.path,Se))&&(ye.current+=1,Ye(null),ve(null)),Fe(null),k([]),G(null),I.current=u,T.current=f,A(u),Le(f),Pe(),await ge({activeDirectoryPath:u,expandedDirectories:f}),oe&&L.trim()){const m=await Ve(l,L.trim());X(m.items)}_e(m=>m+1),j({title:e.length===1?o("conversation.filePanelDeleteSuccess",{name:xt(((a=e[0])==null?void 0:a.path)??"")||((s=e[0])==null?void 0:s.path)||""}):o("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(u){j({title:ne(u,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}async function ze(e,a=R){const s=(We==null?void 0:We.path)??"",u=(a==null?void 0:a.path)??null;if(u===null||!s){Z(!1);return}try{const f=fa(s),m=e==="absolute"?ua(s,u,f):Ke(u,f);await va(m,nt),j({title:e==="absolute"?o("conversation.filePanelCopyAbsolutePathSuccess"):o("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){j({title:f instanceof Error?f.message:o("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{Z(!1),H(null)}}function gi(e,a,s){return[{id:`open-${e.path}`,label:e.kind==="directory"?M.includes(e.path)?o("conversation.filePanelCollapseDirectory"):o("conversation.filePanelExpandDirectory"):o("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){Nn(e.path);return}He(e.path)}},{id:`download-${e.path}`,label:o("conversation.filePanelDownload"),disabled:e.kind!=="file"||N,onSelect:()=>{Vt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:o("conversation.filePanelNewFile"),disabled:!l||b||N,onSelect:()=>{Ue("create_file",s)}},{id:`create-directory-${e.path}`,label:o("conversation.filePanelNewDirectory"),disabled:!l||b||N,onSelect:()=>{Ue("create_directory",s)}},{id:`rename-${e.path}`,label:o("conversation.filePanelRenameMove"),disabled:a.length!==1||b||N,onSelect:()=>Xt(e)},{id:`copy-${e.path}`,label:o("conversation.filePanelCopy"),disabled:a.length===0,onSelect:()=>ce("copy",a)},{id:`cut-${e.path}`,label:o("conversation.filePanelCut"),disabled:a.length===0,onSelect:()=>ce("cut",a)},{id:`paste-${e.path}`,label:o("conversation.filePanelPaste"),disabled:!lt,onSelect:()=>{rt(s)}},{id:`copy-relative-${e.path}`,label:o("conversation.filePanelCopyRelativePath"),onSelect:()=>{ze("relative",e)}},{id:`copy-absolute-${e.path}`,label:o("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{ze("absolute",e)}},{id:`delete-${e.path}`,label:o("conversation.filePanelDelete"),disabled:a.length===0||b||N,onSelect:()=>qt(a)}]}async function _n(e,a){if(nt.isMobile)return;e.preventDefault();const s=z(a.path,a.kind),u=vt.has(s.path)?at:[s],f=s.kind==="directory"?s.path:de(s.path);vt.has(s.path)||Cn(s);const m=gi(s,u,f);if(nt.isDesktop){await Bi(m);return}nt.isWeb&&(Z(!1),B(!1),H({positionX:e.clientX,positionY:e.clientY,items:m}))}c.useEffect(()=>{if(q!=="workspace")return;function e(a){if(!la(a)||a.altKey||a.shiftKey||sa(a.target))return;const s=a.key.toLowerCase();if(s==="c"&&Ee){a.preventDefault(),ce("copy");return}if(s==="x"&&Ee){a.preventDefault(),ce("cut");return}s==="v"&<&&(a.preventDefault(),rt())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[q,Ee,lt,ce,rt]);function Yt(e,a){return n.jsx(n.Fragment,{children:e.map(s=>{const u=z(s.path,s.kind),f=s.kind==="directory",m=f&&M.includes(s.path),x=f&&Tt.includes(s.path),D=Ne[s.path]??[],ue=J?tn(D,Ne,$.statusByPath,$.changedDirs):D,Ci=vt.has(s.path),ji=Ot===s.path,ct=$.statusByPath.get(s.path.replace(/\\/g,"/")),An=f&&$.changedDirs.has(s.path.replace(/\\/g,"/")),Si=(P==null?void 0:P.mode)==="cut"&&P.items.some(fe=>fe.path===s.path);return n.jsxs("div",{className:"file-tree-node",children:[n.jsxs("button",{className:"file-tree-item",type:"button","data-active":ji,"data-selected":Ci,"data-cut-pending":Si||void 0,"data-kind":s.kind,"aria-expanded":f?m:void 0,style:{paddingInlineStart:`${ea+a*ta}px`},onClick:fe=>{if(f){if(fe.shiftKey||Ct(fe)){Pe(),Oe(u,fe);return}Pe(),Oe(u,fe),Nn(s.path);return}mi(s.path,fe)},onContextMenu:fe=>{_n(fe,s)},children:[n.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:m?"v":">"}),f?null:n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(s.name),"aria-hidden":"true",children:Mt(s.name)}),n.jsx("span",{className:"file-tree-label","data-status":ct??void 0,"data-has-changes":An||void 0,children:s.name}),!f&&ct?n.jsx("span",{className:"git-status-badge","data-status":ct,"aria-label":ct,children:ct}):null,f&&An?n.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,x?n.jsx("span",{className:"file-tree-meta",children:o("common.loading")}):null]}),f&&m?n.jsx("div",{className:"file-tree-children",children:x&&!D.length?n.jsx("p",{className:"file-tree-empty",children:o("common.loading")}):ue.length?Yt(ue,a+1):n.jsx("p",{className:"file-tree-empty",children:o("conversation.filePanelEmptyDirectory")})}):null]},`${s.kind}-${s.path}`)})})}function Pi(e){return n.jsx(n.Fragment,{children:e.map(a=>{const s=a.kind==="directory",u=vt.has(a.path),f=Ot===a.path;return n.jsx("div",{className:"file-tree-node",children:n.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":f,"data-selected":u,"data-kind":a.kind,onClick:m=>{pi(a,m)},onContextMenu:m=>{_n(m,a)},children:[n.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),s?null:n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(a.name),"aria-hidden":"true",children:Mt(a.name)}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:a.name}),n.jsx("span",{className:"file-tree-path",children:a.path})]})]})},`search-${a.kind}-${a.path}`)})})}return n.jsx("section",{className:["conversation-panel","surface-card","file-panel",t].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:l?n.jsxs(n.Fragment,{children:[n.jsx(Wi,{workspaceId:l,filePath:Se,open:Se!==null,onClose:()=>{ye.current+=1,Ye(null),ve(null)},onSaved:async e=>{await ge(),await re(e),_e(a=>a+1)},diffContent:oi}),r?null:n.jsx("div",{className:"file-panel-heading-row",children:n.jsx("h2",{className:"file-panel-heading",children:o("conversation.filePanelTitle")})}),h?null:n.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":o("conversation.filePanelTitle"),children:[n.jsx("button",{className:q==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":q==="workspace",onClick:()=>Qe("workspace"),children:o("conversation.filePanelWorkspaceTab")}),n.jsxs("button",{className:q==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":q==="session",onClick:()=>{it&&Qe("session")},disabled:!it,children:[o("conversation.filePanelSessionTab"),n.jsx("span",{className:"file-panel-tab-badge","aria-label":`${o("conversation.filePanelSessionTab")} ${on}`,children:on})]})]}),q==="workspace"?n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:hn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void vi(e)}),pn?n.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":o("conversation.filePanelTitle"),children:n.jsxs("div",{className:"file-mobile-action-shell",ref:dn,children:[n.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":o("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":Je,"data-active":Je,onClick:()=>{Z(!1),B(e=>!e)},children:[n.jsx("span",{children:o("conversation.filePanelActionsMenu")}),n.jsx(Aa,{})]}),Je?n.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":o("conversation.filePanelActionsMenu"),children:[n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ce("copy")),disabled:!Ee,children:o("conversation.filePanelCopy")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ce("cut")),disabled:!Ee,children:o("conversation.filePanelCut")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>rt()),disabled:!lt||b||N,children:o("conversation.filePanelPaste")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),kn()},children:Ge?o("conversation.filePanelHideSearch"):o("conversation.filePanelShowSearch")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),Wt(e=>!e)},disabled:pt.length===0,children:J?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(En),disabled:Re||b||ht,children:o("conversation.filePanelRefresh")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),Rn()},disabled:!xn,children:o("conversation.filePanelCollapseCurrent")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),Mn()},disabled:b||N,children:o("conversation.filePanelUpload")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(Vt),disabled:!bn||N,children:o("conversation.filePanelDownload")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(Xt),disabled:!yn||b||N,children:o("conversation.filePanelRenameMove")}),n.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>Y(qt),disabled:!vn||b||N,children:o("conversation.filePanelDelete")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Ue("create_file")),disabled:b||N,children:o("conversation.filePanelNewFile")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Ue("create_directory")),disabled:b||N,children:o("conversation.filePanelNewDirectory")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ze("absolute")),disabled:!Ht,children:o("conversation.filePanelCopyAbsolutePath")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ze("relative")),disabled:!Ht,children:o("conversation.filePanelCopyRelativePath")})]}):null]})}):n.jsxs("div",{className:"file-panel-toolbar","aria-label":o("conversation.filePanelTitle"),children:[n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopy"),"aria-label":o("conversation.filePanelCopy"),onClick:()=>ce("copy"),disabled:!Ee,children:n.jsx(Na,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCut"),"aria-label":o("conversation.filePanelCut"),onClick:()=>ce("cut"),disabled:!Ee,children:n.jsx(Da,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelPaste"),"aria-label":o("conversation.filePanelPaste"),onClick:()=>void rt(),disabled:!lt||b||N,children:n.jsx(Ea,{})}),n.jsxs("div",{className:"file-toolbar-menu-shell",ref:fn,children:[n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopyPath"),"aria-label":o("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":Ze,"data-active":Ze,onClick:()=>{B(!1),Z(e=>!e)},disabled:!Ht,children:n.jsx(wa,{})}),Ze?n.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[n.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void ze("absolute"),children:o("conversation.filePanelCopyAbsolutePath")}),n.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void ze("relative"),children:o("conversation.filePanelCopyRelativePath")})]}):null]}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCollapseCurrent"),"aria-label":o("conversation.filePanelCollapseCurrent"),onClick:Rn,disabled:!xn,children:n.jsx(ja,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelRefresh"),"aria-label":o("conversation.filePanelRefresh"),onClick:()=>void En(),disabled:Re||b||ht,children:n.jsx(Sa,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),"data-active":Ge,onClick:kn,disabled:Re,children:n.jsx(qn,{})}),pt.length>0?n.jsx("button",{className:"file-toolbar-button",type:"button",title:J?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges"),"aria-label":J?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges"),"data-active":J,onClick:()=>Wt(e=>!e),children:n.jsx(La,{})}):null,n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelUpload"),"aria-label":o("conversation.filePanelUpload"),onClick:Mn,disabled:b||N,children:n.jsx(Ma,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelDownload"),"aria-label":o("conversation.filePanelDownload"),onClick:()=>void Vt(),disabled:!bn||N,children:n.jsx(Ra,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelRenameMove"),"aria-label":o("conversation.filePanelRenameMove"),onClick:()=>Xt(),disabled:!yn||b||N,children:n.jsx(Fa,{})}),n.jsx("button",{className:"file-toolbar-button danger",type:"button",title:o("conversation.filePanelDelete"),"aria-label":o("conversation.filePanelDelete"),onClick:()=>qt(),disabled:!vn||b||N,children:n.jsx(_a,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewFile"),"aria-label":o("conversation.filePanelNewFile"),onClick:()=>void Ue("create_file"),disabled:b||N,children:n.jsx(ka,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewDirectory"),"aria-label":o("conversation.filePanelNewDirectory"),onClick:()=>void Ue("create_directory"),disabled:b||N,children:n.jsx(Ta,{})})]}),ie&&typeof document<"u"?Ni.createPortal(n.jsx("div",{className:"file-web-context-menu",ref:$t,role:"menu","aria-label":o("conversation.filePanelActionsMenu"),style:{left:`${(be==null?void 0:be.left)??Math.max(8,ie.positionX)}px`,top:`${(be==null?void 0:be.top)??Math.max(8,ie.positionY)}px`,maxHeight:be?`${be.maxHeight}px`:void 0},children:ie.items.map(e=>n.jsx("button",{className:["file-web-context-menu-item",e.label===o("conversation.filePanelDelete")?"danger":""].filter(Boolean).join(" "),type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>{H(null),e.onSelect()},children:e.label},e.id))}),document.body):null,gn?n.jsx("p",{className:"file-panel-clipboard-status","data-mode":P==null?void 0:P.mode,children:gn}):null,Ge?n.jsxs("form",{className:"file-toolbar-search",onSubmit:e=>void bi(e),children:[n.jsx("input",{value:L,onChange:e=>qe(e.target.value),placeholder:o("conversation.filePanelSearchPlaceholder")}),pn?n.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":o("conversation.filePanelSearchButton"),disabled:ht,children:o("conversation.filePanelSearchButton")}):n.jsx("button",{className:"file-toolbar-button",type:"submit",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),disabled:ht,children:n.jsx(qn,{})})]}):null,n.jsx("div",{className:"file-tree","data-search-mode":oe,children:Re&&Be.length===0?n.jsx("p",{className:"file-tree-status status-text",children:o("common.loading")}):oe?De!=null&&De.length?Pi(De):n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSearchEmpty")}):J?bt.length?Yt(bt,0):n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelNoChanges")}):Be.length?Yt(Be,0):n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelEmptyDirectory")})}),n.jsx(Ln,{open:S!==null,title:(U==null?void 0:U.title)??"",description:U==null?void 0:U.description,onClose:Gt,children:n.jsxs("form",{className:"workbench-rename-form",onSubmit:e=>void yi(e),children:[n.jsx(ki,{label:o("conversation.filePanelPathFieldLabel"),htmlFor:un,description:(S==null?void 0:S.mode)==="rename"?S.target.path:(S==null?void 0:S.baseDirectory)||void 0,children:n.jsx("input",{id:un,type:"text",value:Bt??"",placeholder:o("conversation.filePanelPathFieldPlaceholder"),autoFocus:!0,onChange:e=>Ae(e.target.value)})}),n.jsxs(Mi,{children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:b,onClick:Gt,children:o("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:b||!(Bt??"").trim(),children:b?(U==null?void 0:U.pendingLabel)??o("common.loading"):(U==null?void 0:U.submitLabel)??o("common.save")})]})]})}),n.jsxs(Ln,{open:W!==null,title:o("conversation.filePanelDeleteConfirmTitle"),description:o("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{b||Fe(null)},children:[n.jsx("p",{className:"workbench-section-empty",children:W!=null&&W.length?W.length===1?((Fn=W[0])==null?void 0:Fn.kind)==="directory"?o("conversation.filePanelDeleteDirectoryConfirm",{path:W[0].path}):o("conversation.filePanelDeleteFileConfirm",{path:W[0].path}):o("conversation.filePanelDeleteSelectionConfirm",{count:W.length}):""}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:b,onClick:()=>Fe(null),children:o("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:b,onClick:()=>{xi()},children:b?o("conversation.filePanelDeleting"):o("conversation.filePanelDelete")})]})]})]}):it&&i?n.jsx(Xi,{sessionId:i,workspaceId:l,showSystemFiles:ee,selectedPath:xe,refreshVersion:sn,onCountChange:At,onSelectFile:re,onOpenFile:He}):n.jsx("section",{className:"file-panel-section",children:n.jsx("p",{className:"status-text",children:o("conversation.filePanelSessionNoSession")})})]}):n.jsx("section",{className:"file-panel-section",children:n.jsx("p",{className:"status-text",children:o("conversation.filePanelNoWorkspace")})})})}function de(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):g}function ut(t,i=!1){const l=t.split("/").filter(Boolean),r=i?l.length:l.length-1,h=[];for(let d=0;d<r;d+=1)h.push(l.slice(0,d+1).join("/"));return h}function Hn(t,i){return t||((i==null?void 0:i.kind)==="directory"?i.path:i!=null&&i.path?de(i.path):g)}function Un(t,i){return t?`${t}/${i}`:i}function na(t){var i;return((i=t.split(/[/\\]/).pop())==null?void 0:i.trim())??""}function z(t,i){return{path:t,kind:i}}function zn(t){return t[t.length-1]??null}function ia(t,i){return t.findIndex(r=>r.path===i.path)>=0?t.filter(r=>r.path!==i.path):[...t,i]}function aa(t,i,l){const r=t.findIndex(y=>y.path===l.path);if(r<0)return[l];const h=i?t.findIndex(y=>y.path===i):r;if(h<0)return[l];const d=Math.min(h,r),p=Math.max(h,r);return t.slice(d,p+1)}function Ct(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function la(t){return t.ctrlKey||t.metaKey}function sa(t){if(!(t instanceof HTMLElement))return!1;const i=t.tagName.toLowerCase();return i==="input"||i==="textarea"||i==="select"||t.isContentEditable}function jt(t){const i=[...new Map(t.map(r=>[r.path,r])).values()].sort((r,h)=>r.path.localeCompare(h.path)),l=[];for(const r of i)l.some(h=>h.kind==="directory"&&_t(h.path,r.path))||l.push(r);return l}function oa(t,i){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?de(t.path):i}function ra(t,i){let l=t;for(;l&&i.some(r=>r.kind==="directory"&&_t(r.path,l));)l=de(l);return l}function ti(t,i,l,r,h,d){const p=[];for(const y of t){if(p.push(z(y.path,y.kind)),y.kind!=="directory"||!l.includes(y.path))continue;const C=i[y.path]??[],F=r?tn(C,i,h,d):C;p.push(...ti(F,i,l,r,h,d))}return p}function ca(t,i,l){const r=Math.max(0,l.width),h=Math.max(0,l.height),d=Math.max(0,h-te*2),p=Math.max(0,r-te*2),y=Math.min(Math.max(i.width,0),p),C=Math.max(0,h-t.y-Pt-te),F=Math.max(0,t.y-Pt-te),_=C<i.height&&F>C,he=Jt(Math.max(_?F:C,Zi),0,d),V=Math.min(Math.max(i.height,0),he),me=_?t.y-Pt-V:t.y+Pt,pe=Math.max(te,h-te-V),K=Math.max(te,r-te-y);return{top:Jt(me,te,pe),left:Jt(t.x,te,K),maxHeight:Math.max(0,he)}}function Jt(t,i,l){return!Number.isFinite(t)||l<i?i:Math.min(Math.max(t,i),l)}function Ke(t,i="posix"){return t?ni(t,i):"."}function ua(t,i,l){const r=ni(t,l),h=Ke(i,l).replace(/^\.[/\\]?/,"");if(!h)return r;const d=ii(l),p=h.replace(/^[/\\]+/,"");return p?r.endsWith("/")||r.endsWith("\\")?`${r}${p}`:`${r}${d}${p}`:r}function fa(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function ni(t,i){return t&&(ii(i)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function ii(t){return t==="windows"?"\\":"/"}function _t(t,i){return i===t||i.startsWith(`${t}/`)}function ai(t,i,l){return t===i?l:t.startsWith(`${i}/`)?`${l}${t.slice(i.length)}`:t}function da(t,i,l){return t.map(r=>({...r,path:ai(r.path,i,l)}))}function ha(t){return t.mode==="create_file"?{title:o("conversation.filePanelNewFile"),description:o("conversation.filePanelCreateFileDescription"),submitLabel:o("conversation.filePanelCreateFileSubmit"),pendingLabel:o("conversation.filePanelCreatingFile")}:t.mode==="create_directory"?{title:o("conversation.filePanelNewDirectory"),description:o("conversation.filePanelCreateDirectoryDescription"),submitLabel:o("conversation.filePanelCreateDirectorySubmit"),pendingLabel:o("conversation.filePanelCreatingDirectory")}:{title:o("conversation.filePanelRenameMove"),description:o("conversation.filePanelRenameDescription"),submitLabel:o("conversation.filePanelRenameSubmit"),pendingLabel:o("conversation.filePanelRenaming")}}async function ma(t){const i=await t.arrayBuffer(),l=new Uint8Array(i),r=32768;let h="";for(let d=0;d<l.length;d+=r){const p=l.subarray(d,d+r);h+=String.fromCharCode(...p)}return btoa(h)}function pa(t){const i=atob(t),l=new Uint8Array(i.length);for(let r=0;r<i.length;r+=1)l[r]=i.charCodeAt(r);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}function ba(t,i){if(typeof document>"u")throw new Error(o("conversation.filePanelDownloadFailed"));const l=window.URL.createObjectURL(i),r=document.createElement("a");r.href=l,r.download=t,document.body.append(r),r.click(),r.remove(),window.URL.revokeObjectURL(l)}async function va(t,i){var l;if(!(i.isDesktop&&(await i.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((l=navigator.clipboard)!=null&&l.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!ya(t))throw new Error(o("conversation.filePanelCopyPathFailed"))}}function ya(t){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const i=document.createElement("textarea");i.value=t,i.setAttribute("readonly","true"),i.style.position="fixed",i.style.top="-9999px",i.style.left="-9999px",i.style.opacity="0",document.body.appendChild(i),i.focus(),i.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(i)}}function xa(t,i){return t&&ut(t,!0).every(h=>h in i)?t:g}function Vn(t,i){if(!i)return[];const l=ut(i,!0);return t.filter(r=>l.includes(r))}function St(t,i,l){const r=ln(i,l);return Object.entries(t).reduce((h,[d,p])=>(r.has(d)&&(h[d]=p),h),{})}function ga(t,i,l){const h=[...ln(i,l)].filter(d=>d===g||d in t);return h.length?h:[g]}function ln(t,i){const l=new Set([g]),r=li(i,ut(t,!0));for(const h of r){l.add(h);for(const d of ut(h,!0))l.add(d)}return l}function Pa(t,i){const l=Object.keys(t),r=Object.keys(i);return l.length!==r.length?!1:l.every(h=>t[h]===i[h])}function kt(t,i){return t.includes(i)?t:[...t,i]}function li(t,i){return i.reduce((l,r)=>kt(l,r),t)}function Kn(t){return`file-panel.workspace-tree.${t}`}function Ca(t,i){return`file-panel.session-change-count.${t}.${i}`}function Gn(t,i){return Object.fromEntries(Object.keys(i).map(l=>[l,t[l]??null]))}function It(t,i){return[...ln(i,t)]}function ne(t,i){return t instanceof Yn?t.message:i}function Xn(t){return t instanceof Error&&(t.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")||t.message.startsWith("FILE_TREE_ABORTED:"))}function ja(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function Sa(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M12.8 5.2A5.5 5.5 0 1 0 13.5 8h-1.8A3.7 3.7 0 1 1 10.6 5l-1.4 1.4h4V2l-1.4 1.4z",fill:"currentColor"})})}function qn(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M11.2 10.1l3 3-1.1 1.1-3-3a5 5 0 1 1 1.1-1.1zM6.8 10.3a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z",fill:"currentColor"})})}function wa(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M3.5 4.3h5.2v1.4H4.9v5.4H3.5zm3.8-2.1h5.2v9.5H7.3z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Na(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Da(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M4.2 4.2a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm0 5.4a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm1-3.2 6.6 5.6M5.2 9.6l6.6-5.6",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})}function Ea(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function ka(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ma(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ra(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"m5.5 8.5 2.5 2.5 2.5-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function _a(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.5 4.5h9M6.2 2.5h3.6l.6 1.4H13v1.2H3V3.9h2.6zM5.2 5.7v6.1m2.8-6.1v6.1m2.8-6.1v6.1M4.4 13.5h7.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ta(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Fa(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.2 11.9h2.2l5.9-5.9-2.2-2.2-5.9 5.9zM8.3 3.8l2.2 2.2M2.8 13.2h10.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Aa(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function La(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function tn(t,i,l,r){const h=[];for(const d of t){const p=d.path.replace(/\\/g,"/");d.kind==="file"?l.has(p)&&h.push(d):si(p,i,l,r)&&h.push(d)}return h}function si(t,i,l,r,h){const d=h??new Set;if(d.has(t))return!1;d.add(t);const p=i[t];if(!p)return r.has(t);for(const y of p){const C=y.path.replace(/\\/g,"/");if(y.kind==="file"){if(l.has(C))return!0}else if(si(C,i,l,r,d))return!0}return!1}export{Ga as FileContextPanel};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{b as l,t as n,j as e,A as Bn}from"./index-BZLcEHW3.js";import{u as Hi,e as Ri,f as wi,g as jn}from"./App-BZvapsi8.js";import{u as Ai,V as st,r as Cn,aY as Nn,w as Pi,aZ as Di,a_ as Li,aQ as _i,a$ as vn,b0 as Fi,b1 as Sn,b2 as Oi,aS as ki,b3 as Gi,aR as $i,b4 as Bi,b5 as Ui,aX as Vi,b6 as Tn,b as Wi,b7 as zi,b8 as Ki}from"./WorkbenchLayout-DGm8Tc5M.js";import{g as Ii}from"./default-session-permission-mode-DT4SGiwp.js";import{S as Xi,v as qi,w as Yi,e as Zi}from"./MobileSheet-Ckug8hTb.js";import{F as Qi,a as Ft,b as Ot}from"./file-tree-icon-Db5LXC8h.js";import{W as Oe}from"./WorkbenchModal-0tPIIhca.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-C5_Iay0I.js";const Rt=56,Mn=28,wt=72,at=8,En=960,Hn=60*1e3,Rn=20,wn=9,An=9,At=68,_=12,rt=8,kt=260,Ji=120,Pt=6e4,ot={authMode:"none",username:"",password:"",token:"",rememberOnHost:!1};function Ms({className:a,workspaceId:i,panelActive:u=!0,externalWindowMode:g=!1,workbenchShellOverrides:m}){const C=Hi(),p=Ri(),y=Ai(),{subscribeGitSnapshot:b,requestGitRefresh:v,addGitSnapshotListener:M,requestNavigationRefresh:S,selectWorkspace:T,upsertNavigationSession:x}={...y,...m},[r,h]=l.useState(null),[j,H]=l.useState(null),[d,P]=l.useState([]),[R,ne]=l.useState(0),[K,ie]=l.useState(null),[he,ct]=l.useState(!1),[G,ge]=l.useState(null),[se,I]=l.useState(null),[fe,pe]=l.useState(""),[$e,$]=l.useState(!1),[N,w]=l.useState(!1),[Yn,Vt]=l.useState([]),[J,Wt]=l.useState(!0),[ee,V]=l.useState(!1),[F,Zn]=l.useState(()=>typeof window<"u"?window.innerWidth<=En:!1),[ut,B]=l.useState([]),[xe,W]=l.useState(null),[be,ae]=l.useState("unstaged"),[ye,X]=l.useState(null),[re,q]=l.useState(null),[Qn,dt]=l.useState(!1),[Jn,mt]=l.useState(null),[ei,Be]=l.useState(!1),[zt,Ue]=l.useState(null),[D,je]=l.useState(null),[Kt,Ce]=l.useState(null),[ti,Ne]=l.useState(!1),[ve,oe]=l.useState(null),[te,ht]=l.useState(!1),[ni,Se]=l.useState(!1),[ii,It]=l.useState([]),[fs,Xt]=l.useState(!1),[Ve,gt]=l.useState(new Set),[si,Te]=l.useState(new Map),[We,qt]=l.useState(null),[ai,Me]=l.useState(!1),[A,Y]=l.useState(ot),[Yt,ze]=l.useState("generic"),[Zt,Ke]=l.useState(null),[O,ft]=l.useState(null),[k,pt]=l.useState(null),[Qt,Jt]=l.useState(Rt),[xt,bt]=l.useState(!1),[en,Ee]=l.useState(null),[ri,He]=l.useState(null),tn=l.useRef(null),nn=l.useRef(null),sn=l.useRef(null),an=l.useRef(null),rn=l.useRef(null),on=l.useRef(null),yt=l.useRef(null),Re=l.useRef(new Map),Ie=l.useRef(new Map),we=l.useRef(0),ln=l.useRef(u),cn=l.useRef(u),Xe=l.useRef(null),{showToast:E}=wi(),un=p.isDesktop&&!F;l.useEffect(()=>{st("git_sidebar.props",{workspaceId:i,externalWindowMode:g})},[g,i]),l.useEffect(()=>{cn.current=u},[u]),l.useEffect(()=>{Vt([]),Wt(!0),ne(0),ie(null),ct(!1),I(null),pe(""),V(!1),B([]),W(null),ae("unstaged"),X(null),q(null),dt(!1),mt(null),Be(!1),Ue(null),je(null),Ce(null),Ne(!1),oe(null),ht(!1),Se(!1),It([]),gt(new Set),Te(new Map),qt(null),Me(!1),Y(ot),ze("generic"),Ke(null),ft(null),pt(null),bt(!1),Jt(Rt),Ee(null),He(null),Ie.current.clear(),Re.current.clear()},[i]),l.useEffect(()=>{function t(){Zn(window.innerWidth<=En)}return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),l.useEffect(()=>{if(!xt)return;const t=document.body.style.cursor,s=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";function o(f){fn(f.clientY)}function c(){bt(!1)}return window.addEventListener("pointermove",o),window.addEventListener("pointerup",c),()=>{document.body.style.cursor=t,document.body.style.userSelect=s,window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",c)}},[xt]),l.useEffect(()=>{var c,f;if(!(i!=null&&i.trim())){Xe.current=null,h(null),H(null),P([]),ne(0),ie(null),ge(null),$(!1);return}const t=i.trim(),s=Cn(ke(t),Hn),o=Lt(s);if(st("git_sidebar.snapshot",{workspaceId:t,cached:o,cachedHistoryCount:((c=s==null?void 0:s.history)==null?void 0:c.length)??0,cachedChangedCount:((f=s==null?void 0:s.status)==null?void 0:f.changes.length)??0}),o&&s){jt(s,t),$(!1);return}Xe.current=null,Nn(ke(t)),h(null),H(null),P([]),ne(0),ie(null),ge(null),$(!0)},[i]),l.useEffect(()=>{if(i!=null&&i.trim())return M(t=>{var s,o,c;t.workspaceId===i.trim()&&(st("git_sidebar.snapshot_received",{workspaceId:t.workspaceId,changedCount:((s=t.status)==null?void 0:s.changes.length)??0,historyCount:t.history.length,branchCount:(((o=t.branches)==null?void 0:o.local.length)??0)+(((c=t.branches)==null?void 0:c.remote.length)??0)}),jt(t,t.workspaceId),$(!1))})},[M,i]),l.useEffect(()=>{if(!(i!=null&&i.trim()))return;const t=i.trim(),s=Cn(ke(t),Hn),o=Lt(s)?(s==null?void 0:s.revision)??null:null;b(t,{knownRevision:o}),cn.current&&z()},[v,b,i]),l.useEffect(()=>{const t=ln.current;ln.current=u,i!=null&&i.trim()&&!t&&u&&v(i.trim(),{knownRevision:j})},[u,v,j,i]),l.useEffect(()=>{const t=i==null?void 0:i.trim();if(!t||Xe.current!==t)return;const s={revision:j,status:r,history:d,historyTotalCount:R,historyNextCursor:K,branches:G};if(!Lt(s)){Nn(ke(t));return}Pi(ke(t),s)},[G,d,K,R,j,r,i]),l.useEffect(()=>{if(!r||!se)return;r.changes.find(s=>s.path===se)||I(null)},[se,r]),l.useEffect(()=>{rs(an.current)},[fe]),l.useEffect(()=>{F||(B([]),W(null),X(null),Ke(null))},[F]),l.useEffect(()=>{if(!r){B([]);return}const t=new Set(r.changes.map(s=>s.path));B(s=>s.filter(o=>t.has(o)))},[r]);function oi(){const t=sn.current;if(!t)return;t.querySelectorAll(".git-tree-shell").forEach(o=>{o.scrollTop=0})}function jt(t,s){Xe.current=(s==null?void 0:s.trim())??(i==null?void 0:i.trim())??null,H(typeof t.revision=="string"?t.revision:null),h(t.status),P(Array.isArray(t.history)?t.history:[]),ne(typeof t.historyTotalCount=="number"?t.historyTotalCount:0),ie(typeof t.historyNextCursor=="string"?t.historyNextCursor:null),ge(t.branches??null)}function z(t){i!=null&&i.trim()&&($(!0),st("git_sidebar.refresh_requested",{workspaceId:i.trim(),resetTreeScroll:!1}),v(i.trim(),{knownRevision:j}))}async function Ct(t){if(!(i!=null&&i.trim()))return;const s=i.trim();$(!0);try{const[o,c,f]=await Promise.all([_i(s),vn(s,Rn,null),Fi(s)]);jt({status:o,history:c.items,historyTotalCount:c.totalCount,historyNextCursor:c.nextCursor,branches:f}),v(s),t!=null&&t.resetTreeScroll&&requestAnimationFrame(()=>{oi()})}catch(o){E({title:L(o,n("git.panelLoadFailed")),tone:"error"})}finally{$(!1)}}async function qe(){if(!(!i||!K||he)){ct(!0);try{const t=await vn(i,Rn,K);P(s=>{const o=new Set(s.map(f=>f.commitHash)),c=t.items.filter(f=>!o.has(f.commitHash));return[...s,...c]}),ne(t.totalCount),ie(t.nextCursor)}catch(t){E({title:L(t,n("git.panelLoadFailed")),tone:"error"})}finally{ct(!1)}}}function li(t){if(!J||he||!K)return;const s=t.currentTarget;s.scrollHeight-s.scrollTop-s.clientHeight<=40&&qe()}async function ci(){if(i){w(!0);try{const t=await Li(i,"ai");pe(t.validation.normalizedDraft.subject||t.draft.subject)}catch(t){E({title:L(t,n("git.draftFailed")),tone:"error"})}finally{w(!1)}}}async function Ye(t,s){if(i&&t.length){w(!0);try{const o=s?await Gi(i,t):await $i(i,t);h(o),I(t[t.length-1]??null),B(c=>c.filter(f=>!t.includes(f))),W(null),z()}catch(o){$(!1),E({title:L(o,n("git.stageFailed")),tone:"error"})}finally{w(!1)}}}async function Nt(t){if(i&&t.length){w(!0);try{const s=await Ui(i,t);h(s),t.includes(se??"")&&I(null),B(o=>o.filter(c=>!t.includes(c))),W(null),z()}catch(s){$(!1),E({title:L(s,n("git.discardFailed")),tone:"error"})}finally{w(!1)}}}async function ui(){if(!(!i||!fe.trim())){w(!0);try{await Oi(i,is(fe)),E({title:n("git.commitSuccess"),tone:"success"}),pe(""),I(null),z()}catch(t){E({title:L(t,n("git.commitFailed")),tone:"error"})}finally{w(!1)}}}async function di(){if(i!=null&&i.trim()){w(!0),$(!0);try{const t=await Di(i.trim());h(t),P([]),ne(0),ie(null),ge(null),E({title:n("git.initSuccess"),tone:"success"}),z()}catch(t){E({title:L(t,n("git.initFailed")),tone:"error"})}finally{w(!1),$(!1)}}}function Ze(t){Y(us(We)),Me(!0),mi(t)}async function mi(t){const s=i==null?void 0:i.trim();if(!s){ze("generic");return}try{const o=await Sn(s);if((i==null?void 0:i.trim())!==s)return;ze(ms(o,t))}catch{if((i==null?void 0:i.trim())!==s)return;ze("generic")}}function hi(){const t=ds(A),s=Yt==="github"?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder");if(A.authMode==="basic"){if(!A.username.trim()){E({title:n("shell.cloneUsernamePlaceholder"),tone:"error"});return}if(!A.password){E({title:s,tone:"error"});return}}if(A.authMode==="token"&&!A.token){E({title:n("shell.cloneTokenPlaceholder"),tone:"error"});return}qt(t),Me(!1),E({title:t?n("git.remoteAuthSaved"):n("git.remoteAuthCleared"),description:t&&A.rememberOnHost?n("git.remoteAuthRememberHint"):void 0,tone:"success"})}async function dn(){if(i){Xt(!0);try{const t=await Sn(i);if(t.length===0){E({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){mn([t[0].name]);return}It(t),gt(new Set),Te(new Map),Se(!0)}catch(t){E({title:L(t,n("git.remoteFailed")),tone:"error"})}finally{Xt(!1)}}}async function mn(t){if(!i||t.length===0)return;w(!0),Te(new Map);const s=new Map;let o=!1;try{for(const c of t)try{const f=await Tn(i,"push",c,We,A.rememberOnHost);s.set(c,{ok:!0,summary:f.summary})}catch(f){if(o=!0,s.set(c,{ok:!1,summary:L(f,n("git.remoteFailed"))}),Te(new Map(s)),Gn(f)){Ze(c);return}}Te(s),z(),o||(E({title:n("git.pushAllSuccess",{count:String(t.length)}),tone:"success"}),Se(!1))}finally{w(!1)}}async function vt(t){if(i){if(t==="push"){V(!1),dn();return}w(!0);try{const s=await Tn(i,t,void 0,We,A.rememberOnHost);E({title:s.summary,tone:"success"}),V(!1),z()}catch(s){if(Gn(s)){Ze();return}E({title:L(s,n("git.remoteFailed")),tone:"error"})}finally{w(!1)}}}async function le(){if(i){w(!0);try{const t=await Bi(i);pe(t.commitSubject??""),E({title:t.summary||n("git.undoLastCommitSuccess"),tone:"success"}),V(!1),z()}catch(t){E({title:L(t,n("git.undoLastCommitFailed")),tone:"error"})}finally{w(!1)}}}async function gi(t){if(i){w(!0);try{const s=await zi(i,t,!1);ge(s),V(!1),z()}catch(s){E({title:L(s,n("git.branchFailed")),tone:"error"})}finally{w(!1)}}}async function St(t){const s=i==null?void 0:i.trim();if(!s)throw new Error(n("git.panelLoadFailed"));const o=Ie.current.get(t);if(o)return o;const c=await Ki(s,t);return Ie.current.set(t,c),c}async function Ae(t){q(null),X(null),mt(t),Ue(null);const s=Ie.current.get(t)??null;if(je(s),Be(!s),s)return;const o=we.current+1;we.current=o;try{const c=await St(t);if(we.current!==o)return;je(c)}catch(c){if(we.current!==o)return;Ue(L(c,n("git.commitDetailLoadFailed"))),je(null)}finally{we.current===o&&Be(!1)}}function fi(){mt(null),Be(!1),Ue(null),je(null)}async function Pe(t){try{const s=await St(t);await U(s.versionLabel,n("git.copyCommitVersionSuccess"))}catch(s){E({title:L(s,n("git.commitDetailLoadFailed")),tone:"error"})}}function De(t){q(null),X(null),Ce(t),oe(null),Ne(!0)}function pi(t){var o;const s=((o=d[0])==null?void 0:o.commitHash)===t.commitHash&&t.commitKind==="local";return[{id:`view-changes:${t.commitHash}`,label:n("git.viewCommitChanges"),onSelect:()=>void Ae(t.commitHash)},{id:`copy-hash:${t.commitHash}`,label:n("git.copyCommitHash"),onSelect:()=>void U(t.commitHash,n("git.copyCommitHashSuccess"))},{id:`copy-message:${t.commitHash}`,label:n("git.copyCommitMessage"),onSelect:()=>void U(me(t),n("git.copyCommitMessageSuccess"))},{id:`copy-version:${t.commitHash}`,label:n("git.copyCommitVersion"),onSelect:()=>void Pe(t.commitHash)},{id:`explain:${t.commitHash}`,label:n("git.explainCommitAction"),onSelect:()=>De(t.commitHash)},...s?[{id:`undo:${t.commitHash}`,label:n("git.undoLastCommit"),disabled:N,onSelect:()=>void le()}]:[]]}async function hn(t){q(null),X(null),await Vi(pi(t))}async function xi(){var t,s;if(!(!i||!Kt||!ve||te)){ht(!0);try{const o=await St(Kt),c=await qi({workspaceId:i,provider:ve,content:as(o),clientRequestId:((s=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:s.call(t))??`git-explain-${Date.now()}-${Math.random().toString(16).slice(2)}`,permissionMode:Ii()}),f=c.session??await Yi(c.sessionId);x(f),S(),T(f.workspaceId),C(Wi(f.workspaceId,f.sessionId)),Ne(!1),Ce(null),oe(null),E({title:n("git.explainCommitStarted"),tone:"success"})}catch(o){E({title:L(o,n("git.explainCommitFailed")),tone:"error"})}finally{ht(!1)}}}function Qe(t){Vt(s=>s.includes(t)?s.filter(o=>o!==t):[...s,t])}const bi=450;function gn(t){const s=Date.now(),o=tn.current;return tn.current={filePath:t,timestamp:s},(o==null?void 0:o.filePath)===t&&s-o.timestamp<=bi}async function Je(t,s){if(s.binary){E({title:n("git.binaryDiff"),tone:"info"});return}if(s.status==="A"||s.status==="?")He(null),Ee(t);else if(i)try{const o=await ki(i,t,s.staged);He(o.content),Ee(t)}catch{He(null),Ee(t)}}function et(t){I(t),W(null),B(s=>s.includes(t)?s.filter(o=>o!==t):[...s,t])}function fn(t){const s=nn.current;if(!s||!Number.isFinite(t))return;const o=s.getBoundingClientRect(),c=o.height-at;if(!Number.isFinite(o.top)||!Number.isFinite(o.height)||c<=0)return;const f=(t-o.top-at/2)/c*100;if(!Number.isFinite(f))return;const Fe=Math.max(Mn,Math.min(wt,Math.round(f)));Jt(Fe)}function yi(t){t.preventDefault(),fn(t.clientY),bt(!0)}const Le=(r==null?void 0:r.changes)??[],Z=Le.filter(t=>Gt(t,"staged")),ce=Le.filter(t=>Gt(t,"unstaged")),pn=On(Z,"staged"),xn=On(ce,"unstaged"),tt=new Set(Yn),nt=new Set(ut),ue=kn(ut,Le,"staged"),de=kn(ut,Le,"unstaged"),Tt=Le.length===0&&((r==null?void 0:r.snapshot.ahead)??0)>0,ji=Z.length>0&&fe.trim().length>0,it=(G==null?void 0:G.currentBranch)??(r==null?void 0:r.snapshot.branch)??n("common.unknown"),Mt=We!==null,_e=Yt==="github",Ci=_e?n("git.remoteAuthDescriptionGithub"):n("git.remoteAuthDescription"),Ni=_e?n("git.remoteAuthGithubPatLabel"):n("shell.clonePasswordLabel"),vi=_e?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder"),Si=_e?n("git.remoteAuthGithubUsernamePlaceholder"):n("shell.cloneUsernamePlaceholder"),Et=Number.isFinite(Qt)?Qt:Rt,Ti=J?`minmax(120px, ${Et}fr) ${at}px minmax(140px, ${100-Et}fr)`:`minmax(120px, 1fr) ${at}px auto`,Mi=ls(r);l.useEffect(()=>{xe==="staged"&&ue.length===0&&W(null),xe==="unstaged"&&de.length===0&&W(null)},[xe,ue.length,de.length]),l.useEffect(()=>{if(!F)return;const t=ce.length>0?"unstaged":Z.length>0?"staged":"history";ae(s=>s==="unstaged"&&ce.length>0||s==="staged"&&Z.length>0?s:t)},[F,Z.length,ce.length]),l.useEffect(()=>{ye&&(d.some(t=>t.commitHash===ye)||X(null))},[d,ye]),l.useEffect(()=>{re&&(d.some(t=>t.commitHash===re)||q(null))},[re,d]),l.useEffect(()=>{F&&be!=="history"&&ee&&V(!1)},[F,ee,be]),l.useLayoutEffect(()=>{if(F||!ee){ft(null);return}function t(){const o=rn.current,c=on.current;!o||!c||typeof window>"u"||ft($n(o.getBoundingClientRect(),{width:c.getBoundingClientRect().width||kt,height:c.getBoundingClientRect().height||c.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}t();const s=window.requestAnimationFrame(t);return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[N,G==null?void 0:G.local.length,it,F,ee,Mt]);const Q=ye??re;l.useLayoutEffect(()=>{if(!Q){pt(null);return}const t=Q;function s(){const c=Re.current.get(t)??null,f=yt.current;!c||!f||typeof window>"u"||pt($n(c.getBoundingClientRect(),{width:f.getBoundingClientRect().width||kt,height:f.getBoundingClientRect().height||f.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}s();const o=window.requestAnimationFrame(s);return window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{window.cancelAnimationFrame(o),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[Q,d.length]),l.useEffect(()=>{if(!Q||typeof document>"u")return;const t=Q;function s(o){const c=o.target;if(!(c instanceof Node))return;const f=Re.current.get(t)??null,Fe=yt.current;f!=null&&f.contains(c)||Fe!=null&&Fe.contains(c)||(X(null),q(null))}return document.addEventListener("pointerdown",s),()=>{document.removeEventListener("pointerdown",s)}},[Q]);async function U(t,s){var o;try{if(p.isDesktop&&(await p.bridge.writeClipboardText(t)).ok){E({title:s,tone:"success"});return}if(typeof navigator<"u"&&((o=navigator.clipboard)!=null&&o.writeText)){await navigator.clipboard.writeText(t),E({title:s,tone:"success"});return}if(ss(t)){E({title:s,tone:"success"});return}}catch{E({title:n("common.copyContentFailed"),tone:"error"})}}async function bn(t,s){typeof window<"u"&&!window.confirm(n("git.discardConfirm",{path:s}))||await Nt(t)}function yn(t){const s=(t==null?void 0:t.desktopFloating)===!0&&!F,o=s?{top:(O==null?void 0:O.top)??_,left:(O==null?void 0:O.left)??_,maxHeight:O==null?void 0:O.maxHeight,transformOrigin:(O==null?void 0:O.transformOrigin)??"top right"}:void 0,c=e.jsxs("div",{ref:s?on:void 0,className:"git-operations-menu","data-floating":s?"true":"false",style:o,children:[e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.currentBranch")}),e.jsx("strong",{className:"git-menu-branch",children:it})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.remoteAuthStatusLabel")}),e.jsxs("div",{className:"git-menu-branch-list",children:[e.jsx("strong",{className:"git-menu-branch",children:Mt?n("git.remoteAuthConfigured"):n("git.remoteAuthNotConfigured")}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>Ze(),children:e.jsx("span",{children:n("git.remoteAuthAction")})})]})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.branchTitle")}),e.jsx("div",{className:"git-menu-branch-list",children:G==null?void 0:G.local.map(f=>e.jsx("button",{className:"git-menu-item",type:"button",disabled:N||f.current,onClick:()=>void gi(f.name),children:e.jsx("span",{children:f.current?`${n("git.switchBranch")} ${f.name}`:`${n("git.switchBranchTo")} ${f.name}`})},f.name))})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>{V(!1),dt(!0)},children:e.jsx("span",{children:n("git.viewAllVersions")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void vt("fetch"),children:e.jsx("span",{children:n("git.fetch")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void vt("pull"),children:e.jsx("span",{children:n("git.pull")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void vt("push"),children:e.jsx("span",{children:n("git.push")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void le(),children:e.jsx("span",{children:n("git.undoLastCommit")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N||$e,onClick:()=>void Ct({resetTreeScroll:!0}),children:e.jsx("span",{children:n("git.refresh")})})]})]});return s?typeof document>"u"?null:jn.createPortal(c,document.body):c}function Ht(t,s){if(s){Re.current.set(t,s);return}Re.current.delete(t)}function Ei(){var o;if(!Q||typeof document>"u")return null;const t=d.find(c=>c.commitHash===Q);if(!t)return null;const s=((o=d[0])==null?void 0:o.commitHash)===t.commitHash&&t.commitKind==="local";return jn.createPortal(e.jsx("div",{ref:yt,className:"git-history-entry-menu","data-floating":"true",style:{top:(k==null?void 0:k.top)??_,left:(k==null?void 0:k.left)??_,maxHeight:k==null?void 0:k.maxHeight,transformOrigin:(k==null?void 0:k.transformOrigin)??"top right"},children:e.jsx(ts,{item:t,canUndo:s,actioning:N,onViewCommitChanges:c=>void Ae(c),onCopyCommitHash:c=>void U(c,n("git.copyCommitHashSuccess")),onCopyCommitMessage:c=>void U(me(c),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:c=>void Pe(c),onExplainCommitChange:c=>void De(c),onUndoLastCommit:()=>void le()})}),document.body)}return r&&!Mi?e.jsx("section",{className:["conversation-panel","surface-card","git-sidebar",a].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:e.jsxs("section",{className:"git-card git-scaffold-section git-disabled-state",children:[e.jsxs("div",{className:"git-disabled-copy",children:[e.jsx("h3",{children:n("git.uninitializedTitle")}),e.jsx("p",{children:n("git.uninitializedDescription")})]}),e.jsx("div",{className:"git-primary-actions",children:e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>void di(),disabled:N||$e||!i,children:N?n("git.initInProgress"):n("git.initRepository")})})]})}):e.jsxs("section",{className:["conversation-panel","surface-card","git-sidebar",a].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:[e.jsxs("section",{className:"git-card git-scaffold-section",children:[e.jsxs("div",{className:"git-editor-row",children:[e.jsx("textarea",{ref:an,rows:1,value:fe,onChange:t=>pe(Kn(t.target.value)),onKeyDown:t=>{t.key==="Enter"&&t.preventDefault()},placeholder:n("git.commitSubjectPlaceholder")}),e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.generateDraft"),title:n("git.generateDraft"),onClick:()=>void ci(),disabled:N||$e,children:e.jsx(gs,{})})]}),e.jsxs("div",{className:"git-primary-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Ct({resetTreeScroll:!0}),disabled:N||$e||!i,children:n("git.refreshNow")}),e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>{if(Tt){dn();return}ui()},disabled:N||!Tt&&!ji,children:Tt?n("git.pushNow"):n("git.commitNow")})]})]}),F?e.jsxs("div",{className:"git-mobile-sections",children:[e.jsx(Dt,{title:n("git.stagedChangesTitle"),count:Z.length,expanded:be==="staged",onToggle:()=>ae("staged"),children:e.jsx(Dn,{title:n("git.stagedChangesTitle"),nodes:pn,collapsedTreePathSet:tt,onToggleTreePath:Qe,onToggleMobileSelection:et,selectedMobilePathSet:nt,selectedTargets:ue,actioning:N,variant:"staged",swipeRowState:Zt,onSwipeRowChange:Ke,onStageToggle:Ye,onDiscardWithConfirm:bn,onClearSelectedTargets:()=>B(t=>t.filter(s=>!ue.includes(s))),onPreviewFile:Je})}),e.jsx(Dt,{title:n("git.changesTitle"),count:ce.length,expanded:be==="unstaged",onToggle:()=>ae("unstaged"),children:e.jsx(Dn,{title:n("git.changesTitle"),nodes:xn,collapsedTreePathSet:tt,onToggleTreePath:Qe,onToggleMobileSelection:et,selectedMobilePathSet:nt,selectedTargets:de,actioning:N,variant:"unstaged",swipeRowState:Zt,onSwipeRowChange:Ke,onStageToggle:Ye,onDiscardWithConfirm:bn,onClearSelectedTargets:()=>B(t=>t.filter(s=>!de.includes(s))),onPreviewFile:Je})}),e.jsxs(Dt,{title:n("git.recentVersionsTitle"),count:R,expanded:be==="history",onToggle:()=>ae("history"),trailingContent:e.jsx("span",{className:"badge",children:it}),headerAction:e.jsx("button",{className:"git-icon-button git-mobile-section-action",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),"aria-expanded":ee,onClick:()=>{ae("history"),V(t=>!t)},disabled:N,children:e.jsx(Ge,{})}),children:[ee?e.jsx("div",{className:"git-mobile-operations-shell",children:yn()}):null,e.jsx(es,{history:d,historyLoadingMore:he,hasMore:!!K,actioning:N,openCommitHash:ye,onMenuTriggerRef:Ht,onToggleMenu:t=>X(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void U(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void U(me(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Pe(t),onExplainCommitChange:t=>void De(t),onUndoLastCommit:()=>void le(),onLoadMore:()=>void qe()})]})]}):e.jsxs("div",{ref:nn,className:"git-content-split",style:{gridTemplateRows:Ti},children:[e.jsx("section",{className:"git-card git-tree-panel",children:e.jsxs("div",{ref:sn,className:"git-tree-panel-body",children:[Z.length>0?e.jsx(Pn,{title:n("git.stagedChangesTitle"),count:Z.length,nodes:pn,selectedPath:se,collapsedTreePathSet:tt,onToggleTreePath:Qe,onSelectFile:I,onPreviewFile:(t,s)=>{gn(t)&&Je(t,s)},onToggleMobileSelection:et,onStageToggle:Ye,onDiscard:Nt,actioning:N,variant:"staged",isMobileViewport:F,selectedMobilePathSet:nt,selectedTargets:ue,mobileActionMenuOpen:xe==="staged",onToggleMobileActionMenu:()=>W(t=>t==="staged"?null:"staged"),onClearSelectedTargets:()=>B(t=>t.filter(s=>!ue.includes(s)))}):null,e.jsx(Pn,{title:n("git.changesTitle"),count:ce.length,nodes:xn,selectedPath:se,collapsedTreePathSet:tt,onToggleTreePath:Qe,onSelectFile:I,onPreviewFile:(t,s)=>{gn(t)&&Je(t,s)},onToggleMobileSelection:et,onStageToggle:Ye,onDiscard:Nt,actioning:N,variant:"unstaged",isMobileViewport:F,selectedMobilePathSet:nt,selectedTargets:de,mobileActionMenuOpen:xe==="unstaged",onToggleMobileActionMenu:()=>W(t=>t==="unstaged"?null:"unstaged"),onClearSelectedTargets:()=>B(t=>t.filter(s=>!de.includes(s)))})]})}),e.jsx("button",{className:"git-panel-divider",type:"button",role:"separator","aria-label":n("git.resizePanels"),"aria-orientation":"horizontal","aria-valuemin":Mn,"aria-valuemax":wt,"aria-valuenow":J?Et:wt,"data-dragging":xt,onPointerDown:yi,children:e.jsx("span",{className:"git-panel-divider-handle","aria-hidden":"true"})}),e.jsxs("section",{className:"git-card git-history-section",children:[e.jsxs("div",{className:"git-history-topbar",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":J,"aria-label":J?n("git.collapseRecentVersions"):n("git.expandRecentVersions"),onClick:()=>Wt(t=>!t),children:[e.jsxs("span",{className:"git-section-toggle-main",children:[e.jsx(lt,{expanded:J}),e.jsx("span",{children:n("git.recentVersionsTitle")})]}),e.jsx("span",{className:"workbench-section-counter",children:R})]}),e.jsxs("div",{className:"git-history-actions",children:[e.jsx("span",{className:"badge",children:it}),e.jsx("button",{className:"git-icon-button",type:"button",ref:rn,"aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:()=>V(t=>!t),disabled:N,children:e.jsx(Ge,{})}),ee?yn({desktopFloating:!0}):null]})]}),J?e.jsx(_n,{history:d,historyLoadingMore:he,hasMore:!!K,actioning:N,openCommitHash:re,useNativeContextMenu:un,onMenuTriggerRef:Ht,onScroll:li,onToggleMenu:t=>{if(un){const s=d.find(o=>o.commitHash===t);s&&hn(s);return}q(s=>s===t?null:t)},onOpenContextMenu:t=>void hn(t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void U(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void U(me(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Pe(t),onExplainCommitChange:t=>void De(t),onUndoLastCommit:()=>void le(),onLoadMore:()=>void qe()}):null]})]}),e.jsxs(Oe,{open:ni,title:n("git.selectRemoteTitle"),description:n("git.selectRemoteDesc"),onClose:()=>{N||Se(!1)},children:[e.jsxs("div",{className:"git-remote-auth-banner",children:[e.jsxs("div",{className:"git-remote-auth-banner-copy",children:[e.jsx("strong",{children:n("git.remoteAuthStatusLabel")}),e.jsx("span",{children:Mt?n("git.remoteAuthConfigured"):n("git.remoteAuthNotConfigured")})]}),e.jsx("button",{className:"secondary-button",type:"button",disabled:N,onClick:()=>Ze(),children:n("git.remoteAuthAction")})]}),e.jsx("div",{className:"git-remote-select-list",children:ii.map(t=>{const s=Ve.has(t.name),o=si.get(t.name);return e.jsxs("label",{className:"git-remote-item",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:N,onChange:()=>{gt(c=>{const f=new Set(c);return f.has(t.name)?f.delete(t.name):f.add(t.name),f})}}),e.jsxs("span",{className:"git-remote-item-body",children:[e.jsx("span",{className:"git-remote-name",children:t.name}),e.jsx("span",{className:"git-remote-url",children:t.pushUrl}),o&&e.jsx("span",{className:`git-remote-result ${o.ok?"ok":"err"}`,children:o.summary})]})]},t.name)})}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:N,onClick:()=>Se(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:N||Ve.size===0,onClick:()=>void mn(Array.from(Ve)),children:N?n("git.pushing"):n("git.pushSelected",{count:String(Ve.size)})})]})]}),e.jsxs(Oe,{open:ai,title:n("git.remoteAuthTitle"),description:Ci,onClose:()=>{N||Me(!1)},children:[e.jsxs("div",{className:"workbench-clone-form",children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneAuthModeLabel")}),e.jsxs("select",{value:A.authMode,disabled:N,onChange:t=>Y(s=>({...s,authMode:t.target.value})),children:[e.jsx("option",{value:"none",children:n("shell.cloneAuthModeNone")}),e.jsx("option",{value:"basic",children:n("shell.cloneAuthModeBasic")}),e.jsx("option",{value:"token",children:n("shell.cloneAuthModeToken")})]})]}),A.authMode==="basic"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneUsernameLabel")}),e.jsx("input",{type:"text",value:A.username,placeholder:Si,autoComplete:"username",onChange:t=>Y(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:Ni}),e.jsx("input",{type:"password",value:A.password,placeholder:vi,autoComplete:"current-password",onChange:t=>Y(s=>({...s,password:t.target.value}))})]})]}):null,A.authMode==="token"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneUsernameLabel")}),e.jsx("input",{type:"text",value:A.username,placeholder:n("shell.cloneTokenUsernamePlaceholder"),autoComplete:"username",onChange:t=>Y(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneTokenLabel")}),e.jsx("input",{type:"password",value:A.token,placeholder:n("shell.cloneTokenPlaceholder"),autoComplete:"current-password",onChange:t=>Y(s=>({...s,token:t.target.value}))})]})]}):null,_e?e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthGithubPatHint")}):null,A.authMode!=="none"?e.jsxs("label",{className:"settings-checkbox git-remote-auth-remember-toggle",children:[e.jsx("input",{type:"checkbox",checked:A.rememberOnHost,onChange:t=>Y(s=>({...s,rememberOnHost:t.target.checked}))}),e.jsx("span",{children:n("git.remoteAuthRemember")})]}):null,e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthSessionHint")})]}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:N,onClick:()=>Me(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:N,onClick:hi,children:n("git.remoteAuthSave")})]})]}),e.jsx(Oe,{open:Qn,title:n("git.viewAllVersions"),description:n("git.viewAllVersionsDescription",{count:String(R)}),onClose:()=>dt(!1),children:e.jsx(_n,{history:d,historyLoadingMore:he,hasMore:!!K,actioning:N,openCommitHash:re,className:"git-history-modal-list",onMenuTriggerRef:Ht,onToggleMenu:t=>q(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void U(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void U(me(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Pe(t),onExplainCommitChange:t=>void De(t),onUndoLastCommit:()=>void le(),onLoadMore:()=>void qe()})}),e.jsx(Oe,{open:Jn!==null,className:"git-commit-detail-modal",title:(D==null?void 0:D.subject)||n("git.commitDetailTitle"),description:D?n("git.commitDetailDescription",{hash:D.shortHash}):n("git.commitDetailLoading"),onClose:fi,children:ei?e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailLoading")})}):zt?e.jsx("div",{className:"git-commit-detail-state is-error",children:e.jsx("p",{children:zt})}):D?e.jsxs("div",{className:"git-commit-detail-shell",children:[e.jsxs("div",{className:"git-commit-detail-meta-grid",children:[e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitVersionLabel")}),e.jsx("strong",{children:D.versionLabel})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitHashLabel")}),e.jsx("strong",{children:D.commitHash})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitAuthorLabel")}),e.jsx("strong",{children:D.authorName})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitTimeLabel")}),e.jsx("strong",{children:os(D.authoredAt)})]})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsx("div",{className:"git-commit-detail-section-header",children:e.jsx("h3",{children:n("git.commitMessageLabel")})}),e.jsx("pre",{className:"git-commit-detail-message",children:me(D)})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsxs("div",{className:"git-commit-detail-section-header",children:[e.jsx("h3",{children:n("git.changedFilesTitle")}),e.jsx("span",{className:"workbench-section-counter",children:D.changedFiles.length})]}),e.jsx("div",{className:"git-commit-detail-file-list",children:D.changedFiles.map(t=>e.jsxs("div",{className:"git-commit-detail-file-item",children:[e.jsx("span",{className:"git-commit-detail-file-status","data-status":t.status,children:t.status}),e.jsxs("div",{className:"git-commit-detail-file-copy",children:[e.jsx("strong",{children:t.path}),t.oldPath?e.jsx("span",{children:n("git.renamedFromLabel",{path:t.oldPath})}):null]})]},`${t.status}:${t.oldPath??""}:${t.path}`))})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsxs("div",{className:"git-commit-detail-section-header",children:[e.jsx("h3",{children:n("git.commitDiffLabel")}),D.diffTruncated?e.jsx("span",{className:"git-commit-detail-truncated",children:n("git.diffTruncated")}):null]}),e.jsx("pre",{className:"git-commit-detail-diff",children:D.diffContent||n("git.emptyDiff")})]})]}):e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailEmpty")})})}),e.jsx(Oe,{open:ti,className:"git-explain-provider-modal",title:n("git.explainCommitTitle"),description:n("git.explainCommitDescription"),onClose:()=>{te||(Ne(!1),Ce(null),oe(null))},children:e.jsxs("div",{className:"git-explain-provider-shell",children:[e.jsx(Xi,{workspaceId:i,selectedProvider:ve,pendingProvider:te?ve:null,disabled:te,onSelect:t=>oe(t)}),e.jsxs("div",{className:"git-explain-provider-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:te,onClick:()=>{Ne(!1),Ce(null),oe(null)},children:n("common.cancel")}),e.jsx("button",{type:"button",className:"primary-button",disabled:!ve||te,onClick:()=>void xi(),children:te?n("conversation.sendingState"):n("git.startExplainCommit")})]})]})}),e.jsx(Qi,{workspaceId:i,filePath:en,open:en!==null,onClose:()=>{Ee(null),He(null)},onSaved:async()=>{await Ct({resetTreeScroll:!0})},diffContent:ri}),Ei()]})}function Pn({title:a,count:i,nodes:u,selectedPath:g,collapsedTreePathSet:m,onToggleTreePath:C,onSelectFile:p,onPreviewFile:y,onToggleMobileSelection:b,onStageToggle:v,onDiscard:M,actioning:S,variant:T,isMobileViewport:x,selectedMobilePathSet:r,selectedTargets:h,mobileActionMenuOpen:j,onToggleMobileActionMenu:H,onClearSelectedTargets:d}){const P=Ut(u),R=T==="staged"?n("git.unstageAll"):n("git.stageAll");return e.jsxs("section",{className:"git-tree-group","data-variant":T,children:[e.jsxs("div",{className:"git-section-header git-tree-group-header",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"git-tree-group-actions",children:[e.jsx("span",{className:"workbench-section-counter",children:i}),!x&&P.length>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":R,title:R,onClick:()=>void v(P,T==="staged"),disabled:S,children:e.jsx($t,{staged:T==="staged"})}),T==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":n("git.discardAll"),title:n("git.discardAll"),onClick:()=>void M(P),disabled:S,children:e.jsx(Bt,{})}):null]}):null,x&&h.length>0?e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:H,disabled:S,children:e.jsx(Ge,{})}):null]}),x&&j?e.jsxs("div",{className:"git-selection-menu",children:[e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.selectedFiles")}),e.jsx("strong",{className:"git-menu-branch",children:h.length})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void v(h,T==="staged"),children:e.jsx("span",{children:T==="staged"?n("git.unstage"):n("git.stage")})}),T==="unstaged"?e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void M(h),children:e.jsx("span",{children:n("git.discard")})}):null,e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:d,children:e.jsx("span",{children:n("git.clearSelection")})})]})]}):null]}),e.jsx("div",{className:"git-tree-shell",role:"tree","aria-label":a,children:u.length?Vn({nodes:u,depth:0,collapsedTreePathSet:m,selectedPath:g,onToggleTreePath:C,onSelectFile:p,onPreviewFile:y,onToggleMobileSelection:b,onStageToggle:v,onDiscard:M,actioning:S,variant:T,isMobileViewport:x,selectedMobilePathSet:r}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Dt({title:a,count:i,expanded:u,onToggle:g,trailingContent:m,headerAction:C,children:p}){return e.jsxs("section",{className:"git-mobile-section","data-expanded":u,children:[e.jsxs("div",{className:"git-mobile-section-header",children:[e.jsxs("button",{className:"git-mobile-section-toggle",type:"button","aria-expanded":u,onClick:g,children:[e.jsxs("span",{className:"git-mobile-section-toggle-main",children:[e.jsx(lt,{expanded:u}),e.jsx("h3",{children:a})]}),e.jsxs("span",{className:"git-mobile-section-toggle-meta",children:[m,e.jsx("span",{className:"workbench-section-counter",children:i})]})]}),C?e.jsx("div",{className:"git-mobile-section-header-action",children:C}):null]}),u?e.jsx("div",{className:"git-mobile-section-body",children:p}):null]})}function Dn({title:a,nodes:i,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,selectedTargets:p,actioning:y,variant:b,swipeRowState:v,onSwipeRowChange:M,onStageToggle:S,onDiscardWithConfirm:T,onClearSelectedTargets:x,onPreviewFile:r}){return e.jsxs("div",{className:"git-mobile-record-shell",children:[p.length>0?e.jsxs("div",{className:"git-mobile-selection-toolbar",children:[e.jsxs("span",{className:"git-mobile-selection-count",children:[n("git.selectedFiles")," ",p.length]}),e.jsxs("div",{className:"git-mobile-selection-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:y,onClick:()=>void S(p,b==="staged"),children:b==="staged"?n("git.unstage"):n("git.stage")}),b==="unstaged"?e.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:y,onClick:()=>void T(p,`${p.length}`),children:n("git.discard")}):null,e.jsx("button",{type:"button",className:"secondary-button",disabled:y,onClick:x,children:n("git.clearSelection")})]})]}):null,e.jsx("div",{className:"git-mobile-record-list",role:"tree","aria-label":a,children:i.length?Un({nodes:i,depth:0,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,actioning:y,variant:b,swipeRowState:v,onSwipeRowChange:M,onStageToggle:S,onDiscardWithConfirm:T,onPreviewFile:r}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Un({nodes:a,depth:i,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,actioning:p,variant:y,swipeRowState:b,onSwipeRowChange:v,onStageToggle:M,onDiscardWithConfirm:S,onPreviewFile:T}){return a.map(x=>{if(x.kind==="directory"){const j=!u.has(x.path),H=Ut(x.children),d=`directory:${x.path}`;return e.jsxs("div",{className:"git-mobile-record-branch",children:[e.jsx(Ln,{rowKey:d,openState:(b==null?void 0:b.path)===d?b.direction:null,onOpenStateChange:P=>v(P?{path:d,direction:P}:null),trailingActions:H.length>0?[{label:y==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M(H,y==="staged")},...y==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S(H,x.path)}]:[]]:null,children:e.jsxs("button",{className:"git-mobile-record git-mobile-record-directory",type:"button",style:{paddingInlineStart:`${wn+i*An}px`},onClick:()=>g(x.path),children:[e.jsxs("span",{className:"git-mobile-record-leading",children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":j,children:e.jsx(lt,{expanded:j})}),e.jsx("span",{className:"git-mobile-record-title",children:x.name})]}),e.jsx("span",{className:"git-mobile-record-meta",children:H.length})]})}),j?e.jsx("div",{className:"git-mobile-record-children",role:"group",children:Un({nodes:x.children,depth:i+1,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,actioning:p,variant:y,swipeRowState:b,onSwipeRowChange:v,onStageToggle:M,onDiscardWithConfirm:S,onPreviewFile:T})}):null]},d)}const r=`file:${x.path}`,h=C.has(x.path);return e.jsx(Ln,{rowKey:r,openState:(b==null?void 0:b.path)===r?b.direction:null,onOpenStateChange:j=>v(j?{path:r,direction:j}:null),trailingActions:[{label:n("git.preview"),tone:"neutral",onPress:()=>T(x.change.path,x.change)},{label:y==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M([x.change.path],y==="staged")},...y==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S([x.change.path],x.path)}]:[]],children:e.jsxs("div",{className:"git-mobile-record git-mobile-record-file","data-active":h,style:{paddingInlineStart:`${wn+i*An}px`},children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:h,"aria-label":`${n("git.selectFile")} ${x.name}`,onChange:()=>m(x.change.path)}),e.jsxs("button",{className:"git-mobile-record-file-main",type:"button",onClick:()=>m(x.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Ot(x.name),"aria-hidden":"true",children:Ft(x.name)}),e.jsxs("span",{className:"git-mobile-record-copy",children:[e.jsx("span",{className:"git-mobile-record-title",children:x.name}),e.jsx("span",{className:"git-mobile-record-path",children:x.path})]}),e.jsx("span",{className:"git-status-badge","data-status":x.status,children:x.status})]})]})},r)})}function Ln({rowKey:a,openState:i,onOpenStateChange:u,trailingActions:g,children:m}){const C=Zi(),p=l.useRef(null),[y,b]=l.useState(0),v=((g==null?void 0:g.length)??0)*At;l.useEffect(()=>{i||b(0)},[i,a]);const M=y!==0?y:i==="trailing"?-v:0;function S(h){var j,H;h.button===0&&(p.current={pointerId:h.pointerId,startX:h.clientX},(H=(j=h.currentTarget).setPointerCapture)==null||H.call(j,h.pointerId))}function T(h){const j=p.current;if(!j||j.pointerId!==h.pointerId)return;const H=v>0?v+10:0,d=Math.max(-H,Math.min(0,h.clientX-j.startX));b(d)}function x(h){var H,d;const j=p.current;if(!(!j||j.pointerId!==h.pointerId)){if((d=(H=h.currentTarget).releasePointerCapture)==null||d.call(H,h.pointerId),p.current=null,y<=-44&&(g!=null&&g.length)){C.trigger("gesture"),u("trailing"),b(0);return}u(null),b(0)}}function r(h){var H,d;const j=p.current;!j||j.pointerId!==h.pointerId||((d=(H=h.currentTarget).releasePointerCapture)==null||d.call(H,h.pointerId),p.current=null,b(0))}return e.jsxs("div",{className:"git-mobile-swipe-row","data-open-state":i??"closed","data-dragging":y!==0,children:[g==null?void 0:g.map((h,j)=>e.jsx("button",{type:"button",className:"git-mobile-swipe-action trailing","data-tone":h.tone,style:{right:j*At,width:At},onClick:()=>{C.trigger(h.tone==="danger"?"warning":"action"),u(null),h.onPress()},children:h.label},`trailing-${j}`)),e.jsx("div",{className:"git-mobile-swipe-content",style:{transform:`translateX(${M}px)`},onPointerDown:S,onPointerMove:T,onPointerUp:x,onPointerCancel:r,children:m})]})}function es({history:a,historyLoadingMore:i,hasMore:u,actioning:g,openCommitHash:m,onMenuTriggerRef:C,onToggleMenu:p,onViewCommitChanges:y,onCopyCommitHash:b,onCopyCommitMessage:v,onCopyCommitVersion:M,onExplainCommitChange:S,onUndoLastCommit:T,onLoadMore:x}){return a.length?e.jsxs("div",{className:"git-mobile-history-list",children:[a.map(r=>e.jsx("article",{className:"git-mobile-history-entry","data-kind":r.commitKind,children:e.jsxs("div",{className:"git-mobile-history-entry-main",children:[e.jsx("span",{className:"git-history-marker","data-kind":r.commitKind,"aria-hidden":"true"}),e.jsxs("div",{className:"git-mobile-history-copy",children:[e.jsxs("div",{className:"git-history-title-row",children:[e.jsx("strong",{title:r.subject,children:r.subject}),e.jsx("span",{className:"git-history-kind-badge","data-kind":r.commitKind,children:In(r.commitKind)})]}),r.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:r.refs.map(h=>e.jsx("span",{className:"git-history-ref-pill","data-kind":h.kind,"data-remote-index":String(Xn(h.remoteName)),children:h.name},`${r.commitHash}:${h.kind}:${h.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:r.commitHash.slice(0,8)}),e.jsx("span",{children:r.authorName}),e.jsx("time",{dateTime:r.authoredAt,children:qn(r.authoredAt)})]})]}),e.jsx("button",{type:"button",className:"git-icon-button",ref:h=>C(r.commitHash,h),"aria-label":n("git.historyItemMenu"),onClick:()=>p(r.commitHash),children:e.jsx(Ge,{})})]})},r.commitHash)),u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:x,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"git-tree-status",children:n("git.noHistory")})}function _n({history:a,historyLoadingMore:i,hasMore:u,actioning:g,openCommitHash:m,className:C,useNativeContextMenu:p=!1,onMenuTriggerRef:y,onScroll:b,onToggleMenu:v,onOpenContextMenu:M,onViewCommitChanges:S,onCopyCommitHash:T,onCopyCommitMessage:x,onCopyCommitVersion:r,onExplainCommitChange:h,onUndoLastCommit:j,onLoadMore:H}){return a.length?e.jsxs("div",{className:["git-history-list",C].filter(Boolean).join(" "),onScroll:b,children:[a.map(d=>{const P=m===d.commitHash;return e.jsxs("article",{className:"git-history-entry","data-kind":d.commitKind,"data-menu-open":P?"true":"false",onContextMenu:R=>{!p||!M||(R.preventDefault(),R.stopPropagation(),M(d))},children:[e.jsx("span",{className:"git-history-marker","data-kind":d.commitKind,"aria-hidden":"true"}),e.jsxs("div",{className:"git-history-body",children:[e.jsxs("div",{className:"git-history-title-row",children:[e.jsx("strong",{title:d.subject,children:d.subject}),e.jsxs("div",{className:"git-history-title-actions",children:[e.jsx("span",{className:"git-history-kind-badge","data-kind":d.commitKind,children:In(d.commitKind)}),p?null:e.jsx("button",{type:"button",className:"git-icon-button git-history-more",ref:R=>y(d.commitHash,R),"aria-label":n("git.historyItemMenu"),onClick:()=>{v(d.commitHash)},children:e.jsx(Ge,{})})]})]}),d.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:d.refs.map(R=>e.jsx("span",{className:"git-history-ref-pill","data-kind":R.kind,"data-remote-index":String(Xn(R.remoteName)),children:R.name},`${d.commitHash}:${R.kind}:${R.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:d.commitHash.slice(0,8)}),e.jsx("span",{children:d.authorName}),e.jsx("time",{dateTime:d.authoredAt,children:qn(d.authoredAt)})]})]})]},d.commitHash)}),i?e.jsxs("p",{className:"git-history-loading",children:[n("git.refreshNow"),"..."]}):null,u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:H,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"status-text",children:n("git.noHistory")})}function ts({item:a,canUndo:i,actioning:u,onViewCommitChanges:g,onCopyCommitHash:m,onCopyCommitMessage:C,onCopyCommitVersion:p,onExplainCommitChange:y,onUndoLastCommit:b}){return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>g(a.commitHash),children:e.jsx("span",{children:n("git.viewCommitChanges")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>m(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitHash")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>C(a),children:e.jsx("span",{children:n("git.copyCommitMessage")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>p(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitVersion")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>y(a.commitHash),children:e.jsx("span",{children:n("git.explainCommitAction")})}),i?e.jsx("button",{type:"button",className:"git-menu-item",disabled:u,onClick:b,children:e.jsx("span",{children:n("git.undoLastCommit")})}):null]})}function Vn({nodes:a,depth:i,collapsedTreePathSet:u,selectedPath:g,onToggleTreePath:m,onSelectFile:C,onPreviewFile:p,onToggleMobileSelection:y,onStageToggle:b,onDiscard:v,actioning:M,variant:S,isMobileViewport:T,selectedMobilePathSet:x}){return a.map(r=>{if(r.kind==="directory"){const H=!u.has(r.path),d=Ut(r.children),P=`${S==="staged"?n("git.unstage"):n("git.stage")} ${r.path}`,R=`${n("git.discard")} ${r.path}`;return e.jsxs("div",{className:"git-tree-node",children:[e.jsxs("div",{className:"git-tree-row",role:"treeitem","aria-expanded":H,children:[e.jsxs("button",{className:"git-tree-trigger",type:"button",style:{paddingInlineStart:`${6+i*8}px`},onClick:()=>m(r.path),children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":H,children:e.jsx(lt,{expanded:H})}),e.jsx("span",{className:"git-tree-label git-tree-label-directory",children:r.name})]}),!T&&d.length>0?e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":P,title:P,onClick:()=>void b(d,S==="staged"),disabled:M,children:e.jsx($t,{staged:S==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":R,title:R,onClick:()=>void v(d),disabled:M,children:e.jsx(Bt,{})}):null]}):null]}),H?e.jsx("div",{className:"git-tree-children",role:"group",children:Vn({nodes:r.children,depth:i+1,collapsedTreePathSet:u,selectedPath:g,onToggleTreePath:m,onSelectFile:C,onPreviewFile:p,onToggleMobileSelection:y,onStageToggle:b,onDiscard:v,actioning:M,variant:S,isMobileViewport:T,selectedMobilePathSet:x})}):null]},`directory:${r.path}`)}const h=x.has(r.path),j=T?h:g===r.path;return T?e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":j,"data-mobile":"true",children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:h,"aria-label":`${n("git.selectFile")} ${r.name}`,onChange:()=>y(r.change.path)}),e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":j,"data-mobile":"true",style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>y(r.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Ot(r.name),"aria-hidden":"true",children:Ft(r.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:r.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":r.status,children:r.status})})]})]},`file:${r.path}`):e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":j,children:[e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":j,style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>{C(r.change.path),p&&p(r.change.path,r.change)},children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Ot(r.name),"aria-hidden":"true",children:Ft(r.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:r.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":r.status,children:r.status})})]}),e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":r.variant==="staged"?n("git.unstage"):n("git.stage"),title:r.variant==="staged"?n("git.unstage"):n("git.stage"),onClick:()=>void b([r.change.path],r.variant==="staged"),disabled:M,children:e.jsx($t,{staged:r.variant==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":n("git.discard"),title:n("git.discard"),onClick:()=>void v([r.change.path]),disabled:M,children:e.jsx(Bt,{})}):null]})]},`file:${r.path}`)})}function Fn(a,i){return{kind:"directory",name:a,path:i,children:new Map}}function On(a,i){const u=Fn("","");for(const g of a){const m=g.path.replace(/\\/g,"/"),C=m.split("/").filter(Boolean);let p=u;C.forEach((y,b)=>{const v=C.slice(0,b+1).join("/");if(b===C.length-1){p.children.set(`file:${v}`,{kind:"file",name:y,path:m,change:g,status:ns(g,i),variant:i});return}const M=`directory:${v}`,S=p.children.get(M);if(S&&S.kind==="directory"){p=S;return}const T=Fn(y,v);p.children.set(M,T),p=T})}return zn(Wn([...u.children.values()]))}function Wn(a){return[...a].sort((i,u)=>i.kind!==u.kind?i.kind==="directory"?-1:1:i.name.localeCompare(u.name,"zh-CN")).map(i=>i.kind==="directory"?{kind:"directory",name:i.name,path:i.path,children:Wn([...i.children.values()])}:i)}function zn(a){return a.map(i=>{var p;if(i.kind!=="directory")return i;const u=zn(i.children);let g=i.name,m=i.path,C=u;for(;C.length===1&&((p=C[0])==null?void 0:p.kind)==="directory";){const y=C[0];g=`${g}/${y.name}`,m=y.path,C=y.children}return{kind:"directory",name:g,path:m,children:C}})}function kn(a,i,u){const g=new Set(a);return i.filter(m=>Gt(m,u)&&g.has(m.path)).map(m=>m.path)}function Ut(a){const i=[],u=new Set;function g(m){if(m.kind==="file"){u.has(m.path)||(u.add(m.path),i.push(m.path));return}m.children.forEach(g)}return a.forEach(g),i}function Gt(a,i){return i==="staged"?!!a.stagedStatus:!!a.worktreeStatus}function ns(a,i){return i==="staged"?a.stagedStatus??a.status:a.worktreeStatus??a.status}function is(a){return{subject:Kn(a).trim(),body:null,footer:null,source:"manual"}}function Kn(a){return a.replace(/[\r\n]+/g," ")}function ss(a){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const i=document.createElement("textarea");i.value=a,i.setAttribute("readonly","true"),i.style.position="fixed",i.style.top="-9999px",i.style.left="-9999px",i.style.opacity="0",document.body.appendChild(i),i.focus(),i.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(i)}}function me(a){const i=a.subject.trim(),u=a.body.trim();return u?`${i}
|
|
2
|
+
|
|
3
|
+
${u}`:i}function as(a){const i=a.changedFiles.map(m=>`- [${m.status}] ${m.path}${m.oldPath?` (from ${m.oldPath})`:""}`).join(`
|
|
4
|
+
`),u=a.diffContent.length>Pt?a.diffContent.slice(0,Pt):a.diffContent,g=a.diffContent.length>Pt||a.diffTruncated?`
|
|
5
|
+
注意:diff 内容过长,下面已经截断,只分析可见部分,同时明确指出可能遗漏的区域。`:"";return["请你分析下面这个 Git 提交。","输出要求:","1. 先用 3 到 5 句话说明这次改动的核心目的。","2. 按文件说明关键改动点,不要泛泛而谈。","3. 指出潜在风险、边界情况和可能的回归点。","4. 如果提交信息写得差,给出一条更合适的中文提交说明。","",`版本号:${a.versionLabel}`,`Commit Hash:${a.commitHash}`,`提交标题:${a.subject}`,`提交作者:${a.authorName} <${a.authorEmail}>`,`提交时间:${a.authoredAt}`,"","变更文件:",i||"- 无",g,"","Diff:",u||"(empty diff)"].join(`
|
|
6
|
+
`)}function rs(a){if(!a)return;a.style.height="0px";const i=Math.min(Math.max(a.scrollHeight,34),120);a.style.height=`${i}px`,a.style.overflowY=a.scrollHeight>120?"auto":"hidden"}function In(a){switch(a){case"local":return n("git.historyKindLocal");case"remote":return n("git.historyKindRemote");default:return n("git.historyKindShared")}}function Xn(a){if(!a)return 0;let i=0;for(const u of a)i=i*33+u.charCodeAt(0)>>>0;return i%6}function os(a){const i=Date.parse(a);return Number.isNaN(i)?a:new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(i)}function L(a,i){return a instanceof Bn?cs(a)??a.message:typeof a=="object"&&a&&"message"in a?a.message:i}function ke(a){return`git-sidebar.snapshot.${a}`}function Lt(a){return a?!!(a.status||a.branches||a.history.length>0||a.historyTotalCount>0||a.historyNextCursor||a.revision):!1}function ls(a){return a?a.snapshot.enabled!==!1:!0}function cs(a){switch(a.errorCode){case"UNAUTHORIZED":return n("git.errors.unauthorized");case"WORKSPACE_NOT_FOUND":return n("git.errors.workspaceNotFound");case"INVALID_WORKSPACE":return n("git.errors.invalidWorkspace");case"NOT_GIT_REPOSITORY":return n("git.errors.notGitRepository");case"GIT_REPO_NOT_FOUND":return n("git.errors.repoNotFound");case"PATH_OUT_OF_WORKSPACE":return n("git.errors.pathOutOfWorkspace");case"INVALID_TARGET":return n("git.errors.invalidTarget");case"NOT_STAGED":return n("git.errors.notStaged");case"EMPTY_STAGED_CHANGES":return n("git.errors.emptyStagedChanges");case"BRANCH_CONFLICT":return n("git.errors.branchConflict");case"BRANCH_NOT_FOUND":return n("git.errors.branchNotFound");case"REMOTE_NOT_FOUND":return n("git.errors.remoteNotFound");case"GIT_REMOTE_AUTH_FAILED":return n("git.errors.remoteAuthFailed");case"GIT_PUSH_FAILED":return n("git.errors.pushFailed");case"GIT_PULL_FAILED":return n("git.errors.pullFailed");case"GIT_REMOTE_FAILED":return n("git.errors.remoteFailed");case"GIT_COMMAND_TIMEOUT":return n("git.errors.commandTimeout");case"GIT_INIT_FAILED":return n("git.errors.initFailed");case"GIT_DISCARD_FAILED":return n("git.discardFailed");case"GIT_UNDO_FAILED":return n("git.undoLastCommitFailed");default:return null}}function Gn(a){return a instanceof Bn&&a.errorCode==="GIT_REMOTE_AUTH_FAILED"}function us(a){return!a||!a.mode||a.mode==="none"?ot:a.mode==="basic"?{authMode:"basic",username:a.username??"",password:a.password??"",token:"",rememberOnHost:!1}:a.mode==="token"?{authMode:"token",username:a.username??"",password:"",token:a.token??"",rememberOnHost:!1}:ot}function ds(a){return a.authMode==="none"?null:a.authMode==="basic"?{mode:"basic",username:a.username.trim(),password:a.password}:{mode:"token",username:a.username.trim()||void 0,token:a.token}}function ms(a,i){const u=a.find(m=>m.name===i)??a.find(m=>m.name==="origin")??a[0];if(!u)return"generic";const g=u.pushUrl||u.fetchUrl;return hs(g)?"github":"generic"}function hs(a){const i=(a==null?void 0:a.trim().toLowerCase())??"";return i.startsWith("https://github.com/")||i.startsWith("http://github.com/")||i.startsWith("ssh://git@github.com/")||i.startsWith("git@github.com:")}function $n(a,i,u){const g=Math.max(0,u.width),m=Math.max(0,u.height),C=Math.max(0,m-_*2),p=Math.max(0,g-_*2),y=Math.min(Math.max(i.width||kt,0),p),b=Math.max(0,m-a.bottom-rt-_),v=Math.max(0,a.top-rt-_),M=b<i.height&&v>b,T=_t(Math.max(M?v:b,Ji),0,C),x=Math.min(Math.max(i.height,0),T),r=M?a.top-rt-x:a.bottom+rt,h=Math.max(_,m-_-x),j=Math.max(_,g-_-y);return{top:_t(r,_,h),left:_t(a.right-y,_,j),maxHeight:Math.max(0,T),transformOrigin:`${M?"bottom":"top"} right`}}function _t(a,i,u){return!Number.isFinite(a)||u<i?i:Math.min(Math.max(a,i),u)}function lt({expanded:a}){return e.jsx("svg",{className:"git-chevron-icon",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:a?"rotate(0deg)":"rotate(-90deg)"},"aria-hidden":"true",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function $t({staged:a}){return a?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M5 12h14"})}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"M5 12h14"})]})}function Bt(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M10 7L6 11l4 4",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7 11h7c3.87 0 7 3.13 7 7 0 1.9-.76 3.63-2 4.89",strokeLinecap:"round",strokeLinejoin:"round"})]})}function gs(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z"})})}function Ge(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"5",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"19",cy:"12",r:"1.8"})]})}function qn(a){try{return new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(a))}catch{return a}}export{Ms as GitSidebar,$n as resolveGitOperationsMenuPosition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as c,j as e,t as a}from"./index-
|
|
1
|
+
import{b as c,j as e,t as a}from"./index-BZLcEHW3.js";import{e as j,M as f,f as k,h as g,i as v,j as M,k as S,S as L}from"./MobileSheet-Ckug8hTb.js";function E({open:o,workspaces:l,workspaceOptions:t,initialWorkspaceId:d,onClose:b,onSelect:x}){const[n,p]=c.useState(""),[h,u]=c.useState(!1),m=j(),i=c.useMemo(()=>t??l.map(s=>({workspace:s,label:s.name,subtitle:s.path,depth:0,kind:"workspace",meta:null})),[t,l]),w=c.useMemo(()=>i.map(s=>s.workspace.id).join("|"),[i]);if(c.useEffect(()=>{o&&(p(N(i,d)),u(!1))},[d,o,w]),!o)return null;const r=i.find(s=>s.workspace.id===n)??i[0]??null;return e.jsxs(f,{open:o,title:a("shell.createSessionModalTitle"),description:a("shell.createSessionModalDescription"),kind:"form",height:"three-quarter",className:"mobile-create-session-sheet",cardClassName:"mobile-create-session-sheet-card",bodyClassName:"mobile-feature-form mobile-workspace-home-form mobile-create-session-form",showHandle:!0,onClose:b,children:[e.jsx(k,{className:"mobile-create-session-section",tone:"accent",children:e.jsxs(g,{label:a("shell.createSessionWorkspaceLabel"),children:[e.jsxs("button",{type:"button",className:"mobile-create-session-workspace-trigger","aria-label":`${a("shell.createSessionWorkspaceLabel")} ${(r==null?void 0:r.label)??""}`.trim(),"aria-expanded":h?"true":"false",disabled:i.length===0,onClick:()=>{m.trigger("selection"),u(s=>!s)},children:[e.jsxs("span",{className:"mobile-create-session-workspace-copy",children:[e.jsx("strong",{children:(r==null?void 0:r.label)??a("common.unknown")}),e.jsx("span",{children:(r==null?void 0:r.subtitle)??a("common.unknown")})]}),e.jsx(C,{expanded:h})]}),h?e.jsx(v,{className:"mobile-workspace-home-group mobile-create-session-workspace-list",role:"list",children:i.map(s=>e.jsx(M,{as:"button",className:"mobile-workspace-home-row mobile-create-session-workspace-row","data-worktree-kind":s.kind,"data-worktree-depth":s.depth,selected:s.workspace.id===n,trailing:e.jsx("span",{className:"mobile-workspace-home-row-trailing",children:s.workspace.id===n?e.jsx(I,{}):e.jsx(y,{})}),style:{"--mobile-workspace-tree-depth":String(s.depth)},onClick:()=>{s.workspace.id!==n&&m.trigger("selection"),p(s.workspace.id),u(!1)},children:e.jsxs("span",{className:"mobile-create-session-workspace-option-copy",children:[e.jsxs("strong",{children:[s.kind==="worktree"?e.jsx(S,{className:"mobile-workspace-home-worktree-badge",children:a("shell.mobileWorktreeBadge")}):null,s.label]}),e.jsx("span",{children:s.subtitle})]})},s.workspace.id))}):null]})}),e.jsx(k,{className:"mobile-create-session-provider-block",heading:a("shell.createSessionProviderLabel"),description:a("shell.providerOptionHint"),children:e.jsx(L,{disabled:!n,workspaceId:n||null,onSelect:s=>{n&&x(n,s)}})})]})}function N(o,l){var t;return l&&o.some(d=>d.workspace.id===l)?l:((t=o[0])==null?void 0:t.workspace.id)??""}function C({expanded:o}){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",className:"mobile-create-session-workspace-chevron","data-expanded":o?"true":"false",children:e.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function y(){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function I(){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}export{E as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var V=Object.defineProperty;var Z=(e,n,s)=>n in e?V(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var R=(e,n,s)=>Z(e,typeof n!="symbol"?n+"":n,s);import{C as r,A as Y,b as w,j as i,t as g,f as X,Y as H,h as $}from"./index-BZLcEHW3.js";import{e as _,g as ee}from"./App-BZvapsi8.js";function ne(){return r.request("/api/workspaces")}async function Te(){try{return await r.request("/api/workbench")}catch(e){if(!(e instanceof Y)||e.status!==404)throw e;const n=await ne();return{items:await Promise.all(n.items.map(async t=>({workspace:t,sessions:(await se(t.id)).items})))}}}function Be(e){return r.request("/api/workspaces/import",{method:"POST",body:JSON.stringify(e)})}function Me(e){return r.request("/api/workspaces/clone",{method:"POST",body:JSON.stringify(e)})}function je(e){return r.request(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})}function ke(e){return r.request("/api/debug-targets/analyze",{method:"POST",body:JSON.stringify(e)})}function Fe(e,n){return r.request(`/api/debug-targets/${encodeURIComponent(e)}/launch-plan`,{method:"POST",body:JSON.stringify({})})}function Je(){return r.request("/api/framework-compatibility-matrix")}function Ke(e){return r.request("/api/workspaces/reorder",{method:"PUT",body:JSON.stringify(e)})}function Qe(e,n){return r.request(`/api/workspaces/${encodeURIComponent(e)}/navigation-state`,{method:"PUT",body:JSON.stringify(n)})}function Ge(e){const n=new URLSearchParams;return e!=null&&e.trim()&&n.set("path",e.trim()),r.request(`/api/workspaces/browse${n.size>0?`?${n.toString()}`:""}`)}function We(e){return r.request("/api/workspaces/directories",{method:"POST",body:JSON.stringify(e)})}function se(e){return r.request(`/api/sessions?workspaceId=${encodeURIComponent(e)}`)}function ze(e){return r.request(`/api/sessions/${encodeURIComponent(e)}`)}function Ve(e){return r.request(`/api/sessions/${encodeURIComponent(e)}/changed-files`)}function Ze(e){return r.request(`/api/sessions/${encodeURIComponent(e)}/seen`,{method:"POST"})}function Ye(e,n){return r.request(`/api/sessions/${encodeURIComponent(e)}/title`,{method:"PATCH",body:JSON.stringify({title:n})})}function Xe(e,n){return r.request(`/api/sessions/${encodeURIComponent(e)}/archive`,{method:"PATCH",body:JSON.stringify({archived:n})})}function He(e,n){return r.request(`/api/sessions/${encodeURIComponent(e)}/favorite`,{method:"PATCH",body:JSON.stringify({favorite:n})})}function $e(e){return r.request(`/api/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function _e(e,n){return r.request(`/api/sessions/${encodeURIComponent(e)}/parallel-groups`,{method:"POST",body:JSON.stringify(n)})}function en(e,n){return r.request(`/api/workspaces/${encodeURIComponent(e)}/parallel-groups`,{method:"POST",body:JSON.stringify(n)})}function nn(e){return r.request(`/api/parallel-groups/${encodeURIComponent(e)}`)}function sn(e,n){return r.request(`/api/parallel-groups/${encodeURIComponent(e)}/members`,{method:"POST",body:JSON.stringify(n)})}function tn(e){return r.request(`/api/session-isolated-workspaces/${encodeURIComponent(e)}/promote`,{method:"POST"})}function on(e){return r.request("/api/worktrees",{method:"POST",body:JSON.stringify(e)})}function rn(e){return r.request(`/api/worktrees/${encodeURIComponent(e)}/merge-preview`,{method:"POST"})}function an(e){return r.request(`/api/worktrees/${encodeURIComponent(e)}/merge-into-parent`,{method:"POST"})}function un(e,n){return r.request(`/api/worktrees/${encodeURIComponent(e)}/cleanup`,{method:"POST",body:JSON.stringify(n??{})})}function ln(e){return r.request(`/api/sessions/${encodeURIComponent(e)}/capabilities`)}function cn(e){return r.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests`)}function dn(){return r.request("/api/preferences/quick-phrases")}function fn(e){return r.request("/api/preferences/quick-phrases",{method:"PUT",body:JSON.stringify({items:e})})}function te(e,n){const s=new URLSearchParams;return n!=null&&n.trim()&&s.set("workspaceId",n.trim()),r.request(`/api/providers/${encodeURIComponent(e)}/capabilities${s.size>0?`?${s.toString()}`:""}`)}async function oe(e,n){const s=await Promise.allSettled(e.map(async o=>[o,await te(o,n)])),t=[];for(const o of s){if(o.status!=="fulfilled")continue;const[a,l]=o.value;t.push([a,l])}return Object.fromEntries(t)}function pn(e,n,s,t="forward"){const o=new URLSearchParams;return n&&o.set("cursor",n),o.set("limit",String(s)),o.set("direction",t),r.request(`/api/sessions/${encodeURIComponent(e)}/messages?${o.toString()}`)}function mn(e,n){return r.requestBlob(`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(n)}/content`)}function gn(e,n){return r.request(`/api/sessions/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(n)})}function Sn(e,n){return r.request(`/api/sessions/${encodeURIComponent(e)}/forks`,{method:"POST",body:JSON.stringify(n)})}function An(e){return r.request("/api/sessions/start-live",{method:"POST",body:JSON.stringify(e)})}function hn(e,n){return r.request(`/api/sessions/${encodeURIComponent(e)}/messages/live`,{method:"POST",body:JSON.stringify(n)})}function yn(e){return r.request(`/api/sessions/${encodeURIComponent(e)}/queue`)}function vn(e,n){return r.request(`/api/sessions/${encodeURIComponent(e)}/queue`,{method:"POST",body:JSON.stringify(n)})}function Rn(e,n){return r.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(n)}`,{method:"DELETE"})}function Cn(e,n){return r.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(n)}/steer`,{method:"POST"})}function wn(e){return r.request(`/api/sessions/${encodeURIComponent(e)}/runtime`)}function Dn(e){return r.request(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:"POST"})}function Pn(e,n,s){return r.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests/${encodeURIComponent(n)}/reply`,{method:"POST",body:JSON.stringify(s)})}const I="codingns.workspace.session-display-sort-mode",b="codingns.file-panel.show-system-files",q="codingns.notification.preferences",C={notifyOnPermissionRequest:!0,notifyOnSessionCompleted:!0,notifyOnSessionFailed:!0};function D(){return typeof window<"u"&&typeof window.localStorage<"u"}function re(e){return e==="createdAt"||e==="updatedAt"||e==="title"}function B(){if(!D())return"createdAt";const e=window.localStorage.getItem(I);return re(e)?e:"createdAt"}function M(){return D()?window.localStorage.getItem(b)==="1":!1}function U(e){return typeof e=="boolean"}function j(){if(!D())return C;const e=window.localStorage.getItem(q);if(!e)return C;try{const n=JSON.parse(e);return{notifyOnPermissionRequest:U(n.notifyOnPermissionRequest)?n.notifyOnPermissionRequest:C.notifyOnPermissionRequest,notifyOnSessionCompleted:U(n.notifyOnSessionCompleted)?n.notifyOnSessionCompleted:C.notifyOnSessionCompleted,notifyOnSessionFailed:U(n.notifyOnSessionFailed)?n.notifyOnSessionFailed:C.notifyOnSessionFailed}}catch{return C}}function k(e,n){return e.notifyOnPermissionRequest===n.notifyOnPermissionRequest&&e.notifyOnSessionCompleted===n.notifyOnSessionCompleted&&e.notifyOnSessionFailed===n.notifyOnSessionFailed}function ie(e){D()&&window.localStorage.setItem(q,JSON.stringify(e))}class ae{constructor(){R(this,"state",{sessionDisplaySortMode:B(),showSystemFiles:M(),notificationPreferences:j()});R(this,"listeners",new Set);R(this,"subscribe",n=>(this.listeners.add(n),()=>{this.listeners.delete(n)}));R(this,"getState",()=>this.state);R(this,"handleStorage",n=>{if(n.key!==null&&n.key!==I&&n.key!==b&&n.key!==q)return;const s=B(),t=M(),o=j(),a=this.state.sessionDisplaySortMode===s,l=this.state.showSystemFiles===t,c=k(this.state.notificationPreferences,o);a&&l&&c||(this.state={sessionDisplaySortMode:s,showSystemFiles:t,notificationPreferences:o},this.emit())});typeof window<"u"&&window.addEventListener("storage",this.handleStorage)}setSessionDisplaySortMode(n){D()&&(n==="createdAt"?window.localStorage.removeItem(I):window.localStorage.setItem(I,n)),this.state.sessionDisplaySortMode!==n&&(this.state={...this.state,sessionDisplaySortMode:n},this.emit())}setShowSystemFiles(n){D()&&(n?window.localStorage.setItem(b,"1"):window.localStorage.removeItem(b)),this.state.showSystemFiles!==n&&(this.state={...this.state,showSystemFiles:n},this.emit())}setNotificationPreferences(n){const s={...this.state.notificationPreferences,...n};k(this.state.notificationPreferences,s)||(ie(s),this.state={...this.state,notificationPreferences:s},this.emit())}emit(){for(const n of this.listeners)n()}}const F=new ae;function On(e){return w.useSyncExternalStore(F.subscribe,()=>e(F.getState()))}function Nn({heading:e,description:n,actions:s,tone:t="default",className:o,children:a}){return i.jsxs("section",{className:y("modal-section",o),"data-tone":t,children:[e||n||s?i.jsxs("div",{className:"modal-section-header",children:[i.jsxs("div",{className:"modal-section-copy",children:[e?i.jsx("strong",{className:"modal-section-heading",children:e}):null,n?i.jsx("p",{className:"modal-section-description",children:n}):null]}),s?i.jsx("div",{className:"modal-section-actions",children:s}):null]}):null,a]})}function In({label:e,description:n,className:s,htmlFor:t,children:o}){return i.jsxs("div",{className:y("workbench-modal-field","modal-field",s),children:[i.jsxs("div",{className:"modal-field-copy",children:[t?i.jsx("label",{className:"modal-field-label",htmlFor:t,children:e}):i.jsx("span",{className:"modal-field-label",children:e}),n?i.jsx("span",{className:"modal-field-description",children:n}):null]}),o]})}function bn({align:e="end",stack:n=!1,className:s,children:t,...o}){return i.jsx("div",{className:y("workbench-modal-actions","modal-actions",s),"data-align":e,"data-stack":n?"true":void 0,...o,children:t})}function En({compact:e=!1,className:n,children:s,...t}){return i.jsx("div",{className:y("modal-list",n),"data-compact":e?"true":void 0,...t,children:s})}function Ln(e){const{as:n="div",label:s,description:t,leading:o,trailing:a,tone:l="default",selected:c=!1,className:P,children:O,...S}=e,f={className:y("modal-list-item",P),"data-tone":l!=="default"?l:void 0,"data-selected":c?"true":void 0,"data-interactive":n==="button"?"true":void 0},A=i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"modal-list-item-main",children:[o?i.jsx("div",{className:"modal-list-item-leading",children:o}):null,i.jsxs("div",{className:"modal-list-item-copy",children:[s?i.jsx("span",{className:"modal-list-item-label",children:s}):null,t?i.jsx("span",{className:"modal-list-item-description",children:t}):null,O]})]}),a?i.jsx("div",{className:"modal-list-item-trailing",children:a}):null]});if(n==="button"){const u=S;return i.jsx("button",{type:u.type??"button",...u,...f,children:A})}return i.jsx("div",{...S,...f,children:A})}function Un({title:e,description:n,action:s,className:t,compact:o=!1}){return i.jsxs("div",{className:y("modal-empty-state",t),"data-compact":o?"true":void 0,children:[i.jsx("strong",{className:"modal-empty-state-title",children:e}),n?i.jsx("p",{className:"modal-empty-state-description",children:n}):null,s?i.jsx("div",{className:"modal-empty-state-action",children:s}):null]})}function qn({tone:e="default",className:n,children:s,...t}){return i.jsx("span",{className:y("modal-tag",n),"data-tone":e!=="default"?e:void 0,...t,children:s})}function y(...e){return e.filter(Boolean).join(" ")}function ue(){return _().haptics}const le="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAF+0lEQVRYha2XbXBUZxXHf+e5u4SkCZjg0NIWnQLJLgRF5UWnL75MP9gMjqPT2eyC0qlMiYxOUAR206LOyhiSTVscp52O0xamWgu7WTp0qLUz6kht6Qed1L7M5GUTsAoDTRSIJJos2b33+GFfWMJuNqmcT/c595z/+d3nOc+9zxXKWE9Li7tm0fjyqmT6H0t/Fp8sFz9XM+UCauouH8Rx+ifmWWdP7Q0sLRbT98g3lySC/mcSQd+GGwrQt2vzx1G2ZEa6KJ3S1mJxlpOKIDyEmEM3FGCk5vw5YCw3FmFbb9hXfV2gcm/26vINBfhS+LU0qgcKXB9xT1hbr6kdDhtgcYaDxHSNwVBg92Ao0DMY8n97zgAAZnK8U2AoX1D0++rzWfkC44k6wAVghP7C3EQo8Iiijyq61oEDiV2bPjojwKk234pEsPnh/lDgzpyv/olXrwi6qyDsjsQy2ZQXmJdefPWWvp0v3uZ/CLQ9NxZINpxJj84IYDvmOUT2G/T1DD0CUB/pflnhd1eT5Mcnwl90Adi23JzPl9TbAEN7fF9AeapQW5AOicftGQFEOJ+9tEDbB9v8x99r21wLYBlnJ5AGUKhfklz8QEbY3J71nVnZceziUPAbtzvGxAB3wdPH6yPRx6cXvw4gbbm/B5zIO5SvVKjdMxAMrKvviPcpHMyLqvyoN+ybh7AUwIi+M9TaVOGI/SJwc4Fsf6rS2SqgxQBkukPDYTM40RdCZB/Z5gKmEGmzjStq2alBoDqbvF2hEWgF9oEuAvlugdx/Deaz9ZEjvcWKFwXIWaLNv14cDqmwugDvFRVOi8qOrOMdhT6BzQhvoNxzjbjItxo6o8+VqjEjAMBQa1OFXbXwh4KGuLqmDleXToHzwG1FpLs9kah/uvf98IPz08nkSuZbp+vDL4zNCJAHaQt82lH9JfCJ2cQrTFjq8hiZGrfVtQGcDQhrFNYAywELuFw15SwRgN6dvrrahcnkreGXJ0pCtDZVOFULwsCerEBJExhVGAY8FH/Z2cBvPJHY1ySx13cbaXMaqACSwCVRLqlhVNBRVTOm4lxCOSdqPkB0FdA2m5kosGGEHpC3UP2z6uRJb9fx8SwsJEL+nwBNwEKgWqBSoXaORQqtH+VNhDdErJMNnYf/ViqwbBNO3lRbVZFSS9yyIG1jucRuVuGnM6TZZL4d/wS9KEgawIH/gF5EzAWBvzecto9KPG7PqgkBTu0NLHVs7VBlcxnwS8ALgtyp6Kco3S9/OF850lQWYCD41RpMZUiUH5BZmgkRDqmyVaCqeJYeS1dqwJq4UoG56S5w7hb4PMp6YH426LJR1+qSAOrzWYPLZCvIPuAWAIHXxGGXY3geWAV6DOTrJRR+r5q8P9dskNtJ1etBVl4R19FPdh4eLQowEPR5RKxfgebOeGMqGvLMX/V0YrK/W+B+4ATCYZRnEJ5E+Q5gFM4AFwQ+I8hbLks2Ltt/ZKTUg163Rwfamrcj5q/54spvLZes9nZ2/yIx0b8jW/wCLmeLOLoCAEdeAjmYnaWPGXga9Jiia1O28+bAbt8dswJQEFF5IrO2chGVBzxdsY0r2qNnBx5uvkuELkAFedDTHj+nIl4AIzJsjL2XTAOisB+XtqryKLBcLHNyKLSpsSyAgKrKJoRtbksaPV3R5yFz7BaHOOBGOdAQib6SRV4L4KQZqe+I/wvYmZWqE1ue8nbFggjbgDoH/VOxY3vZXdDT0uKuqR37I+jdIH9JV9r3NIbjU717fLe4jPkASDVEYhW5730i2PwqIvdlZkK3eCPdv06E/GuAbmCBJxJbUnIGill13b8fyxRnRG070BiOTwG4MeuyszBSeNiw3KZFYDTzdPLzU7u3LPZEYu+qTq5Tlev+K2YESAQD94rKjqzgl72Pxd/P3VNLsgAyXJizoj161kG3Z4d1aZP6HIC36/i4tyt6dE4AasQNDIhxNnoisXevvZndJcLw9DxvpLsb5XGE9yzD2ZlqzPpVPN0SIf854FaUZz1dsW0fVqdsD5Q05Qhgg7z+oTX+Xyv2pzNX+x+eTlGviPgh3AAAAABJRU5ErkJggg==",Q="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAbGSURBVHgBzZo/bBtVHMd/ZzuJA0gYCYlsOFO7xRFDy1R3olucqd0SJtiSjiCknBckpjZjBxRn7BR3owOqs5Wp7tZKoDgSQysh4UqUOCG2eZ/3/Oznv/fObqJ+pfPZd+/ufn++vz/vnQN5FwjbGZFGQSRYUb+yIu2c2tSxIOOMqpktqKpzz9X3ioSLNZkRgUwLhA4aW9KWvPqVl6mgldmVGZSJr0BX8Pb2gIVnRUltxbiKxFOgeLJzAYL3I5BQdhaL/sN9EJ5k1dADw+1LQU1tN328kYgaIMWzDSX4s0sUHmSVwZ5JeFqIGjhZgeKpokyzdKGUGQuyWOtA03YCxlNIC98K5X3AhLgYrYB2ndLeE5l0IFvXklK4mpRsxvyuvmqrrSX71aZUjlsyM4LkpuzM7w8dHhqoAxbO+9Fm63pSwhspLTSo1dt6n830bl1SStx9fK6/Z9LmWL3B1hZ/BHUl1+pgYI9S4Eh0EEVjJ5/SwiPI7m9Nuf+02SfUZi4pO+o8ynDcKmlRqRkPlZ43xQ+q8IXpVfdIsu88vJd2ZOSD/OcJKRXmtMW//PlMyi9a0jjvH5NZCDStEDydCjSlfvm9pa/hd24poc+zf/zH8PUjsCT57wOp/FjpqtQ9pakjR+KJo60Fbdnl3dMubSw4vrc2J/msSXLlF4ZCg+M4zzjGEzM39888aAWVFpYlZN+fRnfEE1iMh8JtVygsDWWefTOvhYMiCLX+8L8h4QHnVx+cas/klgLZvpb0eDrp9d/trjr609P6brbhgesPDXXA5kpS7t0ywYwVi4fERD8noJ1WfIDzBDYeRRw8GscL1gP5iCv0g7FsqAIX4UH9pHeegEb44uG5EuKsT3iuPbg9J08252VPxQ3CoowFGYlgRhEMEY2eFzp3CbbEQ3j28BnXjwI0CSvnXQu6lMJrnOd67qOV6fAf2HuuLPn2l4kbRgGT9yf2OU825o11lXDw+bgenb8LV5JdjwE8s/rAxMPXj0xMkGbxBkpWX8epCRp5WvuERNAHl9qADQ+j8xz0QuGDOz3rIizXW8/wHa7bzISSKAveNCQGGoVElPU3coaTcDQKhmoL3QxEkLMna2FplzKAOCFLGf6b4x+nJQbauURnHjsWWJQg8+1nsChCsZGh2LuUwTvb11J94zfVeVtPGOOej4CuNNlJI2xa9BUeQQaD3FKG83iAdItHClcSQ4rzLJvRohGsRCowqoexyCxKbNiUqVPrnf5MhBL0VKRTv6IWZCJnZJR4bujm7eprY+GD2/M6g/hZyypgKENGspThHha2fqxdjZ4sUg8iRz16aYLXBrN5SLPLa5tBMrGCT3T7wD0GgYcM1XwU0IWsXZ80wPY7WMpVguM2g0ABvMDmZhkXZox4w3dswvQV44FFSIe4vqT46rrbzSAEru1pXF6j1L2vTND6Us10p15Zr5Ywq2OTQRwUO0UMyiCM27PYDDKYLomRoy2VNq+n9HGfbGbvyzM9FWgd+4zMfWY4iaV1v6+assHCZNOl7XcKnUC0bUQ9osrq3qnTevgUTtZYUz4ecGEDDwtjaTYER8jsx0YAO5Gxc2EfyyP83lqq27b4Fc6gqhRolEXSe1FDrRBUZioslrYpkD3WthzHSyg0WNCIkVFeoNWw3S7UsQsAHqiobvQTgrgSNbL80gizdmU4EyEswsNzPMQxV3hqiO1oR3kDoyD87tOm57QStKusUNiUcigRXSlZQRchZW2qpc0Sdg5AbQDuw3XboDIQcwGAUm7uh3LWEPvPx88zRiNgWd5OaBr3o+oBrmeaCJhdDeZ7BB83kbETdjZ3bmzryii6eaDCR8c0PzUk/wOdTX7SFU//bEmg5EYoUiOCvv5H5NXbnuDffpHUGYoxLJN892uvarsgXXIPa/14SJTU+pBepXOWVf5W88yFI58VOWqBW9DAYNM3KQMRE0x4gO2JYmLZrtD1ItLTC3ooK2rKasdvzAIVwNp2PfTqpwmdWZY+CswMKzDeYZp579acNgDjodSLv+IK31JvcT4o218jlhYbM78LcJcUR8EG8xSWrynLL7sHZl7cnQQUoYKvLJn0eVwnHTenCVgxSSbwWNwF4cmm+owsbpeLxLqEC+WhoyPHhosl4Y3hewN4Pyw8mNzfhiehxFgzvRgg/IfhuLPRDXr4ljfwe5f/nkxz/m6HDWMR4zWrPBHPFx+zQ7/BX/d5zRrvRfeFU0pbfVcJHvpeMcVfDfAGby8TG/LO0BFc0vftiwtfzPBnD02rvFnZnrrwVUR3wvEFt5heARddZVDE/uXGjRdt4bru4UWODcfT5WmFdvE/Jeqz44iuBr4AAAAASUVORK5CYII=",ce="/assets/gemini-D4G1NbrE.png",de="/assets/kimi-BWNNSh7e.png",fe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAABzUlEQVR4AeycQQrCQBAEF1+g6J/0o5LPCXmCnnNx0E2nNqGEPciw024VffV0PZ/fHo7BqflBCSgAxd+aAhQAE4DjbYACYAJwvA1QAEwAjrcBCgAIDBRpA2AZClAATACOtwEKgAnA8TZAATABOD7egNc8tz2ftJ+4gPQD9r5fAbDBDQXALx00XgGwGAUoACYAx9sABcAE4HgboACYABxvAxSwJHC7XFryLNP4bzYg7KBar4CKUHiugDDgar0CKkLhuQLCgKv1CqgIhecKCAOu1iugIhSeKyAMuFqvgIpQeK6AMOBq/XAC7o9H6z5fdlRAtp4PJ2BrAHSeAmADClAATACOtwEKgAnA8TZAATABON4GKAAmAMev2AD4JTuNVwAsTgEKgAnA8TZAATABON4GKAAmAMfbAAXABOB4G9ApoPe6AnoJdt5XQCfA3uvDCXhOU0ueXmBr3x9OwNoPHH2fAmBDClAATACOtwEKgAnA8TZAAX8QONAVGwDLVIACYAJwfLwByf/+2WJ32k9cQPoBe9+vANigAhQAE4DjbYACYAJw/A8NgH/pQeMVAItVgAJgAnC8DVAATACOtwEKgAnA8TZAATABON4GFALS4w8AAAD//x7wkLQAAAAGSURBVAMAKj5LkLSa6SQAAAAASUVORK5CYII=",pe=new Set(["low","medium","high","xhigh"]),me=["claude-code","codex","opencode","gemini","kimi"],ge=["codex","claude-code","opencode","gemini","kimi"],G={"claude-code":{displayNameKey:"conversation.providerClaude",fullDisplayNameKey:"shell.providerClaudeCode",draftTitleKey:"conversation.draftTitleClaude",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:le,defaultRunInputMode:"streaming_guidance",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!0,supportsRunSteeringByDefault:!0,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},codex:{displayNameKey:"conversation.providerCodex",draftTitleKey:"conversation.draftTitleCodex",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:Q,defaultRunInputMode:"streaming_guidance",reasoningLevelPersists:!0,defaultReasoningLevel:null,supportsSlashMenuByDefault:!1,supportsRunSteeringByDefault:!0,supportsQueueWhileRunningByDefault:!0,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!0},opencode:{displayNameKey:"conversation.providerOpenCode",draftTitleKey:"conversation.draftTitleOpenCode",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:fe,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},gemini:{displayNameKey:"conversation.providerGemini",draftTitleKey:"conversation.draftTitleGemini",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:ce,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:null,supportsInterrupt:!0,supportsAttachments:!1,supportsPermissionPrompt:!1,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},kimi:{displayNameKey:"conversation.providerKimi",draftTitleKey:"conversation.draftTitleKimi",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:de,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:null,supportsInterrupt:!0,supportsAttachments:!1,supportsPermissionPrompt:!1,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!0}},Se=Array.from(new Set(Object.values(G).map(e=>e.icon)));let J=!1;function Ae(e){return me.includes(e)}function d(e){return!e||!Ae(e)?null:G[e]}function he(e){return[{id:"provider-default",name:g(e),usesProviderDefault:!0}]}function ye(e){const n=d(e);return he((n==null?void 0:n.defaultModelLabelKey)??"conversation.modelUseCliDefault")}function xn(e){return!!(e&&d(e))}function Tn(e){const n=d(e);return g((n==null?void 0:n.draftTitleKey)??"conversation.draftTitleCodex")}function ve(e,n="compact"){const s=d(e);return s?n==="full"&&s.fullDisplayNameKey?g(s.fullDisplayNameKey):g(s.displayNameKey):(e==null?void 0:e.trim())||g("conversation.providerCodex")}function Re(e){const n=d(e);return(n==null?void 0:n.icon)??Q}function W(){J||typeof window>"u"||(J=!0,Se.forEach(e=>{const n=new window.Image;n.decoding="async",n.src=e,typeof n.decode=="function"&&n.decode().catch(()=>{})}))}function Bn(e){const n=d(e);return{provider:e,canStartSession:!0,canResumeSession:!0,canSendMessage:!0,inRunInputMode:(n==null?void 0:n.defaultRunInputMode)??"none",supportsSubagents:!1,supportsInterrupt:(n==null?void 0:n.supportsInterrupt)??!1,supportsStructuredToolCalls:!0,supportsTokenUsage:!0,supportsAttachments:(n==null?void 0:n.supportsAttachments)??!0,supportsPermissionPrompt:(n==null?void 0:n.supportsPermissionPrompt)??!0,supportsCheckpoint:!1,supportsSessionDelete:(n==null?void 0:n.supportsSessionDeleteByDefault)??!1,modelOptions:ye(e),defaultReasoningLevel:n==null?void 0:n.defaultReasoningLevel,supportsRunSteering:n==null?void 0:n.supportsRunSteeringByDefault,supportsQueueWhileRunning:n==null?void 0:n.supportsQueueWhileRunningByDefault,limitations:[]}}function Mn(e){return(e==null?void 0:e.provider)??"claude-code"}function jn(e){var s;if((e==null?void 0:e.supportsSlashMenu)!==void 0)return e.supportsSlashMenu;const n=(e==null?void 0:e.provider)??null;return((s=d(n))==null?void 0:s.supportsSlashMenuByDefault)??!1}function kn(e){var n;return(e==null?void 0:e.supportsReasoningSelector)!==void 0?e.supportsReasoningSelector:!!((n=e==null?void 0:e.modelOptions)!=null&&n.some(s=>{var t;return((t=s.supportedReasoningEfforts)==null?void 0:t.some(o=>pe.has(o)))??!1}))}function Fn(e,n){var a;if((e==null?void 0:e.supportsQueueWhileRunning)!==void 0)return e.supportsQueueWhileRunning;const s=(e==null?void 0:e.provider)??null,t=(a=d(s))==null?void 0:a.supportsQueueWhileRunningByDefault;if(t!==void 0)return t;const o=(e==null?void 0:e.inRunInputMode)??"none";return o==="queued_guidance"||o==="none"||o==="streaming_guidance"&&n===!1}function Jn(e){var s;if((e==null?void 0:e.supportsRunSteering)!==void 0)return e.supportsRunSteering;const n=(e==null?void 0:e.provider)??null;return((s=d(n))==null?void 0:s.supportsRunSteeringByDefault)??(e==null?void 0:e.inRunInputMode)==="streaming_guidance"}function Kn(e){const n=d(e);return(n==null?void 0:n.reasoningLevelPersists)??!1}function Qn(e,n){var t;return((t=d(n??null))==null?void 0:t.foldRulesMessagesByDefault)??!1}typeof window<"u"&&W();const x=new Map;function Gn(){x.clear()}function Wn({disabled:e=!1,workspaceId:n=null,pendingProvider:s=null,selectedProvider:t=null,providers:o=ge,className:a,disabledReasons:l,statusHintByProvider:c,onSelect:P}){const O=ue(),S=!!n,[v,f]=w.useState(()=>K(o,n)),A=o.map(u=>({provider:u}));return w.useEffect(()=>{W()},[]),w.useEffect(()=>{if(!n){f({});return}const u=K(o,n);f(u);const h=o.filter(m=>!u[m]);if(h.length===0)return;let p=!1;return oe(h,n).then(m=>{we(n,m),p||f(N=>({...N,...m}))}),()=>{p=!0}},[o,n]),i.jsx("div",{className:`session-provider-grid${a?` ${a}`:""}`,children:A.map(u=>{const h=ve(u.provider,"full"),p=s===u.provider,m=t===u.provider,N=!!v[u.provider],E=Ce(v[u.provider]??null),L=(l==null?void 0:l[u.provider])??E,T=p?g("shell.startingSession"):L||((c==null?void 0:c[u.provider])??(S&&!N&&!p?g("shell.providerChecking"):null));return i.jsxs("button",{type:"button",className:"session-provider-card","data-provider":u.provider,"data-pending":p?"true":"false","data-selected":m?"true":"false","aria-label":h,disabled:e||!!L,onClick:()=>{O.trigger("action"),P(u.provider)},children:[i.jsx("span",{className:"session-provider-card-icon","aria-hidden":"true",children:i.jsx("img",{src:Re(u.provider),alt:"",loading:"eager",decoding:"async"})}),i.jsxs("span",{className:"session-provider-card-copy",children:[i.jsx("strong",{children:h}),T?i.jsx("span",{className:"session-provider-card-status",children:T}):null]})]},u.provider)})})}function Ce(e){return!e||e.canStartSession!==!1?null:e.limitations[0]??g("conversation.capabilityDenied")}function K(e,n){const s=(n==null?void 0:n.trim())??"";if(!s)return{};const t=[];for(const o of e){const a=x.get(z(s,o));a&&t.push([o,a])}return Object.fromEntries(t)}function we(e,n){const s=e.trim();if(s)for(const[t,o]of Object.entries(n))o&&x.set(z(s,t),o)}function z(e,n){return`${e}::${n}`}function zn(){const e=X(s=>s),n=H(s=>s);return De(e,n)}function De(e,n){var l;const s=$(e);if(!s)return null;const t=!!((l=s.relayTunnel)!=null&&l.enabled),a=!(e.platform==="web"&&t)&&n.activeHostId===s.id&&n.candidateProbePhase==="ready"?Pe(n):null;if(a){const c=Oe(a.kind);return{kind:c,url:a.url,endpointId:a.endpointId,autoDirect:t&&c!=="relay",probeInProgress:!1}}return{kind:Ne(s),url:s.baseUrl,endpointId:null,autoDirect:!1,probeInProgress:t&&n.activeHostId===s.id&&n.candidateProbePhase==="probing"}}function Vn(e){switch(e){case"relay":return"common.connectionRouteRelay";case"lan":return"common.connectionRouteLan";case"loopback":return"common.connectionRouteLoopback";case"tailscale":return"common.connectionRouteTailscale";default:return"common.connectionRouteDirect"}}function Pe(e){const n=e.preferredDirectCandidateEndpointId??e.preferredCandidateEndpointId;return n?e.candidateEndpoints.find(s=>s.endpointId===n&&s.status==="verified")??null:null}function Oe(e){return e==="custom"?"direct":e}function Ne(e){var n;if((n=e.relayTunnel)!=null&&n.enabled&&Ie(e.baseUrl,e.relayTunnel.tunnelDomain))return"relay";try{const s=new URL(e.baseUrl).hostname.toLowerCase();if(be(s))return"loopback";if(Ee(s))return"tailscale";if(Le(s))return"lan"}catch{return"direct"}return e.kind==="local"?"loopback":e.kind==="lan"?"lan":"direct"}function Ie(e,n){try{return new URL(e).hostname.toLowerCase()===n.trim().toLowerCase()}catch{return!1}}function be(e){return e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="[::1]"}function Ee(e){if(e.endsWith(".ts.net"))return!0;const n=e.split(".").map(o=>Number(o));if(n.length!==4||n.some(o=>Number.isNaN(o)))return!1;const[s,t]=n;return s===100&&t>=64&&t<=127}function Le(e){const n=e.split(".").map(o=>Number(o));if(n.length!==4||n.some(o=>Number.isNaN(o)))return!1;const[s,t]=n;return s===10||s===192&&t===168||s===172&&t>=16&&t<=31}function Zn({open:e,title:n,description:s,height:t="auto",kind:o="form",dismissible:a=!0,closeOnBackdrop:l=!0,showHandle:c=!1,showCancelButton:P=!0,cancelLabel:O,className:S,cardClassName:v,bodyClassName:f,footer:A,onClose:u,children:h}){const p=w.useId(),m=w.useId(),N=a&&l;return!e||typeof document>"u"?null:ee.createPortal(i.jsx("div",{className:"ios-action-sheet-overlay mobile-sheet-overlay",role:"presentation",onClick:()=>{N&&u()},children:i.jsxs("div",{className:`mobile-workspace-home-sheet mobile-sheet${S?` ${S}`:""}`,"data-height":t,"data-kind":o,role:"dialog","aria-modal":"true","aria-labelledby":p,"aria-describedby":s?m:void 0,onClick:E=>E.stopPropagation(),children:[i.jsxs("div",{className:`mobile-workspace-home-sheet-card mobile-sheet-card${v?` ${v}`:""}`,children:[c?i.jsx("div",{className:"mobile-sheet-handle","aria-hidden":"true"}):null,i.jsx("div",{className:"mobile-workspace-home-sheet-header mobile-sheet-header",children:i.jsxs("div",{className:"mobile-sheet-title-wrap",children:[i.jsx("strong",{id:p,children:n}),s?i.jsx("p",{id:m,children:s}):null]})}),i.jsx("div",{className:f?`mobile-sheet-body ${f}`:"mobile-sheet-body",children:h}),A?i.jsx("div",{className:"mobile-sheet-footer",children:A}):null]}),P?i.jsx("button",{type:"button",className:"ios-action-sheet-cancel mobile-sheet-cancel",disabled:!a,onClick:()=>{a&&u()},children:O??g("common.cancel")}):null]})}),document.body)}export{mn as $,Cn as A,Dn as B,Pn as C,Ze as D,pn as E,wn as F,ln as G,cn as H,yn as I,gn as J,xn as K,nn as L,Zn as M,Jn as N,$e as O,tn as P,Tn as Q,Un as R,Wn as S,Mn as T,kn as U,jn as V,Fn as W,fn as X,Kn as Y,dn as Z,Qn as _,ve as a,Re as a0,Ge as a1,Me as a2,Be as a3,We as a4,sn as a5,_e as a6,en as a7,rn as a8,an as a9,un as aa,Xe as ab,Gn as ac,Qe as ad,Ke as ae,He as af,Ye as ag,on as ah,F as ai,Ve as aj,ke as b,Fe as c,Je as d,ue as e,Nn as f,Te as g,In as h,En as i,Ln as j,qn as k,zn as l,Vn as m,Bn as n,te as o,oe as p,ge as q,je as r,Sn as s,hn as t,On as u,An as v,ze as w,bn as x,vn as y,Rn as z};
|
package/dist/public/assets/{MobileTopHeaderFrame-BWorAJ1C.js → MobileTopHeaderFrame-Bwv8Ovm_.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as i}from"./index-
|
|
1
|
+
import{j as i}from"./index-BZLcEHW3.js";function m({children:e,className:o,frameRef:r,...a}){return i.jsx("div",{ref:r,className:["mobile-top-header-frame",o].filter(Boolean).join(" "),...a,children:e})}export{m as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as j,f as B,h as $,j as t,t as l}from"./index-BZLcEHW3.js";import{e as K,i as P,j as F,k as S,M as G}from"./MobileSheet-Ckug8hTb.js";import{aN as q,m as z,aO as D,aj as X,aP as J}from"./WorkbenchLayout-DGm8Tc5M.js";import{u as Q,f as V}from"./App-BZvapsi8.js";import{M as Y}from"./MobileTopHeaderFrame-Bwv8Ovm_.js";function Z(s){return s.flatMap(o=>[{workspace:o.workspace,label:o.workspace.name,subtitle:o.workspace.path,depth:0,kind:"workspace",meta:null},...v(o.childWorktrees??[])])}function we(s,o){const a=o==null?void 0:o.trim();if(!a)return null;for(const i of s){if(i.workspace.id===a)return{workspace:i.workspace,sessions:i.sessions,childWorktrees:i.childWorktrees??[],meta:null};const n=N(i.childWorktrees??[],a);if(n)return n}return null}function v(s){return s.flatMap(o=>[{workspace:o.workspace,label:o.meta.displayName||o.workspace.name,subtitle:o.workspace.path,depth:o.meta.depth,kind:"worktree",meta:o.meta},...v(o.children)])}function N(s,o){for(const a of s){if(a.workspace.id===o)return{workspace:a.workspace,sessions:a.sessions,childWorktrees:a.children,meta:a.meta};const i=N(a.children,o);if(i)return i}return null}const W=10080*60*1e3;function ee(s,o){return se(s.hosts,s.activeHostId).flatMap(a=>{const i=a.id===s.activeHostId?o:oe(a.id);return[{kind:"host",host:a,workspaceCount:i.length},...i.map(n=>({kind:"workspace",host:a,workspace:n.workspace,option:n}))]})}function se(s,o){return[...s].sort((a,i)=>{if(a.id===o)return-1;if(i.id===o)return 1;const n=a.lastConnectedAt??a.updatedAt??a.createdAt;return(i.lastConnectedAt??i.updatedAt??i.createdAt).localeCompare(n)})}function oe(s){const o=q(W,s);return o?Z(z(o)):[]}function ke({currentWorkspace:s,workspaces:o,workspaceOptions:a,onSelectWorkspace:i,className:n,containerRef:w,heading:H,content:C,sheetContent:k,triggerLabel:M,triggerAriaLabel:L,onTriggerClick:c,trailing:A,gestureHandlers:y}){const[u,d]=j.useState(!1),[m,f]=j.useState(null),b=K(),I=Q(),{showToast:T}=V(),r=B(e=>e),h=$(r),E=a??o.map(e=>({workspace:{...e,repoRoot:e.path},label:e.name,subtitle:e.path,depth:0,kind:"workspace",meta:null})),O=ee(r,E),p=(s==null?void 0:s.name)??(h==null?void 0:h.name)??null,x=(s==null?void 0:s.path)??(h==null?void 0:h.baseUrl)??null;if(!p)return null;async function R(e){const U=e.kind==="host"?`host:${e.host.id}`:`workspace:${e.host.id}:${e.workspace.id}`;if(!m){f(U);try{e.host.id!==r.activeHostId&&(b.trigger("selection"),await D.switchHost(e.host.id)),e.kind==="host"?I(X()):(e.workspace.id!==(s==null?void 0:s.id)||e.host.id!==r.activeHostId)&&await(i==null?void 0:i(e.workspace.id)),d(!1)}catch(_){T({title:te(_,e.host.name),tone:"error"})}finally{f(null)}}}return t.jsxs(t.Fragment,{children:[t.jsx(Y,{className:n,frameRef:w,...y,children:t.jsxs("section",{className:"mobile-workspace-home-header",children:[t.jsx("h1",{className:"mobile-workspace-switcher-heading",children:H??p}),t.jsxs("div",{className:"mobile-workspace-home-toolbar-top",children:[t.jsxs("button",{type:"button",className:"mobile-workspace-home-switcher","aria-label":L??l("shell.workspaceHomeSwitcherLabel"),onClick:()=>{if(c){c();return}b.trigger("selection"),d(!0)},children:[t.jsx("span",{className:"mobile-workspace-home-switcher-label",children:M??p}),t.jsx(ne,{})]}),t.jsx("div",{className:"mobile-workspace-home-toolbar-actions",children:A})]}),x?t.jsx("p",{className:"mobile-workspace-home-path",children:x}):null,C]})}),u&&!c?t.jsxs(ie,{open:u,title:l("shell.hostWorkspaceSwitcherTitle"),onClose:()=>d(!1),children:[t.jsx(P,{className:"mobile-workspace-home-group mobile-workspace-home-sheet-group",children:O.map(e=>t.jsx(F,{as:"button",className:"mobile-workspace-home-row mobile-workspace-home-sheet-row","data-host-entry-kind":e.kind,"data-host-active":e.host.id===r.activeHostId,"data-worktree-kind":e.kind==="workspace"?e.option.kind:void 0,"data-worktree-depth":e.kind==="workspace"?e.option.depth+1:0,disabled:m!==null,selected:e.kind==="host"&&e.host.id===r.activeHostId||e.kind==="workspace"&&e.workspace.id===(s==null?void 0:s.id)&&e.host.id===r.activeHostId,trailing:t.jsx("span",{className:"mobile-workspace-home-row-trailing",children:e.kind==="host"&&e.host.id===r.activeHostId?t.jsx(g,{}):e.kind==="workspace"&&e.workspace.id===(s==null?void 0:s.id)&&e.host.id===r.activeHostId?t.jsx(g,{}):t.jsx(re,{})}),style:{"--mobile-workspace-tree-depth":String(e.kind==="host"?0:e.option.depth+1)},onClick:()=>{R(e)},label:t.jsxs("span",{className:e.kind==="host"?"mobile-workspace-home-sheet-label mobile-host-workspace-switcher-host-label":"mobile-workspace-home-sheet-label",children:[e.kind==="host"?t.jsx(S,{className:"mobile-host-workspace-switcher-host-badge",children:l("shell.hostSwitcherNodeBadge")}):null,e.kind==="workspace"&&e.option.kind==="worktree"?t.jsx(S,{className:"mobile-workspace-home-worktree-badge",children:l("shell.mobileWorktreeBadge")}):null,t.jsx("span",{className:"mobile-workspace-home-sheet-label-text",children:e.kind==="host"?e.host.name:e.option.label})]}),description:t.jsx("span",{className:"mobile-workspace-home-sheet-description",children:e.kind==="host"?ae(e.host,e.workspaceCount):e.option.subtitle})},e.kind==="host"?`host-${e.host.id}`:`workspace-${e.host.id}-${e.workspace.id}`))}),k?k(()=>d(!1)):null]}):null]})}function te(s,o){return s instanceof J?s.code==="HOST_UNREACHABLE"?l("shell.hostSwitchUnreachable",{name:o}):l("shell.hostSwitchMissing"):l("shell.hostSwitchFailed")}function ae(s,o){return s?s.lastUsername?l("shell.hostSwitcherWorkspaceCountWithUser",{username:s.lastUsername,count:o}):o>0?l("shell.hostSwitcherWorkspaceCount",{count:o}):s.baseUrl:""}function ie({open:s,title:o,onClose:a,children:i}){return t.jsx(G,{open:s,title:o,kind:"picker",height:"three-quarter",className:"mobile-host-workspace-switcher-sheet",bodyClassName:"mobile-workspace-home-form",showHandle:!0,onClose:a,children:i})}function ne(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function re(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function g(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}export{ke as M,we as a,Z as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as m,b as d,e as g,j as n,t as i}from"./index-BZLcEHW3.js";import{u as p,c as f,d as y}from"./App-BZvapsi8.js";import{b as E}from"./relay-entry-C5_Iay0I.js";function I(){const r=p(),{tunnelDomain:t}=f(),[e]=y(),s=m(),[a,c]=d.useState(null);return d.useEffect(()=>{var u;const l=((u=e.get("controlBaseUrl"))==null?void 0:u.trim())??"";if(!t||!l){c(s("auth.relayEntryInvalid"));return}let o=!1;const h=x(e.get("returnTo"));return g.update(E(g.getState(),{tunnelDomain:t,controlBaseUrl:l,bindingId:e.get("bindingId"),hostFingerprint:e.get("hostFingerprint")})).then(()=>{o||r(`/login?returnTo=${encodeURIComponent(h)}`,{replace:!0})}).catch(()=>{o||c(s("auth.relayEntryInvalid"))}),()=>{o=!0}},[r,e,s,t]),n.jsxs("section",{children:[n.jsx("h1",{children:i("auth.relayEntryTitle")}),n.jsx("p",{children:i("auth.relayEntryDescription")}),a?n.jsx("p",{children:a}):null,a?null:n.jsx("p",{children:i("common.loading")})]})}function x(r){const t=r==null?void 0:r.trim();return!t||!t.startsWith("/")?"/":t}export{I as RelayConnectEntryPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as n,n as U,j as r,t as s,e as N}from"./index-BZLcEHW3.js";import{r as E,b as k}from"./relay-entry-C5_Iay0I.js";import{a as h,s as O,t as P,v as w}from"./App-BZvapsi8.js";import{W as T}from"./WorkbenchModal-0tPIIhca.js";function z({isOpen:t,onClose:u,onSave:c,theme:$="dark"}){const d=h(e=>e.baseUrl),B=h(e=>e.options),p=h(e=>e.presetOptions),f=P(),[i,o]=n.useState(d),[g,l]=n.useState(null),[v,m]=n.useState(!1),a=n.useMemo(()=>{try{return U(i)}catch{return null}},[i]),x=O(a??i,B),S=p.find(e=>e.value===x)??null,b="server-settings-preset",j="server-settings-address";if(n.useEffect(()=>{t&&(o(d),l(null),m(!1))},[t,d]),!t)return null;async function I(){if(!a){l(s("auth.serverInvalid"));return}m(!0);try{const e=await E(a);e?await N.update(k(N.getState(),e)):w.setBaseUrl(a),c==null||c(a),u()}catch(e){l(e instanceof Error&&e.message.trim()?e.message:s("auth.serverInvalid"))}finally{m(!1)}}function C(){a&&o(a)}return r.jsx(T,{open:t,title:s("auth.serverSettingsTitle"),description:s("auth.serverHint"),className:"server-settings-modal-card",onClose:u,children:r.jsxs("form",{className:"server-settings-modal-form",onSubmit:e=>{e.preventDefault(),I()},children:[r.jsxs("label",{className:"workbench-modal-field",htmlFor:b,children:[r.jsx("span",{children:s("auth.serverPreset")}),r.jsxs("select",{id:b,"aria-label":s("auth.serverPreset"),value:x,onChange:e=>{const y=e.target.value;y!==f&&(o(y),l(null))},children:[p.map(e=>r.jsx("option",{value:e.value,children:V(e)},`${e.source}:${e.value}`)),r.jsx("option",{value:f,children:s("auth.serverCustomOption")})]})]}),S?r.jsx("div",{className:"server-settings-modal-tags","aria-live":"polite",children:S.source==="discovered"?r.jsx("span",{className:"server-settings-modal-tag","data-tone":"discovered",children:s("auth.serverDiscoveredTag")}):null}):null,r.jsxs("label",{className:"workbench-modal-field",htmlFor:j,children:[r.jsx("span",{children:s("auth.serverAddress")}),r.jsx("input",{id:j,"aria-label":s("auth.serverAddress"),value:i,placeholder:s("auth.serverPlaceholder"),disabled:v,onBlur:C,onChange:e=>{o(e.target.value),l(null)}})]}),g?r.jsx("p",{className:"server-settings-modal-status","data-tone":"error",children:g}):r.jsx("p",{className:"server-settings-modal-hint",children:s("auth.serverHint")}),r.jsxs("div",{className:"workbench-modal-actions",children:[r.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:s("common.cancel")}),r.jsx("button",{type:"submit",className:"primary-button",disabled:v,children:v?s("common.loading"):s("auth.saveServerSettings")})]})]})})}function V(t){return t.source==="discovered"?`${t.value} · ${s("auth.serverDiscoveredTag")}`:t.value}export{z as ServerSettingsModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as h,j as e,t as a}from"./index-BZLcEHW3.js";import{g as ve,u as ye}from"./App-BZvapsi8.js";import{e as je,a as be}from"./MobileSheet-Ckug8hTb.js";import{C as ue,D as Ne,E as ke,F as Me,G as Ee,H as xe,I as Ae,J as Ce,u as Pe,K as Ie,L as De,M as he,f as Le,N as ie,O as oe,P as Te,k as Re,b as Ge}from"./WorkbenchLayout-DGm8Tc5M.js";import{f as Oe,a as me,M as We}from"./MobileWorkspaceSwitcherHeader-RqWrBdn2.js";import{M as $e}from"./MobileCreateSessionSheet-BYfbvK8o.js";import{w as pe}from"./styles-DRVvx_kv.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./WorkbenchModal-0tPIIhca.js";import"./relay-entry-C5_Iay0I.js";import"./MobileTopHeaderFrame-Bwv8Ovm_.js";const Be=420,Fe=156;function He({entry:n,isFavorite:t,isActive:r=!1,depth:d=0,variant:l="default",workspaceTone:N="root",hasSubsessions:m=!1,subsessionsExpanded:k=!1,showActions:z=!0,onActivate:J,onToggleSubsessions:$,onToggleFavorite:ae,onArchive:B,onUnarchive:re,onRename:u}){var C;const[g,L]=h.useState(!1),[T,R]=h.useState(null),[w,F]=h.useState(null),M=h.useRef(null),G=h.useRef(!1),O=h.useRef(null),H=je(),{session:c,workspace:le}=n,V=c.title??c.sessionId,Z=be(c.provider),_=[Z,Ve(c.lastMessageAt??c.updatedAt??null),ue(c)].filter(Boolean).join(" · "),K=Ke(c),U=K?Ue(K):null,W=l==="mobile"?null:ue(c),X=W?Ne("session-list-activity-badge",c):null,E=l!=="mobile",q=E?ke(c.parallelGroup):null,Q=E?Me(c.parallelGroup):null,ce=E?Ee(c.parallelGroup):void 0;h.useEffect(()=>()=>{A()},[]),h.useLayoutEffect(()=>{if(!g||!w||typeof window>"u"){R(null);return}const i=()=>{var P,I;const f=Ae(w,{width:((P=O.current)==null?void 0:P.offsetWidth)??0,height:((I=O.current)==null?void 0:I.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:Fe});R({position:"fixed",left:`${Math.round(f.left)}px`,top:`${Math.round(f.top)}px`,width:`${Math.round(f.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(f.maxHeight)}px`,transformOrigin:f.transformOrigin})},S=f=>{var I;const P=f.target;P&&!((I=O.current)!=null&&I.contains(P))&&y()},ne=f=>{f.key==="Escape"&&y()};return i(),window.addEventListener("pointerdown",S),window.addEventListener("keydown",ne),window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),()=>{window.removeEventListener("pointerdown",S),window.removeEventListener("keydown",ne),window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}},[w,g]);function Y(i){F(i),L(!0)}function y(){L(!1),F(null)}function A(){M.current!==null&&(window.clearTimeout(M.current),M.current=null)}function ee(i){if(!z||i.pointerType==="mouse")return;const S={x:i.clientX,y:i.clientY};A(),M.current=window.setTimeout(()=>{G.current=!0,H.trigger("gesture"),Y(S)},Be)}function s(){A()}function o(){if(G.current){G.current=!1;return}H.trigger("selection"),J(c.sessionId)}const p=async()=>{const i=window.prompt(a("shell.renameModalDescription"),V);i&&(await u(c.sessionId,i.trim()),y())},v=async()=>{if(c.isArchived){await re(c.sessionId),y();return}await B(c.sessionId),y()},j=()=>{ae(c.sessionId),y()},x=i=>{if(i.key!=="ContextMenu"&&!(i.shiftKey&&i.key==="F10"))return;i.preventDefault(),i.stopPropagation();const S=i.currentTarget.getBoundingClientRect();Y({x:S.right,y:S.bottom})},se=g&&typeof document<"u"?ve.createPortal(e.jsxs("div",{ref:O,className:"session-action-menu surface-card",role:"menu","aria-label":a("shell.sessionMoreAction"),style:T??{position:"fixed",top:0,left:0,visibility:"hidden"},onClick:i=>i.stopPropagation(),children:[e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:j,children:t?a("shell.unfavoriteAction"):a("shell.favoriteAction")}),e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void v(),children:c.isArchived?a("shell.unarchiveAction"):a("shell.archiveAction")}),e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void p(),children:a("shell.renameAction")})]}),document.body):null;return e.jsxs("article",{className:"session-list-item","data-depth":d,"data-active":r,"data-workspace-tone":N,"data-has-subsessions":m,"data-variant":l,"data-parallel-group":E&&c.parallelGroup?"true":void 0,"data-parallel-role":E?((C=c.parallelGroup)==null?void 0:C.role)??void 0:void 0,style:ce,onContextMenu:i=>{z&&(i.preventDefault(),i.stopPropagation(),Y({x:i.clientX,y:i.clientY}))},children:[m?e.jsx("button",{type:"button",className:"session-list-subsession-toggle","aria-label":k?a("shell.subagentCollapse"):a("shell.subagentExpand"),title:k?a("shell.subagentCollapse"):a("shell.subagentExpand"),"aria-expanded":k,onClick:i=>{i.stopPropagation(),H.trigger("selection"),$==null||$()},children:e.jsx("span",{className:fe(c,{isActive:r,hasSubsessions:m}),"aria-hidden":"true"})}):e.jsx("span",{className:fe(c,{isActive:r,hasSubsessions:m}),"aria-hidden":"true"}),e.jsx("button",{type:"button",className:"session-list-link",onClick:o,onPointerDown:ee,onPointerUp:s,onPointerCancel:s,onPointerLeave:s,onKeyDown:x,children:e.jsxs("div",{className:"session-list-copy",children:[e.jsxs("div",{className:"session-list-title-row",children:[e.jsx("div",{className:"session-list-title",children:V||a("shell.searchEntry")}),q?e.jsx("span",{className:"session-list-parallel-badge",children:q}):null,Q?e.jsx("span",{className:"session-list-parallel-role-badge",children:Q}):null]}),e.jsx("div",{className:"session-list-meta",children:l==="mobile"?e.jsx(e.Fragment,{children:e.jsx("span",{children:_})}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:le.name}),W&&X?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{className:X,children:W})]}):null,e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:Z})]})}),U?e.jsx("div",{className:"session-list-error",title:K??void 0,children:U}):null]})}),se]})}function fe(n,t){return Ce("session-list-indicator",n,{isActive:t.isActive,hasSubagents:t.hasSubsessions})}function Ve(n){return n?new Date(n).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):a("common.unknown")}function _e(n){return xe(n)||n.syncStatus==="error"}function Ke(n){var d,l;if(!_e(n))return null;const t=((d=n.lastErrorCode)==null?void 0:d.trim())??"",r=((l=n.lastErrorDetail)==null?void 0:l.replace(/\s+/g," ").trim())??"";return t&&r&&!r.includes(t)?`${t} · ${r}`:r||t||(n.syncStatus==="error"&&!xe(n)?a("conversation.syncStatusError"):a("conversation.runtimeErrorTitle"))}function Ue(n,t=96){return n.length<=t?n:`${n.slice(0,Math.max(0,t-1)).trimEnd()}…`}const te=5;function us(){var ee;const n=ye(),{navigationGroups:t,favoriteSessionIds:r,currentWorkspaceId:d,currentSessionId:l,navigationLoading:N,selectWorkspace:m,toggleFavoriteSession:k,archiveSession:z,unarchiveSession:J,renameSession:$,startDraftSession:ae}=Pe(),B=Oe(t),re=h.useMemo(()=>Ie(t),[t]),u=me(t,d)??me(t,((ee=t[0])==null?void 0:ee.workspace.id)??null),g=B.find(s=>s.workspace.id===(u==null?void 0:u.workspace.id))??(u?{workspace:u.workspace,label:u.workspace.name,subtitle:u.workspace.path}:null),L=h.useMemo(()=>new Set(r),[r]),T=h.useMemo(()=>u?u.sessions.filter(s=>{if(s.isArchived)return!1;const o=De(s,{mode:"mobile"});if(!o)return!0;const p=u.sessions.find(v=>v.sessionId===o);return!p||!p.isArchived}).map(s=>({session:s,workspace:u.workspace})):[],[u]),R=h.useMemo(()=>T.filter(s=>L.has(s.session.sessionId)),[T,L]),w=h.useMemo(()=>he(T,{mode:"mobile"}),[T]),F=h.useMemo(()=>he(R,{mode:"mobile"}),[R]),M=h.useMemo(()=>u?u.sessions.filter(s=>s.isArchived===!0&&!Le(s)):[],[u]),G=(u==null?void 0:u.workspace.id)??"",O=!!G,[H,c]=h.useState([]),[le,V]=h.useState({}),[Z,_]=h.useState(!1),[K,U]=h.useState(!1),[W,X]=h.useState(null);h.useEffect(()=>{V(s=>{const o={};for(const p of w){const v=ie(oe(p));if(v.length===0)continue;const j=v.findIndex(x=>x.item.session.sessionId===l);o[p.item.session.sessionId]=Ze(v.length,te,s[p.item.session.sessionId],j)}return qe(s,o)?s:o})},[l,w]),h.useEffect(()=>{if(!l)return;const s=Te(w,l,o=>o.session.sessionId);s.length!==0&&c(o=>{const p=new Set(o);let v=!1;for(const j of s)p.has(j)||(p.add(j),v=!0);return v?Array.from(p):o})},[l,w]);function E(s){c(o=>o.includes(s)?o.filter(p=>p!==s):[...o,s])}function q(s){return le[s]??te}function Q(s){V(o=>({...o,[s]:(o[s]??te)+te}))}function ce(s,o){pe("immersive"),n(Ge(s,o))}function Y(s,o){_(!1),pe("immersive"),ae(s,o)}async function y(s){X(s);try{await J(s)}finally{X(o=>o===s?null:o)}}function A(s,o=!1,p=[],v=!1,j=!1){var de;const x=s.item.session.sessionId,se=s.children,C=s.depth===0&&se.length>0,i=o||C&&H.includes(x),S=i&&C,ne=S?Je(s,q(x)):s,f=i?ne.children:[],P=ie(se).length,I=ie(f).length,we=S&&I<P,Se=s.depth>0?[...p,v]:[...p];return e.jsxs("div",{className:"session-list-tree-node",children:[e.jsxs("div",{className:"session-list-tree-row",style:{"--session-tree-depth":s.depth},children:[s.depth>0?e.jsxs("div",{className:"session-tree-guides","aria-hidden":"true",style:{"--session-tree-depth":s.depth},children:[p.map((b,D)=>b?e.jsx("span",{className:"session-tree-guide-column",style:{"--session-tree-level":D+1}},`${x}:ancestor:${D}`):null),e.jsx("span",{className:"session-tree-guide-branch","data-continue":v,"data-first":j,style:{"--session-tree-level":s.depth},children:e.jsx("span",{className:"session-tree-guide-branch-horizontal"})})]}):null,e.jsx(He,{entry:s.item,isFavorite:L.has(x),isActive:l===x,depth:s.depth,variant:"mobile",workspaceTone:((de=re[s.item.workspace.id])==null?void 0:de.tone)??"root",hasSubsessions:C,subsessionsExpanded:i,onActivate:b=>ce(s.item.workspace.id,b),onToggleSubsessions:C?()=>E(x):void 0,onToggleFavorite:b=>{k(b)},onArchive:b=>z(b),onUnarchive:b=>J(b),onRename:(b,D)=>$(b,D)})]}),i&&f.length>0?e.jsx("div",{className:"session-list-children",children:f.map((b,D)=>A(b,!0,Se,D<f.length-1,D===0))}):null,we?e.jsx("div",{className:"session-list-children",children:e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>Q(x),children:a("shell.subagentExpandMore")})}):null]},`${s.item.workspace.id}:${x}`)}return e.jsxs("main",{className:"session-index-page mobile-feature-page mobile-page-scroll-root mobile-page-with-top-header",children:[e.jsx(We,{currentWorkspace:g?{id:g.workspace.id,name:g.label,path:g.subtitle}:null,workspaces:t.map(s=>s.workspace),workspaceOptions:B,onSelectWorkspace:s=>{m(s),n(Re(s))},content:e.jsx("button",{type:"button",className:"primary-button mobile-session-index-create-button",disabled:N||!O,onClick:()=>_(!0),children:a("shell.createSession")})}),e.jsxs("div",{className:"mobile-page-top-body",children:[e.jsx("div",{className:"session-index-archive-actions",children:e.jsxs("button",{type:"button",className:"primary-button mobile-session-index-create-button session-index-archive-button",disabled:N||!u,onClick:()=>U(!0),children:[e.jsx("span",{children:a("shell.archiveViewAction")}),e.jsx("span",{className:"session-index-archive-count",children:M.length})]})}),F.length>0?e.jsxs("section",{className:"session-section session-section-sheet",children:[e.jsxs("header",{className:"session-section-heading",children:[e.jsx("div",{children:e.jsx("h2",{children:a("shell.favoriteSectionTitle")})}),e.jsx("span",{className:"session-section-count",children:R.length})]}),e.jsx("div",{className:"session-current-workspace-list",children:F.map(s=>A(s))})]}):null,e.jsxs("section",{className:"session-section session-section-sheet",children:[e.jsxs("header",{className:"session-section-heading",children:[e.jsx("div",{children:e.jsx("h2",{children:a("shell.mobileConversationCurrentWorkspaceSection")})}),e.jsx("span",{className:"session-section-count",children:w.length})]}),w.length===0?e.jsx("p",{className:"session-section-empty",children:N?a("shell.searchSessionHint"):a("shell.emptyWorkspaceSessions")}):e.jsx("div",{className:"session-current-workspace-list",children:w.map(s=>A(s))})]})]}),e.jsx($e,{open:Z,workspaces:t.map(s=>s.workspace),workspaceOptions:B,initialWorkspaceId:d??G,onClose:()=>_(!1),onSelect:Y}),e.jsx(Xe,{open:K,workspaceName:(g==null?void 0:g.label)??(u==null?void 0:u.workspace.name)??null,sessions:M,restoringSessionId:W,onClose:()=>{W||U(!1)},onRestore:s=>void y(s)})]})}function Xe({open:n,workspaceName:t,sessions:r,restoringSessionId:d,onClose:l,onRestore:N}){return h.useEffect(()=>{if(!n)return;function m(k){k.key==="Escape"&&!d&&l()}return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m)}},[l,n,d]),!n||typeof document>"u"?null:ve.createPortal(e.jsxs("div",{className:"workbench-modal-layer",children:[e.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":a("common.close"),disabled:!!d,onClick:l}),e.jsxs("section",{className:"workbench-modal-card surface-card",role:"dialog","aria-modal":"true","aria-label":a("shell.archiveModalTitle"),children:[e.jsx("div",{className:"workbench-modal-header",children:e.jsxs("div",{className:"workbench-modal-title-wrap",children:[e.jsx("h2",{children:a("shell.archiveModalTitle")}),e.jsx("p",{children:t?`${t} · ${a("shell.archiveModalDescription")}`:a("shell.archiveModalDescription")})]})}),e.jsx("div",{className:"workbench-modal-body",children:r.length>0?e.jsx("div",{className:"workbench-archive-list",children:r.map(m=>e.jsxs("article",{className:"workbench-archive-item",children:[e.jsxs("div",{className:"workbench-archive-item-main",children:[e.jsx("strong",{title:m.title??m.sessionId,children:m.title??m.sessionId}),e.jsx("p",{children:Ye(m)})]}),e.jsx("button",{type:"button",className:"secondary-button",disabled:d===m.sessionId,onClick:()=>{N(m.sessionId)},children:a("shell.unarchiveAction")})]},m.sessionId))}):e.jsx("p",{className:"workbench-section-empty",children:a("shell.archiveEmpty")})})]})]}),document.body)}function Ye(n){const t=be(n.provider),r=ze(n.lastMessageAt??n.updatedAt??null);return[t,r].filter(Boolean).join(" · ")}function ze(n){if(!n)return null;const t=Date.parse(n);return Number.isNaN(t)?null:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(t)}function Je(n,t){const r=new Set(ie(oe(n)).sort((d,l)=>(l.item.session.lastMessageAt??l.item.session.updatedAt).localeCompare(d.item.session.lastMessageAt??d.item.session.updatedAt)).slice(0,t).map(d=>d.item.session.sessionId));return{...n,children:ge(oe(n),r)}}function ge(n,t){return n.flatMap(r=>{const d=ge(oe(r),t);return!t.has(r.item.session.sessionId)&&d.length===0?[]:[{...r,children:d}]})}function Ze(n,t,r,d=-1){if(n<=0)return 0;const l=d>=0?Math.max(t,d+1):t;return Math.min(n,Math.max(r??0,l))}function qe(n,t){const r=Object.keys(n),d=Object.keys(t);return r.length!==d.length?!1:r.every(l=>n[l]===t[l])}export{us as SessionIndexPage};
|