@jingyi0605/codingns 1.0.0-beta.1 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/public/assets/AdaptiveButlerPage-BHUAx_24.js +2 -0
  2. package/dist/public/assets/{App-CHsm-VrM.js → App-D5hc6KuU.js} +6 -6
  3. package/dist/public/assets/{BootstrapPage-Bp0KfySv.js → BootstrapPage-C2sMZMJa.js} +1 -1
  4. package/dist/public/assets/ConversationPage-CDpyEOUA.js +9 -0
  5. package/dist/public/assets/{DesktopDetachPreviewPage-DlDSb_tf.js → DesktopDetachPreviewPage-D9Abm5NU.js} +1 -1
  6. package/dist/public/assets/{DesktopModal-Csj5AdAN.js → DesktopModal-BCVZq_PQ.js} +1 -1
  7. package/dist/public/assets/{DesktopWindowPage-CacXiWjV.js → DesktopWindowPage-Cotl5fte.js} +1 -1
  8. package/dist/public/assets/{FileContextPanel-DzMUQvE5.js → FileContextPanel-DbPOq5w-.js} +1 -1
  9. package/dist/public/assets/{GitSidebar-C8IC18GH.js → GitSidebar-Cuxi2R93.js} +1 -1
  10. package/dist/public/assets/{MobileCreateSessionSheet-BtqR_hKc.js → MobileCreateSessionSheet-DYqarJqO.js} +1 -1
  11. package/dist/public/assets/{MobileSheet-Co-qPMBD.js → MobileSheet-DPYtp5Ze.js} +1 -1
  12. package/dist/public/assets/{PluginAccessOverview-D-KXkcyj.js → PluginAccessOverview-CiVzb_NI.js} +1 -1
  13. package/dist/public/assets/{PluginContainerPage-BKwCIs4r.js → PluginContainerPage-BfZ3E41c.js} +1 -1
  14. package/dist/public/assets/{PluginDetailPage-Djv_swcO.js → PluginDetailPage-DQQAg_ba.js} +1 -1
  15. package/dist/public/assets/{PluginsListPage-DAECNoN6.js → PluginsListPage-bF1NmA_r.js} +1 -1
  16. package/dist/public/assets/{PureConversationPage-DP1X7Hix.js → PureConversationPage-CWji-ARJ.js} +1 -1
  17. package/dist/public/assets/{RelayConnectEntryPage-xL_IPH8a.js → RelayConnectEntryPage-D4-3Fher.js} +1 -1
  18. package/dist/public/assets/{ServerSettingsModal-CyhMgk10.js → ServerSettingsModal-BUY1Y3g6.js} +1 -1
  19. package/dist/public/assets/{SessionIndexPage-CVEz50tc.js → SessionIndexPage-zVB9jnzP.js} +1 -1
  20. package/dist/public/assets/SettingsPage-DeqR2p7d.js +2 -0
  21. package/dist/public/assets/{TerminalManagerPanel-wVnoRA8u.js → TerminalManagerPanel-BjnC70ga.js} +1 -1
  22. package/dist/public/assets/{ToolFilesPage-BospXumK.js → ToolFilesPage-BZseQqvZ.js} +1 -1
  23. package/dist/public/assets/{ToolGitPage-B2zOeCAD.js → ToolGitPage-SrOO8Ftz.js} +1 -1
  24. package/dist/public/assets/{ToolProcessesPage-BDShao4b.js → ToolProcessesPage-Dbzlqjdy.js} +1 -1
  25. package/dist/public/assets/{ToolsHomePage-s4zH7D9M.js → ToolsHomePage-BBilUc0P.js} +1 -1
  26. package/dist/public/assets/{WorkbenchLandingPage-D51QCU_u.js → WorkbenchLandingPage-FdsBC8WN.js} +1 -1
  27. package/dist/public/assets/WorkbenchLayout-yGxGKcG1.js +1081 -0
  28. package/dist/public/assets/{WorkbenchModal-YsyEdJ_m.js → WorkbenchModal-Cm-ciXO9.js} +1 -1
  29. package/dist/public/assets/WorkbenchShellRoute-CijuAd9-.js +1 -0
  30. package/dist/public/assets/WorkbenchShellRoute-DpycFsbp.css +1 -0
  31. package/dist/public/assets/{WorkspaceDebugDetailPage-CMjNLqFq.js → WorkspaceDebugDetailPage-CZtpOiY0.js} +1 -1
  32. package/dist/public/assets/{WorkspaceDetailPage-CKxTbPKh.js → WorkspaceDetailPage-CbbgUz1H.js} +1 -1
  33. package/dist/public/assets/{WorkspaceHomePage-CEy4ShCu.js → WorkspaceHomePage-DMNJKAYe.js} +1 -1
  34. package/dist/public/assets/{client-runtime-manager-BFXU9DmS.js → client-runtime-manager-tsFkLtO_.js} +1 -1
  35. package/dist/public/assets/{host-alias-Zb2xyVrf.js → host-alias-df5bYDlE.js} +1 -1
  36. package/dist/public/assets/index-CILPuSCp.js +50 -0
  37. package/dist/public/assets/index-CSlwKnM4.css +1 -0
  38. package/dist/public/assets/{login-direct-candidate-resolver-DL8DS-Si.js → login-direct-candidate-resolver-pkfXrMJy.js} +1 -1
  39. package/dist/public/assets/peer-host-config-sync-nS_66OLg.js +1 -0
  40. package/dist/public/assets/{plugin-permission-copy-DrLk22m5.js → plugin-permission-copy-LDy-lW7h.js} +1 -1
  41. package/dist/public/assets/{plugins-api-COF4oh24.js → plugins-api-BGF9OybZ.js} +1 -1
  42. package/dist/public/assets/{preferences-service-CEWNV1w9.js → preferences-service-BC25oxA_.js} +1 -1
  43. package/dist/public/assets/{relay-entry-Cmc8vTlE.js → relay-entry-ErQKnI7B.js} +1 -1
  44. package/dist/public/assets/{useRegisteredDebugTemplates-FdmHG2S4.js → useRegisteredDebugTemplates-BTr3ATCZ.js} +1 -1
  45. package/dist/public/assets/{workbench-navigation-ED0157V-.js → workbench-navigation-hwM28xIb.js} +1 -1
  46. package/dist/public/index.html +2 -2
  47. package/dist/server/modules/client/client-controller.d.ts +1 -0
  48. package/dist/server/modules/client/client-controller.js +4 -0
  49. package/dist/server/modules/client/client-controller.js.map +1 -1
  50. package/dist/server/modules/client/client-service.d.ts +3 -0
  51. package/dist/server/modules/client/client-service.js +3 -0
  52. package/dist/server/modules/client/client-service.js.map +1 -1
  53. package/dist/server/modules/client/npm-global-package-service.js +32 -7
  54. package/dist/server/modules/client/npm-global-package-service.js.map +1 -1
  55. package/dist/server/modules/peer-host/host-ws-proxy-service.js +73 -12
  56. package/dist/server/modules/peer-host/host-ws-proxy-service.js.map +1 -1
  57. package/dist/server/modules/provider/provider-discovery-helper-client.d.ts +2 -0
  58. package/dist/server/modules/provider/provider-discovery-helper-client.js.map +1 -1
  59. package/dist/server/modules/provider/provider-discovery-helper-process.js +6 -3
  60. package/dist/server/modules/provider/provider-discovery-helper-process.js.map +1 -1
  61. package/dist/server/modules/provider/provider-discovery-runtime.js +4 -1
  62. package/dist/server/modules/provider/provider-discovery-runtime.js.map +1 -1
  63. package/dist/server/modules/sessions/session-history-service.d.ts +8 -0
  64. package/dist/server/modules/sessions/session-history-service.js +123 -5
  65. package/dist/server/modules/sessions/session-history-service.js.map +1 -1
  66. package/dist/server/modules/sessions/session-live-runtime-service.d.ts +13 -0
  67. package/dist/server/modules/sessions/session-live-runtime-service.js +354 -5
  68. package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
  69. package/dist/server/modules/sessions/session-permission-request-service.d.ts +16 -1
  70. package/dist/server/modules/sessions/session-permission-request-service.js +375 -9
  71. package/dist/server/modules/sessions/session-permission-request-service.js.map +1 -1
  72. package/dist/server/modules/sessions/workspace-session-runtime-context-service.js +10 -0
  73. package/dist/server/modules/sessions/workspace-session-runtime-context-service.js.map +1 -1
  74. package/dist/server/modules/tasks/task-helper-process-handlers.d.ts +1 -0
  75. package/dist/server/modules/tasks/task-helper-process-handlers.js +4 -1
  76. package/dist/server/modules/tasks/task-helper-process-handlers.js.map +1 -1
  77. package/dist/server/modules/workbench/workbench-service.js +7 -4
  78. package/dist/server/modules/workbench/workbench-service.js.map +1 -1
  79. package/dist/server/routes/client.js +1 -0
  80. package/dist/server/routes/client.js.map +1 -1
  81. package/dist/server/shared/utils/peer-host-proxy-log.d.ts +3 -0
  82. package/dist/server/shared/utils/peer-host-proxy-log.js +48 -0
  83. package/dist/server/shared/utils/peer-host-proxy-log.js.map +1 -0
  84. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.d.ts +2 -0
  85. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js +93 -12
  86. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js.map +1 -1
  87. package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +3 -0
  88. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +116 -2
  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/claude-runtime.d.ts +1 -0
  91. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +19 -8
  92. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -1
  93. package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.d.ts +1 -0
  94. package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js +30 -2
  95. package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js.map +1 -1
  96. package/package.json +1 -1
  97. package/dist/public/assets/AdaptiveButlerPage-BYETYaIe.js +0 -2
  98. package/dist/public/assets/ConversationPage-BCrNml1k.js +0 -9
  99. package/dist/public/assets/SettingsPage-CQNCrgaj.js +0 -2
  100. package/dist/public/assets/WorkbenchLayout-Bo2BbMY6.js +0 -1081
  101. package/dist/public/assets/WorkbenchShellRoute-D3l4aWJS.js +0 -1
  102. package/dist/public/assets/WorkbenchShellRoute-D5fnyF8z.css +0 -1
  103. package/dist/public/assets/index-BilHJjYU.js +0 -50
  104. package/dist/public/assets/index-OR7OITpQ.css +0 -1
  105. package/dist/public/assets/peer-host-config-sync-d2ZcPC5P.js +0 -1
@@ -1,4 +1,4 @@
1
- import{b as l,E as wn,ac as Pn,F as Gi,t as n,j as e,B as Zn}from"./index-BilHJjYU.js";import{u as Ii,e as Ui,f as Bi,g as An}from"./App-CHsm-VrM.js";import{b as Vi,ar as mt,S as Wi,c1 as zi,ca as Ki,cb as Xi,bT as qi,cc as Dn,cd as Yi,ce as Zi,c0 as Ji,cf as Qi,bX as es,cg as ts,bV as Jn,ch as ns,c9 as is,ci as Ln,a9 as ss,a8 as as,aa as rs,cj as os,bY as zt,bZ as Kt,ck as ls,cl as cs,I as us}from"./WorkbenchLayout-Bo2BbMY6.js";import{W as $e}from"./WorkbenchModal-YsyEdJ_m.js";import{c as ds}from"./workbench-navigation-ED0157V-.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./host-alias-Zb2xyVrf.js";import"./DesktopModal-Csj5AdAN.js";import"./relay-entry-Cmc8vTlE.js";import"./MobileSheet-Co-qPMBD.js";const $t=56,_n=28,Gt=72,ht=8,Fn=960,kn=60*1e3,On=20,$n=9,Gn=9,It=68,k=12,gt=8,Xt=260,ms=120,Ut=6e4,ft={authMode:"none",username:"",password:"",token:"",rememberOnHost:!1};function Us({className:a,workspaceId:i,panelActive:u=!0,externalWindowMode:h=!1,workbenchShellOverrides:g}){const j=Ii(),p=Ui(),y=Vi(),{subscribeGitSnapshot:b,requestGitRefresh:N,addGitSnapshotListener:M,requestNavigationRefresh:v,selectWorkspace:S,upsertNavigationSession:x,currentTargetHostId:o,currentWorkspaceRef:f}={...y,...g},[d,H]=l.useState(null),[R,E]=l.useState(null),[P,A]=l.useState([]),[be,se]=l.useState(0),[X,ae]=l.useState(null),[ye,bt]=l.useState(!1),[I,je]=l.useState(null),[re,q]=l.useState(null),[Ce,Ne]=l.useState(""),[Ue,U]=l.useState(!1),[C,D]=l.useState(!1),[oi,Qt]=l.useState([]),[te,en]=l.useState(!0),[ne,W]=l.useState(!1),[O,li]=l.useState(()=>typeof window<"u"?window.innerWidth<=Fn:!1),[yt,B]=l.useState([]),[ve,z]=l.useState(null),[Se,oe]=l.useState("unstaged"),[Te,Y]=l.useState(null),[le,Z]=l.useState(null),[ci,jt]=l.useState(!1),[ui,Ct]=l.useState(null),[di,Be]=l.useState(!1),[tn,Ve]=l.useState(null),[F,Me]=l.useState(null),[nn,He]=l.useState(null),[mi,Ee]=l.useState(!1),[Re,ce]=l.useState(null),[ie,Nt]=l.useState(!1),[hi,ue]=l.useState(!1),[We,vt]=l.useState("push"),[ze,Ke]=l.useState([]),[gi,Xe]=l.useState(!1),[qe,Ye]=l.useState(new Set),[fi,de]=l.useState(new Map),[Ze,sn]=l.useState({}),[pi,me]=l.useState(!1),[Je,an]=l.useState(null),[L,J]=l.useState(ft),[rn,on]=l.useState("generic"),[ln,Qe]=l.useState(null),[$,St]=l.useState(null),[G,Tt]=l.useState(null),[cn,un]=l.useState($t),[Mt,Ht]=l.useState(!1),[dn,we]=l.useState(null),[xi,Pe]=l.useState(null),mn=l.useRef(null),hn=l.useRef(null),gn=l.useRef(null),fn=l.useRef(null),pn=l.useRef(null),xn=l.useRef(null),Et=l.useRef(null),Ae=l.useRef(new Map),et=l.useRef(new Map),De=l.useRef(0),bn=l.useRef(u),yn=l.useRef(u),tt=l.useRef(null),{showToast:T}=Bi(),jn=p.isDesktop&&!O;l.useEffect(()=>{mt("git_sidebar.props",{workspaceId:i,externalWindowMode:h})},[h,i]),l.useEffect(()=>{yn.current=u},[u]),l.useEffect(()=>{Qt([]),en(!0),se(0),ae(null),bt(!1),q(null),Ne(""),W(!1),B([]),z(null),oe("unstaged"),Y(null),Z(null),jt(!1),Ct(null),Be(!1),Ve(null),Me(null),He(null),Ee(!1),ce(null),Nt(!1),ue(!1),vt("push"),Ke([]),Ye(new Set),de(new Map),sn({}),me(!1),an(null),J(ft),on("generic"),Qe(null),St(null),Tt(null),Ht(!1),un($t),we(null),Pe(null),et.current.clear(),Ae.current.clear()},[i]),l.useEffect(()=>{function t(){li(window.innerWidth<=Fn)}return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),l.useEffect(()=>{if(!Mt)return;const t=document.body.style.cursor,s=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";function r(m){Tn(m.clientY)}function c(){Ht(!1)}return window.addEventListener("pointermove",r),window.addEventListener("pointerup",c),()=>{document.body.style.cursor=t,document.body.style.userSelect=s,window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",c)}},[Mt]),l.useEffect(()=>{var c,m;if(!(i!=null&&i.trim())){tt.current=null,H(null),E(null),A([]),se(0),ae(null),je(null),U(!1);return}const t=i.trim(),s=wn(Ge(t,o),kn),r=Vt(s);if(mt("git_sidebar.snapshot",{workspaceId:t,cached:r,cachedHistoryCount:((c=s==null?void 0:s.history)==null?void 0:c.length)??0,cachedChangedCount:((m=s==null?void 0:s.status)==null?void 0:m.changes.length)??0}),r&&s){Rt(s,t),U(!1);return}tt.current=null,Pn(Ge(t,o)),H(null),E(null),A([]),se(0),ae(null),je(null),U(!0)},[i]),l.useEffect(()=>{if(i!=null&&i.trim())return M(t=>{var s,r,c;t.workspaceId!==i.trim()||!Ns(Cs(t),o)||(mt("git_sidebar.snapshot_received",{workspaceId:t.workspaceId,changedCount:((s=t.status)==null?void 0:s.changes.length)??0,historyCount:t.history.length,branchCount:(((r=t.branches)==null?void 0:r.local.length)??0)+(((c=t.branches)==null?void 0:c.remote.length)??0)}),Rt(t,t.workspaceId),U(!1))})},[M,i]),l.useEffect(()=>{if(!(i!=null&&i.trim()))return;const t=i.trim(),s=wn(Ge(t,o),kn),r=Vt(s)?(s==null?void 0:s.revision)??null:null;b(t,{knownRevision:r,targetHostId:o}),yn.current&&K()},[o,N,b,i]),l.useEffect(()=>{const t=bn.current;bn.current=u,i!=null&&i.trim()&&!t&&u&&N(i.trim(),{knownRevision:R,targetHostId:o})},[o,u,N,R,i]),l.useEffect(()=>{const t=i==null?void 0:i.trim();if(!t||tt.current!==t)return;const s={revision:R,status:d,history:P,historyTotalCount:be,historyNextCursor:X,branches:I};if(!Vt(s)){Pn(Ge(t,o));return}Gi(Ge(t,o),s)},[I,P,X,be,R,d,i]),l.useEffect(()=>{if(!d||!re)return;d.changes.find(s=>s.path===re)||q(null)},[re,d]),l.useEffect(()=>{ys(fn.current)},[Ce]),l.useEffect(()=>{O||(B([]),z(null),Y(null),Qe(null))},[O]),l.useEffect(()=>{if(!d){B([]);return}const t=new Set(d.changes.map(s=>s.path));B(s=>s.filter(r=>t.has(r)))},[d]);function bi(){const t=gn.current;if(!t)return;t.querySelectorAll(".git-tree-shell").forEach(r=>{r.scrollTop=0})}function Rt(t,s){tt.current=(s==null?void 0:s.trim())??(i==null?void 0:i.trim())??null,E(typeof t.revision=="string"?t.revision:null),H(t.status),A(Array.isArray(t.history)?t.history:[]),se(typeof t.historyTotalCount=="number"?t.historyTotalCount:0),ae(typeof t.historyNextCursor=="string"?t.historyNextCursor:null),je(t.branches??null)}function K(t){i!=null&&i.trim()&&(U(!0),mt("git_sidebar.refresh_requested",{workspaceId:i.trim(),resetTreeScroll:!1}),N(i.trim(),{knownRevision:R,targetHostId:o}))}async function wt(t){if(!(i!=null&&i.trim()))return;const s=i.trim();U(!0);try{const[r,c,m]=await Promise.all([qi(s,{targetHostId:o}),Dn(s,On,null,{targetHostId:o}),Yi(s,{targetHostId:o})]);Rt({status:r,history:c.items,historyTotalCount:c.totalCount,historyNextCursor:c.nextCursor,branches:m}),N(s,{targetHostId:o}),t!=null&&t.resetTreeScroll&&requestAnimationFrame(()=>{bi()})}catch(r){T({title:_(r,n("git.panelLoadFailed")),tone:"error"})}finally{U(!1)}}async function nt(){if(!(!i||!X||ye)){bt(!0);try{const t=await Dn(i,On,X,{targetHostId:o});A(s=>{const r=new Set(s.map(m=>m.commitHash)),c=t.items.filter(m=>!r.has(m.commitHash));return[...s,...c]}),se(t.totalCount),ae(t.nextCursor)}catch(t){T({title:_(t,n("git.panelLoadFailed")),tone:"error"})}finally{bt(!1)}}}function yi(t){if(!te||ye||!X)return;const s=t.currentTarget;s.scrollHeight-s.scrollTop-s.clientHeight<=40&&nt()}async function ji(){if(i){D(!0);try{const t=await Xi(i,"ai",{targetHostId:o});Ne(t.validation.normalizedDraft.subject||t.draft.subject)}catch(t){T({title:_(t,n("git.draftFailed")),tone:"error"})}finally{D(!1)}}}async function it(t,s){if(i&&t.length){D(!0);try{const r=s?await Qi(i,t,{targetHostId:o}):await es(i,t,{targetHostId:o});H(r),q(t[t.length-1]??null),B(c=>c.filter(m=>!t.includes(m))),z(null),K()}catch(r){U(!1),T({title:_(r,n("git.stageFailed")),tone:"error"})}finally{D(!1)}}}async function Pt(t){if(i&&t.length){D(!0);try{const s=await ns(i,t,{targetHostId:o});H(s),t.includes(re??"")&&q(null),B(r=>r.filter(c=>!t.includes(c))),z(null),K()}catch(s){U(!1),T({title:_(s,n("git.discardFailed")),tone:"error"})}finally{D(!1)}}}async function Ci(){if(!(!i||!Ce.trim())){D(!0);try{await Zi(i,ps(Ce),{targetHostId:o}),T({title:n("git.commitSuccess"),tone:"success"}),Ne(""),q(null),K()}catch(t){T({title:_(t,n("git.commitFailed")),tone:"error"})}finally{D(!1)}}}async function Ni(){if(i!=null&&i.trim()){D(!0),U(!0);try{const t=await Ki(i.trim(),{targetHostId:o});H(t),A([]),se(0),ae(null),je(null),T({title:n("git.initSuccess"),tone:"success"}),K()}catch(t){T({title:_(t,n("git.initFailed")),tone:"error"})}finally{D(!1),U(!1)}}}async function At(){const t=i==null?void 0:i.trim();if(!t)return[];const s=await os(t,{targetHostId:o});return(i==null?void 0:i.trim())!==t?[]:(Ke(s),s)}async function st(t){const s=await At(),r=pt(s,t);if(!r){T({title:n("git.noRemotes"),tone:"error"});return}const c=Ze[r.name]??null;an(r.name),on(Hs(s,r.name)),J(Ts((c==null?void 0:c.auth)??null,(c==null?void 0:c.rememberOnHost)??!1)),me(!0)}async function vi(){if(i!=null&&i.trim()){Xe(!0);try{const t=await At();if(t.length===0){T({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){await st(t[0].name);return}vt("auth"),Ye(new Set),de(new Map),ue(!0)}catch(t){T({title:_(t,n("git.remoteFailed")),tone:"error"})}finally{Xe(!1)}}}function Si(){const t=Je==null?void 0:Je.trim();if(!t){me(!1);return}const s=Ms(L),r=rn==="github"?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder");if(L.authMode==="basic"){if(!L.username.trim()){T({title:n("shell.cloneUsernamePlaceholder"),tone:"error"});return}if(!L.password){T({title:r,tone:"error"});return}}if(L.authMode==="token"&&!L.token){T({title:n("shell.cloneTokenPlaceholder"),tone:"error"});return}sn(c=>{if(!s){const{[t]:m,...w}=c;return w}return{...c,[t]:{auth:s,rememberOnHost:L.rememberOnHost}}}),me(!1),T({title:s?n("git.remoteAuthSaved"):n("git.remoteAuthCleared"),description:s&&L.rememberOnHost?n("git.remoteAuthRememberHint"):void 0,tone:"success"})}async function Cn(){if(i){Xe(!0);try{const t=await At();if(t.length===0){T({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){Nn([t[0].name]);return}vt("push"),Ye(new Set),de(new Map),ue(!0)}catch(t){T({title:_(t,n("git.remoteFailed")),tone:"error"})}finally{Xe(!1)}}}async function Nn(t){if(!i||t.length===0)return;D(!0),de(new Map);const s=new Map;let r=!1;try{for(const c of t){const m=Ze[c]??null;try{const w=await Ln(i,"push",c,m==null?void 0:m.auth,(m==null?void 0:m.rememberOnHost)??!1,{targetHostId:o});s.set(c,{ok:!0,summary:w.summary}),m!=null&&m.rememberOnHost&&m.auth&&Ke($i=>$i.map(Ot=>Ot.name===c?{...Ot,credentialConfigured:!0}:Ot))}catch(w){if(r=!0,s.set(c,{ok:!1,summary:_(w,n("git.remoteFailed"))}),de(new Map(s)),Xn(w)){st(c);return}}}de(s),K(),r||(T({title:n("git.pushAllSuccess",{count:String(t.length)}),tone:"success"}),ue(!1))}finally{D(!1)}}async function Dt(t){if(i){if(t==="push"){W(!1),Cn();return}D(!0);try{const s=qn(ze),r=s?Ze[s]??null:null,c=await Ln(i,t,void 0,r==null?void 0:r.auth,(r==null?void 0:r.rememberOnHost)??!1,{targetHostId:o});T({title:c.summary,tone:"success"}),s&&(r!=null&&r.rememberOnHost)&&r.auth&&Ke(m=>m.map(w=>w.name===s?{...w,credentialConfigured:!0}:w)),W(!1),K()}catch(s){if(Xn(s)){st(qn(ze));return}T({title:_(s,n("git.remoteFailed")),tone:"error"})}finally{D(!1)}}}async function he(){if(i){D(!0);try{const t=await ts(i,{targetHostId:o});Ne(t.commitSubject??""),T({title:t.summary||n("git.undoLastCommitSuccess"),tone:"success"}),W(!1),K()}catch(t){T({title:_(t,n("git.undoLastCommitFailed")),tone:"error"})}finally{D(!1)}}}async function Ti(t){if(i){D(!0);try{const s=await ls(i,t,!1,{targetHostId:o});je(s),W(!1),K()}catch(s){T({title:_(s,n("git.branchFailed")),tone:"error"})}finally{D(!1)}}}async function Lt(t){const s=i==null?void 0:i.trim();if(!s)throw new Error(n("git.panelLoadFailed"));const r=et.current.get(t);if(r)return r;const c=await cs(s,t,{targetHostId:o});return et.current.set(t,c),c}async function Le(t){Z(null),Y(null),Ct(t),Ve(null);const s=et.current.get(t)??null;if(Me(s),Be(!s),s)return;const r=De.current+1;De.current=r;try{const c=await Lt(t);if(De.current!==r)return;Me(c)}catch(c){if(De.current!==r)return;Ve(_(c,n("git.commitDetailLoadFailed"))),Me(null)}finally{De.current===r&&Be(!1)}}function Mi(){Ct(null),Be(!1),Ve(null),Me(null)}async function _e(t){try{const s=await Lt(t);await V(s.versionLabel,n("git.copyCommitVersionSuccess"))}catch(s){T({title:_(s,n("git.commitDetailLoadFailed")),tone:"error"})}}function Fe(t){Z(null),Y(null),He(t),ce(null),Ee(!0)}function Hi(t){var r;const s=((r=P[0])==null?void 0:r.commitHash)===t.commitHash&&t.commitKind==="local";return[{id:`view-changes:${t.commitHash}`,label:n("git.viewCommitChanges"),onSelect:()=>void Le(t.commitHash)},{id:`copy-hash:${t.commitHash}`,label:n("git.copyCommitHash"),onSelect:()=>void V(t.commitHash,n("git.copyCommitHashSuccess"))},{id:`copy-message:${t.commitHash}`,label:n("git.copyCommitMessage"),onSelect:()=>void V(xe(t),n("git.copyCommitMessageSuccess"))},{id:`copy-version:${t.commitHash}`,label:n("git.copyCommitVersion"),onSelect:()=>void _e(t.commitHash)},{id:`explain:${t.commitHash}`,label:n("git.explainCommitAction"),onSelect:()=>Fe(t.commitHash)},...s?[{id:`undo:${t.commitHash}`,label:n("git.undoLastCommit"),disabled:C,onSelect:()=>void he()}]:[]]}async function vn(t){Z(null),Y(null),await is(Hi(t))}async function Ei(){var t,s;if(!(!i||!nn||!Re||ie)){Nt(!0);try{const r=await Lt(nn),c=await ss({workspaceId:i,provider:Re,content:bs(r),clientRequestId:((s=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:s.call(t))??`git-explain-${Date.now()}-${Math.random().toString(16).slice(2)}`,permissionMode:as()},{targetHostId:o}),m=c.session??await rs(c.sessionId,{targetHostId:o});x(m),v();const w=o&&f?{hostId:o,workspaceId:f.workspaceId}:f;S(m.workspaceId,w),j(ds(m.workspaceId,m.sessionId,w)),Ee(!1),He(null),ce(null),T({title:n("git.explainCommitStarted"),tone:"success"})}catch(r){T({title:_(r,n("git.explainCommitFailed")),tone:"error"})}finally{Nt(!1)}}}function at(t){Qt(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t])}const Ri=450;function Sn(t){const s=Date.now(),r=mn.current;return mn.current={filePath:t,timestamp:s},(r==null?void 0:r.filePath)===t&&s-r.timestamp<=Ri}async function rt(t,s){if(s.binary){T({title:n("git.binaryDiff"),tone:"info"});return}if(s.status==="A"||s.status==="?")Pe(null),we(t);else if(i)try{const r=await Ji(i,t,s.staged,{targetHostId:o});Pe(r.content),we(t)}catch{Pe(null),we(t)}}function ot(t){q(t),z(null),B(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t])}function Tn(t){const s=hn.current;if(!s||!Number.isFinite(t))return;const r=s.getBoundingClientRect(),c=r.height-ht;if(!Number.isFinite(r.top)||!Number.isFinite(r.height)||c<=0)return;const m=(t-r.top-ht/2)/c*100;if(!Number.isFinite(m))return;const w=Math.max(_n,Math.min(Gt,Math.round(m)));un(w)}function wi(t){t.preventDefault(),Tn(t.clientY),Ht(!0)}const ke=(d==null?void 0:d.changes)??[],Q=ke.filter(t=>qt(t,"staged")),ge=ke.filter(t=>qt(t,"unstaged")),Mn=zn(Q,"staged"),Hn=zn(ge,"unstaged"),lt=new Set(oi),ct=new Set(yt),fe=Kn(yt,ke,"staged"),pe=Kn(yt,ke,"unstaged"),_t=ke.length===0&&((d==null?void 0:d.snapshot.ahead)??0)>0,Pi=Q.length>0&&Ce.trim().length>0,ut=(I==null?void 0:I.currentBranch)??(d==null?void 0:d.snapshot.branch)??n("common.unknown"),dt=pt(ze,Je),Oe=rn==="github",Ai=Oe?n("git.remoteAuthDescriptionGithub"):n("git.remoteAuthDescription"),Di=Oe?n("git.remoteAuthGithubPatLabel"):n("shell.clonePasswordLabel"),Li=Oe?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder"),_i=Oe?n("git.remoteAuthGithubUsernamePlaceholder"):n("shell.cloneUsernamePlaceholder"),Ft=Number.isFinite(cn)?cn:$t,Fi=te?`minmax(120px, ${Ft}fr) ${ht}px minmax(140px, ${100-Ft}fr)`:`minmax(120px, 1fr) ${ht}px auto`,ki=vs(d);l.useEffect(()=>{ve==="staged"&&fe.length===0&&z(null),ve==="unstaged"&&pe.length===0&&z(null)},[ve,fe.length,pe.length]),l.useEffect(()=>{if(!O)return;const t=ge.length>0?"unstaged":Q.length>0?"staged":"history";oe(s=>s==="unstaged"&&ge.length>0||s==="staged"&&Q.length>0?s:t)},[O,Q.length,ge.length]),l.useEffect(()=>{Te&&(P.some(t=>t.commitHash===Te)||Y(null))},[P,Te]),l.useEffect(()=>{le&&(P.some(t=>t.commitHash===le)||Z(null))},[le,P]),l.useEffect(()=>{O&&Se!=="history"&&ne&&W(!1)},[O,ne,Se]),l.useLayoutEffect(()=>{if(O||!ne){St(null);return}function t(){const r=pn.current,c=xn.current;!r||!c||typeof window>"u"||St(Yn(r.getBoundingClientRect(),{width:c.getBoundingClientRect().width||Xt,height:c.getBoundingClientRect().height||c.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}t();const s=window.requestAnimationFrame(t);return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[C,I==null?void 0:I.local.length,ut,O,ne]);const ee=Te??le;l.useLayoutEffect(()=>{if(!ee){Tt(null);return}const t=ee;function s(){const c=Ae.current.get(t)??null,m=Et.current;!c||!m||typeof window>"u"||Tt(Yn(c.getBoundingClientRect(),{width:m.getBoundingClientRect().width||Xt,height:m.getBoundingClientRect().height||m.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}s();const r=window.requestAnimationFrame(s);return window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{window.cancelAnimationFrame(r),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[ee,P.length]),l.useEffect(()=>{if(!ee||typeof document>"u")return;const t=ee;function s(r){const c=r.target;if(!(c instanceof Node))return;const m=Ae.current.get(t)??null,w=Et.current;m!=null&&m.contains(c)||w!=null&&w.contains(c)||(Y(null),Z(null))}return document.addEventListener("pointerdown",s),()=>{document.removeEventListener("pointerdown",s)}},[ee]);async function V(t,s){var r;try{if(p.isDesktop&&(await p.bridge.writeClipboardText(t)).ok){T({title:s,tone:"success"});return}if(typeof navigator<"u"&&((r=navigator.clipboard)!=null&&r.writeText)){await navigator.clipboard.writeText(t),T({title:s,tone:"success"});return}if(xs(t)){T({title:s,tone:"success"});return}}catch{T({title:n("common.copyContentFailed"),tone:"error"})}}async function En(t,s){typeof window<"u"&&!window.confirm(n("git.discardConfirm",{path:s}))||await Pt(t)}function Rn(t){const s=(t==null?void 0:t.desktopFloating)===!0&&!O,r=s?{top:($==null?void 0:$.top)??k,left:($==null?void 0:$.left)??k,maxHeight:$==null?void 0:$.maxHeight,transformOrigin:($==null?void 0:$.transformOrigin)??"top right"}:void 0,c=e.jsxs("div",{ref:s?xn:void 0,className:"git-operations-menu","data-floating":s?"true":"false",style:r,children:[e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.currentBranch")}),e.jsx("strong",{className:"git-menu-branch",children:ut})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.remoteAuthStatusLabel")}),e.jsxs("div",{className:"git-menu-branch-list",children:[e.jsx("strong",{className:"git-menu-branch",children:n("git.remoteAuthManageHint")}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:C||gi,onClick:()=>void vi(),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:I==null?void 0:I.local.map(m=>e.jsx("button",{className:"git-menu-item",type:"button",disabled:C||m.current,onClick:()=>void Ti(m.name),children:e.jsx("span",{children:m.current?`${n("git.switchBranch")} ${m.name}`:`${n("git.switchBranchTo")} ${m.name}`})},m.name))})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:C,onClick:()=>{W(!1),jt(!0)},children:e.jsx("span",{children:n("git.viewAllVersions")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:C,onClick:()=>void Dt("fetch"),children:e.jsx("span",{children:n("git.fetch")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:C,onClick:()=>void Dt("pull"),children:e.jsx("span",{children:n("git.pull")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:C,onClick:()=>void Dt("push"),children:e.jsx("span",{children:n("git.push")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:C,onClick:()=>void he(),children:e.jsx("span",{children:n("git.undoLastCommit")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:C||Ue,onClick:()=>void wt({resetTreeScroll:!0}),children:e.jsx("span",{children:n("git.refresh")})})]})]});return s?typeof document>"u"?null:An.createPortal(c,document.body):c}function kt(t,s){if(s){Ae.current.set(t,s);return}Ae.current.delete(t)}function Oi(){var r;if(!ee||typeof document>"u")return null;const t=P.find(c=>c.commitHash===ee);if(!t)return null;const s=((r=P[0])==null?void 0:r.commitHash)===t.commitHash&&t.commitKind==="local";return An.createPortal(e.jsx("div",{ref:Et,className:"git-history-entry-menu","data-floating":"true",style:{top:(G==null?void 0:G.top)??k,left:(G==null?void 0:G.left)??k,maxHeight:G==null?void 0:G.maxHeight,transformOrigin:(G==null?void 0:G.transformOrigin)??"top right"},children:e.jsx(gs,{item:t,canUndo:s,actioning:C,onViewCommitChanges:c=>void Le(c),onCopyCommitHash:c=>void V(c,n("git.copyCommitHashSuccess")),onCopyCommitMessage:c=>void V(xe(c),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:c=>void _e(c),onExplainCommitChange:c=>void Fe(c),onUndoLastCommit:()=>void he()})}),document.body)}return d&&!ki?e.jsx("section",{className:["conversation-panel","surface-card","git-sidebar",a].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:e.jsxs("section",{className:"git-card git-scaffold-section git-disabled-state",children:[e.jsxs("div",{className:"git-disabled-copy",children:[e.jsx("h3",{children:n("git.uninitializedTitle")}),e.jsx("p",{children:n("git.uninitializedDescription")})]}),e.jsx("div",{className:"git-primary-actions",children:e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>void Ni(),disabled:C||Ue||!i,children:C?n("git.initInProgress"):n("git.initRepository")})})]})}):e.jsxs("section",{className:["conversation-panel","surface-card","git-sidebar",a].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:[e.jsxs("section",{className:"git-card git-scaffold-section",children:[e.jsxs("div",{className:"git-editor-row",children:[e.jsx("textarea",{ref:fn,rows:1,value:Ce,onChange:t=>Ne(ii(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 ji(),disabled:C||Ue,children:e.jsx(ws,{})})]}),e.jsxs("div",{className:"git-primary-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void wt({resetTreeScroll:!0}),disabled:C||Ue||!i,children:n("git.refreshNow")}),e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>{if(_t){Cn();return}Ci()},disabled:C||!_t&&!Pi,children:_t?n("git.pushNow"):n("git.commitNow")})]})]}),O?e.jsxs("div",{className:"git-mobile-sections",children:[e.jsx(Bt,{title:n("git.stagedChangesTitle"),count:Q.length,expanded:Se==="staged",onToggle:()=>oe("staged"),children:e.jsx(Un,{title:n("git.stagedChangesTitle"),nodes:Mn,collapsedTreePathSet:lt,onToggleTreePath:at,onToggleMobileSelection:ot,selectedMobilePathSet:ct,selectedTargets:fe,actioning:C,variant:"staged",swipeRowState:ln,onSwipeRowChange:Qe,onStageToggle:it,onDiscardWithConfirm:En,onClearSelectedTargets:()=>B(t=>t.filter(s=>!fe.includes(s))),onPreviewFile:rt})}),e.jsx(Bt,{title:n("git.changesTitle"),count:ge.length,expanded:Se==="unstaged",onToggle:()=>oe("unstaged"),children:e.jsx(Un,{title:n("git.changesTitle"),nodes:Hn,collapsedTreePathSet:lt,onToggleTreePath:at,onToggleMobileSelection:ot,selectedMobilePathSet:ct,selectedTargets:pe,actioning:C,variant:"unstaged",swipeRowState:ln,onSwipeRowChange:Qe,onStageToggle:it,onDiscardWithConfirm:En,onClearSelectedTargets:()=>B(t=>t.filter(s=>!pe.includes(s))),onPreviewFile:rt})}),e.jsxs(Bt,{title:n("git.recentVersionsTitle"),count:be,expanded:Se==="history",onToggle:()=>oe("history"),trailingContent:e.jsx("span",{className:"badge",children:ut}),headerAction:e.jsx("button",{className:"git-icon-button git-mobile-section-action",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),"aria-expanded":ne,onClick:()=>{oe("history"),W(t=>!t)},disabled:C,children:e.jsx(Ie,{})}),children:[ne?e.jsx("div",{className:"git-mobile-operations-shell",children:Rn()}):null,e.jsx(hs,{history:P,historyLoadingMore:ye,hasMore:!!X,actioning:C,openCommitHash:Te,onMenuTriggerRef:kt,onToggleMenu:t=>Y(s=>s===t?null:t),onViewCommitChanges:t=>void Le(t),onCopyCommitHash:t=>void V(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void V(xe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void _e(t),onExplainCommitChange:t=>void Fe(t),onUndoLastCommit:()=>void he(),onLoadMore:()=>void nt()})]})]}):e.jsxs("div",{ref:hn,className:"git-content-split",style:{gridTemplateRows:Fi},children:[e.jsx("section",{className:"git-card git-tree-panel",children:e.jsxs("div",{ref:gn,className:"git-tree-panel-body",children:[Q.length>0?e.jsx(In,{title:n("git.stagedChangesTitle"),count:Q.length,nodes:Mn,selectedPath:re,collapsedTreePathSet:lt,onToggleTreePath:at,onSelectFile:q,onPreviewFile:(t,s)=>{Sn(t)&&rt(t,s)},onToggleMobileSelection:ot,onStageToggle:it,onDiscard:Pt,actioning:C,variant:"staged",isMobileViewport:O,selectedMobilePathSet:ct,selectedTargets:fe,mobileActionMenuOpen:ve==="staged",onToggleMobileActionMenu:()=>z(t=>t==="staged"?null:"staged"),onClearSelectedTargets:()=>B(t=>t.filter(s=>!fe.includes(s)))}):null,e.jsx(In,{title:n("git.changesTitle"),count:ge.length,nodes:Hn,selectedPath:re,collapsedTreePathSet:lt,onToggleTreePath:at,onSelectFile:q,onPreviewFile:(t,s)=>{Sn(t)&&rt(t,s)},onToggleMobileSelection:ot,onStageToggle:it,onDiscard:Pt,actioning:C,variant:"unstaged",isMobileViewport:O,selectedMobilePathSet:ct,selectedTargets:pe,mobileActionMenuOpen:ve==="unstaged",onToggleMobileActionMenu:()=>z(t=>t==="unstaged"?null:"unstaged"),onClearSelectedTargets:()=>B(t=>t.filter(s=>!pe.includes(s)))})]})}),e.jsx("button",{className:"git-panel-divider",type:"button",role:"separator","aria-label":n("git.resizePanels"),"aria-orientation":"horizontal","aria-valuemin":_n,"aria-valuemax":Gt,"aria-valuenow":te?Ft:Gt,"data-dragging":Mt,onPointerDown:wi,children:e.jsx("span",{className:"git-panel-divider-handle","aria-hidden":"true"})}),e.jsxs("section",{className:"git-card git-history-section",children:[e.jsxs("div",{className:"git-history-topbar",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":te,"aria-label":te?n("git.collapseRecentVersions"):n("git.expandRecentVersions"),onClick:()=>en(t=>!t),children:[e.jsxs("span",{className:"git-section-toggle-main",children:[e.jsx(xt,{expanded:te}),e.jsx("span",{children:n("git.recentVersionsTitle")})]}),e.jsx("span",{className:"workbench-section-counter",children:be})]}),e.jsxs("div",{className:"git-history-actions",children:[e.jsx("span",{className:"badge",children:ut}),e.jsx("button",{className:"git-icon-button",type:"button",ref:pn,"aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:()=>W(t=>!t),disabled:C,children:e.jsx(Ie,{})}),ne?Rn({desktopFloating:!0}):null]})]}),te?e.jsx(Vn,{history:P,historyLoadingMore:ye,hasMore:!!X,actioning:C,openCommitHash:le,useNativeContextMenu:jn,onMenuTriggerRef:kt,onScroll:yi,onToggleMenu:t=>{if(jn){const s=P.find(r=>r.commitHash===t);s&&vn(s);return}Z(s=>s===t?null:t)},onOpenContextMenu:t=>void vn(t),onViewCommitChanges:t=>void Le(t),onCopyCommitHash:t=>void V(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void V(xe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void _e(t),onExplainCommitChange:t=>void Fe(t),onUndoLastCommit:()=>void he(),onLoadMore:()=>void nt()}):null]})]}),e.jsxs($e,{open:hi,title:We==="push"?n("git.selectRemoteTitle"):n("git.remoteAuthManageTitle"),description:We==="push"?n("git.selectRemoteDesc"):n("git.remoteAuthManageDescription"),onClose:()=>{C||ue(!1)},children:[e.jsx("div",{className:"git-remote-select-list",children:ze.map(t=>{const s=qe.has(t.name),r=fi.get(t.name),c=Es(t,Ze[t.name]??null);return e.jsxs("div",{className:"git-remote-item",children:[We==="push"?e.jsxs("label",{className:"git-remote-item-selector",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:C,onChange:()=>{Ye(m=>{const w=new Set(m);return w.has(t.name)?w.delete(t.name):w.add(t.name),w})}}),e.jsxs("span",{className:"git-remote-item-body",children:[e.jsx("span",{className:"git-remote-name",children:t.name}),e.jsx("span",{className:"git-remote-url",children:t.pushUrl}),r&&e.jsx("span",{className:`git-remote-result ${r.ok?"ok":"err"}`,children:r.summary})]})]}):e.jsx("div",{className:"git-remote-item-selector git-remote-item-selector-static",children:e.jsxs("span",{className:"git-remote-item-body",children:[e.jsx("span",{className:"git-remote-name",children:t.name}),e.jsx("span",{className:"git-remote-url",children:t.pushUrl}),r&&e.jsx("span",{className:`git-remote-result ${r.ok?"ok":"err"}`,children:r.summary})]})}),e.jsxs("div",{className:"git-remote-item-meta",children:[e.jsx("span",{className:`git-remote-credential-badge ${c.kind}`,children:c.label}),e.jsx("button",{className:"secondary-button git-remote-inline-action",type:"button",disabled:C,onClick:()=>void st(t.name),children:n("git.remoteAuthAction")})]})]},t.name)})}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:C,onClick:()=>ue(!1),children:n("common.close")}),We==="push"?e.jsx("button",{className:"primary-button",type:"button",disabled:C||qe.size===0,onClick:()=>void Nn(Array.from(qe)),children:C?n("git.pushing"):n("git.pushSelected",{count:String(qe.size)})}):null]})]}),e.jsxs($e,{open:pi,title:n("git.remoteAuthTitle"),description:Ai,onClose:()=>{C||me(!1)},children:[dt?e.jsxs("div",{className:"git-remote-auth-target",children:[e.jsx("strong",{children:dt.name}),e.jsx("span",{children:dt.pushUrl||dt.fetchUrl})]}):null,e.jsxs("div",{className:"workbench-clone-form",children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneAuthModeLabel")}),e.jsxs("select",{value:L.authMode,disabled:C,onChange:t=>J(s=>({...s,authMode:t.target.value})),children:[e.jsx("option",{value:"none",children:n("shell.cloneAuthModeNone")}),e.jsx("option",{value:"basic",children:n("shell.cloneAuthModeBasic")}),e.jsx("option",{value:"token",children:n("shell.cloneAuthModeToken")})]})]}),L.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:L.username,placeholder:_i,autoComplete:"username",onChange:t=>J(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:Di}),e.jsx("input",{type:"password",value:L.password,placeholder:Li,autoComplete:"current-password",onChange:t=>J(s=>({...s,password:t.target.value}))})]})]}):null,L.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:L.username,placeholder:n("shell.cloneTokenUsernamePlaceholder"),autoComplete:"username",onChange:t=>J(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneTokenLabel")}),e.jsx("input",{type:"password",value:L.token,placeholder:n("shell.cloneTokenPlaceholder"),autoComplete:"current-password",onChange:t=>J(s=>({...s,token:t.target.value}))})]})]}):null,Oe?e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthGithubPatHint")}):null,L.authMode!=="none"?e.jsxs("label",{className:"settings-checkbox git-remote-auth-remember-toggle",children:[e.jsx("input",{type:"checkbox",checked:L.rememberOnHost,onChange:t=>J(s=>({...s,rememberOnHost:t.target.checked}))}),e.jsx("span",{children:n("git.remoteAuthRemember")})]}):null,e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthSessionHint")})]}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:C,onClick:()=>me(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:C,onClick:Si,children:n("git.remoteAuthSave")})]})]}),e.jsx($e,{open:ci,title:n("git.viewAllVersions"),description:n("git.viewAllVersionsDescription",{count:String(be)}),onClose:()=>jt(!1),children:e.jsx(Vn,{history:P,historyLoadingMore:ye,hasMore:!!X,actioning:C,openCommitHash:le,className:"git-history-modal-list",onMenuTriggerRef:kt,onToggleMenu:t=>Z(s=>s===t?null:t),onViewCommitChanges:t=>void Le(t),onCopyCommitHash:t=>void V(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void V(xe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void _e(t),onExplainCommitChange:t=>void Fe(t),onUndoLastCommit:()=>void he(),onLoadMore:()=>void nt()})}),e.jsx($e,{open:ui!==null,className:"git-commit-detail-modal",title:(F==null?void 0:F.subject)||n("git.commitDetailTitle"),description:F?n("git.commitDetailDescription",{hash:F.shortHash}):n("git.commitDetailLoading"),onClose:Mi,children:di?e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailLoading")})}):tn?e.jsx("div",{className:"git-commit-detail-state is-error",children:e.jsx("p",{children:tn})}):F?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:F.versionLabel})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitHashLabel")}),e.jsx("strong",{children:F.commitHash})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitAuthorLabel")}),e.jsx("strong",{children:F.authorName})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitTimeLabel")}),e.jsx("strong",{children:js(F.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:xe(F)})]}),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:F.changedFiles.length})]}),e.jsx("div",{className:"git-commit-detail-file-list",children:F.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")}),F.diffTruncated?e.jsx("span",{className:"git-commit-detail-truncated",children:n("git.diffTruncated")}):null]}),e.jsx("pre",{className:"git-commit-detail-diff",children:F.diffContent||n("git.emptyDiff")})]})]}):e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailEmpty")})})}),e.jsx($e,{open:mi,className:"git-explain-provider-modal",title:n("git.explainCommitTitle"),description:n("git.explainCommitDescription"),onClose:()=>{ie||(Ee(!1),He(null),ce(null))},children:e.jsxs("div",{className:"git-explain-provider-shell",children:[e.jsx(Wi,{workspaceId:i,selectedProvider:Re,pendingProvider:ie?Re:null,disabled:ie,onSelect:t=>ce(t)}),e.jsxs("div",{className:"git-explain-provider-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:ie,onClick:()=>{Ee(!1),He(null),ce(null)},children:n("common.cancel")}),e.jsx("button",{type:"button",className:"primary-button",disabled:!Re||ie,onClick:()=>void Ei(),children:ie?n("conversation.sendingState"):n("git.startExplainCommit")})]})]})}),e.jsx(zi,{workspaceId:i,filePath:dn,open:dn!==null,onClose:()=>{we(null),Pe(null)},onSaved:async()=>{await wt({resetTreeScroll:!0})},diffContent:xi}),Oi()]})}function In({title:a,count:i,nodes:u,selectedPath:h,collapsedTreePathSet:g,onToggleTreePath:j,onSelectFile:p,onPreviewFile:y,onToggleMobileSelection:b,onStageToggle:N,onDiscard:M,actioning:v,variant:S,isMobileViewport:x,selectedMobilePathSet:o,selectedTargets:f,mobileActionMenuOpen:d,onToggleMobileActionMenu:H,onClearSelectedTargets:R}){const E=Jn(),P=Jt(u),A=S==="staged"?n("git.unstageAll"):n("git.stageAll");return e.jsxs("section",{className:"git-tree-group","data-variant":S,children:[e.jsxs("div",{className:"git-section-header git-tree-group-header",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"git-tree-group-actions",children:[e.jsx("span",{className:"workbench-section-counter",children:i}),!x&&P.length>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":A,title:A,onClick:()=>void N(P,S==="staged"),disabled:v,children:e.jsx(Yt,{staged:S==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":n("git.discardAll"),title:n("git.discardAll"),onClick:()=>void M(P),disabled:v,children:e.jsx(Zt,{})}):null]}):null,x&&f.length>0?e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:H,disabled:v,children:e.jsx(Ie,{})}):null]}),x&&d?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:f.length})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void N(f,S==="staged"),children:e.jsx("span",{children:S==="staged"?n("git.unstage"):n("git.stage")})}),S==="unstaged"?e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void M(f),children:e.jsx("span",{children:n("git.discard")})}):null,e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:R,children:e.jsx("span",{children:n("git.clearSelection")})})]})]}):null]}),e.jsx("div",{ref:E,className:"git-tree-shell",role:"tree","aria-label":a,"data-scrollbar-autohide":"true",children:u.length?ei({nodes:u,depth:0,collapsedTreePathSet:g,selectedPath:h,onToggleTreePath:j,onSelectFile:p,onPreviewFile:y,onToggleMobileSelection:b,onStageToggle:N,onDiscard:M,actioning:v,variant:S,isMobileViewport:x,selectedMobilePathSet:o}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Bt({title:a,count:i,expanded:u,onToggle:h,trailingContent:g,headerAction:j,children:p}){return e.jsxs("section",{className:"git-mobile-section","data-expanded":u,children:[e.jsxs("div",{className:"git-mobile-section-header",children:[e.jsxs("button",{className:"git-mobile-section-toggle",type:"button","aria-expanded":u,onClick:h,children:[e.jsxs("span",{className:"git-mobile-section-toggle-main",children:[e.jsx(xt,{expanded:u}),e.jsx("h3",{children:a})]}),e.jsxs("span",{className:"git-mobile-section-toggle-meta",children:[g,e.jsx("span",{className:"workbench-section-counter",children:i})]})]}),j?e.jsx("div",{className:"git-mobile-section-header-action",children:j}):null]}),u?e.jsx("div",{className:"git-mobile-section-body",children:p}):null]})}function Un({title:a,nodes:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,selectedTargets:p,actioning:y,variant:b,swipeRowState:N,onSwipeRowChange:M,onStageToggle:v,onDiscardWithConfirm:S,onClearSelectedTargets:x,onPreviewFile:o}){return e.jsxs("div",{className:"git-mobile-record-shell",children:[p.length>0?e.jsxs("div",{className:"git-mobile-selection-toolbar",children:[e.jsxs("span",{className:"git-mobile-selection-count",children:[n("git.selectedFiles")," ",p.length]}),e.jsxs("div",{className:"git-mobile-selection-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:y,onClick:()=>void v(p,b==="staged"),children:b==="staged"?n("git.unstage"):n("git.stage")}),b==="unstaged"?e.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:y,onClick:()=>void S(p,`${p.length}`),children:n("git.discard")}):null,e.jsx("button",{type:"button",className:"secondary-button",disabled:y,onClick:x,children:n("git.clearSelection")})]})]}):null,e.jsx("div",{className:"git-mobile-record-list",role:"tree","aria-label":a,children:i.length?Qn({nodes:i,depth:0,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:y,variant:b,swipeRowState:N,onSwipeRowChange:M,onStageToggle:v,onDiscardWithConfirm:S,onPreviewFile:o}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Qn({nodes:a,depth:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:p,variant:y,swipeRowState:b,onSwipeRowChange:N,onStageToggle:M,onDiscardWithConfirm:v,onPreviewFile:S}){return a.map(x=>{if(x.kind==="directory"){const d=!u.has(x.path),H=Jt(x.children),R=`directory:${x.path}`;return e.jsxs("div",{className:"git-mobile-record-branch",children:[e.jsx(Bn,{rowKey:R,openState:(b==null?void 0:b.path)===R?b.direction:null,onOpenStateChange:E=>N(E?{path:R,direction:E}:null),trailingActions:H.length>0?[{label:y==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M(H,y==="staged")},...y==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void v(H,x.path)}]:[]]:null,children:e.jsxs("button",{className:"git-mobile-record git-mobile-record-directory",type:"button",style:{paddingInlineStart:`${$n+i*Gn}px`},onClick:()=>h(x.path),children:[e.jsxs("span",{className:"git-mobile-record-leading",children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":d,children:e.jsx(xt,{expanded:d})}),e.jsx("span",{className:"git-mobile-record-title",children:x.name})]}),e.jsx("span",{className:"git-mobile-record-meta",children:H.length})]})}),d?e.jsx("div",{className:"git-mobile-record-children",role:"group",children:Qn({nodes:x.children,depth:i+1,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:p,variant:y,swipeRowState:b,onSwipeRowChange:N,onStageToggle:M,onDiscardWithConfirm:v,onPreviewFile:S})}):null]},R)}const o=`file:${x.path}`,f=j.has(x.path);return e.jsx(Bn,{rowKey:o,openState:(b==null?void 0:b.path)===o?b.direction:null,onOpenStateChange:d=>N(d?{path:o,direction:d}:null),trailingActions:[{label:n("git.preview"),tone:"neutral",onPress:()=>S(x.change.path,x.change)},{label:y==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M([x.change.path],y==="staged")},...y==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void v([x.change.path],x.path)}]:[]],children:e.jsxs("div",{className:"git-mobile-record git-mobile-record-file","data-active":f,style:{paddingInlineStart:`${$n+i*Gn}px`},children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:f,"aria-label":`${n("git.selectFile")} ${x.name}`,onChange:()=>g(x.change.path)}),e.jsxs("button",{className:"git-mobile-record-file-main",type:"button",onClick:()=>g(x.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Kt(x.name),"aria-hidden":"true",children:zt(x.name)}),e.jsxs("span",{className:"git-mobile-record-copy",children:[e.jsx("span",{className:"git-mobile-record-title",children:x.name}),e.jsx("span",{className:"git-mobile-record-path",children:x.path})]}),e.jsx("span",{className:"git-status-badge","data-status":x.status,children:x.status})]})]})},o)})}function Bn({rowKey:a,openState:i,onOpenStateChange:u,trailingActions:h,children:g}){const j=us(),p=l.useRef(null),[y,b]=l.useState(0),N=((h==null?void 0:h.length)??0)*It;l.useEffect(()=>{i||b(0)},[i,a]);const M=y!==0?y:i==="trailing"?-N:0;function v(f){var d,H;f.button===0&&(p.current={pointerId:f.pointerId,startX:f.clientX},(H=(d=f.currentTarget).setPointerCapture)==null||H.call(d,f.pointerId))}function S(f){const d=p.current;if(!d||d.pointerId!==f.pointerId)return;const H=N>0?N+10:0,R=Math.max(-H,Math.min(0,f.clientX-d.startX));b(R)}function x(f){var H,R;const d=p.current;if(!(!d||d.pointerId!==f.pointerId)){if((R=(H=f.currentTarget).releasePointerCapture)==null||R.call(H,f.pointerId),p.current=null,y<=-44&&(h!=null&&h.length)){j.trigger("gesture"),u("trailing"),b(0);return}u(null),b(0)}}function o(f){var H,R;const d=p.current;!d||d.pointerId!==f.pointerId||((R=(H=f.currentTarget).releasePointerCapture)==null||R.call(H,f.pointerId),p.current=null,b(0))}return e.jsxs("div",{className:"git-mobile-swipe-row","data-open-state":i??"closed","data-dragging":y!==0,children:[h==null?void 0:h.map((f,d)=>e.jsx("button",{type:"button",className:"git-mobile-swipe-action trailing","data-tone":f.tone,style:{right:d*It,width:It},onClick:()=>{j.trigger(f.tone==="danger"?"warning":"action"),u(null),f.onPress()},children:f.label},`trailing-${d}`)),e.jsx("div",{className:"git-mobile-swipe-content",style:{transform:`translateX(${M}px)`},onPointerDown:v,onPointerMove:S,onPointerUp:x,onPointerCancel:o,children:g})]})}function hs({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:g,onMenuTriggerRef:j,onToggleMenu:p,onViewCommitChanges:y,onCopyCommitHash:b,onCopyCommitMessage:N,onCopyCommitVersion:M,onExplainCommitChange:v,onUndoLastCommit:S,onLoadMore:x}){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:si(o.commitKind)})]}),o.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:o.refs.map(f=>e.jsx("span",{className:"git-history-ref-pill","data-kind":f.kind,"data-remote-index":String(ai(f.remoteName)),children:f.name},`${o.commitHash}:${f.kind}:${f.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:ri(o.authoredAt)})]})]}),e.jsx("button",{type:"button",className:"git-icon-button",ref:f=>j(o.commitHash,f),"aria-label":n("git.historyItemMenu"),onClick:()=>p(o.commitHash),children:e.jsx(Ie,{})})]})},o.commitHash)),u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:x,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"git-tree-status",children:n("git.noHistory")})}function Vn({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:g,className:j,useNativeContextMenu:p=!1,onMenuTriggerRef:y,onScroll:b,onToggleMenu:N,onOpenContextMenu:M,onViewCommitChanges:v,onCopyCommitHash:S,onCopyCommitMessage:x,onCopyCommitVersion:o,onExplainCommitChange:f,onUndoLastCommit:d,onLoadMore:H}){const R=Jn();return a.length?e.jsxs("div",{ref:R,className:["git-history-list",j].filter(Boolean).join(" "),onScroll:b,"data-scrollbar-autohide":"true",children:[a.map(E=>{const P=g===E.commitHash;return e.jsxs("article",{className:"git-history-entry","data-kind":E.commitKind,"data-menu-open":P?"true":"false",onContextMenu:A=>{!p||!M||(A.preventDefault(),A.stopPropagation(),M(E))},children:[e.jsx("span",{className:"git-history-marker","data-kind":E.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:E.subject,children:E.subject}),e.jsxs("div",{className:"git-history-title-actions",children:[e.jsx("span",{className:"git-history-kind-badge","data-kind":E.commitKind,children:si(E.commitKind)}),p?null:e.jsx("button",{type:"button",className:"git-icon-button git-history-more",ref:A=>y(E.commitHash,A),"aria-label":n("git.historyItemMenu"),onClick:()=>{N(E.commitHash)},children:e.jsx(Ie,{})})]})]}),E.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:E.refs.map(A=>e.jsx("span",{className:"git-history-ref-pill","data-kind":A.kind,"data-remote-index":String(ai(A.remoteName)),children:A.name},`${E.commitHash}:${A.kind}:${A.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:E.commitHash.slice(0,8)}),e.jsx("span",{children:E.authorName}),e.jsx("time",{dateTime:E.authoredAt,children:ri(E.authoredAt)})]})]})]},E.commitHash)}),i?e.jsxs("p",{className:"git-history-loading",children:[n("git.refreshNow"),"..."]}):null,u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:H,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"status-text",children:n("git.noHistory")})}function gs({item:a,canUndo:i,actioning:u,onViewCommitChanges:h,onCopyCommitHash:g,onCopyCommitMessage:j,onCopyCommitVersion:p,onExplainCommitChange:y,onUndoLastCommit:b}){return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>h(a.commitHash),children:e.jsx("span",{children:n("git.viewCommitChanges")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>g(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitHash")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>j(a),children:e.jsx("span",{children:n("git.copyCommitMessage")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>p(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitVersion")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>y(a.commitHash),children:e.jsx("span",{children:n("git.explainCommitAction")})}),i?e.jsx("button",{type:"button",className:"git-menu-item",disabled:u,onClick:b,children:e.jsx("span",{children:n("git.undoLastCommit")})}):null]})}function ei({nodes:a,depth:i,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:g,onSelectFile:j,onPreviewFile:p,onToggleMobileSelection:y,onStageToggle:b,onDiscard:N,actioning:M,variant:v,isMobileViewport:S,selectedMobilePathSet:x}){return a.map(o=>{if(o.kind==="directory"){const H=!u.has(o.path),R=Jt(o.children),E=`${v==="staged"?n("git.unstage"):n("git.stage")} ${o.path}`,P=`${n("git.discard")} ${o.path}`;return e.jsxs("div",{className:"git-tree-node",children:[e.jsxs("div",{className:"git-tree-row",role:"treeitem","aria-expanded":H,children:[e.jsxs("button",{className:"git-tree-trigger",type:"button",style:{paddingInlineStart:`${6+i*8}px`},onClick:()=>g(o.path),children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":H,children:e.jsx(xt,{expanded:H})}),e.jsx("span",{className:"git-tree-label git-tree-label-directory",children:o.name})]}),!S&&R.length>0?e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":E,title:E,onClick:()=>void b(R,v==="staged"),disabled:M,children:e.jsx(Yt,{staged:v==="staged"})}),v==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":P,title:P,onClick:()=>void N(R),disabled:M,children:e.jsx(Zt,{})}):null]}):null]}),H?e.jsx("div",{className:"git-tree-children",role:"group",children:ei({nodes:o.children,depth:i+1,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:g,onSelectFile:j,onPreviewFile:p,onToggleMobileSelection:y,onStageToggle:b,onDiscard:N,actioning:M,variant:v,isMobileViewport:S,selectedMobilePathSet:x})}):null]},`directory:${o.path}`)}const f=x.has(o.path),d=S?f:h===o.path;return S?e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":d,"data-mobile":"true",children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:f,"aria-label":`${n("git.selectFile")} ${o.name}`,onChange:()=>y(o.change.path)}),e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":d,"data-mobile":"true",style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>y(o.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Kt(o.name),"aria-hidden":"true",children:zt(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":d,children:[e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":d,style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>{j(o.change.path),p&&p(o.change.path,o.change)},children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Kt(o.name),"aria-hidden":"true",children:zt(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(Yt,{staged:o.variant==="staged"})}),v==="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(Zt,{})}):null]})]},`file:${o.path}`)})}function Wn(a,i){return{kind:"directory",name:a,path:i,children:new Map}}function zn(a,i){const u=Wn("","");for(const h of a){const g=h.path.replace(/\\/g,"/"),j=g.split("/").filter(Boolean);let p=u;j.forEach((y,b)=>{const N=j.slice(0,b+1).join("/");if(b===j.length-1){p.children.set(`file:${N}`,{kind:"file",name:y,path:g,change:h,status:fs(h,i),variant:i});return}const M=`directory:${N}`,v=p.children.get(M);if(v&&v.kind==="directory"){p=v;return}const S=Wn(y,N);p.children.set(M,S),p=S})}return ni(ti([...u.children.values()]))}function ti(a){return[...a].sort((i,u)=>i.kind!==u.kind?i.kind==="directory"?-1:1:i.name.localeCompare(u.name,"zh-CN")).map(i=>i.kind==="directory"?{kind:"directory",name:i.name,path:i.path,children:ti([...i.children.values()])}:i)}function ni(a){return a.map(i=>{var p;if(i.kind!=="directory")return i;const u=ni(i.children);let h=i.name,g=i.path,j=u;for(;j.length===1&&((p=j[0])==null?void 0:p.kind)==="directory";){const y=j[0];h=`${h}/${y.name}`,g=y.path,j=y.children}return{kind:"directory",name:h,path:g,children:j}})}function Kn(a,i,u){const h=new Set(a);return i.filter(g=>qt(g,u)&&h.has(g.path)).map(g=>g.path)}function Jt(a){const i=[],u=new Set;function h(g){if(g.kind==="file"){u.has(g.path)||(u.add(g.path),i.push(g.path));return}g.children.forEach(h)}return a.forEach(h),i}function qt(a,i){return i==="staged"?!!a.stagedStatus:!!a.worktreeStatus}function fs(a,i){return i==="staged"?a.stagedStatus??a.status:a.worktreeStatus??a.status}function ps(a){return{subject:ii(a).trim(),body:null,footer:null,source:"manual"}}function ii(a){return a.replace(/[\r\n]+/g," ")}function xs(a){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const i=document.createElement("textarea");i.value=a,i.setAttribute("readonly","true"),i.style.position="fixed",i.style.top="-9999px",i.style.left="-9999px",i.style.opacity="0",document.body.appendChild(i),i.focus(),i.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(i)}}function xe(a){const i=a.subject.trim(),u=a.body.trim();return u?`${i}
1
+ import{b as l,E as wn,ac as Pn,F as Gi,t as n,j as e,B as Zn}from"./index-CILPuSCp.js";import{u as Ii,e as Ui,f as Bi,g as An}from"./App-D5hc6KuU.js";import{b as Vi,ar as mt,S as Wi,c1 as zi,ca as Ki,cb as Xi,bT as qi,cc as Dn,cd as Yi,ce as Zi,c0 as Ji,cf as Qi,bX as es,cg as ts,bV as Jn,ch as ns,c9 as is,ci as Ln,a9 as ss,a8 as as,aa as rs,cj as os,bY as zt,bZ as Kt,ck as ls,cl as cs,I as us}from"./WorkbenchLayout-yGxGKcG1.js";import{W as $e}from"./WorkbenchModal-Cm-ciXO9.js";import{c as ds}from"./workbench-navigation-hwM28xIb.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./host-alias-df5bYDlE.js";import"./DesktopModal-BCVZq_PQ.js";import"./relay-entry-ErQKnI7B.js";import"./MobileSheet-DPYtp5Ze.js";const $t=56,_n=28,Gt=72,ht=8,Fn=960,kn=60*1e3,On=20,$n=9,Gn=9,It=68,k=12,gt=8,Xt=260,ms=120,Ut=6e4,ft={authMode:"none",username:"",password:"",token:"",rememberOnHost:!1};function Us({className:a,workspaceId:i,panelActive:u=!0,externalWindowMode:h=!1,workbenchShellOverrides:g}){const j=Ii(),p=Ui(),y=Vi(),{subscribeGitSnapshot:b,requestGitRefresh:N,addGitSnapshotListener:M,requestNavigationRefresh:v,selectWorkspace:S,upsertNavigationSession:x,currentTargetHostId:o,currentWorkspaceRef:f}={...y,...g},[d,H]=l.useState(null),[R,E]=l.useState(null),[P,A]=l.useState([]),[be,se]=l.useState(0),[X,ae]=l.useState(null),[ye,bt]=l.useState(!1),[I,je]=l.useState(null),[re,q]=l.useState(null),[Ce,Ne]=l.useState(""),[Ue,U]=l.useState(!1),[C,D]=l.useState(!1),[oi,Qt]=l.useState([]),[te,en]=l.useState(!0),[ne,W]=l.useState(!1),[O,li]=l.useState(()=>typeof window<"u"?window.innerWidth<=Fn:!1),[yt,B]=l.useState([]),[ve,z]=l.useState(null),[Se,oe]=l.useState("unstaged"),[Te,Y]=l.useState(null),[le,Z]=l.useState(null),[ci,jt]=l.useState(!1),[ui,Ct]=l.useState(null),[di,Be]=l.useState(!1),[tn,Ve]=l.useState(null),[F,Me]=l.useState(null),[nn,He]=l.useState(null),[mi,Ee]=l.useState(!1),[Re,ce]=l.useState(null),[ie,Nt]=l.useState(!1),[hi,ue]=l.useState(!1),[We,vt]=l.useState("push"),[ze,Ke]=l.useState([]),[gi,Xe]=l.useState(!1),[qe,Ye]=l.useState(new Set),[fi,de]=l.useState(new Map),[Ze,sn]=l.useState({}),[pi,me]=l.useState(!1),[Je,an]=l.useState(null),[L,J]=l.useState(ft),[rn,on]=l.useState("generic"),[ln,Qe]=l.useState(null),[$,St]=l.useState(null),[G,Tt]=l.useState(null),[cn,un]=l.useState($t),[Mt,Ht]=l.useState(!1),[dn,we]=l.useState(null),[xi,Pe]=l.useState(null),mn=l.useRef(null),hn=l.useRef(null),gn=l.useRef(null),fn=l.useRef(null),pn=l.useRef(null),xn=l.useRef(null),Et=l.useRef(null),Ae=l.useRef(new Map),et=l.useRef(new Map),De=l.useRef(0),bn=l.useRef(u),yn=l.useRef(u),tt=l.useRef(null),{showToast:T}=Bi(),jn=p.isDesktop&&!O;l.useEffect(()=>{mt("git_sidebar.props",{workspaceId:i,externalWindowMode:h})},[h,i]),l.useEffect(()=>{yn.current=u},[u]),l.useEffect(()=>{Qt([]),en(!0),se(0),ae(null),bt(!1),q(null),Ne(""),W(!1),B([]),z(null),oe("unstaged"),Y(null),Z(null),jt(!1),Ct(null),Be(!1),Ve(null),Me(null),He(null),Ee(!1),ce(null),Nt(!1),ue(!1),vt("push"),Ke([]),Ye(new Set),de(new Map),sn({}),me(!1),an(null),J(ft),on("generic"),Qe(null),St(null),Tt(null),Ht(!1),un($t),we(null),Pe(null),et.current.clear(),Ae.current.clear()},[i]),l.useEffect(()=>{function t(){li(window.innerWidth<=Fn)}return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),l.useEffect(()=>{if(!Mt)return;const t=document.body.style.cursor,s=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";function r(m){Tn(m.clientY)}function c(){Ht(!1)}return window.addEventListener("pointermove",r),window.addEventListener("pointerup",c),()=>{document.body.style.cursor=t,document.body.style.userSelect=s,window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",c)}},[Mt]),l.useEffect(()=>{var c,m;if(!(i!=null&&i.trim())){tt.current=null,H(null),E(null),A([]),se(0),ae(null),je(null),U(!1);return}const t=i.trim(),s=wn(Ge(t,o),kn),r=Vt(s);if(mt("git_sidebar.snapshot",{workspaceId:t,cached:r,cachedHistoryCount:((c=s==null?void 0:s.history)==null?void 0:c.length)??0,cachedChangedCount:((m=s==null?void 0:s.status)==null?void 0:m.changes.length)??0}),r&&s){Rt(s,t),U(!1);return}tt.current=null,Pn(Ge(t,o)),H(null),E(null),A([]),se(0),ae(null),je(null),U(!0)},[i]),l.useEffect(()=>{if(i!=null&&i.trim())return M(t=>{var s,r,c;t.workspaceId!==i.trim()||!Ns(Cs(t),o)||(mt("git_sidebar.snapshot_received",{workspaceId:t.workspaceId,changedCount:((s=t.status)==null?void 0:s.changes.length)??0,historyCount:t.history.length,branchCount:(((r=t.branches)==null?void 0:r.local.length)??0)+(((c=t.branches)==null?void 0:c.remote.length)??0)}),Rt(t,t.workspaceId),U(!1))})},[M,i]),l.useEffect(()=>{if(!(i!=null&&i.trim()))return;const t=i.trim(),s=wn(Ge(t,o),kn),r=Vt(s)?(s==null?void 0:s.revision)??null:null;b(t,{knownRevision:r,targetHostId:o}),yn.current&&K()},[o,N,b,i]),l.useEffect(()=>{const t=bn.current;bn.current=u,i!=null&&i.trim()&&!t&&u&&N(i.trim(),{knownRevision:R,targetHostId:o})},[o,u,N,R,i]),l.useEffect(()=>{const t=i==null?void 0:i.trim();if(!t||tt.current!==t)return;const s={revision:R,status:d,history:P,historyTotalCount:be,historyNextCursor:X,branches:I};if(!Vt(s)){Pn(Ge(t,o));return}Gi(Ge(t,o),s)},[I,P,X,be,R,d,i]),l.useEffect(()=>{if(!d||!re)return;d.changes.find(s=>s.path===re)||q(null)},[re,d]),l.useEffect(()=>{ys(fn.current)},[Ce]),l.useEffect(()=>{O||(B([]),z(null),Y(null),Qe(null))},[O]),l.useEffect(()=>{if(!d){B([]);return}const t=new Set(d.changes.map(s=>s.path));B(s=>s.filter(r=>t.has(r)))},[d]);function bi(){const t=gn.current;if(!t)return;t.querySelectorAll(".git-tree-shell").forEach(r=>{r.scrollTop=0})}function Rt(t,s){tt.current=(s==null?void 0:s.trim())??(i==null?void 0:i.trim())??null,E(typeof t.revision=="string"?t.revision:null),H(t.status),A(Array.isArray(t.history)?t.history:[]),se(typeof t.historyTotalCount=="number"?t.historyTotalCount:0),ae(typeof t.historyNextCursor=="string"?t.historyNextCursor:null),je(t.branches??null)}function K(t){i!=null&&i.trim()&&(U(!0),mt("git_sidebar.refresh_requested",{workspaceId:i.trim(),resetTreeScroll:!1}),N(i.trim(),{knownRevision:R,targetHostId:o}))}async function wt(t){if(!(i!=null&&i.trim()))return;const s=i.trim();U(!0);try{const[r,c,m]=await Promise.all([qi(s,{targetHostId:o}),Dn(s,On,null,{targetHostId:o}),Yi(s,{targetHostId:o})]);Rt({status:r,history:c.items,historyTotalCount:c.totalCount,historyNextCursor:c.nextCursor,branches:m}),N(s,{targetHostId:o}),t!=null&&t.resetTreeScroll&&requestAnimationFrame(()=>{bi()})}catch(r){T({title:_(r,n("git.panelLoadFailed")),tone:"error"})}finally{U(!1)}}async function nt(){if(!(!i||!X||ye)){bt(!0);try{const t=await Dn(i,On,X,{targetHostId:o});A(s=>{const r=new Set(s.map(m=>m.commitHash)),c=t.items.filter(m=>!r.has(m.commitHash));return[...s,...c]}),se(t.totalCount),ae(t.nextCursor)}catch(t){T({title:_(t,n("git.panelLoadFailed")),tone:"error"})}finally{bt(!1)}}}function yi(t){if(!te||ye||!X)return;const s=t.currentTarget;s.scrollHeight-s.scrollTop-s.clientHeight<=40&&nt()}async function ji(){if(i){D(!0);try{const t=await Xi(i,"ai",{targetHostId:o});Ne(t.validation.normalizedDraft.subject||t.draft.subject)}catch(t){T({title:_(t,n("git.draftFailed")),tone:"error"})}finally{D(!1)}}}async function it(t,s){if(i&&t.length){D(!0);try{const r=s?await Qi(i,t,{targetHostId:o}):await es(i,t,{targetHostId:o});H(r),q(t[t.length-1]??null),B(c=>c.filter(m=>!t.includes(m))),z(null),K()}catch(r){U(!1),T({title:_(r,n("git.stageFailed")),tone:"error"})}finally{D(!1)}}}async function Pt(t){if(i&&t.length){D(!0);try{const s=await ns(i,t,{targetHostId:o});H(s),t.includes(re??"")&&q(null),B(r=>r.filter(c=>!t.includes(c))),z(null),K()}catch(s){U(!1),T({title:_(s,n("git.discardFailed")),tone:"error"})}finally{D(!1)}}}async function Ci(){if(!(!i||!Ce.trim())){D(!0);try{await Zi(i,ps(Ce),{targetHostId:o}),T({title:n("git.commitSuccess"),tone:"success"}),Ne(""),q(null),K()}catch(t){T({title:_(t,n("git.commitFailed")),tone:"error"})}finally{D(!1)}}}async function Ni(){if(i!=null&&i.trim()){D(!0),U(!0);try{const t=await Ki(i.trim(),{targetHostId:o});H(t),A([]),se(0),ae(null),je(null),T({title:n("git.initSuccess"),tone:"success"}),K()}catch(t){T({title:_(t,n("git.initFailed")),tone:"error"})}finally{D(!1),U(!1)}}}async function At(){const t=i==null?void 0:i.trim();if(!t)return[];const s=await os(t,{targetHostId:o});return(i==null?void 0:i.trim())!==t?[]:(Ke(s),s)}async function st(t){const s=await At(),r=pt(s,t);if(!r){T({title:n("git.noRemotes"),tone:"error"});return}const c=Ze[r.name]??null;an(r.name),on(Hs(s,r.name)),J(Ts((c==null?void 0:c.auth)??null,(c==null?void 0:c.rememberOnHost)??!1)),me(!0)}async function vi(){if(i!=null&&i.trim()){Xe(!0);try{const t=await At();if(t.length===0){T({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){await st(t[0].name);return}vt("auth"),Ye(new Set),de(new Map),ue(!0)}catch(t){T({title:_(t,n("git.remoteFailed")),tone:"error"})}finally{Xe(!1)}}}function Si(){const t=Je==null?void 0:Je.trim();if(!t){me(!1);return}const s=Ms(L),r=rn==="github"?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder");if(L.authMode==="basic"){if(!L.username.trim()){T({title:n("shell.cloneUsernamePlaceholder"),tone:"error"});return}if(!L.password){T({title:r,tone:"error"});return}}if(L.authMode==="token"&&!L.token){T({title:n("shell.cloneTokenPlaceholder"),tone:"error"});return}sn(c=>{if(!s){const{[t]:m,...w}=c;return w}return{...c,[t]:{auth:s,rememberOnHost:L.rememberOnHost}}}),me(!1),T({title:s?n("git.remoteAuthSaved"):n("git.remoteAuthCleared"),description:s&&L.rememberOnHost?n("git.remoteAuthRememberHint"):void 0,tone:"success"})}async function Cn(){if(i){Xe(!0);try{const t=await At();if(t.length===0){T({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){Nn([t[0].name]);return}vt("push"),Ye(new Set),de(new Map),ue(!0)}catch(t){T({title:_(t,n("git.remoteFailed")),tone:"error"})}finally{Xe(!1)}}}async function Nn(t){if(!i||t.length===0)return;D(!0),de(new Map);const s=new Map;let r=!1;try{for(const c of t){const m=Ze[c]??null;try{const w=await Ln(i,"push",c,m==null?void 0:m.auth,(m==null?void 0:m.rememberOnHost)??!1,{targetHostId:o});s.set(c,{ok:!0,summary:w.summary}),m!=null&&m.rememberOnHost&&m.auth&&Ke($i=>$i.map(Ot=>Ot.name===c?{...Ot,credentialConfigured:!0}:Ot))}catch(w){if(r=!0,s.set(c,{ok:!1,summary:_(w,n("git.remoteFailed"))}),de(new Map(s)),Xn(w)){st(c);return}}}de(s),K(),r||(T({title:n("git.pushAllSuccess",{count:String(t.length)}),tone:"success"}),ue(!1))}finally{D(!1)}}async function Dt(t){if(i){if(t==="push"){W(!1),Cn();return}D(!0);try{const s=qn(ze),r=s?Ze[s]??null:null,c=await Ln(i,t,void 0,r==null?void 0:r.auth,(r==null?void 0:r.rememberOnHost)??!1,{targetHostId:o});T({title:c.summary,tone:"success"}),s&&(r!=null&&r.rememberOnHost)&&r.auth&&Ke(m=>m.map(w=>w.name===s?{...w,credentialConfigured:!0}:w)),W(!1),K()}catch(s){if(Xn(s)){st(qn(ze));return}T({title:_(s,n("git.remoteFailed")),tone:"error"})}finally{D(!1)}}}async function he(){if(i){D(!0);try{const t=await ts(i,{targetHostId:o});Ne(t.commitSubject??""),T({title:t.summary||n("git.undoLastCommitSuccess"),tone:"success"}),W(!1),K()}catch(t){T({title:_(t,n("git.undoLastCommitFailed")),tone:"error"})}finally{D(!1)}}}async function Ti(t){if(i){D(!0);try{const s=await ls(i,t,!1,{targetHostId:o});je(s),W(!1),K()}catch(s){T({title:_(s,n("git.branchFailed")),tone:"error"})}finally{D(!1)}}}async function Lt(t){const s=i==null?void 0:i.trim();if(!s)throw new Error(n("git.panelLoadFailed"));const r=et.current.get(t);if(r)return r;const c=await cs(s,t,{targetHostId:o});return et.current.set(t,c),c}async function Le(t){Z(null),Y(null),Ct(t),Ve(null);const s=et.current.get(t)??null;if(Me(s),Be(!s),s)return;const r=De.current+1;De.current=r;try{const c=await Lt(t);if(De.current!==r)return;Me(c)}catch(c){if(De.current!==r)return;Ve(_(c,n("git.commitDetailLoadFailed"))),Me(null)}finally{De.current===r&&Be(!1)}}function Mi(){Ct(null),Be(!1),Ve(null),Me(null)}async function _e(t){try{const s=await Lt(t);await V(s.versionLabel,n("git.copyCommitVersionSuccess"))}catch(s){T({title:_(s,n("git.commitDetailLoadFailed")),tone:"error"})}}function Fe(t){Z(null),Y(null),He(t),ce(null),Ee(!0)}function Hi(t){var r;const s=((r=P[0])==null?void 0:r.commitHash)===t.commitHash&&t.commitKind==="local";return[{id:`view-changes:${t.commitHash}`,label:n("git.viewCommitChanges"),onSelect:()=>void Le(t.commitHash)},{id:`copy-hash:${t.commitHash}`,label:n("git.copyCommitHash"),onSelect:()=>void V(t.commitHash,n("git.copyCommitHashSuccess"))},{id:`copy-message:${t.commitHash}`,label:n("git.copyCommitMessage"),onSelect:()=>void V(xe(t),n("git.copyCommitMessageSuccess"))},{id:`copy-version:${t.commitHash}`,label:n("git.copyCommitVersion"),onSelect:()=>void _e(t.commitHash)},{id:`explain:${t.commitHash}`,label:n("git.explainCommitAction"),onSelect:()=>Fe(t.commitHash)},...s?[{id:`undo:${t.commitHash}`,label:n("git.undoLastCommit"),disabled:C,onSelect:()=>void he()}]:[]]}async function vn(t){Z(null),Y(null),await is(Hi(t))}async function Ei(){var t,s;if(!(!i||!nn||!Re||ie)){Nt(!0);try{const r=await Lt(nn),c=await ss({workspaceId:i,provider:Re,content:bs(r),clientRequestId:((s=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:s.call(t))??`git-explain-${Date.now()}-${Math.random().toString(16).slice(2)}`,permissionMode:as()},{targetHostId:o}),m=c.session??await rs(c.sessionId,{targetHostId:o});x(m),v();const w=o&&f?{hostId:o,workspaceId:f.workspaceId}:f;S(m.workspaceId,w),j(ds(m.workspaceId,m.sessionId,w)),Ee(!1),He(null),ce(null),T({title:n("git.explainCommitStarted"),tone:"success"})}catch(r){T({title:_(r,n("git.explainCommitFailed")),tone:"error"})}finally{Nt(!1)}}}function at(t){Qt(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t])}const Ri=450;function Sn(t){const s=Date.now(),r=mn.current;return mn.current={filePath:t,timestamp:s},(r==null?void 0:r.filePath)===t&&s-r.timestamp<=Ri}async function rt(t,s){if(s.binary){T({title:n("git.binaryDiff"),tone:"info"});return}if(s.status==="A"||s.status==="?")Pe(null),we(t);else if(i)try{const r=await Ji(i,t,s.staged,{targetHostId:o});Pe(r.content),we(t)}catch{Pe(null),we(t)}}function ot(t){q(t),z(null),B(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t])}function Tn(t){const s=hn.current;if(!s||!Number.isFinite(t))return;const r=s.getBoundingClientRect(),c=r.height-ht;if(!Number.isFinite(r.top)||!Number.isFinite(r.height)||c<=0)return;const m=(t-r.top-ht/2)/c*100;if(!Number.isFinite(m))return;const w=Math.max(_n,Math.min(Gt,Math.round(m)));un(w)}function wi(t){t.preventDefault(),Tn(t.clientY),Ht(!0)}const ke=(d==null?void 0:d.changes)??[],Q=ke.filter(t=>qt(t,"staged")),ge=ke.filter(t=>qt(t,"unstaged")),Mn=zn(Q,"staged"),Hn=zn(ge,"unstaged"),lt=new Set(oi),ct=new Set(yt),fe=Kn(yt,ke,"staged"),pe=Kn(yt,ke,"unstaged"),_t=ke.length===0&&((d==null?void 0:d.snapshot.ahead)??0)>0,Pi=Q.length>0&&Ce.trim().length>0,ut=(I==null?void 0:I.currentBranch)??(d==null?void 0:d.snapshot.branch)??n("common.unknown"),dt=pt(ze,Je),Oe=rn==="github",Ai=Oe?n("git.remoteAuthDescriptionGithub"):n("git.remoteAuthDescription"),Di=Oe?n("git.remoteAuthGithubPatLabel"):n("shell.clonePasswordLabel"),Li=Oe?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder"),_i=Oe?n("git.remoteAuthGithubUsernamePlaceholder"):n("shell.cloneUsernamePlaceholder"),Ft=Number.isFinite(cn)?cn:$t,Fi=te?`minmax(120px, ${Ft}fr) ${ht}px minmax(140px, ${100-Ft}fr)`:`minmax(120px, 1fr) ${ht}px auto`,ki=vs(d);l.useEffect(()=>{ve==="staged"&&fe.length===0&&z(null),ve==="unstaged"&&pe.length===0&&z(null)},[ve,fe.length,pe.length]),l.useEffect(()=>{if(!O)return;const t=ge.length>0?"unstaged":Q.length>0?"staged":"history";oe(s=>s==="unstaged"&&ge.length>0||s==="staged"&&Q.length>0?s:t)},[O,Q.length,ge.length]),l.useEffect(()=>{Te&&(P.some(t=>t.commitHash===Te)||Y(null))},[P,Te]),l.useEffect(()=>{le&&(P.some(t=>t.commitHash===le)||Z(null))},[le,P]),l.useEffect(()=>{O&&Se!=="history"&&ne&&W(!1)},[O,ne,Se]),l.useLayoutEffect(()=>{if(O||!ne){St(null);return}function t(){const r=pn.current,c=xn.current;!r||!c||typeof window>"u"||St(Yn(r.getBoundingClientRect(),{width:c.getBoundingClientRect().width||Xt,height:c.getBoundingClientRect().height||c.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}t();const s=window.requestAnimationFrame(t);return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[C,I==null?void 0:I.local.length,ut,O,ne]);const ee=Te??le;l.useLayoutEffect(()=>{if(!ee){Tt(null);return}const t=ee;function s(){const c=Ae.current.get(t)??null,m=Et.current;!c||!m||typeof window>"u"||Tt(Yn(c.getBoundingClientRect(),{width:m.getBoundingClientRect().width||Xt,height:m.getBoundingClientRect().height||m.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}s();const r=window.requestAnimationFrame(s);return window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{window.cancelAnimationFrame(r),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[ee,P.length]),l.useEffect(()=>{if(!ee||typeof document>"u")return;const t=ee;function s(r){const c=r.target;if(!(c instanceof Node))return;const m=Ae.current.get(t)??null,w=Et.current;m!=null&&m.contains(c)||w!=null&&w.contains(c)||(Y(null),Z(null))}return document.addEventListener("pointerdown",s),()=>{document.removeEventListener("pointerdown",s)}},[ee]);async function V(t,s){var r;try{if(p.isDesktop&&(await p.bridge.writeClipboardText(t)).ok){T({title:s,tone:"success"});return}if(typeof navigator<"u"&&((r=navigator.clipboard)!=null&&r.writeText)){await navigator.clipboard.writeText(t),T({title:s,tone:"success"});return}if(xs(t)){T({title:s,tone:"success"});return}}catch{T({title:n("common.copyContentFailed"),tone:"error"})}}async function En(t,s){typeof window<"u"&&!window.confirm(n("git.discardConfirm",{path:s}))||await Pt(t)}function Rn(t){const s=(t==null?void 0:t.desktopFloating)===!0&&!O,r=s?{top:($==null?void 0:$.top)??k,left:($==null?void 0:$.left)??k,maxHeight:$==null?void 0:$.maxHeight,transformOrigin:($==null?void 0:$.transformOrigin)??"top right"}:void 0,c=e.jsxs("div",{ref:s?xn:void 0,className:"git-operations-menu","data-floating":s?"true":"false",style:r,children:[e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.currentBranch")}),e.jsx("strong",{className:"git-menu-branch",children:ut})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.remoteAuthStatusLabel")}),e.jsxs("div",{className:"git-menu-branch-list",children:[e.jsx("strong",{className:"git-menu-branch",children:n("git.remoteAuthManageHint")}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:C||gi,onClick:()=>void vi(),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:I==null?void 0:I.local.map(m=>e.jsx("button",{className:"git-menu-item",type:"button",disabled:C||m.current,onClick:()=>void Ti(m.name),children:e.jsx("span",{children:m.current?`${n("git.switchBranch")} ${m.name}`:`${n("git.switchBranchTo")} ${m.name}`})},m.name))})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:C,onClick:()=>{W(!1),jt(!0)},children:e.jsx("span",{children:n("git.viewAllVersions")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:C,onClick:()=>void Dt("fetch"),children:e.jsx("span",{children:n("git.fetch")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:C,onClick:()=>void Dt("pull"),children:e.jsx("span",{children:n("git.pull")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:C,onClick:()=>void Dt("push"),children:e.jsx("span",{children:n("git.push")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:C,onClick:()=>void he(),children:e.jsx("span",{children:n("git.undoLastCommit")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:C||Ue,onClick:()=>void wt({resetTreeScroll:!0}),children:e.jsx("span",{children:n("git.refresh")})})]})]});return s?typeof document>"u"?null:An.createPortal(c,document.body):c}function kt(t,s){if(s){Ae.current.set(t,s);return}Ae.current.delete(t)}function Oi(){var r;if(!ee||typeof document>"u")return null;const t=P.find(c=>c.commitHash===ee);if(!t)return null;const s=((r=P[0])==null?void 0:r.commitHash)===t.commitHash&&t.commitKind==="local";return An.createPortal(e.jsx("div",{ref:Et,className:"git-history-entry-menu","data-floating":"true",style:{top:(G==null?void 0:G.top)??k,left:(G==null?void 0:G.left)??k,maxHeight:G==null?void 0:G.maxHeight,transformOrigin:(G==null?void 0:G.transformOrigin)??"top right"},children:e.jsx(gs,{item:t,canUndo:s,actioning:C,onViewCommitChanges:c=>void Le(c),onCopyCommitHash:c=>void V(c,n("git.copyCommitHashSuccess")),onCopyCommitMessage:c=>void V(xe(c),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:c=>void _e(c),onExplainCommitChange:c=>void Fe(c),onUndoLastCommit:()=>void he()})}),document.body)}return d&&!ki?e.jsx("section",{className:["conversation-panel","surface-card","git-sidebar",a].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:e.jsxs("section",{className:"git-card git-scaffold-section git-disabled-state",children:[e.jsxs("div",{className:"git-disabled-copy",children:[e.jsx("h3",{children:n("git.uninitializedTitle")}),e.jsx("p",{children:n("git.uninitializedDescription")})]}),e.jsx("div",{className:"git-primary-actions",children:e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>void Ni(),disabled:C||Ue||!i,children:C?n("git.initInProgress"):n("git.initRepository")})})]})}):e.jsxs("section",{className:["conversation-panel","surface-card","git-sidebar",a].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:[e.jsxs("section",{className:"git-card git-scaffold-section",children:[e.jsxs("div",{className:"git-editor-row",children:[e.jsx("textarea",{ref:fn,rows:1,value:Ce,onChange:t=>Ne(ii(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 ji(),disabled:C||Ue,children:e.jsx(ws,{})})]}),e.jsxs("div",{className:"git-primary-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void wt({resetTreeScroll:!0}),disabled:C||Ue||!i,children:n("git.refreshNow")}),e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>{if(_t){Cn();return}Ci()},disabled:C||!_t&&!Pi,children:_t?n("git.pushNow"):n("git.commitNow")})]})]}),O?e.jsxs("div",{className:"git-mobile-sections",children:[e.jsx(Bt,{title:n("git.stagedChangesTitle"),count:Q.length,expanded:Se==="staged",onToggle:()=>oe("staged"),children:e.jsx(Un,{title:n("git.stagedChangesTitle"),nodes:Mn,collapsedTreePathSet:lt,onToggleTreePath:at,onToggleMobileSelection:ot,selectedMobilePathSet:ct,selectedTargets:fe,actioning:C,variant:"staged",swipeRowState:ln,onSwipeRowChange:Qe,onStageToggle:it,onDiscardWithConfirm:En,onClearSelectedTargets:()=>B(t=>t.filter(s=>!fe.includes(s))),onPreviewFile:rt})}),e.jsx(Bt,{title:n("git.changesTitle"),count:ge.length,expanded:Se==="unstaged",onToggle:()=>oe("unstaged"),children:e.jsx(Un,{title:n("git.changesTitle"),nodes:Hn,collapsedTreePathSet:lt,onToggleTreePath:at,onToggleMobileSelection:ot,selectedMobilePathSet:ct,selectedTargets:pe,actioning:C,variant:"unstaged",swipeRowState:ln,onSwipeRowChange:Qe,onStageToggle:it,onDiscardWithConfirm:En,onClearSelectedTargets:()=>B(t=>t.filter(s=>!pe.includes(s))),onPreviewFile:rt})}),e.jsxs(Bt,{title:n("git.recentVersionsTitle"),count:be,expanded:Se==="history",onToggle:()=>oe("history"),trailingContent:e.jsx("span",{className:"badge",children:ut}),headerAction:e.jsx("button",{className:"git-icon-button git-mobile-section-action",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),"aria-expanded":ne,onClick:()=>{oe("history"),W(t=>!t)},disabled:C,children:e.jsx(Ie,{})}),children:[ne?e.jsx("div",{className:"git-mobile-operations-shell",children:Rn()}):null,e.jsx(hs,{history:P,historyLoadingMore:ye,hasMore:!!X,actioning:C,openCommitHash:Te,onMenuTriggerRef:kt,onToggleMenu:t=>Y(s=>s===t?null:t),onViewCommitChanges:t=>void Le(t),onCopyCommitHash:t=>void V(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void V(xe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void _e(t),onExplainCommitChange:t=>void Fe(t),onUndoLastCommit:()=>void he(),onLoadMore:()=>void nt()})]})]}):e.jsxs("div",{ref:hn,className:"git-content-split",style:{gridTemplateRows:Fi},children:[e.jsx("section",{className:"git-card git-tree-panel",children:e.jsxs("div",{ref:gn,className:"git-tree-panel-body",children:[Q.length>0?e.jsx(In,{title:n("git.stagedChangesTitle"),count:Q.length,nodes:Mn,selectedPath:re,collapsedTreePathSet:lt,onToggleTreePath:at,onSelectFile:q,onPreviewFile:(t,s)=>{Sn(t)&&rt(t,s)},onToggleMobileSelection:ot,onStageToggle:it,onDiscard:Pt,actioning:C,variant:"staged",isMobileViewport:O,selectedMobilePathSet:ct,selectedTargets:fe,mobileActionMenuOpen:ve==="staged",onToggleMobileActionMenu:()=>z(t=>t==="staged"?null:"staged"),onClearSelectedTargets:()=>B(t=>t.filter(s=>!fe.includes(s)))}):null,e.jsx(In,{title:n("git.changesTitle"),count:ge.length,nodes:Hn,selectedPath:re,collapsedTreePathSet:lt,onToggleTreePath:at,onSelectFile:q,onPreviewFile:(t,s)=>{Sn(t)&&rt(t,s)},onToggleMobileSelection:ot,onStageToggle:it,onDiscard:Pt,actioning:C,variant:"unstaged",isMobileViewport:O,selectedMobilePathSet:ct,selectedTargets:pe,mobileActionMenuOpen:ve==="unstaged",onToggleMobileActionMenu:()=>z(t=>t==="unstaged"?null:"unstaged"),onClearSelectedTargets:()=>B(t=>t.filter(s=>!pe.includes(s)))})]})}),e.jsx("button",{className:"git-panel-divider",type:"button",role:"separator","aria-label":n("git.resizePanels"),"aria-orientation":"horizontal","aria-valuemin":_n,"aria-valuemax":Gt,"aria-valuenow":te?Ft:Gt,"data-dragging":Mt,onPointerDown:wi,children:e.jsx("span",{className:"git-panel-divider-handle","aria-hidden":"true"})}),e.jsxs("section",{className:"git-card git-history-section",children:[e.jsxs("div",{className:"git-history-topbar",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":te,"aria-label":te?n("git.collapseRecentVersions"):n("git.expandRecentVersions"),onClick:()=>en(t=>!t),children:[e.jsxs("span",{className:"git-section-toggle-main",children:[e.jsx(xt,{expanded:te}),e.jsx("span",{children:n("git.recentVersionsTitle")})]}),e.jsx("span",{className:"workbench-section-counter",children:be})]}),e.jsxs("div",{className:"git-history-actions",children:[e.jsx("span",{className:"badge",children:ut}),e.jsx("button",{className:"git-icon-button",type:"button",ref:pn,"aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:()=>W(t=>!t),disabled:C,children:e.jsx(Ie,{})}),ne?Rn({desktopFloating:!0}):null]})]}),te?e.jsx(Vn,{history:P,historyLoadingMore:ye,hasMore:!!X,actioning:C,openCommitHash:le,useNativeContextMenu:jn,onMenuTriggerRef:kt,onScroll:yi,onToggleMenu:t=>{if(jn){const s=P.find(r=>r.commitHash===t);s&&vn(s);return}Z(s=>s===t?null:t)},onOpenContextMenu:t=>void vn(t),onViewCommitChanges:t=>void Le(t),onCopyCommitHash:t=>void V(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void V(xe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void _e(t),onExplainCommitChange:t=>void Fe(t),onUndoLastCommit:()=>void he(),onLoadMore:()=>void nt()}):null]})]}),e.jsxs($e,{open:hi,title:We==="push"?n("git.selectRemoteTitle"):n("git.remoteAuthManageTitle"),description:We==="push"?n("git.selectRemoteDesc"):n("git.remoteAuthManageDescription"),onClose:()=>{C||ue(!1)},children:[e.jsx("div",{className:"git-remote-select-list",children:ze.map(t=>{const s=qe.has(t.name),r=fi.get(t.name),c=Es(t,Ze[t.name]??null);return e.jsxs("div",{className:"git-remote-item",children:[We==="push"?e.jsxs("label",{className:"git-remote-item-selector",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:C,onChange:()=>{Ye(m=>{const w=new Set(m);return w.has(t.name)?w.delete(t.name):w.add(t.name),w})}}),e.jsxs("span",{className:"git-remote-item-body",children:[e.jsx("span",{className:"git-remote-name",children:t.name}),e.jsx("span",{className:"git-remote-url",children:t.pushUrl}),r&&e.jsx("span",{className:`git-remote-result ${r.ok?"ok":"err"}`,children:r.summary})]})]}):e.jsx("div",{className:"git-remote-item-selector git-remote-item-selector-static",children:e.jsxs("span",{className:"git-remote-item-body",children:[e.jsx("span",{className:"git-remote-name",children:t.name}),e.jsx("span",{className:"git-remote-url",children:t.pushUrl}),r&&e.jsx("span",{className:`git-remote-result ${r.ok?"ok":"err"}`,children:r.summary})]})}),e.jsxs("div",{className:"git-remote-item-meta",children:[e.jsx("span",{className:`git-remote-credential-badge ${c.kind}`,children:c.label}),e.jsx("button",{className:"secondary-button git-remote-inline-action",type:"button",disabled:C,onClick:()=>void st(t.name),children:n("git.remoteAuthAction")})]})]},t.name)})}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:C,onClick:()=>ue(!1),children:n("common.close")}),We==="push"?e.jsx("button",{className:"primary-button",type:"button",disabled:C||qe.size===0,onClick:()=>void Nn(Array.from(qe)),children:C?n("git.pushing"):n("git.pushSelected",{count:String(qe.size)})}):null]})]}),e.jsxs($e,{open:pi,title:n("git.remoteAuthTitle"),description:Ai,onClose:()=>{C||me(!1)},children:[dt?e.jsxs("div",{className:"git-remote-auth-target",children:[e.jsx("strong",{children:dt.name}),e.jsx("span",{children:dt.pushUrl||dt.fetchUrl})]}):null,e.jsxs("div",{className:"workbench-clone-form",children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneAuthModeLabel")}),e.jsxs("select",{value:L.authMode,disabled:C,onChange:t=>J(s=>({...s,authMode:t.target.value})),children:[e.jsx("option",{value:"none",children:n("shell.cloneAuthModeNone")}),e.jsx("option",{value:"basic",children:n("shell.cloneAuthModeBasic")}),e.jsx("option",{value:"token",children:n("shell.cloneAuthModeToken")})]})]}),L.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:L.username,placeholder:_i,autoComplete:"username",onChange:t=>J(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:Di}),e.jsx("input",{type:"password",value:L.password,placeholder:Li,autoComplete:"current-password",onChange:t=>J(s=>({...s,password:t.target.value}))})]})]}):null,L.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:L.username,placeholder:n("shell.cloneTokenUsernamePlaceholder"),autoComplete:"username",onChange:t=>J(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneTokenLabel")}),e.jsx("input",{type:"password",value:L.token,placeholder:n("shell.cloneTokenPlaceholder"),autoComplete:"current-password",onChange:t=>J(s=>({...s,token:t.target.value}))})]})]}):null,Oe?e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthGithubPatHint")}):null,L.authMode!=="none"?e.jsxs("label",{className:"settings-checkbox git-remote-auth-remember-toggle",children:[e.jsx("input",{type:"checkbox",checked:L.rememberOnHost,onChange:t=>J(s=>({...s,rememberOnHost:t.target.checked}))}),e.jsx("span",{children:n("git.remoteAuthRemember")})]}):null,e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthSessionHint")})]}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:C,onClick:()=>me(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:C,onClick:Si,children:n("git.remoteAuthSave")})]})]}),e.jsx($e,{open:ci,title:n("git.viewAllVersions"),description:n("git.viewAllVersionsDescription",{count:String(be)}),onClose:()=>jt(!1),children:e.jsx(Vn,{history:P,historyLoadingMore:ye,hasMore:!!X,actioning:C,openCommitHash:le,className:"git-history-modal-list",onMenuTriggerRef:kt,onToggleMenu:t=>Z(s=>s===t?null:t),onViewCommitChanges:t=>void Le(t),onCopyCommitHash:t=>void V(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void V(xe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void _e(t),onExplainCommitChange:t=>void Fe(t),onUndoLastCommit:()=>void he(),onLoadMore:()=>void nt()})}),e.jsx($e,{open:ui!==null,className:"git-commit-detail-modal",title:(F==null?void 0:F.subject)||n("git.commitDetailTitle"),description:F?n("git.commitDetailDescription",{hash:F.shortHash}):n("git.commitDetailLoading"),onClose:Mi,children:di?e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailLoading")})}):tn?e.jsx("div",{className:"git-commit-detail-state is-error",children:e.jsx("p",{children:tn})}):F?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:F.versionLabel})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitHashLabel")}),e.jsx("strong",{children:F.commitHash})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitAuthorLabel")}),e.jsx("strong",{children:F.authorName})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitTimeLabel")}),e.jsx("strong",{children:js(F.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:xe(F)})]}),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:F.changedFiles.length})]}),e.jsx("div",{className:"git-commit-detail-file-list",children:F.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")}),F.diffTruncated?e.jsx("span",{className:"git-commit-detail-truncated",children:n("git.diffTruncated")}):null]}),e.jsx("pre",{className:"git-commit-detail-diff",children:F.diffContent||n("git.emptyDiff")})]})]}):e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailEmpty")})})}),e.jsx($e,{open:mi,className:"git-explain-provider-modal",title:n("git.explainCommitTitle"),description:n("git.explainCommitDescription"),onClose:()=>{ie||(Ee(!1),He(null),ce(null))},children:e.jsxs("div",{className:"git-explain-provider-shell",children:[e.jsx(Wi,{workspaceId:i,selectedProvider:Re,pendingProvider:ie?Re:null,disabled:ie,onSelect:t=>ce(t)}),e.jsxs("div",{className:"git-explain-provider-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:ie,onClick:()=>{Ee(!1),He(null),ce(null)},children:n("common.cancel")}),e.jsx("button",{type:"button",className:"primary-button",disabled:!Re||ie,onClick:()=>void Ei(),children:ie?n("conversation.sendingState"):n("git.startExplainCommit")})]})]})}),e.jsx(zi,{workspaceId:i,filePath:dn,open:dn!==null,onClose:()=>{we(null),Pe(null)},onSaved:async()=>{await wt({resetTreeScroll:!0})},diffContent:xi}),Oi()]})}function In({title:a,count:i,nodes:u,selectedPath:h,collapsedTreePathSet:g,onToggleTreePath:j,onSelectFile:p,onPreviewFile:y,onToggleMobileSelection:b,onStageToggle:N,onDiscard:M,actioning:v,variant:S,isMobileViewport:x,selectedMobilePathSet:o,selectedTargets:f,mobileActionMenuOpen:d,onToggleMobileActionMenu:H,onClearSelectedTargets:R}){const E=Jn(),P=Jt(u),A=S==="staged"?n("git.unstageAll"):n("git.stageAll");return e.jsxs("section",{className:"git-tree-group","data-variant":S,children:[e.jsxs("div",{className:"git-section-header git-tree-group-header",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"git-tree-group-actions",children:[e.jsx("span",{className:"workbench-section-counter",children:i}),!x&&P.length>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":A,title:A,onClick:()=>void N(P,S==="staged"),disabled:v,children:e.jsx(Yt,{staged:S==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":n("git.discardAll"),title:n("git.discardAll"),onClick:()=>void M(P),disabled:v,children:e.jsx(Zt,{})}):null]}):null,x&&f.length>0?e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:H,disabled:v,children:e.jsx(Ie,{})}):null]}),x&&d?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:f.length})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void N(f,S==="staged"),children:e.jsx("span",{children:S==="staged"?n("git.unstage"):n("git.stage")})}),S==="unstaged"?e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void M(f),children:e.jsx("span",{children:n("git.discard")})}):null,e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:R,children:e.jsx("span",{children:n("git.clearSelection")})})]})]}):null]}),e.jsx("div",{ref:E,className:"git-tree-shell",role:"tree","aria-label":a,"data-scrollbar-autohide":"true",children:u.length?ei({nodes:u,depth:0,collapsedTreePathSet:g,selectedPath:h,onToggleTreePath:j,onSelectFile:p,onPreviewFile:y,onToggleMobileSelection:b,onStageToggle:N,onDiscard:M,actioning:v,variant:S,isMobileViewport:x,selectedMobilePathSet:o}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Bt({title:a,count:i,expanded:u,onToggle:h,trailingContent:g,headerAction:j,children:p}){return e.jsxs("section",{className:"git-mobile-section","data-expanded":u,children:[e.jsxs("div",{className:"git-mobile-section-header",children:[e.jsxs("button",{className:"git-mobile-section-toggle",type:"button","aria-expanded":u,onClick:h,children:[e.jsxs("span",{className:"git-mobile-section-toggle-main",children:[e.jsx(xt,{expanded:u}),e.jsx("h3",{children:a})]}),e.jsxs("span",{className:"git-mobile-section-toggle-meta",children:[g,e.jsx("span",{className:"workbench-section-counter",children:i})]})]}),j?e.jsx("div",{className:"git-mobile-section-header-action",children:j}):null]}),u?e.jsx("div",{className:"git-mobile-section-body",children:p}):null]})}function Un({title:a,nodes:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,selectedTargets:p,actioning:y,variant:b,swipeRowState:N,onSwipeRowChange:M,onStageToggle:v,onDiscardWithConfirm:S,onClearSelectedTargets:x,onPreviewFile:o}){return e.jsxs("div",{className:"git-mobile-record-shell",children:[p.length>0?e.jsxs("div",{className:"git-mobile-selection-toolbar",children:[e.jsxs("span",{className:"git-mobile-selection-count",children:[n("git.selectedFiles")," ",p.length]}),e.jsxs("div",{className:"git-mobile-selection-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:y,onClick:()=>void v(p,b==="staged"),children:b==="staged"?n("git.unstage"):n("git.stage")}),b==="unstaged"?e.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:y,onClick:()=>void S(p,`${p.length}`),children:n("git.discard")}):null,e.jsx("button",{type:"button",className:"secondary-button",disabled:y,onClick:x,children:n("git.clearSelection")})]})]}):null,e.jsx("div",{className:"git-mobile-record-list",role:"tree","aria-label":a,children:i.length?Qn({nodes:i,depth:0,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:y,variant:b,swipeRowState:N,onSwipeRowChange:M,onStageToggle:v,onDiscardWithConfirm:S,onPreviewFile:o}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Qn({nodes:a,depth:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:p,variant:y,swipeRowState:b,onSwipeRowChange:N,onStageToggle:M,onDiscardWithConfirm:v,onPreviewFile:S}){return a.map(x=>{if(x.kind==="directory"){const d=!u.has(x.path),H=Jt(x.children),R=`directory:${x.path}`;return e.jsxs("div",{className:"git-mobile-record-branch",children:[e.jsx(Bn,{rowKey:R,openState:(b==null?void 0:b.path)===R?b.direction:null,onOpenStateChange:E=>N(E?{path:R,direction:E}:null),trailingActions:H.length>0?[{label:y==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M(H,y==="staged")},...y==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void v(H,x.path)}]:[]]:null,children:e.jsxs("button",{className:"git-mobile-record git-mobile-record-directory",type:"button",style:{paddingInlineStart:`${$n+i*Gn}px`},onClick:()=>h(x.path),children:[e.jsxs("span",{className:"git-mobile-record-leading",children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":d,children:e.jsx(xt,{expanded:d})}),e.jsx("span",{className:"git-mobile-record-title",children:x.name})]}),e.jsx("span",{className:"git-mobile-record-meta",children:H.length})]})}),d?e.jsx("div",{className:"git-mobile-record-children",role:"group",children:Qn({nodes:x.children,depth:i+1,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:p,variant:y,swipeRowState:b,onSwipeRowChange:N,onStageToggle:M,onDiscardWithConfirm:v,onPreviewFile:S})}):null]},R)}const o=`file:${x.path}`,f=j.has(x.path);return e.jsx(Bn,{rowKey:o,openState:(b==null?void 0:b.path)===o?b.direction:null,onOpenStateChange:d=>N(d?{path:o,direction:d}:null),trailingActions:[{label:n("git.preview"),tone:"neutral",onPress:()=>S(x.change.path,x.change)},{label:y==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M([x.change.path],y==="staged")},...y==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void v([x.change.path],x.path)}]:[]],children:e.jsxs("div",{className:"git-mobile-record git-mobile-record-file","data-active":f,style:{paddingInlineStart:`${$n+i*Gn}px`},children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:f,"aria-label":`${n("git.selectFile")} ${x.name}`,onChange:()=>g(x.change.path)}),e.jsxs("button",{className:"git-mobile-record-file-main",type:"button",onClick:()=>g(x.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Kt(x.name),"aria-hidden":"true",children:zt(x.name)}),e.jsxs("span",{className:"git-mobile-record-copy",children:[e.jsx("span",{className:"git-mobile-record-title",children:x.name}),e.jsx("span",{className:"git-mobile-record-path",children:x.path})]}),e.jsx("span",{className:"git-status-badge","data-status":x.status,children:x.status})]})]})},o)})}function Bn({rowKey:a,openState:i,onOpenStateChange:u,trailingActions:h,children:g}){const j=us(),p=l.useRef(null),[y,b]=l.useState(0),N=((h==null?void 0:h.length)??0)*It;l.useEffect(()=>{i||b(0)},[i,a]);const M=y!==0?y:i==="trailing"?-N:0;function v(f){var d,H;f.button===0&&(p.current={pointerId:f.pointerId,startX:f.clientX},(H=(d=f.currentTarget).setPointerCapture)==null||H.call(d,f.pointerId))}function S(f){const d=p.current;if(!d||d.pointerId!==f.pointerId)return;const H=N>0?N+10:0,R=Math.max(-H,Math.min(0,f.clientX-d.startX));b(R)}function x(f){var H,R;const d=p.current;if(!(!d||d.pointerId!==f.pointerId)){if((R=(H=f.currentTarget).releasePointerCapture)==null||R.call(H,f.pointerId),p.current=null,y<=-44&&(h!=null&&h.length)){j.trigger("gesture"),u("trailing"),b(0);return}u(null),b(0)}}function o(f){var H,R;const d=p.current;!d||d.pointerId!==f.pointerId||((R=(H=f.currentTarget).releasePointerCapture)==null||R.call(H,f.pointerId),p.current=null,b(0))}return e.jsxs("div",{className:"git-mobile-swipe-row","data-open-state":i??"closed","data-dragging":y!==0,children:[h==null?void 0:h.map((f,d)=>e.jsx("button",{type:"button",className:"git-mobile-swipe-action trailing","data-tone":f.tone,style:{right:d*It,width:It},onClick:()=>{j.trigger(f.tone==="danger"?"warning":"action"),u(null),f.onPress()},children:f.label},`trailing-${d}`)),e.jsx("div",{className:"git-mobile-swipe-content",style:{transform:`translateX(${M}px)`},onPointerDown:v,onPointerMove:S,onPointerUp:x,onPointerCancel:o,children:g})]})}function hs({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:g,onMenuTriggerRef:j,onToggleMenu:p,onViewCommitChanges:y,onCopyCommitHash:b,onCopyCommitMessage:N,onCopyCommitVersion:M,onExplainCommitChange:v,onUndoLastCommit:S,onLoadMore:x}){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:si(o.commitKind)})]}),o.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:o.refs.map(f=>e.jsx("span",{className:"git-history-ref-pill","data-kind":f.kind,"data-remote-index":String(ai(f.remoteName)),children:f.name},`${o.commitHash}:${f.kind}:${f.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:ri(o.authoredAt)})]})]}),e.jsx("button",{type:"button",className:"git-icon-button",ref:f=>j(o.commitHash,f),"aria-label":n("git.historyItemMenu"),onClick:()=>p(o.commitHash),children:e.jsx(Ie,{})})]})},o.commitHash)),u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:x,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"git-tree-status",children:n("git.noHistory")})}function Vn({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:g,className:j,useNativeContextMenu:p=!1,onMenuTriggerRef:y,onScroll:b,onToggleMenu:N,onOpenContextMenu:M,onViewCommitChanges:v,onCopyCommitHash:S,onCopyCommitMessage:x,onCopyCommitVersion:o,onExplainCommitChange:f,onUndoLastCommit:d,onLoadMore:H}){const R=Jn();return a.length?e.jsxs("div",{ref:R,className:["git-history-list",j].filter(Boolean).join(" "),onScroll:b,"data-scrollbar-autohide":"true",children:[a.map(E=>{const P=g===E.commitHash;return e.jsxs("article",{className:"git-history-entry","data-kind":E.commitKind,"data-menu-open":P?"true":"false",onContextMenu:A=>{!p||!M||(A.preventDefault(),A.stopPropagation(),M(E))},children:[e.jsx("span",{className:"git-history-marker","data-kind":E.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:E.subject,children:E.subject}),e.jsxs("div",{className:"git-history-title-actions",children:[e.jsx("span",{className:"git-history-kind-badge","data-kind":E.commitKind,children:si(E.commitKind)}),p?null:e.jsx("button",{type:"button",className:"git-icon-button git-history-more",ref:A=>y(E.commitHash,A),"aria-label":n("git.historyItemMenu"),onClick:()=>{N(E.commitHash)},children:e.jsx(Ie,{})})]})]}),E.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:E.refs.map(A=>e.jsx("span",{className:"git-history-ref-pill","data-kind":A.kind,"data-remote-index":String(ai(A.remoteName)),children:A.name},`${E.commitHash}:${A.kind}:${A.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:E.commitHash.slice(0,8)}),e.jsx("span",{children:E.authorName}),e.jsx("time",{dateTime:E.authoredAt,children:ri(E.authoredAt)})]})]})]},E.commitHash)}),i?e.jsxs("p",{className:"git-history-loading",children:[n("git.refreshNow"),"..."]}):null,u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:H,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"status-text",children:n("git.noHistory")})}function gs({item:a,canUndo:i,actioning:u,onViewCommitChanges:h,onCopyCommitHash:g,onCopyCommitMessage:j,onCopyCommitVersion:p,onExplainCommitChange:y,onUndoLastCommit:b}){return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>h(a.commitHash),children:e.jsx("span",{children:n("git.viewCommitChanges")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>g(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitHash")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>j(a),children:e.jsx("span",{children:n("git.copyCommitMessage")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>p(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitVersion")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>y(a.commitHash),children:e.jsx("span",{children:n("git.explainCommitAction")})}),i?e.jsx("button",{type:"button",className:"git-menu-item",disabled:u,onClick:b,children:e.jsx("span",{children:n("git.undoLastCommit")})}):null]})}function ei({nodes:a,depth:i,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:g,onSelectFile:j,onPreviewFile:p,onToggleMobileSelection:y,onStageToggle:b,onDiscard:N,actioning:M,variant:v,isMobileViewport:S,selectedMobilePathSet:x}){return a.map(o=>{if(o.kind==="directory"){const H=!u.has(o.path),R=Jt(o.children),E=`${v==="staged"?n("git.unstage"):n("git.stage")} ${o.path}`,P=`${n("git.discard")} ${o.path}`;return e.jsxs("div",{className:"git-tree-node",children:[e.jsxs("div",{className:"git-tree-row",role:"treeitem","aria-expanded":H,children:[e.jsxs("button",{className:"git-tree-trigger",type:"button",style:{paddingInlineStart:`${6+i*8}px`},onClick:()=>g(o.path),children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":H,children:e.jsx(xt,{expanded:H})}),e.jsx("span",{className:"git-tree-label git-tree-label-directory",children:o.name})]}),!S&&R.length>0?e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":E,title:E,onClick:()=>void b(R,v==="staged"),disabled:M,children:e.jsx(Yt,{staged:v==="staged"})}),v==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":P,title:P,onClick:()=>void N(R),disabled:M,children:e.jsx(Zt,{})}):null]}):null]}),H?e.jsx("div",{className:"git-tree-children",role:"group",children:ei({nodes:o.children,depth:i+1,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:g,onSelectFile:j,onPreviewFile:p,onToggleMobileSelection:y,onStageToggle:b,onDiscard:N,actioning:M,variant:v,isMobileViewport:S,selectedMobilePathSet:x})}):null]},`directory:${o.path}`)}const f=x.has(o.path),d=S?f:h===o.path;return S?e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":d,"data-mobile":"true",children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:f,"aria-label":`${n("git.selectFile")} ${o.name}`,onChange:()=>y(o.change.path)}),e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":d,"data-mobile":"true",style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>y(o.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Kt(o.name),"aria-hidden":"true",children:zt(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":d,children:[e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":d,style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>{j(o.change.path),p&&p(o.change.path,o.change)},children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Kt(o.name),"aria-hidden":"true",children:zt(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(Yt,{staged:o.variant==="staged"})}),v==="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(Zt,{})}):null]})]},`file:${o.path}`)})}function Wn(a,i){return{kind:"directory",name:a,path:i,children:new Map}}function zn(a,i){const u=Wn("","");for(const h of a){const g=h.path.replace(/\\/g,"/"),j=g.split("/").filter(Boolean);let p=u;j.forEach((y,b)=>{const N=j.slice(0,b+1).join("/");if(b===j.length-1){p.children.set(`file:${N}`,{kind:"file",name:y,path:g,change:h,status:fs(h,i),variant:i});return}const M=`directory:${N}`,v=p.children.get(M);if(v&&v.kind==="directory"){p=v;return}const S=Wn(y,N);p.children.set(M,S),p=S})}return ni(ti([...u.children.values()]))}function ti(a){return[...a].sort((i,u)=>i.kind!==u.kind?i.kind==="directory"?-1:1:i.name.localeCompare(u.name,"zh-CN")).map(i=>i.kind==="directory"?{kind:"directory",name:i.name,path:i.path,children:ti([...i.children.values()])}:i)}function ni(a){return a.map(i=>{var p;if(i.kind!=="directory")return i;const u=ni(i.children);let h=i.name,g=i.path,j=u;for(;j.length===1&&((p=j[0])==null?void 0:p.kind)==="directory";){const y=j[0];h=`${h}/${y.name}`,g=y.path,j=y.children}return{kind:"directory",name:h,path:g,children:j}})}function Kn(a,i,u){const h=new Set(a);return i.filter(g=>qt(g,u)&&h.has(g.path)).map(g=>g.path)}function Jt(a){const i=[],u=new Set;function h(g){if(g.kind==="file"){u.has(g.path)||(u.add(g.path),i.push(g.path));return}g.children.forEach(h)}return a.forEach(h),i}function qt(a,i){return i==="staged"?!!a.stagedStatus:!!a.worktreeStatus}function fs(a,i){return i==="staged"?a.stagedStatus??a.status:a.worktreeStatus??a.status}function ps(a){return{subject:ii(a).trim(),body:null,footer:null,source:"manual"}}function ii(a){return a.replace(/[\r\n]+/g," ")}function xs(a){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const i=document.createElement("textarea");i.value=a,i.setAttribute("readonly","true"),i.style.position="fixed",i.style.top="-9999px",i.style.left="-9999px",i.style.opacity="0",document.body.appendChild(i),i.focus(),i.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(i)}}function xe(a){const i=a.subject.trim(),u=a.body.trim();return u?`${i}
2
2
 
3
3
  ${u}`:i}function bs(a){const i=a.changedFiles.map(g=>`- [${g.status}] ${g.path}${g.oldPath?` (from ${g.oldPath})`:""}`).join(`
4
4
  `),u=a.diffContent.length>Ut?a.diffContent.slice(0,Ut):a.diffContent,h=a.diffContent.length>Ut||a.diffTruncated?`
@@ -1 +1 @@
1
- import{b as c,j as e,t as n}from"./index-BilHJjYU.js";import{M as k,s as j,t as f,u as g,v as M}from"./workbench-navigation-ED0157V-.js";import{M as v}from"./MobileSheet-Co-qPMBD.js";import{I as S,S as L}from"./WorkbenchLayout-Bo2BbMY6.js";function H({open:o,workspaces:l,workspaceOptions:t,initialWorkspaceId:d,onClose:b,onSelect:x}){const[a,u]=c.useState(""),[h,m]=c.useState(!1),p=S(),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&&(u(N(i,d)),m(!1))},[d,o,w]),!o)return null;const r=i.find(s=>s.workspace.id===a)??i[0]??null;return e.jsxs(v,{open:o,title:n("shell.createSessionModalTitle"),description:n("shell.createSessionModalDescription"),kind:"form",height:"three-quarter",className:"mobile-create-session-sheet",cardClassName:"mobile-create-session-sheet-card",bodyClassName:"mobile-feature-form mobile-workspace-home-form mobile-create-session-form",showHandle:!0,onClose:b,children:[e.jsx(k,{className:"mobile-create-session-section",tone:"accent",children:e.jsxs(j,{label:n("shell.createSessionWorkspaceLabel"),children:[e.jsxs("button",{type:"button",className:"mobile-create-session-workspace-trigger","aria-label":`${n("shell.createSessionWorkspaceLabel")} ${(r==null?void 0:r.label)??""}`.trim(),"aria-expanded":h?"true":"false",disabled:i.length===0,onClick:()=>{p.trigger("selection"),m(s=>!s)},children:[e.jsxs("span",{className:"mobile-create-session-workspace-copy",children:[e.jsx("strong",{children:(r==null?void 0:r.label)??n("common.unknown")}),e.jsx("span",{children:(r==null?void 0:r.subtitle)??n("common.unknown")})]}),e.jsx(C,{expanded:h})]}),h?e.jsx(f,{className:"mobile-workspace-home-group mobile-create-session-workspace-list",role:"list",children:i.map(s=>e.jsx(g,{as:"button",className:"mobile-workspace-home-row mobile-create-session-workspace-row","data-worktree-kind":s.kind,"data-worktree-depth":s.depth,selected:s.workspace.id===a,trailing:e.jsx("span",{className:"mobile-workspace-home-row-trailing",children:s.workspace.id===a?e.jsx(y,{}):e.jsx(I,{})}),style:{"--mobile-workspace-tree-depth":String(s.depth)},onClick:()=>{s.workspace.id!==a&&p.trigger("selection"),u(s.workspace.id),m(!1)},children:e.jsxs("span",{className:"mobile-create-session-workspace-option-copy",children:[e.jsxs("strong",{children:[s.kind==="worktree"?e.jsx(M,{className:"mobile-workspace-home-worktree-badge",children:n("shell.mobileWorktreeBadge")}):null,s.label]}),e.jsx("span",{children:s.subtitle})]})},s.workspace.id))}):null]})}),e.jsx(k,{className:"mobile-create-session-provider-block",heading:n("shell.createSessionProviderLabel"),children:e.jsx(L,{disabled:!a,workspaceId:a||null,onSelect:s=>{a&&x(a,s)}})})]})}function N(o,l){var t;return l&&o.some(d=>d.workspace.id===l)?l:((t=o[0])==null?void 0:t.workspace.id)??""}function C({expanded:o}){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",className:"mobile-create-session-workspace-chevron","data-expanded":o?"true":"false",children:e.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function I(){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 y(){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{H as M};
1
+ import{b as c,j as e,t as n}from"./index-CILPuSCp.js";import{M as k,s as j,t as f,u as g,v as M}from"./workbench-navigation-hwM28xIb.js";import{M as v}from"./MobileSheet-DPYtp5Ze.js";import{I as S,S as L}from"./WorkbenchLayout-yGxGKcG1.js";function H({open:o,workspaces:l,workspaceOptions:t,initialWorkspaceId:d,onClose:b,onSelect:x}){const[a,u]=c.useState(""),[h,m]=c.useState(!1),p=S(),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&&(u(N(i,d)),m(!1))},[d,o,w]),!o)return null;const r=i.find(s=>s.workspace.id===a)??i[0]??null;return e.jsxs(v,{open:o,title:n("shell.createSessionModalTitle"),description:n("shell.createSessionModalDescription"),kind:"form",height:"three-quarter",className:"mobile-create-session-sheet",cardClassName:"mobile-create-session-sheet-card",bodyClassName:"mobile-feature-form mobile-workspace-home-form mobile-create-session-form",showHandle:!0,onClose:b,children:[e.jsx(k,{className:"mobile-create-session-section",tone:"accent",children:e.jsxs(j,{label:n("shell.createSessionWorkspaceLabel"),children:[e.jsxs("button",{type:"button",className:"mobile-create-session-workspace-trigger","aria-label":`${n("shell.createSessionWorkspaceLabel")} ${(r==null?void 0:r.label)??""}`.trim(),"aria-expanded":h?"true":"false",disabled:i.length===0,onClick:()=>{p.trigger("selection"),m(s=>!s)},children:[e.jsxs("span",{className:"mobile-create-session-workspace-copy",children:[e.jsx("strong",{children:(r==null?void 0:r.label)??n("common.unknown")}),e.jsx("span",{children:(r==null?void 0:r.subtitle)??n("common.unknown")})]}),e.jsx(C,{expanded:h})]}),h?e.jsx(f,{className:"mobile-workspace-home-group mobile-create-session-workspace-list",role:"list",children:i.map(s=>e.jsx(g,{as:"button",className:"mobile-workspace-home-row mobile-create-session-workspace-row","data-worktree-kind":s.kind,"data-worktree-depth":s.depth,selected:s.workspace.id===a,trailing:e.jsx("span",{className:"mobile-workspace-home-row-trailing",children:s.workspace.id===a?e.jsx(y,{}):e.jsx(I,{})}),style:{"--mobile-workspace-tree-depth":String(s.depth)},onClick:()=>{s.workspace.id!==a&&p.trigger("selection"),u(s.workspace.id),m(!1)},children:e.jsxs("span",{className:"mobile-create-session-workspace-option-copy",children:[e.jsxs("strong",{children:[s.kind==="worktree"?e.jsx(M,{className:"mobile-workspace-home-worktree-badge",children:n("shell.mobileWorktreeBadge")}):null,s.label]}),e.jsx("span",{children:s.subtitle})]})},s.workspace.id))}):null]})}),e.jsx(k,{className:"mobile-create-session-provider-block",heading:n("shell.createSessionProviderLabel"),children:e.jsx(L,{disabled:!a,workspaceId:a||null,onSelect:s=>{a&&x(a,s)}})})]})}function N(o,l){var t;return l&&o.some(d=>d.workspace.id===l)?l:((t=o[0])==null?void 0:t.workspace.id)??""}function C({expanded:o}){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",className:"mobile-create-session-workspace-chevron","data-expanded":o?"true":"false",children:e.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function I(){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 y(){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{H as M};
@@ -1 +1 @@
1
- import{b as n,j as e,t as g}from"./index-BilHJjYU.js";import{g as $}from"./App-CHsm-VrM.js";function E({open:h,title:m,description:o,height:b="auto",kind:u="form",dismissible:t=!0,closeOnBackdrop:p=!0,backdropVisible:x=!0,showHandle:j=!1,showCancelButton:v=!0,cancelLabel:f,className:a,cardClassName:l,bodyClassName:s,footer:i,onClose:r,children:k}){const d=n.useId(),c=n.useId(),y=t&&p;return!h||typeof document>"u"?null:$.createPortal(e.jsx("div",{className:"ios-action-sheet-overlay mobile-sheet-overlay","data-backdrop-visible":x?"true":"false",role:"presentation",onClick:()=>{y&&r()},children:e.jsxs("div",{className:`mobile-workspace-home-sheet mobile-sheet${a?` ${a}`:""}`,"data-height":b,"data-kind":u,role:"dialog","aria-modal":"true","aria-labelledby":d,"aria-describedby":o?c:void 0,onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:`mobile-workspace-home-sheet-card mobile-sheet-card${l?` ${l}`:""}`,children:[j?e.jsx("div",{className:"mobile-sheet-handle","aria-hidden":"true"}):null,e.jsx("div",{className:"mobile-workspace-home-sheet-header mobile-sheet-header",children:e.jsxs("div",{className:"mobile-sheet-title-wrap",children:[e.jsx("strong",{id:d,children:m}),o?e.jsx("p",{id:c,children:o}):null]})}),e.jsx("div",{className:s?`mobile-sheet-body ${s}`:"mobile-sheet-body",children:k}),i?e.jsx("div",{className:"mobile-sheet-footer",children:i}):null]}),v?e.jsx("button",{type:"button",className:"ios-action-sheet-cancel mobile-sheet-cancel",disabled:!t,onClick:()=>{t&&r()},children:f??g("common.cancel")}):null]})}),document.body)}export{E as M};
1
+ import{b as n,j as e,t as g}from"./index-CILPuSCp.js";import{g as $}from"./App-D5hc6KuU.js";function E({open:h,title:m,description:o,height:b="auto",kind:u="form",dismissible:t=!0,closeOnBackdrop:p=!0,backdropVisible:x=!0,showHandle:j=!1,showCancelButton:v=!0,cancelLabel:f,className:a,cardClassName:l,bodyClassName:s,footer:i,onClose:r,children:k}){const d=n.useId(),c=n.useId(),y=t&&p;return!h||typeof document>"u"?null:$.createPortal(e.jsx("div",{className:"ios-action-sheet-overlay mobile-sheet-overlay","data-backdrop-visible":x?"true":"false",role:"presentation",onClick:()=>{y&&r()},children:e.jsxs("div",{className:`mobile-workspace-home-sheet mobile-sheet${a?` ${a}`:""}`,"data-height":b,"data-kind":u,role:"dialog","aria-modal":"true","aria-labelledby":d,"aria-describedby":o?c:void 0,onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:`mobile-workspace-home-sheet-card mobile-sheet-card${l?` ${l}`:""}`,children:[j?e.jsx("div",{className:"mobile-sheet-handle","aria-hidden":"true"}):null,e.jsx("div",{className:"mobile-workspace-home-sheet-header mobile-sheet-header",children:e.jsxs("div",{className:"mobile-sheet-title-wrap",children:[e.jsx("strong",{id:d,children:m}),o?e.jsx("p",{id:c,children:o}):null]})}),e.jsx("div",{className:s?`mobile-sheet-body ${s}`:"mobile-sheet-body",children:k}),i?e.jsx("div",{className:"mobile-sheet-footer",children:i}):null]}),v?e.jsx("button",{type:"button",className:"ios-action-sheet-cancel mobile-sheet-cancel",disabled:!t,onClick:()=>{t&&r()},children:f??g("common.cancel")}):null]})}),document.body)}export{E as M};
@@ -1 +1 @@
1
- import{j as n,t as s}from"./index-BilHJjYU.js";import{M as a,H as d,t as m,u,v as g}from"./workbench-navigation-ED0157V-.js";import{b as c,a as y,g as f}from"./plugin-permission-copy-DrLk22m5.js";function k({grants:i,auditEvents:r,loading:t,revokingGrantId:o,onRevokeGrant:p}){const l=r.filter(e=>e.eventType==="plugin.permission_granted"||e.eventType==="plugin.permission_revoked"||e.eventType==="plugin.permission_denied");return n.jsxs(n.Fragment,{children:[n.jsx(a,{heading:s("plugins.grantedPermissionTitle"),description:s("plugins.grantedPermissionDescription"),children:t?n.jsx("p",{className:"plugins-hint-text",children:s("plugins.permissionGrantLoading")}):i.length===0?n.jsx(d,{title:s("plugins.grantedPermissionEmptyTitle"),description:s("plugins.grantedPermissionEmptyDescription"),compact:!0}):n.jsx(m,{compact:!0,children:i.map(e=>n.jsx(u,{label:f(e.permissionKey),description:`${y(e.scopeType,e.scopePath)} · ${c(e.grantMode)}`,trailing:p?n.jsx("button",{type:"button",className:"ghost-button",disabled:o===e.id,onClick:()=>p(e),children:s("plugins.revokeGrantAction")}):n.jsx(g,{children:c(e.grantMode)})},e.id))})}),n.jsx(a,{heading:s("plugins.permissionAuditTitle"),description:s("plugins.permissionAuditDescription"),children:l.length===0?n.jsx(d,{title:s("plugins.permissionAuditEmptyTitle"),description:s("plugins.permissionAuditEmptyDescription"),compact:!0}):n.jsx(m,{compact:!0,children:l.slice(0,10).map(e=>n.jsx(u,{label:P(e),description:x(e),trailing:n.jsx(g,{children:e.createdAt})},e.id))})})]})}function P(i){const r=h(i.payloadJson),t=j(r.permissionKey),o=t?f(t):s("plugins.permissionEventUnknown");return i.eventType==="plugin.permission_granted"?s("plugins.permissionEventGranted",{permission:o}):i.eventType==="plugin.permission_revoked"?s("plugins.permissionEventRevoked",{permission:o}):s("plugins.permissionEventDenied",{permission:o})}function x(i){const r=h(i.payloadJson),t=b(r.scopeType),o=typeof r.scopePath=="string"?r.scopePath:null,p=t?y(t,o):s("plugins.permissionScopeUnknown");if(i.eventType==="plugin.permission_denied"){const e=r.reason==="declaration_missing"?s("plugins.permissionEventReasonDeclarationMissing"):s("plugins.permissionEventReasonGrantRequired");return`${p} · ${e}`}const l=E(r.grantMode);return l?`${p} · ${c(l)}`:p}function h(i){try{const r=JSON.parse(i);return r&&typeof r=="object"?r:{}}catch{return{}}}function j(i){return i==="workspace.read_file"||i==="workspace.list_dir"||i==="workspace.write_file"||i==="desktop.open_file"||i==="desktop.reveal_in_file_manager"?i:null}function b(i){return i==="workspace"||i==="directory"||i==="file"?i:null}function E(i){return i==="once"||i==="session"||i==="persistent"?i:null}export{k as P};
1
+ import{j as n,t as s}from"./index-CILPuSCp.js";import{M as a,H as d,t as m,u,v as g}from"./workbench-navigation-hwM28xIb.js";import{b as c,a as y,g as f}from"./plugin-permission-copy-LDy-lW7h.js";function k({grants:i,auditEvents:r,loading:t,revokingGrantId:o,onRevokeGrant:p}){const l=r.filter(e=>e.eventType==="plugin.permission_granted"||e.eventType==="plugin.permission_revoked"||e.eventType==="plugin.permission_denied");return n.jsxs(n.Fragment,{children:[n.jsx(a,{heading:s("plugins.grantedPermissionTitle"),description:s("plugins.grantedPermissionDescription"),children:t?n.jsx("p",{className:"plugins-hint-text",children:s("plugins.permissionGrantLoading")}):i.length===0?n.jsx(d,{title:s("plugins.grantedPermissionEmptyTitle"),description:s("plugins.grantedPermissionEmptyDescription"),compact:!0}):n.jsx(m,{compact:!0,children:i.map(e=>n.jsx(u,{label:f(e.permissionKey),description:`${y(e.scopeType,e.scopePath)} · ${c(e.grantMode)}`,trailing:p?n.jsx("button",{type:"button",className:"ghost-button",disabled:o===e.id,onClick:()=>p(e),children:s("plugins.revokeGrantAction")}):n.jsx(g,{children:c(e.grantMode)})},e.id))})}),n.jsx(a,{heading:s("plugins.permissionAuditTitle"),description:s("plugins.permissionAuditDescription"),children:l.length===0?n.jsx(d,{title:s("plugins.permissionAuditEmptyTitle"),description:s("plugins.permissionAuditEmptyDescription"),compact:!0}):n.jsx(m,{compact:!0,children:l.slice(0,10).map(e=>n.jsx(u,{label:P(e),description:x(e),trailing:n.jsx(g,{children:e.createdAt})},e.id))})})]})}function P(i){const r=h(i.payloadJson),t=j(r.permissionKey),o=t?f(t):s("plugins.permissionEventUnknown");return i.eventType==="plugin.permission_granted"?s("plugins.permissionEventGranted",{permission:o}):i.eventType==="plugin.permission_revoked"?s("plugins.permissionEventRevoked",{permission:o}):s("plugins.permissionEventDenied",{permission:o})}function x(i){const r=h(i.payloadJson),t=b(r.scopeType),o=typeof r.scopePath=="string"?r.scopePath:null,p=t?y(t,o):s("plugins.permissionScopeUnknown");if(i.eventType==="plugin.permission_denied"){const e=r.reason==="declaration_missing"?s("plugins.permissionEventReasonDeclarationMissing"):s("plugins.permissionEventReasonGrantRequired");return`${p} · ${e}`}const l=E(r.grantMode);return l?`${p} · ${c(l)}`:p}function h(i){try{const r=JSON.parse(i);return r&&typeof r=="object"?r:{}}catch{return{}}}function j(i){return i==="workspace.read_file"||i==="workspace.list_dir"||i==="workspace.write_file"||i==="desktop.open_file"||i==="desktop.reveal_in_file_manager"?i:null}function b(i){return i==="workspace"||i==="directory"||i==="file"?i:null}function E(i){return i==="once"||i==="session"||i==="persistent"?i:null}export{k as P};
@@ -1 +1 @@
1
- import{b as f,j as o,t as r,B as h,H as L,I as U,J as x,D as C}from"./index-BilHJjYU.js";import{M as D,t as k,u as b,v as S,H as v,w as A,N as j}from"./workbench-navigation-ED0157V-.js";import{e as G,i as M,T as F,P as K,c as B,u as H,f as z}from"./App-CHsm-VrM.js";import{c as Q,f as W,h as Y,i as $,o as V,j as J,k as X,w as Z,m as q}from"./plugins-api-COF4oh24.js";import{D as ee}from"./DesktopModal-Csj5AdAN.js";import{M as ne}from"./MobileSheet-Co-qPMBD.js";import{g as ie,a as te,b as se}from"./plugin-permission-copy-DrLk22m5.js";function oe({open:e,request:n,submitting:t,onClose:s,onApprove:i}){const l=G(),c=f.useMemo(()=>re(n),[n]);if(!n)return null;const d=o.jsxs("div",{className:"plugins-permission-prompt",children:[o.jsx(D,{heading:r("plugins.permissionPromptSummaryTitle"),description:r("plugins.permissionPromptSummaryDescription",{pluginName:n.pluginName}),children:o.jsxs(k,{compact:!0,children:[o.jsx(b,{label:r("plugins.permissionPromptPermissionLabel"),description:ie(n.permissionKey),trailing:o.jsx(S,{tone:"warning",children:r("plugins.permissionPromptPendingTag")})}),o.jsx(b,{label:r("plugins.permissionPromptTargetLabel"),description:te(n.scopeType,n.scopePath)})]})}),o.jsx(D,{heading:r("plugins.permissionPromptOptionsTitle"),description:r("plugins.permissionPromptOptionsDescription"),children:c.length===0?o.jsx(v,{title:r("plugins.permissionPromptNoOptionTitle"),description:r("plugins.permissionPromptNoOptionDescription"),compact:!0}):o.jsx(k,{children:c.map(a=>o.jsx(b,{as:"button",disabled:t,label:a.label,description:a.description,trailing:o.jsx(S,{children:se(a.grantMode)}),onClick:()=>{i({scopeType:a.scopeType,scopePath:a.scopePath,grantMode:a.grantMode})}},a.id))})}),o.jsx(A,{align:"end",children:o.jsx("button",{type:"button",className:"secondary-button",disabled:t,onClick:s,children:r("plugins.permissionPromptDenyAction")})})]});return l.isMobile?o.jsx(ne,{open:e,title:r("plugins.permissionPromptTitle"),description:r("plugins.permissionPromptDescription"),height:"three-quarter",kind:"form",onClose:s,footer:null,children:d}):o.jsx(ee,{open:e,title:r("plugins.permissionPromptTitle"),description:r("plugins.permissionPromptDescription"),size:"regular",layout:"form",onClose:s,footer:null,children:d})}function re(e){var s;if(!e)return[];const n=[],t=((s=e.scopePath)==null?void 0:s.trim())||null;if(e.grantOptions.includes("once")&&n.push({id:"once-file",label:r("plugins.permissionPromptOptionOnce"),description:r("plugins.permissionPromptOptionOnceDescription"),grantMode:"once",scopeType:e.scopeType==="workspace"?"workspace":"file",scopePath:e.scopeType==="workspace"?null:t}),e.grantOptions.includes("session")&&n.push({id:"session-current",label:r("plugins.permissionPromptOptionSession"),description:r("plugins.permissionPromptOptionSessionDescription"),grantMode:"session",scopeType:e.scopeType==="workspace"?"workspace":"file",scopePath:e.scopeType==="workspace"?null:t}),e.grantOptions.includes("persistent")&&t&&e.scopeType!=="workspace"){const i=ae(t);i&&n.push({id:"persistent-directory",label:r("plugins.permissionPromptOptionDirectory"),description:r("plugins.permissionPromptOptionDirectoryDescription",{scopePath:i}),grantMode:"persistent",scopeType:"directory",scopePath:i})}return n}function ae(e){const n=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");if(!n)return null;const t=n.split("/");return t.length<=1?n:t.slice(0,-1).join("/")}const R="codingns-plugin:response",le="codingns-plugin:init",pe="codingns-plugin:ready",ce="codingns-plugin:request";async function de(e,n,t){const s=await Q(e,n);return Ne(s.context,t)}async function O(e,n){await W(e,n)}function ue(e){const{iframe:n,pluginId:t,hostOrigin:s,context:i}=e;function l(c){var m;if(c.source!==n.contentWindow||c.origin!==s)return;const d=c.data;if(!d||typeof d!="object")return;if(d.type===pe){(m=n.contentWindow)==null||m.postMessage({type:le,context:i},s);return}const a=d;a.type!==ce||typeof a.requestId!="string"||me({pluginId:t,pluginName:i.pluginName,runtimeSessionId:i.runtimeSessionId,request:a}).then(g=>{var u;(u=n.contentWindow)==null||u.postMessage({type:R,requestId:a.requestId,ok:!0,result:g},s)}).catch(g=>{var u;(u=n.contentWindow)==null||u.postMessage({type:R,requestId:a.requestId,ok:!1,error:Ee(g)},s)})}return window.addEventListener("message",l),()=>{window.removeEventListener("message",l)}}async function me(e){var c,d,a,m,g,u,P;const{pluginId:n,pluginName:t,runtimeSessionId:s,request:i}=e;if(i.action==="callAction"){const p=typeof((c=i.payload)==null?void 0:c.actionId)=="string"?i.payload.actionId.trim():"";if(!p)throw new h(400,{error_code:"PLUGIN_ACTION_ID_REQUIRED",detail:"插件动作请求缺少 actionId"});return await Y(n,p,s,(d=i.payload)==null?void 0:d.input)}if(i.action==="readFile"){const p=_((a=i.payload)==null?void 0:a.path,"插件读文件缺少路径");return await w({pluginId:n,pluginName:t,runtimeSessionId:s,permissionKey:"workspace.read_file",scopePath:p,execute:async()=>await X(n,s,p)})}if(i.action==="writeFile"){const p=_((m=i.payload)==null?void 0:m.path,"插件写文件缺少路径"),N=typeof((g=i.payload)==null?void 0:g.content)=="string"?i.payload.content:"";return await w({pluginId:n,pluginName:t,runtimeSessionId:s,permissionKey:"workspace.write_file",scopePath:p,execute:async()=>await Z(n,s,p,N)})}if(i.action==="listDir"){const p=typeof((u=i.payload)==null?void 0:u.path)=="string"?i.payload.path.trim():"";return{items:(await w({pluginId:n,pluginName:t,runtimeSessionId:s,permissionKey:"workspace.list_dir",scopePath:p||null,execute:async()=>await $(n,s,p||void 0)})).items.map(ge)}}const l=_((P=i.payload)==null?void 0:P.path,"插件桌面动作缺少路径");if(i.action==="openFile"){const p=await w({pluginId:n,pluginName:t,runtimeSessionId:s,permissionKey:"desktop.open_file",scopePath:l,execute:async()=>await V(n,s,l)}),y=await M().fs.openFile(p.absolutePath);if(!y.ok)throw new h(500,{error_code:y.errorCode??"PLUGIN_DESKTOP_OPEN_FAILED",detail:y.detail??"打开文件失败"});return p}if(i.action==="revealInFileManager"){const p=await w({pluginId:n,pluginName:t,runtimeSessionId:s,permissionKey:"desktop.reveal_in_file_manager",scopePath:l,execute:async()=>await J(n,s,l)}),y=await M().fs.revealInFileManager(p.absolutePath);if(!y.ok)throw new h(500,{error_code:y.errorCode??"PLUGIN_DESKTOP_REVEAL_FAILED",detail:y.detail??"打开所在目录失败"});return p}throw new h(400,{error_code:"PLUGIN_BRIDGE_ACTION_UNKNOWN",detail:`未知插件桥动作:${i.action}`})}function _(e,n){const t=typeof e=="string"?e.trim():"";if(!t)throw new h(400,{error_code:"PLUGIN_PATH_REQUIRED",detail:n});return t}function ge(e){return{path:e.path,name:e.name,kind:e.kind,size:e.size,updatedAt:e.updatedAt}}async function w(e){try{return await e.execute()}catch(n){const t=fe(n,e);if(!t||!await we(t))throw n;return await e.execute()}}function fe(e,n){var c,d,a,m;if(!(e instanceof h)||e.errorCode!=="PLUGIN_PERMISSION_GRANT_REQUIRED")return null;const t=Pe((c=e.data)==null?void 0:c.permissionKey,n.permissionKey),s=he((d=e.data)==null?void 0:d.scopeType,n.scopePath?"file":"workspace"),i=typeof((a=e.data)==null?void 0:a.scopePath)=="string"?e.data.scopePath:n.scopePath,l=ye((m=e.data)==null?void 0:m.grantOptions);return{pluginId:n.pluginId,pluginName:n.pluginName,runtimeSessionId:n.runtimeSessionId,permissionKey:t,scopeType:s,scopePath:i,grantOptions:l}}function Pe(e,n){return e==="workspace.read_file"||e==="workspace.list_dir"||e==="workspace.write_file"||e==="desktop.open_file"||e==="desktop.reveal_in_file_manager"?e:n}function he(e,n){return e==="workspace"||e==="directory"||e==="file"?e:n}function ye(e){return Array.isArray(e)?e.filter(n=>n==="once"||n==="session"||n==="persistent"):["once","session"]}let E=null,I=null;async function we(e){return typeof document>"u"?!1:await new Promise(n=>{Ie();const t=i=>{T({open:!1,request:null,submitting:!1,onClose:()=>t(!1),onApprove:()=>{}}),window.setTimeout(()=>n(i),0)};T({open:!0,request:e,submitting:!1,onClose:()=>t(!1),onApprove:async i=>{T({open:!0,request:e,submitting:!0,onClose:()=>{},onApprove:()=>{}});try{await q(e.pluginId,{runtimeSessionId:e.runtimeSessionId,permissionKey:e.permissionKey,scopeType:i.scopeType,scopePath:i.scopePath,grantMode:i.grantMode}),t(!0)}catch{t(!1)}}})})}function Ie(){I||(I=document.createElement("div"),I.dataset.pluginPermissionPrompt="true",document.body.appendChild(I)),E||(E=L.createRoot(I))}function T(e){E&&E.render(f.createElement(U,null,f.createElement(F,null,f.createElement(K,null,f.createElement(oe,{open:e.open,request:e.request,submitting:e.submitting,onClose:e.onClose,onApprove:e.onApprove})))))}function Ne(e,n){if(!e.frontendEntryUrl)throw new h(404,{error_code:"PLUGIN_FRONTEND_NOT_FOUND",detail:"当前插件没有可运行的前端入口"});return{pluginId:e.pluginId,workspaceId:e.workspaceId,runtimeSessionId:e.runtimeSessionId,pluginName:e.pluginName,pluginVersion:e.pluginVersion,frontendEntryUrl:e.frontendEntryUrl,hostOrigin:n}}function Ee(e){return e instanceof h?{code:e.errorCode??`HTTP_${e.status}`,detail:e.message}:e instanceof Error?{code:"PLUGIN_BRIDGE_REQUEST_FAILED",detail:e.message}:{code:"PLUGIN_BRIDGE_REQUEST_FAILED",detail:"插件桥请求失败"}}const be="allow-scripts allow-forms allow-modals allow-downloads";function Me(){const{workspaceId:e="",pluginId:n=""}=B(),t=H(),{showToast:s}=z(),i=f.useRef(null),[l,c]=f.useState(null),[d,a]=f.useState(!0),m=f.useMemo(()=>{const g=x();try{return new URL(g).origin}catch{return window.location.origin}},[]);return f.useEffect(()=>{let g=!1,u=null;return a(!0),c(null),de(n,e,m).then(P=>{if(g){O(n,P.runtimeSessionId).catch(()=>{});return}u=P,c(P)}).catch(P=>{g||s({title:P instanceof Error?P.message:r("plugins.containerLoadFailed"),tone:"error"})}).finally(()=>{g||a(!1)}),()=>{g=!0,u!=null&&u.runtimeSessionId&&O(n,u.runtimeSessionId).catch(()=>{})}},[m,n,s,e]),f.useEffect(()=>{if(!(!l||!i.current))return ue({iframe:i.current,pluginId:n,hostOrigin:m,context:l})},[l,m,n]),d?o.jsx("main",{className:"mobile-feature-page mobile-page-fixed-root plugins-page",children:o.jsx("article",{className:"surface-card plugins-panel plugins-container-panel",children:o.jsx("p",{className:"plugins-hint-text",children:r("plugins.loading")})})}):l?o.jsx("main",{className:"mobile-feature-page mobile-page-fixed-root plugins-page",children:o.jsxs("article",{className:"surface-card plugins-panel plugins-container-panel",children:[o.jsxs("header",{className:"plugins-page-header",children:[o.jsxs("div",{children:[o.jsx("h1",{children:l.pluginName}),o.jsx("p",{children:r("plugins.containerDescription")})]}),o.jsx(A,{children:o.jsx("button",{type:"button",className:"secondary-button",onClick:()=>t(j(e,n)),children:r("plugins.backToDetail")})})]}),o.jsx("div",{className:"plugins-runtime-shell",children:o.jsx("iframe",{ref:i,title:l.pluginName,className:"plugins-runtime-frame",src:C(l.frontendEntryUrl,x()),sandbox:be,referrerPolicy:"no-referrer"})})]})}):o.jsx("main",{className:"mobile-feature-page mobile-page-fixed-root plugins-page",children:o.jsx("article",{className:"surface-card plugins-panel plugins-container-panel",children:o.jsx(v,{title:r("plugins.containerMissingTitle"),description:r("plugins.containerMissingDescription"),action:o.jsx("button",{type:"button",className:"secondary-button",onClick:()=>t(j(e,n)),children:r("plugins.backToDetail")})})})})}export{Me as PluginContainerPage};
1
+ import{b as f,j as o,t as r,B as h,H as L,I as U,J as x,D as C}from"./index-CILPuSCp.js";import{M as D,t as k,u as b,v as S,H as v,w as A,N as j}from"./workbench-navigation-hwM28xIb.js";import{e as G,i as M,T as F,P as K,c as B,u as H,f as z}from"./App-D5hc6KuU.js";import{c as Q,f as W,h as Y,i as $,o as V,j as J,k as X,w as Z,m as q}from"./plugins-api-BGF9OybZ.js";import{D as ee}from"./DesktopModal-BCVZq_PQ.js";import{M as ne}from"./MobileSheet-DPYtp5Ze.js";import{g as ie,a as te,b as se}from"./plugin-permission-copy-LDy-lW7h.js";function oe({open:e,request:n,submitting:t,onClose:s,onApprove:i}){const l=G(),c=f.useMemo(()=>re(n),[n]);if(!n)return null;const d=o.jsxs("div",{className:"plugins-permission-prompt",children:[o.jsx(D,{heading:r("plugins.permissionPromptSummaryTitle"),description:r("plugins.permissionPromptSummaryDescription",{pluginName:n.pluginName}),children:o.jsxs(k,{compact:!0,children:[o.jsx(b,{label:r("plugins.permissionPromptPermissionLabel"),description:ie(n.permissionKey),trailing:o.jsx(S,{tone:"warning",children:r("plugins.permissionPromptPendingTag")})}),o.jsx(b,{label:r("plugins.permissionPromptTargetLabel"),description:te(n.scopeType,n.scopePath)})]})}),o.jsx(D,{heading:r("plugins.permissionPromptOptionsTitle"),description:r("plugins.permissionPromptOptionsDescription"),children:c.length===0?o.jsx(v,{title:r("plugins.permissionPromptNoOptionTitle"),description:r("plugins.permissionPromptNoOptionDescription"),compact:!0}):o.jsx(k,{children:c.map(a=>o.jsx(b,{as:"button",disabled:t,label:a.label,description:a.description,trailing:o.jsx(S,{children:se(a.grantMode)}),onClick:()=>{i({scopeType:a.scopeType,scopePath:a.scopePath,grantMode:a.grantMode})}},a.id))})}),o.jsx(A,{align:"end",children:o.jsx("button",{type:"button",className:"secondary-button",disabled:t,onClick:s,children:r("plugins.permissionPromptDenyAction")})})]});return l.isMobile?o.jsx(ne,{open:e,title:r("plugins.permissionPromptTitle"),description:r("plugins.permissionPromptDescription"),height:"three-quarter",kind:"form",onClose:s,footer:null,children:d}):o.jsx(ee,{open:e,title:r("plugins.permissionPromptTitle"),description:r("plugins.permissionPromptDescription"),size:"regular",layout:"form",onClose:s,footer:null,children:d})}function re(e){var s;if(!e)return[];const n=[],t=((s=e.scopePath)==null?void 0:s.trim())||null;if(e.grantOptions.includes("once")&&n.push({id:"once-file",label:r("plugins.permissionPromptOptionOnce"),description:r("plugins.permissionPromptOptionOnceDescription"),grantMode:"once",scopeType:e.scopeType==="workspace"?"workspace":"file",scopePath:e.scopeType==="workspace"?null:t}),e.grantOptions.includes("session")&&n.push({id:"session-current",label:r("plugins.permissionPromptOptionSession"),description:r("plugins.permissionPromptOptionSessionDescription"),grantMode:"session",scopeType:e.scopeType==="workspace"?"workspace":"file",scopePath:e.scopeType==="workspace"?null:t}),e.grantOptions.includes("persistent")&&t&&e.scopeType!=="workspace"){const i=ae(t);i&&n.push({id:"persistent-directory",label:r("plugins.permissionPromptOptionDirectory"),description:r("plugins.permissionPromptOptionDirectoryDescription",{scopePath:i}),grantMode:"persistent",scopeType:"directory",scopePath:i})}return n}function ae(e){const n=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");if(!n)return null;const t=n.split("/");return t.length<=1?n:t.slice(0,-1).join("/")}const R="codingns-plugin:response",le="codingns-plugin:init",pe="codingns-plugin:ready",ce="codingns-plugin:request";async function de(e,n,t){const s=await Q(e,n);return Ne(s.context,t)}async function O(e,n){await W(e,n)}function ue(e){const{iframe:n,pluginId:t,hostOrigin:s,context:i}=e;function l(c){var m;if(c.source!==n.contentWindow||c.origin!==s)return;const d=c.data;if(!d||typeof d!="object")return;if(d.type===pe){(m=n.contentWindow)==null||m.postMessage({type:le,context:i},s);return}const a=d;a.type!==ce||typeof a.requestId!="string"||me({pluginId:t,pluginName:i.pluginName,runtimeSessionId:i.runtimeSessionId,request:a}).then(g=>{var u;(u=n.contentWindow)==null||u.postMessage({type:R,requestId:a.requestId,ok:!0,result:g},s)}).catch(g=>{var u;(u=n.contentWindow)==null||u.postMessage({type:R,requestId:a.requestId,ok:!1,error:Ee(g)},s)})}return window.addEventListener("message",l),()=>{window.removeEventListener("message",l)}}async function me(e){var c,d,a,m,g,u,P;const{pluginId:n,pluginName:t,runtimeSessionId:s,request:i}=e;if(i.action==="callAction"){const p=typeof((c=i.payload)==null?void 0:c.actionId)=="string"?i.payload.actionId.trim():"";if(!p)throw new h(400,{error_code:"PLUGIN_ACTION_ID_REQUIRED",detail:"插件动作请求缺少 actionId"});return await Y(n,p,s,(d=i.payload)==null?void 0:d.input)}if(i.action==="readFile"){const p=_((a=i.payload)==null?void 0:a.path,"插件读文件缺少路径");return await w({pluginId:n,pluginName:t,runtimeSessionId:s,permissionKey:"workspace.read_file",scopePath:p,execute:async()=>await X(n,s,p)})}if(i.action==="writeFile"){const p=_((m=i.payload)==null?void 0:m.path,"插件写文件缺少路径"),N=typeof((g=i.payload)==null?void 0:g.content)=="string"?i.payload.content:"";return await w({pluginId:n,pluginName:t,runtimeSessionId:s,permissionKey:"workspace.write_file",scopePath:p,execute:async()=>await Z(n,s,p,N)})}if(i.action==="listDir"){const p=typeof((u=i.payload)==null?void 0:u.path)=="string"?i.payload.path.trim():"";return{items:(await w({pluginId:n,pluginName:t,runtimeSessionId:s,permissionKey:"workspace.list_dir",scopePath:p||null,execute:async()=>await $(n,s,p||void 0)})).items.map(ge)}}const l=_((P=i.payload)==null?void 0:P.path,"插件桌面动作缺少路径");if(i.action==="openFile"){const p=await w({pluginId:n,pluginName:t,runtimeSessionId:s,permissionKey:"desktop.open_file",scopePath:l,execute:async()=>await V(n,s,l)}),y=await M().fs.openFile(p.absolutePath);if(!y.ok)throw new h(500,{error_code:y.errorCode??"PLUGIN_DESKTOP_OPEN_FAILED",detail:y.detail??"打开文件失败"});return p}if(i.action==="revealInFileManager"){const p=await w({pluginId:n,pluginName:t,runtimeSessionId:s,permissionKey:"desktop.reveal_in_file_manager",scopePath:l,execute:async()=>await J(n,s,l)}),y=await M().fs.revealInFileManager(p.absolutePath);if(!y.ok)throw new h(500,{error_code:y.errorCode??"PLUGIN_DESKTOP_REVEAL_FAILED",detail:y.detail??"打开所在目录失败"});return p}throw new h(400,{error_code:"PLUGIN_BRIDGE_ACTION_UNKNOWN",detail:`未知插件桥动作:${i.action}`})}function _(e,n){const t=typeof e=="string"?e.trim():"";if(!t)throw new h(400,{error_code:"PLUGIN_PATH_REQUIRED",detail:n});return t}function ge(e){return{path:e.path,name:e.name,kind:e.kind,size:e.size,updatedAt:e.updatedAt}}async function w(e){try{return await e.execute()}catch(n){const t=fe(n,e);if(!t||!await we(t))throw n;return await e.execute()}}function fe(e,n){var c,d,a,m;if(!(e instanceof h)||e.errorCode!=="PLUGIN_PERMISSION_GRANT_REQUIRED")return null;const t=Pe((c=e.data)==null?void 0:c.permissionKey,n.permissionKey),s=he((d=e.data)==null?void 0:d.scopeType,n.scopePath?"file":"workspace"),i=typeof((a=e.data)==null?void 0:a.scopePath)=="string"?e.data.scopePath:n.scopePath,l=ye((m=e.data)==null?void 0:m.grantOptions);return{pluginId:n.pluginId,pluginName:n.pluginName,runtimeSessionId:n.runtimeSessionId,permissionKey:t,scopeType:s,scopePath:i,grantOptions:l}}function Pe(e,n){return e==="workspace.read_file"||e==="workspace.list_dir"||e==="workspace.write_file"||e==="desktop.open_file"||e==="desktop.reveal_in_file_manager"?e:n}function he(e,n){return e==="workspace"||e==="directory"||e==="file"?e:n}function ye(e){return Array.isArray(e)?e.filter(n=>n==="once"||n==="session"||n==="persistent"):["once","session"]}let E=null,I=null;async function we(e){return typeof document>"u"?!1:await new Promise(n=>{Ie();const t=i=>{T({open:!1,request:null,submitting:!1,onClose:()=>t(!1),onApprove:()=>{}}),window.setTimeout(()=>n(i),0)};T({open:!0,request:e,submitting:!1,onClose:()=>t(!1),onApprove:async i=>{T({open:!0,request:e,submitting:!0,onClose:()=>{},onApprove:()=>{}});try{await q(e.pluginId,{runtimeSessionId:e.runtimeSessionId,permissionKey:e.permissionKey,scopeType:i.scopeType,scopePath:i.scopePath,grantMode:i.grantMode}),t(!0)}catch{t(!1)}}})})}function Ie(){I||(I=document.createElement("div"),I.dataset.pluginPermissionPrompt="true",document.body.appendChild(I)),E||(E=L.createRoot(I))}function T(e){E&&E.render(f.createElement(U,null,f.createElement(F,null,f.createElement(K,null,f.createElement(oe,{open:e.open,request:e.request,submitting:e.submitting,onClose:e.onClose,onApprove:e.onApprove})))))}function Ne(e,n){if(!e.frontendEntryUrl)throw new h(404,{error_code:"PLUGIN_FRONTEND_NOT_FOUND",detail:"当前插件没有可运行的前端入口"});return{pluginId:e.pluginId,workspaceId:e.workspaceId,runtimeSessionId:e.runtimeSessionId,pluginName:e.pluginName,pluginVersion:e.pluginVersion,frontendEntryUrl:e.frontendEntryUrl,hostOrigin:n}}function Ee(e){return e instanceof h?{code:e.errorCode??`HTTP_${e.status}`,detail:e.message}:e instanceof Error?{code:"PLUGIN_BRIDGE_REQUEST_FAILED",detail:e.message}:{code:"PLUGIN_BRIDGE_REQUEST_FAILED",detail:"插件桥请求失败"}}const be="allow-scripts allow-forms allow-modals allow-downloads";function Me(){const{workspaceId:e="",pluginId:n=""}=B(),t=H(),{showToast:s}=z(),i=f.useRef(null),[l,c]=f.useState(null),[d,a]=f.useState(!0),m=f.useMemo(()=>{const g=x();try{return new URL(g).origin}catch{return window.location.origin}},[]);return f.useEffect(()=>{let g=!1,u=null;return a(!0),c(null),de(n,e,m).then(P=>{if(g){O(n,P.runtimeSessionId).catch(()=>{});return}u=P,c(P)}).catch(P=>{g||s({title:P instanceof Error?P.message:r("plugins.containerLoadFailed"),tone:"error"})}).finally(()=>{g||a(!1)}),()=>{g=!0,u!=null&&u.runtimeSessionId&&O(n,u.runtimeSessionId).catch(()=>{})}},[m,n,s,e]),f.useEffect(()=>{if(!(!l||!i.current))return ue({iframe:i.current,pluginId:n,hostOrigin:m,context:l})},[l,m,n]),d?o.jsx("main",{className:"mobile-feature-page mobile-page-fixed-root plugins-page",children:o.jsx("article",{className:"surface-card plugins-panel plugins-container-panel",children:o.jsx("p",{className:"plugins-hint-text",children:r("plugins.loading")})})}):l?o.jsx("main",{className:"mobile-feature-page mobile-page-fixed-root plugins-page",children:o.jsxs("article",{className:"surface-card plugins-panel plugins-container-panel",children:[o.jsxs("header",{className:"plugins-page-header",children:[o.jsxs("div",{children:[o.jsx("h1",{children:l.pluginName}),o.jsx("p",{children:r("plugins.containerDescription")})]}),o.jsx(A,{children:o.jsx("button",{type:"button",className:"secondary-button",onClick:()=>t(j(e,n)),children:r("plugins.backToDetail")})})]}),o.jsx("div",{className:"plugins-runtime-shell",children:o.jsx("iframe",{ref:i,title:l.pluginName,className:"plugins-runtime-frame",src:C(l.frontendEntryUrl,x()),sandbox:be,referrerPolicy:"no-referrer"})})]})}):o.jsx("main",{className:"mobile-feature-page mobile-page-fixed-root plugins-page",children:o.jsx("article",{className:"surface-card plugins-panel plugins-container-panel",children:o.jsx(v,{title:r("plugins.containerMissingTitle"),description:r("plugins.containerMissingDescription"),action:o.jsx("button",{type:"button",className:"secondary-button",onClick:()=>t(j(e,n)),children:r("plugins.backToDetail")})})})})}export{Me as PluginContainerPage};
@@ -1 +1 @@
1
- import{b as t,j as e,t as s}from"./index-BilHJjYU.js";import{H as R,O as S,v as o,M as u,t as f,u as d,w as $,Q as H}from"./workbench-navigation-ED0157V-.js";import{c as F,u as W,f as O}from"./App-CHsm-VrM.js";import{g as z,a as B,b as Q,r as U,d as _,e as q}from"./plugins-api-COF4oh24.js";import{P as J}from"./PluginAccessOverview-D-KXkcyj.js";import"./plugin-permission-copy-DrLk22m5.js";function se(){var N,E;const{workspaceId:r="",pluginId:l=""}=F(),p=W(),{showToast:c}=O(),[n,T]=t.useState(null),[b,D]=t.useState([]),[L,g]=t.useState([]),[M,h]=t.useState(!0),[I,x]=t.useState(!1),[j,k]=t.useState(!1),[y,v]=t.useState(null);async function m(){h(!0);try{const[i,a]=await Promise.all([z(l),B(l)]);T(i),D(a.items)}catch(i){c({title:i instanceof Error?i.message:s("plugins.detailLoadFailed"),tone:"error"})}finally{h(!1)}}async function w(){const i=r.trim();if(!i||!l.trim()){g([]);return}x(!0);try{const a=await Q(l,i);g(a.items)}catch(a){c({title:a instanceof Error?a.message:s("plugins.permissionGrantLoadFailed"),tone:"error"}),g([])}finally{x(!1)}}t.useEffect(()=>{m()},[l]),t.useEffect(()=>{w()},[l,r]);const P=t.useMemo(()=>(n==null?void 0:n.manifest.permissions.desktop)??[],[n]);async function A(){if(!(!n||j)){k(!0);try{n.enablement.enabled?await _(n.definition.id,s("plugins.disabledByUserReason")):await q(n.definition.id),await m(),c({title:n.enablement.enabled?s("plugins.disableSuccess"):s("plugins.enableSuccess"),tone:"success"})}catch(i){c({title:i instanceof Error?i.message:s("plugins.saveFailed"),tone:"error"})}finally{k(!1)}}}async function C(i){const a=r.trim();if(!(!a||y)){v(i.id);try{await U(l,i.id,a),await Promise.all([m(),w()]),c({title:s("plugins.revokeGrantSuccess"),tone:"success"})}catch(G){c({title:G instanceof Error?G.message:s("plugins.revokeGrantFailed"),tone:"error"})}finally{v(null)}}}return M?e.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root plugins-page",children:e.jsx("article",{className:"surface-card plugins-panel",children:e.jsx("p",{className:"plugins-hint-text",children:s("plugins.loading")})})}):n?e.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root plugins-page",children:e.jsxs("article",{className:"surface-card plugins-panel",children:[e.jsxs("header",{className:"plugins-page-header",children:[e.jsxs("div",{children:[e.jsx("h1",{children:n.manifest.name}),e.jsx("p",{children:n.manifest.description??n.definition.id})]}),e.jsxs("div",{className:"plugins-list-tags",children:[e.jsx(o,{tone:n.enablement.enabled?"success":"default",children:n.enablement.enabled?s("plugins.enabled"):s("plugins.disabled")}),e.jsx(o,{children:`v${n.manifest.version}`})]})]}),e.jsx(u,{heading:s("plugins.summaryTitle"),description:s("plugins.summaryDescription"),children:e.jsxs(f,{children:[e.jsx(d,{label:s("plugins.pluginIdLabel"),description:n.definition.id}),e.jsx(d,{label:s("plugins.installRootLabel"),description:n.definition.installRoot}),e.jsx(d,{label:s("plugins.runtimeLabel"),description:n.manifest.backend?`${s("plugins.backendTag")} · ${n.manifest.backend.mode??"on_demand"}`:s("plugins.frontendOnly")})]})}),e.jsx(u,{heading:s("plugins.permissionTitle"),description:s("plugins.permissionDescription"),children:e.jsxs("div",{className:"plugins-list-tags",children:[e.jsx(o,{tone:n.manifest.permissions.workspaceRead?"success":"default",children:n.manifest.permissions.workspaceRead?s("plugins.workspaceReadAllowed"):s("plugins.workspaceReadDenied")}),e.jsx(o,{tone:n.manifest.permissions.network?"warning":"default",children:n.manifest.permissions.network?s("plugins.networkAllowed"):s("plugins.networkDenied")}),P.length>0?P.map(i=>e.jsx(o,{children:i},i)):e.jsx(o,{tone:"default",children:s("plugins.noDesktopPermission")})]})}),e.jsx(J,{grants:L,auditEvents:n.auditEvents,loading:I,revokingGrantId:y,onRevokeGrant:i=>{C(i)}}),(E=(N=n.manifest.backend)==null?void 0:N.actions)!=null&&E.length?e.jsx(u,{heading:s("plugins.actionTitle"),description:s("plugins.actionDescription"),children:e.jsx(f,{children:n.manifest.backend.actions.map(i=>e.jsx(d,{label:i.title,description:`${i.id} · ${i.timeoutMs??3e4}ms`},i.id))})}):null,e.jsx(u,{heading:s("plugins.runHistoryTitle"),description:s("plugins.runHistoryDescription"),children:b.length===0?e.jsx(R,{title:s("plugins.runHistoryEmptyTitle"),description:s("plugins.runHistoryEmptyDescription")}):e.jsx(f,{children:b.slice(0,10).map(i=>e.jsx(d,{label:i.actionId??s("plugins.unknownAction"),description:`${i.status} · ${i.createdAt}`,trailing:i.errorCode?e.jsx(o,{tone:"danger",children:i.errorCode}):null},i.id))})}),e.jsxs($,{align:"between",stack:!0,children:[e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>p(S(r)),children:s("plugins.backToList")}),e.jsxs("div",{className:"plugins-detail-actions",children:[n.frontend?e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>p(H(r,n.definition.id)),children:s("plugins.openPlugin")}):null,e.jsx("button",{type:"button",className:n.enablement.enabled?"secondary-button":"primary-button",disabled:j,onClick:()=>{A()},children:n.enablement.enabled?s("plugins.disableAction"):s("plugins.enableAction")})]})]})]})}):e.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root plugins-page",children:e.jsx("article",{className:"surface-card plugins-panel",children:e.jsx(R,{title:s("plugins.detailMissingTitle"),description:s("plugins.detailMissingDescription"),action:e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>p(S(r)),children:s("plugins.backToList")})})})})}export{se as PluginDetailPage};
1
+ import{b as t,j as e,t as s}from"./index-CILPuSCp.js";import{H as R,O as S,v as o,M as u,t as f,u as d,w as $,Q as H}from"./workbench-navigation-hwM28xIb.js";import{c as F,u as W,f as O}from"./App-D5hc6KuU.js";import{g as z,a as B,b as Q,r as U,d as _,e as q}from"./plugins-api-BGF9OybZ.js";import{P as J}from"./PluginAccessOverview-CiVzb_NI.js";import"./plugin-permission-copy-LDy-lW7h.js";function se(){var N,E;const{workspaceId:r="",pluginId:l=""}=F(),p=W(),{showToast:c}=O(),[n,T]=t.useState(null),[b,D]=t.useState([]),[L,g]=t.useState([]),[M,h]=t.useState(!0),[I,x]=t.useState(!1),[j,k]=t.useState(!1),[y,v]=t.useState(null);async function m(){h(!0);try{const[i,a]=await Promise.all([z(l),B(l)]);T(i),D(a.items)}catch(i){c({title:i instanceof Error?i.message:s("plugins.detailLoadFailed"),tone:"error"})}finally{h(!1)}}async function w(){const i=r.trim();if(!i||!l.trim()){g([]);return}x(!0);try{const a=await Q(l,i);g(a.items)}catch(a){c({title:a instanceof Error?a.message:s("plugins.permissionGrantLoadFailed"),tone:"error"}),g([])}finally{x(!1)}}t.useEffect(()=>{m()},[l]),t.useEffect(()=>{w()},[l,r]);const P=t.useMemo(()=>(n==null?void 0:n.manifest.permissions.desktop)??[],[n]);async function A(){if(!(!n||j)){k(!0);try{n.enablement.enabled?await _(n.definition.id,s("plugins.disabledByUserReason")):await q(n.definition.id),await m(),c({title:n.enablement.enabled?s("plugins.disableSuccess"):s("plugins.enableSuccess"),tone:"success"})}catch(i){c({title:i instanceof Error?i.message:s("plugins.saveFailed"),tone:"error"})}finally{k(!1)}}}async function C(i){const a=r.trim();if(!(!a||y)){v(i.id);try{await U(l,i.id,a),await Promise.all([m(),w()]),c({title:s("plugins.revokeGrantSuccess"),tone:"success"})}catch(G){c({title:G instanceof Error?G.message:s("plugins.revokeGrantFailed"),tone:"error"})}finally{v(null)}}}return M?e.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root plugins-page",children:e.jsx("article",{className:"surface-card plugins-panel",children:e.jsx("p",{className:"plugins-hint-text",children:s("plugins.loading")})})}):n?e.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root plugins-page",children:e.jsxs("article",{className:"surface-card plugins-panel",children:[e.jsxs("header",{className:"plugins-page-header",children:[e.jsxs("div",{children:[e.jsx("h1",{children:n.manifest.name}),e.jsx("p",{children:n.manifest.description??n.definition.id})]}),e.jsxs("div",{className:"plugins-list-tags",children:[e.jsx(o,{tone:n.enablement.enabled?"success":"default",children:n.enablement.enabled?s("plugins.enabled"):s("plugins.disabled")}),e.jsx(o,{children:`v${n.manifest.version}`})]})]}),e.jsx(u,{heading:s("plugins.summaryTitle"),description:s("plugins.summaryDescription"),children:e.jsxs(f,{children:[e.jsx(d,{label:s("plugins.pluginIdLabel"),description:n.definition.id}),e.jsx(d,{label:s("plugins.installRootLabel"),description:n.definition.installRoot}),e.jsx(d,{label:s("plugins.runtimeLabel"),description:n.manifest.backend?`${s("plugins.backendTag")} · ${n.manifest.backend.mode??"on_demand"}`:s("plugins.frontendOnly")})]})}),e.jsx(u,{heading:s("plugins.permissionTitle"),description:s("plugins.permissionDescription"),children:e.jsxs("div",{className:"plugins-list-tags",children:[e.jsx(o,{tone:n.manifest.permissions.workspaceRead?"success":"default",children:n.manifest.permissions.workspaceRead?s("plugins.workspaceReadAllowed"):s("plugins.workspaceReadDenied")}),e.jsx(o,{tone:n.manifest.permissions.network?"warning":"default",children:n.manifest.permissions.network?s("plugins.networkAllowed"):s("plugins.networkDenied")}),P.length>0?P.map(i=>e.jsx(o,{children:i},i)):e.jsx(o,{tone:"default",children:s("plugins.noDesktopPermission")})]})}),e.jsx(J,{grants:L,auditEvents:n.auditEvents,loading:I,revokingGrantId:y,onRevokeGrant:i=>{C(i)}}),(E=(N=n.manifest.backend)==null?void 0:N.actions)!=null&&E.length?e.jsx(u,{heading:s("plugins.actionTitle"),description:s("plugins.actionDescription"),children:e.jsx(f,{children:n.manifest.backend.actions.map(i=>e.jsx(d,{label:i.title,description:`${i.id} · ${i.timeoutMs??3e4}ms`},i.id))})}):null,e.jsx(u,{heading:s("plugins.runHistoryTitle"),description:s("plugins.runHistoryDescription"),children:b.length===0?e.jsx(R,{title:s("plugins.runHistoryEmptyTitle"),description:s("plugins.runHistoryEmptyDescription")}):e.jsx(f,{children:b.slice(0,10).map(i=>e.jsx(d,{label:i.actionId??s("plugins.unknownAction"),description:`${i.status} · ${i.createdAt}`,trailing:i.errorCode?e.jsx(o,{tone:"danger",children:i.errorCode}):null},i.id))})}),e.jsxs($,{align:"between",stack:!0,children:[e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>p(S(r)),children:s("plugins.backToList")}),e.jsxs("div",{className:"plugins-detail-actions",children:[n.frontend?e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>p(H(r,n.definition.id)),children:s("plugins.openPlugin")}):null,e.jsx("button",{type:"button",className:n.enablement.enabled?"secondary-button":"primary-button",disabled:j,onClick:()=>{A()},children:n.enablement.enabled?s("plugins.disableAction"):s("plugins.enableAction")})]})]})]})}):e.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root plugins-page",children:e.jsx("article",{className:"surface-card plugins-panel",children:e.jsx(R,{title:s("plugins.detailMissingTitle"),description:s("plugins.detailMissingDescription"),action:e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>p(S(r)),children:s("plugins.backToList")})})})})}export{se as PluginDetailPage};
@@ -1 +1 @@
1
- import{b as i,t as a,j as e}from"./index-BilHJjYU.js";import{H as m,t as g,u as h,N as f,v as n}from"./workbench-navigation-ED0157V-.js";import{c as x,u as j,f as b}from"./App-CHsm-VrM.js";import{l as N}from"./plugins-api-COF4oh24.js";function E(){const{workspaceId:d=""}=x(),u=j(),{showToast:r}=b(),[l,p]=i.useState([]),[o,c]=i.useState(!0);return i.useEffect(()=>{let s=!1;return c(!0),N().then(t=>{s||p(t.items)}).catch(t=>{s||r({title:t instanceof Error?t.message:a("plugins.listLoadFailed"),tone:"error"})}).finally(()=>{s||c(!1)}),()=>{s=!0}},[r]),e.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root plugins-page",children:e.jsxs("article",{className:"surface-card plugins-panel",children:[e.jsx("header",{className:"plugins-page-header",children:e.jsxs("div",{children:[e.jsx("h1",{children:a("plugins.listTitle")}),e.jsx("p",{children:a("plugins.listDescription")})]})}),o?e.jsx("p",{className:"plugins-hint-text",children:a("plugins.loading")}):null,!o&&l.length===0?e.jsx(m,{title:a("plugins.emptyTitle"),description:a("plugins.emptyDescription")}):null,l.length>0?e.jsx(g,{className:"plugins-list",children:l.map(s=>e.jsx(h,{as:"button",className:"plugins-list-item",label:s.name,description:`${s.id} · v${s.version}`,trailing:e.jsxs("div",{className:"plugins-list-tags",children:[e.jsx(n,{tone:s.enabled?"success":"default",children:s.enabled?a("plugins.enabled"):a("plugins.disabled")}),s.hasFrontend?e.jsx(n,{children:a("plugins.frontendTag")}):null,s.hasBackend?e.jsx(n,{children:a("plugins.backendTag")}):null]}),onClick:()=>u(f(d,s.id))},s.id))}):null]})})}export{E as PluginsListPage};
1
+ import{b as i,t as a,j as e}from"./index-CILPuSCp.js";import{H as m,t as g,u as h,N as f,v as n}from"./workbench-navigation-hwM28xIb.js";import{c as x,u as j,f as b}from"./App-D5hc6KuU.js";import{l as N}from"./plugins-api-BGF9OybZ.js";function E(){const{workspaceId:d=""}=x(),u=j(),{showToast:r}=b(),[l,p]=i.useState([]),[o,c]=i.useState(!0);return i.useEffect(()=>{let s=!1;return c(!0),N().then(t=>{s||p(t.items)}).catch(t=>{s||r({title:t instanceof Error?t.message:a("plugins.listLoadFailed"),tone:"error"})}).finally(()=>{s||c(!1)}),()=>{s=!0}},[r]),e.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root plugins-page",children:e.jsxs("article",{className:"surface-card plugins-panel",children:[e.jsx("header",{className:"plugins-page-header",children:e.jsxs("div",{children:[e.jsx("h1",{children:a("plugins.listTitle")}),e.jsx("p",{children:a("plugins.listDescription")})]})}),o?e.jsx("p",{className:"plugins-hint-text",children:a("plugins.loading")}):null,!o&&l.length===0?e.jsx(m,{title:a("plugins.emptyTitle"),description:a("plugins.emptyDescription")}):null,l.length>0?e.jsx(g,{className:"plugins-list",children:l.map(s=>e.jsx(h,{as:"button",className:"plugins-list-item",label:s.name,description:`${s.id} · v${s.version}`,trailing:e.jsxs("div",{className:"plugins-list-tags",children:[e.jsx(n,{tone:s.enabled?"success":"default",children:s.enabled?a("plugins.enabled"):a("plugins.disabled")}),s.hasFrontend?e.jsx(n,{children:a("plugins.frontendTag")}):null,s.hasBackend?e.jsx(n,{children:a("plugins.backendTag")}):null]}),onClick:()=>u(f(d,s.id))},s.id))}):null]})})}export{E as PluginsListPage};
@@ -1 +1 @@
1
- import{b as a,j as l}from"./index-BilHJjYU.js";import{b as k,b7 as C,b8 as L,b9 as x,ba as N,bb as P,bc as A}from"./WorkbenchLayout-Bo2BbMY6.js";import{L as D}from"./workbench-navigation-ED0157V-.js";import{c as R,h as W,u as j}from"./App-CHsm-VrM.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./host-alias-Zb2xyVrf.js";import"./DesktopModal-Csj5AdAN.js";import"./relay-entry-Cmc8vTlE.js";import"./WorkbenchModal-YsyEdJ_m.js";import"./MobileSheet-Co-qPMBD.js";const E="codex";function M(t){var r;return((r=new URLSearchParams(t).get("provider"))==null?void 0:r.trim())==="claude-code"?"claude-code":E}function G(t){const o=(t==null?void 0:t.trim())??"",r="conversation:lightweight:session:";return o.startsWith(r)&&o.slice(r.length).trim()||null}function J(){var g,v;const t=R(),o=W(),r=j(),{navigationGroups:c,currentWorkspaceRef:u,currentWorkspaceId:w,refreshNavigation:b}=k(),e=((g=t.workspaceId)==null?void 0:g.trim())||w,s=((v=t.chatId)==null?void 0:v.trim())??null,d=!s||s==="new",I=a.useMemo(()=>{var n;return((n=c.find(i=>i.workspace.id===e))==null?void 0:n.workspace.name)??null},[c,e]),h=a.useMemo(()=>M(o.search),[o.search]),f=a.useMemo(()=>({kind:"lightweight",provider:h}),[h]),m=d?C(f):L("lightweight",s),p=a.useMemo(()=>e?{...x(e),primarySection:"conversation",selectedNodeId:m,selectedObjectId:null,selectedDocumentId:null,pendingLibraryPreview:null}:null,[m,e]),S=a.useCallback(n=>{const i=G(n.selectedNodeId);if(e&&i&&i!==s){r(D(e,i,u),{replace:!0});return}},[u,r,s,e]);return!e||!p?null:l.jsx(N,{workspaceId:e,workspaceName:I,navigationGroups:c,state:p,onStateChange:S,onRefreshNavigation:b,forceRoute:!1,children:d?l.jsx(P,{workspaceId:e,draft:f}):l.jsx(A,{sessionId:s,runtimeSeed:null})})}export{J as PureConversationPage};
1
+ import{b as a,j as l}from"./index-CILPuSCp.js";import{b as k,b7 as C,b8 as L,b9 as x,ba as N,bb as P,bc as A}from"./WorkbenchLayout-yGxGKcG1.js";import{L as D}from"./workbench-navigation-hwM28xIb.js";import{c as R,h as W,u as j}from"./App-D5hc6KuU.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./host-alias-df5bYDlE.js";import"./DesktopModal-BCVZq_PQ.js";import"./relay-entry-ErQKnI7B.js";import"./WorkbenchModal-Cm-ciXO9.js";import"./MobileSheet-DPYtp5Ze.js";const E="codex";function M(t){var r;return((r=new URLSearchParams(t).get("provider"))==null?void 0:r.trim())==="claude-code"?"claude-code":E}function G(t){const o=(t==null?void 0:t.trim())??"",r="conversation:lightweight:session:";return o.startsWith(r)&&o.slice(r.length).trim()||null}function J(){var g,v;const t=R(),o=W(),r=j(),{navigationGroups:c,currentWorkspaceRef:u,currentWorkspaceId:w,refreshNavigation:b}=k(),e=((g=t.workspaceId)==null?void 0:g.trim())||w,s=((v=t.chatId)==null?void 0:v.trim())??null,d=!s||s==="new",I=a.useMemo(()=>{var n;return((n=c.find(i=>i.workspace.id===e))==null?void 0:n.workspace.name)??null},[c,e]),h=a.useMemo(()=>M(o.search),[o.search]),f=a.useMemo(()=>({kind:"lightweight",provider:h}),[h]),m=d?C(f):L("lightweight",s),p=a.useMemo(()=>e?{...x(e),primarySection:"conversation",selectedNodeId:m,selectedObjectId:null,selectedDocumentId:null,pendingLibraryPreview:null}:null,[m,e]),S=a.useCallback(n=>{const i=G(n.selectedNodeId);if(e&&i&&i!==s){r(D(e,i,u),{replace:!0});return}},[u,r,s,e]);return!e||!p?null:l.jsx(N,{workspaceId:e,workspaceName:I,navigationGroups:c,state:p,onStateChange:S,onRefreshNavigation:b,forceRoute:!1,children:d?l.jsx(P,{workspaceId:e,draft:f}):l.jsx(A,{sessionId:s,runtimeSeed:null})})}export{J as PureConversationPage};
@@ -1 +1 @@
1
- import{p as m,b as d,e as g,j as n,t as i}from"./index-BilHJjYU.js";import{u as p,c as f,d as y}from"./App-CHsm-VrM.js";import{b as E}from"./relay-entry-Cmc8vTlE.js";function I(){const r=p(),{tunnelDomain:t}=f(),[e]=y(),s=m(),[a,c]=d.useState(null);return d.useEffect(()=>{var u;const l=((u=e.get("controlBaseUrl"))==null?void 0:u.trim())??"";if(!t||!l){c(s("auth.relayEntryInvalid"));return}let o=!1;const h=x(e.get("returnTo"));return g.update(E(g.getState(),{tunnelDomain:t,controlBaseUrl:l,bindingId:e.get("bindingId"),hostFingerprint:e.get("hostFingerprint")})).then(()=>{o||r(`/login?returnTo=${encodeURIComponent(h)}`,{replace:!0})}).catch(()=>{o||c(s("auth.relayEntryInvalid"))}),()=>{o=!0}},[r,e,s,t]),n.jsxs("section",{children:[n.jsx("h1",{children:i("auth.relayEntryTitle")}),n.jsx("p",{children:i("auth.relayEntryDescription")}),a?n.jsx("p",{children:a}):null,a?null:n.jsx("p",{children:i("common.loading")})]})}function x(r){const t=r==null?void 0:r.trim();return!t||!t.startsWith("/")?"/":t}export{I as RelayConnectEntryPage};
1
+ import{p as m,b as d,e as g,j as n,t as i}from"./index-CILPuSCp.js";import{u as p,c as f,d as y}from"./App-D5hc6KuU.js";import{b as E}from"./relay-entry-ErQKnI7B.js";function I(){const r=p(),{tunnelDomain:t}=f(),[e]=y(),s=m(),[a,c]=d.useState(null);return d.useEffect(()=>{var u;const l=((u=e.get("controlBaseUrl"))==null?void 0:u.trim())??"";if(!t||!l){c(s("auth.relayEntryInvalid"));return}let o=!1;const h=x(e.get("returnTo"));return g.update(E(g.getState(),{tunnelDomain:t,controlBaseUrl:l,bindingId:e.get("bindingId"),hostFingerprint:e.get("hostFingerprint")})).then(()=>{o||r(`/login?returnTo=${encodeURIComponent(h)}`,{replace:!0})}).catch(()=>{o||c(s("auth.relayEntryInvalid"))}),()=>{o=!0}},[r,e,s,t]),n.jsxs("section",{children:[n.jsx("h1",{children:i("auth.relayEntryTitle")}),n.jsx("p",{children:i("auth.relayEntryDescription")}),a?n.jsx("p",{children:a}):null,a?null:n.jsx("p",{children:i("common.loading")})]})}function x(r){const t=r==null?void 0:r.trim();return!t||!t.startsWith("/")?"/":t}export{I as RelayConnectEntryPage};
@@ -1 +1 @@
1
- import{b as n,n as U,j as r,t as s,e as N}from"./index-BilHJjYU.js";import{r as E,b as k}from"./relay-entry-Cmc8vTlE.js";import{a as h,B as O,C as P,D as w}from"./App-CHsm-VrM.js";import{W as T}from"./WorkbenchModal-YsyEdJ_m.js";import"./DesktopModal-Csj5AdAN.js";function A({isOpen:t,onClose:u,onSave:c,theme:V="dark"}){const d=h(e=>e.baseUrl),B=h(e=>e.options),p=h(e=>e.presetOptions),f=P(),[i,o]=n.useState(d),[g,l]=n.useState(null),[v,m]=n.useState(!1),a=n.useMemo(()=>{try{return U(i)}catch{return null}},[i]),x=O(a??i,B),S=p.find(e=>e.value===x)??null,b="server-settings-preset",j="server-settings-address";if(n.useEffect(()=>{t&&(o(d),l(null),m(!1))},[t,d]),!t)return null;async function C(){if(!a){l(s("auth.serverInvalid"));return}m(!0);try{const e=await E(a);e?await N.update(k(N.getState(),e)):w.setBaseUrl(a),c==null||c(a),u()}catch(e){l(e instanceof Error&&e.message.trim()?e.message:s("auth.serverInvalid"))}finally{m(!1)}}function I(){a&&o(a)}return r.jsx(T,{open:t,title:s("auth.serverSettingsTitle"),description:s("auth.serverHint"),className:"server-settings-modal-card",onClose:u,children:r.jsxs("form",{className:"server-settings-modal-form",onSubmit:e=>{e.preventDefault(),C()},children:[r.jsxs("label",{className:"workbench-modal-field",htmlFor:b,children:[r.jsx("span",{children:s("auth.serverPreset")}),r.jsxs("select",{id:b,"aria-label":s("auth.serverPreset"),value:x,onChange:e=>{const y=e.target.value;y!==f&&(o(y),l(null))},children:[p.map(e=>r.jsx("option",{value:e.value,children:D(e)},`${e.source}:${e.value}`)),r.jsx("option",{value:f,children:s("auth.serverCustomOption")})]})]}),S?r.jsx("div",{className:"server-settings-modal-tags","aria-live":"polite",children:S.source==="discovered"?r.jsx("span",{className:"server-settings-modal-tag","data-tone":"discovered",children:s("auth.serverDiscoveredTag")}):null}):null,r.jsxs("label",{className:"workbench-modal-field",htmlFor:j,children:[r.jsx("span",{children:s("auth.serverAddress")}),r.jsx("input",{id:j,"aria-label":s("auth.serverAddress"),value:i,placeholder:s("auth.serverPlaceholder"),disabled:v,onBlur:I,onChange:e=>{o(e.target.value),l(null)}})]}),g?r.jsx("p",{className:"server-settings-modal-status","data-tone":"error",children:g}):r.jsx("p",{className:"server-settings-modal-hint",children:s("auth.serverHint")}),r.jsxs("div",{className:"workbench-modal-actions",children:[r.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:s("common.cancel")}),r.jsx("button",{type:"submit",className:"primary-button",disabled:v,children:v?s("common.loading"):s("auth.saveServerSettings")})]})]})})}function D(t){return t.source==="discovered"?`${t.value} · ${s("auth.serverDiscoveredTag")}`:t.value}export{A as ServerSettingsModal};
1
+ import{b as n,n as E,j as r,t as s,e as N}from"./index-CILPuSCp.js";import{r as U,b as k}from"./relay-entry-ErQKnI7B.js";import{a as h,C as O,D as P,E as w}from"./App-D5hc6KuU.js";import{W as T}from"./WorkbenchModal-Cm-ciXO9.js";import"./DesktopModal-BCVZq_PQ.js";function A({isOpen:t,onClose:u,onSave:c,theme:V="dark"}){const d=h(e=>e.baseUrl),B=h(e=>e.options),p=h(e=>e.presetOptions),f=P(),[i,o]=n.useState(d),[g,l]=n.useState(null),[v,m]=n.useState(!1),a=n.useMemo(()=>{try{return E(i)}catch{return null}},[i]),x=O(a??i,B),S=p.find(e=>e.value===x)??null,b="server-settings-preset",j="server-settings-address";if(n.useEffect(()=>{t&&(o(d),l(null),m(!1))},[t,d]),!t)return null;async function C(){if(!a){l(s("auth.serverInvalid"));return}m(!0);try{const e=await U(a);e?await N.update(k(N.getState(),e)):w.setBaseUrl(a),c==null||c(a),u()}catch(e){l(e instanceof Error&&e.message.trim()?e.message:s("auth.serverInvalid"))}finally{m(!1)}}function I(){a&&o(a)}return r.jsx(T,{open:t,title:s("auth.serverSettingsTitle"),description:s("auth.serverHint"),className:"server-settings-modal-card",onClose:u,children:r.jsxs("form",{className:"server-settings-modal-form",onSubmit:e=>{e.preventDefault(),C()},children:[r.jsxs("label",{className:"workbench-modal-field",htmlFor:b,children:[r.jsx("span",{children:s("auth.serverPreset")}),r.jsxs("select",{id:b,"aria-label":s("auth.serverPreset"),value:x,onChange:e=>{const y=e.target.value;y!==f&&(o(y),l(null))},children:[p.map(e=>r.jsx("option",{value:e.value,children:D(e)},`${e.source}:${e.value}`)),r.jsx("option",{value:f,children:s("auth.serverCustomOption")})]})]}),S?r.jsx("div",{className:"server-settings-modal-tags","aria-live":"polite",children:S.source==="discovered"?r.jsx("span",{className:"server-settings-modal-tag","data-tone":"discovered",children:s("auth.serverDiscoveredTag")}):null}):null,r.jsxs("label",{className:"workbench-modal-field",htmlFor:j,children:[r.jsx("span",{children:s("auth.serverAddress")}),r.jsx("input",{id:j,"aria-label":s("auth.serverAddress"),value:i,placeholder:s("auth.serverPlaceholder"),disabled:v,onBlur:I,onChange:e=>{o(e.target.value),l(null)}})]}),g?r.jsx("p",{className:"server-settings-modal-status","data-tone":"error",children:g}):r.jsx("p",{className:"server-settings-modal-hint",children:s("auth.serverHint")}),r.jsxs("div",{className:"workbench-modal-actions",children:[r.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:s("common.cancel")}),r.jsx("button",{type:"submit",className:"primary-button",disabled:v,children:v?s("common.loading"):s("auth.saveServerSettings")})]})]})})}function D(t){return t.source==="discovered"?`${t.value} · ${s("auth.serverDiscoveredTag")}`:t.value}export{A as ServerSettingsModal};