@jingyi0605/codingns 0.5.0 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/public/assets/AdaptiveButlerPage-CUyNL98E.js +3 -0
  2. package/dist/public/assets/App-BFP7LCSC.js +30 -0
  3. package/dist/public/assets/{BootstrapPage-Vu5oEJ8z.js → BootstrapPage-G74dX2Us.js} +1 -1
  4. package/dist/public/assets/ConversationPage-Bz0_tvvM.js +2 -0
  5. package/dist/public/assets/{DesktopDetachPreviewPage-BgeEqbc5.js → DesktopDetachPreviewPage-IV7oEdOX.js} +1 -1
  6. package/dist/public/assets/DesktopWindowPage-BBmHyRg5.js +2 -0
  7. package/dist/public/assets/FileContextPanel--FVTxDrq.js +1 -0
  8. package/dist/public/assets/GitSidebar-DAiSi9oc.js +6 -0
  9. package/dist/public/assets/{MobileCreateSessionSheet-DLq5qPkx.js → MobileCreateSessionSheet-DqVwz_Hp.js} +1 -1
  10. package/dist/public/assets/MobileSheet-D1lMrcvD.js +1 -0
  11. package/dist/public/assets/{MobileTopHeaderFrame-DArgZI7L.js → MobileTopHeaderFrame-COTc7cRr.js} +1 -1
  12. package/dist/public/assets/{MobileWorkspaceSwitcherHeader-0ywJKfBQ.js → MobileWorkspaceSwitcherHeader-DJPV9ym2.js} +1 -1
  13. package/dist/public/assets/RelayConnectEntryPage-dSwU8VzK.js +1 -0
  14. package/dist/public/assets/{ServerSettingsModal-izoYMx9U.js → ServerSettingsModal-B34ms3ze.js} +1 -1
  15. package/dist/public/assets/{SessionIndexPage-C5aG8FIv.js → SessionIndexPage-D3tG1gmM.js} +1 -1
  16. package/dist/public/assets/SettingsPage-B3-6-5GL.js +1 -0
  17. package/dist/public/assets/TerminalManagerPanel-DhuTEdzV.js +1 -0
  18. package/dist/public/assets/{TerminalPage-CtKXIU0h.js → TerminalPage-DpsvQQVR.js} +19 -19
  19. package/dist/public/assets/{TerminalRuntimeFallbackModal-CRhOQOsT.js → TerminalRuntimeFallbackModal-CNzOt5v5.js} +1 -1
  20. package/dist/public/assets/{ToolFilesPage-DcYPsS-e.js → ToolFilesPage-BX9QDi9Y.js} +1 -1
  21. package/dist/public/assets/{ToolGitPage-CsPl89ty.js → ToolGitPage-4VtFox3p.js} +1 -1
  22. package/dist/public/assets/{ToolProcessesPage-D0dvR8xK.js → ToolProcessesPage-DZJC6Qnt.js} +1 -1
  23. package/dist/public/assets/{ToolsHomePage-4fP-KRiv.js → ToolsHomePage-D7JbrAWv.js} +1 -1
  24. package/dist/public/assets/{WorkbenchLandingPage-kvlfyxRo.js → WorkbenchLandingPage-C0yqnzqh.js} +1 -1
  25. package/dist/public/assets/WorkbenchLayout-Brlj8K3i.js +3 -0
  26. package/dist/public/assets/{WorkbenchModal-Ctob14VR.js → WorkbenchModal-CbDxaCOR.js} +1 -1
  27. package/dist/public/assets/WorkbenchShellRoute-BMcnFadA.css +1 -0
  28. package/dist/public/assets/WorkbenchShellRoute-puGpdDFY.js +1 -0
  29. package/dist/public/assets/{WorkspaceDebugDetailPage-Com5kEXJ.js → WorkspaceDebugDetailPage-fTGweC9N.js} +1 -1
  30. package/dist/public/assets/WorkspaceDetailPage-BtaIzSDB.js +1 -0
  31. package/dist/public/assets/WorkspaceHomePage-CUmmYDrM.js +1 -0
  32. package/dist/public/assets/client-runtime-manager-RHFa_iWo.js +1 -0
  33. package/dist/public/assets/{default-session-permission-mode-CcGwR4Kk.js → default-session-permission-mode-Cu5SreTG.js} +1 -1
  34. package/dist/public/assets/file-tree-icon-BMKuc5pw.js +31 -0
  35. package/dist/public/assets/index-Cq3ue0za.css +1 -0
  36. package/dist/public/assets/index-DEbFT-Aq.js +42 -0
  37. package/dist/public/assets/{preferences-service-KIYeE2gk.js → preferences-service-gv_9vGKz.js} +1 -1
  38. package/dist/public/assets/session-runtime-machine-Bfnxkk9B.js +17 -0
  39. package/dist/public/assets/{terminal-runtime-meta-AWXJpN4r.js → terminal-runtime-meta-B9xJGY__.js} +1 -1
  40. package/dist/public/assets/{useRegisteredDebugTemplates-DBDRdptr.js → useRegisteredDebugTemplates-CDfl54Wt.js} +1 -1
  41. package/dist/public/index.html +2 -2
  42. package/dist/server/config/env.d.ts +1 -0
  43. package/dist/server/config/env.js +36 -0
  44. package/dist/server/config/env.js.map +1 -1
  45. package/dist/server/modules/client/client-controller.js +1 -1
  46. package/dist/server/modules/client/client-controller.js.map +1 -1
  47. package/dist/server/modules/client/client-service.d.ts +16 -2
  48. package/dist/server/modules/client/client-service.js +21 -3
  49. package/dist/server/modules/client/client-service.js.map +1 -1
  50. package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-packets.d.ts +16 -1
  51. package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-packets.js.map +1 -1
  52. package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.d.ts +2 -1
  53. package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.js +18 -0
  54. package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.js.map +1 -1
  55. package/dist/server/modules/relay-tunnel/relay-tunnel-client-context.d.ts +13 -0
  56. package/dist/server/modules/relay-tunnel/relay-tunnel-client-context.js +2 -0
  57. package/dist/server/modules/relay-tunnel/relay-tunnel-client-context.js.map +1 -0
  58. package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.d.ts +6 -0
  59. package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.js +110 -10
  60. package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.js.map +1 -1
  61. package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.d.ts +16 -4
  62. package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js +216 -101
  63. package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js.map +1 -1
  64. package/dist/server/modules/relay-tunnel/relay-tunnel-service.d.ts +6 -2
  65. package/dist/server/modules/relay-tunnel/relay-tunnel-service.js +457 -40
  66. package/dist/server/modules/relay-tunnel/relay-tunnel-service.js.map +1 -1
  67. package/dist/server/modules/sessions/session-activity-inspector.js +6 -8
  68. package/dist/server/modules/sessions/session-activity-inspector.js.map +1 -1
  69. package/dist/server/modules/sessions/session-history-service.d.ts +1 -0
  70. package/dist/server/modules/sessions/session-history-service.js +62 -7
  71. package/dist/server/modules/sessions/session-history-service.js.map +1 -1
  72. package/dist/server/modules/workbench/snapshot-revision.d.ts +4 -0
  73. package/dist/server/modules/workbench/snapshot-revision.js +13 -0
  74. package/dist/server/modules/workbench/snapshot-revision.js.map +1 -0
  75. package/dist/server/modules/workbench/workbench-service.d.ts +33 -2
  76. package/dist/server/modules/workbench/workbench-service.js +39 -4
  77. package/dist/server/modules/workbench/workbench-service.js.map +1 -1
  78. package/dist/server/modules/workbench/workspace-panel-snapshot-service.d.ts +6 -1
  79. package/dist/server/modules/workbench/workspace-panel-snapshot-service.js +10 -8
  80. package/dist/server/modules/workbench/workspace-panel-snapshot-service.js.map +1 -1
  81. package/dist/server/server/create-server.js +11 -6
  82. package/dist/server/server/create-server.js.map +1 -1
  83. package/dist/server/types/domain.d.ts +9 -0
  84. package/dist/server/ws/workbench-ws-hub.js +295 -43
  85. package/dist/server/ws/workbench-ws-hub.js.map +1 -1
  86. package/dist/server/ws/ws-server.js +141 -8
  87. package/dist/server/ws/ws-server.js.map +1 -1
  88. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +33 -6
  89. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
  90. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +78 -36
  91. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
  92. package/package.json +1 -1
  93. package/dist/public/assets/AdaptiveButlerPage-R-XZw7pd.js +0 -3
  94. package/dist/public/assets/App-DkvE5EyM.js +0 -30
  95. package/dist/public/assets/ConversationPage-Cjpg6g0J.js +0 -2
  96. package/dist/public/assets/DesktopWindowPage-1WelvxdH.js +0 -2
  97. package/dist/public/assets/FileContextPanel-D_ghXJuW.js +0 -1
  98. package/dist/public/assets/GitSidebar-D9f9Jxwr.js +0 -6
  99. package/dist/public/assets/MobileSheet-DLg-gX1t.js +0 -1
  100. package/dist/public/assets/SettingsPage-HJIC-P-4.js +0 -1
  101. package/dist/public/assets/TerminalManagerPanel-DpyUTo9k.js +0 -1
  102. package/dist/public/assets/WorkbenchLayout-ByFw4eeu.js +0 -3
  103. package/dist/public/assets/WorkbenchShellRoute-BUITtdAg.css +0 -1
  104. package/dist/public/assets/WorkbenchShellRoute-Kw7JEZI3.js +0 -1
  105. package/dist/public/assets/WorkspaceDetailPage-D0Lrx4Uz.js +0 -1
  106. package/dist/public/assets/WorkspaceHomePage-wR8d3aP9.js +0 -1
  107. package/dist/public/assets/file-tree-icon-UFVoVzhM.js +0 -31
  108. package/dist/public/assets/index-Byp9hJ0c.js +0 -42
  109. package/dist/public/assets/index-_52jxu4a.css +0 -1
  110. package/dist/public/assets/session-runtime-machine-0KNSSPp5.js +0 -17
@@ -0,0 +1,6 @@
1
+ import{b as l,t as n,j as e,A as Bn}from"./index-DEbFT-Aq.js";import{u as Mi,e as Ei,f as Hi,g as jn}from"./App-BFP7LCSC.js";import{u as wi,X as it,r as Cn,aE as Nn,w as Ai,aF as Ri,aw as Pi,aG as vn,aH as Li,aI as Sn,aJ as Di,ay as _i,aK as Fi,ax as Oi,aL as ki,aM as Gi,aD as $i,aN as Tn,b as Bi,aO as Ui,aP as Vi}from"./WorkbenchLayout-Brlj8K3i.js";import{g as Wi}from"./default-session-permission-mode-Cu5SreTG.js";import{S as zi,v as Ki,w as Ii,e as Xi}from"./MobileSheet-D1lMrcvD.js";import{F as qi,a as Ft,b as Ot}from"./file-tree-icon-BMKuc5pw.js";import{W as Fe}from"./WorkbenchModal-CbDxaCOR.js";import"./window-BWqRixxq.js";import"./event-DvH9tcej.js";const wt=56,Mn=28,At=72,st=8,En=960,Hn=60*1e3,wn=20,An=9,Rn=9,Rt=68,_=12,at=8,kt=260,Yi=120,Pt=6e4,rt={authMode:"none",username:"",password:"",token:"",rememberOnHost:!1};function js({className:a,workspaceId:s,panelActive:u=!0,externalWindowMode:g=!1,workbenchShellOverrides:m}){const C=Mi(),x=Ei(),y=wi(),{subscribeGitSnapshot:b,requestGitRefresh:N,addGitSnapshotListener:M,requestNavigationRefresh:S,selectWorkspace:T,upsertNavigationSession:p}={...y,...m},[o,h]=l.useState(null),[j,E]=l.useState(null),[d,R]=l.useState([]),[w,de]=l.useState(0),[z,me]=l.useState(null),[he,lt]=l.useState(!1),[G,Ge]=l.useState(null),[ne,K]=l.useState(null),[ge,fe]=l.useState(""),[ct,U]=l.useState(!1),[v,P]=l.useState(!1),[Yn,Vt]=l.useState([]),[Q,Wt]=l.useState(!0),[ee,V]=l.useState(!1),[F,Zn]=l.useState(()=>typeof window<"u"?window.innerWidth<=En:!1),[ut,$]=l.useState([]),[pe,W]=l.useState(null),[xe,ie]=l.useState("unstaged"),[be,I]=l.useState(null),[se,X]=l.useState(null),[Jn,dt]=l.useState(!1),[Qn,mt]=l.useState(null),[ei,$e]=l.useState(!1),[zt,Be]=l.useState(null),[L,ye]=l.useState(null),[Kt,je]=l.useState(null),[ti,Ce]=l.useState(!1),[Ne,ae]=l.useState(null),[te,ht]=l.useState(!1),[ni,ve]=l.useState(!1),[ii,It]=l.useState([]),[us,Xt]=l.useState(!1),[Ue,gt]=l.useState(new Set),[si,Se]=l.useState(new Map),[Ve,qt]=l.useState(null),[ai,Te]=l.useState(!1),[A,q]=l.useState(rt),[Yt,We]=l.useState("generic"),[Zt,ze]=l.useState(null),[O,ft]=l.useState(null),[k,pt]=l.useState(null),[Jt,Qt]=l.useState(wt),[xt,bt]=l.useState(!1),[en,Me]=l.useState(null),[ri,Ee]=l.useState(null),tn=l.useRef(null),nn=l.useRef(null),sn=l.useRef(null),an=l.useRef(null),rn=l.useRef(null),on=l.useRef(null),yt=l.useRef(null),He=l.useRef(new Map),Ke=l.useRef(new Map),we=l.useRef(0),ln=l.useRef(u),cn=l.useRef(u),Ie=l.useRef(null),{showToast:H}=Hi(),un=x.isDesktop&&!F;l.useEffect(()=>{it("git_sidebar.props",{workspaceId:s,externalWindowMode:g})},[g,s]),l.useEffect(()=>{cn.current=u},[u]),l.useEffect(()=>{Vt([]),Wt(!0),de(0),me(null),lt(!1),K(null),fe(""),V(!1),$([]),W(null),ie("unstaged"),I(null),X(null),dt(!1),mt(null),$e(!1),Be(null),ye(null),je(null),Ce(!1),ae(null),ht(!1),ve(!1),It([]),gt(new Set),Se(new Map),qt(null),Te(!1),q(rt),We("generic"),ze(null),ft(null),pt(null),bt(!1),Qt(wt),Me(null),Ee(null),Ke.current.clear(),He.current.clear()},[s]),l.useEffect(()=>{function t(){Zn(window.innerWidth<=En)}return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),l.useEffect(()=>{if(!xt)return;const t=document.body.style.cursor,i=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";function r(f){fn(f.clientY)}function c(){bt(!1)}return window.addEventListener("pointermove",r),window.addEventListener("pointerup",c),()=>{document.body.style.cursor=t,document.body.style.userSelect=i,window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",c)}},[xt]),l.useEffect(()=>{var c,f;if(!(s!=null&&s.trim())){Ie.current=null,h(null),E(null),R([]),de(0),me(null),Ge(null),U(!1);return}const t=s.trim(),i=Cn(Oe(t),Hn),r=Dt(i);if(it("git_sidebar.snapshot",{workspaceId:t,cached:r,cachedHistoryCount:((c=i==null?void 0:i.history)==null?void 0:c.length)??0,cachedChangedCount:((f=i==null?void 0:i.status)==null?void 0:f.changes.length)??0}),r&&i){jt(i,t),U(!1);return}Ie.current=null,Nn(Oe(t)),h(null),E(null),R([]),de(0),me(null),Ge(null),U(!0)},[s]),l.useEffect(()=>{if(s!=null&&s.trim())return M(t=>{var i,r,c;t.workspaceId===s.trim()&&(it("git_sidebar.snapshot_received",{workspaceId:t.workspaceId,changedCount:((i=t.status)==null?void 0:i.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)}),jt(t,t.workspaceId),U(!1))})},[M,s]),l.useEffect(()=>{if(!(s!=null&&s.trim()))return;const t=s.trim(),i=Cn(Oe(t),Hn),r=Dt(i)?(i==null?void 0:i.revision)??null:null;b(t,{knownRevision:r}),cn.current&&Y()},[N,b,s]),l.useEffect(()=>{const t=ln.current;ln.current=u,s!=null&&s.trim()&&!t&&u&&N(s.trim(),{knownRevision:j})},[u,N,j,s]),l.useEffect(()=>{const t=s==null?void 0:s.trim();if(!t||Ie.current!==t)return;const i={revision:j,status:o,history:d,historyTotalCount:w,historyNextCursor:z,branches:G};if(!Dt(i)){Nn(Oe(t));return}Ai(Oe(t),i)},[G,d,z,w,j,o,s]),l.useEffect(()=>{if(!o||!ne)return;o.changes.find(i=>i.path===ne)||K(null)},[ne,o]),l.useEffect(()=>{ns(an.current)},[ge]),l.useEffect(()=>{F||($([]),W(null),I(null),ze(null))},[F]),l.useEffect(()=>{if(!o){$([]);return}const t=new Set(o.changes.map(i=>i.path));$(i=>i.filter(r=>t.has(r)))},[o]);function oi(){const t=sn.current;if(!t)return;t.querySelectorAll(".git-tree-shell").forEach(r=>{r.scrollTop=0})}function jt(t,i){Ie.current=(i==null?void 0:i.trim())??(s==null?void 0:s.trim())??null,E(typeof t.revision=="string"?t.revision:null),h(t.status),R(Array.isArray(t.history)?t.history:[]),de(typeof t.historyTotalCount=="number"?t.historyTotalCount:0),me(typeof t.historyNextCursor=="string"?t.historyNextCursor:null),Ge(t.branches??null)}function Y(t){s!=null&&s.trim()&&(U(!0),it("git_sidebar.refresh_requested",{workspaceId:s.trim(),resetTreeScroll:!1}),N(s.trim(),{knownRevision:j}))}async function Ct(t){if(!(s!=null&&s.trim()))return;const i=s.trim();U(!0);try{const[r,c,f]=await Promise.all([Pi(i),vn(i,wn,null),Li(i)]);jt({status:r,history:c.items,historyTotalCount:c.totalCount,historyNextCursor:c.nextCursor,branches:f}),N(i),t!=null&&t.resetTreeScroll&&requestAnimationFrame(()=>{oi()})}catch(r){H({title:D(r,n("git.panelLoadFailed")),tone:"error"})}finally{U(!1)}}async function Xe(){if(!(!s||!z||he)){lt(!0);try{const t=await vn(s,wn,z);R(i=>{const r=new Set(i.map(f=>f.commitHash)),c=t.items.filter(f=>!r.has(f.commitHash));return[...i,...c]}),de(t.totalCount),me(t.nextCursor)}catch(t){H({title:D(t,n("git.panelLoadFailed")),tone:"error"})}finally{lt(!1)}}}function li(t){if(!Q||he||!z)return;const i=t.currentTarget;i.scrollHeight-i.scrollTop-i.clientHeight<=40&&Xe()}async function ci(){if(s){P(!0);try{const t=await Ri(s,"ai");fe(t.validation.normalizedDraft.subject||t.draft.subject)}catch(t){H({title:D(t,n("git.draftFailed")),tone:"error"})}finally{P(!1)}}}async function qe(t,i){if(s&&t.length){P(!0);try{const r=i?await Fi(s,t):await Oi(s,t);h(r),K(t[t.length-1]??null),$(c=>c.filter(f=>!t.includes(f))),W(null),Y()}catch(r){U(!1),H({title:D(r,n("git.stageFailed")),tone:"error"})}finally{P(!1)}}}async function Nt(t){if(s&&t.length){P(!0);try{const i=await Gi(s,t);h(i),t.includes(ne??"")&&K(null),$(r=>r.filter(c=>!t.includes(c))),W(null),Y()}catch(i){U(!1),H({title:D(i,n("git.discardFailed")),tone:"error"})}finally{P(!1)}}}async function ui(){if(!(!s||!ge.trim())){P(!0);try{await Di(s,es(ge)),H({title:n("git.commitSuccess"),tone:"success"}),fe(""),K(null),Y()}catch(t){H({title:D(t,n("git.commitFailed")),tone:"error"})}finally{P(!1)}}}function Ye(t){q(as(Ve)),Te(!0),di(t)}async function di(t){const i=s==null?void 0:s.trim();if(!i){We("generic");return}try{const r=await Sn(i);if((s==null?void 0:s.trim())!==i)return;We(os(r,t))}catch{if((s==null?void 0:s.trim())!==i)return;We("generic")}}function mi(){const t=rs(A),i=Yt==="github"?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder");if(A.authMode==="basic"){if(!A.username.trim()){H({title:n("shell.cloneUsernamePlaceholder"),tone:"error"});return}if(!A.password){H({title:i,tone:"error"});return}}if(A.authMode==="token"&&!A.token){H({title:n("shell.cloneTokenPlaceholder"),tone:"error"});return}qt(t),Te(!1),H({title:t?n("git.remoteAuthSaved"):n("git.remoteAuthCleared"),description:t&&A.rememberOnHost?n("git.remoteAuthRememberHint"):void 0,tone:"success"})}async function dn(){if(s){Xt(!0);try{const t=await Sn(s);if(t.length===0){H({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){mn([t[0].name]);return}It(t),gt(new Set),Se(new Map),ve(!0)}catch(t){H({title:D(t,n("git.remoteFailed")),tone:"error"})}finally{Xt(!1)}}}async function mn(t){if(!s||t.length===0)return;P(!0),Se(new Map);const i=new Map;let r=!1;try{for(const c of t)try{const f=await Tn(s,"push",c,Ve,A.rememberOnHost);i.set(c,{ok:!0,summary:f.summary})}catch(f){if(r=!0,i.set(c,{ok:!1,summary:D(f,n("git.remoteFailed"))}),Se(new Map(i)),Gn(f)){Ye(c);return}}Se(i),Y(),r||(H({title:n("git.pushAllSuccess",{count:String(t.length)}),tone:"success"}),ve(!1))}finally{P(!1)}}async function vt(t){if(s){if(t==="push"){V(!1),dn();return}P(!0);try{const i=await Tn(s,t,void 0,Ve,A.rememberOnHost);H({title:i.summary,tone:"success"}),V(!1),Y()}catch(i){if(Gn(i)){Ye();return}H({title:D(i,n("git.remoteFailed")),tone:"error"})}finally{P(!1)}}}async function re(){if(s){P(!0);try{const t=await ki(s);fe(t.commitSubject??""),H({title:t.summary||n("git.undoLastCommitSuccess"),tone:"success"}),V(!1),Y()}catch(t){H({title:D(t,n("git.undoLastCommitFailed")),tone:"error"})}finally{P(!1)}}}async function hi(t){if(s){P(!0);try{const i=await Ui(s,t,!1);Ge(i),V(!1),Y()}catch(i){H({title:D(i,n("git.branchFailed")),tone:"error"})}finally{P(!1)}}}async function St(t){const i=s==null?void 0:s.trim();if(!i)throw new Error(n("git.panelLoadFailed"));const r=Ke.current.get(t);if(r)return r;const c=await Vi(i,t);return Ke.current.set(t,c),c}async function Ae(t){X(null),I(null),mt(t),Be(null);const i=Ke.current.get(t)??null;if(ye(i),$e(!i),i)return;const r=we.current+1;we.current=r;try{const c=await St(t);if(we.current!==r)return;ye(c)}catch(c){if(we.current!==r)return;Be(D(c,n("git.commitDetailLoadFailed"))),ye(null)}finally{we.current===r&&$e(!1)}}function gi(){mt(null),$e(!1),Be(null),ye(null)}async function Re(t){try{const i=await St(t);await B(i.versionLabel,n("git.copyCommitVersionSuccess"))}catch(i){H({title:D(i,n("git.commitDetailLoadFailed")),tone:"error"})}}function Pe(t){X(null),I(null),je(t),ae(null),Ce(!0)}function fi(t){var r;const i=((r=d[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 B(t.commitHash,n("git.copyCommitHashSuccess"))},{id:`copy-message:${t.commitHash}`,label:n("git.copyCommitMessage"),onSelect:()=>void B(ue(t),n("git.copyCommitMessageSuccess"))},{id:`copy-version:${t.commitHash}`,label:n("git.copyCommitVersion"),onSelect:()=>void Re(t.commitHash)},{id:`explain:${t.commitHash}`,label:n("git.explainCommitAction"),onSelect:()=>Pe(t.commitHash)},...i?[{id:`undo:${t.commitHash}`,label:n("git.undoLastCommit"),disabled:v,onSelect:()=>void re()}]:[]]}async function hn(t){X(null),I(null),await $i(fi(t))}async function pi(){var t,i;if(!(!s||!Kt||!Ne||te)){ht(!0);try{const r=await St(Kt),c=await Ki({workspaceId:s,provider:Ne,content:ts(r),clientRequestId:((i=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:i.call(t))??`git-explain-${Date.now()}-${Math.random().toString(16).slice(2)}`,permissionMode:Wi()}),f=c.session??await Ii(c.sessionId);p(f),S(),T(f.workspaceId),C(Bi(f.workspaceId,f.sessionId)),Ce(!1),je(null),ae(null),H({title:n("git.explainCommitStarted"),tone:"success"})}catch(r){H({title:D(r,n("git.explainCommitFailed")),tone:"error"})}finally{ht(!1)}}}function Ze(t){Vt(i=>i.includes(t)?i.filter(r=>r!==t):[...i,t])}const xi=450;function gn(t){const i=Date.now(),r=tn.current;return tn.current={filePath:t,timestamp:i},(r==null?void 0:r.filePath)===t&&i-r.timestamp<=xi}async function Je(t,i){if(i.binary){H({title:n("git.binaryDiff"),tone:"info"});return}if(i.status==="A"||i.status==="?")Ee(null),Me(t);else if(s)try{const r=await _i(s,t,i.staged);Ee(r.content),Me(t)}catch{Ee(null),Me(t)}}function Qe(t){K(t),W(null),$(i=>i.includes(t)?i.filter(r=>r!==t):[...i,t])}function fn(t){const i=nn.current;if(!i||!Number.isFinite(t))return;const r=i.getBoundingClientRect(),c=r.height-st;if(!Number.isFinite(r.top)||!Number.isFinite(r.height)||c<=0)return;const f=(t-r.top-st/2)/c*100;if(!Number.isFinite(f))return;const _e=Math.max(Mn,Math.min(At,Math.round(f)));Qt(_e)}function bi(t){t.preventDefault(),fn(t.clientY),bt(!0)}const Le=(o==null?void 0:o.changes)??[],Z=Le.filter(t=>Gt(t,"staged")),oe=Le.filter(t=>Gt(t,"unstaged")),pn=On(Z,"staged"),xn=On(oe,"unstaged"),et=new Set(Yn),tt=new Set(ut),le=kn(ut,Le,"staged"),ce=kn(ut,Le,"unstaged"),Tt=Le.length===0&&((o==null?void 0:o.snapshot.ahead)??0)>0,yi=Z.length>0&&ge.trim().length>0,nt=(G==null?void 0:G.currentBranch)??(o==null?void 0:o.snapshot.branch)??n("common.unknown"),Mt=Ve!==null,De=Yt==="github",ji=De?n("git.remoteAuthDescriptionGithub"):n("git.remoteAuthDescription"),Ci=De?n("git.remoteAuthGithubPatLabel"):n("shell.clonePasswordLabel"),Ni=De?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder"),vi=De?n("git.remoteAuthGithubUsernamePlaceholder"):n("shell.cloneUsernamePlaceholder"),Et=Number.isFinite(Jt)?Jt:wt,Si=Q?`minmax(120px, ${Et}fr) ${st}px minmax(140px, ${100-Et}fr)`:`minmax(120px, 1fr) ${st}px auto`;l.useEffect(()=>{pe==="staged"&&le.length===0&&W(null),pe==="unstaged"&&ce.length===0&&W(null)},[pe,le.length,ce.length]),l.useEffect(()=>{if(!F)return;const t=oe.length>0?"unstaged":Z.length>0?"staged":"history";ie(i=>i==="unstaged"&&oe.length>0||i==="staged"&&Z.length>0?i:t)},[F,Z.length,oe.length]),l.useEffect(()=>{be&&(d.some(t=>t.commitHash===be)||I(null))},[d,be]),l.useEffect(()=>{se&&(d.some(t=>t.commitHash===se)||X(null))},[se,d]),l.useEffect(()=>{F&&xe!=="history"&&ee&&V(!1)},[F,ee,xe]),l.useLayoutEffect(()=>{if(F||!ee){ft(null);return}function t(){const r=rn.current,c=on.current;!r||!c||typeof window>"u"||ft($n(r.getBoundingClientRect(),{width:c.getBoundingClientRect().width||kt,height:c.getBoundingClientRect().height||c.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}t();const i=window.requestAnimationFrame(t);return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.cancelAnimationFrame(i),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[v,G==null?void 0:G.local.length,nt,F,ee,Mt]);const J=be??se;l.useLayoutEffect(()=>{if(!J){pt(null);return}const t=J;function i(){const c=He.current.get(t)??null,f=yt.current;!c||!f||typeof window>"u"||pt($n(c.getBoundingClientRect(),{width:f.getBoundingClientRect().width||kt,height:f.getBoundingClientRect().height||f.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}i();const r=window.requestAnimationFrame(i);return window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),()=>{window.cancelAnimationFrame(r),window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}},[J,d.length]),l.useEffect(()=>{if(!J||typeof document>"u")return;const t=J;function i(r){const c=r.target;if(!(c instanceof Node))return;const f=He.current.get(t)??null,_e=yt.current;f!=null&&f.contains(c)||_e!=null&&_e.contains(c)||(I(null),X(null))}return document.addEventListener("pointerdown",i),()=>{document.removeEventListener("pointerdown",i)}},[J]);async function B(t,i){var r;try{if(typeof navigator>"u"||!((r=navigator.clipboard)!=null&&r.writeText))throw new Error("clipboard unavailable");await navigator.clipboard.writeText(t),H({title:i,tone:"success"})}catch{H({title:n("common.copyContentFailed"),tone:"error"})}}async function bn(t,i){typeof window<"u"&&!window.confirm(n("git.discardConfirm",{path:i}))||await Nt(t)}function yn(t){const i=(t==null?void 0:t.desktopFloating)===!0&&!F,r=i?{top:(O==null?void 0:O.top)??_,left:(O==null?void 0:O.left)??_,maxHeight:O==null?void 0:O.maxHeight,transformOrigin:(O==null?void 0:O.transformOrigin)??"top right"}:void 0,c=e.jsxs("div",{ref:i?on:void 0,className:"git-operations-menu","data-floating":i?"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:nt})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.remoteAuthStatusLabel")}),e.jsxs("div",{className:"git-menu-branch-list",children:[e.jsx("strong",{className:"git-menu-branch",children:Mt?n("git.remoteAuthConfigured"):n("git.remoteAuthNotConfigured")}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>Ye(),children:e.jsx("span",{children:n("git.remoteAuthAction")})})]})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.branchTitle")}),e.jsx("div",{className:"git-menu-branch-list",children:G==null?void 0:G.local.map(f=>e.jsx("button",{className:"git-menu-item",type:"button",disabled:v||f.current,onClick:()=>void hi(f.name),children:e.jsx("span",{children:f.current?`${n("git.switchBranch")} ${f.name}`:`${n("git.switchBranchTo")} ${f.name}`})},f.name))})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>{V(!1),dt(!0)},children:e.jsx("span",{children:n("git.viewAllVersions")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void vt("fetch"),children:e.jsx("span",{children:n("git.fetch")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void vt("pull"),children:e.jsx("span",{children:n("git.pull")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void vt("push"),children:e.jsx("span",{children:n("git.push")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void re(),children:e.jsx("span",{children:n("git.undoLastCommit")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v||ct,onClick:()=>void Ct({resetTreeScroll:!0}),children:e.jsx("span",{children:n("git.refresh")})})]})]});return i?typeof document>"u"?null:jn.createPortal(c,document.body):c}function Ht(t,i){if(i){He.current.set(t,i);return}He.current.delete(t)}function Ti(){var r;if(!J||typeof document>"u")return null;const t=d.find(c=>c.commitHash===J);if(!t)return null;const i=((r=d[0])==null?void 0:r.commitHash)===t.commitHash&&t.commitKind==="local";return jn.createPortal(e.jsx("div",{ref:yt,className:"git-history-entry-menu","data-floating":"true",style:{top:(k==null?void 0:k.top)??_,left:(k==null?void 0:k.left)??_,maxHeight:k==null?void 0:k.maxHeight,transformOrigin:(k==null?void 0:k.transformOrigin)??"top right"},children:e.jsx(Ji,{item:t,canUndo:i,actioning:v,onViewCommitChanges:c=>void Ae(c),onCopyCommitHash:c=>void B(c,n("git.copyCommitHashSuccess")),onCopyCommitMessage:c=>void B(ue(c),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:c=>void Re(c),onExplainCommitChange:c=>void Pe(c),onUndoLastCommit:()=>void re()})}),document.body)}return e.jsxs("section",{className:["conversation-panel","surface-card","git-sidebar",a].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:[e.jsxs("section",{className:"git-card git-scaffold-section",children:[e.jsxs("div",{className:"git-editor-row",children:[e.jsx("textarea",{ref:an,rows:1,value:ge,onChange:t=>fe(Kn(t.target.value)),onKeyDown:t=>{t.key==="Enter"&&t.preventDefault()},placeholder:n("git.commitSubjectPlaceholder")}),e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.generateDraft"),title:n("git.generateDraft"),onClick:()=>void ci(),disabled:v||ct,children:e.jsx(cs,{})})]}),e.jsxs("div",{className:"git-primary-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Ct({resetTreeScroll:!0}),disabled:v||ct||!s,children:n("git.refreshNow")}),e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>{if(Tt){dn();return}ui()},disabled:v||!Tt&&!yi,children:Tt?n("git.pushNow"):n("git.commitNow")})]})]}),F?e.jsxs("div",{className:"git-mobile-sections",children:[e.jsx(Lt,{title:n("git.stagedChangesTitle"),count:Z.length,expanded:xe==="staged",onToggle:()=>ie("staged"),children:e.jsx(Ln,{title:n("git.stagedChangesTitle"),nodes:pn,collapsedTreePathSet:et,onToggleTreePath:Ze,onToggleMobileSelection:Qe,selectedMobilePathSet:tt,selectedTargets:le,actioning:v,variant:"staged",swipeRowState:Zt,onSwipeRowChange:ze,onStageToggle:qe,onDiscardWithConfirm:bn,onClearSelectedTargets:()=>$(t=>t.filter(i=>!le.includes(i))),onPreviewFile:Je})}),e.jsx(Lt,{title:n("git.changesTitle"),count:oe.length,expanded:xe==="unstaged",onToggle:()=>ie("unstaged"),children:e.jsx(Ln,{title:n("git.changesTitle"),nodes:xn,collapsedTreePathSet:et,onToggleTreePath:Ze,onToggleMobileSelection:Qe,selectedMobilePathSet:tt,selectedTargets:ce,actioning:v,variant:"unstaged",swipeRowState:Zt,onSwipeRowChange:ze,onStageToggle:qe,onDiscardWithConfirm:bn,onClearSelectedTargets:()=>$(t=>t.filter(i=>!ce.includes(i))),onPreviewFile:Je})}),e.jsxs(Lt,{title:n("git.recentVersionsTitle"),count:w,expanded:xe==="history",onToggle:()=>ie("history"),trailingContent:e.jsx("span",{className:"badge",children:nt}),headerAction:e.jsx("button",{className:"git-icon-button git-mobile-section-action",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),"aria-expanded":ee,onClick:()=>{ie("history"),V(t=>!t)},disabled:v,children:e.jsx(ke,{})}),children:[ee?e.jsx("div",{className:"git-mobile-operations-shell",children:yn()}):null,e.jsx(Zi,{history:d,historyLoadingMore:he,hasMore:!!z,actioning:v,openCommitHash:be,onMenuTriggerRef:Ht,onToggleMenu:t=>I(i=>i===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void B(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void B(ue(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Re(t),onExplainCommitChange:t=>void Pe(t),onUndoLastCommit:()=>void re(),onLoadMore:()=>void Xe()})]})]}):e.jsxs("div",{ref:nn,className:"git-content-split",style:{gridTemplateRows:Si},children:[e.jsx("section",{className:"git-card git-tree-panel",children:e.jsxs("div",{ref:sn,className:"git-tree-panel-body",children:[Z.length>0?e.jsx(Pn,{title:n("git.stagedChangesTitle"),count:Z.length,nodes:pn,selectedPath:ne,collapsedTreePathSet:et,onToggleTreePath:Ze,onSelectFile:K,onPreviewFile:(t,i)=>{gn(t)&&Je(t,i)},onToggleMobileSelection:Qe,onStageToggle:qe,onDiscard:Nt,actioning:v,variant:"staged",isMobileViewport:F,selectedMobilePathSet:tt,selectedTargets:le,mobileActionMenuOpen:pe==="staged",onToggleMobileActionMenu:()=>W(t=>t==="staged"?null:"staged"),onClearSelectedTargets:()=>$(t=>t.filter(i=>!le.includes(i)))}):null,e.jsx(Pn,{title:n("git.changesTitle"),count:oe.length,nodes:xn,selectedPath:ne,collapsedTreePathSet:et,onToggleTreePath:Ze,onSelectFile:K,onPreviewFile:(t,i)=>{gn(t)&&Je(t,i)},onToggleMobileSelection:Qe,onStageToggle:qe,onDiscard:Nt,actioning:v,variant:"unstaged",isMobileViewport:F,selectedMobilePathSet:tt,selectedTargets:ce,mobileActionMenuOpen:pe==="unstaged",onToggleMobileActionMenu:()=>W(t=>t==="unstaged"?null:"unstaged"),onClearSelectedTargets:()=>$(t=>t.filter(i=>!ce.includes(i)))})]})}),e.jsx("button",{className:"git-panel-divider",type:"button",role:"separator","aria-label":n("git.resizePanels"),"aria-orientation":"horizontal","aria-valuemin":Mn,"aria-valuemax":At,"aria-valuenow":Q?Et:At,"data-dragging":xt,onPointerDown:bi,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":Q,"aria-label":Q?n("git.collapseRecentVersions"):n("git.expandRecentVersions"),onClick:()=>Wt(t=>!t),children:[e.jsxs("span",{className:"git-section-toggle-main",children:[e.jsx(ot,{expanded:Q}),e.jsx("span",{children:n("git.recentVersionsTitle")})]}),e.jsx("span",{className:"workbench-section-counter",children:w})]}),e.jsxs("div",{className:"git-history-actions",children:[e.jsx("span",{className:"badge",children:nt}),e.jsx("button",{className:"git-icon-button",type:"button",ref:rn,"aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:()=>V(t=>!t),disabled:v,children:e.jsx(ke,{})}),ee?yn({desktopFloating:!0}):null]})]}),Q?e.jsx(_n,{history:d,historyLoadingMore:he,hasMore:!!z,actioning:v,openCommitHash:se,useNativeContextMenu:un,onMenuTriggerRef:Ht,onScroll:li,onToggleMenu:t=>{if(un){const i=d.find(r=>r.commitHash===t);i&&hn(i);return}X(i=>i===t?null:t)},onOpenContextMenu:t=>void hn(t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void B(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void B(ue(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Re(t),onExplainCommitChange:t=>void Pe(t),onUndoLastCommit:()=>void re(),onLoadMore:()=>void Xe()}):null]})]}),e.jsxs(Fe,{open:ni,title:n("git.selectRemoteTitle"),description:n("git.selectRemoteDesc"),onClose:()=>{v||ve(!1)},children:[e.jsxs("div",{className:"git-remote-auth-banner",children:[e.jsxs("div",{className:"git-remote-auth-banner-copy",children:[e.jsx("strong",{children:n("git.remoteAuthStatusLabel")}),e.jsx("span",{children:Mt?n("git.remoteAuthConfigured"):n("git.remoteAuthNotConfigured")})]}),e.jsx("button",{className:"secondary-button",type:"button",disabled:v,onClick:()=>Ye(),children:n("git.remoteAuthAction")})]}),e.jsx("div",{className:"git-remote-select-list",children:ii.map(t=>{const i=Ue.has(t.name),r=si.get(t.name);return e.jsxs("label",{className:"git-remote-item",children:[e.jsx("input",{type:"checkbox",checked:i,disabled:v,onChange:()=>{gt(c=>{const f=new Set(c);return f.has(t.name)?f.delete(t.name):f.add(t.name),f})}}),e.jsxs("span",{className:"git-remote-item-body",children:[e.jsx("span",{className:"git-remote-name",children:t.name}),e.jsx("span",{className:"git-remote-url",children:t.pushUrl}),r&&e.jsx("span",{className:`git-remote-result ${r.ok?"ok":"err"}`,children:r.summary})]})]},t.name)})}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:v,onClick:()=>ve(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:v||Ue.size===0,onClick:()=>void mn(Array.from(Ue)),children:v?n("git.pushing"):n("git.pushSelected",{count:String(Ue.size)})})]})]}),e.jsxs(Fe,{open:ai,title:n("git.remoteAuthTitle"),description:ji,onClose:()=>{v||Te(!1)},children:[e.jsxs("div",{className:"workbench-clone-form",children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneAuthModeLabel")}),e.jsxs("select",{value:A.authMode,disabled:v,onChange:t=>q(i=>({...i,authMode:t.target.value})),children:[e.jsx("option",{value:"none",children:n("shell.cloneAuthModeNone")}),e.jsx("option",{value:"basic",children:n("shell.cloneAuthModeBasic")}),e.jsx("option",{value:"token",children:n("shell.cloneAuthModeToken")})]})]}),A.authMode==="basic"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneUsernameLabel")}),e.jsx("input",{type:"text",value:A.username,placeholder:vi,autoComplete:"username",onChange:t=>q(i=>({...i,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:Ci}),e.jsx("input",{type:"password",value:A.password,placeholder:Ni,autoComplete:"current-password",onChange:t=>q(i=>({...i,password:t.target.value}))})]})]}):null,A.authMode==="token"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneUsernameLabel")}),e.jsx("input",{type:"text",value:A.username,placeholder:n("shell.cloneTokenUsernamePlaceholder"),autoComplete:"username",onChange:t=>q(i=>({...i,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneTokenLabel")}),e.jsx("input",{type:"password",value:A.token,placeholder:n("shell.cloneTokenPlaceholder"),autoComplete:"current-password",onChange:t=>q(i=>({...i,token:t.target.value}))})]})]}):null,De?e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthGithubPatHint")}):null,A.authMode!=="none"?e.jsxs("label",{className:"settings-checkbox git-remote-auth-remember-toggle",children:[e.jsx("input",{type:"checkbox",checked:A.rememberOnHost,onChange:t=>q(i=>({...i,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:v,onClick:()=>Te(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:v,onClick:mi,children:n("git.remoteAuthSave")})]})]}),e.jsx(Fe,{open:Jn,title:n("git.viewAllVersions"),description:n("git.viewAllVersionsDescription",{count:String(w)}),onClose:()=>dt(!1),children:e.jsx(_n,{history:d,historyLoadingMore:he,hasMore:!!z,actioning:v,openCommitHash:se,className:"git-history-modal-list",onMenuTriggerRef:Ht,onToggleMenu:t=>X(i=>i===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void B(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void B(ue(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Re(t),onExplainCommitChange:t=>void Pe(t),onUndoLastCommit:()=>void re(),onLoadMore:()=>void Xe()})}),e.jsx(Fe,{open:Qn!==null,className:"git-commit-detail-modal",title:(L==null?void 0:L.subject)||n("git.commitDetailTitle"),description:L?n("git.commitDetailDescription",{hash:L.shortHash}):n("git.commitDetailLoading"),onClose:gi,children:ei?e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailLoading")})}):zt?e.jsx("div",{className:"git-commit-detail-state is-error",children:e.jsx("p",{children:zt})}):L?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:L.versionLabel})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitHashLabel")}),e.jsx("strong",{children:L.commitHash})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitAuthorLabel")}),e.jsx("strong",{children:L.authorName})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitTimeLabel")}),e.jsx("strong",{children:is(L.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:ue(L)})]}),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:L.changedFiles.length})]}),e.jsx("div",{className:"git-commit-detail-file-list",children:L.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")}),L.diffTruncated?e.jsx("span",{className:"git-commit-detail-truncated",children:n("git.diffTruncated")}):null]}),e.jsx("pre",{className:"git-commit-detail-diff",children:L.diffContent||n("git.emptyDiff")})]})]}):e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailEmpty")})})}),e.jsx(Fe,{open:ti,className:"git-explain-provider-modal",title:n("git.explainCommitTitle"),description:n("git.explainCommitDescription"),onClose:()=>{te||(Ce(!1),je(null),ae(null))},children:e.jsxs("div",{className:"git-explain-provider-shell",children:[e.jsx(zi,{workspaceId:s,selectedProvider:Ne,pendingProvider:te?Ne:null,disabled:te,onSelect:t=>ae(t)}),e.jsxs("div",{className:"git-explain-provider-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:te,onClick:()=>{Ce(!1),je(null),ae(null)},children:n("common.cancel")}),e.jsx("button",{type:"button",className:"primary-button",disabled:!Ne||te,onClick:()=>void pi(),children:te?n("conversation.sendingState"):n("git.startExplainCommit")})]})]})}),e.jsx(qi,{workspaceId:s,filePath:en,open:en!==null,onClose:()=>{Me(null),Ee(null)},onSaved:async()=>{await Ct({resetTreeScroll:!0})},diffContent:ri}),Ti()]})}function Pn({title:a,count:s,nodes:u,selectedPath:g,collapsedTreePathSet:m,onToggleTreePath:C,onSelectFile:x,onPreviewFile:y,onToggleMobileSelection:b,onStageToggle:N,onDiscard:M,actioning:S,variant:T,isMobileViewport:p,selectedMobilePathSet:o,selectedTargets:h,mobileActionMenuOpen:j,onToggleMobileActionMenu:E,onClearSelectedTargets:d}){const R=Ut(u),w=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:s}),!p&&R.length>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":w,title:w,onClick:()=>void N(R,T==="staged"),disabled:S,children:e.jsx($t,{staged:T==="staged"})}),T==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":n("git.discardAll"),title:n("git.discardAll"),onClick:()=>void M(R),disabled:S,children:e.jsx(Bt,{})}):null]}):null,p&&h.length>0?e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:E,disabled:S,children:e.jsx(ke,{})}):null]}),p&&j?e.jsxs("div",{className:"git-selection-menu",children:[e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.selectedFiles")}),e.jsx("strong",{className:"git-menu-branch",children:h.length})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void N(h,T==="staged"),children:e.jsx("span",{children:T==="staged"?n("git.unstage"):n("git.stage")})}),T==="unstaged"?e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void M(h),children:e.jsx("span",{children:n("git.discard")})}):null,e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:d,children:e.jsx("span",{children:n("git.clearSelection")})})]})]}):null]}),e.jsx("div",{className:"git-tree-shell",role:"tree","aria-label":a,children:u.length?Vn({nodes:u,depth:0,collapsedTreePathSet:m,selectedPath:g,onToggleTreePath:C,onSelectFile:x,onPreviewFile:y,onToggleMobileSelection:b,onStageToggle:N,onDiscard:M,actioning:S,variant:T,isMobileViewport:p,selectedMobilePathSet:o}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Lt({title:a,count:s,expanded:u,onToggle:g,trailingContent:m,headerAction:C,children:x}){return e.jsxs("section",{className:"git-mobile-section","data-expanded":u,children:[e.jsxs("div",{className:"git-mobile-section-header",children:[e.jsxs("button",{className:"git-mobile-section-toggle",type:"button","aria-expanded":u,onClick:g,children:[e.jsxs("span",{className:"git-mobile-section-toggle-main",children:[e.jsx(ot,{expanded:u}),e.jsx("h3",{children:a})]}),e.jsxs("span",{className:"git-mobile-section-toggle-meta",children:[m,e.jsx("span",{className:"workbench-section-counter",children:s})]})]}),C?e.jsx("div",{className:"git-mobile-section-header-action",children:C}):null]}),u?e.jsx("div",{className:"git-mobile-section-body",children:x}):null]})}function Ln({title:a,nodes:s,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,selectedTargets:x,actioning:y,variant:b,swipeRowState:N,onSwipeRowChange:M,onStageToggle:S,onDiscardWithConfirm:T,onClearSelectedTargets:p,onPreviewFile:o}){return e.jsxs("div",{className:"git-mobile-record-shell",children:[x.length>0?e.jsxs("div",{className:"git-mobile-selection-toolbar",children:[e.jsxs("span",{className:"git-mobile-selection-count",children:[n("git.selectedFiles")," ",x.length]}),e.jsxs("div",{className:"git-mobile-selection-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:y,onClick:()=>void S(x,b==="staged"),children:b==="staged"?n("git.unstage"):n("git.stage")}),b==="unstaged"?e.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:y,onClick:()=>void T(x,`${x.length}`),children:n("git.discard")}):null,e.jsx("button",{type:"button",className:"secondary-button",disabled:y,onClick:p,children:n("git.clearSelection")})]})]}):null,e.jsx("div",{className:"git-mobile-record-list",role:"tree","aria-label":a,children:s.length?Un({nodes:s,depth:0,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,actioning:y,variant:b,swipeRowState:N,onSwipeRowChange:M,onStageToggle:S,onDiscardWithConfirm:T,onPreviewFile:o}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Un({nodes:a,depth:s,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,actioning:x,variant:y,swipeRowState:b,onSwipeRowChange:N,onStageToggle:M,onDiscardWithConfirm:S,onPreviewFile:T}){return a.map(p=>{if(p.kind==="directory"){const j=!u.has(p.path),E=Ut(p.children),d=`directory:${p.path}`;return e.jsxs("div",{className:"git-mobile-record-branch",children:[e.jsx(Dn,{rowKey:d,openState:(b==null?void 0:b.path)===d?b.direction:null,onOpenStateChange:R=>N(R?{path:d,direction:R}:null),trailingActions:E.length>0?[{label:y==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M(E,y==="staged")},...y==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S(E,p.path)}]:[]]:null,children:e.jsxs("button",{className:"git-mobile-record git-mobile-record-directory",type:"button",style:{paddingInlineStart:`${An+s*Rn}px`},onClick:()=>g(p.path),children:[e.jsxs("span",{className:"git-mobile-record-leading",children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":j,children:e.jsx(ot,{expanded:j})}),e.jsx("span",{className:"git-mobile-record-title",children:p.name})]}),e.jsx("span",{className:"git-mobile-record-meta",children:E.length})]})}),j?e.jsx("div",{className:"git-mobile-record-children",role:"group",children:Un({nodes:p.children,depth:s+1,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,actioning:x,variant:y,swipeRowState:b,onSwipeRowChange:N,onStageToggle:M,onDiscardWithConfirm:S,onPreviewFile:T})}):null]},d)}const o=`file:${p.path}`,h=C.has(p.path);return e.jsx(Dn,{rowKey:o,openState:(b==null?void 0:b.path)===o?b.direction:null,onOpenStateChange:j=>N(j?{path:o,direction:j}:null),trailingActions:[{label:n("git.preview"),tone:"neutral",onPress:()=>T(p.change.path,p.change)},{label:y==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M([p.change.path],y==="staged")},...y==="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":h,style:{paddingInlineStart:`${An+s*Rn}px`},children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:h,"aria-label":`${n("git.selectFile")} ${p.name}`,onChange:()=>m(p.change.path)}),e.jsxs("button",{className:"git-mobile-record-file-main",type:"button",onClick:()=>m(p.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Ot(p.name),"aria-hidden":"true",children:Ft(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 Dn({rowKey:a,openState:s,onOpenStateChange:u,trailingActions:g,children:m}){const C=Xi(),x=l.useRef(null),[y,b]=l.useState(0),N=((g==null?void 0:g.length)??0)*Rt;l.useEffect(()=>{s||b(0)},[s,a]);const M=y!==0?y:s==="trailing"?-N:0;function S(h){var j,E;h.button===0&&(x.current={pointerId:h.pointerId,startX:h.clientX},(E=(j=h.currentTarget).setPointerCapture)==null||E.call(j,h.pointerId))}function T(h){const j=x.current;if(!j||j.pointerId!==h.pointerId)return;const E=N>0?N+10:0,d=Math.max(-E,Math.min(0,h.clientX-j.startX));b(d)}function p(h){var E,d;const j=x.current;if(!(!j||j.pointerId!==h.pointerId)){if((d=(E=h.currentTarget).releasePointerCapture)==null||d.call(E,h.pointerId),x.current=null,y<=-44&&(g!=null&&g.length)){C.trigger("gesture"),u("trailing"),b(0);return}u(null),b(0)}}function o(h){var E,d;const j=x.current;!j||j.pointerId!==h.pointerId||((d=(E=h.currentTarget).releasePointerCapture)==null||d.call(E,h.pointerId),x.current=null,b(0))}return e.jsxs("div",{className:"git-mobile-swipe-row","data-open-state":s??"closed","data-dragging":y!==0,children:[g==null?void 0:g.map((h,j)=>e.jsx("button",{type:"button",className:"git-mobile-swipe-action trailing","data-tone":h.tone,style:{right:j*Rt,width:Rt},onClick:()=>{C.trigger(h.tone==="danger"?"warning":"action"),u(null),h.onPress()},children:h.label},`trailing-${j}`)),e.jsx("div",{className:"git-mobile-swipe-content",style:{transform:`translateX(${M}px)`},onPointerDown:S,onPointerMove:T,onPointerUp:p,onPointerCancel:o,children:m})]})}function Zi({history:a,historyLoadingMore:s,hasMore:u,actioning:g,openCommitHash:m,onMenuTriggerRef:C,onToggleMenu:x,onViewCommitChanges:y,onCopyCommitHash:b,onCopyCommitMessage:N,onCopyCommitVersion:M,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:In(o.commitKind)})]}),o.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:o.refs.map(h=>e.jsx("span",{className:"git-history-ref-pill","data-kind":h.kind,"data-remote-index":String(Xn(h.remoteName)),children:h.name},`${o.commitHash}:${h.kind}:${h.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:qn(o.authoredAt)})]})]}),e.jsx("button",{type:"button",className:"git-icon-button",ref:h=>C(o.commitHash,h),"aria-label":n("git.historyItemMenu"),onClick:()=>x(o.commitHash),children:e.jsx(ke,{})})]})},o.commitHash)),u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:s,onClick:p,children:s?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"git-tree-status",children:n("git.noHistory")})}function _n({history:a,historyLoadingMore:s,hasMore:u,actioning:g,openCommitHash:m,className:C,useNativeContextMenu:x=!1,onMenuTriggerRef:y,onScroll:b,onToggleMenu:N,onOpenContextMenu:M,onViewCommitChanges:S,onCopyCommitHash:T,onCopyCommitMessage:p,onCopyCommitVersion:o,onExplainCommitChange:h,onUndoLastCommit:j,onLoadMore:E}){return a.length?e.jsxs("div",{className:["git-history-list",C].filter(Boolean).join(" "),onScroll:b,children:[a.map(d=>{const R=m===d.commitHash;return e.jsxs("article",{className:"git-history-entry","data-kind":d.commitKind,"data-menu-open":R?"true":"false",onContextMenu:w=>{!x||!M||(w.preventDefault(),w.stopPropagation(),M(d))},children:[e.jsx("span",{className:"git-history-marker","data-kind":d.commitKind,"aria-hidden":"true"}),e.jsxs("div",{className:"git-history-body",children:[e.jsxs("div",{className:"git-history-title-row",children:[e.jsx("strong",{title:d.subject,children:d.subject}),e.jsxs("div",{className:"git-history-title-actions",children:[e.jsx("span",{className:"git-history-kind-badge","data-kind":d.commitKind,children:In(d.commitKind)}),x?null:e.jsx("button",{type:"button",className:"git-icon-button git-history-more",ref:w=>y(d.commitHash,w),"aria-label":n("git.historyItemMenu"),onClick:()=>{N(d.commitHash)},children:e.jsx(ke,{})})]})]}),d.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:d.refs.map(w=>e.jsx("span",{className:"git-history-ref-pill","data-kind":w.kind,"data-remote-index":String(Xn(w.remoteName)),children:w.name},`${d.commitHash}:${w.kind}:${w.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:d.commitHash.slice(0,8)}),e.jsx("span",{children:d.authorName}),e.jsx("time",{dateTime:d.authoredAt,children:qn(d.authoredAt)})]})]})]},d.commitHash)}),s?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:s,onClick:E,children:s?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"status-text",children:n("git.noHistory")})}function Ji({item:a,canUndo:s,actioning:u,onViewCommitChanges:g,onCopyCommitHash:m,onCopyCommitMessage:C,onCopyCommitVersion:x,onExplainCommitChange:y,onUndoLastCommit:b}){return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>g(a.commitHash),children:e.jsx("span",{children:n("git.viewCommitChanges")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>m(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitHash")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>C(a),children:e.jsx("span",{children:n("git.copyCommitMessage")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>x(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitVersion")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>y(a.commitHash),children:e.jsx("span",{children:n("git.explainCommitAction")})}),s?e.jsx("button",{type:"button",className:"git-menu-item",disabled:u,onClick:b,children:e.jsx("span",{children:n("git.undoLastCommit")})}):null]})}function Vn({nodes:a,depth:s,collapsedTreePathSet:u,selectedPath:g,onToggleTreePath:m,onSelectFile:C,onPreviewFile:x,onToggleMobileSelection:y,onStageToggle:b,onDiscard:N,actioning:M,variant:S,isMobileViewport:T,selectedMobilePathSet:p}){return a.map(o=>{if(o.kind==="directory"){const E=!u.has(o.path),d=Ut(o.children),R=`${S==="staged"?n("git.unstage"):n("git.stage")} ${o.path}`,w=`${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":E,children:[e.jsxs("button",{className:"git-tree-trigger",type:"button",style:{paddingInlineStart:`${6+s*8}px`},onClick:()=>m(o.path),children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":E,children:e.jsx(ot,{expanded:E})}),e.jsx("span",{className:"git-tree-label git-tree-label-directory",children:o.name})]}),!T&&d.length>0?e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":R,title:R,onClick:()=>void b(d,S==="staged"),disabled:M,children:e.jsx($t,{staged:S==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":w,title:w,onClick:()=>void N(d),disabled:M,children:e.jsx(Bt,{})}):null]}):null]}),E?e.jsx("div",{className:"git-tree-children",role:"group",children:Vn({nodes:o.children,depth:s+1,collapsedTreePathSet:u,selectedPath:g,onToggleTreePath:m,onSelectFile:C,onPreviewFile:x,onToggleMobileSelection:y,onStageToggle:b,onDiscard:N,actioning:M,variant:S,isMobileViewport:T,selectedMobilePathSet:p})}):null]},`directory:${o.path}`)}const h=p.has(o.path),j=T?h:g===o.path;return T?e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":j,"data-mobile":"true",children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:h,"aria-label":`${n("git.selectFile")} ${o.name}`,onChange:()=>y(o.change.path)}),e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":j,"data-mobile":"true",style:{paddingInlineStart:`${18+s*8}px`},onClick:()=>y(o.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Ot(o.name),"aria-hidden":"true",children:Ft(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":j,children:[e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":j,style:{paddingInlineStart:`${18+s*8}px`},onClick:()=>{C(o.change.path),x&&x(o.change.path,o.change)},children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Ot(o.name),"aria-hidden":"true",children:Ft(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:M,children:e.jsx($t,{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 N([o.change.path]),disabled:M,children:e.jsx(Bt,{})}):null]})]},`file:${o.path}`)})}function Fn(a,s){return{kind:"directory",name:a,path:s,children:new Map}}function On(a,s){const u=Fn("","");for(const g of a){const m=g.path.replace(/\\/g,"/"),C=m.split("/").filter(Boolean);let x=u;C.forEach((y,b)=>{const N=C.slice(0,b+1).join("/");if(b===C.length-1){x.children.set(`file:${N}`,{kind:"file",name:y,path:m,change:g,status:Qi(g,s),variant:s});return}const M=`directory:${N}`,S=x.children.get(M);if(S&&S.kind==="directory"){x=S;return}const T=Fn(y,N);x.children.set(M,T),x=T})}return zn(Wn([...u.children.values()]))}function Wn(a){return[...a].sort((s,u)=>s.kind!==u.kind?s.kind==="directory"?-1:1:s.name.localeCompare(u.name,"zh-CN")).map(s=>s.kind==="directory"?{kind:"directory",name:s.name,path:s.path,children:Wn([...s.children.values()])}:s)}function zn(a){return a.map(s=>{var x;if(s.kind!=="directory")return s;const u=zn(s.children);let g=s.name,m=s.path,C=u;for(;C.length===1&&((x=C[0])==null?void 0:x.kind)==="directory";){const y=C[0];g=`${g}/${y.name}`,m=y.path,C=y.children}return{kind:"directory",name:g,path:m,children:C}})}function kn(a,s,u){const g=new Set(a);return s.filter(m=>Gt(m,u)&&g.has(m.path)).map(m=>m.path)}function Ut(a){const s=[],u=new Set;function g(m){if(m.kind==="file"){u.has(m.path)||(u.add(m.path),s.push(m.path));return}m.children.forEach(g)}return a.forEach(g),s}function Gt(a,s){return s==="staged"?!!a.stagedStatus:!!a.worktreeStatus}function Qi(a,s){return s==="staged"?a.stagedStatus??a.status:a.worktreeStatus??a.status}function es(a){return{subject:Kn(a).trim(),body:null,footer:null,source:"manual"}}function Kn(a){return a.replace(/[\r\n]+/g," ")}function ue(a){const s=a.subject.trim(),u=a.body.trim();return u?`${s}
2
+
3
+ ${u}`:s}function ts(a){const s=a.changedFiles.map(m=>`- [${m.status}] ${m.path}${m.oldPath?` (from ${m.oldPath})`:""}`).join(`
4
+ `),u=a.diffContent.length>Pt?a.diffContent.slice(0,Pt):a.diffContent,g=a.diffContent.length>Pt||a.diffTruncated?`
5
+ 注意:diff 内容过长,下面已经截断,只分析可见部分,同时明确指出可能遗漏的区域。`:"";return["请你分析下面这个 Git 提交。","输出要求:","1. 先用 3 到 5 句话说明这次改动的核心目的。","2. 按文件说明关键改动点,不要泛泛而谈。","3. 指出潜在风险、边界情况和可能的回归点。","4. 如果提交信息写得差,给出一条更合适的中文提交说明。","",`版本号:${a.versionLabel}`,`Commit Hash:${a.commitHash}`,`提交标题:${a.subject}`,`提交作者:${a.authorName} <${a.authorEmail}>`,`提交时间:${a.authoredAt}`,"","变更文件:",s||"- 无",g,"","Diff:",u||"(empty diff)"].join(`
6
+ `)}function ns(a){if(!a)return;a.style.height="0px";const s=Math.min(Math.max(a.scrollHeight,34),120);a.style.height=`${s}px`,a.style.overflowY=a.scrollHeight>120?"auto":"hidden"}function In(a){switch(a){case"local":return n("git.historyKindLocal");case"remote":return n("git.historyKindRemote");default:return n("git.historyKindShared")}}function Xn(a){if(!a)return 0;let s=0;for(const u of a)s=s*33+u.charCodeAt(0)>>>0;return s%6}function is(a){const s=Date.parse(a);return Number.isNaN(s)?a:new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(s)}function D(a,s){return a instanceof Bn?ss(a)??a.message:typeof a=="object"&&a&&"message"in a?a.message:s}function Oe(a){return`git-sidebar.snapshot.${a}`}function Dt(a){return a?!!(a.status||a.branches||a.history.length>0||a.historyTotalCount>0||a.historyNextCursor||a.revision):!1}function ss(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_DISCARD_FAILED":return n("git.discardFailed");case"GIT_UNDO_FAILED":return n("git.undoLastCommitFailed");default:return null}}function Gn(a){return a instanceof Bn&&a.errorCode==="GIT_REMOTE_AUTH_FAILED"}function as(a){return!a||!a.mode||a.mode==="none"?rt:a.mode==="basic"?{authMode:"basic",username:a.username??"",password:a.password??"",token:"",rememberOnHost:!1}:a.mode==="token"?{authMode:"token",username:a.username??"",password:"",token:a.token??"",rememberOnHost:!1}:rt}function rs(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 os(a,s){const u=a.find(m=>m.name===s)??a.find(m=>m.name==="origin")??a[0];if(!u)return"generic";const g=u.pushUrl||u.fetchUrl;return ls(g)?"github":"generic"}function ls(a){const s=(a==null?void 0:a.trim().toLowerCase())??"";return s.startsWith("https://github.com/")||s.startsWith("http://github.com/")||s.startsWith("ssh://git@github.com/")||s.startsWith("git@github.com:")}function $n(a,s,u){const g=Math.max(0,u.width),m=Math.max(0,u.height),C=Math.max(0,m-_*2),x=Math.max(0,g-_*2),y=Math.min(Math.max(s.width||kt,0),x),b=Math.max(0,m-a.bottom-at-_),N=Math.max(0,a.top-at-_),M=b<s.height&&N>b,T=_t(Math.max(M?N:b,Yi),0,C),p=Math.min(Math.max(s.height,0),T),o=M?a.top-at-p:a.bottom+at,h=Math.max(_,m-_-p),j=Math.max(_,g-_-y);return{top:_t(o,_,h),left:_t(a.right-y,_,j),maxHeight:Math.max(0,T),transformOrigin:`${M?"bottom":"top"} right`}}function _t(a,s,u){return!Number.isFinite(a)||u<s?s:Math.min(Math.max(a,s),u)}function ot({expanded:a}){return e.jsx("svg",{className:"git-chevron-icon",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:a?"rotate(0deg)":"rotate(-90deg)"},"aria-hidden":"true",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function $t({staged:a}){return a?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M5 12h14"})}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"M5 12h14"})]})}function Bt(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M10 7L6 11l4 4",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7 11h7c3.87 0 7 3.13 7 7 0 1.9-.76 3.63-2 4.89",strokeLinecap:"round",strokeLinejoin:"round"})]})}function cs(){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 ke(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"5",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"19",cy:"12",r:"1.8"})]})}function qn(a){try{return new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(a))}catch{return a}}export{js as GitSidebar,$n as resolveGitOperationsMenuPosition};
@@ -1 +1 @@
1
- import{b as c,j as e,t as a}from"./index-Byp9hJ0c.js";import{e as j,M as f,f as k,h as g,i as v,j as M,k as S,S as L}from"./MobileSheet-DLg-gX1t.js";function E({open:o,workspaces:l,workspaceOptions:t,initialWorkspaceId:d,onClose:b,onSelect:x}){const[n,p]=c.useState(""),[h,u]=c.useState(!1),m=j(),i=c.useMemo(()=>t??l.map(s=>({workspace:s,label:s.name,subtitle:s.path,depth:0,kind:"workspace",meta:null})),[t,l]),w=c.useMemo(()=>i.map(s=>s.workspace.id).join("|"),[i]);if(c.useEffect(()=>{o&&(p(N(i,d)),u(!1))},[d,o,w]),!o)return null;const r=i.find(s=>s.workspace.id===n)??i[0]??null;return e.jsxs(f,{open:o,title:a("shell.createSessionModalTitle"),description:a("shell.createSessionModalDescription"),kind:"form",height:"three-quarter",className:"mobile-create-session-sheet",cardClassName:"mobile-create-session-sheet-card",bodyClassName:"mobile-feature-form mobile-workspace-home-form mobile-create-session-form",showHandle:!0,onClose:b,children:[e.jsx(k,{className:"mobile-create-session-section",tone:"accent",children:e.jsxs(g,{label:a("shell.createSessionWorkspaceLabel"),children:[e.jsxs("button",{type:"button",className:"mobile-create-session-workspace-trigger","aria-label":`${a("shell.createSessionWorkspaceLabel")} ${(r==null?void 0:r.label)??""}`.trim(),"aria-expanded":h?"true":"false",disabled:i.length===0,onClick:()=>{m.trigger("selection"),u(s=>!s)},children:[e.jsxs("span",{className:"mobile-create-session-workspace-copy",children:[e.jsx("strong",{children:(r==null?void 0:r.label)??a("common.unknown")}),e.jsx("span",{children:(r==null?void 0:r.subtitle)??a("common.unknown")})]}),e.jsx(C,{expanded:h})]}),h?e.jsx(v,{className:"mobile-workspace-home-group mobile-create-session-workspace-list",role:"list",children:i.map(s=>e.jsx(M,{as:"button",className:"mobile-workspace-home-row mobile-create-session-workspace-row","data-worktree-kind":s.kind,"data-worktree-depth":s.depth,selected:s.workspace.id===n,trailing:e.jsx("span",{className:"mobile-workspace-home-row-trailing",children:s.workspace.id===n?e.jsx(I,{}):e.jsx(y,{})}),style:{"--mobile-workspace-tree-depth":String(s.depth)},onClick:()=>{s.workspace.id!==n&&m.trigger("selection"),p(s.workspace.id),u(!1)},children:e.jsxs("span",{className:"mobile-create-session-workspace-option-copy",children:[e.jsxs("strong",{children:[s.kind==="worktree"?e.jsx(S,{className:"mobile-workspace-home-worktree-badge",children:a("shell.mobileWorktreeBadge")}):null,s.label]}),e.jsx("span",{children:s.subtitle})]})},s.workspace.id))}):null]})}),e.jsx(k,{className:"mobile-create-session-provider-block",heading:a("shell.createSessionProviderLabel"),description:a("shell.providerOptionHint"),children:e.jsx(L,{disabled:!n,workspaceId:n||null,onSelect:s=>{n&&x(n,s)}})})]})}function N(o,l){var t;return l&&o.some(d=>d.workspace.id===l)?l:((t=o[0])==null?void 0:t.workspace.id)??""}function C({expanded:o}){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",className:"mobile-create-session-workspace-chevron","data-expanded":o?"true":"false",children:e.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function y(){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function I(){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}export{E as M};
1
+ import{b as c,j as e,t as a}from"./index-DEbFT-Aq.js";import{e as j,M as f,f as k,h as g,i as v,j as M,k as S,S as L}from"./MobileSheet-D1lMrcvD.js";function E({open:o,workspaces:l,workspaceOptions:t,initialWorkspaceId:d,onClose:b,onSelect:x}){const[n,p]=c.useState(""),[h,u]=c.useState(!1),m=j(),i=c.useMemo(()=>t??l.map(s=>({workspace:s,label:s.name,subtitle:s.path,depth:0,kind:"workspace",meta:null})),[t,l]),w=c.useMemo(()=>i.map(s=>s.workspace.id).join("|"),[i]);if(c.useEffect(()=>{o&&(p(N(i,d)),u(!1))},[d,o,w]),!o)return null;const r=i.find(s=>s.workspace.id===n)??i[0]??null;return e.jsxs(f,{open:o,title:a("shell.createSessionModalTitle"),description:a("shell.createSessionModalDescription"),kind:"form",height:"three-quarter",className:"mobile-create-session-sheet",cardClassName:"mobile-create-session-sheet-card",bodyClassName:"mobile-feature-form mobile-workspace-home-form mobile-create-session-form",showHandle:!0,onClose:b,children:[e.jsx(k,{className:"mobile-create-session-section",tone:"accent",children:e.jsxs(g,{label:a("shell.createSessionWorkspaceLabel"),children:[e.jsxs("button",{type:"button",className:"mobile-create-session-workspace-trigger","aria-label":`${a("shell.createSessionWorkspaceLabel")} ${(r==null?void 0:r.label)??""}`.trim(),"aria-expanded":h?"true":"false",disabled:i.length===0,onClick:()=>{m.trigger("selection"),u(s=>!s)},children:[e.jsxs("span",{className:"mobile-create-session-workspace-copy",children:[e.jsx("strong",{children:(r==null?void 0:r.label)??a("common.unknown")}),e.jsx("span",{children:(r==null?void 0:r.subtitle)??a("common.unknown")})]}),e.jsx(C,{expanded:h})]}),h?e.jsx(v,{className:"mobile-workspace-home-group mobile-create-session-workspace-list",role:"list",children:i.map(s=>e.jsx(M,{as:"button",className:"mobile-workspace-home-row mobile-create-session-workspace-row","data-worktree-kind":s.kind,"data-worktree-depth":s.depth,selected:s.workspace.id===n,trailing:e.jsx("span",{className:"mobile-workspace-home-row-trailing",children:s.workspace.id===n?e.jsx(I,{}):e.jsx(y,{})}),style:{"--mobile-workspace-tree-depth":String(s.depth)},onClick:()=>{s.workspace.id!==n&&m.trigger("selection"),p(s.workspace.id),u(!1)},children:e.jsxs("span",{className:"mobile-create-session-workspace-option-copy",children:[e.jsxs("strong",{children:[s.kind==="worktree"?e.jsx(S,{className:"mobile-workspace-home-worktree-badge",children:a("shell.mobileWorktreeBadge")}):null,s.label]}),e.jsx("span",{children:s.subtitle})]})},s.workspace.id))}):null]})}),e.jsx(k,{className:"mobile-create-session-provider-block",heading:a("shell.createSessionProviderLabel"),description:a("shell.providerOptionHint"),children:e.jsx(L,{disabled:!n,workspaceId:n||null,onSelect:s=>{n&&x(n,s)}})})]})}function N(o,l){var t;return l&&o.some(d=>d.workspace.id===l)?l:((t=o[0])==null?void 0:t.workspace.id)??""}function C({expanded:o}){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",className:"mobile-create-session-workspace-chevron","data-expanded":o?"true":"false",children:e.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function y(){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function I(){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}export{E as M};
@@ -0,0 +1 @@
1
+ var V=Object.defineProperty;var Z=(e,n,s)=>n in e?V(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var R=(e,n,s)=>Z(e,typeof n!="symbol"?n+"":n,s);import{C as i,A as Y,b as w,j as r,t as g,f as X,X as H,h as $}from"./index-DEbFT-Aq.js";import{e as _,g as ee}from"./App-BFP7LCSC.js";function ne(){return i.request("/api/workspaces")}async function Te(){try{return await i.request("/api/workbench")}catch(e){if(!(e instanceof Y)||e.status!==404)throw e;const n=await ne();return{items:await Promise.all(n.items.map(async t=>({workspace:t,sessions:(await se(t.id)).items})))}}}function Be(e){return i.request("/api/workspaces/import",{method:"POST",body:JSON.stringify(e)})}function Me(e){return i.request("/api/workspaces/clone",{method:"POST",body:JSON.stringify(e)})}function je(e){return i.request(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})}function ke(e){return i.request("/api/debug-targets/analyze",{method:"POST",body:JSON.stringify(e)})}function Ke(e,n){return i.request(`/api/debug-targets/${encodeURIComponent(e)}/launch-plan`,{method:"POST",body:JSON.stringify({})})}function Fe(){return i.request("/api/framework-compatibility-matrix")}function Je(e){return i.request("/api/workspaces/reorder",{method:"PUT",body:JSON.stringify(e)})}function Qe(e,n){return i.request(`/api/workspaces/${encodeURIComponent(e)}/navigation-state`,{method:"PUT",body:JSON.stringify(n)})}function Ge(e){const n=new URLSearchParams;return e!=null&&e.trim()&&n.set("path",e.trim()),i.request(`/api/workspaces/browse${n.size>0?`?${n.toString()}`:""}`)}function We(e){return i.request("/api/workspaces/directories",{method:"POST",body:JSON.stringify(e)})}function se(e){return i.request(`/api/sessions?workspaceId=${encodeURIComponent(e)}`)}function ze(e){return i.request(`/api/sessions/${encodeURIComponent(e)}`)}function Ve(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/changed-files`)}function Ze(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/seen`,{method:"POST"})}function Ye(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/title`,{method:"PATCH",body:JSON.stringify({title:n})})}function Xe(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/archive`,{method:"PATCH",body:JSON.stringify({archived:n})})}function He(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/favorite`,{method:"PATCH",body:JSON.stringify({favorite:n})})}function $e(e){return i.request(`/api/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function _e(e){return i.request("/api/worktrees",{method:"POST",body:JSON.stringify(e)})}function en(e){return i.request(`/api/worktrees/${encodeURIComponent(e)}/merge-preview`,{method:"POST"})}function nn(e){return i.request(`/api/worktrees/${encodeURIComponent(e)}/merge-into-parent`,{method:"POST"})}function sn(e,n){return i.request(`/api/worktrees/${encodeURIComponent(e)}/cleanup`,{method:"POST",body:JSON.stringify(n??{})})}function tn(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/capabilities`)}function on(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests`)}function rn(){return i.request("/api/preferences/quick-phrases")}function an(e){return i.request("/api/preferences/quick-phrases",{method:"PUT",body:JSON.stringify({items:e})})}function te(e,n){const s=new URLSearchParams;return n!=null&&n.trim()&&s.set("workspaceId",n.trim()),i.request(`/api/providers/${encodeURIComponent(e)}/capabilities${s.size>0?`?${s.toString()}`:""}`)}async function oe(e,n){const s=await Promise.allSettled(e.map(async o=>[o,await te(o,n)])),t=[];for(const o of s){if(o.status!=="fulfilled")continue;const[a,l]=o.value;t.push([a,l])}return Object.fromEntries(t)}function un(e,n,s,t="forward"){const o=new URLSearchParams;return n&&o.set("cursor",n),o.set("limit",String(s)),o.set("direction",t),i.request(`/api/sessions/${encodeURIComponent(e)}/messages?${o.toString()}`)}function ln(e,n){return i.requestBlob(`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(n)}/content`)}function cn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(n)})}function dn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/forks`,{method:"POST",body:JSON.stringify(n)})}function fn(e){return i.request("/api/sessions/start-live",{method:"POST",body:JSON.stringify(e)})}function pn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/messages/live`,{method:"POST",body:JSON.stringify(n)})}function mn(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue`)}function gn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue`,{method:"POST",body:JSON.stringify(n)})}function An(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(n)}`,{method:"DELETE"})}function Sn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(n)}/steer`,{method:"POST"})}function hn(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/runtime`)}function yn(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:"POST"})}function vn(e,n,s){return i.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests/${encodeURIComponent(n)}/reply`,{method:"POST",body:JSON.stringify(s)})}const I="codingns.workspace.session-display-sort-mode",b="codingns.file-panel.show-system-files",q="codingns.notification.preferences",C={notifyOnPermissionRequest:!0,notifyOnSessionCompleted:!0,notifyOnSessionFailed:!0};function D(){return typeof window<"u"&&typeof window.localStorage<"u"}function re(e){return e==="createdAt"||e==="updatedAt"||e==="title"}function B(){if(!D())return"createdAt";const e=window.localStorage.getItem(I);return re(e)?e:"createdAt"}function M(){return D()?window.localStorage.getItem(b)==="1":!1}function U(e){return typeof e=="boolean"}function j(){if(!D())return C;const e=window.localStorage.getItem(q);if(!e)return C;try{const n=JSON.parse(e);return{notifyOnPermissionRequest:U(n.notifyOnPermissionRequest)?n.notifyOnPermissionRequest:C.notifyOnPermissionRequest,notifyOnSessionCompleted:U(n.notifyOnSessionCompleted)?n.notifyOnSessionCompleted:C.notifyOnSessionCompleted,notifyOnSessionFailed:U(n.notifyOnSessionFailed)?n.notifyOnSessionFailed:C.notifyOnSessionFailed}}catch{return C}}function k(e,n){return e.notifyOnPermissionRequest===n.notifyOnPermissionRequest&&e.notifyOnSessionCompleted===n.notifyOnSessionCompleted&&e.notifyOnSessionFailed===n.notifyOnSessionFailed}function ie(e){D()&&window.localStorage.setItem(q,JSON.stringify(e))}class ae{constructor(){R(this,"state",{sessionDisplaySortMode:B(),showSystemFiles:M(),notificationPreferences:j()});R(this,"listeners",new Set);R(this,"subscribe",n=>(this.listeners.add(n),()=>{this.listeners.delete(n)}));R(this,"getState",()=>this.state);R(this,"handleStorage",n=>{if(n.key!==null&&n.key!==I&&n.key!==b&&n.key!==q)return;const s=B(),t=M(),o=j(),a=this.state.sessionDisplaySortMode===s,l=this.state.showSystemFiles===t,c=k(this.state.notificationPreferences,o);a&&l&&c||(this.state={sessionDisplaySortMode:s,showSystemFiles:t,notificationPreferences:o},this.emit())});typeof window<"u"&&window.addEventListener("storage",this.handleStorage)}setSessionDisplaySortMode(n){D()&&(n==="createdAt"?window.localStorage.removeItem(I):window.localStorage.setItem(I,n)),this.state.sessionDisplaySortMode!==n&&(this.state={...this.state,sessionDisplaySortMode:n},this.emit())}setShowSystemFiles(n){D()&&(n?window.localStorage.setItem(b,"1"):window.localStorage.removeItem(b)),this.state.showSystemFiles!==n&&(this.state={...this.state,showSystemFiles:n},this.emit())}setNotificationPreferences(n){const s={...this.state.notificationPreferences,...n};k(this.state.notificationPreferences,s)||(ie(s),this.state={...this.state,notificationPreferences:s},this.emit())}emit(){for(const n of this.listeners)n()}}const K=new ae;function Rn(e){return w.useSyncExternalStore(K.subscribe,()=>e(K.getState()))}function Cn({heading:e,description:n,actions:s,tone:t="default",className:o,children:a}){return r.jsxs("section",{className:y("modal-section",o),"data-tone":t,children:[e||n||s?r.jsxs("div",{className:"modal-section-header",children:[r.jsxs("div",{className:"modal-section-copy",children:[e?r.jsx("strong",{className:"modal-section-heading",children:e}):null,n?r.jsx("p",{className:"modal-section-description",children:n}):null]}),s?r.jsx("div",{className:"modal-section-actions",children:s}):null]}):null,a]})}function wn({label:e,description:n,className:s,htmlFor:t,children:o}){return r.jsxs("div",{className:y("workbench-modal-field","modal-field",s),children:[r.jsxs("div",{className:"modal-field-copy",children:[t?r.jsx("label",{className:"modal-field-label",htmlFor:t,children:e}):r.jsx("span",{className:"modal-field-label",children:e}),n?r.jsx("span",{className:"modal-field-description",children:n}):null]}),o]})}function Dn({align:e="end",stack:n=!1,className:s,children:t,...o}){return r.jsx("div",{className:y("workbench-modal-actions","modal-actions",s),"data-align":e,"data-stack":n?"true":void 0,...o,children:t})}function Pn({compact:e=!1,className:n,children:s,...t}){return r.jsx("div",{className:y("modal-list",n),"data-compact":e?"true":void 0,...t,children:s})}function On(e){const{as:n="div",label:s,description:t,leading:o,trailing:a,tone:l="default",selected:c=!1,className:P,children:O,...A}=e,f={className:y("modal-list-item",P),"data-tone":l!=="default"?l:void 0,"data-selected":c?"true":void 0,"data-interactive":n==="button"?"true":void 0},S=r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"modal-list-item-main",children:[o?r.jsx("span",{className:"modal-list-item-leading",children:o}):null,r.jsxs("span",{className:"modal-list-item-copy",children:[s?r.jsx("span",{className:"modal-list-item-label",children:s}):null,t?r.jsx("span",{className:"modal-list-item-description",children:t}):null,O]})]}),a?r.jsx("span",{className:"modal-list-item-trailing",children:a}):null]});if(n==="button"){const u=A;return r.jsx("button",{type:u.type??"button",...u,...f,children:S})}return r.jsx("div",{...A,...f,children:S})}function Nn({title:e,description:n,action:s,className:t,compact:o=!1}){return r.jsxs("div",{className:y("modal-empty-state",t),"data-compact":o?"true":void 0,children:[r.jsx("strong",{className:"modal-empty-state-title",children:e}),n?r.jsx("p",{className:"modal-empty-state-description",children:n}):null,s?r.jsx("div",{className:"modal-empty-state-action",children:s}):null]})}function In({tone:e="default",className:n,children:s,...t}){return r.jsx("span",{className:y("modal-tag",n),"data-tone":e!=="default"?e:void 0,...t,children:s})}function y(...e){return e.filter(Boolean).join(" ")}function ue(){return _().haptics}const le="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAF+0lEQVRYha2XbXBUZxXHf+e5u4SkCZjg0NIWnQLJLgRF5UWnL75MP9gMjqPT2eyC0qlMiYxOUAR206LOyhiSTVscp52O0xamWgu7WTp0qLUz6kht6Qed1L7M5GUTsAoDTRSIJJos2b33+GFfWMJuNqmcT/c595z/+d3nOc+9zxXKWE9Li7tm0fjyqmT6H0t/Fp8sFz9XM+UCauouH8Rx+ifmWWdP7Q0sLRbT98g3lySC/mcSQd+GGwrQt2vzx1G2ZEa6KJ3S1mJxlpOKIDyEmEM3FGCk5vw5YCw3FmFbb9hXfV2gcm/26vINBfhS+LU0qgcKXB9xT1hbr6kdDhtgcYaDxHSNwVBg92Ao0DMY8n97zgAAZnK8U2AoX1D0++rzWfkC44k6wAVghP7C3EQo8Iiijyq61oEDiV2bPjojwKk234pEsPnh/lDgzpyv/olXrwi6qyDsjsQy2ZQXmJdefPWWvp0v3uZ/CLQ9NxZINpxJj84IYDvmOUT2G/T1DD0CUB/pflnhd1eT5Mcnwl90Adi23JzPl9TbAEN7fF9AeapQW5AOicftGQFEOJ+9tEDbB9v8x99r21wLYBlnJ5AGUKhfklz8QEbY3J71nVnZceziUPAbtzvGxAB3wdPH6yPRx6cXvw4gbbm/B5zIO5SvVKjdMxAMrKvviPcpHMyLqvyoN+ybh7AUwIi+M9TaVOGI/SJwc4Fsf6rS2SqgxQBkukPDYTM40RdCZB/Z5gKmEGmzjStq2alBoDqbvF2hEWgF9oEuAvlugdx/Deaz9ZEjvcWKFwXIWaLNv14cDqmwugDvFRVOi8qOrOMdhT6BzQhvoNxzjbjItxo6o8+VqjEjAMBQa1OFXbXwh4KGuLqmDleXToHzwG1FpLs9kah/uvf98IPz08nkSuZbp+vDL4zNCJAHaQt82lH9JfCJ2cQrTFjq8hiZGrfVtQGcDQhrFNYAywELuFw15SwRgN6dvrrahcnkreGXJ0pCtDZVOFULwsCerEBJExhVGAY8FH/Z2cBvPJHY1ySx13cbaXMaqACSwCVRLqlhVNBRVTOm4lxCOSdqPkB0FdA2m5kosGGEHpC3UP2z6uRJb9fx8SwsJEL+nwBNwEKgWqBSoXaORQqtH+VNhDdErJMNnYf/ViqwbBNO3lRbVZFSS9yyIG1jucRuVuGnM6TZZL4d/wS9KEgawIH/gF5EzAWBvzecto9KPG7PqgkBTu0NLHVs7VBlcxnwS8ALgtyp6Kco3S9/OF850lQWYCD41RpMZUiUH5BZmgkRDqmyVaCqeJYeS1dqwJq4UoG56S5w7hb4PMp6YH426LJR1+qSAOrzWYPLZCvIPuAWAIHXxGGXY3geWAV6DOTrJRR+r5q8P9dskNtJ1etBVl4R19FPdh4eLQowEPR5RKxfgebOeGMqGvLMX/V0YrK/W+B+4ATCYZRnEJ5E+Q5gFM4AFwQ+I8hbLks2Ltt/ZKTUg163Rwfamrcj5q/54spvLZes9nZ2/yIx0b8jW/wCLmeLOLoCAEdeAjmYnaWPGXga9Jiia1O28+bAbt8dswJQEFF5IrO2chGVBzxdsY0r2qNnBx5uvkuELkAFedDTHj+nIl4AIzJsjL2XTAOisB+XtqryKLBcLHNyKLSpsSyAgKrKJoRtbksaPV3R5yFz7BaHOOBGOdAQib6SRV4L4KQZqe+I/wvYmZWqE1ue8nbFggjbgDoH/VOxY3vZXdDT0uKuqR37I+jdIH9JV9r3NIbjU717fLe4jPkASDVEYhW5730i2PwqIvdlZkK3eCPdv06E/GuAbmCBJxJbUnIGill13b8fyxRnRG070BiOTwG4MeuyszBSeNiw3KZFYDTzdPLzU7u3LPZEYu+qTq5Tlev+K2YESAQD94rKjqzgl72Pxd/P3VNLsgAyXJizoj161kG3Z4d1aZP6HIC36/i4tyt6dE4AasQNDIhxNnoisXevvZndJcLw9DxvpLsb5XGE9yzD2ZlqzPpVPN0SIf854FaUZz1dsW0fVqdsD5Q05Qhgg7z+oTX+Xyv2pzNX+x+eTlGviPgh3AAAAABJRU5ErkJggg==",Q="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAbGSURBVHgBzZo/bBtVHMd/ZzuJA0gYCYlsOFO7xRFDy1R3olucqd0SJtiSjiCknBckpjZjBxRn7BR3owOqs5Wp7tZKoDgSQysh4UqUOCG2eZ/3/Oznv/fObqJ+pfPZd+/ufn++vz/vnQN5FwjbGZFGQSRYUb+yIu2c2tSxIOOMqpktqKpzz9X3ioSLNZkRgUwLhA4aW9KWvPqVl6mgldmVGZSJr0BX8Pb2gIVnRUltxbiKxFOgeLJzAYL3I5BQdhaL/sN9EJ5k1dADw+1LQU1tN328kYgaIMWzDSX4s0sUHmSVwZ5JeFqIGjhZgeKpokyzdKGUGQuyWOtA03YCxlNIC98K5X3AhLgYrYB2ndLeE5l0IFvXklK4mpRsxvyuvmqrrSX71aZUjlsyM4LkpuzM7w8dHhqoAxbO+9Fm63pSwhspLTSo1dt6n830bl1SStx9fK6/Z9LmWL3B1hZ/BHUl1+pgYI9S4Eh0EEVjJ5/SwiPI7m9Nuf+02SfUZi4pO+o8ynDcKmlRqRkPlZ43xQ+q8IXpVfdIsu88vJd2ZOSD/OcJKRXmtMW//PlMyi9a0jjvH5NZCDStEDydCjSlfvm9pa/hd24poc+zf/zH8PUjsCT57wOp/FjpqtQ9pakjR+KJo60Fbdnl3dMubSw4vrc2J/msSXLlF4ZCg+M4zzjGEzM39888aAWVFpYlZN+fRnfEE1iMh8JtVygsDWWefTOvhYMiCLX+8L8h4QHnVx+cas/klgLZvpb0eDrp9d/trjr609P6brbhgesPDXXA5kpS7t0ywYwVi4fERD8noJ1WfIDzBDYeRRw8GscL1gP5iCv0g7FsqAIX4UH9pHeegEb44uG5EuKsT3iuPbg9J08252VPxQ3CoowFGYlgRhEMEY2eFzp3CbbEQ3j28BnXjwI0CSvnXQu6lMJrnOd67qOV6fAf2HuuLPn2l4kbRgGT9yf2OU825o11lXDw+bgenb8LV5JdjwE8s/rAxMPXj0xMkGbxBkpWX8epCRp5WvuERNAHl9qADQ+j8xz0QuGDOz3rIizXW8/wHa7bzISSKAveNCQGGoVElPU3coaTcDQKhmoL3QxEkLMna2FplzKAOCFLGf6b4x+nJQbauURnHjsWWJQg8+1nsChCsZGh2LuUwTvb11J94zfVeVtPGOOej4CuNNlJI2xa9BUeQQaD3FKG83iAdItHClcSQ4rzLJvRohGsRCowqoexyCxKbNiUqVPrnf5MhBL0VKRTv6IWZCJnZJR4bujm7eprY+GD2/M6g/hZyypgKENGspThHha2fqxdjZ4sUg8iRz16aYLXBrN5SLPLa5tBMrGCT3T7wD0GgYcM1XwU0IWsXZ80wPY7WMpVguM2g0ABvMDmZhkXZox4w3dswvQV44FFSIe4vqT46rrbzSAEru1pXF6j1L2vTND6Us10p15Zr5Ywq2OTQRwUO0UMyiCM27PYDDKYLomRoy2VNq+n9HGfbGbvyzM9FWgd+4zMfWY4iaV1v6+assHCZNOl7XcKnUC0bUQ9osrq3qnTevgUTtZYUz4ecGEDDwtjaTYER8jsx0YAO5Gxc2EfyyP83lqq27b4Fc6gqhRolEXSe1FDrRBUZioslrYpkD3WthzHSyg0WNCIkVFeoNWw3S7UsQsAHqiobvQTgrgSNbL80gizdmU4EyEswsNzPMQxV3hqiO1oR3kDoyD87tOm57QStKusUNiUcigRXSlZQRchZW2qpc0Sdg5AbQDuw3XboDIQcwGAUm7uh3LWEPvPx88zRiNgWd5OaBr3o+oBrmeaCJhdDeZ7BB83kbETdjZ3bmzryii6eaDCR8c0PzUk/wOdTX7SFU//bEmg5EYoUiOCvv5H5NXbnuDffpHUGYoxLJN892uvarsgXXIPa/14SJTU+pBepXOWVf5W88yFI58VOWqBW9DAYNM3KQMRE0x4gO2JYmLZrtD1ItLTC3ooK2rKasdvzAIVwNp2PfTqpwmdWZY+CswMKzDeYZp579acNgDjodSLv+IK31JvcT4o218jlhYbM78LcJcUR8EG8xSWrynLL7sHZl7cnQQUoYKvLJn0eVwnHTenCVgxSSbwWNwF4cmm+owsbpeLxLqEC+WhoyPHhosl4Y3hewN4Pyw8mNzfhiehxFgzvRgg/IfhuLPRDXr4ljfwe5f/nkxz/m6HDWMR4zWrPBHPFx+zQ7/BX/d5zRrvRfeFU0pbfVcJHvpeMcVfDfAGby8TG/LO0BFc0vftiwtfzPBnD02rvFnZnrrwVUR3wvEFt5heARddZVDE/uXGjRdt4bru4UWODcfT5WmFdvE/Jeqz44iuBr4AAAAASUVORK5CYII=",ce="/assets/gemini-D4G1NbrE.png",de="/assets/kimi-BWNNSh7e.png",fe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAABzUlEQVR4AeycQQrCQBAEF1+g6J/0o5LPCXmCnnNx0E2nNqGEPciw024VffV0PZ/fHo7BqflBCSgAxd+aAhQAE4DjbYACYAJwvA1QAEwAjrcBCgAIDBRpA2AZClAATACOtwEKgAnA8TZAATABOD7egNc8tz2ftJ+4gPQD9r5fAbDBDQXALx00XgGwGAUoACYAx9sABcAE4HgboACYABxvAxSwJHC7XFryLNP4bzYg7KBar4CKUHiugDDgar0CKkLhuQLCgKv1CqgIhecKCAOu1iugIhSeKyAMuFqvgIpQeK6AMOBq/XAC7o9H6z5fdlRAtp4PJ2BrAHSeAmADClAATACOtwEKgAnA8TZAATABON4GKAAmAMev2AD4JTuNVwAsTgEKgAnA8TZAATABON4GKAAmAMfbAAXABOB4G9ApoPe6AnoJdt5XQCfA3uvDCXhOU0ueXmBr3x9OwNoPHH2fAmBDClAATACOtwEKgAnA8TZAAX8QONAVGwDLVIACYAJwfLwByf/+2WJ32k9cQPoBe9+vANigAhQAE4DjbYACYAJw/A8NgH/pQeMVAItVgAJgAnC8DVAATACOtwEKgAnA8TZAATABON4GFALS4w8AAAD//x7wkLQAAAAGSURBVAMAKj5LkLSa6SQAAAAASUVORK5CYII=",pe=new Set(["low","medium","high","xhigh"]),me=["claude-code","codex","opencode","gemini","kimi"],ge=["codex","claude-code","opencode","gemini","kimi"],G={"claude-code":{displayNameKey:"conversation.providerClaude",fullDisplayNameKey:"shell.providerClaudeCode",draftTitleKey:"conversation.draftTitleClaude",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:le,defaultRunInputMode:"streaming_guidance",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!0,supportsRunSteeringByDefault:!0,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},codex:{displayNameKey:"conversation.providerCodex",draftTitleKey:"conversation.draftTitleCodex",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:Q,defaultRunInputMode:"streaming_guidance",reasoningLevelPersists:!0,defaultReasoningLevel:null,supportsSlashMenuByDefault:!1,supportsRunSteeringByDefault:!0,supportsQueueWhileRunningByDefault:!0,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!0},opencode:{displayNameKey:"conversation.providerOpenCode",draftTitleKey:"conversation.draftTitleOpenCode",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:fe,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},gemini:{displayNameKey:"conversation.providerGemini",draftTitleKey:"conversation.draftTitleGemini",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:ce,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:null,supportsInterrupt:!0,supportsAttachments:!1,supportsPermissionPrompt:!1,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},kimi:{displayNameKey:"conversation.providerKimi",draftTitleKey:"conversation.draftTitleKimi",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:de,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:null,supportsInterrupt:!0,supportsAttachments:!1,supportsPermissionPrompt:!1,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!0}},Ae=Array.from(new Set(Object.values(G).map(e=>e.icon)));let F=!1;function Se(e){return me.includes(e)}function d(e){return!e||!Se(e)?null:G[e]}function he(e){return[{id:"provider-default",name:g(e),usesProviderDefault:!0}]}function ye(e){const n=d(e);return he((n==null?void 0:n.defaultModelLabelKey)??"conversation.modelUseCliDefault")}function bn(e){return!!(e&&d(e))}function En(e){const n=d(e);return g((n==null?void 0:n.draftTitleKey)??"conversation.draftTitleCodex")}function ve(e,n="compact"){const s=d(e);return s?n==="full"&&s.fullDisplayNameKey?g(s.fullDisplayNameKey):g(s.displayNameKey):(e==null?void 0:e.trim())||g("conversation.providerCodex")}function Re(e){const n=d(e);return(n==null?void 0:n.icon)??Q}function W(){F||typeof window>"u"||(F=!0,Ae.forEach(e=>{const n=new window.Image;n.decoding="async",n.src=e,typeof n.decode=="function"&&n.decode().catch(()=>{})}))}function Ln(e){const n=d(e);return{provider:e,canStartSession:!0,canResumeSession:!0,canSendMessage:!0,inRunInputMode:(n==null?void 0:n.defaultRunInputMode)??"none",supportsSubagents:!1,supportsInterrupt:(n==null?void 0:n.supportsInterrupt)??!1,supportsStructuredToolCalls:!0,supportsTokenUsage:!0,supportsAttachments:(n==null?void 0:n.supportsAttachments)??!0,supportsPermissionPrompt:(n==null?void 0:n.supportsPermissionPrompt)??!0,supportsCheckpoint:!1,supportsSessionDelete:(n==null?void 0:n.supportsSessionDeleteByDefault)??!1,modelOptions:ye(e),defaultReasoningLevel:n==null?void 0:n.defaultReasoningLevel,supportsRunSteering:n==null?void 0:n.supportsRunSteeringByDefault,supportsQueueWhileRunning:n==null?void 0:n.supportsQueueWhileRunningByDefault,limitations:[]}}function Un(e){return(e==null?void 0:e.provider)??"claude-code"}function qn(e){var s;if((e==null?void 0:e.supportsSlashMenu)!==void 0)return e.supportsSlashMenu;const n=(e==null?void 0:e.provider)??null;return((s=d(n))==null?void 0:s.supportsSlashMenuByDefault)??!1}function xn(e){var n;return(e==null?void 0:e.supportsReasoningSelector)!==void 0?e.supportsReasoningSelector:!!((n=e==null?void 0:e.modelOptions)!=null&&n.some(s=>{var t;return((t=s.supportedReasoningEfforts)==null?void 0:t.some(o=>pe.has(o)))??!1}))}function Tn(e,n){var a;if((e==null?void 0:e.supportsQueueWhileRunning)!==void 0)return e.supportsQueueWhileRunning;const s=(e==null?void 0:e.provider)??null,t=(a=d(s))==null?void 0:a.supportsQueueWhileRunningByDefault;if(t!==void 0)return t;const o=(e==null?void 0:e.inRunInputMode)??"none";return o==="queued_guidance"||o==="none"||o==="streaming_guidance"&&n===!1}function Bn(e){var s;if((e==null?void 0:e.supportsRunSteering)!==void 0)return e.supportsRunSteering;const n=(e==null?void 0:e.provider)??null;return((s=d(n))==null?void 0:s.supportsRunSteeringByDefault)??(e==null?void 0:e.inRunInputMode)==="streaming_guidance"}function Mn(e){const n=d(e);return(n==null?void 0:n.reasoningLevelPersists)??!1}function jn(e,n){var t;return((t=d(n??null))==null?void 0:t.foldRulesMessagesByDefault)??!1}typeof window<"u"&&W();const x=new Map;function kn(){x.clear()}function Kn({disabled:e=!1,workspaceId:n=null,pendingProvider:s=null,selectedProvider:t=null,providers:o=ge,className:a,disabledReasons:l,statusHintByProvider:c,onSelect:P}){const O=ue(),A=!!n,[v,f]=w.useState(()=>J(o,n)),S=o.map(u=>({provider:u}));return w.useEffect(()=>{W()},[]),w.useEffect(()=>{if(!n){f({});return}const u=J(o,n);f(u);const h=o.filter(m=>!u[m]);if(h.length===0)return;let p=!1;return oe(h,n).then(m=>{we(n,m),p||f(N=>({...N,...m}))}),()=>{p=!0}},[o,n]),r.jsx("div",{className:`session-provider-grid${a?` ${a}`:""}`,children:S.map(u=>{const h=ve(u.provider,"full"),p=s===u.provider,m=t===u.provider,N=!!v[u.provider],E=Ce(v[u.provider]??null),L=(l==null?void 0:l[u.provider])??E,T=p?g("shell.startingSession"):L||((c==null?void 0:c[u.provider])??(A&&!N&&!p?g("shell.providerChecking"):null));return r.jsxs("button",{type:"button",className:"session-provider-card","data-provider":u.provider,"data-pending":p?"true":"false","data-selected":m?"true":"false","aria-label":h,disabled:e||!!L,onClick:()=>{O.trigger("action"),P(u.provider)},children:[r.jsx("span",{className:"session-provider-card-icon","aria-hidden":"true",children:r.jsx("img",{src:Re(u.provider),alt:"",loading:"eager",decoding:"async"})}),r.jsxs("span",{className:"session-provider-card-copy",children:[r.jsx("strong",{children:h}),T?r.jsx("span",{className:"session-provider-card-status",children:T}):null]})]},u.provider)})})}function Ce(e){return!e||e.canStartSession!==!1?null:e.limitations[0]??g("conversation.capabilityDenied")}function J(e,n){const s=(n==null?void 0:n.trim())??"";if(!s)return{};const t=[];for(const o of e){const a=x.get(z(s,o));a&&t.push([o,a])}return Object.fromEntries(t)}function we(e,n){const s=e.trim();if(s)for(const[t,o]of Object.entries(n))o&&x.set(z(s,t),o)}function z(e,n){return`${e}::${n}`}function Fn(){const e=X(s=>s),n=H(s=>s);return De(e,n)}function De(e,n){var l;const s=$(e);if(!s)return null;const t=!!((l=s.relayTunnel)!=null&&l.enabled),a=!(e.platform==="web"&&t)&&n.activeHostId===s.id&&n.candidateProbePhase==="ready"?Pe(n):null;if(a){const c=Oe(a.kind);return{kind:c,url:a.url,endpointId:a.endpointId,autoDirect:t&&c!=="relay",probeInProgress:!1}}return{kind:Ne(s),url:s.baseUrl,endpointId:null,autoDirect:!1,probeInProgress:t&&n.activeHostId===s.id&&n.candidateProbePhase==="probing"}}function Jn(e){switch(e){case"relay":return"common.connectionRouteRelay";case"lan":return"common.connectionRouteLan";case"loopback":return"common.connectionRouteLoopback";case"tailscale":return"common.connectionRouteTailscale";default:return"common.connectionRouteDirect"}}function Pe(e){const n=e.preferredDirectCandidateEndpointId??e.preferredCandidateEndpointId;return n?e.candidateEndpoints.find(s=>s.endpointId===n&&s.status==="verified")??null:null}function Oe(e){return e==="custom"?"direct":e}function Ne(e){var n;if((n=e.relayTunnel)!=null&&n.enabled&&Ie(e.baseUrl,e.relayTunnel.tunnelDomain))return"relay";try{const s=new URL(e.baseUrl).hostname.toLowerCase();if(be(s))return"loopback";if(Ee(s))return"tailscale";if(Le(s))return"lan"}catch{return"direct"}return e.kind==="local"?"loopback":e.kind==="lan"?"lan":"direct"}function Ie(e,n){try{return new URL(e).hostname.toLowerCase()===n.trim().toLowerCase()}catch{return!1}}function be(e){return e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="[::1]"}function Ee(e){if(e.endsWith(".ts.net"))return!0;const n=e.split(".").map(o=>Number(o));if(n.length!==4||n.some(o=>Number.isNaN(o)))return!1;const[s,t]=n;return s===100&&t>=64&&t<=127}function Le(e){const n=e.split(".").map(o=>Number(o));if(n.length!==4||n.some(o=>Number.isNaN(o)))return!1;const[s,t]=n;return s===10||s===192&&t===168||s===172&&t>=16&&t<=31}function Qn({open:e,title:n,description:s,height:t="auto",kind:o="form",dismissible:a=!0,closeOnBackdrop:l=!0,showHandle:c=!1,showCancelButton:P=!0,cancelLabel:O,className:A,cardClassName:v,bodyClassName:f,footer:S,onClose:u,children:h}){const p=w.useId(),m=w.useId(),N=a&&l;return!e||typeof document>"u"?null:ee.createPortal(r.jsx("div",{className:"ios-action-sheet-overlay mobile-sheet-overlay",role:"presentation",onClick:()=>{N&&u()},children:r.jsxs("div",{className:`mobile-workspace-home-sheet mobile-sheet${A?` ${A}`:""}`,"data-height":t,"data-kind":o,role:"dialog","aria-modal":"true","aria-labelledby":p,"aria-describedby":s?m:void 0,onClick:E=>E.stopPropagation(),children:[r.jsxs("div",{className:`mobile-workspace-home-sheet-card mobile-sheet-card${v?` ${v}`:""}`,children:[c?r.jsx("div",{className:"mobile-sheet-handle","aria-hidden":"true"}):null,r.jsx("div",{className:"mobile-workspace-home-sheet-header mobile-sheet-header",children:r.jsxs("div",{className:"mobile-sheet-title-wrap",children:[r.jsx("strong",{id:p,children:n}),s?r.jsx("p",{id:m,children:s}):null]})}),r.jsx("div",{className:f?`mobile-sheet-body ${f}`:"mobile-sheet-body",children:h}),S?r.jsx("div",{className:"mobile-sheet-footer",children:S}):null]}),P?r.jsx("button",{type:"button",className:"ios-action-sheet-cancel mobile-sheet-cancel",disabled:!a,onClick:()=>{a&&u()},children:O??g("common.cancel")}):null]})}),document.body)}export{Ge as $,An as A,Sn as B,yn as C,vn as D,Ze as E,hn as F,tn as G,on as H,mn as I,cn as J,bn as K,Bn as L,Qn as M,En as N,Nn as O,$e as P,Un as Q,xn as R,Kn as S,qn as T,Tn as U,an as V,Mn as W,rn as X,jn as Y,ln as Z,Re as _,ve as a,Me as a0,Be as a1,We as a2,en as a3,nn as a4,sn as a5,Xe as a6,kn as a7,Qe as a8,Je as a9,He as aa,Ye as ab,_e as ac,K as ad,Ve as ae,ke as b,Ke as c,Fe as d,ue as e,Cn as f,Te as g,wn as h,Pn as i,On as j,In as k,Fn as l,Jn as m,Ln as n,te as o,oe as p,ge as q,je as r,dn as s,pn as t,Rn as u,fn as v,ze as w,Dn as x,un as y,gn as z};
@@ -1 +1 @@
1
- import{j as i}from"./index-Byp9hJ0c.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
+ import{j as i}from"./index-DEbFT-Aq.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 $,i as B,j as t,t as l}from"./index-Byp9hJ0c.js";import{e as K,i as F,j as P,k as S,M as G}from"./MobileSheet-DLg-gX1t.js";import{ar as q,m as z,as as D,$ as X,at as J}from"./WorkbenchLayout-ByFw4eeu.js";import{u as Q,e as V}from"./App-DkvE5EyM.js";import{M as Y}from"./MobileTopHeaderFrame-DArgZI7L.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:y}){const[u,d]=j.useState(!1),[m,f]=j.useState(null),b=K(),I=Q(),{showToast:T}=V(),r=$(e=>e),h=B(r),E=a??o.map(e=>({workspace:{...e,repoRoot:e.path},label:e.name,subtitle:e.path,depth:0,kind:"workspace",meta:null})),O=ee(r,E),p=(s==null?void 0:s.name)??(h==null?void 0:h.name)??null,x=(s==null?void 0:s.path)??(h==null?void 0:h.baseUrl)??null;if(!p)return null;async function R(e){const U=e.kind==="host"?`host:${e.host.id}`:`workspace:${e.host.id}:${e.workspace.id}`;if(!m){f(U);try{e.host.id!==r.activeHostId&&(b.trigger("selection"),await D.switchHost(e.host.id)),e.kind==="host"?I(X()):(e.workspace.id!==(s==null?void 0:s.id)||e.host.id!==r.activeHostId)&&await(i==null?void 0:i(e.workspace.id)),d(!1)}catch(_){T({title:te(_,e.host.name),tone:"error"})}finally{f(null)}}}return t.jsxs(t.Fragment,{children:[t.jsx(Y,{className:n,frameRef:w,...y,children:t.jsxs("section",{className:"mobile-workspace-home-header",children:[t.jsx("h1",{className:"mobile-workspace-switcher-heading",children: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}b.trigger("selection"),d(!0)},children:[t.jsx("span",{className:"mobile-workspace-home-switcher-label",children:M??p}),t.jsx(ne,{})]}),t.jsx("div",{className:"mobile-workspace-home-toolbar-actions",children:A})]}),x?t.jsx("p",{className:"mobile-workspace-home-path",children:x}):null,C]})}),u&&!c?t.jsxs(ie,{open:u,title:l("shell.hostWorkspaceSwitcherTitle"),onClose:()=>d(!1),children:[t.jsx(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)},children:t.jsxs("div",{className:e.kind==="host"?"mobile-workspace-home-session-main mobile-host-workspace-switcher-host-main":"mobile-workspace-home-session-main",children:[t.jsxs("span",{className:"mobile-workspace-home-session-title",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,e.kind==="host"?e.host.name:e.option.label]}),t.jsx("span",{className:"mobile-workspace-home-session-meta",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};
1
+ import{b as j,f as $,h as B,j as t,t as l}from"./index-DEbFT-Aq.js";import{e as K,i as F,j as P,k as S,M as G}from"./MobileSheet-D1lMrcvD.js";import{at as q,m as z,au as D,$ as X,av as J}from"./WorkbenchLayout-Brlj8K3i.js";import{u as Q,f as V}from"./App-BFP7LCSC.js";import{M as Y}from"./MobileTopHeaderFrame-COTc7cRr.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:y}){const[u,d]=j.useState(!1),[m,f]=j.useState(null),b=K(),I=Q(),{showToast:T}=V(),r=$(e=>e),h=B(r),E=a??o.map(e=>({workspace:{...e,repoRoot:e.path},label:e.name,subtitle:e.path,depth:0,kind:"workspace",meta:null})),O=ee(r,E),p=(s==null?void 0:s.name)??(h==null?void 0:h.name)??null,x=(s==null?void 0:s.path)??(h==null?void 0:h.baseUrl)??null;if(!p)return null;async function R(e){const U=e.kind==="host"?`host:${e.host.id}`:`workspace:${e.host.id}:${e.workspace.id}`;if(!m){f(U);try{e.host.id!==r.activeHostId&&(b.trigger("selection"),await D.switchHost(e.host.id)),e.kind==="host"?I(X()):(e.workspace.id!==(s==null?void 0:s.id)||e.host.id!==r.activeHostId)&&await(i==null?void 0:i(e.workspace.id)),d(!1)}catch(_){T({title:te(_,e.host.name),tone:"error"})}finally{f(null)}}}return t.jsxs(t.Fragment,{children:[t.jsx(Y,{className:n,frameRef:w,...y,children:t.jsxs("section",{className:"mobile-workspace-home-header",children:[t.jsx("h1",{className:"mobile-workspace-switcher-heading",children: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}b.trigger("selection"),d(!0)},children:[t.jsx("span",{className:"mobile-workspace-home-switcher-label",children:M??p}),t.jsx(ne,{})]}),t.jsx("div",{className:"mobile-workspace-home-toolbar-actions",children:A})]}),x?t.jsx("p",{className:"mobile-workspace-home-path",children:x}):null,C]})}),u&&!c?t.jsxs(ie,{open:u,title:l("shell.hostWorkspaceSwitcherTitle"),onClose:()=>d(!1),children:[t.jsx(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)},children:t.jsxs("div",{className:e.kind==="host"?"mobile-workspace-home-session-main mobile-host-workspace-switcher-host-main":"mobile-workspace-home-session-main",children:[t.jsxs("span",{className:"mobile-workspace-home-session-title",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,e.kind==="host"?e.host.name:e.option.label]}),t.jsx("span",{className:"mobile-workspace-home-session-meta",children:e.kind==="host"?ae(e.host,e.workspaceCount):e.option.subtitle})]})},e.kind==="host"?`host-${e.host.id}`:`workspace-${e.host.id}-${e.workspace.id}`))}),k?k(()=>d(!1)):null]}):null]})}function te(s,o){return s instanceof J?s.code==="HOST_UNREACHABLE"?l("shell.hostSwitchUnreachable",{name:o}):l("shell.hostSwitchMissing"):l("shell.hostSwitchFailed")}function ae(s,o){return s?s.lastUsername?l("shell.hostSwitcherWorkspaceCountWithUser",{username:s.lastUsername,count:o}):o>0?l("shell.hostSwitcherWorkspaceCount",{count:o}):s.baseUrl:""}function ie({open:s,title:o,onClose:a,children:i}){return t.jsx(G,{open:s,title:o,kind:"picker",height:"three-quarter",className:"mobile-host-workspace-switcher-sheet",bodyClassName:"mobile-workspace-home-form",showHandle:!0,onClose:a,children:i})}function ne(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function re(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function g(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}export{ke as M,we as a,Z as f};
@@ -0,0 +1 @@
1
+ import{n as E,o as g,b as h,e as f,j as d,t as m}from"./index-DEbFT-Aq.js";import{u as I,c as b,d as T}from"./App-BFP7LCSC.js";function z(e,n){var y;const t=R(n.tunnelDomain),a=E(n.controlBaseUrl),l=D(t,a),o=new Date().toISOString(),r=B(e.hosts,l,n.bindingId??null),i={endpointId:`relay-entry:${l}`,kind:"relay",url:l,priority:0,expiresAt:null,source:"user_saved"},u=(((y=r==null?void 0:r.relayTunnel)==null?void 0:y.candidateEndpoints)??[]).filter(c=>c.url!==l),s={id:(r==null?void 0:r.id)??C(n.bindingId??null,t),name:t,baseUrl:l,kind:"remote",createdAt:(r==null?void 0:r.createdAt)??o,updatedAt:o,lastConnectedAt:(r==null?void 0:r.lastConnectedAt)??null,lastUserId:(r==null?void 0:r.lastUserId)??null,lastUsername:(r==null?void 0:r.lastUsername)??null,relayTunnel:{provider:"codingns_relay",enabled:!0,tunnelDomain:t,controlBaseUrl:a,bindingId:p(n.bindingId??null),hostFingerprint:p(n.hostFingerprint??null),candidateEndpoints:[i,...u]}},U=r?e.hosts.map(c=>c.id===r.id?s:c):[s,...e.hosts];return{activeHostId:s.id,activeDiscoveredHostId:null,hosts:U}}function B(e,n,t){if(t){const a=e.find(l=>{var o;return((o=l.relayTunnel)==null?void 0:o.bindingId)===t})??null;if(a)return a}return e.find(a=>a.baseUrl===n)??null}function C(e,n){return e?`relay-entry:${e}`:`relay-entry:${n}`}function R(e){const n=e.trim().toLowerCase();if(!n||!/^[a-z0-9-]+(\.[a-z0-9-]+)+$/i.test(n))throw new Error("隧道域名无效");return n}function p(e){const n=e==null?void 0:e.trim();return n||null}function D(e,n){const t=new URL(n);return t.hostname=e,t.username="",t.password="",t.pathname="",t.search="",t.hash="",E(t.toString())}function A(){const e=I(),{tunnelDomain:n}=b(),[t]=T(),a=g(),[l,o]=h.useState(null);return h.useEffect(()=>{var s;const r=((s=t.get("controlBaseUrl"))==null?void 0:s.trim())??"";if(!n||!r){o(a("auth.relayEntryInvalid"));return}let i=!1;const u=S(t.get("returnTo"));return f.update(z(f.getState(),{tunnelDomain:n,controlBaseUrl:r,bindingId:t.get("bindingId"),hostFingerprint:t.get("hostFingerprint")})).then(()=>{i||e(`/login?returnTo=${encodeURIComponent(u)}`,{replace:!0})}).catch(()=>{i||o(a("auth.relayEntryInvalid"))}),()=>{i=!0}},[e,t,a,n]),d.jsxs("section",{children:[d.jsx("h1",{children:m("auth.relayEntryTitle")}),d.jsx("p",{children:m("auth.relayEntryDescription")}),l?d.jsx("p",{children:l}):null,l?null:d.jsx("p",{children:m("common.loading")})]})}function S(e){const n=e==null?void 0:e.trim();return!n||!n.startsWith("/")?"/":n}export{A as RelayConnectEntryPage};
@@ -1 +1 @@
1
- import{b as i,n as U,j as r,t as s}from"./index-Byp9hJ0c.js";import{a as v,q as k,s as I,t as O}from"./App-DkvE5EyM.js";import{W as y}from"./WorkbenchModal-Ctob14VR.js";function w({isOpen:t,onClose:u,onSave:c,theme:P="dark"}){const d=v(e=>e.baseUrl),b=v(e=>e.options),m=v(e=>e.presetOptions),h=I(),[l,n]=i.useState(d),[p,o]=i.useState(null),a=i.useMemo(()=>{try{return U(l)}catch{return null}},[l]),f=k(a??l,b),x=m.find(e=>e.value===f)??null,g="server-settings-preset",S="server-settings-address";if(i.useEffect(()=>{t&&(n(d),o(null))},[t,d]),!t)return null;function N(){if(!a){o(s("auth.serverInvalid"));return}O.setBaseUrl(a),c==null||c(a),u()}function B(){a&&n(a)}return r.jsx(y,{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(),N()},children:[r.jsxs("label",{className:"workbench-modal-field",htmlFor:g,children:[r.jsx("span",{children:s("auth.serverPreset")}),r.jsxs("select",{id:g,"aria-label":s("auth.serverPreset"),value:f,onChange:e=>{const j=e.target.value;j!==h&&(n(j),o(null))},children:[m.map(e=>r.jsx("option",{value:e.value,children:C(e)},`${e.source}:${e.value}`)),r.jsx("option",{value:h,children:s("auth.serverCustomOption")})]})]}),x?r.jsx("div",{className:"server-settings-modal-tags","aria-live":"polite",children:x.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:S,children:[r.jsx("span",{children:s("auth.serverAddress")}),r.jsx("input",{id:S,"aria-label":s("auth.serverAddress"),value:l,placeholder:s("auth.serverPlaceholder"),onBlur:B,onChange:e=>{n(e.target.value),o(null)}})]}),p?r.jsx("p",{className:"server-settings-modal-status","data-tone":"error",children:p}):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",children:s("auth.saveServerSettings")})]})]})})}function C(t){return t.source==="discovered"?`${t.value} · ${s("auth.serverDiscoveredTag")}`:t.value}export{w as ServerSettingsModal};
1
+ import{b as i,n as U,j as r,t as s}from"./index-DEbFT-Aq.js";import{a as v,s as k,t as I,v as O}from"./App-BFP7LCSC.js";import{W as y}from"./WorkbenchModal-CbDxaCOR.js";function w({isOpen:t,onClose:u,onSave:c,theme:P="dark"}){const d=v(e=>e.baseUrl),b=v(e=>e.options),m=v(e=>e.presetOptions),h=I(),[l,n]=i.useState(d),[p,o]=i.useState(null),a=i.useMemo(()=>{try{return U(l)}catch{return null}},[l]),f=k(a??l,b),x=m.find(e=>e.value===f)??null,g="server-settings-preset",S="server-settings-address";if(i.useEffect(()=>{t&&(n(d),o(null))},[t,d]),!t)return null;function N(){if(!a){o(s("auth.serverInvalid"));return}O.setBaseUrl(a),c==null||c(a),u()}function B(){a&&n(a)}return r.jsx(y,{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(),N()},children:[r.jsxs("label",{className:"workbench-modal-field",htmlFor:g,children:[r.jsx("span",{children:s("auth.serverPreset")}),r.jsxs("select",{id:g,"aria-label":s("auth.serverPreset"),value:f,onChange:e=>{const j=e.target.value;j!==h&&(n(j),o(null))},children:[m.map(e=>r.jsx("option",{value:e.value,children:C(e)},`${e.source}:${e.value}`)),r.jsx("option",{value:h,children:s("auth.serverCustomOption")})]})]}),x?r.jsx("div",{className:"server-settings-modal-tags","aria-live":"polite",children:x.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:S,children:[r.jsx("span",{children:s("auth.serverAddress")}),r.jsx("input",{id:S,"aria-label":s("auth.serverAddress"),value:l,placeholder:s("auth.serverPlaceholder"),onBlur:B,onChange:e=>{n(e.target.value),o(null)}})]}),p?r.jsx("p",{className:"server-settings-modal-status","data-tone":"error",children:p}):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",children:s("auth.saveServerSettings")})]})]})})}function C(t){return t.source==="discovered"?`${t.value} · ${s("auth.serverDiscoveredTag")}`:t.value}export{w as ServerSettingsModal};
@@ -1 +1 @@
1
- import{b as u,j as e,t as r}from"./index-Byp9hJ0c.js";import{f as me,u as ye}from"./App-DkvE5EyM.js";import{e as je,a as pe}from"./MobileSheet-DLg-gX1t.js";import{A as le,C as ke,D as fe,E as Ne,F as Me,u as Ee,G as Ae,H as ce,i as Ce,I as Q,J as ee,K as Ie,j as Pe,b as De}from"./WorkbenchLayout-ByFw4eeu.js";import{f as Te,a as de,M as Le}from"./MobileWorkspaceSwitcherHeader-0ywJKfBQ.js";import{M as Re}from"./MobileCreateSessionSheet-DLq5qPkx.js";import{w as ue}from"./styles-CSUx5LGe.js";import"./window-BWqRixxq.js";import"./event-DvH9tcej.js";import"./WorkbenchModal-Ctob14VR.js";import"./MobileTopHeaderFrame-DArgZI7L.js";const Oe=420,We=156;function $e({entry:n,isFavorite:i,isActive:a=!1,depth:l=0,variant:c="default",workspaceTone:k="root",hasSubsessions:m=!1,subsessionsExpanded:N=!1,showActions:X=!0,onActivate:Y,onToggleSubsessions:L,onToggleFavorite:se,onArchive:R,onUnarchive:ne,onRename:d}){const[g,A]=u.useState(!1),[C,I]=u.useState(null),[w,O]=u.useState(null),M=u.useRef(null),P=u.useRef(!1),D=u.useRef(null),W=je(),{session:h,workspace:te}=n,$=h.title??h.sessionId,z=pe(h.provider),B=[z,Be(h.lastMessageAt??h.updatedAt??null),le(h)].filter(Boolean).join(" · "),H=Ve(h),V=H?Fe(H):null,T=c==="mobile"?null:le(h),F=T?ke("session-list-activity-badge",h):null;u.useEffect(()=>()=>{K()},[]),u.useLayoutEffect(()=>{if(!g||!w||typeof window>"u"){I(null);return}const t=()=>{var S,y;const x=Ne(w,{width:((S=D.current)==null?void 0:S.offsetWidth)??0,height:((y=D.current)==null?void 0:y.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:We});I({position:"fixed",left:`${Math.round(x.left)}px`,top:`${Math.round(x.top)}px`,width:`${Math.round(x.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(x.maxHeight)}px`,transformOrigin:x.transformOrigin})},f=x=>{var y;const S=x.target;S&&!((y=D.current)!=null&&y.contains(S))&&j()},v=x=>{x.key==="Escape"&&j()};return t(),window.addEventListener("pointerdown",f),window.addEventListener("keydown",v),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("pointerdown",f),window.removeEventListener("keydown",v),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[w,g]);function _(t){O(t),A(!0)}function j(){A(!1),O(null)}function K(){M.current!==null&&(window.clearTimeout(M.current),M.current=null)}function ie(t){if(!X||t.pointerType==="mouse")return;const f={x:t.clientX,y:t.clientY};K(),M.current=window.setTimeout(()=>{P.current=!0,W.trigger("gesture"),_(f)},Oe)}function G(){K()}function oe(){if(P.current){P.current=!1;return}W.trigger("selection"),Y(h.sessionId)}const U=async()=>{const t=window.prompt(r("shell.renameModalDescription"),$);t&&(await d(h.sessionId,t.trim()),j())},J=async()=>{if(h.isArchived){await ne(h.sessionId),j();return}await R(h.sessionId),j()},s=()=>{se(h.sessionId),j()},o=t=>{if(t.key!=="ContextMenu"&&!(t.shiftKey&&t.key==="F10"))return;t.preventDefault(),t.stopPropagation();const f=t.currentTarget.getBoundingClientRect();_({x:f.right,y:f.bottom})},p=g&&typeof document<"u"?me.createPortal(e.jsxs("div",{ref:D,className:"session-action-menu surface-card",role:"menu","aria-label":r("shell.sessionMoreAction"),style:C??{position:"fixed",top:0,left:0,visibility:"hidden"},onClick:t=>t.stopPropagation(),children:[e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:s,children:i?r("shell.unfavoriteAction"):r("shell.favoriteAction")}),e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void J(),children:h.isArchived?r("shell.unarchiveAction"):r("shell.archiveAction")}),e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void U(),children:r("shell.renameAction")})]}),document.body):null;return e.jsxs("article",{className:"session-list-item","data-depth":l,"data-active":a,"data-workspace-tone":k,"data-has-subsessions":m,"data-variant":c,onContextMenu:t=>{X&&(t.preventDefault(),t.stopPropagation(),_({x:t.clientX,y:t.clientY}))},children:[m?e.jsx("button",{type:"button",className:"session-list-subsession-toggle","aria-label":N?r("shell.subagentCollapse"):r("shell.subagentExpand"),title:N?r("shell.subagentCollapse"):r("shell.subagentExpand"),"aria-expanded":N,onClick:t=>{t.stopPropagation(),W.trigger("selection"),L==null||L()},children:e.jsx("span",{className:he(h,{isActive:a,hasSubsessions:m}),"aria-hidden":"true"})}):e.jsx("span",{className:he(h,{isActive:a,hasSubsessions:m}),"aria-hidden":"true"}),e.jsx("button",{type:"button",className:"session-list-link",onClick:oe,onPointerDown:ie,onPointerUp:G,onPointerCancel:G,onPointerLeave:G,onKeyDown:o,children:e.jsxs("div",{className:"session-list-copy",children:[e.jsx("div",{className:"session-list-title",children:$||r("shell.searchEntry")}),e.jsx("div",{className:"session-list-meta",children:c==="mobile"?e.jsx("span",{children:B}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:te.name}),T&&F?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{className:F,children:T})]}):null,e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:z})]})}),V?e.jsx("div",{className:"session-list-error",title:H??void 0,children:V}):null]})}),p]})}function he(n,i){return Me("session-list-indicator",n,{isActive:i.isActive,hasSubagents:i.hasSubsessions})}function Be(n){return n?new Date(n).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):r("common.unknown")}function He(n){return fe(n)||n.syncStatus==="error"}function Ve(n){var l,c;if(!He(n))return null;const i=((l=n.lastErrorCode)==null?void 0:l.trim())??"",a=((c=n.lastErrorDetail)==null?void 0:c.replace(/\s+/g," ").trim())??"";return i&&a&&!a.includes(i)?`${i} · ${a}`:a||i||(n.syncStatus==="error"&&!fe(n)?r("conversation.syncStatusError"):r("conversation.runtimeErrorTitle"))}function Fe(n,i=96){return n.length<=i?n:`${n.slice(0,Math.max(0,i-1)).trimEnd()}…`}const q=5;function rs(){var J;const n=ye(),{navigationGroups:i,favoriteSessionIds:a,currentWorkspaceId:l,currentSessionId:c,navigationLoading:k,selectWorkspace:m,toggleFavoriteSession:N,archiveSession:X,unarchiveSession:Y,renameSession:L,startDraftSession:se}=Ee(),R=Te(i),ne=u.useMemo(()=>Ae(i),[i]),d=de(i,l)??de(i,((J=i[0])==null?void 0:J.workspace.id)??null),g=R.find(s=>s.workspace.id===(d==null?void 0:d.workspace.id))??(d?{workspace:d.workspace,label:d.workspace.name,subtitle:d.workspace.path}:null),A=u.useMemo(()=>new Set(a),[a]),C=u.useMemo(()=>d?d.sessions.filter(s=>{var t;if(s.isArchived)return!1;const o=((t=s.parentSessionId)==null?void 0:t.trim())||null;if(!o)return!0;const p=d.sessions.find(f=>f.sessionId===o);return!p||!p.isArchived}).map(s=>({session:s,workspace:d.workspace})):[],[d]),I=u.useMemo(()=>C.filter(s=>A.has(s.session.sessionId)),[C,A]),w=u.useMemo(()=>ce(C),[C]),O=u.useMemo(()=>ce(I),[I]),M=u.useMemo(()=>d?d.sessions.filter(s=>s.isArchived===!0&&!Ce(s)):[],[d]),P=(d==null?void 0:d.workspace.id)??"",D=!!P,[W,h]=u.useState([]),[te,$]=u.useState({}),[z,B]=u.useState(!1),[H,V]=u.useState(!1),[T,F]=u.useState(null);u.useEffect(()=>{$(s=>{const o={};for(const p of w){const t=Q(ee(p));if(t.length===0)continue;const f=t.findIndex(v=>v.item.session.sessionId===c);o[p.item.session.sessionId]=Xe(t.length,q,s[p.item.session.sessionId],f)}return Ye(s,o)?s:o})},[c,w]),u.useEffect(()=>{if(!c)return;const s=Ie(w,c,o=>o.session.sessionId);s.length!==0&&h(o=>{const p=new Set(o);let t=!1;for(const f of s)p.has(f)||(p.add(f),t=!0);return t?Array.from(p):o})},[c,w]);function _(s){h(o=>o.includes(s)?o.filter(p=>p!==s):[...o,s])}function j(s){return te[s]??q}function K(s){$(o=>({...o,[s]:(o[s]??q)+q}))}function ie(s,o){ue("immersive"),n(De(s,o))}function G(s,o){B(!1),ue("immersive"),se(s,o)}async function oe(s){F(s);try{await Y(s)}finally{F(o=>o===s?null:o)}}function U(s,o=!1,p=[],t=!1,f=!1){var ae;const v=s.item.session.sessionId,x=s.children,S=s.depth===0&&x.length>0,y=o||S&&W.includes(v),re=y&&S,be=re?Ue(s,j(v)):s,Z=y?be.children:[],xe=Q(x).length,ge=Q(Z).length,we=re&&ge<xe,Se=s.depth>0?[...p,t]:[...p];return e.jsxs("div",{className:"session-list-tree-node",children:[e.jsxs("div",{className:"session-list-tree-row",style:{"--session-tree-depth":s.depth},children:[s.depth>0?e.jsxs("div",{className:"session-tree-guides","aria-hidden":"true",style:{"--session-tree-depth":s.depth},children:[p.map((b,E)=>b?e.jsx("span",{className:"session-tree-guide-column",style:{"--session-tree-level":E+1}},`${v}:ancestor:${E}`):null),e.jsx("span",{className:"session-tree-guide-branch","data-continue":t,"data-first":f,style:{"--session-tree-level":s.depth},children:e.jsx("span",{className:"session-tree-guide-branch-horizontal"})})]}):null,e.jsx($e,{entry:s.item,isFavorite:A.has(v),isActive:c===v,depth:s.depth,variant:"mobile",workspaceTone:((ae=ne[s.item.workspace.id])==null?void 0:ae.tone)??"root",hasSubsessions:S,subsessionsExpanded:y,onActivate:b=>ie(s.item.workspace.id,b),onToggleSubsessions:S?()=>_(v):void 0,onToggleFavorite:b=>{N(b)},onArchive:b=>X(b),onUnarchive:b=>Y(b),onRename:(b,E)=>L(b,E)})]}),y&&Z.length>0?e.jsx("div",{className:"session-list-children",children:Z.map((b,E)=>U(b,!0,Se,E<Z.length-1,E===0))}):null,we?e.jsx("div",{className:"session-list-children",children:e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>K(v),children:r("shell.subagentExpandMore")})}):null]},`${s.item.workspace.id}:${v}`)}return e.jsxs("main",{className:"session-index-page mobile-feature-page mobile-page-scroll-root mobile-page-with-top-header",children:[e.jsx(Le,{currentWorkspace:g?{id:g.workspace.id,name:g.label,path:g.subtitle}:null,workspaces:i.map(s=>s.workspace),workspaceOptions:R,onSelectWorkspace:s=>{m(s),n(Pe(s))},content:e.jsx("button",{type:"button",className:"primary-button mobile-session-index-create-button",disabled:k||!D,onClick:()=>B(!0),children:r("shell.createSession")})}),e.jsxs("div",{className:"mobile-page-top-body",children:[e.jsx("div",{className:"session-index-archive-actions",children:e.jsxs("button",{type:"button",className:"primary-button mobile-session-index-create-button session-index-archive-button",disabled:k||!d,onClick:()=>V(!0),children:[e.jsx("span",{children:r("shell.archiveViewAction")}),e.jsx("span",{className:"session-index-archive-count",children:M.length})]})}),O.length>0?e.jsxs("section",{className:"session-section session-section-sheet",children:[e.jsxs("header",{className:"session-section-heading",children:[e.jsx("div",{children:e.jsx("h2",{children:r("shell.favoriteSectionTitle")})}),e.jsx("span",{className:"session-section-count",children:I.length})]}),e.jsx("div",{className:"session-current-workspace-list",children:O.map(s=>U(s))})]}):null,e.jsxs("section",{className:"session-section session-section-sheet",children:[e.jsxs("header",{className:"session-section-heading",children:[e.jsx("div",{children:e.jsx("h2",{children:r("shell.mobileConversationCurrentWorkspaceSection")})}),e.jsx("span",{className:"session-section-count",children:w.length})]}),w.length===0?e.jsx("p",{className:"session-section-empty",children:k?r("shell.searchSessionHint"):r("shell.emptyWorkspaceSessions")}):e.jsx("div",{className:"session-current-workspace-list",children:w.map(s=>U(s))})]})]}),e.jsx(Re,{open:z,workspaces:i.map(s=>s.workspace),workspaceOptions:R,initialWorkspaceId:l??P,onClose:()=>B(!1),onSelect:G}),e.jsx(_e,{open:H,workspaceName:(g==null?void 0:g.label)??(d==null?void 0:d.workspace.name)??null,sessions:M,restoringSessionId:T,onClose:()=>{T||V(!1)},onRestore:s=>void oe(s)})]})}function _e({open:n,workspaceName:i,sessions:a,restoringSessionId:l,onClose:c,onRestore:k}){return u.useEffect(()=>{if(!n)return;function m(N){N.key==="Escape"&&!l&&c()}return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m)}},[c,n,l]),!n||typeof document>"u"?null:me.createPortal(e.jsxs("div",{className:"workbench-modal-layer",children:[e.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":r("common.close"),disabled:!!l,onClick:c}),e.jsxs("section",{className:"workbench-modal-card surface-card",role:"dialog","aria-modal":"true","aria-label":r("shell.archiveModalTitle"),children:[e.jsx("div",{className:"workbench-modal-header",children:e.jsxs("div",{className:"workbench-modal-title-wrap",children:[e.jsx("h2",{children:r("shell.archiveModalTitle")}),e.jsx("p",{children:i?`${i} · ${r("shell.archiveModalDescription")}`:r("shell.archiveModalDescription")})]})}),e.jsx("div",{className:"workbench-modal-body",children:a.length>0?e.jsx("div",{className:"workbench-archive-list",children:a.map(m=>e.jsxs("article",{className:"workbench-archive-item",children:[e.jsxs("div",{className:"workbench-archive-item-main",children:[e.jsx("strong",{title:m.title??m.sessionId,children:m.title??m.sessionId}),e.jsx("p",{children:Ke(m)})]}),e.jsx("button",{type:"button",className:"secondary-button",disabled:l===m.sessionId,onClick:()=>{k(m.sessionId)},children:r("shell.unarchiveAction")})]},m.sessionId))}):e.jsx("p",{className:"workbench-section-empty",children:r("shell.archiveEmpty")})})]})]}),document.body)}function Ke(n){const i=pe(n.provider),a=Ge(n.lastMessageAt??n.updatedAt??null);return[i,a].filter(Boolean).join(" · ")}function Ge(n){if(!n)return null;const i=Date.parse(n);return Number.isNaN(i)?null:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(i)}function Ue(n,i){const a=new Set(Q(ee(n)).sort((l,c)=>(c.item.session.lastMessageAt??c.item.session.updatedAt).localeCompare(l.item.session.lastMessageAt??l.item.session.updatedAt)).slice(0,i).map(l=>l.item.session.sessionId));return{...n,children:ve(ee(n),a)}}function ve(n,i){return n.flatMap(a=>{const l=ve(ee(a),i);return!i.has(a.item.session.sessionId)&&l.length===0?[]:[{...a,children:l}]})}function Xe(n,i,a,l=-1){if(n<=0)return 0;const c=l>=0?Math.max(i,l+1):i;return Math.min(n,Math.max(a??0,c))}function Ye(n,i){const a=Object.keys(n),l=Object.keys(i);return a.length!==l.length?!1:a.every(c=>n[c]===i[c])}export{rs as SessionIndexPage};
1
+ import{b as u,j as e,t as r}from"./index-DEbFT-Aq.js";import{g as me,u as ye}from"./App-BFP7LCSC.js";import{e as je,a as pe}from"./MobileSheet-D1lMrcvD.js";import{A as le,C as ke,D as fe,E as Ne,F as Me,u as Ee,G as Ae,H as ce,i as Ce,I as Q,J as ee,K as Ie,j as Pe,b as De}from"./WorkbenchLayout-Brlj8K3i.js";import{f as Te,a as de,M as Le}from"./MobileWorkspaceSwitcherHeader-DJPV9ym2.js";import{M as Re}from"./MobileCreateSessionSheet-DqVwz_Hp.js";import{w as ue}from"./styles-CSUx5LGe.js";import"./window-BWqRixxq.js";import"./event-DvH9tcej.js";import"./WorkbenchModal-CbDxaCOR.js";import"./MobileTopHeaderFrame-COTc7cRr.js";const Oe=420,We=156;function $e({entry:n,isFavorite:i,isActive:a=!1,depth:l=0,variant:c="default",workspaceTone:k="root",hasSubsessions:m=!1,subsessionsExpanded:N=!1,showActions:X=!0,onActivate:Y,onToggleSubsessions:L,onToggleFavorite:se,onArchive:R,onUnarchive:ne,onRename:d}){const[g,A]=u.useState(!1),[C,I]=u.useState(null),[w,O]=u.useState(null),M=u.useRef(null),P=u.useRef(!1),D=u.useRef(null),W=je(),{session:h,workspace:te}=n,$=h.title??h.sessionId,z=pe(h.provider),B=[z,Be(h.lastMessageAt??h.updatedAt??null),le(h)].filter(Boolean).join(" · "),H=Ve(h),V=H?Fe(H):null,T=c==="mobile"?null:le(h),F=T?ke("session-list-activity-badge",h):null;u.useEffect(()=>()=>{K()},[]),u.useLayoutEffect(()=>{if(!g||!w||typeof window>"u"){I(null);return}const t=()=>{var S,y;const x=Ne(w,{width:((S=D.current)==null?void 0:S.offsetWidth)??0,height:((y=D.current)==null?void 0:y.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:We});I({position:"fixed",left:`${Math.round(x.left)}px`,top:`${Math.round(x.top)}px`,width:`${Math.round(x.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(x.maxHeight)}px`,transformOrigin:x.transformOrigin})},f=x=>{var y;const S=x.target;S&&!((y=D.current)!=null&&y.contains(S))&&j()},v=x=>{x.key==="Escape"&&j()};return t(),window.addEventListener("pointerdown",f),window.addEventListener("keydown",v),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("pointerdown",f),window.removeEventListener("keydown",v),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[w,g]);function _(t){O(t),A(!0)}function j(){A(!1),O(null)}function K(){M.current!==null&&(window.clearTimeout(M.current),M.current=null)}function ie(t){if(!X||t.pointerType==="mouse")return;const f={x:t.clientX,y:t.clientY};K(),M.current=window.setTimeout(()=>{P.current=!0,W.trigger("gesture"),_(f)},Oe)}function G(){K()}function oe(){if(P.current){P.current=!1;return}W.trigger("selection"),Y(h.sessionId)}const U=async()=>{const t=window.prompt(r("shell.renameModalDescription"),$);t&&(await d(h.sessionId,t.trim()),j())},J=async()=>{if(h.isArchived){await ne(h.sessionId),j();return}await R(h.sessionId),j()},s=()=>{se(h.sessionId),j()},o=t=>{if(t.key!=="ContextMenu"&&!(t.shiftKey&&t.key==="F10"))return;t.preventDefault(),t.stopPropagation();const f=t.currentTarget.getBoundingClientRect();_({x:f.right,y:f.bottom})},p=g&&typeof document<"u"?me.createPortal(e.jsxs("div",{ref:D,className:"session-action-menu surface-card",role:"menu","aria-label":r("shell.sessionMoreAction"),style:C??{position:"fixed",top:0,left:0,visibility:"hidden"},onClick:t=>t.stopPropagation(),children:[e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:s,children:i?r("shell.unfavoriteAction"):r("shell.favoriteAction")}),e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void J(),children:h.isArchived?r("shell.unarchiveAction"):r("shell.archiveAction")}),e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void U(),children:r("shell.renameAction")})]}),document.body):null;return e.jsxs("article",{className:"session-list-item","data-depth":l,"data-active":a,"data-workspace-tone":k,"data-has-subsessions":m,"data-variant":c,onContextMenu:t=>{X&&(t.preventDefault(),t.stopPropagation(),_({x:t.clientX,y:t.clientY}))},children:[m?e.jsx("button",{type:"button",className:"session-list-subsession-toggle","aria-label":N?r("shell.subagentCollapse"):r("shell.subagentExpand"),title:N?r("shell.subagentCollapse"):r("shell.subagentExpand"),"aria-expanded":N,onClick:t=>{t.stopPropagation(),W.trigger("selection"),L==null||L()},children:e.jsx("span",{className:he(h,{isActive:a,hasSubsessions:m}),"aria-hidden":"true"})}):e.jsx("span",{className:he(h,{isActive:a,hasSubsessions:m}),"aria-hidden":"true"}),e.jsx("button",{type:"button",className:"session-list-link",onClick:oe,onPointerDown:ie,onPointerUp:G,onPointerCancel:G,onPointerLeave:G,onKeyDown:o,children:e.jsxs("div",{className:"session-list-copy",children:[e.jsx("div",{className:"session-list-title",children:$||r("shell.searchEntry")}),e.jsx("div",{className:"session-list-meta",children:c==="mobile"?e.jsx("span",{children:B}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:te.name}),T&&F?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{className:F,children:T})]}):null,e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:z})]})}),V?e.jsx("div",{className:"session-list-error",title:H??void 0,children:V}):null]})}),p]})}function he(n,i){return Me("session-list-indicator",n,{isActive:i.isActive,hasSubagents:i.hasSubsessions})}function Be(n){return n?new Date(n).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):r("common.unknown")}function He(n){return fe(n)||n.syncStatus==="error"}function Ve(n){var l,c;if(!He(n))return null;const i=((l=n.lastErrorCode)==null?void 0:l.trim())??"",a=((c=n.lastErrorDetail)==null?void 0:c.replace(/\s+/g," ").trim())??"";return i&&a&&!a.includes(i)?`${i} · ${a}`:a||i||(n.syncStatus==="error"&&!fe(n)?r("conversation.syncStatusError"):r("conversation.runtimeErrorTitle"))}function Fe(n,i=96){return n.length<=i?n:`${n.slice(0,Math.max(0,i-1)).trimEnd()}…`}const q=5;function rs(){var J;const n=ye(),{navigationGroups:i,favoriteSessionIds:a,currentWorkspaceId:l,currentSessionId:c,navigationLoading:k,selectWorkspace:m,toggleFavoriteSession:N,archiveSession:X,unarchiveSession:Y,renameSession:L,startDraftSession:se}=Ee(),R=Te(i),ne=u.useMemo(()=>Ae(i),[i]),d=de(i,l)??de(i,((J=i[0])==null?void 0:J.workspace.id)??null),g=R.find(s=>s.workspace.id===(d==null?void 0:d.workspace.id))??(d?{workspace:d.workspace,label:d.workspace.name,subtitle:d.workspace.path}:null),A=u.useMemo(()=>new Set(a),[a]),C=u.useMemo(()=>d?d.sessions.filter(s=>{var t;if(s.isArchived)return!1;const o=((t=s.parentSessionId)==null?void 0:t.trim())||null;if(!o)return!0;const p=d.sessions.find(f=>f.sessionId===o);return!p||!p.isArchived}).map(s=>({session:s,workspace:d.workspace})):[],[d]),I=u.useMemo(()=>C.filter(s=>A.has(s.session.sessionId)),[C,A]),w=u.useMemo(()=>ce(C),[C]),O=u.useMemo(()=>ce(I),[I]),M=u.useMemo(()=>d?d.sessions.filter(s=>s.isArchived===!0&&!Ce(s)):[],[d]),P=(d==null?void 0:d.workspace.id)??"",D=!!P,[W,h]=u.useState([]),[te,$]=u.useState({}),[z,B]=u.useState(!1),[H,V]=u.useState(!1),[T,F]=u.useState(null);u.useEffect(()=>{$(s=>{const o={};for(const p of w){const t=Q(ee(p));if(t.length===0)continue;const f=t.findIndex(v=>v.item.session.sessionId===c);o[p.item.session.sessionId]=Xe(t.length,q,s[p.item.session.sessionId],f)}return Ye(s,o)?s:o})},[c,w]),u.useEffect(()=>{if(!c)return;const s=Ie(w,c,o=>o.session.sessionId);s.length!==0&&h(o=>{const p=new Set(o);let t=!1;for(const f of s)p.has(f)||(p.add(f),t=!0);return t?Array.from(p):o})},[c,w]);function _(s){h(o=>o.includes(s)?o.filter(p=>p!==s):[...o,s])}function j(s){return te[s]??q}function K(s){$(o=>({...o,[s]:(o[s]??q)+q}))}function ie(s,o){ue("immersive"),n(De(s,o))}function G(s,o){B(!1),ue("immersive"),se(s,o)}async function oe(s){F(s);try{await Y(s)}finally{F(o=>o===s?null:o)}}function U(s,o=!1,p=[],t=!1,f=!1){var ae;const v=s.item.session.sessionId,x=s.children,S=s.depth===0&&x.length>0,y=o||S&&W.includes(v),re=y&&S,be=re?Ue(s,j(v)):s,Z=y?be.children:[],xe=Q(x).length,ge=Q(Z).length,we=re&&ge<xe,Se=s.depth>0?[...p,t]:[...p];return e.jsxs("div",{className:"session-list-tree-node",children:[e.jsxs("div",{className:"session-list-tree-row",style:{"--session-tree-depth":s.depth},children:[s.depth>0?e.jsxs("div",{className:"session-tree-guides","aria-hidden":"true",style:{"--session-tree-depth":s.depth},children:[p.map((b,E)=>b?e.jsx("span",{className:"session-tree-guide-column",style:{"--session-tree-level":E+1}},`${v}:ancestor:${E}`):null),e.jsx("span",{className:"session-tree-guide-branch","data-continue":t,"data-first":f,style:{"--session-tree-level":s.depth},children:e.jsx("span",{className:"session-tree-guide-branch-horizontal"})})]}):null,e.jsx($e,{entry:s.item,isFavorite:A.has(v),isActive:c===v,depth:s.depth,variant:"mobile",workspaceTone:((ae=ne[s.item.workspace.id])==null?void 0:ae.tone)??"root",hasSubsessions:S,subsessionsExpanded:y,onActivate:b=>ie(s.item.workspace.id,b),onToggleSubsessions:S?()=>_(v):void 0,onToggleFavorite:b=>{N(b)},onArchive:b=>X(b),onUnarchive:b=>Y(b),onRename:(b,E)=>L(b,E)})]}),y&&Z.length>0?e.jsx("div",{className:"session-list-children",children:Z.map((b,E)=>U(b,!0,Se,E<Z.length-1,E===0))}):null,we?e.jsx("div",{className:"session-list-children",children:e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>K(v),children:r("shell.subagentExpandMore")})}):null]},`${s.item.workspace.id}:${v}`)}return e.jsxs("main",{className:"session-index-page mobile-feature-page mobile-page-scroll-root mobile-page-with-top-header",children:[e.jsx(Le,{currentWorkspace:g?{id:g.workspace.id,name:g.label,path:g.subtitle}:null,workspaces:i.map(s=>s.workspace),workspaceOptions:R,onSelectWorkspace:s=>{m(s),n(Pe(s))},content:e.jsx("button",{type:"button",className:"primary-button mobile-session-index-create-button",disabled:k||!D,onClick:()=>B(!0),children:r("shell.createSession")})}),e.jsxs("div",{className:"mobile-page-top-body",children:[e.jsx("div",{className:"session-index-archive-actions",children:e.jsxs("button",{type:"button",className:"primary-button mobile-session-index-create-button session-index-archive-button",disabled:k||!d,onClick:()=>V(!0),children:[e.jsx("span",{children:r("shell.archiveViewAction")}),e.jsx("span",{className:"session-index-archive-count",children:M.length})]})}),O.length>0?e.jsxs("section",{className:"session-section session-section-sheet",children:[e.jsxs("header",{className:"session-section-heading",children:[e.jsx("div",{children:e.jsx("h2",{children:r("shell.favoriteSectionTitle")})}),e.jsx("span",{className:"session-section-count",children:I.length})]}),e.jsx("div",{className:"session-current-workspace-list",children:O.map(s=>U(s))})]}):null,e.jsxs("section",{className:"session-section session-section-sheet",children:[e.jsxs("header",{className:"session-section-heading",children:[e.jsx("div",{children:e.jsx("h2",{children:r("shell.mobileConversationCurrentWorkspaceSection")})}),e.jsx("span",{className:"session-section-count",children:w.length})]}),w.length===0?e.jsx("p",{className:"session-section-empty",children:k?r("shell.searchSessionHint"):r("shell.emptyWorkspaceSessions")}):e.jsx("div",{className:"session-current-workspace-list",children:w.map(s=>U(s))})]})]}),e.jsx(Re,{open:z,workspaces:i.map(s=>s.workspace),workspaceOptions:R,initialWorkspaceId:l??P,onClose:()=>B(!1),onSelect:G}),e.jsx(_e,{open:H,workspaceName:(g==null?void 0:g.label)??(d==null?void 0:d.workspace.name)??null,sessions:M,restoringSessionId:T,onClose:()=>{T||V(!1)},onRestore:s=>void oe(s)})]})}function _e({open:n,workspaceName:i,sessions:a,restoringSessionId:l,onClose:c,onRestore:k}){return u.useEffect(()=>{if(!n)return;function m(N){N.key==="Escape"&&!l&&c()}return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m)}},[c,n,l]),!n||typeof document>"u"?null:me.createPortal(e.jsxs("div",{className:"workbench-modal-layer",children:[e.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":r("common.close"),disabled:!!l,onClick:c}),e.jsxs("section",{className:"workbench-modal-card surface-card",role:"dialog","aria-modal":"true","aria-label":r("shell.archiveModalTitle"),children:[e.jsx("div",{className:"workbench-modal-header",children:e.jsxs("div",{className:"workbench-modal-title-wrap",children:[e.jsx("h2",{children:r("shell.archiveModalTitle")}),e.jsx("p",{children:i?`${i} · ${r("shell.archiveModalDescription")}`:r("shell.archiveModalDescription")})]})}),e.jsx("div",{className:"workbench-modal-body",children:a.length>0?e.jsx("div",{className:"workbench-archive-list",children:a.map(m=>e.jsxs("article",{className:"workbench-archive-item",children:[e.jsxs("div",{className:"workbench-archive-item-main",children:[e.jsx("strong",{title:m.title??m.sessionId,children:m.title??m.sessionId}),e.jsx("p",{children:Ke(m)})]}),e.jsx("button",{type:"button",className:"secondary-button",disabled:l===m.sessionId,onClick:()=>{k(m.sessionId)},children:r("shell.unarchiveAction")})]},m.sessionId))}):e.jsx("p",{className:"workbench-section-empty",children:r("shell.archiveEmpty")})})]})]}),document.body)}function Ke(n){const i=pe(n.provider),a=Ge(n.lastMessageAt??n.updatedAt??null);return[i,a].filter(Boolean).join(" · ")}function Ge(n){if(!n)return null;const i=Date.parse(n);return Number.isNaN(i)?null:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(i)}function Ue(n,i){const a=new Set(Q(ee(n)).sort((l,c)=>(c.item.session.lastMessageAt??c.item.session.updatedAt).localeCompare(l.item.session.lastMessageAt??l.item.session.updatedAt)).slice(0,i).map(l=>l.item.session.sessionId));return{...n,children:ve(ee(n),a)}}function ve(n,i){return n.flatMap(a=>{const l=ve(ee(a),i);return!i.has(a.item.session.sessionId)&&l.length===0?[]:[{...a,children:l}]})}function Xe(n,i,a,l=-1){if(n<=0)return 0;const c=l>=0?Math.max(i,l+1):i;return Math.min(n,Math.max(a??0,c))}function Ye(n,i){const a=Object.keys(n),l=Object.keys(i);return a.length!==l.length?!1:a.every(c=>n[c]===i[c])}export{rs as SessionIndexPage};