@jingyi0605/codingns 0.7.0 → 0.7.2
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-B8mg25ze.js → AdaptiveButlerPage-174Mg-9X.js} +1 -1
- package/dist/public/assets/{App-C2lNmeKL.js → App-BRupl2Ul.js} +3 -3
- package/dist/public/assets/{BootstrapPage-CAVA-a8h.js → BootstrapPage-BKzDRWtn.js} +1 -1
- package/dist/public/assets/ConversationPage-BLQXBsBc.js +6 -0
- package/dist/public/assets/{DesktopDetachPreviewPage-B37DUL15.js → DesktopDetachPreviewPage-DtHzSQOX.js} +1 -1
- package/dist/public/assets/{DesktopWindowPage-CDA6l7lm.js → DesktopWindowPage-ppc3h5sO.js} +1 -1
- package/dist/public/assets/{FileContextPanel-CMGTtAB6.js → FileContextPanel-h0kvRbSR.js} +1 -1
- package/dist/public/assets/GitSidebar-TlaPNhxG.js +6 -0
- package/dist/public/assets/{MobileCreateSessionSheet-THIrIzJ3.js → MobileCreateSessionSheet-Bp4xOKdt.js} +1 -1
- package/dist/public/assets/{MobileTopHeaderFrame-D-X7pVnV.js → MobileTopHeaderFrame-BawK1vUE.js} +1 -1
- package/dist/public/assets/{MobileWorkspaceSwitcherHeader-Cczi7RYu.js → MobileWorkspaceSwitcherHeader-CWPXAMoX.js} +1 -1
- package/dist/public/assets/{RelayConnectEntryPage-D417tgWj.js → RelayConnectEntryPage-B0-OBZXu.js} +1 -1
- package/dist/public/assets/{ServerSettingsModal-BdTxbRbU.js → ServerSettingsModal-P_pcDvyR.js} +1 -1
- package/dist/public/assets/{SessionIndexPage-D5iefVcc.js → SessionIndexPage-r8AZ0pJv.js} +1 -1
- package/dist/public/assets/{SettingsPage-iCFe_DHP.js → SettingsPage-B-uNuML1.js} +1 -1
- package/dist/public/assets/{TerminalManagerPanel-CtldwWz8.js → TerminalManagerPanel-Bkgr9ZNV.js} +1 -1
- package/dist/public/assets/{TerminalPage-DAzQTmQC.js → TerminalPage-BpFpA3My.js} +1 -1
- package/dist/public/assets/{TerminalRuntimeFallbackModal-DLOhAvaq.js → TerminalRuntimeFallbackModal-D_BUt6HD.js} +1 -1
- package/dist/public/assets/ToolFilesPage-BE9-iHL0.js +1 -0
- package/dist/public/assets/ToolGitPage-ChUkwKgK.js +1 -0
- package/dist/public/assets/ToolProcessesPage-C4dli_mi.js +1 -0
- package/dist/public/assets/{ToolsHomePage-rU3V8mmh.js → ToolsHomePage-ZmcEotg4.js} +1 -1
- package/dist/public/assets/{WorkbenchLandingPage-BudM2C69.js → WorkbenchLandingPage-DZzbQZHt.js} +1 -1
- package/dist/public/assets/WorkbenchLayout-Cht6Un5X.js +244 -0
- package/dist/public/assets/{WorkbenchModal-DMQutm1x.js → WorkbenchModal-CAj_TqWW.js} +1 -1
- package/dist/public/assets/WorkbenchShellRoute-DzbO05cD.js +1 -0
- package/dist/public/assets/{WorkspaceDebugDetailPage-CHqo-uDf.js → WorkspaceDebugDetailPage-qku5AzZQ.js} +1 -1
- package/dist/public/assets/{WorkspaceDetailPage-CGkAH1W-.js → WorkspaceDetailPage-BtrSsZVP.js} +1 -1
- package/dist/public/assets/{WorkspaceHomePage-CfuPVITd.js → WorkspaceHomePage-BhekFDSu.js} +1 -1
- package/dist/public/assets/{client-runtime-manager-CKbtaemV.js → client-runtime-manager-CgogHxt0.js} +1 -1
- package/dist/public/assets/file-tree-icon-CLfk31E7.js +3 -0
- package/dist/public/assets/index-CkkzIvxs.css +1 -0
- package/dist/public/assets/index-DvkfRpBe.js +42 -0
- package/dist/public/assets/{login-direct-candidate-resolver-DjJMbqB7.js → login-direct-candidate-resolver-DvJnjQCi.js} +1 -1
- package/dist/public/assets/{model-switch-api-T55eW6D4.js → model-switch-api-Dps4yN2t.js} +1 -1
- package/dist/public/assets/{preferences-service-BTKBl5xM.js → preferences-service-ohVuseA-.js} +1 -1
- package/dist/public/assets/realtime-client-CIci6rCd.js +1 -0
- package/dist/public/assets/{relay-entry-sdeFnTbY.js → relay-entry-WiotM2TL.js} +1 -1
- package/dist/public/assets/styles-DkbkRgWw.css +1 -0
- package/dist/public/assets/{terminal-runtime-meta-Cvt1ID92.js → terminal-runtime-meta-C3Mr0zW5.js} +1 -1
- package/dist/public/assets/{useRegisteredDebugTemplates-O-ymgLd9.js → useRegisteredDebugTemplates-DVQBPV-V.js} +1 -1
- package/dist/public/index.html +2 -2
- package/dist/server/modules/git/git-controller.d.ts +3 -1
- package/dist/server/modules/git/git-controller.js +9 -2
- package/dist/server/modules/git/git-controller.js.map +1 -1
- package/dist/server/modules/git/git-read-service.js +2 -1
- package/dist/server/modules/git/git-read-service.js.map +1 -1
- package/dist/server/modules/git/git-remote-credential-service.d.ts +1 -0
- package/dist/server/modules/git/git-remote-credential-service.js +4 -0
- package/dist/server/modules/git/git-remote-credential-service.js.map +1 -1
- package/dist/server/modules/git/types.d.ts +1 -0
- package/dist/server/modules/provider/codex-model-options.js +14 -15
- package/dist/server/modules/provider/codex-model-options.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-helper-process.js +2 -1
- package/dist/server/modules/provider/provider-discovery-helper-process.js.map +1 -1
- package/dist/server/server/create-server.js +1 -1
- package/dist/server/server/create-server.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/patch-builder.d.ts +6 -0
- package/node_modules/@codingns/session-sync-core/dist/patch-builder.js +398 -0
- package/node_modules/@codingns/session-sync-core/dist/patch-builder.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +47 -4
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +32 -4
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
- package/package.json +5 -1
- package/dist/public/assets/ConversationPage-B6BGOX4C.js +0 -6
- package/dist/public/assets/GitSidebar--DCqBiGL.js +0 -6
- package/dist/public/assets/ToolFilesPage-D7thcDEv.js +0 -1
- package/dist/public/assets/ToolGitPage-uPRsxdcn.js +0 -1
- package/dist/public/assets/ToolProcessesPage-B1uOk0Ef.js +0 -1
- package/dist/public/assets/WorkbenchLayout-Dybarc1V.js +0 -244
- package/dist/public/assets/WorkbenchShellRoute-Cy4WBbzq.js +0 -1
- package/dist/public/assets/file-tree-icon-Bc0KADEl.js +0 -3
- package/dist/public/assets/index-DNRyROOG.css +0 -1
- package/dist/public/assets/index-oGylLBIX.js +0 -42
- package/dist/public/assets/realtime-client-ww7MnbTD.js +0 -1
- package/dist/public/assets/styles-BjPytabP.css +0 -1
- package/dist/server/modules/channels/wechat-claw-client.d.ts +0 -51
- package/dist/server/modules/channels/wechat-claw-client.js +0 -245
- package/dist/server/modules/channels/wechat-claw-client.js.map +0 -1
- /package/dist/public/assets/{styles-lhQGDlPF.js → styles-JKFlsYFv.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as c,j as n,t as r,A as Yn}from"./index-oGylLBIX.js";import{f as Zn,e as Di,g as ki}from"./App-C2lNmeKL.js";import{aq as Ei,u as Mi,h as Ri,v as _i}from"./model-switch-api-T55eW6D4.js";import{bg as Ti,bh as Jn,b as en,w as wt,bi as Fi,u as Ai,ac as Me,bj as Li,bk as yt,bl as Ve,bm as Bi,bn as Wi,bo as $i}from"./WorkbenchLayout-Dybarc1V.js";import{W as Ln}from"./WorkbenchModal-DMQutm1x.js";import{r as Mt,a as Rt,F as Oi}from"./file-tree-icon-Bc0KADEl.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-sdeFnTbY.js";const Hi=new Set([".ds_store","thumbs.db","ehthumbs.db","desktop.ini",".spotlight-v100",".trashes",".fseventsd","__macosx","$recycle.bin","system volume information",".apdisk",".appledouble",".temporaryitems"]),zi=["._"];function xt(t){return t.split(/[/\\]/).filter(Boolean).pop()??t}function Ui(t){const i=t.trim().toLowerCase();return i?Hi.has(i)||zi.some(l=>i.startsWith(l)):!1}function nn(t,i,l){return l?[...t]:t.filter(o=>!Ui(i(o)))}function Nt(t,i){return nn(t,l=>l.name,i)}function Vi(t,i){return i?t:Object.entries(t).reduce((l,[o,h])=>(l[o]=Nt(h,!1),l),{})}async function Zt(t,i){const[l,o]=await Promise.all([Ti(i),Ei(t)]);return Ki(l.changes,o.items)}function Ki(t,i){const l=new Set(i.map(o=>kt(o.path)));return t.filter(o=>l.has(kt(o.path))||o.oldPath!==null&&l.has(kt(o.oldPath)))}function Gi(t){const i=Bn("","");for(const l of t){const o=kt(l.path),h=o.split("/").filter(Boolean);let d=i;h.forEach((b,y)=>{const C=h.slice(0,y+1).join("/");if(y===h.length-1){d.children.set(`file:${C}`,{kind:"file",name:b,path:o,change:l});return}const T=`directory:${C}`,M=d.children.get(T);if(M&&M.kind==="directory"){d=M;return}const Y=Bn(b,C);d.children.set(T,Y),d=Y})}return ei(In([...i.children.values()]))}function Qn(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 kt(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function Bn(t,i){return{kind:"directory",name:t,path:i,children:new Map}}function In(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:In([...i.children.values()])}:i)}function ei(t){return t.map(i=>{var b;if(i.kind!=="directory")return i;const l=ei(i.children);let o=i.name,h=i.path,d=l;for(;d.length===1&&((b=d[0])==null?void 0:b.kind)==="directory";){const y=d[0];o=`${o}/${y.name}`,h=y.path,d=y.children}return{kind:"directory",name:o,path:h,children:d}})}const Xi=450,qi=60*1e3,Wn=20,$n=16;function Yi({sessionId:t,workspaceId:i,showSystemFiles:l,selectedPath:o,refreshVersion:h,onCountChange:d,onSelectFile:b,onOpenFile:y}){const[C,T]=c.useState("tree"),[M,Y]=c.useState([]),[me,U]=c.useState(!0),[pe,be]=c.useState(!1),[V,ft]=c.useState([]),k=c.useRef(null),Tt=Jn(),{showToast:je}=Zn();c.useEffect(()=>{const m=en(gt(i,t),qi);T("tree"),Y(m??[]),U(m===null),be(!1),ft([]),k.current=null},[t,i]),c.useEffect(()=>{let m=!1;async function j(){U(!0);try{const v=await Zt(t,i);m||(Y(v),wt(gt(i,t),v))}catch(v){m||je({title:Jt(v,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{m||U(!1)}}return j(),()=>{m=!0}},[h,t,je,i]);async function Se(){U(!0);try{const m=await Zt(t,i);Y(m),wt(gt(i,t),m)}catch(m){je({title:Jt(m,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{U(!1)}}async function D(){if(R.length!==0){be(!0);try{await Fi(i,R.map(j=>j.path));const m=await Zt(t,i);Y(m),wt(gt(i,t),m),je({title:r("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(m){je({title:Jt(m,r("git.stageFailed")),tone:"error"})}finally{be(!1)}}}function F(m){ft(j=>j.includes(m)?j.filter(v=>v!==m):[...j,m])}function K(m){const j=Date.now(),v=k.current;return k.current={filePath:m,timestamp:j},(v==null?void 0:v.filePath)===m&&j-v.timestamp<=Xi}async function $(m,j){if(j&&K(m)){await y(m),k.current=null;return}j||(k.current=null),await b(m)}const ne=c.useMemo(()=>nn(M,m=>Dt(m.path),l),[M,l]),R=ne.filter(m=>!m.staged),Re=Gi(ne),ie=new Set(V);return c.useEffect(()=>{d==null||d(ne.length)},[d,ne.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":r("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:()=>T("tree"),children:r("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:()=>T("list"),children:r("conversation.filePanelSessionListView")})]}),n.jsxs("div",{className:"file-panel-session-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Se(),disabled:me||pe,children:r("conversation.filePanelRefresh")}),n.jsx("button",{className:"primary-button",type:"button",onClick:()=>void D(),disabled:pe||R.length===0,children:r("conversation.filePanelSessionStageAll")})]})]}),n.jsxs("div",{className:"file-panel-session-summary",children:[n.jsx("span",{children:`${r("conversation.filePanelSessionSummary")} ${ne.length}`}),n.jsx("span",{children:`${r("conversation.filePanelSessionUnstagedSummary")} ${R.length}`})]}),n.jsx("div",{ref:Tt,className:"file-tree","data-scrollbar-autohide":"true",children:me?n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionLoading")}):ne.length===0?n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionEmpty")}):C==="tree"?ti({nodes:Re,depth:0,collapsedPathSet:ie,selectedPath:o,onToggleTreePath:F,onFileClick:$}):Zi({items:ne,selectedPath:o,onFileClick:$})})]})}function ti({nodes:t,depth:i,collapsedPathSet:l,selectedPath:o,onToggleTreePath:h,onFileClick:d}){return t.map(b=>{if(b.kind==="directory"){const y=!l.has(b.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(b.path),children:[n.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:y?"v":">"}),n.jsx("span",{className:"file-tree-label",children:b.name})]}),y?n.jsx("div",{className:"file-tree-children",children:ti({nodes:b.children,depth:i+1,collapsedPathSet:l,selectedPath:o,onToggleTreePath:h,onFileClick:d})}):null]},`session-directory:${b.path}`)}return n.jsx("div",{className:"file-tree-node",children:n.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":o===b.change.path,"data-kind":"file",style:{paddingInlineStart:`${Wn+i*$n}px`},onClick:()=>void d(b.change.path,!an(b.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(b.name),"aria-hidden":"true",children:Mt(b.name)}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:b.name}),n.jsx("span",{className:"file-tree-path",children:Qn(b.change,r("conversation.filePanelSessionDeleted"))})]}),n.jsxs("span",{className:"file-session-item-meta",children:[n.jsx("span",{className:"file-session-badge","data-status":b.change.status,children:b.change.status}),n.jsx("span",{className:"file-session-badge subtle",children:b.change.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-file:${b.path}`)})}function Zi({items:t,selectedPath:i,onFileClick:l}){return t.map(o=>n.jsx("div",{className:"file-session-list-item",children:n.jsxs("button",{className:"file-session-list-button",type:"button","data-active":i===o.path,onClick:()=>void l(o.path,!an(o)),children:[n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(Dt(o.path)),"aria-hidden":"true",children:Mt(Dt(o.path))}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:Dt(o.path)}),n.jsx("span",{className:"file-tree-path",children:Qn(o,r("conversation.filePanelSessionDeleted"))})]}),n.jsxs("span",{className:"file-session-item-meta",children:[n.jsx("span",{className:"file-session-badge","data-status":o.status,children:o.status}),n.jsx("span",{className:"file-session-badge subtle",children:o.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-list:${o.path}`))}function gt(t,i){return`file-panel.session-changes.${t}.${i}`}function Jt(t,i){return t instanceof Yn?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??i):i}const g="",Ji=450,ee=8,Pt=4,Qi=176,Ii=120,ea=300*1e3,ta=60*1e3,On=1600,na=20,ia=16;function qa({className:t,sessionId:i,workspaceId:l,hideHeading:o=!1,hideTabs:h=!1,externalRevealRequest:d=null,externalWindowMode:b=!1,workbenchShellOverrides:y}){var Tn,Fn;const C=Ai(),{navigationGroups:T,subscribeFileTree:M,requestFileTreeRefresh:Y,addFileTreeSnapshotListener:me,subscribeGitSnapshot:U,requestGitRefresh:pe,addGitSnapshotListener:be}={...C,...y},[V,ft]=c.useState({}),[k,Tt]=c.useState([]),[je,Se]=c.useState([]),[D,F]=c.useState(g),[K,$]=c.useState([]),[ne,R]=c.useState(null),[Re,ie]=c.useState(!1),[m,j]=c.useState(!1),[v,dt]=c.useState(!1),[Ge,Xe]=c.useState(!1),[A,qe]=c.useState(""),[Ft,G]=c.useState(null),[ht,mt]=c.useState(!1),[we,Ye]=c.useState(null),[X,Ze]=c.useState("workspace"),[sn,_e]=c.useState(0),[rn,At]=c.useState(0),[Je,Z]=c.useState(!1),[Qe,L]=c.useState(!1),[ae,O]=c.useState(null),[ve,Te]=c.useState(null),[B,Fe]=c.useState(null),[P,Lt]=c.useState(null),[w,Ie]=c.useState(null),[Bt,Ae]=c.useState(""),[on,cn]=c.useState([]),[J,Wt]=c.useState(!1),[oi,ye]=c.useState(null),un=c.useId(),le=c.useRef({}),se=c.useRef({}),_=c.useRef([]),Q=c.useRef(g),et=c.useRef(!1),tt=c.useRef(null),ci=Jn(),fn=c.useRef(null),dn=c.useRef(null),$t=c.useRef(null),hn=c.useRef(null),mn=c.useRef(null),xe=c.useRef(0),re=c.useRef(new Map),{showToast:S}=Zn(),nt=Di(),I=Mi(e=>e.showSystemFiles),it=!!(i!=null&&i.trim()),pn=o&&nt.isMobile;c.useEffect(()=>{Me("file_panel.props",{sessionId:i,workspaceId:l,externalWindowMode:b})},[b,i,l]),c.useEffect(()=>{Q.current=D},[D]);function Ne(e){ft(a=>{const s=typeof e=="function"?e(a):e;return le.current=s,s})}function Le(e){Tt(a=>{const s=typeof e=="function"?e(a):e;return _.current=s,s})}c.useEffect(()=>{var f,p;if(Ut(),!l){Ut(),et.current=!1,le.current={},se.current={},_.current=[],Q.current=g,Ne({}),Le([]),Se([]),F(g),Xe(!1),qe(""),G(null),mt(!1),ie(!1),Wt(!1),ye(null),$([]),R(null),O(null),Te(null),Fe(null),Ie(null),Ae("");return}et.current=!0;const e=en(Kn(l),ea);Me("file_panel.workspace_snapshot",{workspaceId:l,cached:!!e,cachedRootItems:((p=(f=e==null?void 0:e.treeCache)==null?void 0:f[g])==null?void 0:p.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const a=Pa((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);le.current=u,se.current=Gn((e==null?void 0:e.treeRevisionByPath)??{},u),_.current=s,Q.current=a,Ne(u),Le(s),Se([]),F(a),ie(!1),j(!1),Xe(!1),qe(""),G(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,Ze("workspace"),(d.openViewer?He(d.filePath):ce(d.filePath)).catch(s=>{S({title:te(s,r("conversation.filePanelOpenFailed")),tone:"error"})})};if(et.current){queueMicrotask(e);return}e()},[d,He,ce,S,l]),c.useEffect(()=>{if(l)return me(e=>{e.workspaceId===l&&(se.current={...se.current,[e.path]:typeof e.revision=="string"?e.revision:null},Ne(a=>({...a,[e.path]:e.items})),e.path===g&&ie(!1),Se(a=>a.filter(s=>s!==e.path)),di(e.path,e.items))})},[me,l]),c.useEffect(()=>()=>{Ut()},[]),c.useEffect(()=>{l&&M(l,It(_.current,Q.current),{knownRevisionByPath:se.current})},[D,k,M,l]),c.useEffect(()=>{$([]),R(null),Ye(null),ye(null),_e(0),Z(!1),L(!1),O(null),Te(null),Fe(null),Ie(null),Ae(""),tt.current=null,xe.current+=1},[i]),c.useEffect(()=>{!it&&X==="session"&&Ze("workspace")},[X,it]),c.useEffect(()=>{h&&X!=="workspace"&&Ze("workspace")},[X,h]),c.useEffect(()=>{if(!Je&&!Qe&&!ae)return;function e(s){var x,N,fe;if(!(s.target instanceof Node))return;const u=((x=fn.current)==null?void 0:x.contains(s.target))??!1,f=((N=dn.current)==null?void 0:N.contains(s.target))??!1,p=((fe=$t.current)==null?void 0:fe.contains(s.target))??!1;!u&&!f&&!p&&(Z(!1),L(!1),O(null),Te(null))}function a(s){s.key==="Escape"&&(Z(!1),L(!1),O(null),Te(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",a)}},[Je,Qe,ae]),c.useLayoutEffect(()=>{if(!ae||typeof window>"u"){Te(null);return}const e=ae;function a(){const u=$t.current;if(!u)return;const f=u.getBoundingClientRect();Te(fa({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)}},[ae]),c.useEffect(()=>{if(!l)return;const e=Vn(k,D),a=St(V,D,e);wt(Kn(l),{treeCache:a,treeRevisionByPath:Gn(se.current,a),expandedDirectories:e,activeDirectoryPath:D})},[D,k,V,l]),c.useEffect(()=>{if(et.current)return;const e=St(V,D,k);ja(V,e)||Ne(e)},[D,k,V]),c.useEffect(()=>{let e=!1;const a=(l==null?void 0:l.trim())??null;async function s(f){if(!a)return;const p=Nt(le.current[g]??[],I),x=(f==null?void 0:f.silent)!==!0&&p.length===0;x&&ie(!0),Me("file_panel.load_root_tree.start",{sessionId:i,workspaceId:a,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:p.length});try{const N=await zt(g,{force:!0});e||(Me("file_panel.load_root_tree.end",{sessionId:i,workspaceId:a,itemCount:N.length}),Ne(fe=>({...St(fe,Q.current,_.current),[g]:N})))}catch(N){!e&&!Xn(N)&&S({title:te(N,r("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&x&&ie(!1)}}if(Nt(le.current[g]??[],I).length>0){const f=window.setTimeout(()=>{a&&(M(a,It(_.current,Q.current),{knownRevisionByPath:se.current}),s({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return s(),()=>{e=!0}},[i,I,S,l]),c.useEffect(()=>{if(!l||!i){At(0);return}const e=en(Sa(l,i),ta);Me("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();U(e),pe(e)},[l,U,pe]),c.useEffect(()=>{if(!l)return;const e=l.trim();return be(a=>{var s;a.workspaceId===e&&cn(((s=a.status)==null?void 0:s.changes)??[])})},[be,l]);const pt=c.useMemo(()=>nn(on,e=>xt(e.path),I),[on,I]),W=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 p=u.split("/");for(let x=1;x<p.length;x++)a.add(p.slice(0,x).join("/"))}return{statusByPath:e,changedDirs:a}},[pt]),De=c.useMemo(()=>Vi(V,I),[I,V]),ke=c.useMemo(()=>Ft===null?null:Nt(Ft,I),[Ft,I]),Be=De[g]??[],oe=Ge&&ke!==null,bt=c.useMemo(()=>J?tn(Be,De,W.statusByPath,W.changedDirs):Be,[W.changedDirs,W.statusByPath,Be,J,De]),ui=c.useMemo(()=>oe?(ke??[]).map(e=>z(e.path,e.kind)):ni(bt,De,k,J,W.statusByPath,W.changedDirs),[k,W.changedDirs,W.statusByPath,oe,J,ke,De,bt]),We=((Tn=T.find(e=>e.workspace.id===l))==null?void 0:Tn.workspace)??null,E=Un(K),Ot=(E==null?void 0:E.path)??null,ge=(E==null?void 0:E.kind)==="file"?E.path:null,vt=c.useMemo(()=>new Set(K.map(e=>e.path)),[K]),at=c.useMemo(()=>jt(K),[K]),Ht=!!(We!=null&&We.path&&K.length===1&&Ot),bn=K.length===1&&(E==null?void 0:E.kind)==="file",vn=at.length>0,Ee=at.length>0,lt=!!(P!=null&&P.items.length&&l),yn=!!l&&K.length===1&&E!==null,xn=!!((ge?he(ge):D)&&k.length),gn=P?P.mode==="copy"?r("conversation.filePanelClipboardCopyReady",{count:P.items.length}):r("conversation.filePanelClipboardCutReady",{count:P.items.length}):null,H=w?pa(w):null;async function Pn(e,a=!1){if(!l)return[];if(!a){const s=le.current[e];if(s)return s}e===g?ie(!0):Se(s=>Et(s,e));try{const s=await zt(e,{force:a});return Ne(u=>({...u,[e]:s})),s}catch(s){throw Xn(s)||S({title:te(s,r("conversation.filePanelLoadFailed")),tone:"error"}),s}finally{e===g?ie(!1):Se(s=>s.filter(u=>u!==e))}}async function Pe(e){if(!l)return;const a=(e==null?void 0:e.activeDirectoryPath)??Q.current,s=(e==null?void 0:e.expandedDirectories)??_.current,u=Ca(le.current,a,s);Me("file_panel.refresh_tree_cache.start",{sessionId:i,workspaceId:l,targetDirectories:u});const p=(await Promise.all(u.map(async x=>{const N=await zt(x,{force:!0});return[x,N]}))).reduce((x,[N,fe])=>(x[N]=fe,x),{});Me("file_panel.refresh_tree_cache.end",{sessionId:i,workspaceId:l,targetDirectories:u,directoryCount:Object.keys(p).length}),Ne(p)}async function zt(e,a){if(!l)return[];if(!(a!=null&&a.force)){const u=le.current[e];if(u)return u}const s=It(Et(_.current,e),e||Q.current);return M(l,s,{knownRevisionByPath:se.current}),Y(l,[e],{knownRevisionByPath:se.current}),fi(e,On,{allowCached:(a==null?void 0:a.force)!==!0})}function fi(e,a=On,s){const u=le.current[e];return(s==null?void 0:s.allowCached)!==!1&&u?Promise.resolve(u):new Promise((f,p)=>{const x=window.setTimeout(()=>{hi(e,x),p(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},a),N=re.current.get(e)??[];re.current.set(e,[...N,{resolve:f,reject:p,timerId:x}])})}function di(e,a){const s=re.current.get(e)??[];s.length!==0&&(re.current.delete(e),s.forEach(u=>{window.clearTimeout(u.timerId),u.resolve(a)}))}function hi(e,a){const u=(re.current.get(e)??[]).filter(f=>f.timerId!==a);if(u.length===0){re.current.delete(e);return}re.current.set(e,u)}function Ut(){for(const[e,a]of re.current.entries())a.forEach(s=>{window.clearTimeout(s.timerId),s.reject(new Error(`FILE_TREE_ABORTED:${e}`))});re.current.clear()}function $e(e){$([e]),R(e.path)}function st(e){F(e.kind==="directory"?e.path:he(e.path))}function mi(e){const a=sa(ui,ne,e);$(a),R(e.path),st(e)}function pi(e){const a=la(K,e),s=Un(a);$(a),R(e.path),s&&st(s)}function Cn(e){$e(e),st(e)}function Oe(e,a){if(a!=null&&a.shiftKey){mi(e);return}if(Ct(a)){pi(e);return}Cn(e)}async function rt(e,a=!1){const s=ut(e,a);if(!s.length){F(g);return}Le(u=>si(u,s)),F(s[s.length-1]??g);for(const u of s)try{await Pn(u)}catch{return}}async function ce(e){const a=z(e,"file");$e(a),st(a),await rt(e)}async function He(e){Ye(e),ye(null),tt.current=null,xe.current+=1,ce(e);const a=xe.current,s=e.replace(/\\/g,"/"),u=W.statusByPath.get(s);if(l&&u&&u!=="?"&&u!=="D")try{const f=await Li(l,e,!1);xe.current===a&&ye(f.content||null)}catch{xe.current===a&&ye(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<=Ji}function Ce(){tt.current=null}async function bi(e,a){const s=z(e,"file");if(a!=null&&a.shiftKey||Ct(a)){Ce(),Oe(s,a);return}if(jn(e)){await He(e);return}Oe(s,a),await rt(e)}function Sn(){Xe(!1),qe(""),G(null),Ce()}async function vi(e,a){const s=z(e.path,e.kind);if(a!=null&&a.shiftKey||Ct(a)){Ce(),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 ce(e.path)}async function wn(e){if($e(z(e,"directory")),F(e),!_.current.includes(e))try{await Pn(e),Le(a=>Et(a,e))}catch{}}async function Nn(e){if($e(z(e,"directory")),F(e),_.current.includes(e)){Dn(e);return}await wn(e)}function Dn(e){Le(a=>a.filter(s=>s!==e&&!s.startsWith(`${e}/`))),F(he(e)),$([]),R(null)}async function kn(){if(!l)return;const e=l;try{if(pe(e),await Pe(),ge&&await rt(ge),oe&&A.trim()){const a=await Ve(e,A.trim());G(a.items)}}catch(a){S({title:te(a,r("conversation.filePanelLoadFailed")),tone:"error"})}}async function yi(e){if(e==null||e.preventDefault(),!l||!A.trim()){G(null);return}mt(!0);try{const a=await Ve(l,A.trim());G(a.items)}catch(a){S({title:te(a,r("conversation.filePanelSearchFailed")),tone:"error"})}finally{mt(!1)}}function En(){if(Ge){Xe(!1),qe(""),G(null);return}Xe(!0)}function q(e){L(!1),e()}function Mn(){var e;(e=hn.current)==null||e.click()}async function xi(e){var p;const a=((p=e.target.files)==null?void 0:p[0])??null;if(e.target.value="",!a||!l)return;const s=aa(a.name);if(!s){S({title:r("conversation.filePanelUploadFailed"),tone:"error"});return}const u=Hn(D,E),f=zn(u,s);dt(!0);try{const x=await ba(a);await Bi({workspaceId:l,path:f,contentBase64:x}),await Pe(),await ce(f),S({title:r("conversation.filePanelUploadSuccess",{name:s}),tone:"success"})}catch(x){S({title:te(x,r("conversation.filePanelUploadFailed")),tone:"error"})}finally{dt(!1)}}async function Vt(e=ge){if(!(!l||!e)){dt(!0);try{const a=await Wi(l,e),s=va(a.contentBase64);ya(a.fileName,new Blob([s],{type:"application/octet-stream"})),S({title:r("conversation.filePanelDownloadSuccess",{name:a.fileName}),tone:"success"})}catch(a){S({title:te(a,r("conversation.filePanelDownloadFailed")),tone:"error"})}finally{dt(!1)}}}function Rn(){const e=ge?he(ge):D;!e||!_.current.includes(e)||Dn(e)}function Kt(){Ie(null),Ae("")}function Gt(){m||Kt()}function ze(e,a=Hn(D,E)){if(!l)return;const s=a,u=s?`${s}/`:"";Z(!1),L(!1),O(null),Ie({mode:e,baseDirectory:s}),Ae(u)}function Xt(e=E){!l||!e||(Z(!1),L(!1),O(null),Ie({mode:"rename",target:e}),Ae(e.path))}async function gi(e){if(e==null||e.preventDefault(),!l||!w)return;const a=(Bt??"").trim();if(a){if(w.mode==="rename"&&Ke(w.target.path)===Ke(a)){Gt();return}j(!0);try{if(w.mode==="rename"){const s=w.target.path,u=z(a,w.target.kind),f=we?li(we,s,a):null;if(await yt({workspaceId:l,opType:"rename",srcPath:s,dstPath:a}),P&&Lt({...P,items:ma(P.items,s,a)}),Kt(),Ce(),await Pe(),w.target.kind==="directory"?(await rt(a,!0),$e(u),F(a)):await ce(a),f!==we&&(xe.current+=1,Ye(f),ye(null)),oe&&A.trim()){const p=await Ve(l,A.trim());G(p.items)}_e(p=>p+1),S({title:r("conversation.filePanelRenameSuccess",{name:xt(a)||a}),tone:"success"});return}if(await yt({workspaceId:l,opType:w.mode,dstPath:a,content:w.mode==="create_file"?"":void 0}),Kt(),await Pe(),w.mode==="create_directory"?(await rt(a,!0),$e(z(a,"directory")),F(a)):await ce(a),oe&&A.trim()){const s=await Ve(l,A.trim());G(s.items)}_e(s=>s+1)}catch(s){S({title:te(s,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{j(!1)}}}function ue(e,a=at){var u;if(a.length===0)return;const s=jt(a);Lt({mode:e,items:s}),$(s),R(((u=s[s.length-1])==null?void 0:u.path)??null),S({title:e==="copy"?r("conversation.filePanelCopySelectionSuccess",{count:s.length}):r("conversation.filePanelCutSelectionSuccess",{count:s.length}),tone:"success"}),O(null)}async function ot(e=ca(E,D)){if(!l||!P||!P.items.length)return;const a=e??g,s=P.items.map(u=>({source:u,destinationPath:zn(a,xt(u.path)||u.path)}));j(!0);try{for(const p of s)P.mode==="cut"&&Ke(p.source.path)===Ke(p.destinationPath)||await yt({workspaceId:l,opType:P.mode==="copy"?"copy":"move",srcPath:p.source.path,dstPath:p.destinationPath});const u=s.map(p=>z(p.destinationPath,p.source.kind)),f=u[u.length-1]??null;if(P.mode==="cut"&&Lt(null),$(u),R((f==null?void 0:f.path)??null),f&&st(f),Ce(),await Pe({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?he(f.path):Q.current,expandedDirectories:_.current}),oe&&A.trim()){const p=await Ve(l,A.trim());G(p.items)}_e(p=>p+1),S({title:r("conversation.filePanelPasteSuccess",{count:u.length}),tone:"success"}),O(null)}catch(u){await Pe().catch(()=>{}),S({title:te(u,r("conversation.filePanelPasteFailed")),tone:"error"})}finally{j(!1)}}function qt(e=at){!e.length||m||(Fe(jt(e)),O(null))}async function Pi(){var a,s;if(!l||!(B!=null&&B.length))return;const e=jt(B);j(!0);try{for(const p of e)await yt({workspaceId:l,opType:"delete",srcPath:p.path});const u=ua(D,e),f=_.current.filter(p=>!e.some(x=>x.kind==="directory"&&_t(x.path,p)));if(we&&e.some(p=>_t(p.path,we))&&(xe.current+=1,Ye(null),ye(null)),Fe(null),$([]),R(null),Q.current=u,_.current=f,F(u),Le(f),Ce(),await Pe({activeDirectoryPath:u,expandedDirectories:f}),oe&&A.trim()){const p=await Ve(l,A.trim());G(p.items)}_e(p=>p+1),S({title:e.length===1?r("conversation.filePanelDeleteSuccess",{name:xt(((a=e[0])==null?void 0:a.path)??"")||((s=e[0])==null?void 0:s.path)||""}):r("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(u){S({title:te(u,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{j(!1)}}async function Ue(e,a=E){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=ha(s),p=e==="absolute"?da(s,u,f):Ke(u,f);await xa(p,nt),S({title:e==="absolute"?r("conversation.filePanelCopyAbsolutePathSuccess"):r("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){S({title:f instanceof Error?f.message:r("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{Z(!1),O(null)}}function Ci(e,a,s){return[{id:`open-${e.path}`,label:e.kind==="directory"?k.includes(e.path)?r("conversation.filePanelCollapseDirectory"):r("conversation.filePanelExpandDirectory"):r("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){Nn(e.path);return}He(e.path)}},{id:`download-${e.path}`,label:r("conversation.filePanelDownload"),disabled:e.kind!=="file"||v,onSelect:()=>{Vt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:r("conversation.filePanelNewFile"),disabled:!l||m||v,onSelect:()=>{ze("create_file",s)}},{id:`create-directory-${e.path}`,label:r("conversation.filePanelNewDirectory"),disabled:!l||m||v,onSelect:()=>{ze("create_directory",s)}},{id:`rename-${e.path}`,label:r("conversation.filePanelRenameMove"),disabled:a.length!==1||m||v,onSelect:()=>Xt(e)},{id:`copy-${e.path}`,label:r("conversation.filePanelCopy"),disabled:a.length===0,onSelect:()=>ue("copy",a)},{id:`cut-${e.path}`,label:r("conversation.filePanelCut"),disabled:a.length===0,onSelect:()=>ue("cut",a)},{id:`paste-${e.path}`,label:r("conversation.filePanelPaste"),disabled:!lt,onSelect:()=>{ot(s)}},{id:`copy-relative-${e.path}`,label:r("conversation.filePanelCopyRelativePath"),onSelect:()=>{Ue("relative",e)}},{id:`copy-absolute-${e.path}`,label:r("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{Ue("absolute",e)}},{id:`delete-${e.path}`,label:r("conversation.filePanelDelete"),disabled:a.length===0||m||v,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:he(s.path);vt.has(s.path)||Cn(s);const p=Ci(s,u,f);if(nt.isDesktop){await $i(p);return}nt.isWeb&&(Z(!1),L(!1),O({positionX:e.clientX,positionY:e.clientY,items:p}))}c.useEffect(()=>{if(X!=="workspace")return;function e(a){if(!ra(a)||a.altKey||a.shiftKey||oa(a.target))return;const s=a.key.toLowerCase();if(s==="c"&&Ee){a.preventDefault(),ue("copy");return}if(s==="x"&&Ee){a.preventDefault(),ue("cut");return}s==="v"&<&&(a.preventDefault(),ot())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[X,Ee,lt,ue,ot]);function Yt(e,a){return n.jsx(n.Fragment,{children:e.map(s=>{const u=z(s.path,s.kind),f=s.kind==="directory",p=f&&k.includes(s.path),x=f&&je.includes(s.path),N=De[s.path]??[],fe=J?tn(N,De,W.statusByPath,W.changedDirs):N,Si=vt.has(s.path),wi=Ot===s.path,ct=W.statusByPath.get(s.path.replace(/\\/g,"/")),An=f&&W.changedDirs.has(s.path.replace(/\\/g,"/")),Ni=(P==null?void 0:P.mode)==="cut"&&P.items.some(de=>de.path===s.path);return n.jsxs("div",{className:"file-tree-node",children:[n.jsxs("button",{className:"file-tree-item",type:"button","data-active":wi,"data-selected":Si,"data-cut-pending":Ni||void 0,"data-kind":s.kind,"aria-expanded":f?p:void 0,style:{paddingInlineStart:`${na+a*ia}px`},onClick:de=>{if(f){if(de.shiftKey||Ct(de)){Ce(),Oe(u,de);return}Ce(),Oe(u,de),Nn(s.path);return}bi(s.path,de)},onContextMenu:de=>{_n(de,s)},children:[n.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:p?"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:r("common.loading")}):null]}),f&&p?n.jsx("div",{className:"file-tree-children",children:x&&!N.length?n.jsx("p",{className:"file-tree-empty",children:r("common.loading")}):fe.length?Yt(fe,a+1):n.jsx("p",{className:"file-tree-empty",children:r("conversation.filePanelEmptyDirectory")})}):null]},`${s.kind}-${s.path}`)})})}function ji(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:p=>{vi(a,p)},onContextMenu:p=>{_n(p,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(Oi,{workspaceId:l,filePath:we,open:we!==null,onClose:()=>{xe.current+=1,Ye(null),ye(null)},onSaved:async e=>{await Pe(),await ce(e),_e(a=>a+1)},diffContent:oi}),o?null:n.jsx("div",{className:"file-panel-heading-row",children:n.jsx("h2",{className:"file-panel-heading",children:r("conversation.filePanelTitle")})}),h?null:n.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":r("conversation.filePanelTitle"),children:[n.jsx("button",{className:X==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":X==="workspace",onClick:()=>Ze("workspace"),children:r("conversation.filePanelWorkspaceTab")}),n.jsxs("button",{className:X==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":X==="session",onClick:()=>{it&&Ze("session")},disabled:!it,children:[r("conversation.filePanelSessionTab"),n.jsx("span",{className:"file-panel-tab-badge","aria-label":`${r("conversation.filePanelSessionTab")} ${rn}`,children:rn})]})]}),X==="workspace"?n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:hn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void xi(e)}),pn?n.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":r("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":r("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":Qe,"data-active":Qe,onClick:()=>{Z(!1),L(e=>!e)},children:[n.jsx("span",{children:r("conversation.filePanelActionsMenu")}),n.jsx(Ba,{})]}),Qe?n.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":r("conversation.filePanelActionsMenu"),children:[n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ue("copy")),disabled:!Ee,children:r("conversation.filePanelCopy")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ue("cut")),disabled:!Ee,children:r("conversation.filePanelCut")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ot()),disabled:!lt||m||v,children:r("conversation.filePanelPaste")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),En()},children:Ge?r("conversation.filePanelHideSearch"):r("conversation.filePanelShowSearch")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Wt(e=>!e)},disabled:pt.length===0,children:J?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(kn),disabled:Re||m||ht,children:r("conversation.filePanelRefresh")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Rn()},disabled:!xn,children:r("conversation.filePanelCollapseCurrent")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Mn()},disabled:m||v,children:r("conversation.filePanelUpload")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(Vt),disabled:!bn||v,children:r("conversation.filePanelDownload")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(Xt),disabled:!yn||m||v,children:r("conversation.filePanelRenameMove")}),n.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>q(qt),disabled:!vn||m||v,children:r("conversation.filePanelDelete")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ze("create_file")),disabled:m||v,children:r("conversation.filePanelNewFile")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ze("create_directory")),disabled:m||v,children:r("conversation.filePanelNewDirectory")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>Ue("absolute")),disabled:!Ht,children:r("conversation.filePanelCopyAbsolutePath")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>Ue("relative")),disabled:!Ht,children:r("conversation.filePanelCopyRelativePath")})]}):null]})}):n.jsxs("div",{className:"file-panel-toolbar","aria-label":r("conversation.filePanelTitle"),children:[n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopy"),"aria-label":r("conversation.filePanelCopy"),onClick:()=>ue("copy"),disabled:!Ee,children:n.jsx(ka,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCut"),"aria-label":r("conversation.filePanelCut"),onClick:()=>ue("cut"),disabled:!Ee,children:n.jsx(Ea,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelPaste"),"aria-label":r("conversation.filePanelPaste"),onClick:()=>void ot(),disabled:!lt||m||v,children:n.jsx(Ma,{})}),n.jsxs("div",{className:"file-toolbar-menu-shell",ref:fn,children:[n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopyPath"),"aria-label":r("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":Je,"data-active":Je,onClick:()=>{L(!1),Z(e=>!e)},disabled:!Ht,children:n.jsx(Da,{})}),Je?n.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[n.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ue("absolute"),children:r("conversation.filePanelCopyAbsolutePath")}),n.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ue("relative"),children:r("conversation.filePanelCopyRelativePath")})]}):null]}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCollapseCurrent"),"aria-label":r("conversation.filePanelCollapseCurrent"),onClick:Rn,disabled:!xn,children:n.jsx(wa,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRefresh"),"aria-label":r("conversation.filePanelRefresh"),onClick:()=>void kn(),disabled:Re||m||ht,children:n.jsx(Na,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),"data-active":Ge,onClick:En,disabled:Re,children:n.jsx(qn,{})}),pt.length>0?n.jsx("button",{className:"file-toolbar-button",type:"button",title:J?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"aria-label":J?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"data-active":J,onClick:()=>Wt(e=>!e),children:n.jsx(Wa,{})}):null,n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelUpload"),"aria-label":r("conversation.filePanelUpload"),onClick:Mn,disabled:m||v,children:n.jsx(_a,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelDownload"),"aria-label":r("conversation.filePanelDownload"),onClick:()=>void Vt(),disabled:!bn||v,children:n.jsx(Ta,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRenameMove"),"aria-label":r("conversation.filePanelRenameMove"),onClick:()=>Xt(),disabled:!yn||m||v,children:n.jsx(La,{})}),n.jsx("button",{className:"file-toolbar-button danger",type:"button",title:r("conversation.filePanelDelete"),"aria-label":r("conversation.filePanelDelete"),onClick:()=>qt(),disabled:!vn||m||v,children:n.jsx(Fa,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewFile"),"aria-label":r("conversation.filePanelNewFile"),onClick:()=>void ze("create_file"),disabled:m||v,children:n.jsx(Ra,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewDirectory"),"aria-label":r("conversation.filePanelNewDirectory"),onClick:()=>void ze("create_directory"),disabled:m||v,children:n.jsx(Aa,{})})]}),ae&&typeof document<"u"?ki.createPortal(n.jsx("div",{className:"file-web-context-menu",ref:$t,role:"menu","aria-label":r("conversation.filePanelActionsMenu"),style:{left:`${(ve==null?void 0:ve.left)??Math.max(8,ae.positionX)}px`,top:`${(ve==null?void 0:ve.top)??Math.max(8,ae.positionY)}px`,maxHeight:ve?`${ve.maxHeight}px`:void 0},children:ae.items.map(e=>n.jsx("button",{className:["file-web-context-menu-item",e.label===r("conversation.filePanelDelete")?"danger":""].filter(Boolean).join(" "),type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>{O(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 yi(e),children:[n.jsx("input",{value:A,onChange:e=>qe(e.target.value),placeholder:r("conversation.filePanelSearchPlaceholder")}),pn?n.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":r("conversation.filePanelSearchButton"),disabled:ht,children:r("conversation.filePanelSearchButton")}):n.jsx("button",{className:"file-toolbar-button",type:"submit",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),disabled:ht,children:n.jsx(qn,{})})]}):null,n.jsx("div",{ref:ci,className:"file-tree","data-search-mode":oe,"data-scrollbar-autohide":"true",children:Re&&Be.length===0?n.jsx("p",{className:"file-tree-status status-text",children:r("common.loading")}):oe?ke!=null&&ke.length?ji(ke):n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSearchEmpty")}):J?bt.length?Yt(bt,0):n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelNoChanges")}):Be.length?Yt(Be,0):n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelEmptyDirectory")})}),n.jsx(Ln,{open:w!==null,title:(H==null?void 0:H.title)??"",description:H==null?void 0:H.description,onClose:Gt,children:n.jsxs("form",{className:"workbench-rename-form",onSubmit:e=>void gi(e),children:[n.jsx(Ri,{label:r("conversation.filePanelPathFieldLabel"),htmlFor:un,description:(w==null?void 0:w.mode)==="rename"?w.target.path:(w==null?void 0:w.baseDirectory)||void 0,children:n.jsx("input",{id:un,type:"text",value:Bt??"",placeholder:r("conversation.filePanelPathFieldPlaceholder"),autoFocus:!0,onChange:e=>Ae(e.target.value)})}),n.jsxs(_i,{children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:m,onClick:Gt,children:r("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:m||!(Bt??"").trim(),children:m?(H==null?void 0:H.pendingLabel)??r("common.loading"):(H==null?void 0:H.submitLabel)??r("common.save")})]})]})}),n.jsxs(Ln,{open:B!==null,title:r("conversation.filePanelDeleteConfirmTitle"),description:r("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{m||Fe(null)},children:[n.jsx("p",{className:"workbench-section-empty",children:B!=null&&B.length?B.length===1?((Fn=B[0])==null?void 0:Fn.kind)==="directory"?r("conversation.filePanelDeleteDirectoryConfirm",{path:B[0].path}):r("conversation.filePanelDeleteFileConfirm",{path:B[0].path}):r("conversation.filePanelDeleteSelectionConfirm",{count:B.length}):""}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:m,onClick:()=>Fe(null),children:r("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:m,onClick:()=>{Pi()},children:m?r("conversation.filePanelDeleting"):r("conversation.filePanelDelete")})]})]})]}):it&&i?n.jsx(Yi,{sessionId:i,workspaceId:l,showSystemFiles:I,selectedPath:ge,refreshVersion:sn,onCountChange:At,onSelectFile:ce,onOpenFile:He}):n.jsx("section",{className:"file-panel-section",children:n.jsx("p",{className:"status-text",children:r("conversation.filePanelSessionNoSession")})})]}):n.jsx("section",{className:"file-panel-section",children:n.jsx("p",{className:"status-text",children:r("conversation.filePanelNoWorkspace")})})})}function he(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):g}function ut(t,i=!1){const l=t.split("/").filter(Boolean),o=i?l.length:l.length-1,h=[];for(let d=0;d<o;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?he(i.path):g)}function zn(t,i){return t?`${t}/${i}`:i}function aa(t){var i;return((i=t.split(/[/\\]/).pop())==null?void 0:i.trim())??""}function z(t,i){return{path:t,kind:i}}function Un(t){return t[t.length-1]??null}function la(t,i){return t.findIndex(o=>o.path===i.path)>=0?t.filter(o=>o.path!==i.path):[...t,i]}function sa(t,i,l){const o=t.findIndex(y=>y.path===l.path);if(o<0)return[l];const h=i?t.findIndex(y=>y.path===i):o;if(h<0)return[l];const d=Math.min(h,o),b=Math.max(h,o);return t.slice(d,b+1)}function Ct(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function ra(t){return t.ctrlKey||t.metaKey}function oa(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(o=>[o.path,o])).values()].sort((o,h)=>o.path.localeCompare(h.path)),l=[];for(const o of i)l.some(h=>h.kind==="directory"&&_t(h.path,o.path))||l.push(o);return l}function ca(t,i){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?he(t.path):i}function ua(t,i){let l=t;for(;l&&i.some(o=>o.kind==="directory"&&_t(o.path,l));)l=he(l);return l}function ni(t,i,l,o,h,d){const b=[];for(const y of t){if(b.push(z(y.path,y.kind)),y.kind!=="directory"||!l.includes(y.path))continue;const C=i[y.path]??[],T=o?tn(C,i,h,d):C;b.push(...ni(T,i,l,o,h,d))}return b}function fa(t,i,l){const o=Math.max(0,l.width),h=Math.max(0,l.height),d=Math.max(0,h-ee*2),b=Math.max(0,o-ee*2),y=Math.min(Math.max(i.width,0),b),C=Math.max(0,h-t.y-Pt-ee),T=Math.max(0,t.y-Pt-ee),M=C<i.height&&T>C,me=Qt(Math.max(M?T:C,Ii),0,d),U=Math.min(Math.max(i.height,0),me),pe=M?t.y-Pt-U:t.y+Pt,be=Math.max(ee,h-ee-U),V=Math.max(ee,o-ee-y);return{top:Qt(pe,ee,be),left:Qt(t.x,ee,V),maxHeight:Math.max(0,me)}}function Qt(t,i,l){return!Number.isFinite(t)||l<i?i:Math.min(Math.max(t,i),l)}function Ke(t,i="posix"){return t?ii(t,i):"."}function da(t,i,l){const o=ii(t,l),h=Ke(i,l).replace(/^\.[/\\]?/,"");if(!h)return o;const d=ai(l),b=h.replace(/^[/\\]+/,"");return b?o.endsWith("/")||o.endsWith("\\")?`${o}${b}`:`${o}${d}${b}`:o}function ha(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function ii(t,i){return t&&(ai(i)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function ai(t){return t==="windows"?"\\":"/"}function _t(t,i){return i===t||i.startsWith(`${t}/`)}function li(t,i,l){return t===i?l:t.startsWith(`${i}/`)?`${l}${t.slice(i.length)}`:t}function ma(t,i,l){return t.map(o=>({...o,path:li(o.path,i,l)}))}function pa(t){return t.mode==="create_file"?{title:r("conversation.filePanelNewFile"),description:r("conversation.filePanelCreateFileDescription"),submitLabel:r("conversation.filePanelCreateFileSubmit"),pendingLabel:r("conversation.filePanelCreatingFile")}:t.mode==="create_directory"?{title:r("conversation.filePanelNewDirectory"),description:r("conversation.filePanelCreateDirectoryDescription"),submitLabel:r("conversation.filePanelCreateDirectorySubmit"),pendingLabel:r("conversation.filePanelCreatingDirectory")}:{title:r("conversation.filePanelRenameMove"),description:r("conversation.filePanelRenameDescription"),submitLabel:r("conversation.filePanelRenameSubmit"),pendingLabel:r("conversation.filePanelRenaming")}}async function ba(t){const i=await t.arrayBuffer(),l=new Uint8Array(i),o=32768;let h="";for(let d=0;d<l.length;d+=o){const b=l.subarray(d,d+o);h+=String.fromCharCode(...b)}return btoa(h)}function va(t){const i=atob(t),l=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)l[o]=i.charCodeAt(o);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}function ya(t,i){if(typeof document>"u")throw new Error(r("conversation.filePanelDownloadFailed"));const l=window.URL.createObjectURL(i),o=document.createElement("a");o.href=l,o.download=t,document.body.append(o),o.click(),o.remove(),window.URL.revokeObjectURL(l)}async function xa(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(!ga(t))throw new Error(r("conversation.filePanelCopyPathFailed"))}}function ga(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 Pa(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(o=>l.includes(o))}function St(t,i,l){const o=ln(i,l);return Object.entries(t).reduce((h,[d,b])=>(o.has(d)&&(h[d]=b),h),{})}function Ca(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]),o=si(i,ut(t,!0));for(const h of o){l.add(h);for(const d of ut(h,!0))l.add(d)}return l}function ja(t,i){const l=Object.keys(t),o=Object.keys(i);return l.length!==o.length?!1:l.every(h=>t[h]===i[h])}function Et(t,i){return t.includes(i)?t:[...t,i]}function si(t,i){return i.reduce((l,o)=>Et(l,o),t)}function Kn(t){return`file-panel.workspace-tree.${t}`}function Sa(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 te(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 wa(){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 Na(){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 Da(){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 ka(){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 Ea(){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 Ma(){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 Ra(){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 _a(){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 Ta(){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 Fa(){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 Aa(){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 La(){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 Ba(){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 Wa(){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,o){const h=[];for(const d of t){const b=d.path.replace(/\\/g,"/");d.kind==="file"?l.has(b)&&h.push(d):ri(b,i,l,o)&&h.push(d)}return h}function ri(t,i,l,o,h){const d=h??new Set;if(d.has(t))return!1;d.add(t);const b=i[t];if(!b)return o.has(t);for(const y of b){const C=y.path.replace(/\\/g,"/");if(y.kind==="file"){if(l.has(C))return!0}else if(ri(C,i,l,o,d))return!0}return!1}export{qa as FileContextPanel};
|
|
1
|
+
import{b as c,j as n,t as r,A as Yn}from"./index-DvkfRpBe.js";import{f as Zn,e as Di,g as ki}from"./App-BRupl2Ul.js";import{aq as Ei,u as Mi,h as Ri,v as _i}from"./model-switch-api-Dps4yN2t.js";import{bh as Ti,bi as Jn,b as en,w as wt,bj as Fi,u as Ai,ac as Me,bk as Li,bl as yt,bm as Ve,bn as Bi,bo as Wi,bp as $i}from"./WorkbenchLayout-Cht6Un5X.js";import{W as Ln}from"./WorkbenchModal-CAj_TqWW.js";import{r as Mt,a as Rt,F as Oi}from"./file-tree-icon-CLfk31E7.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-WiotM2TL.js";const Hi=new Set([".ds_store","thumbs.db","ehthumbs.db","desktop.ini",".spotlight-v100",".trashes",".fseventsd","__macosx","$recycle.bin","system volume information",".apdisk",".appledouble",".temporaryitems"]),zi=["._"];function xt(t){return t.split(/[/\\]/).filter(Boolean).pop()??t}function Ui(t){const i=t.trim().toLowerCase();return i?Hi.has(i)||zi.some(l=>i.startsWith(l)):!1}function nn(t,i,l){return l?[...t]:t.filter(o=>!Ui(i(o)))}function Nt(t,i){return nn(t,l=>l.name,i)}function Vi(t,i){return i?t:Object.entries(t).reduce((l,[o,h])=>(l[o]=Nt(h,!1),l),{})}async function Zt(t,i){const[l,o]=await Promise.all([Ti(i),Ei(t)]);return Ki(l.changes,o.items)}function Ki(t,i){const l=new Set(i.map(o=>kt(o.path)));return t.filter(o=>l.has(kt(o.path))||o.oldPath!==null&&l.has(kt(o.oldPath)))}function Gi(t){const i=Bn("","");for(const l of t){const o=kt(l.path),h=o.split("/").filter(Boolean);let d=i;h.forEach((b,y)=>{const C=h.slice(0,y+1).join("/");if(y===h.length-1){d.children.set(`file:${C}`,{kind:"file",name:b,path:o,change:l});return}const T=`directory:${C}`,M=d.children.get(T);if(M&&M.kind==="directory"){d=M;return}const Y=Bn(b,C);d.children.set(T,Y),d=Y})}return ei(In([...i.children.values()]))}function Qn(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 kt(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function Bn(t,i){return{kind:"directory",name:t,path:i,children:new Map}}function In(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:In([...i.children.values()])}:i)}function ei(t){return t.map(i=>{var b;if(i.kind!=="directory")return i;const l=ei(i.children);let o=i.name,h=i.path,d=l;for(;d.length===1&&((b=d[0])==null?void 0:b.kind)==="directory";){const y=d[0];o=`${o}/${y.name}`,h=y.path,d=y.children}return{kind:"directory",name:o,path:h,children:d}})}const Xi=450,qi=60*1e3,Wn=20,$n=16;function Yi({sessionId:t,workspaceId:i,showSystemFiles:l,selectedPath:o,refreshVersion:h,onCountChange:d,onSelectFile:b,onOpenFile:y}){const[C,T]=c.useState("tree"),[M,Y]=c.useState([]),[me,U]=c.useState(!0),[pe,be]=c.useState(!1),[V,ft]=c.useState([]),k=c.useRef(null),Tt=Jn(),{showToast:je}=Zn();c.useEffect(()=>{const m=en(gt(i,t),qi);T("tree"),Y(m??[]),U(m===null),be(!1),ft([]),k.current=null},[t,i]),c.useEffect(()=>{let m=!1;async function j(){U(!0);try{const v=await Zt(t,i);m||(Y(v),wt(gt(i,t),v))}catch(v){m||je({title:Jt(v,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{m||U(!1)}}return j(),()=>{m=!0}},[h,t,je,i]);async function Se(){U(!0);try{const m=await Zt(t,i);Y(m),wt(gt(i,t),m)}catch(m){je({title:Jt(m,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{U(!1)}}async function D(){if(R.length!==0){be(!0);try{await Fi(i,R.map(j=>j.path));const m=await Zt(t,i);Y(m),wt(gt(i,t),m),je({title:r("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(m){je({title:Jt(m,r("git.stageFailed")),tone:"error"})}finally{be(!1)}}}function F(m){ft(j=>j.includes(m)?j.filter(v=>v!==m):[...j,m])}function K(m){const j=Date.now(),v=k.current;return k.current={filePath:m,timestamp:j},(v==null?void 0:v.filePath)===m&&j-v.timestamp<=Xi}async function $(m,j){if(j&&K(m)){await y(m),k.current=null;return}j||(k.current=null),await b(m)}const ne=c.useMemo(()=>nn(M,m=>Dt(m.path),l),[M,l]),R=ne.filter(m=>!m.staged),Re=Gi(ne),ie=new Set(V);return c.useEffect(()=>{d==null||d(ne.length)},[d,ne.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":r("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:()=>T("tree"),children:r("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:()=>T("list"),children:r("conversation.filePanelSessionListView")})]}),n.jsxs("div",{className:"file-panel-session-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Se(),disabled:me||pe,children:r("conversation.filePanelRefresh")}),n.jsx("button",{className:"primary-button",type:"button",onClick:()=>void D(),disabled:pe||R.length===0,children:r("conversation.filePanelSessionStageAll")})]})]}),n.jsxs("div",{className:"file-panel-session-summary",children:[n.jsx("span",{children:`${r("conversation.filePanelSessionSummary")} ${ne.length}`}),n.jsx("span",{children:`${r("conversation.filePanelSessionUnstagedSummary")} ${R.length}`})]}),n.jsx("div",{ref:Tt,className:"file-tree","data-scrollbar-autohide":"true",children:me?n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionLoading")}):ne.length===0?n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionEmpty")}):C==="tree"?ti({nodes:Re,depth:0,collapsedPathSet:ie,selectedPath:o,onToggleTreePath:F,onFileClick:$}):Zi({items:ne,selectedPath:o,onFileClick:$})})]})}function ti({nodes:t,depth:i,collapsedPathSet:l,selectedPath:o,onToggleTreePath:h,onFileClick:d}){return t.map(b=>{if(b.kind==="directory"){const y=!l.has(b.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(b.path),children:[n.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:y?"v":">"}),n.jsx("span",{className:"file-tree-label",children:b.name})]}),y?n.jsx("div",{className:"file-tree-children",children:ti({nodes:b.children,depth:i+1,collapsedPathSet:l,selectedPath:o,onToggleTreePath:h,onFileClick:d})}):null]},`session-directory:${b.path}`)}return n.jsx("div",{className:"file-tree-node",children:n.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":o===b.change.path,"data-kind":"file",style:{paddingInlineStart:`${Wn+i*$n}px`},onClick:()=>void d(b.change.path,!an(b.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(b.name),"aria-hidden":"true",children:Mt(b.name)}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:b.name}),n.jsx("span",{className:"file-tree-path",children:Qn(b.change,r("conversation.filePanelSessionDeleted"))})]}),n.jsxs("span",{className:"file-session-item-meta",children:[n.jsx("span",{className:"file-session-badge","data-status":b.change.status,children:b.change.status}),n.jsx("span",{className:"file-session-badge subtle",children:b.change.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-file:${b.path}`)})}function Zi({items:t,selectedPath:i,onFileClick:l}){return t.map(o=>n.jsx("div",{className:"file-session-list-item",children:n.jsxs("button",{className:"file-session-list-button",type:"button","data-active":i===o.path,onClick:()=>void l(o.path,!an(o)),children:[n.jsx("span",{className:"git-tree-file-icon","data-kind":Rt(Dt(o.path)),"aria-hidden":"true",children:Mt(Dt(o.path))}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:Dt(o.path)}),n.jsx("span",{className:"file-tree-path",children:Qn(o,r("conversation.filePanelSessionDeleted"))})]}),n.jsxs("span",{className:"file-session-item-meta",children:[n.jsx("span",{className:"file-session-badge","data-status":o.status,children:o.status}),n.jsx("span",{className:"file-session-badge subtle",children:o.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-list:${o.path}`))}function gt(t,i){return`file-panel.session-changes.${t}.${i}`}function Jt(t,i){return t instanceof Yn?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??i):i}const g="",Ji=450,ee=8,Pt=4,Qi=176,Ii=120,ea=300*1e3,ta=60*1e3,On=1600,na=20,ia=16;function qa({className:t,sessionId:i,workspaceId:l,hideHeading:o=!1,hideTabs:h=!1,externalRevealRequest:d=null,externalWindowMode:b=!1,workbenchShellOverrides:y}){var Tn,Fn;const C=Ai(),{navigationGroups:T,subscribeFileTree:M,requestFileTreeRefresh:Y,addFileTreeSnapshotListener:me,subscribeGitSnapshot:U,requestGitRefresh:pe,addGitSnapshotListener:be}={...C,...y},[V,ft]=c.useState({}),[k,Tt]=c.useState([]),[je,Se]=c.useState([]),[D,F]=c.useState(g),[K,$]=c.useState([]),[ne,R]=c.useState(null),[Re,ie]=c.useState(!1),[m,j]=c.useState(!1),[v,dt]=c.useState(!1),[Ge,Xe]=c.useState(!1),[A,qe]=c.useState(""),[Ft,G]=c.useState(null),[ht,mt]=c.useState(!1),[we,Ye]=c.useState(null),[X,Ze]=c.useState("workspace"),[sn,_e]=c.useState(0),[rn,At]=c.useState(0),[Je,Z]=c.useState(!1),[Qe,L]=c.useState(!1),[ae,O]=c.useState(null),[ve,Te]=c.useState(null),[B,Fe]=c.useState(null),[P,Lt]=c.useState(null),[w,Ie]=c.useState(null),[Bt,Ae]=c.useState(""),[on,cn]=c.useState([]),[J,Wt]=c.useState(!1),[oi,ye]=c.useState(null),un=c.useId(),le=c.useRef({}),se=c.useRef({}),_=c.useRef([]),Q=c.useRef(g),et=c.useRef(!1),tt=c.useRef(null),ci=Jn(),fn=c.useRef(null),dn=c.useRef(null),$t=c.useRef(null),hn=c.useRef(null),mn=c.useRef(null),xe=c.useRef(0),re=c.useRef(new Map),{showToast:S}=Zn(),nt=Di(),I=Mi(e=>e.showSystemFiles),it=!!(i!=null&&i.trim()),pn=o&&nt.isMobile;c.useEffect(()=>{Me("file_panel.props",{sessionId:i,workspaceId:l,externalWindowMode:b})},[b,i,l]),c.useEffect(()=>{Q.current=D},[D]);function Ne(e){ft(a=>{const s=typeof e=="function"?e(a):e;return le.current=s,s})}function Le(e){Tt(a=>{const s=typeof e=="function"?e(a):e;return _.current=s,s})}c.useEffect(()=>{var f,p;if(Ut(),!l){Ut(),et.current=!1,le.current={},se.current={},_.current=[],Q.current=g,Ne({}),Le([]),Se([]),F(g),Xe(!1),qe(""),G(null),mt(!1),ie(!1),Wt(!1),ye(null),$([]),R(null),O(null),Te(null),Fe(null),Ie(null),Ae("");return}et.current=!0;const e=en(Kn(l),ea);Me("file_panel.workspace_snapshot",{workspaceId:l,cached:!!e,cachedRootItems:((p=(f=e==null?void 0:e.treeCache)==null?void 0:f[g])==null?void 0:p.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const a=Pa((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);le.current=u,se.current=Gn((e==null?void 0:e.treeRevisionByPath)??{},u),_.current=s,Q.current=a,Ne(u),Le(s),Se([]),F(a),ie(!1),j(!1),Xe(!1),qe(""),G(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,Ze("workspace"),(d.openViewer?He(d.filePath):ce(d.filePath)).catch(s=>{S({title:te(s,r("conversation.filePanelOpenFailed")),tone:"error"})})};if(et.current){queueMicrotask(e);return}e()},[d,He,ce,S,l]),c.useEffect(()=>{if(l)return me(e=>{e.workspaceId===l&&(se.current={...se.current,[e.path]:typeof e.revision=="string"?e.revision:null},Ne(a=>({...a,[e.path]:e.items})),e.path===g&&ie(!1),Se(a=>a.filter(s=>s!==e.path)),di(e.path,e.items))})},[me,l]),c.useEffect(()=>()=>{Ut()},[]),c.useEffect(()=>{l&&M(l,It(_.current,Q.current),{knownRevisionByPath:se.current})},[D,k,M,l]),c.useEffect(()=>{$([]),R(null),Ye(null),ye(null),_e(0),Z(!1),L(!1),O(null),Te(null),Fe(null),Ie(null),Ae(""),tt.current=null,xe.current+=1},[i]),c.useEffect(()=>{!it&&X==="session"&&Ze("workspace")},[X,it]),c.useEffect(()=>{h&&X!=="workspace"&&Ze("workspace")},[X,h]),c.useEffect(()=>{if(!Je&&!Qe&&!ae)return;function e(s){var x,N,fe;if(!(s.target instanceof Node))return;const u=((x=fn.current)==null?void 0:x.contains(s.target))??!1,f=((N=dn.current)==null?void 0:N.contains(s.target))??!1,p=((fe=$t.current)==null?void 0:fe.contains(s.target))??!1;!u&&!f&&!p&&(Z(!1),L(!1),O(null),Te(null))}function a(s){s.key==="Escape"&&(Z(!1),L(!1),O(null),Te(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",a)}},[Je,Qe,ae]),c.useLayoutEffect(()=>{if(!ae||typeof window>"u"){Te(null);return}const e=ae;function a(){const u=$t.current;if(!u)return;const f=u.getBoundingClientRect();Te(fa({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)}},[ae]),c.useEffect(()=>{if(!l)return;const e=Vn(k,D),a=St(V,D,e);wt(Kn(l),{treeCache:a,treeRevisionByPath:Gn(se.current,a),expandedDirectories:e,activeDirectoryPath:D})},[D,k,V,l]),c.useEffect(()=>{if(et.current)return;const e=St(V,D,k);ja(V,e)||Ne(e)},[D,k,V]),c.useEffect(()=>{let e=!1;const a=(l==null?void 0:l.trim())??null;async function s(f){if(!a)return;const p=Nt(le.current[g]??[],I),x=(f==null?void 0:f.silent)!==!0&&p.length===0;x&&ie(!0),Me("file_panel.load_root_tree.start",{sessionId:i,workspaceId:a,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:p.length});try{const N=await zt(g,{force:!0});e||(Me("file_panel.load_root_tree.end",{sessionId:i,workspaceId:a,itemCount:N.length}),Ne(fe=>({...St(fe,Q.current,_.current),[g]:N})))}catch(N){!e&&!Xn(N)&&S({title:te(N,r("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&x&&ie(!1)}}if(Nt(le.current[g]??[],I).length>0){const f=window.setTimeout(()=>{a&&(M(a,It(_.current,Q.current),{knownRevisionByPath:se.current}),s({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return s(),()=>{e=!0}},[i,I,S,l]),c.useEffect(()=>{if(!l||!i){At(0);return}const e=en(Sa(l,i),ta);Me("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();U(e),pe(e)},[l,U,pe]),c.useEffect(()=>{if(!l)return;const e=l.trim();return be(a=>{var s;a.workspaceId===e&&cn(((s=a.status)==null?void 0:s.changes)??[])})},[be,l]);const pt=c.useMemo(()=>nn(on,e=>xt(e.path),I),[on,I]),W=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 p=u.split("/");for(let x=1;x<p.length;x++)a.add(p.slice(0,x).join("/"))}return{statusByPath:e,changedDirs:a}},[pt]),De=c.useMemo(()=>Vi(V,I),[I,V]),ke=c.useMemo(()=>Ft===null?null:Nt(Ft,I),[Ft,I]),Be=De[g]??[],oe=Ge&&ke!==null,bt=c.useMemo(()=>J?tn(Be,De,W.statusByPath,W.changedDirs):Be,[W.changedDirs,W.statusByPath,Be,J,De]),ui=c.useMemo(()=>oe?(ke??[]).map(e=>z(e.path,e.kind)):ni(bt,De,k,J,W.statusByPath,W.changedDirs),[k,W.changedDirs,W.statusByPath,oe,J,ke,De,bt]),We=((Tn=T.find(e=>e.workspace.id===l))==null?void 0:Tn.workspace)??null,E=Un(K),Ot=(E==null?void 0:E.path)??null,ge=(E==null?void 0:E.kind)==="file"?E.path:null,vt=c.useMemo(()=>new Set(K.map(e=>e.path)),[K]),at=c.useMemo(()=>jt(K),[K]),Ht=!!(We!=null&&We.path&&K.length===1&&Ot),bn=K.length===1&&(E==null?void 0:E.kind)==="file",vn=at.length>0,Ee=at.length>0,lt=!!(P!=null&&P.items.length&&l),yn=!!l&&K.length===1&&E!==null,xn=!!((ge?he(ge):D)&&k.length),gn=P?P.mode==="copy"?r("conversation.filePanelClipboardCopyReady",{count:P.items.length}):r("conversation.filePanelClipboardCutReady",{count:P.items.length}):null,H=w?pa(w):null;async function Pn(e,a=!1){if(!l)return[];if(!a){const s=le.current[e];if(s)return s}e===g?ie(!0):Se(s=>Et(s,e));try{const s=await zt(e,{force:a});return Ne(u=>({...u,[e]:s})),s}catch(s){throw Xn(s)||S({title:te(s,r("conversation.filePanelLoadFailed")),tone:"error"}),s}finally{e===g?ie(!1):Se(s=>s.filter(u=>u!==e))}}async function Pe(e){if(!l)return;const a=(e==null?void 0:e.activeDirectoryPath)??Q.current,s=(e==null?void 0:e.expandedDirectories)??_.current,u=Ca(le.current,a,s);Me("file_panel.refresh_tree_cache.start",{sessionId:i,workspaceId:l,targetDirectories:u});const p=(await Promise.all(u.map(async x=>{const N=await zt(x,{force:!0});return[x,N]}))).reduce((x,[N,fe])=>(x[N]=fe,x),{});Me("file_panel.refresh_tree_cache.end",{sessionId:i,workspaceId:l,targetDirectories:u,directoryCount:Object.keys(p).length}),Ne(p)}async function zt(e,a){if(!l)return[];if(!(a!=null&&a.force)){const u=le.current[e];if(u)return u}const s=It(Et(_.current,e),e||Q.current);return M(l,s,{knownRevisionByPath:se.current}),Y(l,[e],{knownRevisionByPath:se.current}),fi(e,On,{allowCached:(a==null?void 0:a.force)!==!0})}function fi(e,a=On,s){const u=le.current[e];return(s==null?void 0:s.allowCached)!==!1&&u?Promise.resolve(u):new Promise((f,p)=>{const x=window.setTimeout(()=>{hi(e,x),p(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},a),N=re.current.get(e)??[];re.current.set(e,[...N,{resolve:f,reject:p,timerId:x}])})}function di(e,a){const s=re.current.get(e)??[];s.length!==0&&(re.current.delete(e),s.forEach(u=>{window.clearTimeout(u.timerId),u.resolve(a)}))}function hi(e,a){const u=(re.current.get(e)??[]).filter(f=>f.timerId!==a);if(u.length===0){re.current.delete(e);return}re.current.set(e,u)}function Ut(){for(const[e,a]of re.current.entries())a.forEach(s=>{window.clearTimeout(s.timerId),s.reject(new Error(`FILE_TREE_ABORTED:${e}`))});re.current.clear()}function $e(e){$([e]),R(e.path)}function st(e){F(e.kind==="directory"?e.path:he(e.path))}function mi(e){const a=sa(ui,ne,e);$(a),R(e.path),st(e)}function pi(e){const a=la(K,e),s=Un(a);$(a),R(e.path),s&&st(s)}function Cn(e){$e(e),st(e)}function Oe(e,a){if(a!=null&&a.shiftKey){mi(e);return}if(Ct(a)){pi(e);return}Cn(e)}async function rt(e,a=!1){const s=ut(e,a);if(!s.length){F(g);return}Le(u=>si(u,s)),F(s[s.length-1]??g);for(const u of s)try{await Pn(u)}catch{return}}async function ce(e){const a=z(e,"file");$e(a),st(a),await rt(e)}async function He(e){Ye(e),ye(null),tt.current=null,xe.current+=1,ce(e);const a=xe.current,s=e.replace(/\\/g,"/"),u=W.statusByPath.get(s);if(l&&u&&u!=="?"&&u!=="D")try{const f=await Li(l,e,!1);xe.current===a&&ye(f.content||null)}catch{xe.current===a&&ye(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<=Ji}function Ce(){tt.current=null}async function bi(e,a){const s=z(e,"file");if(a!=null&&a.shiftKey||Ct(a)){Ce(),Oe(s,a);return}if(jn(e)){await He(e);return}Oe(s,a),await rt(e)}function Sn(){Xe(!1),qe(""),G(null),Ce()}async function vi(e,a){const s=z(e.path,e.kind);if(a!=null&&a.shiftKey||Ct(a)){Ce(),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 ce(e.path)}async function wn(e){if($e(z(e,"directory")),F(e),!_.current.includes(e))try{await Pn(e),Le(a=>Et(a,e))}catch{}}async function Nn(e){if($e(z(e,"directory")),F(e),_.current.includes(e)){Dn(e);return}await wn(e)}function Dn(e){Le(a=>a.filter(s=>s!==e&&!s.startsWith(`${e}/`))),F(he(e)),$([]),R(null)}async function kn(){if(!l)return;const e=l;try{if(pe(e),await Pe(),ge&&await rt(ge),oe&&A.trim()){const a=await Ve(e,A.trim());G(a.items)}}catch(a){S({title:te(a,r("conversation.filePanelLoadFailed")),tone:"error"})}}async function yi(e){if(e==null||e.preventDefault(),!l||!A.trim()){G(null);return}mt(!0);try{const a=await Ve(l,A.trim());G(a.items)}catch(a){S({title:te(a,r("conversation.filePanelSearchFailed")),tone:"error"})}finally{mt(!1)}}function En(){if(Ge){Xe(!1),qe(""),G(null);return}Xe(!0)}function q(e){L(!1),e()}function Mn(){var e;(e=hn.current)==null||e.click()}async function xi(e){var p;const a=((p=e.target.files)==null?void 0:p[0])??null;if(e.target.value="",!a||!l)return;const s=aa(a.name);if(!s){S({title:r("conversation.filePanelUploadFailed"),tone:"error"});return}const u=Hn(D,E),f=zn(u,s);dt(!0);try{const x=await ba(a);await Bi({workspaceId:l,path:f,contentBase64:x}),await Pe(),await ce(f),S({title:r("conversation.filePanelUploadSuccess",{name:s}),tone:"success"})}catch(x){S({title:te(x,r("conversation.filePanelUploadFailed")),tone:"error"})}finally{dt(!1)}}async function Vt(e=ge){if(!(!l||!e)){dt(!0);try{const a=await Wi(l,e),s=va(a.contentBase64);ya(a.fileName,new Blob([s],{type:"application/octet-stream"})),S({title:r("conversation.filePanelDownloadSuccess",{name:a.fileName}),tone:"success"})}catch(a){S({title:te(a,r("conversation.filePanelDownloadFailed")),tone:"error"})}finally{dt(!1)}}}function Rn(){const e=ge?he(ge):D;!e||!_.current.includes(e)||Dn(e)}function Kt(){Ie(null),Ae("")}function Gt(){m||Kt()}function ze(e,a=Hn(D,E)){if(!l)return;const s=a,u=s?`${s}/`:"";Z(!1),L(!1),O(null),Ie({mode:e,baseDirectory:s}),Ae(u)}function Xt(e=E){!l||!e||(Z(!1),L(!1),O(null),Ie({mode:"rename",target:e}),Ae(e.path))}async function gi(e){if(e==null||e.preventDefault(),!l||!w)return;const a=(Bt??"").trim();if(a){if(w.mode==="rename"&&Ke(w.target.path)===Ke(a)){Gt();return}j(!0);try{if(w.mode==="rename"){const s=w.target.path,u=z(a,w.target.kind),f=we?li(we,s,a):null;if(await yt({workspaceId:l,opType:"rename",srcPath:s,dstPath:a}),P&&Lt({...P,items:ma(P.items,s,a)}),Kt(),Ce(),await Pe(),w.target.kind==="directory"?(await rt(a,!0),$e(u),F(a)):await ce(a),f!==we&&(xe.current+=1,Ye(f),ye(null)),oe&&A.trim()){const p=await Ve(l,A.trim());G(p.items)}_e(p=>p+1),S({title:r("conversation.filePanelRenameSuccess",{name:xt(a)||a}),tone:"success"});return}if(await yt({workspaceId:l,opType:w.mode,dstPath:a,content:w.mode==="create_file"?"":void 0}),Kt(),await Pe(),w.mode==="create_directory"?(await rt(a,!0),$e(z(a,"directory")),F(a)):await ce(a),oe&&A.trim()){const s=await Ve(l,A.trim());G(s.items)}_e(s=>s+1)}catch(s){S({title:te(s,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{j(!1)}}}function ue(e,a=at){var u;if(a.length===0)return;const s=jt(a);Lt({mode:e,items:s}),$(s),R(((u=s[s.length-1])==null?void 0:u.path)??null),S({title:e==="copy"?r("conversation.filePanelCopySelectionSuccess",{count:s.length}):r("conversation.filePanelCutSelectionSuccess",{count:s.length}),tone:"success"}),O(null)}async function ot(e=ca(E,D)){if(!l||!P||!P.items.length)return;const a=e??g,s=P.items.map(u=>({source:u,destinationPath:zn(a,xt(u.path)||u.path)}));j(!0);try{for(const p of s)P.mode==="cut"&&Ke(p.source.path)===Ke(p.destinationPath)||await yt({workspaceId:l,opType:P.mode==="copy"?"copy":"move",srcPath:p.source.path,dstPath:p.destinationPath});const u=s.map(p=>z(p.destinationPath,p.source.kind)),f=u[u.length-1]??null;if(P.mode==="cut"&&Lt(null),$(u),R((f==null?void 0:f.path)??null),f&&st(f),Ce(),await Pe({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?he(f.path):Q.current,expandedDirectories:_.current}),oe&&A.trim()){const p=await Ve(l,A.trim());G(p.items)}_e(p=>p+1),S({title:r("conversation.filePanelPasteSuccess",{count:u.length}),tone:"success"}),O(null)}catch(u){await Pe().catch(()=>{}),S({title:te(u,r("conversation.filePanelPasteFailed")),tone:"error"})}finally{j(!1)}}function qt(e=at){!e.length||m||(Fe(jt(e)),O(null))}async function Pi(){var a,s;if(!l||!(B!=null&&B.length))return;const e=jt(B);j(!0);try{for(const p of e)await yt({workspaceId:l,opType:"delete",srcPath:p.path});const u=ua(D,e),f=_.current.filter(p=>!e.some(x=>x.kind==="directory"&&_t(x.path,p)));if(we&&e.some(p=>_t(p.path,we))&&(xe.current+=1,Ye(null),ye(null)),Fe(null),$([]),R(null),Q.current=u,_.current=f,F(u),Le(f),Ce(),await Pe({activeDirectoryPath:u,expandedDirectories:f}),oe&&A.trim()){const p=await Ve(l,A.trim());G(p.items)}_e(p=>p+1),S({title:e.length===1?r("conversation.filePanelDeleteSuccess",{name:xt(((a=e[0])==null?void 0:a.path)??"")||((s=e[0])==null?void 0:s.path)||""}):r("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(u){S({title:te(u,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{j(!1)}}async function Ue(e,a=E){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=ha(s),p=e==="absolute"?da(s,u,f):Ke(u,f);await xa(p,nt),S({title:e==="absolute"?r("conversation.filePanelCopyAbsolutePathSuccess"):r("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){S({title:f instanceof Error?f.message:r("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{Z(!1),O(null)}}function Ci(e,a,s){return[{id:`open-${e.path}`,label:e.kind==="directory"?k.includes(e.path)?r("conversation.filePanelCollapseDirectory"):r("conversation.filePanelExpandDirectory"):r("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){Nn(e.path);return}He(e.path)}},{id:`download-${e.path}`,label:r("conversation.filePanelDownload"),disabled:e.kind!=="file"||v,onSelect:()=>{Vt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:r("conversation.filePanelNewFile"),disabled:!l||m||v,onSelect:()=>{ze("create_file",s)}},{id:`create-directory-${e.path}`,label:r("conversation.filePanelNewDirectory"),disabled:!l||m||v,onSelect:()=>{ze("create_directory",s)}},{id:`rename-${e.path}`,label:r("conversation.filePanelRenameMove"),disabled:a.length!==1||m||v,onSelect:()=>Xt(e)},{id:`copy-${e.path}`,label:r("conversation.filePanelCopy"),disabled:a.length===0,onSelect:()=>ue("copy",a)},{id:`cut-${e.path}`,label:r("conversation.filePanelCut"),disabled:a.length===0,onSelect:()=>ue("cut",a)},{id:`paste-${e.path}`,label:r("conversation.filePanelPaste"),disabled:!lt,onSelect:()=>{ot(s)}},{id:`copy-relative-${e.path}`,label:r("conversation.filePanelCopyRelativePath"),onSelect:()=>{Ue("relative",e)}},{id:`copy-absolute-${e.path}`,label:r("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{Ue("absolute",e)}},{id:`delete-${e.path}`,label:r("conversation.filePanelDelete"),disabled:a.length===0||m||v,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:he(s.path);vt.has(s.path)||Cn(s);const p=Ci(s,u,f);if(nt.isDesktop){await $i(p);return}nt.isWeb&&(Z(!1),L(!1),O({positionX:e.clientX,positionY:e.clientY,items:p}))}c.useEffect(()=>{if(X!=="workspace")return;function e(a){if(!ra(a)||a.altKey||a.shiftKey||oa(a.target))return;const s=a.key.toLowerCase();if(s==="c"&&Ee){a.preventDefault(),ue("copy");return}if(s==="x"&&Ee){a.preventDefault(),ue("cut");return}s==="v"&<&&(a.preventDefault(),ot())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[X,Ee,lt,ue,ot]);function Yt(e,a){return n.jsx(n.Fragment,{children:e.map(s=>{const u=z(s.path,s.kind),f=s.kind==="directory",p=f&&k.includes(s.path),x=f&&je.includes(s.path),N=De[s.path]??[],fe=J?tn(N,De,W.statusByPath,W.changedDirs):N,Si=vt.has(s.path),wi=Ot===s.path,ct=W.statusByPath.get(s.path.replace(/\\/g,"/")),An=f&&W.changedDirs.has(s.path.replace(/\\/g,"/")),Ni=(P==null?void 0:P.mode)==="cut"&&P.items.some(de=>de.path===s.path);return n.jsxs("div",{className:"file-tree-node",children:[n.jsxs("button",{className:"file-tree-item",type:"button","data-active":wi,"data-selected":Si,"data-cut-pending":Ni||void 0,"data-kind":s.kind,"aria-expanded":f?p:void 0,style:{paddingInlineStart:`${na+a*ia}px`},onClick:de=>{if(f){if(de.shiftKey||Ct(de)){Ce(),Oe(u,de);return}Ce(),Oe(u,de),Nn(s.path);return}bi(s.path,de)},onContextMenu:de=>{_n(de,s)},children:[n.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:p?"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:r("common.loading")}):null]}),f&&p?n.jsx("div",{className:"file-tree-children",children:x&&!N.length?n.jsx("p",{className:"file-tree-empty",children:r("common.loading")}):fe.length?Yt(fe,a+1):n.jsx("p",{className:"file-tree-empty",children:r("conversation.filePanelEmptyDirectory")})}):null]},`${s.kind}-${s.path}`)})})}function ji(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:p=>{vi(a,p)},onContextMenu:p=>{_n(p,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(Oi,{workspaceId:l,filePath:we,open:we!==null,onClose:()=>{xe.current+=1,Ye(null),ye(null)},onSaved:async e=>{await Pe(),await ce(e),_e(a=>a+1)},diffContent:oi}),o?null:n.jsx("div",{className:"file-panel-heading-row",children:n.jsx("h2",{className:"file-panel-heading",children:r("conversation.filePanelTitle")})}),h?null:n.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":r("conversation.filePanelTitle"),children:[n.jsx("button",{className:X==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":X==="workspace",onClick:()=>Ze("workspace"),children:r("conversation.filePanelWorkspaceTab")}),n.jsxs("button",{className:X==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":X==="session",onClick:()=>{it&&Ze("session")},disabled:!it,children:[r("conversation.filePanelSessionTab"),n.jsx("span",{className:"file-panel-tab-badge","aria-label":`${r("conversation.filePanelSessionTab")} ${rn}`,children:rn})]})]}),X==="workspace"?n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:hn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void xi(e)}),pn?n.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":r("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":r("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":Qe,"data-active":Qe,onClick:()=>{Z(!1),L(e=>!e)},children:[n.jsx("span",{children:r("conversation.filePanelActionsMenu")}),n.jsx(Ba,{})]}),Qe?n.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":r("conversation.filePanelActionsMenu"),children:[n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ue("copy")),disabled:!Ee,children:r("conversation.filePanelCopy")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ue("cut")),disabled:!Ee,children:r("conversation.filePanelCut")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ot()),disabled:!lt||m||v,children:r("conversation.filePanelPaste")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),En()},children:Ge?r("conversation.filePanelHideSearch"):r("conversation.filePanelShowSearch")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Wt(e=>!e)},disabled:pt.length===0,children:J?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(kn),disabled:Re||m||ht,children:r("conversation.filePanelRefresh")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Rn()},disabled:!xn,children:r("conversation.filePanelCollapseCurrent")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Mn()},disabled:m||v,children:r("conversation.filePanelUpload")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(Vt),disabled:!bn||v,children:r("conversation.filePanelDownload")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(Xt),disabled:!yn||m||v,children:r("conversation.filePanelRenameMove")}),n.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>q(qt),disabled:!vn||m||v,children:r("conversation.filePanelDelete")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ze("create_file")),disabled:m||v,children:r("conversation.filePanelNewFile")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>ze("create_directory")),disabled:m||v,children:r("conversation.filePanelNewDirectory")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>Ue("absolute")),disabled:!Ht,children:r("conversation.filePanelCopyAbsolutePath")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>q(()=>Ue("relative")),disabled:!Ht,children:r("conversation.filePanelCopyRelativePath")})]}):null]})}):n.jsxs("div",{className:"file-panel-toolbar","aria-label":r("conversation.filePanelTitle"),children:[n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopy"),"aria-label":r("conversation.filePanelCopy"),onClick:()=>ue("copy"),disabled:!Ee,children:n.jsx(ka,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCut"),"aria-label":r("conversation.filePanelCut"),onClick:()=>ue("cut"),disabled:!Ee,children:n.jsx(Ea,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelPaste"),"aria-label":r("conversation.filePanelPaste"),onClick:()=>void ot(),disabled:!lt||m||v,children:n.jsx(Ma,{})}),n.jsxs("div",{className:"file-toolbar-menu-shell",ref:fn,children:[n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopyPath"),"aria-label":r("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":Je,"data-active":Je,onClick:()=>{L(!1),Z(e=>!e)},disabled:!Ht,children:n.jsx(Da,{})}),Je?n.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[n.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ue("absolute"),children:r("conversation.filePanelCopyAbsolutePath")}),n.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ue("relative"),children:r("conversation.filePanelCopyRelativePath")})]}):null]}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCollapseCurrent"),"aria-label":r("conversation.filePanelCollapseCurrent"),onClick:Rn,disabled:!xn,children:n.jsx(wa,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRefresh"),"aria-label":r("conversation.filePanelRefresh"),onClick:()=>void kn(),disabled:Re||m||ht,children:n.jsx(Na,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),"data-active":Ge,onClick:En,disabled:Re,children:n.jsx(qn,{})}),pt.length>0?n.jsx("button",{className:"file-toolbar-button",type:"button",title:J?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"aria-label":J?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"data-active":J,onClick:()=>Wt(e=>!e),children:n.jsx(Wa,{})}):null,n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelUpload"),"aria-label":r("conversation.filePanelUpload"),onClick:Mn,disabled:m||v,children:n.jsx(_a,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelDownload"),"aria-label":r("conversation.filePanelDownload"),onClick:()=>void Vt(),disabled:!bn||v,children:n.jsx(Ta,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRenameMove"),"aria-label":r("conversation.filePanelRenameMove"),onClick:()=>Xt(),disabled:!yn||m||v,children:n.jsx(La,{})}),n.jsx("button",{className:"file-toolbar-button danger",type:"button",title:r("conversation.filePanelDelete"),"aria-label":r("conversation.filePanelDelete"),onClick:()=>qt(),disabled:!vn||m||v,children:n.jsx(Fa,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewFile"),"aria-label":r("conversation.filePanelNewFile"),onClick:()=>void ze("create_file"),disabled:m||v,children:n.jsx(Ra,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewDirectory"),"aria-label":r("conversation.filePanelNewDirectory"),onClick:()=>void ze("create_directory"),disabled:m||v,children:n.jsx(Aa,{})})]}),ae&&typeof document<"u"?ki.createPortal(n.jsx("div",{className:"file-web-context-menu",ref:$t,role:"menu","aria-label":r("conversation.filePanelActionsMenu"),style:{left:`${(ve==null?void 0:ve.left)??Math.max(8,ae.positionX)}px`,top:`${(ve==null?void 0:ve.top)??Math.max(8,ae.positionY)}px`,maxHeight:ve?`${ve.maxHeight}px`:void 0},children:ae.items.map(e=>n.jsx("button",{className:["file-web-context-menu-item",e.label===r("conversation.filePanelDelete")?"danger":""].filter(Boolean).join(" "),type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>{O(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 yi(e),children:[n.jsx("input",{value:A,onChange:e=>qe(e.target.value),placeholder:r("conversation.filePanelSearchPlaceholder")}),pn?n.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":r("conversation.filePanelSearchButton"),disabled:ht,children:r("conversation.filePanelSearchButton")}):n.jsx("button",{className:"file-toolbar-button",type:"submit",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),disabled:ht,children:n.jsx(qn,{})})]}):null,n.jsx("div",{ref:ci,className:"file-tree","data-search-mode":oe,"data-scrollbar-autohide":"true",children:Re&&Be.length===0?n.jsx("p",{className:"file-tree-status status-text",children:r("common.loading")}):oe?ke!=null&&ke.length?ji(ke):n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSearchEmpty")}):J?bt.length?Yt(bt,0):n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelNoChanges")}):Be.length?Yt(Be,0):n.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelEmptyDirectory")})}),n.jsx(Ln,{open:w!==null,title:(H==null?void 0:H.title)??"",description:H==null?void 0:H.description,onClose:Gt,children:n.jsxs("form",{className:"workbench-rename-form",onSubmit:e=>void gi(e),children:[n.jsx(Ri,{label:r("conversation.filePanelPathFieldLabel"),htmlFor:un,description:(w==null?void 0:w.mode)==="rename"?w.target.path:(w==null?void 0:w.baseDirectory)||void 0,children:n.jsx("input",{id:un,type:"text",value:Bt??"",placeholder:r("conversation.filePanelPathFieldPlaceholder"),autoFocus:!0,onChange:e=>Ae(e.target.value)})}),n.jsxs(_i,{children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:m,onClick:Gt,children:r("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:m||!(Bt??"").trim(),children:m?(H==null?void 0:H.pendingLabel)??r("common.loading"):(H==null?void 0:H.submitLabel)??r("common.save")})]})]})}),n.jsxs(Ln,{open:B!==null,title:r("conversation.filePanelDeleteConfirmTitle"),description:r("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{m||Fe(null)},children:[n.jsx("p",{className:"workbench-section-empty",children:B!=null&&B.length?B.length===1?((Fn=B[0])==null?void 0:Fn.kind)==="directory"?r("conversation.filePanelDeleteDirectoryConfirm",{path:B[0].path}):r("conversation.filePanelDeleteFileConfirm",{path:B[0].path}):r("conversation.filePanelDeleteSelectionConfirm",{count:B.length}):""}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:m,onClick:()=>Fe(null),children:r("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:m,onClick:()=>{Pi()},children:m?r("conversation.filePanelDeleting"):r("conversation.filePanelDelete")})]})]})]}):it&&i?n.jsx(Yi,{sessionId:i,workspaceId:l,showSystemFiles:I,selectedPath:ge,refreshVersion:sn,onCountChange:At,onSelectFile:ce,onOpenFile:He}):n.jsx("section",{className:"file-panel-section",children:n.jsx("p",{className:"status-text",children:r("conversation.filePanelSessionNoSession")})})]}):n.jsx("section",{className:"file-panel-section",children:n.jsx("p",{className:"status-text",children:r("conversation.filePanelNoWorkspace")})})})}function he(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):g}function ut(t,i=!1){const l=t.split("/").filter(Boolean),o=i?l.length:l.length-1,h=[];for(let d=0;d<o;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?he(i.path):g)}function zn(t,i){return t?`${t}/${i}`:i}function aa(t){var i;return((i=t.split(/[/\\]/).pop())==null?void 0:i.trim())??""}function z(t,i){return{path:t,kind:i}}function Un(t){return t[t.length-1]??null}function la(t,i){return t.findIndex(o=>o.path===i.path)>=0?t.filter(o=>o.path!==i.path):[...t,i]}function sa(t,i,l){const o=t.findIndex(y=>y.path===l.path);if(o<0)return[l];const h=i?t.findIndex(y=>y.path===i):o;if(h<0)return[l];const d=Math.min(h,o),b=Math.max(h,o);return t.slice(d,b+1)}function Ct(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function ra(t){return t.ctrlKey||t.metaKey}function oa(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(o=>[o.path,o])).values()].sort((o,h)=>o.path.localeCompare(h.path)),l=[];for(const o of i)l.some(h=>h.kind==="directory"&&_t(h.path,o.path))||l.push(o);return l}function ca(t,i){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?he(t.path):i}function ua(t,i){let l=t;for(;l&&i.some(o=>o.kind==="directory"&&_t(o.path,l));)l=he(l);return l}function ni(t,i,l,o,h,d){const b=[];for(const y of t){if(b.push(z(y.path,y.kind)),y.kind!=="directory"||!l.includes(y.path))continue;const C=i[y.path]??[],T=o?tn(C,i,h,d):C;b.push(...ni(T,i,l,o,h,d))}return b}function fa(t,i,l){const o=Math.max(0,l.width),h=Math.max(0,l.height),d=Math.max(0,h-ee*2),b=Math.max(0,o-ee*2),y=Math.min(Math.max(i.width,0),b),C=Math.max(0,h-t.y-Pt-ee),T=Math.max(0,t.y-Pt-ee),M=C<i.height&&T>C,me=Qt(Math.max(M?T:C,Ii),0,d),U=Math.min(Math.max(i.height,0),me),pe=M?t.y-Pt-U:t.y+Pt,be=Math.max(ee,h-ee-U),V=Math.max(ee,o-ee-y);return{top:Qt(pe,ee,be),left:Qt(t.x,ee,V),maxHeight:Math.max(0,me)}}function Qt(t,i,l){return!Number.isFinite(t)||l<i?i:Math.min(Math.max(t,i),l)}function Ke(t,i="posix"){return t?ii(t,i):"."}function da(t,i,l){const o=ii(t,l),h=Ke(i,l).replace(/^\.[/\\]?/,"");if(!h)return o;const d=ai(l),b=h.replace(/^[/\\]+/,"");return b?o.endsWith("/")||o.endsWith("\\")?`${o}${b}`:`${o}${d}${b}`:o}function ha(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function ii(t,i){return t&&(ai(i)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function ai(t){return t==="windows"?"\\":"/"}function _t(t,i){return i===t||i.startsWith(`${t}/`)}function li(t,i,l){return t===i?l:t.startsWith(`${i}/`)?`${l}${t.slice(i.length)}`:t}function ma(t,i,l){return t.map(o=>({...o,path:li(o.path,i,l)}))}function pa(t){return t.mode==="create_file"?{title:r("conversation.filePanelNewFile"),description:r("conversation.filePanelCreateFileDescription"),submitLabel:r("conversation.filePanelCreateFileSubmit"),pendingLabel:r("conversation.filePanelCreatingFile")}:t.mode==="create_directory"?{title:r("conversation.filePanelNewDirectory"),description:r("conversation.filePanelCreateDirectoryDescription"),submitLabel:r("conversation.filePanelCreateDirectorySubmit"),pendingLabel:r("conversation.filePanelCreatingDirectory")}:{title:r("conversation.filePanelRenameMove"),description:r("conversation.filePanelRenameDescription"),submitLabel:r("conversation.filePanelRenameSubmit"),pendingLabel:r("conversation.filePanelRenaming")}}async function ba(t){const i=await t.arrayBuffer(),l=new Uint8Array(i),o=32768;let h="";for(let d=0;d<l.length;d+=o){const b=l.subarray(d,d+o);h+=String.fromCharCode(...b)}return btoa(h)}function va(t){const i=atob(t),l=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)l[o]=i.charCodeAt(o);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}function ya(t,i){if(typeof document>"u")throw new Error(r("conversation.filePanelDownloadFailed"));const l=window.URL.createObjectURL(i),o=document.createElement("a");o.href=l,o.download=t,document.body.append(o),o.click(),o.remove(),window.URL.revokeObjectURL(l)}async function xa(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(!ga(t))throw new Error(r("conversation.filePanelCopyPathFailed"))}}function ga(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 Pa(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(o=>l.includes(o))}function St(t,i,l){const o=ln(i,l);return Object.entries(t).reduce((h,[d,b])=>(o.has(d)&&(h[d]=b),h),{})}function Ca(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]),o=si(i,ut(t,!0));for(const h of o){l.add(h);for(const d of ut(h,!0))l.add(d)}return l}function ja(t,i){const l=Object.keys(t),o=Object.keys(i);return l.length!==o.length?!1:l.every(h=>t[h]===i[h])}function Et(t,i){return t.includes(i)?t:[...t,i]}function si(t,i){return i.reduce((l,o)=>Et(l,o),t)}function Kn(t){return`file-panel.workspace-tree.${t}`}function Sa(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 te(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 wa(){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 Na(){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 Da(){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 ka(){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 Ea(){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 Ma(){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 Ra(){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 _a(){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 Ta(){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 Fa(){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 Aa(){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 La(){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 Ba(){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 Wa(){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,o){const h=[];for(const d of t){const b=d.path.replace(/\\/g,"/");d.kind==="file"?l.has(b)&&h.push(d):ri(b,i,l,o)&&h.push(d)}return h}function ri(t,i,l,o,h){const d=h??new Set;if(d.has(t))return!1;d.add(t);const b=i[t];if(!b)return o.has(t);for(const y of b){const C=y.path.replace(/\\/g,"/");if(y.kind==="file"){if(l.has(C))return!0}else if(ri(C,i,l,o,d))return!0}return!1}export{qa as FileContextPanel};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{b as l,t as n,j as e,A as qn}from"./index-DvkfRpBe.js";import{u as ki,e as Gi,f as $i,g as Rn}from"./App-BRupl2Ul.js";import{u as Ui,ac as ut,b as Hn,bq as wn,w as Bi,br as Vi,bs as Wi,bh as zi,bt as Pn,bu as Ki,bv as Ii,bk as Xi,bw as qi,bj as Yi,bx as Zi,bi as Yn,by as Ji,bp as Qi,bz as An,Z as es,c as ts,bA as ns,bB as is,bC as ss}from"./WorkbenchLayout-Cht6Un5X.js";import{S as as,y as rs,z as os,e as ls}from"./model-switch-api-Dps4yN2t.js";import{F as cs,r as Wt,a as zt}from"./file-tree-icon-CLfk31E7.js";import{W as Oe}from"./WorkbenchModal-CAj_TqWW.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-WiotM2TL.js";const Ot=56,Dn=28,kt=72,dt=8,Ln=960,_n=60*1e3,Fn=20,On=9,kn=9,Gt=68,O=12,mt=8,Kt=260,us=120,$t=6e4,ht={authMode:"none",username:"",password:"",token:"",rememberOnHost:!1};function Fs({className:a,workspaceId:i,panelActive:u=!0,externalWindowMode:h=!1,workbenchShellOverrides:g}){const j=ki(),f=Gi(),x=Ui(),{subscribeGitSnapshot:b,requestGitRefresh:v,addGitSnapshotListener:R,requestNavigationRefresh:S,selectWorkspace:T,upsertNavigationSession:p}={...x,...g},[o,m]=l.useState(null),[y,H]=l.useState(null),[C,M]=l.useState([]),[F,P]=l.useState(0),[X,se]=l.useState(null),[be,pt]=l.useState(!1),[U,xe]=l.useState(null),[ae,q]=l.useState(null),[ye,je]=l.useState(""),[$e,B]=l.useState(!1),[N,A]=l.useState(!1),[ai,Zt]=l.useState([]),[te,Jt]=l.useState(!0),[ne,z]=l.useState(!1),[k,ri]=l.useState(()=>typeof window<"u"?window.innerWidth<=Ln:!1),[bt,V]=l.useState([]),[Ce,K]=l.useState(null),[Ne,re]=l.useState("unstaged"),[ve,Y]=l.useState(null),[oe,Z]=l.useState(null),[oi,xt]=l.useState(!1),[li,yt]=l.useState(null),[ci,Ue]=l.useState(!1),[Qt,Be]=l.useState(null),[_,Se]=l.useState(null),[en,Te]=l.useState(null),[ui,Me]=l.useState(!1),[Ee,le]=l.useState(null),[ie,jt]=l.useState(!1),[di,ce]=l.useState(!1),[Ve,Ct]=l.useState("push"),[We,ze]=l.useState([]),[mi,Ke]=l.useState(!1),[Ie,Xe]=l.useState(new Set),[hi,ue]=l.useState(new Map),[qe,tn]=l.useState({}),[gi,de]=l.useState(!1),[Ye,nn]=l.useState(null),[D,J]=l.useState(ht),[sn,an]=l.useState("generic"),[rn,Ze]=l.useState(null),[G,Nt]=l.useState(null),[$,vt]=l.useState(null),[on,ln]=l.useState(Ot),[St,Tt]=l.useState(!1),[cn,Re]=l.useState(null),[fi,He]=l.useState(null),un=l.useRef(null),dn=l.useRef(null),mn=l.useRef(null),hn=l.useRef(null),gn=l.useRef(null),fn=l.useRef(null),Mt=l.useRef(null),we=l.useRef(new Map),Je=l.useRef(new Map),Pe=l.useRef(0),pn=l.useRef(u),bn=l.useRef(u),Qe=l.useRef(null),{showToast:E}=$i(),xn=f.isDesktop&&!k;l.useEffect(()=>{ut("git_sidebar.props",{workspaceId:i,externalWindowMode:h})},[h,i]),l.useEffect(()=>{bn.current=u},[u]),l.useEffect(()=>{Zt([]),Jt(!0),P(0),se(null),pt(!1),q(null),je(""),z(!1),V([]),K(null),re("unstaged"),Y(null),Z(null),xt(!1),yt(null),Ue(!1),Be(null),Se(null),Te(null),Me(!1),le(null),jt(!1),ce(!1),Ct("push"),ze([]),Xe(new Set),ue(new Map),tn({}),de(!1),nn(null),J(ht),an("generic"),Ze(null),Nt(null),vt(null),Tt(!1),ln(Ot),Re(null),He(null),Je.current.clear(),we.current.clear()},[i]),l.useEffect(()=>{function t(){ri(window.innerWidth<=Ln)}return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),l.useEffect(()=>{if(!St)return;const t=document.body.style.cursor,s=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";function r(d){vn(d.clientY)}function c(){Tt(!1)}return window.addEventListener("pointermove",r),window.addEventListener("pointerup",c),()=>{document.body.style.cursor=t,document.body.style.userSelect=s,window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",c)}},[St]),l.useEffect(()=>{var c,d;if(!(i!=null&&i.trim())){Qe.current=null,m(null),H(null),M([]),P(0),se(null),xe(null),B(!1);return}const t=i.trim(),s=Hn(ke(t),_n),r=Bt(s);if(ut("git_sidebar.snapshot",{workspaceId:t,cached:r,cachedHistoryCount:((c=s==null?void 0:s.history)==null?void 0:c.length)??0,cachedChangedCount:((d=s==null?void 0:s.status)==null?void 0:d.changes.length)??0}),r&&s){Et(s,t),B(!1);return}Qe.current=null,wn(ke(t)),m(null),H(null),M([]),P(0),se(null),xe(null),B(!0)},[i]),l.useEffect(()=>{if(i!=null&&i.trim())return R(t=>{var s,r,c;t.workspaceId===i.trim()&&(ut("git_sidebar.snapshot_received",{workspaceId:t.workspaceId,changedCount:((s=t.status)==null?void 0:s.changes.length)??0,historyCount:t.history.length,branchCount:(((r=t.branches)==null?void 0:r.local.length)??0)+(((c=t.branches)==null?void 0:c.remote.length)??0)}),Et(t,t.workspaceId),B(!1))})},[R,i]),l.useEffect(()=>{if(!(i!=null&&i.trim()))return;const t=i.trim(),s=Hn(ke(t),_n),r=Bt(s)?(s==null?void 0:s.revision)??null:null;b(t,{knownRevision:r}),bn.current&&I()},[v,b,i]),l.useEffect(()=>{const t=pn.current;pn.current=u,i!=null&&i.trim()&&!t&&u&&v(i.trim(),{knownRevision:y})},[u,v,y,i]),l.useEffect(()=>{const t=i==null?void 0:i.trim();if(!t||Qe.current!==t)return;const s={revision:y,status:o,history:C,historyTotalCount:F,historyNextCursor:X,branches:U};if(!Bt(s)){wn(ke(t));return}Bi(ke(t),s)},[U,C,X,F,y,o,i]),l.useEffect(()=>{if(!o||!ae)return;o.changes.find(s=>s.path===ae)||q(null)},[ae,o]),l.useEffect(()=>{bs(hn.current)},[ye]),l.useEffect(()=>{k||(V([]),K(null),Y(null),Ze(null))},[k]),l.useEffect(()=>{if(!o){V([]);return}const t=new Set(o.changes.map(s=>s.path));V(s=>s.filter(r=>t.has(r)))},[o]);function pi(){const t=mn.current;if(!t)return;t.querySelectorAll(".git-tree-shell").forEach(r=>{r.scrollTop=0})}function Et(t,s){Qe.current=(s==null?void 0:s.trim())??(i==null?void 0:i.trim())??null,H(typeof t.revision=="string"?t.revision:null),m(t.status),M(Array.isArray(t.history)?t.history:[]),P(typeof t.historyTotalCount=="number"?t.historyTotalCount:0),se(typeof t.historyNextCursor=="string"?t.historyNextCursor:null),xe(t.branches??null)}function I(t){i!=null&&i.trim()&&(B(!0),ut("git_sidebar.refresh_requested",{workspaceId:i.trim(),resetTreeScroll:!1}),v(i.trim(),{knownRevision:y}))}async function Rt(t){if(!(i!=null&&i.trim()))return;const s=i.trim();B(!0);try{const[r,c,d]=await Promise.all([zi(s),Pn(s,Fn,null),Ki(s)]);Et({status:r,history:c.items,historyTotalCount:c.totalCount,historyNextCursor:c.nextCursor,branches:d}),v(s),t!=null&&t.resetTreeScroll&&requestAnimationFrame(()=>{pi()})}catch(r){E({title:L(r,n("git.panelLoadFailed")),tone:"error"})}finally{B(!1)}}async function et(){if(!(!i||!X||be)){pt(!0);try{const t=await Pn(i,Fn,X);M(s=>{const r=new Set(s.map(d=>d.commitHash)),c=t.items.filter(d=>!r.has(d.commitHash));return[...s,...c]}),P(t.totalCount),se(t.nextCursor)}catch(t){E({title:L(t,n("git.panelLoadFailed")),tone:"error"})}finally{pt(!1)}}}function bi(t){if(!te||be||!X)return;const s=t.currentTarget;s.scrollHeight-s.scrollTop-s.clientHeight<=40&&et()}async function xi(){if(i){A(!0);try{const t=await Wi(i,"ai");je(t.validation.normalizedDraft.subject||t.draft.subject)}catch(t){E({title:L(t,n("git.draftFailed")),tone:"error"})}finally{A(!1)}}}async function tt(t,s){if(i&&t.length){A(!0);try{const r=s?await qi(i,t):await Yi(i,t);m(r),q(t[t.length-1]??null),V(c=>c.filter(d=>!t.includes(d))),K(null),I()}catch(r){B(!1),E({title:L(r,n("git.stageFailed")),tone:"error"})}finally{A(!1)}}}async function Ht(t){if(i&&t.length){A(!0);try{const s=await Ji(i,t);m(s),t.includes(ae??"")&&q(null),V(r=>r.filter(c=>!t.includes(c))),K(null),I()}catch(s){B(!1),E({title:L(s,n("git.discardFailed")),tone:"error"})}finally{A(!1)}}}async function yi(){if(!(!i||!ye.trim())){A(!0);try{await Ii(i,gs(ye)),E({title:n("git.commitSuccess"),tone:"success"}),je(""),q(null),I()}catch(t){E({title:L(t,n("git.commitFailed")),tone:"error"})}finally{A(!1)}}}async function ji(){if(i!=null&&i.trim()){A(!0),B(!0);try{const t=await Vi(i.trim());m(t),M([]),P(0),se(null),xe(null),E({title:n("git.initSuccess"),tone:"success"}),I()}catch(t){E({title:L(t,n("git.initFailed")),tone:"error"})}finally{A(!1),B(!1)}}}async function wt(){const t=i==null?void 0:i.trim();if(!t)return[];const s=await ns(t);return(i==null?void 0:i.trim())!==t?[]:(ze(s),s)}async function nt(t){const s=await wt(),r=gt(s,t);if(!r){E({title:n("git.noRemotes"),tone:"error"});return}const c=qe[r.name]??null;nn(r.name),an(vs(s,r.name)),J(Cs((c==null?void 0:c.auth)??null,(c==null?void 0:c.rememberOnHost)??!1)),de(!0)}async function Ci(){if(i!=null&&i.trim()){Ke(!0);try{const t=await wt();if(t.length===0){E({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){await nt(t[0].name);return}Ct("auth"),Xe(new Set),ue(new Map),ce(!0)}catch(t){E({title:L(t,n("git.remoteFailed")),tone:"error"})}finally{Ke(!1)}}}function Ni(){const t=Ye==null?void 0:Ye.trim();if(!t){de(!1);return}const s=Ns(D),r=sn==="github"?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder");if(D.authMode==="basic"){if(!D.username.trim()){E({title:n("shell.cloneUsernamePlaceholder"),tone:"error"});return}if(!D.password){E({title:r,tone:"error"});return}}if(D.authMode==="token"&&!D.token){E({title:n("shell.cloneTokenPlaceholder"),tone:"error"});return}tn(c=>{if(!s){const{[t]:d,...w}=c;return w}return{...c,[t]:{auth:s,rememberOnHost:D.rememberOnHost}}}),de(!1),E({title:s?n("git.remoteAuthSaved"):n("git.remoteAuthCleared"),description:s&&D.rememberOnHost?n("git.remoteAuthRememberHint"):void 0,tone:"success"})}async function yn(){if(i){Ke(!0);try{const t=await wt();if(t.length===0){E({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){jn([t[0].name]);return}Ct("push"),Xe(new Set),ue(new Map),ce(!0)}catch(t){E({title:L(t,n("git.remoteFailed")),tone:"error"})}finally{Ke(!1)}}}async function jn(t){if(!i||t.length===0)return;A(!0),ue(new Map);const s=new Map;let r=!1;try{for(const c of t){const d=qe[c]??null;try{const w=await An(i,"push",c,d==null?void 0:d.auth,(d==null?void 0:d.rememberOnHost)??!1);s.set(c,{ok:!0,summary:w.summary}),d!=null&&d.rememberOnHost&&d.auth&&ze(Oi=>Oi.map(Ft=>Ft.name===c?{...Ft,credentialConfigured:!0}:Ft))}catch(w){if(r=!0,s.set(c,{ok:!1,summary:L(w,n("git.remoteFailed"))}),ue(new Map(s)),Kn(w)){nt(c);return}}}ue(s),I(),r||(E({title:n("git.pushAllSuccess",{count:String(t.length)}),tone:"success"}),ce(!1))}finally{A(!1)}}async function Pt(t){if(i){if(t==="push"){z(!1),yn();return}A(!0);try{const s=In(We),r=s?qe[s]??null:null,c=await An(i,t,void 0,r==null?void 0:r.auth,(r==null?void 0:r.rememberOnHost)??!1);E({title:c.summary,tone:"success"}),s&&(r!=null&&r.rememberOnHost)&&r.auth&&ze(d=>d.map(w=>w.name===s?{...w,credentialConfigured:!0}:w)),z(!1),I()}catch(s){if(Kn(s)){nt(In(We));return}E({title:L(s,n("git.remoteFailed")),tone:"error"})}finally{A(!1)}}}async function me(){if(i){A(!0);try{const t=await Zi(i);je(t.commitSubject??""),E({title:t.summary||n("git.undoLastCommitSuccess"),tone:"success"}),z(!1),I()}catch(t){E({title:L(t,n("git.undoLastCommitFailed")),tone:"error"})}finally{A(!1)}}}async function vi(t){if(i){A(!0);try{const s=await is(i,t,!1);xe(s),z(!1),I()}catch(s){E({title:L(s,n("git.branchFailed")),tone:"error"})}finally{A(!1)}}}async function At(t){const s=i==null?void 0:i.trim();if(!s)throw new Error(n("git.panelLoadFailed"));const r=Je.current.get(t);if(r)return r;const c=await ss(s,t);return Je.current.set(t,c),c}async function Ae(t){Z(null),Y(null),yt(t),Be(null);const s=Je.current.get(t)??null;if(Se(s),Ue(!s),s)return;const r=Pe.current+1;Pe.current=r;try{const c=await At(t);if(Pe.current!==r)return;Se(c)}catch(c){if(Pe.current!==r)return;Be(L(c,n("git.commitDetailLoadFailed"))),Se(null)}finally{Pe.current===r&&Ue(!1)}}function Si(){yt(null),Ue(!1),Be(null),Se(null)}async function De(t){try{const s=await At(t);await W(s.versionLabel,n("git.copyCommitVersionSuccess"))}catch(s){E({title:L(s,n("git.commitDetailLoadFailed")),tone:"error"})}}function Le(t){Z(null),Y(null),Te(t),le(null),Me(!0)}function Ti(t){var r;const s=((r=C[0])==null?void 0:r.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 W(t.commitHash,n("git.copyCommitHashSuccess"))},{id:`copy-message:${t.commitHash}`,label:n("git.copyCommitMessage"),onSelect:()=>void W(pe(t),n("git.copyCommitMessageSuccess"))},{id:`copy-version:${t.commitHash}`,label:n("git.copyCommitVersion"),onSelect:()=>void De(t.commitHash)},{id:`explain:${t.commitHash}`,label:n("git.explainCommitAction"),onSelect:()=>Le(t.commitHash)},...s?[{id:`undo:${t.commitHash}`,label:n("git.undoLastCommit"),disabled:N,onSelect:()=>void me()}]:[]]}async function Cn(t){Z(null),Y(null),await Qi(Ti(t))}async function Mi(){var t,s;if(!(!i||!en||!Ee||ie)){jt(!0);try{const r=await At(en),c=await rs({workspaceId:i,provider:Ee,content:ps(r),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:es()}),d=c.session??await os(c.sessionId);p(d),S(),T(d.workspaceId),j(ts(d.workspaceId,d.sessionId)),Me(!1),Te(null),le(null),E({title:n("git.explainCommitStarted"),tone:"success"})}catch(r){E({title:L(r,n("git.explainCommitFailed")),tone:"error"})}finally{jt(!1)}}}function it(t){Zt(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t])}const Ei=450;function Nn(t){const s=Date.now(),r=un.current;return un.current={filePath:t,timestamp:s},(r==null?void 0:r.filePath)===t&&s-r.timestamp<=Ei}async function st(t,s){if(s.binary){E({title:n("git.binaryDiff"),tone:"info"});return}if(s.status==="A"||s.status==="?")He(null),Re(t);else if(i)try{const r=await Xi(i,t,s.staged);He(r.content),Re(t)}catch{He(null),Re(t)}}function at(t){q(t),K(null),V(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t])}function vn(t){const s=dn.current;if(!s||!Number.isFinite(t))return;const r=s.getBoundingClientRect(),c=r.height-dt;if(!Number.isFinite(r.top)||!Number.isFinite(r.height)||c<=0)return;const d=(t-r.top-dt/2)/c*100;if(!Number.isFinite(d))return;const w=Math.max(Dn,Math.min(kt,Math.round(d)));ln(w)}function Ri(t){t.preventDefault(),vn(t.clientY),Tt(!0)}const _e=(o==null?void 0:o.changes)??[],Q=_e.filter(t=>It(t,"staged")),he=_e.filter(t=>It(t,"unstaged")),Sn=Wn(Q,"staged"),Tn=Wn(he,"unstaged"),rt=new Set(ai),ot=new Set(bt),ge=zn(bt,_e,"staged"),fe=zn(bt,_e,"unstaged"),Dt=_e.length===0&&((o==null?void 0:o.snapshot.ahead)??0)>0,Hi=Q.length>0&&ye.trim().length>0,lt=(U==null?void 0:U.currentBranch)??(o==null?void 0:o.snapshot.branch)??n("common.unknown"),ct=gt(We,Ye),Fe=sn==="github",wi=Fe?n("git.remoteAuthDescriptionGithub"):n("git.remoteAuthDescription"),Pi=Fe?n("git.remoteAuthGithubPatLabel"):n("shell.clonePasswordLabel"),Ai=Fe?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder"),Di=Fe?n("git.remoteAuthGithubUsernamePlaceholder"):n("shell.cloneUsernamePlaceholder"),Lt=Number.isFinite(on)?on:Ot,Li=te?`minmax(120px, ${Lt}fr) ${dt}px minmax(140px, ${100-Lt}fr)`:`minmax(120px, 1fr) ${dt}px auto`,_i=ys(o);l.useEffect(()=>{Ce==="staged"&&ge.length===0&&K(null),Ce==="unstaged"&&fe.length===0&&K(null)},[Ce,ge.length,fe.length]),l.useEffect(()=>{if(!k)return;const t=he.length>0?"unstaged":Q.length>0?"staged":"history";re(s=>s==="unstaged"&&he.length>0||s==="staged"&&Q.length>0?s:t)},[k,Q.length,he.length]),l.useEffect(()=>{ve&&(C.some(t=>t.commitHash===ve)||Y(null))},[C,ve]),l.useEffect(()=>{oe&&(C.some(t=>t.commitHash===oe)||Z(null))},[oe,C]),l.useEffect(()=>{k&&Ne!=="history"&&ne&&z(!1)},[k,ne,Ne]),l.useLayoutEffect(()=>{if(k||!ne){Nt(null);return}function t(){const r=gn.current,c=fn.current;!r||!c||typeof window>"u"||Nt(Xn(r.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,U==null?void 0:U.local.length,lt,k,ne]);const ee=ve??oe;l.useLayoutEffect(()=>{if(!ee){vt(null);return}const t=ee;function s(){const c=we.current.get(t)??null,d=Mt.current;!c||!d||typeof window>"u"||vt(Xn(c.getBoundingClientRect(),{width:d.getBoundingClientRect().width||Kt,height:d.getBoundingClientRect().height||d.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}s();const r=window.requestAnimationFrame(s);return window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{window.cancelAnimationFrame(r),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[ee,C.length]),l.useEffect(()=>{if(!ee||typeof document>"u")return;const t=ee;function s(r){const c=r.target;if(!(c instanceof Node))return;const d=we.current.get(t)??null,w=Mt.current;d!=null&&d.contains(c)||w!=null&&w.contains(c)||(Y(null),Z(null))}return document.addEventListener("pointerdown",s),()=>{document.removeEventListener("pointerdown",s)}},[ee]);async function W(t,s){var r;try{if(f.isDesktop&&(await f.bridge.writeClipboardText(t)).ok){E({title:s,tone:"success"});return}if(typeof navigator<"u"&&((r=navigator.clipboard)!=null&&r.writeText)){await navigator.clipboard.writeText(t),E({title:s,tone:"success"});return}if(fs(t)){E({title:s,tone:"success"});return}}catch{E({title:n("common.copyContentFailed"),tone:"error"})}}async function Mn(t,s){typeof window<"u"&&!window.confirm(n("git.discardConfirm",{path:s}))||await Ht(t)}function En(t){const s=(t==null?void 0:t.desktopFloating)===!0&&!k,r=s?{top:(G==null?void 0:G.top)??O,left:(G==null?void 0:G.left)??O,maxHeight:G==null?void 0:G.maxHeight,transformOrigin:(G==null?void 0:G.transformOrigin)??"top right"}:void 0,c=e.jsxs("div",{ref:s?fn:void 0,className:"git-operations-menu","data-floating":s?"true":"false",style:r,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:lt})]}),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:n("git.remoteAuthManageHint")}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N||mi,onClick:()=>void Ci(),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:U==null?void 0:U.local.map(d=>e.jsx("button",{className:"git-menu-item",type:"button",disabled:N||d.current,onClick:()=>void vi(d.name),children:e.jsx("span",{children:d.current?`${n("git.switchBranch")} ${d.name}`:`${n("git.switchBranchTo")} ${d.name}`})},d.name))})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>{z(!1),xt(!0)},children:e.jsx("span",{children:n("git.viewAllVersions")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void Pt("fetch"),children:e.jsx("span",{children:n("git.fetch")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void Pt("pull"),children:e.jsx("span",{children:n("git.pull")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void Pt("push"),children:e.jsx("span",{children:n("git.push")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void me(),children:e.jsx("span",{children:n("git.undoLastCommit")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N||$e,onClick:()=>void Rt({resetTreeScroll:!0}),children:e.jsx("span",{children:n("git.refresh")})})]})]});return s?typeof document>"u"?null:Rn.createPortal(c,document.body):c}function _t(t,s){if(s){we.current.set(t,s);return}we.current.delete(t)}function Fi(){var r;if(!ee||typeof document>"u")return null;const t=C.find(c=>c.commitHash===ee);if(!t)return null;const s=((r=C[0])==null?void 0:r.commitHash)===t.commitHash&&t.commitKind==="local";return Rn.createPortal(e.jsx("div",{ref:Mt,className:"git-history-entry-menu","data-floating":"true",style:{top:($==null?void 0:$.top)??O,left:($==null?void 0:$.left)??O,maxHeight:$==null?void 0:$.maxHeight,transformOrigin:($==null?void 0:$.transformOrigin)??"top right"},children:e.jsx(ms,{item:t,canUndo:s,actioning:N,onViewCommitChanges:c=>void Ae(c),onCopyCommitHash:c=>void W(c,n("git.copyCommitHashSuccess")),onCopyCommitMessage:c=>void W(pe(c),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:c=>void De(c),onExplainCommitChange:c=>void Le(c),onUndoLastCommit:()=>void me()})}),document.body)}return o&&!_i?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 ji(),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:hn,rows:1,value:ye,onChange:t=>je(ti(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 xi(),disabled:N||$e,children:e.jsx(Ms,{})})]}),e.jsxs("div",{className:"git-primary-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Rt({resetTreeScroll:!0}),disabled:N||$e||!i,children:n("git.refreshNow")}),e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>{if(Dt){yn();return}yi()},disabled:N||!Dt&&!Hi,children:Dt?n("git.pushNow"):n("git.commitNow")})]})]}),k?e.jsxs("div",{className:"git-mobile-sections",children:[e.jsx(Ut,{title:n("git.stagedChangesTitle"),count:Q.length,expanded:Ne==="staged",onToggle:()=>re("staged"),children:e.jsx($n,{title:n("git.stagedChangesTitle"),nodes:Sn,collapsedTreePathSet:rt,onToggleTreePath:it,onToggleMobileSelection:at,selectedMobilePathSet:ot,selectedTargets:ge,actioning:N,variant:"staged",swipeRowState:rn,onSwipeRowChange:Ze,onStageToggle:tt,onDiscardWithConfirm:Mn,onClearSelectedTargets:()=>V(t=>t.filter(s=>!ge.includes(s))),onPreviewFile:st})}),e.jsx(Ut,{title:n("git.changesTitle"),count:he.length,expanded:Ne==="unstaged",onToggle:()=>re("unstaged"),children:e.jsx($n,{title:n("git.changesTitle"),nodes:Tn,collapsedTreePathSet:rt,onToggleTreePath:it,onToggleMobileSelection:at,selectedMobilePathSet:ot,selectedTargets:fe,actioning:N,variant:"unstaged",swipeRowState:rn,onSwipeRowChange:Ze,onStageToggle:tt,onDiscardWithConfirm:Mn,onClearSelectedTargets:()=>V(t=>t.filter(s=>!fe.includes(s))),onPreviewFile:st})}),e.jsxs(Ut,{title:n("git.recentVersionsTitle"),count:F,expanded:Ne==="history",onToggle:()=>re("history"),trailingContent:e.jsx("span",{className:"badge",children:lt}),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":ne,onClick:()=>{re("history"),z(t=>!t)},disabled:N,children:e.jsx(Ge,{})}),children:[ne?e.jsx("div",{className:"git-mobile-operations-shell",children:En()}):null,e.jsx(ds,{history:C,historyLoadingMore:be,hasMore:!!X,actioning:N,openCommitHash:ve,onMenuTriggerRef:_t,onToggleMenu:t=>Y(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void W(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void W(pe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void De(t),onExplainCommitChange:t=>void Le(t),onUndoLastCommit:()=>void me(),onLoadMore:()=>void et()})]})]}):e.jsxs("div",{ref:dn,className:"git-content-split",style:{gridTemplateRows:Li},children:[e.jsx("section",{className:"git-card git-tree-panel",children:e.jsxs("div",{ref:mn,className:"git-tree-panel-body",children:[Q.length>0?e.jsx(Gn,{title:n("git.stagedChangesTitle"),count:Q.length,nodes:Sn,selectedPath:ae,collapsedTreePathSet:rt,onToggleTreePath:it,onSelectFile:q,onPreviewFile:(t,s)=>{Nn(t)&&st(t,s)},onToggleMobileSelection:at,onStageToggle:tt,onDiscard:Ht,actioning:N,variant:"staged",isMobileViewport:k,selectedMobilePathSet:ot,selectedTargets:ge,mobileActionMenuOpen:Ce==="staged",onToggleMobileActionMenu:()=>K(t=>t==="staged"?null:"staged"),onClearSelectedTargets:()=>V(t=>t.filter(s=>!ge.includes(s)))}):null,e.jsx(Gn,{title:n("git.changesTitle"),count:he.length,nodes:Tn,selectedPath:ae,collapsedTreePathSet:rt,onToggleTreePath:it,onSelectFile:q,onPreviewFile:(t,s)=>{Nn(t)&&st(t,s)},onToggleMobileSelection:at,onStageToggle:tt,onDiscard:Ht,actioning:N,variant:"unstaged",isMobileViewport:k,selectedMobilePathSet:ot,selectedTargets:fe,mobileActionMenuOpen:Ce==="unstaged",onToggleMobileActionMenu:()=>K(t=>t==="unstaged"?null:"unstaged"),onClearSelectedTargets:()=>V(t=>t.filter(s=>!fe.includes(s)))})]})}),e.jsx("button",{className:"git-panel-divider",type:"button",role:"separator","aria-label":n("git.resizePanels"),"aria-orientation":"horizontal","aria-valuemin":Dn,"aria-valuemax":kt,"aria-valuenow":te?Lt:kt,"data-dragging":St,onPointerDown:Ri,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":te,"aria-label":te?n("git.collapseRecentVersions"):n("git.expandRecentVersions"),onClick:()=>Jt(t=>!t),children:[e.jsxs("span",{className:"git-section-toggle-main",children:[e.jsx(ft,{expanded:te}),e.jsx("span",{children:n("git.recentVersionsTitle")})]}),e.jsx("span",{className:"workbench-section-counter",children:F})]}),e.jsxs("div",{className:"git-history-actions",children:[e.jsx("span",{className:"badge",children:lt}),e.jsx("button",{className:"git-icon-button",type:"button",ref:gn,"aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:()=>z(t=>!t),disabled:N,children:e.jsx(Ge,{})}),ne?En({desktopFloating:!0}):null]})]}),te?e.jsx(Bn,{history:C,historyLoadingMore:be,hasMore:!!X,actioning:N,openCommitHash:oe,useNativeContextMenu:xn,onMenuTriggerRef:_t,onScroll:bi,onToggleMenu:t=>{if(xn){const s=C.find(r=>r.commitHash===t);s&&Cn(s);return}Z(s=>s===t?null:t)},onOpenContextMenu:t=>void Cn(t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void W(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void W(pe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void De(t),onExplainCommitChange:t=>void Le(t),onUndoLastCommit:()=>void me(),onLoadMore:()=>void et()}):null]})]}),e.jsxs(Oe,{open:di,title:Ve==="push"?n("git.selectRemoteTitle"):n("git.remoteAuthManageTitle"),description:Ve==="push"?n("git.selectRemoteDesc"):n("git.remoteAuthManageDescription"),onClose:()=>{N||ce(!1)},children:[e.jsx("div",{className:"git-remote-select-list",children:We.map(t=>{const s=Ie.has(t.name),r=hi.get(t.name),c=Ss(t,qe[t.name]??null);return e.jsxs("div",{className:"git-remote-item",children:[Ve==="push"?e.jsxs("label",{className:"git-remote-item-selector",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:N,onChange:()=>{Xe(d=>{const w=new Set(d);return w.has(t.name)?w.delete(t.name):w.add(t.name),w})}}),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}),r&&e.jsx("span",{className:`git-remote-result ${r.ok?"ok":"err"}`,children:r.summary})]})]}):e.jsx("div",{className:"git-remote-item-selector git-remote-item-selector-static",children: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}),r&&e.jsx("span",{className:`git-remote-result ${r.ok?"ok":"err"}`,children:r.summary})]})}),e.jsxs("div",{className:"git-remote-item-meta",children:[e.jsx("span",{className:`git-remote-credential-badge ${c.kind}`,children:c.label}),e.jsx("button",{className:"secondary-button git-remote-inline-action",type:"button",disabled:N,onClick:()=>void nt(t.name),children:n("git.remoteAuthAction")})]})]},t.name)})}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:N,onClick:()=>ce(!1),children:n("common.close")}),Ve==="push"?e.jsx("button",{className:"primary-button",type:"button",disabled:N||Ie.size===0,onClick:()=>void jn(Array.from(Ie)),children:N?n("git.pushing"):n("git.pushSelected",{count:String(Ie.size)})}):null]})]}),e.jsxs(Oe,{open:gi,title:n("git.remoteAuthTitle"),description:wi,onClose:()=>{N||de(!1)},children:[ct?e.jsxs("div",{className:"git-remote-auth-target",children:[e.jsx("strong",{children:ct.name}),e.jsx("span",{children:ct.pushUrl||ct.fetchUrl})]}):null,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:D.authMode,disabled:N,onChange:t=>J(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")})]})]}),D.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:D.username,placeholder:Di,autoComplete:"username",onChange:t=>J(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:Pi}),e.jsx("input",{type:"password",value:D.password,placeholder:Ai,autoComplete:"current-password",onChange:t=>J(s=>({...s,password:t.target.value}))})]})]}):null,D.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:D.username,placeholder:n("shell.cloneTokenUsernamePlaceholder"),autoComplete:"username",onChange:t=>J(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:D.token,placeholder:n("shell.cloneTokenPlaceholder"),autoComplete:"current-password",onChange:t=>J(s=>({...s,token:t.target.value}))})]})]}):null,Fe?e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthGithubPatHint")}):null,D.authMode!=="none"?e.jsxs("label",{className:"settings-checkbox git-remote-auth-remember-toggle",children:[e.jsx("input",{type:"checkbox",checked:D.rememberOnHost,onChange:t=>J(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:()=>de(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:N,onClick:Ni,children:n("git.remoteAuthSave")})]})]}),e.jsx(Oe,{open:oi,title:n("git.viewAllVersions"),description:n("git.viewAllVersionsDescription",{count:String(F)}),onClose:()=>xt(!1),children:e.jsx(Bn,{history:C,historyLoadingMore:be,hasMore:!!X,actioning:N,openCommitHash:oe,className:"git-history-modal-list",onMenuTriggerRef:_t,onToggleMenu:t=>Z(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void W(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void W(pe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void De(t),onExplainCommitChange:t=>void Le(t),onUndoLastCommit:()=>void me(),onLoadMore:()=>void et()})}),e.jsx(Oe,{open:li!==null,className:"git-commit-detail-modal",title:(_==null?void 0:_.subject)||n("git.commitDetailTitle"),description:_?n("git.commitDetailDescription",{hash:_.shortHash}):n("git.commitDetailLoading"),onClose:Si,children:ci?e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailLoading")})}):Qt?e.jsx("div",{className:"git-commit-detail-state is-error",children:e.jsx("p",{children:Qt})}):_?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:_.versionLabel})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitHashLabel")}),e.jsx("strong",{children:_.commitHash})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitAuthorLabel")}),e.jsx("strong",{children:_.authorName})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitTimeLabel")}),e.jsx("strong",{children:xs(_.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:pe(_)})]}),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:_.changedFiles.length})]}),e.jsx("div",{className:"git-commit-detail-file-list",children:_.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")}),_.diffTruncated?e.jsx("span",{className:"git-commit-detail-truncated",children:n("git.diffTruncated")}):null]}),e.jsx("pre",{className:"git-commit-detail-diff",children:_.diffContent||n("git.emptyDiff")})]})]}):e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailEmpty")})})}),e.jsx(Oe,{open:ui,className:"git-explain-provider-modal",title:n("git.explainCommitTitle"),description:n("git.explainCommitDescription"),onClose:()=>{ie||(Me(!1),Te(null),le(null))},children:e.jsxs("div",{className:"git-explain-provider-shell",children:[e.jsx(as,{workspaceId:i,selectedProvider:Ee,pendingProvider:ie?Ee:null,disabled:ie,onSelect:t=>le(t)}),e.jsxs("div",{className:"git-explain-provider-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:ie,onClick:()=>{Me(!1),Te(null),le(null)},children:n("common.cancel")}),e.jsx("button",{type:"button",className:"primary-button",disabled:!Ee||ie,onClick:()=>void Mi(),children:ie?n("conversation.sendingState"):n("git.startExplainCommit")})]})]})}),e.jsx(cs,{workspaceId:i,filePath:cn,open:cn!==null,onClose:()=>{Re(null),He(null)},onSaved:async()=>{await Rt({resetTreeScroll:!0})},diffContent:fi}),Fi()]})}function Gn({title:a,count:i,nodes:u,selectedPath:h,collapsedTreePathSet:g,onToggleTreePath:j,onSelectFile:f,onPreviewFile:x,onToggleMobileSelection:b,onStageToggle:v,onDiscard:R,actioning:S,variant:T,isMobileViewport:p,selectedMobilePathSet:o,selectedTargets:m,mobileActionMenuOpen:y,onToggleMobileActionMenu:H,onClearSelectedTargets:C}){const M=Yn(),F=Yt(u),P=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}),!p&&F.length>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":P,title:P,onClick:()=>void v(F,T==="staged"),disabled:S,children:e.jsx(Xt,{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 R(F),disabled:S,children:e.jsx(qt,{})}):null]}):null,p&&m.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]}),p&&y?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:m.length})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void v(m,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 R(m),children:e.jsx("span",{children:n("git.discard")})}):null,e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:C,children:e.jsx("span",{children:n("git.clearSelection")})})]})]}):null]}),e.jsx("div",{ref:M,className:"git-tree-shell",role:"tree","aria-label":a,"data-scrollbar-autohide":"true",children:u.length?Jn({nodes:u,depth:0,collapsedTreePathSet:g,selectedPath:h,onToggleTreePath:j,onSelectFile:f,onPreviewFile:x,onToggleMobileSelection:b,onStageToggle:v,onDiscard:R,actioning:S,variant:T,isMobileViewport:p,selectedMobilePathSet:o}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Ut({title:a,count:i,expanded:u,onToggle:h,trailingContent:g,headerAction:j,children:f}){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:h,children:[e.jsxs("span",{className:"git-mobile-section-toggle-main",children:[e.jsx(ft,{expanded:u}),e.jsx("h3",{children:a})]}),e.jsxs("span",{className:"git-mobile-section-toggle-meta",children:[g,e.jsx("span",{className:"workbench-section-counter",children:i})]})]}),j?e.jsx("div",{className:"git-mobile-section-header-action",children:j}):null]}),u?e.jsx("div",{className:"git-mobile-section-body",children:f}):null]})}function $n({title:a,nodes:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,selectedTargets:f,actioning:x,variant:b,swipeRowState:v,onSwipeRowChange:R,onStageToggle:S,onDiscardWithConfirm:T,onClearSelectedTargets:p,onPreviewFile:o}){return e.jsxs("div",{className:"git-mobile-record-shell",children:[f.length>0?e.jsxs("div",{className:"git-mobile-selection-toolbar",children:[e.jsxs("span",{className:"git-mobile-selection-count",children:[n("git.selectedFiles")," ",f.length]}),e.jsxs("div",{className:"git-mobile-selection-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:x,onClick:()=>void S(f,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:x,onClick:()=>void T(f,`${f.length}`),children:n("git.discard")}):null,e.jsx("button",{type:"button",className:"secondary-button",disabled:x,onClick:p,children:n("git.clearSelection")})]})]}):null,e.jsx("div",{className:"git-mobile-record-list",role:"tree","aria-label":a,children:i.length?Zn({nodes:i,depth:0,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:x,variant:b,swipeRowState:v,onSwipeRowChange:R,onStageToggle:S,onDiscardWithConfirm:T,onPreviewFile:o}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Zn({nodes:a,depth:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:f,variant:x,swipeRowState:b,onSwipeRowChange:v,onStageToggle:R,onDiscardWithConfirm:S,onPreviewFile:T}){return a.map(p=>{if(p.kind==="directory"){const y=!u.has(p.path),H=Yt(p.children),C=`directory:${p.path}`;return e.jsxs("div",{className:"git-mobile-record-branch",children:[e.jsx(Un,{rowKey:C,openState:(b==null?void 0:b.path)===C?b.direction:null,onOpenStateChange:M=>v(M?{path:C,direction:M}:null),trailingActions:H.length>0?[{label:x==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void R(H,x==="staged")},...x==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S(H,p.path)}]:[]]:null,children:e.jsxs("button",{className:"git-mobile-record git-mobile-record-directory",type:"button",style:{paddingInlineStart:`${On+i*kn}px`},onClick:()=>h(p.path),children:[e.jsxs("span",{className:"git-mobile-record-leading",children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":y,children:e.jsx(ft,{expanded:y})}),e.jsx("span",{className:"git-mobile-record-title",children:p.name})]}),e.jsx("span",{className:"git-mobile-record-meta",children:H.length})]})}),y?e.jsx("div",{className:"git-mobile-record-children",role:"group",children:Zn({nodes:p.children,depth:i+1,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:f,variant:x,swipeRowState:b,onSwipeRowChange:v,onStageToggle:R,onDiscardWithConfirm:S,onPreviewFile:T})}):null]},C)}const o=`file:${p.path}`,m=j.has(p.path);return e.jsx(Un,{rowKey:o,openState:(b==null?void 0:b.path)===o?b.direction:null,onOpenStateChange:y=>v(y?{path:o,direction:y}:null),trailingActions:[{label:n("git.preview"),tone:"neutral",onPress:()=>T(p.change.path,p.change)},{label:x==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void R([p.change.path],x==="staged")},...x==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S([p.change.path],p.path)}]:[]],children:e.jsxs("div",{className:"git-mobile-record git-mobile-record-file","data-active":m,style:{paddingInlineStart:`${On+i*kn}px`},children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:m,"aria-label":`${n("git.selectFile")} ${p.name}`,onChange:()=>g(p.change.path)}),e.jsxs("button",{className:"git-mobile-record-file-main",type:"button",onClick:()=>g(p.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":zt(p.name),"aria-hidden":"true",children:Wt(p.name)}),e.jsxs("span",{className:"git-mobile-record-copy",children:[e.jsx("span",{className:"git-mobile-record-title",children:p.name}),e.jsx("span",{className:"git-mobile-record-path",children:p.path})]}),e.jsx("span",{className:"git-status-badge","data-status":p.status,children:p.status})]})]})},o)})}function Un({rowKey:a,openState:i,onOpenStateChange:u,trailingActions:h,children:g}){const j=ls(),f=l.useRef(null),[x,b]=l.useState(0),v=((h==null?void 0:h.length)??0)*Gt;l.useEffect(()=>{i||b(0)},[i,a]);const R=x!==0?x:i==="trailing"?-v:0;function S(m){var y,H;m.button===0&&(f.current={pointerId:m.pointerId,startX:m.clientX},(H=(y=m.currentTarget).setPointerCapture)==null||H.call(y,m.pointerId))}function T(m){const y=f.current;if(!y||y.pointerId!==m.pointerId)return;const H=v>0?v+10:0,C=Math.max(-H,Math.min(0,m.clientX-y.startX));b(C)}function p(m){var H,C;const y=f.current;if(!(!y||y.pointerId!==m.pointerId)){if((C=(H=m.currentTarget).releasePointerCapture)==null||C.call(H,m.pointerId),f.current=null,x<=-44&&(h!=null&&h.length)){j.trigger("gesture"),u("trailing"),b(0);return}u(null),b(0)}}function o(m){var H,C;const y=f.current;!y||y.pointerId!==m.pointerId||((C=(H=m.currentTarget).releasePointerCapture)==null||C.call(H,m.pointerId),f.current=null,b(0))}return e.jsxs("div",{className:"git-mobile-swipe-row","data-open-state":i??"closed","data-dragging":x!==0,children:[h==null?void 0:h.map((m,y)=>e.jsx("button",{type:"button",className:"git-mobile-swipe-action trailing","data-tone":m.tone,style:{right:y*Gt,width:Gt},onClick:()=>{j.trigger(m.tone==="danger"?"warning":"action"),u(null),m.onPress()},children:m.label},`trailing-${y}`)),e.jsx("div",{className:"git-mobile-swipe-content",style:{transform:`translateX(${R}px)`},onPointerDown:S,onPointerMove:T,onPointerUp:p,onPointerCancel:o,children:g})]})}function ds({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:g,onMenuTriggerRef:j,onToggleMenu:f,onViewCommitChanges:x,onCopyCommitHash:b,onCopyCommitMessage:v,onCopyCommitVersion:R,onExplainCommitChange:S,onUndoLastCommit:T,onLoadMore:p}){return a.length?e.jsxs("div",{className:"git-mobile-history-list",children:[a.map(o=>e.jsx("article",{className:"git-mobile-history-entry","data-kind":o.commitKind,children:e.jsxs("div",{className:"git-mobile-history-entry-main",children:[e.jsx("span",{className:"git-history-marker","data-kind":o.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:o.subject,children:o.subject}),e.jsx("span",{className:"git-history-kind-badge","data-kind":o.commitKind,children:ni(o.commitKind)})]}),o.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:o.refs.map(m=>e.jsx("span",{className:"git-history-ref-pill","data-kind":m.kind,"data-remote-index":String(ii(m.remoteName)),children:m.name},`${o.commitHash}:${m.kind}:${m.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:o.commitHash.slice(0,8)}),e.jsx("span",{children:o.authorName}),e.jsx("time",{dateTime:o.authoredAt,children:si(o.authoredAt)})]})]}),e.jsx("button",{type:"button",className:"git-icon-button",ref:m=>j(o.commitHash,m),"aria-label":n("git.historyItemMenu"),onClick:()=>f(o.commitHash),children:e.jsx(Ge,{})})]})},o.commitHash)),u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:p,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"git-tree-status",children:n("git.noHistory")})}function Bn({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:g,className:j,useNativeContextMenu:f=!1,onMenuTriggerRef:x,onScroll:b,onToggleMenu:v,onOpenContextMenu:R,onViewCommitChanges:S,onCopyCommitHash:T,onCopyCommitMessage:p,onCopyCommitVersion:o,onExplainCommitChange:m,onUndoLastCommit:y,onLoadMore:H}){const C=Yn();return a.length?e.jsxs("div",{ref:C,className:["git-history-list",j].filter(Boolean).join(" "),onScroll:b,"data-scrollbar-autohide":"true",children:[a.map(M=>{const F=g===M.commitHash;return e.jsxs("article",{className:"git-history-entry","data-kind":M.commitKind,"data-menu-open":F?"true":"false",onContextMenu:P=>{!f||!R||(P.preventDefault(),P.stopPropagation(),R(M))},children:[e.jsx("span",{className:"git-history-marker","data-kind":M.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:M.subject,children:M.subject}),e.jsxs("div",{className:"git-history-title-actions",children:[e.jsx("span",{className:"git-history-kind-badge","data-kind":M.commitKind,children:ni(M.commitKind)}),f?null:e.jsx("button",{type:"button",className:"git-icon-button git-history-more",ref:P=>x(M.commitHash,P),"aria-label":n("git.historyItemMenu"),onClick:()=>{v(M.commitHash)},children:e.jsx(Ge,{})})]})]}),M.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:M.refs.map(P=>e.jsx("span",{className:"git-history-ref-pill","data-kind":P.kind,"data-remote-index":String(ii(P.remoteName)),children:P.name},`${M.commitHash}:${P.kind}:${P.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:M.commitHash.slice(0,8)}),e.jsx("span",{children:M.authorName}),e.jsx("time",{dateTime:M.authoredAt,children:si(M.authoredAt)})]})]})]},M.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 ms({item:a,canUndo:i,actioning:u,onViewCommitChanges:h,onCopyCommitHash:g,onCopyCommitMessage:j,onCopyCommitVersion:f,onExplainCommitChange:x,onUndoLastCommit:b}){return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>h(a.commitHash),children:e.jsx("span",{children:n("git.viewCommitChanges")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>g(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitHash")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>j(a),children:e.jsx("span",{children:n("git.copyCommitMessage")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>f(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitVersion")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>x(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 Jn({nodes:a,depth:i,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:g,onSelectFile:j,onPreviewFile:f,onToggleMobileSelection:x,onStageToggle:b,onDiscard:v,actioning:R,variant:S,isMobileViewport:T,selectedMobilePathSet:p}){return a.map(o=>{if(o.kind==="directory"){const H=!u.has(o.path),C=Yt(o.children),M=`${S==="staged"?n("git.unstage"):n("git.stage")} ${o.path}`,F=`${n("git.discard")} ${o.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:()=>g(o.path),children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":H,children:e.jsx(ft,{expanded:H})}),e.jsx("span",{className:"git-tree-label git-tree-label-directory",children:o.name})]}),!T&&C.length>0?e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":M,title:M,onClick:()=>void b(C,S==="staged"),disabled:R,children:e.jsx(Xt,{staged:S==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":F,title:F,onClick:()=>void v(C),disabled:R,children:e.jsx(qt,{})}):null]}):null]}),H?e.jsx("div",{className:"git-tree-children",role:"group",children:Jn({nodes:o.children,depth:i+1,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:g,onSelectFile:j,onPreviewFile:f,onToggleMobileSelection:x,onStageToggle:b,onDiscard:v,actioning:R,variant:S,isMobileViewport:T,selectedMobilePathSet:p})}):null]},`directory:${o.path}`)}const m=p.has(o.path),y=T?m:h===o.path;return T?e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":y,"data-mobile":"true",children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:m,"aria-label":`${n("git.selectFile")} ${o.name}`,onChange:()=>x(o.change.path)}),e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":y,"data-mobile":"true",style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>x(o.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":zt(o.name),"aria-hidden":"true",children:Wt(o.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:o.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":o.status,children:o.status})})]})]},`file:${o.path}`):e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":y,children:[e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":y,style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>{j(o.change.path),f&&f(o.change.path,o.change)},children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":zt(o.name),"aria-hidden":"true",children:Wt(o.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:o.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":o.status,children:o.status})})]}),e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":o.variant==="staged"?n("git.unstage"):n("git.stage"),title:o.variant==="staged"?n("git.unstage"):n("git.stage"),onClick:()=>void b([o.change.path],o.variant==="staged"),disabled:R,children:e.jsx(Xt,{staged:o.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([o.change.path]),disabled:R,children:e.jsx(qt,{})}):null]})]},`file:${o.path}`)})}function Vn(a,i){return{kind:"directory",name:a,path:i,children:new Map}}function Wn(a,i){const u=Vn("","");for(const h of a){const g=h.path.replace(/\\/g,"/"),j=g.split("/").filter(Boolean);let f=u;j.forEach((x,b)=>{const v=j.slice(0,b+1).join("/");if(b===j.length-1){f.children.set(`file:${v}`,{kind:"file",name:x,path:g,change:h,status:hs(h,i),variant:i});return}const R=`directory:${v}`,S=f.children.get(R);if(S&&S.kind==="directory"){f=S;return}const T=Vn(x,v);f.children.set(R,T),f=T})}return ei(Qn([...u.children.values()]))}function Qn(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:Qn([...i.children.values()])}:i)}function ei(a){return a.map(i=>{var f;if(i.kind!=="directory")return i;const u=ei(i.children);let h=i.name,g=i.path,j=u;for(;j.length===1&&((f=j[0])==null?void 0:f.kind)==="directory";){const x=j[0];h=`${h}/${x.name}`,g=x.path,j=x.children}return{kind:"directory",name:h,path:g,children:j}})}function zn(a,i,u){const h=new Set(a);return i.filter(g=>It(g,u)&&h.has(g.path)).map(g=>g.path)}function Yt(a){const i=[],u=new Set;function h(g){if(g.kind==="file"){u.has(g.path)||(u.add(g.path),i.push(g.path));return}g.children.forEach(h)}return a.forEach(h),i}function It(a,i){return i==="staged"?!!a.stagedStatus:!!a.worktreeStatus}function hs(a,i){return i==="staged"?a.stagedStatus??a.status:a.worktreeStatus??a.status}function gs(a){return{subject:ti(a).trim(),body:null,footer:null,source:"manual"}}function ti(a){return a.replace(/[\r\n]+/g," ")}function fs(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 pe(a){const i=a.subject.trim(),u=a.body.trim();return u?`${i}
|
|
2
|
+
|
|
3
|
+
${u}`:i}function ps(a){const i=a.changedFiles.map(g=>`- [${g.status}] ${g.path}${g.oldPath?` (from ${g.oldPath})`:""}`).join(`
|
|
4
|
+
`),u=a.diffContent.length>$t?a.diffContent.slice(0,$t):a.diffContent,h=a.diffContent.length>$t||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||"- 无",h,"","Diff:",u||"(empty diff)"].join(`
|
|
6
|
+
`)}function bs(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 ni(a){switch(a){case"local":return n("git.historyKindLocal");case"remote":return n("git.historyKindRemote");default:return n("git.historyKindShared")}}function ii(a){if(!a)return 0;let i=0;for(const u of a)i=i*33+u.charCodeAt(0)>>>0;return i%6}function xs(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 qn?js(a)??a.message:typeof a=="object"&&a&&"message"in a?a.message:i}function ke(a){return`git-sidebar.snapshot.${a}`}function Bt(a){return a?!!(a.status||a.branches||a.history.length>0||a.historyTotalCount>0||a.historyNextCursor||a.revision):!1}function ys(a){return a?a.snapshot.enabled!==!1:!0}function js(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 Kn(a){return a instanceof qn&&a.errorCode==="GIT_REMOTE_AUTH_FAILED"}function Cs(a,i=!1){return!a||!a.mode||a.mode==="none"?ht:a.mode==="basic"?{authMode:"basic",username:a.username??"",password:a.password??"",token:"",rememberOnHost:i}:a.mode==="token"?{authMode:"token",username:a.username??"",password:"",token:a.token??"",rememberOnHost:i}:ht}function Ns(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 vs(a,i){const u=gt(a,i);if(!u)return"generic";const h=u.pushUrl||u.fetchUrl;return Ts(h)?"github":"generic"}function gt(a,i){return a.find(u=>u.name===i)??a.find(u=>u.name==="origin")??a[0]??null}function In(a){var i;return(i=gt(a))==null?void 0:i.name}function Ss(a,i){return i!=null&&i.auth?{kind:"session",label:n("git.remoteAuthConfiguredInSession")}:a.credentialConfigured?{kind:"host",label:n("git.remoteAuthConfiguredOnHost")}:{kind:"missing",label:n("git.remoteAuthNotConfigured")}}function Ts(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 Xn(a,i,u){const h=Math.max(0,u.width),g=Math.max(0,u.height),j=Math.max(0,g-O*2),f=Math.max(0,h-O*2),x=Math.min(Math.max(i.width||Kt,0),f),b=Math.max(0,g-a.bottom-mt-O),v=Math.max(0,a.top-mt-O),R=b<i.height&&v>b,T=Vt(Math.max(R?v:b,us),0,j),p=Math.min(Math.max(i.height,0),T),o=R?a.top-mt-p:a.bottom+mt,m=Math.max(O,g-O-p),y=Math.max(O,h-O-x);return{top:Vt(o,O,m),left:Vt(a.right-x,O,y),maxHeight:Math.max(0,T),transformOrigin:`${R?"bottom":"top"} right`}}function Vt(a,i,u){return!Number.isFinite(a)||u<i?i:Math.min(Math.max(a,i),u)}function ft({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 Xt({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 qt(){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 Ms(){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 si(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{Fs as GitSidebar,Xn as resolveGitOperationsMenuPosition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as c,j as e,t as n}from"./index-
|
|
1
|
+
import{b as c,j as e,t as n}from"./index-DvkfRpBe.js";import{e as j,M as f,f as p,h as g,i as M,j as S,k as v,S as L}from"./model-switch-api-Dps4yN2t.js";function E({open:o,workspaces:l,workspaceOptions:t,initialWorkspaceId:d,onClose:b,onSelect:x}){const[a,m]=c.useState(""),[h,u]=c.useState(!1),k=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&&(m(N(i,d)),u(!1))},[d,o,w]),!o)return null;const r=i.find(s=>s.workspace.id===a)??i[0]??null;return e.jsxs(f,{open:o,title:n("shell.createSessionModalTitle"),description:n("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(p,{className:"mobile-create-session-section",tone:"accent",children:e.jsxs(g,{label:n("shell.createSessionWorkspaceLabel"),children:[e.jsxs("button",{type:"button",className:"mobile-create-session-workspace-trigger","aria-label":`${n("shell.createSessionWorkspaceLabel")} ${(r==null?void 0:r.label)??""}`.trim(),"aria-expanded":h?"true":"false",disabled:i.length===0,onClick:()=>{k.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)??n("common.unknown")}),e.jsx("span",{children:(r==null?void 0:r.subtitle)??n("common.unknown")})]}),e.jsx(C,{expanded:h})]}),h?e.jsx(M,{className:"mobile-workspace-home-group mobile-create-session-workspace-list",role:"list",children:i.map(s=>e.jsx(S,{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===a,trailing:e.jsx("span",{className:"mobile-workspace-home-row-trailing",children:s.workspace.id===a?e.jsx(I,{}):e.jsx(y,{})}),style:{"--mobile-workspace-tree-depth":String(s.depth)},onClick:()=>{s.workspace.id!==a&&k.trigger("selection"),m(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(v,{className:"mobile-workspace-home-worktree-badge",children:n("shell.mobileWorktreeBadge")}):null,s.label]}),e.jsx("span",{children:s.subtitle})]})},s.workspace.id))}):null]})}),e.jsx(p,{className:"mobile-create-session-provider-block",heading:n("shell.createSessionProviderLabel"),children:e.jsx(L,{disabled:!a,workspaceId:a||null,onSelect:s=>{a&&x(a,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};
|
package/dist/public/assets/{MobileTopHeaderFrame-D-X7pVnV.js → MobileTopHeaderFrame-BawK1vUE.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as i}from"./index-
|
|
1
|
+
import{j as i}from"./index-DvkfRpBe.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as j,f as B,h as $,j as t,t as l}from"./index-
|
|
1
|
+
import{b as j,f as B,h as $,j as t,t as l}from"./index-DvkfRpBe.js";import{e as K,i as F,j as P,k as S,M as G}from"./model-switch-api-Dps4yN2t.js";import{be as q,m as z,bf as D,aI as X,bg as J}from"./WorkbenchLayout-Cht6Un5X.js";import{u as Q,f as V}from"./App-BRupl2Ul.js";import{M as Y}from"./MobileTopHeaderFrame-BawK1vUE.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=H(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 H(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=H(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:N,content:C,sheetContent:k,triggerLabel:M,triggerAriaLabel:L,onTriggerClick:c,trailing:A,gestureHandlers:I}){const[u,d]=j.useState(!1),[m,b]=j.useState(null),f=K(),y=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){b(U);try{e.host.id!==r.activeHostId&&(f.trigger("selection"),await D.switchHost(e.host.id)),e.kind==="host"?y(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{b(null)}}}return t.jsxs(t.Fragment,{children:[t.jsx(Y,{className:n,frameRef:w,...I,children:t.jsxs("section",{className:"mobile-workspace-home-header",children:[t.jsx("h1",{className:"mobile-workspace-switcher-heading",children:N??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}f.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(F,{className:"mobile-workspace-home-group mobile-workspace-home-sheet-group",children:O.map(e=>t.jsx(P,{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};
|
package/dist/public/assets/{RelayConnectEntryPage-D417tgWj.js → RelayConnectEntryPage-B0-OBZXu.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as m,b as d,e as g,j as n,t as i}from"./index-
|
|
1
|
+
import{o as m,b as d,e as g,j as n,t as i}from"./index-DvkfRpBe.js";import{u as p,c as f,d as y}from"./App-BRupl2Ul.js";import{b as E}from"./relay-entry-WiotM2TL.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};
|
package/dist/public/assets/{ServerSettingsModal-BdTxbRbU.js → ServerSettingsModal-P_pcDvyR.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as n,n as U,j as r,t as s,e as N}from"./index-
|
|
1
|
+
import{b as n,n as U,j as r,t as s,e as N}from"./index-DvkfRpBe.js";import{r as E,b as k}from"./relay-entry-WiotM2TL.js";import{a as h,s as O,t as P,v as w}from"./App-BRupl2Ul.js";import{W as T}from"./WorkbenchModal-CAj_TqWW.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};
|