@jingyi0605/codingns 0.9.7 → 0.9.9

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 (202) hide show
  1. package/dist/public/assets/{AdaptiveButlerPage-DclGPzEx.js → AdaptiveButlerPage-CqBM1XiC.js} +2 -2
  2. package/dist/public/assets/{App-CcDXqFl1.css → App-7zrCMhE-.css} +1 -1
  3. package/dist/public/assets/App-Pe30N_Dy.js +30 -0
  4. package/dist/public/assets/{BootstrapPage-Bl21SsuW.js → BootstrapPage-D9ai1XhC.js} +1 -1
  5. package/dist/public/assets/ConversationPage-C8aU99KN.js +9 -0
  6. package/dist/public/assets/{DesktopDetachPreviewPage-uaOHVsjV.js → DesktopDetachPreviewPage-BJVPVFf2.js} +1 -1
  7. package/dist/public/assets/{DesktopModal-BxsogpLf.js → DesktopModal-DyC_e0eF.js} +1 -1
  8. package/dist/public/assets/DesktopWindowPage-BZleww0T.js +2 -0
  9. package/dist/public/assets/FileContextPanel-BklQRQXj.js +1 -0
  10. package/dist/public/assets/GitSidebar-D0tb3W87.js +6 -0
  11. package/dist/public/assets/MobileCreateSessionSheet-BS881Agk.js +1 -0
  12. package/dist/public/assets/{MobileSheet-C5IVmUsO.js → MobileSheet-C32hwIFd.js} +1 -1
  13. package/dist/public/assets/PluginAccessOverview-BDiz6fV8.js +1 -0
  14. package/dist/public/assets/{PluginContainerPage-_2u-9thM.js → PluginContainerPage-BMT6J0YS.js} +1 -1
  15. package/dist/public/assets/{PluginDetailPage-F9cKjSCp.js → PluginDetailPage-ztNhvCWP.js} +1 -1
  16. package/dist/public/assets/{PluginsListPage-BOhcua_4.js → PluginsListPage-Cuk2-U6E.js} +1 -1
  17. package/dist/public/assets/PureConversationPage-ShluI2En.js +1 -0
  18. package/dist/public/assets/{RelayConnectEntryPage-Ck_uZLzj.js → RelayConnectEntryPage-CMbjlD0k.js} +1 -1
  19. package/dist/public/assets/{ServerSettingsModal-ICd82a_x.js → ServerSettingsModal-CLSWyHu6.js} +1 -1
  20. package/dist/public/assets/SessionIndexPage-dqfauVAj.js +1 -0
  21. package/dist/public/assets/SettingsPage-PUga-wwJ.js +2 -0
  22. package/dist/public/assets/TerminalManagerPanel-75khWhRz.js +1 -0
  23. package/dist/public/assets/ToolFilesPage-S3eWxO_D.js +1 -0
  24. package/dist/public/assets/ToolGitPage-8RAMpope.js +1 -0
  25. package/dist/public/assets/ToolProcessesPage-TZACKEoH.js +1 -0
  26. package/dist/public/assets/ToolsHomePage-Whgu6Tyf.js +1 -0
  27. package/dist/public/assets/WorkbenchLandingPage-CC24vHza.js +1 -0
  28. package/dist/public/assets/{WorkbenchLayout-BksVkkFF.css → WorkbenchLayout-BZdfVest.css} +32 -1
  29. package/dist/public/assets/WorkbenchLayout-CoYxMzzR.js +1081 -0
  30. package/dist/public/assets/{WorkbenchModal-CsZeLArg.js → WorkbenchModal-2PaCY_Gj.js} +1 -1
  31. package/dist/public/assets/WorkbenchShellRoute-DLVRpGzb.css +1 -0
  32. package/dist/public/assets/WorkbenchShellRoute-QXztW_Ny.js +1 -0
  33. package/dist/public/assets/WorkspaceDebugDetailPage-Ce_oMmJ8.js +1 -0
  34. package/dist/public/assets/WorkspaceDetailPage-aX6w4Q7S.js +1 -0
  35. package/dist/public/assets/WorkspaceHomePage-DQttgj2w.js +1 -0
  36. package/dist/public/assets/{client-runtime-manager-BgGugw8T.js → client-runtime-manager-CGVLChqs.js} +1 -1
  37. package/dist/public/assets/host-alias-CeDJeL0T.js +1 -0
  38. package/dist/public/assets/index-BehUkul4.css +1 -0
  39. package/dist/public/assets/index-Bp1FnRo_.js +50 -0
  40. package/dist/public/assets/{login-direct-candidate-resolver-ty2uOY5y.js → login-direct-candidate-resolver-Bvs5uPix.js} +1 -1
  41. package/dist/public/assets/peer-host-config-sync-oelf2T0_.js +1 -0
  42. package/dist/public/assets/{plugin-permission-copy-iK3faI3n.js → plugin-permission-copy-Do028HzJ.js} +1 -1
  43. package/dist/public/assets/{plugins-api-CmV7aDGA.js → plugins-api-BOugklJ-.js} +1 -1
  44. package/dist/public/assets/{preferences-service-BoSmT_ny.js → preferences-service-Dys1mbBy.js} +1 -1
  45. package/dist/public/assets/relay-entry-B6UDc5cD.js +1 -0
  46. package/dist/public/assets/useRegisteredDebugTemplates-BafVuBvE.js +1 -0
  47. package/dist/public/assets/workbench-navigation-Bs4OQYD3.js +1 -0
  48. package/dist/public/index.html +2 -2
  49. package/dist/server/middlewares/auth-guard.js +1 -0
  50. package/dist/server/middlewares/auth-guard.js.map +1 -1
  51. package/dist/server/modules/assistant-capability/assistant-capability-controller.d.ts +3 -0
  52. package/dist/server/modules/assistant-capability/assistant-capability-controller.js +9 -0
  53. package/dist/server/modules/assistant-capability/assistant-capability-controller.js.map +1 -1
  54. package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +3 -0
  55. package/dist/server/modules/assistant-capability/assistant-capability-service.js +4 -1
  56. package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
  57. package/dist/server/modules/peer-host/host-api-proxy-service.d.ts +9 -0
  58. package/dist/server/modules/peer-host/host-api-proxy-service.js +174 -0
  59. package/dist/server/modules/peer-host/host-api-proxy-service.js.map +1 -0
  60. package/dist/server/modules/peer-host/host-handshake-controller.d.ts +7 -0
  61. package/dist/server/modules/peer-host/host-handshake-controller.js +10 -0
  62. package/dist/server/modules/peer-host/host-handshake-controller.js.map +1 -0
  63. package/dist/server/modules/peer-host/host-handshake.d.ts +15 -0
  64. package/dist/server/modules/peer-host/host-handshake.js +20 -0
  65. package/dist/server/modules/peer-host/host-handshake.js.map +1 -0
  66. package/dist/server/modules/peer-host/host-ws-proxy-service.d.ts +14 -0
  67. package/dist/server/modules/peer-host/host-ws-proxy-service.js +256 -0
  68. package/dist/server/modules/peer-host/host-ws-proxy-service.js.map +1 -0
  69. package/dist/server/modules/peer-host/peer-host-controller.d.ts +55 -0
  70. package/dist/server/modules/peer-host/peer-host-controller.js +62 -0
  71. package/dist/server/modules/peer-host/peer-host-controller.js.map +1 -0
  72. package/dist/server/modules/peer-host/peer-host-service.d.ts +77 -0
  73. package/dist/server/modules/peer-host/peer-host-service.js +529 -0
  74. package/dist/server/modules/peer-host/peer-host-service.js.map +1 -0
  75. package/dist/server/modules/sessions/codex-session-title-generator.js +18 -5
  76. package/dist/server/modules/sessions/codex-session-title-generator.js.map +1 -1
  77. package/dist/server/modules/sessions/session-controller.d.ts +10 -0
  78. package/dist/server/modules/sessions/session-controller.js +11 -0
  79. package/dist/server/modules/sessions/session-controller.js.map +1 -1
  80. package/dist/server/modules/sessions/session-history-service.d.ts +54 -2
  81. package/dist/server/modules/sessions/session-history-service.js +407 -63
  82. package/dist/server/modules/sessions/session-history-service.js.map +1 -1
  83. package/dist/server/modules/sessions/session-live-runtime-service.d.ts +6 -0
  84. package/dist/server/modules/sessions/session-live-runtime-service.js +181 -80
  85. package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
  86. package/dist/server/modules/sessions/session-title-utils.d.ts +3 -0
  87. package/dist/server/modules/sessions/session-title-utils.js +25 -0
  88. package/dist/server/modules/sessions/session-title-utils.js.map +1 -0
  89. package/dist/server/modules/sessions/workspace-office-mcp-config.d.ts +2 -1
  90. package/dist/server/modules/sessions/workspace-office-mcp-config.js +44 -3
  91. package/dist/server/modules/sessions/workspace-office-mcp-config.js.map +1 -1
  92. package/dist/server/modules/tasks/observability-controller.d.ts +2 -0
  93. package/dist/server/modules/tasks/observability-controller.js +16 -1
  94. package/dist/server/modules/tasks/observability-controller.js.map +1 -1
  95. package/dist/server/modules/tasks/observability-service.d.ts +12 -2
  96. package/dist/server/modules/tasks/observability-service.js +16 -3
  97. package/dist/server/modules/tasks/observability-service.js.map +1 -1
  98. package/dist/server/modules/tasks/task-manager.d.ts +2 -1
  99. package/dist/server/modules/tasks/task-manager.js +3 -0
  100. package/dist/server/modules/tasks/task-manager.js.map +1 -1
  101. package/dist/server/modules/tasks/task-scheduler.d.ts +2 -1
  102. package/dist/server/modules/tasks/task-scheduler.js +21 -0
  103. package/dist/server/modules/tasks/task-scheduler.js.map +1 -1
  104. package/dist/server/modules/tasks/task-types.d.ts +5 -0
  105. package/dist/server/modules/tasks/task-types.js.map +1 -1
  106. package/dist/server/modules/workbench/workbench-controller.js +3 -2
  107. package/dist/server/modules/workbench/workbench-controller.js.map +1 -1
  108. package/dist/server/modules/workbench/workbench-service.d.ts +2 -0
  109. package/dist/server/modules/workbench/workbench-service.js +162 -19
  110. package/dist/server/modules/workbench/workbench-service.js.map +1 -1
  111. package/dist/server/modules/workspace/affairs-library-controller.d.ts +1 -0
  112. package/dist/server/modules/workspace/affairs-library-controller.js +3 -0
  113. package/dist/server/modules/workspace/affairs-library-controller.js.map +1 -1
  114. package/dist/server/modules/workspace/affairs-library-service.d.ts +5 -0
  115. package/dist/server/modules/workspace/affairs-library-service.js +103 -4
  116. package/dist/server/modules/workspace/affairs-library-service.js.map +1 -1
  117. package/dist/server/modules/workspace/workspace-controller.d.ts +7 -1
  118. package/dist/server/modules/workspace/workspace-controller.js +11 -1
  119. package/dist/server/modules/workspace/workspace-controller.js.map +1 -1
  120. package/dist/server/modules/workspace/workspace-service.d.ts +9 -2
  121. package/dist/server/modules/workspace/workspace-service.js +45 -10
  122. package/dist/server/modules/workspace/workspace-service.js.map +1 -1
  123. package/dist/server/routes/affairs.js +4 -0
  124. package/dist/server/routes/affairs.js.map +1 -1
  125. package/dist/server/routes/peer-hosts.d.ts +3 -0
  126. package/dist/server/routes/peer-hosts.js +18 -0
  127. package/dist/server/routes/peer-hosts.js.map +1 -0
  128. package/dist/server/routes/public.d.ts +2 -1
  129. package/dist/server/routes/public.js +2 -1
  130. package/dist/server/routes/public.js.map +1 -1
  131. package/dist/server/routes/sessions.js +2 -0
  132. package/dist/server/routes/sessions.js.map +1 -1
  133. package/dist/server/server/create-server.d.ts +4 -0
  134. package/dist/server/server/create-server.js +31 -3
  135. package/dist/server/server/create-server.js.map +1 -1
  136. package/dist/server/shared/http/error-handler.js +12 -0
  137. package/dist/server/shared/http/error-handler.js.map +1 -1
  138. package/dist/server/storage/repositories/peer-host-repository.d.ts +44 -0
  139. package/dist/server/storage/repositories/peer-host-repository.js +271 -0
  140. package/dist/server/storage/repositories/peer-host-repository.js.map +1 -0
  141. package/dist/server/storage/repositories/session-discovery-diagnostics-repository.d.ts +10 -0
  142. package/dist/server/storage/repositories/session-discovery-diagnostics-repository.js +68 -0
  143. package/dist/server/storage/repositories/session-discovery-diagnostics-repository.js.map +1 -0
  144. package/dist/server/storage/repositories/session-source-index-repository.d.ts +14 -0
  145. package/dist/server/storage/repositories/session-source-index-repository.js +164 -0
  146. package/dist/server/storage/repositories/session-source-index-repository.js.map +1 -0
  147. package/dist/server/storage/repositories/workspace-navigation-state-repository.js +16 -7
  148. package/dist/server/storage/repositories/workspace-navigation-state-repository.js.map +1 -1
  149. package/dist/server/storage/sqlite/client.js +107 -0
  150. package/dist/server/storage/sqlite/client.js.map +1 -1
  151. package/dist/server/storage/sqlite/schema.sql +121 -0
  152. package/dist/server/types/domain.d.ts +88 -0
  153. package/dist/server/ws/workbench-ws-hub.js +5 -14
  154. package/dist/server/ws/workbench-ws-hub.js.map +1 -1
  155. package/dist/server/ws/ws-server.d.ts +2 -1
  156. package/dist/server/ws/ws-server.js +5 -1
  157. package/dist/server/ws/ws-server.js.map +1 -1
  158. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js +19 -2
  159. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js.map +1 -1
  160. package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +1 -0
  161. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +74 -6
  162. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
  163. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +11 -4
  164. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -1
  165. package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js +8 -1
  166. package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js.map +1 -1
  167. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.d.ts +3 -0
  168. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +144 -27
  169. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
  170. package/package.json +1 -1
  171. package/dist/public/assets/App-BxX5mm9o.js +0 -30
  172. package/dist/public/assets/ConversationPage-CmiVCV0q.js +0 -9
  173. package/dist/public/assets/DesktopWindowPage-Bubfw1nC.js +0 -2
  174. package/dist/public/assets/FileContextPanel-DrYWcTkp.js +0 -1
  175. package/dist/public/assets/GitSidebar-CQsfJqun.js +0 -6
  176. package/dist/public/assets/MobileCreateSessionSheet-CqtmfVNo.js +0 -1
  177. package/dist/public/assets/MobileTopHeaderFrame-EoBm3-X0.js +0 -1
  178. package/dist/public/assets/MobileWorkspaceSwitcherHeader-BC8MMQs_.js +0 -1
  179. package/dist/public/assets/PluginAccessOverview-CrQiQxxZ.js +0 -1
  180. package/dist/public/assets/SessionIndexPage-Cox6P6dw.js +0 -1
  181. package/dist/public/assets/SettingsPage-BI5cM3j5.js +0 -2
  182. package/dist/public/assets/TerminalManagerPanel-DiVhBQhf.js +0 -1
  183. package/dist/public/assets/TerminalPage-6GBZ9nXN.css +0 -32
  184. package/dist/public/assets/TerminalPage-DUMUO7Ng.js +0 -55
  185. package/dist/public/assets/TerminalRuntimeFallbackModal-DGPR_CMh.js +0 -1
  186. package/dist/public/assets/ToolFilesPage-m88CAp-r.js +0 -1
  187. package/dist/public/assets/ToolGitPage-DCYpfTsb.js +0 -1
  188. package/dist/public/assets/ToolProcessesPage-Bk5ulsyq.js +0 -1
  189. package/dist/public/assets/ToolsHomePage-BrTwfjI7.js +0 -1
  190. package/dist/public/assets/WorkbenchLandingPage-q4AAmdMV.js +0 -1
  191. package/dist/public/assets/WorkbenchLayout-DD8b-m2G.js +0 -1027
  192. package/dist/public/assets/WorkbenchShellRoute-BaiW_vfb.js +0 -1
  193. package/dist/public/assets/WorkbenchShellRoute-CxKYZ6uF.css +0 -1
  194. package/dist/public/assets/WorkspaceDebugDetailPage-BcUUDEyw.js +0 -1
  195. package/dist/public/assets/WorkspaceDetailPage-zEZ1VARA.js +0 -1
  196. package/dist/public/assets/WorkspaceHomePage-CR0rqS4e.js +0 -1
  197. package/dist/public/assets/index-CFyk1rgJ.js +0 -50
  198. package/dist/public/assets/index-CrU73EIV.css +0 -1
  199. package/dist/public/assets/relay-entry-C8k5qsl5.js +0 -1
  200. package/dist/public/assets/terminal-runtime-meta-okQIDzfA.js +0 -1
  201. package/dist/public/assets/useRegisteredDebugTemplates-B_vXUtSe.js +0 -1
  202. package/dist/public/assets/workbench-navigation-DoDaQR4z.js +0 -1
@@ -0,0 +1 @@
1
+ import{b as c,E as nn,j as i,t as o,F as dt,B as ni}from"./index-Bp1FnRo_.js";import{f as ii,e as Li,g as Bi}from"./App-Pe30N_Dy.js";import{bU as Wi,bV as Hi,bW as ai,bX as an,bY as $i,bZ as Rt,b_ as Tt,b as Oi,u as Vi,ar as Fe,b$ as Jt,c0 as Ui,c1 as zi,c2 as Ki,c3 as ft,c4 as Ct,c5 as qe,c6 as Gi,c7 as Xi,c8 as qi,c9 as Ii,ca as Yi}from"./WorkbenchLayout-CoYxMzzR.js";import{s as Zi,w as Ji}from"./workbench-navigation-Bs4OQYD3.js";import{W as $n}from"./WorkbenchModal-2PaCY_Gj.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./host-alias-CeDJeL0T.js";import"./DesktopModal-DyC_e0eF.js";import"./relay-entry-B6UDc5cD.js";import"./MobileSheet-C32hwIFd.js";async function Dt(t,n,l={}){const[s,h]=await Promise.all([Wi(n,{targetHostId:l.targetHostId}),Hi(t,{targetHostId:l.targetHostId})]);return Qi(s.changes,h.items)}function Qi(t,n){const l=new Set(n.map(s=>kt(s.path)));return t.filter(s=>l.has(kt(s.path))||s.oldPath!==null&&l.has(kt(s.oldPath)))}function ea(t){const n=On("","");for(const l of t){const s=kt(l.path),h=s.split("/").filter(Boolean);let m=n;h.forEach((b,g)=>{const D=h.slice(0,g+1).join("/");if(g===h.length-1){m.children.set(`file:${D}`,{kind:"file",name:b,path:s,change:l});return}const R=`directory:${D}`,T=m.children.get(R);if(T&&T.kind==="directory"){m=T;return}const xe=On(b,D);m.children.set(R,xe),m=xe})}return oi(ri([...n.children.values()]))}function li(t,n){const l=t.oldPath?`${t.oldPath} -> ${t.path}`:t.path;return rn(t)?`${l} ${n}`:l}function rn(t){return t.status==="D"||t.stagedStatus==="D"||t.worktreeStatus==="D"}function Et(t){return t.split("/").filter(Boolean).pop()??t}function kt(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function On(t,n){return{kind:"directory",name:t,path:n,children:new Map}}function ri(t){return[...t].sort((n,l)=>n.kind!==l.kind?n.kind==="directory"?-1:1:n.name.localeCompare(l.name,"zh-CN")).map(n=>n.kind==="directory"?{kind:"directory",name:n.name,path:n.path,children:ri([...n.children.values()])}:n)}function oi(t){return t.map(n=>{var b;if(n.kind!=="directory")return n;const l=oi(n.children);let s=n.name,h=n.path,m=l;for(;m.length===1&&((b=m[0])==null?void 0:b.kind)==="directory";){const g=m[0];s=`${s}/${g.name}`,h=g.path,m=g.children}return{kind:"directory",name:s,path:h,children:m}})}const ta=450,na=60*1e3,Vn=20,Un=16;function ia({sessionId:t,workspaceId:n,targetHostId:l,showSystemFiles:s,selectedPath:h,refreshVersion:m,onCountChange:b,onSelectFile:g,onOpenFile:D}){const[R,T]=c.useState("tree"),[xe,J]=c.useState([]),[ge,G]=c.useState(!0),[Ne,v]=c.useState(!1),[ie,mt]=c.useState([]),k=c.useRef(null),Ft=ai(),{showToast:De}=ii();c.useEffect(()=>{const p=nn(Pt(n,t),na);T("tree"),J(p??[]),G(p===null),v(!1),mt([]),k.current=null},[t,n]),c.useEffect(()=>{let p=!1;async function w(){G(!0);try{const y=await Dt(t,n,{targetHostId:l});p||(J(y),dt(Pt(n,t),y))}catch(y){p||De({title:Qt(y,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{p||G(!1)}}return w(),()=>{p=!0}},[m,t,De,l,n]);async function Ee(){G(!0);try{const p=await Dt(t,n,{targetHostId:l});J(p),dt(Pt(n,t),p)}catch(p){De({title:Qt(p,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{G(!1)}}async function E(){if(_.length!==0){v(!0);try{await $i(n,_.map(w=>w.path),{targetHostId:l});const p=await Dt(t,n,{targetHostId:l});J(p),dt(Pt(n,t),p),De({title:o("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(p){De({title:Qt(p,o("git.stageFailed")),tone:"error"})}finally{v(!1)}}}function A(p){mt(w=>w.includes(p)?w.filter(y=>y!==p):[...w,p])}function X(p){const w=Date.now(),y=k.current;return k.current={filePath:p,timestamp:w},(y==null?void 0:y.filePath)===p&&w-y.timestamp<=ta}async function $(p,w){if(w&&X(p)){await D(p),k.current=null;return}w||(k.current=null),await g(p)}const ae=c.useMemo(()=>an(xe,p=>Et(p.path),s),[xe,s]),_=ae.filter(p=>!p.staged),Ae=ea(ae),le=new Set(ie);return c.useEffect(()=>{b==null||b(ae.length)},[b,ae.length]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"file-panel-session-toolbar",children:[i.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":o("conversation.filePanelSessionViewLabel"),children:[i.jsx("button",{className:R==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":R==="tree",onClick:()=>T("tree"),children:o("conversation.filePanelSessionTreeView")}),i.jsx("button",{className:R==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":R==="list",onClick:()=>T("list"),children:o("conversation.filePanelSessionListView")})]}),i.jsxs("div",{className:"file-panel-session-actions",children:[i.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Ee(),disabled:ge||Ne,children:o("conversation.filePanelRefresh")}),i.jsx("button",{className:"primary-button",type:"button",onClick:()=>void E(),disabled:Ne||_.length===0,children:o("conversation.filePanelSessionStageAll")})]})]}),i.jsxs("div",{className:"file-panel-session-summary",children:[i.jsx("span",{children:`${o("conversation.filePanelSessionSummary")} ${ae.length}`}),i.jsx("span",{children:`${o("conversation.filePanelSessionUnstagedSummary")} ${_.length}`})]}),i.jsx("div",{ref:Ft,className:"file-tree","data-scrollbar-autohide":"true",children:ge?i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionLoading")}):ae.length===0?i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionEmpty")}):R==="tree"?si({nodes:Ae,depth:0,collapsedPathSet:le,selectedPath:h,onToggleTreePath:A,onFileClick:$}):aa({items:ae,selectedPath:h,onFileClick:$})})]})}function si({nodes:t,depth:n,collapsedPathSet:l,selectedPath:s,onToggleTreePath:h,onFileClick:m}){return t.map(b=>{if(b.kind==="directory"){const g=!l.has(b.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":g,style:{paddingInlineStart:`${Vn+n*Un}px`},onClick:()=>h(b.path),children:[i.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:g?"v":">"}),i.jsx("span",{className:"file-tree-label",children:b.name})]}),g?i.jsx("div",{className:"file-tree-children",children:si({nodes:b.children,depth:n+1,collapsedPathSet:l,selectedPath:s,onToggleTreePath:h,onFileClick:m})}):null]},`session-directory:${b.path}`)}return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":s===b.change.path,"data-kind":"file",style:{paddingInlineStart:`${Vn+n*Un}px`},onClick:()=>void m(b.change.path,!rn(b.change)),children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),i.jsx("span",{className:"git-tree-file-icon","data-kind":Tt(b.name),"aria-hidden":"true",children:Rt(b.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:b.name}),i.jsx("span",{className:"file-tree-path",children:li(b.change,o("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":b.change.status,children:b.change.status}),i.jsx("span",{className:"file-session-badge subtle",children:b.change.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-file:${b.path}`)})}function aa({items:t,selectedPath:n,onFileClick:l}){return t.map(s=>i.jsx("div",{className:"file-session-list-item",children:i.jsxs("button",{className:"file-session-list-button",type:"button","data-active":n===s.path,onClick:()=>void l(s.path,!rn(s)),children:[i.jsx("span",{className:"git-tree-file-icon","data-kind":Tt(Et(s.path)),"aria-hidden":"true",children:Rt(Et(s.path))}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:Et(s.path)}),i.jsx("span",{className:"file-tree-path",children:li(s,o("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":s.status,children:s.status}),i.jsx("span",{className:"file-session-badge subtle",children:s.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-list:${s.path}`))}function Pt(t,n){return`file-panel.session-changes.${t}.${n}`}function Qt(t,n){return t instanceof ni?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??n):n}const C="",la=450,ne=8,jt=4,ra=176,oa=120,sa=300*1e3,ca=60*1e3,zn=1600,ua=220,fa=20,da=16;function ha(){if(typeof document>"u")return;const t=document.querySelector(".workbench-modal-card.file-viewer-modal"),n=t==null?void 0:t.getBoundingClientRect();if(!(!n||n.width<=0||n.height<=0))return{width:Math.round(n.width),height:Math.round(n.height),minWidth:720,minHeight:480}}function rl({className:t,sessionId:n,workspaceId:l,hideHeading:s=!1,hideTabs:h=!1,externalRevealRequest:m=null,externalWindowMode:b=!1,workbenchShellOverrides:g}){var Bn,Wn;const D=Oi(),{navigationGroups:R,subscribeFileTree:T,requestFileTreeRefresh:xe,addFileTreeSnapshotListener:J,subscribeGitSnapshot:ge,requestGitRefresh:G,addGitSnapshotListener:Ne,currentTargetHostId:v}={...D,...g},[ie,mt]=c.useState({}),[k,Ft]=c.useState([]),[De,Ee]=c.useState([]),[E,A]=c.useState(C),[X,$]=c.useState([]),[ae,_]=c.useState(null),[Ae,le]=c.useState(!1),[p,w]=c.useState(!1),[y,pt]=c.useState(!1),[Ye,Ze]=c.useState(!1),[L,Je]=c.useState(""),[At,q]=c.useState(null),[bt,vt]=c.useState(!1),[re,Le]=c.useState(null),[O,Qe]=c.useState("workspace"),[sn,ke]=c.useState(0),[cn,Lt]=c.useState(0),[et,Q]=c.useState(!1),[tt,B]=c.useState(!1),[oe,V]=c.useState(null),[Ce,Be]=c.useState(null),[W,We]=c.useState(null),[P,Bt]=c.useState(null),[S,nt]=c.useState(null),[Wt,He]=c.useState(""),[un,fn]=c.useState([]),[ee,Ht]=c.useState(!1),[bi,se]=c.useState(null),dn=c.useId(),ce=c.useRef({}),I=c.useRef({}),F=c.useRef([]),te=c.useRef(C),it=c.useRef(!1),at=c.useRef(null),vi=ai(),hn=c.useRef(null),mn=c.useRef(null),$t=c.useRef(null),pn=c.useRef(null),bn=c.useRef(null),ue=c.useRef(0),fe=c.useRef(new Map),{showToast:j}=ii(),Pe=Li(),U=Vi(e=>e.showSystemFiles),$e=!!(n!=null&&n.trim()),vn=s&&Pe.isMobile;c.useEffect(()=>{Fe("file_panel.props",{sessionId:n,workspaceId:l,externalWindowMode:b})},[b,n,l]),c.useEffect(()=>{te.current=E},[E]);function Ot(e){Lt(e),!(!l||!n)&&dt(Jn(l,n),e)}async function yn(){if(!l||!n){Ot(0);return}const e=await Dt(n,l,{targetHostId:v}),a=an(e,r=>ft(r.path),U).length;Ot(a)}function Me(e){mt(a=>{const r=typeof e=="function"?e(a):e;return ce.current=r,r})}function Oe(e){Ft(a=>{const r=typeof e=="function"?e(a):e;return F.current=r,r})}c.useEffect(()=>{var f,d;if(Kt(),!l){Kt(),it.current=!1,ce.current={},I.current={},F.current=[],te.current=C,Me({}),Oe([]),Ee([]),A(C),Ze(!1),Je(""),q(null),vt(!1),le(!1),Ht(!1),se(null),$([]),_(null),V(null),Be(null),We(null),nt(null),He("");return}it.current=!0;const e=nn(Zn(l),sa);Fe("file_panel.workspace_snapshot",{workspaceId:l,cached:!!e,cachedRootItems:((d=(f=e==null?void 0:e.treeCache)==null?void 0:f[C])==null?void 0:d.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const a=Ra((e==null?void 0:e.activeDirectoryPath)??C,(e==null?void 0:e.treeCache)??{}),r=Yn((e==null?void 0:e.expandedDirectories)??[],a),u=Nt((e==null?void 0:e.treeCache)??{},a,r);ce.current=u,I.current=Qn((e==null?void 0:e.treeRevisionByPath)??{},u),F.current=r,te.current=a,Me(u),Oe(r),Ee([]),A(a),le(!1),w(!1),Ze(!1),Je(""),q(null),vt(!1),queueMicrotask(()=>{it.current=!1})},[l]),c.useEffect(()=>{if(!m||m.workspaceId!==l)return;const e=()=>{if(bn.current===m.requestId)return;bn.current=m.requestId,Qe("workspace"),(m.openViewer?Ke(m.filePath):me(m.filePath)).catch(r=>{j({title:Z(r,o("conversation.filePanelOpenFailed")),tone:"error"})})};if(it.current){queueMicrotask(e);return}e()},[m,Ke,me,j,l]),c.useEffect(()=>{if(l)return J(e=>{e.workspaceId!==l||!Gn(Kn(e),v)||(I.current={...I.current,[e.path]:typeof e.revision=="string"?e.revision:null},Me(a=>({...a,[e.path]:e.items})),e.path===C&&le(!1),Ee(a=>a.filter(r=>r!==e.path)),Sn(e.path,e.items))})},[J,l]),c.useEffect(()=>()=>{Kt()},[]),c.useEffect(()=>{l&&T(l,tn(F.current,te.current),{knownRevisionByPath:I.current,targetHostId:v})},[E,v,k,T,l]),c.useEffect(()=>{$([]),_(null),Le(null),se(null),ke(0),Q(!1),B(!1),V(null),Be(null),We(null),nt(null),He(""),at.current=null,ue.current+=1},[n]),c.useEffect(()=>{!$e&&O==="session"&&Qe("workspace")},[O,$e]),c.useEffect(()=>{h&&O!=="workspace"&&Qe("workspace")},[O,h]),c.useEffect(()=>{if(!et&&!tt&&!oe)return;function e(r){var x,N,be;if(!(r.target instanceof Node))return;const u=((x=hn.current)==null?void 0:x.contains(r.target))??!1,f=((N=mn.current)==null?void 0:N.contains(r.target))??!1,d=((be=$t.current)==null?void 0:be.contains(r.target))??!1;!u&&!f&&!d&&(Q(!1),B(!1),V(null),Be(null))}function a(r){r.key==="Escape"&&(Q(!1),B(!1),V(null),Be(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",a)}},[et,tt,oe]),c.useLayoutEffect(()=>{if(!oe||typeof window>"u"){Be(null);return}const e=oe;function a(){const u=$t.current;if(!u)return;const f=u.getBoundingClientRect();Be(Ca({x:e.positionX,y:e.positionY},{width:f.width||ra,height:f.height||u.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}a();const r=window.requestAnimationFrame(a);return window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{window.cancelAnimationFrame(r),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}},[oe]),c.useEffect(()=>{if(!l)return;const e=Yn(k,E),a=Nt(ie,E,e);dt(Zn(l),{treeCache:a,treeRevisionByPath:Qn(I.current,a),expandedDirectories:e,activeDirectoryPath:E})},[E,k,ie,l]),c.useEffect(()=>{if(it.current)return;const e=Nt(ie,E,k);_a(ie,e)||Me(e)},[E,k,ie]),c.useEffect(()=>{let e=!1;const a=(l==null?void 0:l.trim())??null;async function r(f){if(!a)return;const d=Jt(ce.current[C]??[],U),x=(f==null?void 0:f.silent)!==!0&&d.length===0;x&&le(!0),Fe("file_panel.load_root_tree.start",{sessionId:n,workspaceId:a,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:d.length});try{const N=await zt(C,{force:!0});e||(Fe("file_panel.load_root_tree.end",{sessionId:n,workspaceId:a,itemCount:N.length}),Me(be=>({...Nt(be,te.current,F.current),[C]:N})))}catch(N){!e&&!ei(N)&&j({title:Z(N,o("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&x&&le(!1)}}if(Jt(ce.current[C]??[],U).length>0){const f=window.setTimeout(()=>{a&&(T(a,tn(F.current,te.current),{knownRevisionByPath:I.current,targetHostId:v}),r({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return r(),()=>{e=!0}},[n,U,j,l]),c.useEffect(()=>{if(!l||!n){Lt(0);return}const e=nn(Jn(l,n),ca);Fe("file_panel.session_change_count.snapshot",{sessionId:n,workspaceId:l,cached:e!==null,cachedCount:e}),Lt(e??0);let a=!1;return yn().catch(()=>{}),()=>{a=!0}},[n,sn,U,l]),c.useEffect(()=>{if(!l){fn([]);return}const e=l.trim();ge(e,{targetHostId:v}),G(e,{targetHostId:v})},[v,l,ge,G]),c.useEffect(()=>{if(!l)return;const e=l.trim();return Ne(a=>{var r;a.workspaceId!==e||!Gn(Kn(a),v)||fn(((r=a.status)==null?void 0:r.changes)??[])})},[Ne,l]);const yt=c.useMemo(()=>an(un,e=>ft(e.path),U),[un,U]),H=c.useMemo(()=>{const e=new Map,a=new Set;for(const r of yt){const u=r.path.replace(/\\/g,"/"),f=r.worktreeStatus??r.stagedStatus??r.status;e.set(u,f);const d=u.split("/");for(let x=1;x<d.length;x++)a.add(d.slice(0,x).join("/"))}return{statusByPath:e,changedDirs:a}},[yt]),Re=c.useMemo(()=>Ui(ie,U),[U,ie]),Te=c.useMemo(()=>At===null?null:Jt(At,U),[At,U]),Ve=Re[C]??[],de=Ye&&Te!==null,xt=c.useMemo(()=>ee?ln(Ve,Re,H.statusByPath,H.changedDirs):Ve,[H.changedDirs,H.statusByPath,Ve,ee,Re]),yi=c.useMemo(()=>de?(Te??[]).map(e=>K(e.path,e.kind)):ci(xt,Re,k,ee,H.statusByPath,H.changedDirs),[k,H.changedDirs,H.statusByPath,de,ee,Te,Re,xt]),he=((Bn=R.find(e=>e.workspace.id===l))==null?void 0:Bn.workspace)??null,M=In(X),Vt=(M==null?void 0:M.path)??null,je=(M==null?void 0:M.kind)==="file"?M.path:null,gt=c.useMemo(()=>new Set(X.map(e=>e.path)),[X]),lt=c.useMemo(()=>St(X),[X]),Ut=!!(he!=null&&he.path&&X.length===1&&Vt),xn=X.length===1&&(M==null?void 0:M.kind)==="file",gn=lt.length>0,_e=lt.length>0,rt=!!(P!=null&&P.items.length&&l),Cn=!!l&&X.length===1&&M!==null,Pn=!!((je?ye(je):E)&&k.length),jn=P?P.mode==="copy"?o("conversation.filePanelClipboardCopyReady",{count:P.items.length}):o("conversation.filePanelClipboardCutReady",{count:P.items.length}):null,z=S?Sa(S):null;async function wn(e,a=!1){if(!l)return[];if(!a){const r=ce.current[e];if(r)return r}e===C?le(!0):Ee(r=>Mt(r,e));try{const r=await zt(e,{force:a});return Me(u=>({...u,[e]:r})),r}catch(r){throw ei(r)||j({title:Z(r,o("conversation.filePanelLoadFailed")),tone:"error"}),r}finally{e===C?le(!1):Ee(r=>r.filter(u=>u!==e))}}async function we(e){if(!l)return;const a=(e==null?void 0:e.activeDirectoryPath)??te.current,r=(e==null?void 0:e.expandedDirectories)??F.current,u=Ta(ce.current,a,r);Fe("file_panel.refresh_tree_cache.start",{sessionId:n,workspaceId:l,targetDirectories:u});const d=(await Promise.all(u.map(async x=>{const N=await zt(x,{force:!0});return[x,N]}))).reduce((x,[N,be])=>(x[N]=be,x),{});Fe("file_panel.refresh_tree_cache.end",{sessionId:n,workspaceId:l,targetDirectories:u,directoryCount:Object.keys(d).length}),Me(d)}async function zt(e,a){if(!l)return[];if(!(a!=null&&a.force)){const d=ce.current[e];if(d)return d}const r=tn(Mt(F.current,e),e||te.current);T(l,r,{knownRevisionByPath:I.current,targetHostId:v}),xe(l,[e],{knownRevisionByPath:I.current,targetHostId:v});const u=xi(e,zn,{allowCached:(a==null?void 0:a.force)!==!0}),f=Fa(ua).then(async()=>{if(!l)return[];const x=(await Ii(l,e||void 0,{targetHostId:v})).items;return I.current={...I.current,[e]:null},Sn(e,x),x});try{return await Promise.race([u,f])}catch(d){if(!mi(d))throw d;return await f}}function xi(e,a=zn,r){const u=ce.current[e];return(r==null?void 0:r.allowCached)!==!1&&u?Promise.resolve(u):new Promise((f,d)=>{const x=window.setTimeout(()=>{gi(e,x),d(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},a),N=fe.current.get(e)??[];fe.current.set(e,[...N,{resolve:f,reject:d,timerId:x}])})}function Sn(e,a){const r=fe.current.get(e)??[];r.length!==0&&(fe.current.delete(e),r.forEach(u=>{window.clearTimeout(u.timerId),u.resolve(a)}))}function gi(e,a){const u=(fe.current.get(e)??[]).filter(f=>f.timerId!==a);if(u.length===0){fe.current.delete(e);return}fe.current.set(e,u)}function Kt(){for(const[e,a]of fe.current.entries())a.forEach(r=>{window.clearTimeout(r.timerId),r.reject(new Error(`FILE_TREE_ABORTED:${e}`))});fe.current.clear()}function Ue(e){$([e]),_(e.path)}function ot(e){A(e.kind==="directory"?e.path:ye(e.path))}function Ci(e){const a=ba(yi,ae,e);$(a),_(e.path),ot(e)}function Pi(e){const a=pa(X,e),r=In(a);$(a),_(e.path),r&&ot(r)}function Nn(e){Ue(e),ot(e)}function ze(e,a){if(a!=null&&a.shiftKey){Ci(e);return}if(wt(a)){Pi(e);return}Nn(e)}async function st(e,a=!1){const r=ht(e,a);if(!r.length){A(C);return}Oe(u=>hi(u,r)),A(r[r.length-1]??C);for(const u of r)try{await wn(u)}catch{return}}async function me(e){const a=K(e,"file");Ue(a),ot(a),await st(e)}async function Ke(e){Le(e),se(null),at.current=null,ue.current+=1,me(e),await ji(e)}async function ji(e){const a=ue.current,r=e.replace(/\\/g,"/"),u=H.statusByPath.get(r);if(l&&u&&u!=="?"&&u!=="D")try{const f=await zi(l,e,!1,{targetHostId:v});ue.current===a&&se(f.content||null)}catch{ue.current===a&&se(null)}}async function wi(e){if(!l)return;const a=ha(),r=await Gi(Pe,{workspaceId:l,workspaceName:(he==null?void 0:he.name)??null,sessionId:n??null,filePath:e,bounds:a});if(!r.ok){j({title:r.detail??o("conversation.fileViewerOpenInWindowFailed"),tone:"error"});return}ue.current+=1,Le(null),se(null)}function Dn(e){const a=Date.now(),r=at.current;return at.current={filePath:e,timestamp:a},(r==null?void 0:r.filePath)===e&&a-r.timestamp<=la}function Se(){at.current=null}async function Si(e,a){const r=K(e,"file");if(a!=null&&a.shiftKey||wt(a)){Se(),ze(r,a);return}if(Dn(e)){await Ke(e);return}ze(r,a),await st(e)}function En(){Ze(!1),Je(""),q(null),Se()}async function Ni(e,a){const r=K(e.path,e.kind);if(a!=null&&a.shiftKey||wt(a)){Se(),ze(r,a);return}if(e.kind==="directory"){En(),ze(r,a),await kn(e.path);return}if(Dn(e.path)){En(),await Ke(e.path);return}await me(e.path)}async function kn(e){if(Ue(K(e,"directory")),A(e),!F.current.includes(e))try{await wn(e),Oe(a=>Mt(a,e))}catch{}}async function Mn(e){if(Ue(K(e,"directory")),A(e),F.current.includes(e)){Rn(e);return}await kn(e)}function Rn(e){Oe(a=>a.filter(r=>r!==e&&!r.startsWith(`${e}/`))),A(ye(e)),$([]),_(null)}async function Tn(){if(!l)return;const e=l;try{if(G(e,{targetHostId:v}),await we(),je&&await st(je),de&&L.trim()){const a=await qe(e,L.trim(),1,20,{targetHostId:v});q(a.items)}if($e&&n)if(O==="session")ke(a=>a+1);else try{await yn()}catch(a){j({title:Z(a,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}}catch(a){j({title:Z(a,o("conversation.filePanelLoadFailed")),tone:"error"})}}async function Di(e){if(e==null||e.preventDefault(),!l||!L.trim()){q(null);return}vt(!0);try{const a=await qe(l,L.trim(),1,20,{targetHostId:v});q(a.items)}catch(a){j({title:Z(a,o("conversation.filePanelSearchFailed")),tone:"error"})}finally{vt(!1)}}function _n(){if(Ye){Ze(!1),Je(""),q(null);return}Ze(!0)}function Y(e){B(!1),e()}function Fn(){var e;(e=pn.current)==null||e.click()}async function Ei(e){var d;const a=((d=e.target.files)==null?void 0:d[0])??null;if(e.target.value="",!a||!l)return;const r=ma(a.name);if(!r){j({title:o("conversation.filePanelUploadFailed"),tone:"error"});return}const u=Xn(E,M),f=qn(u,r);pt(!0);try{const x=await Na(a);await Xi({workspaceId:l,path:f,contentBase64:x},{targetHostId:v}),await we(),await me(f),j({title:o("conversation.filePanelUploadSuccess",{name:r}),tone:"success"})}catch(x){j({title:Z(x,o("conversation.filePanelUploadFailed")),tone:"error"})}finally{pt(!1)}}async function Gt(e=je){if(!(!l||!e)){pt(!0);try{const a=await qi(l,e,{targetHostId:v}),r=Da(a.contentBase64);Ea(a.fileName,new Blob([r],{type:"application/octet-stream"})),j({title:o("conversation.filePanelDownloadSuccess",{name:a.fileName}),tone:"success"})}catch(a){j({title:Z(a,o("conversation.filePanelDownloadFailed")),tone:"error"})}finally{pt(!1)}}}function An(){const e=je?ye(je):E;!e||!F.current.includes(e)||Rn(e)}function Xt(){nt(null),He("")}function qt(){p||Xt()}function Ge(e,a=Xn(E,M)){if(!l)return;const r=a,u=r?`${r}/`:"";Q(!1),B(!1),V(null),nt({mode:e,baseDirectory:r}),He(u)}function It(e=M){!l||!e||(Q(!1),B(!1),V(null),nt({mode:"rename",target:e}),He(e.path))}async function ki(e){if(e==null||e.preventDefault(),!l||!S)return;const a=(Wt??"").trim();if(a){if(S.mode==="rename"&&Ie(S.target.path)===Ie(a)){qt();return}w(!0);try{if(S.mode==="rename"){const r=S.target.path,u=K(a,S.target.kind),f=re?di(re,r,a):null;if(await Ct({workspaceId:l,opType:"rename",srcPath:r,dstPath:a},{targetHostId:v}),P&&Bt({...P,items:wa(P.items,r,a)}),Xt(),Se(),await we(),S.target.kind==="directory"?(await st(a,!0),Ue(u),A(a)):await me(a),f!==re&&(ue.current+=1,Le(f),se(null)),de&&L.trim()){const d=await qe(l,L.trim(),1,20,{targetHostId:v});q(d.items)}ke(d=>d+1),j({title:o("conversation.filePanelRenameSuccess",{name:ft(a)||a}),tone:"success"});return}if(await Ct({workspaceId:l,opType:S.mode,dstPath:a,content:S.mode==="create_file"?"":void 0},{targetHostId:v}),Xt(),await we(),S.mode==="create_directory"?(await st(a,!0),Ue(K(a,"directory")),A(a)):await me(a),de&&L.trim()){const r=await qe(l,L.trim(),1,20,{targetHostId:v});q(r.items)}ke(r=>r+1)}catch(r){j({title:Z(r,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}}function pe(e,a=lt){var u;if(a.length===0)return;const r=St(a);Bt({mode:e,items:r}),$(r),_(((u=r[r.length-1])==null?void 0:u.path)??null),j({title:e==="copy"?o("conversation.filePanelCopySelectionSuccess",{count:r.length}):o("conversation.filePanelCutSelectionSuccess",{count:r.length}),tone:"success"}),V(null)}async function ct(e=xa(M,E)){if(!l||!P||!P.items.length)return;const a=e??C,r=P.items.map(u=>({source:u,destinationPath:qn(a,ft(u.path)||u.path)}));w(!0);try{for(const d of r)P.mode==="cut"&&Ie(d.source.path)===Ie(d.destinationPath)||await Ct({workspaceId:l,opType:P.mode==="copy"?"copy":"move",srcPath:d.source.path,dstPath:d.destinationPath},{targetHostId:v});const u=r.map(d=>K(d.destinationPath,d.source.kind)),f=u[u.length-1]??null;if(P.mode==="cut"&&Bt(null),$(u),_((f==null?void 0:f.path)??null),f&&ot(f),Se(),await we({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?ye(f.path):te.current,expandedDirectories:F.current}),de&&L.trim()){const d=await qe(l,L.trim(),1,20,{targetHostId:v});q(d.items)}ke(d=>d+1),j({title:o("conversation.filePanelPasteSuccess",{count:u.length}),tone:"success"}),V(null)}catch(u){await we().catch(()=>{}),j({title:Z(u,o("conversation.filePanelPasteFailed")),tone:"error"})}finally{w(!1)}}function Yt(e=lt){!e.length||p||(We(St(e)),V(null))}async function Mi(){var a,r;if(!l||!(W!=null&&W.length))return;const e=St(W);w(!0);try{for(const d of e)await Ct({workspaceId:l,opType:"delete",srcPath:d.path},{targetHostId:v});const u=ga(E,e),f=F.current.filter(d=>!e.some(x=>x.kind==="directory"&&_t(x.path,d)));if(re&&e.some(d=>_t(d.path,re))&&(ue.current+=1,Le(null),se(null)),We(null),$([]),_(null),te.current=u,F.current=f,A(u),Oe(f),Se(),await we({activeDirectoryPath:u,expandedDirectories:f}),de&&L.trim()){const d=await qe(l,L.trim(),1,20,{targetHostId:v});q(d.items)}ke(d=>d+1),j({title:e.length===1?o("conversation.filePanelDeleteSuccess",{name:ft(((a=e[0])==null?void 0:a.path)??"")||((r=e[0])==null?void 0:r.path)||""}):o("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(u){j({title:Z(u,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}async function Xe(e,a=M){const r=(he==null?void 0:he.path)??"",u=(a==null?void 0:a.path)??null;if(u===null||!r){Q(!1);return}try{const f=ja(r),d=e==="absolute"?Pa(r,u,f):Ie(u,f);await ka(d,Pe),j({title:e==="absolute"?o("conversation.filePanelCopyAbsolutePathSuccess"):o("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){j({title:f instanceof Error?f.message:o("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{Q(!1),V(null)}}function Ri(e,a,r){return[{id:`open-${e.path}`,label:e.kind==="directory"?k.includes(e.path)?o("conversation.filePanelCollapseDirectory"):o("conversation.filePanelExpandDirectory"):o("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){Mn(e.path);return}Ke(e.path)}},{id:`download-${e.path}`,label:o("conversation.filePanelDownload"),disabled:e.kind!=="file"||y,onSelect:()=>{Gt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:o("conversation.filePanelNewFile"),disabled:!l||p||y,onSelect:()=>{Ge("create_file",r)}},{id:`create-directory-${e.path}`,label:o("conversation.filePanelNewDirectory"),disabled:!l||p||y,onSelect:()=>{Ge("create_directory",r)}},{id:`rename-${e.path}`,label:o("conversation.filePanelRenameMove"),disabled:a.length!==1||p||y,onSelect:()=>It(e)},{id:`copy-${e.path}`,label:o("conversation.filePanelCopy"),disabled:a.length===0,onSelect:()=>pe("copy",a)},{id:`cut-${e.path}`,label:o("conversation.filePanelCut"),disabled:a.length===0,onSelect:()=>pe("cut",a)},{id:`paste-${e.path}`,label:o("conversation.filePanelPaste"),disabled:!rt,onSelect:()=>{ct(r)}},{id:`copy-relative-${e.path}`,label:o("conversation.filePanelCopyRelativePath"),onSelect:()=>{Xe("relative",e)}},{id:`copy-absolute-${e.path}`,label:o("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{Xe("absolute",e)}},{id:`delete-${e.path}`,label:o("conversation.filePanelDelete"),disabled:a.length===0||p||y,onSelect:()=>Yt(a)}]}async function Ln(e,a){if(Pe.isMobile)return;e.preventDefault();const r=K(a.path,a.kind),u=gt.has(r.path)?lt:[r],f=r.kind==="directory"?r.path:ye(r.path);gt.has(r.path)||Nn(r);const d=Ri(r,u,f);if(Pe.isDesktop){await Yi(d);return}Pe.isWeb&&(Q(!1),B(!1),V({positionX:e.clientX,positionY:e.clientY,items:d}))}c.useEffect(()=>{if(O!=="workspace")return;function e(a){if(!va(a)||a.altKey||a.shiftKey||ya(a.target))return;const r=a.key.toLowerCase();if(r==="c"&&_e){a.preventDefault(),pe("copy");return}if(r==="x"&&_e){a.preventDefault(),pe("cut");return}r==="v"&&rt&&(a.preventDefault(),ct())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[O,_e,rt,pe,ct]);function Zt(e,a){return i.jsx(i.Fragment,{children:e.map(r=>{const u=K(r.path,r.kind),f=r.kind==="directory",d=f&&k.includes(r.path),x=f&&De.includes(r.path),N=Re[r.path]??[],be=ee?ln(N,Re,H.statusByPath,H.changedDirs):N,_i=gt.has(r.path),Fi=Vt===r.path,ut=H.statusByPath.get(r.path.replace(/\\/g,"/")),Hn=f&&H.changedDirs.has(r.path.replace(/\\/g,"/")),Ai=(P==null?void 0:P.mode)==="cut"&&P.items.some(ve=>ve.path===r.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-active":Fi,"data-selected":_i,"data-cut-pending":Ai||void 0,"data-kind":r.kind,"aria-expanded":f?d:void 0,style:{paddingInlineStart:`${fa+a*da}px`},onClick:ve=>{if(f){if(ve.shiftKey||wt(ve)){Se(),ze(u,ve);return}Se(),ze(u,ve),Mn(r.path);return}Si(r.path,ve)},onContextMenu:ve=>{Ln(ve,r)},children:[i.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:d?"v":">"}),f?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":Tt(r.name),"aria-hidden":"true",children:Rt(r.name)}),i.jsx("span",{className:"file-tree-label","data-status":ut??void 0,"data-has-changes":Hn||void 0,children:r.name}),!f&&ut?i.jsx("span",{className:"git-status-badge","data-status":ut,"aria-label":ut,children:ut}):null,f&&Hn?i.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,x?i.jsx("span",{className:"file-tree-meta",children:o("common.loading")}):null]}),f&&d?i.jsx("div",{className:"file-tree-children",children:x&&!N.length?i.jsx("p",{className:"file-tree-empty",children:o("common.loading")}):be.length?Zt(be,a+1):i.jsx("p",{className:"file-tree-empty",children:o("conversation.filePanelEmptyDirectory")})}):null]},`${r.kind}-${r.path}`)})})}function Ti(e){return i.jsx(i.Fragment,{children:e.map(a=>{const r=a.kind==="directory",u=gt.has(a.path),f=Vt===a.path;return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":f,"data-selected":u,"data-kind":a.kind,onClick:d=>{Ni(a,d)},onContextMenu:d=>{Ln(d,a)},children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),r?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":Tt(a.name),"aria-hidden":"true",children:Rt(a.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:a.name}),i.jsx("span",{className:"file-tree-path",children:a.path})]})]})},`search-${a.kind}-${a.path}`)})})}return i.jsx("section",{className:["conversation-panel","surface-card","file-panel",t].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:l?i.jsxs(i.Fragment,{children:[i.jsx(Ki,{workspaceId:l,filePath:re,open:re!==null,onClose:()=>{ue.current+=1,Le(null),se(null)},onSaved:async e=>{await we(),await me(e),ke(a=>a+1)},diffContent:bi,showDetachAction:Pe.isDesktop&&Pe.bridge.supported,onDetach:()=>{re&&wi(re)}}),s?null:i.jsx("div",{className:"file-panel-heading-row",children:i.jsx("h2",{className:"file-panel-heading",children:o("conversation.filePanelTitle")})}),h?null:i.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":o("conversation.filePanelTitle"),children:[i.jsx("button",{className:O==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="workspace",onClick:()=>Qe("workspace"),children:o("conversation.filePanelWorkspaceTab")}),i.jsxs("button",{className:O==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="session",onClick:()=>{$e&&Qe("session")},disabled:!$e,children:[o("conversation.filePanelSessionTab"),i.jsx("span",{className:"file-panel-tab-badge","aria-label":`${o("conversation.filePanelSessionTab")} ${cn}`,children:cn})]})]}),O==="workspace"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:pn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void Ei(e)}),vn?i.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":o("conversation.filePanelTitle"),children:i.jsxs("div",{className:"file-mobile-action-shell",ref:mn,children:[i.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":o("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":tt,"data-active":tt,onClick:()=>{Q(!1),B(e=>!e)},children:[i.jsx("span",{children:o("conversation.filePanelActionsMenu")}),i.jsx(Xa,{})]}),tt?i.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":o("conversation.filePanelActionsMenu"),children:[i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>pe("copy")),disabled:!_e,children:o("conversation.filePanelCopy")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>pe("cut")),disabled:!_e,children:o("conversation.filePanelCut")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ct()),disabled:!rt||p||y,children:o("conversation.filePanelPaste")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),_n()},children:Ye?o("conversation.filePanelHideSearch"):o("conversation.filePanelShowSearch")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),Ht(e=>!e)},disabled:yt.length===0,children:ee?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(Tn),disabled:Ae||p||bt,children:o("conversation.filePanelRefresh")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),An()},disabled:!Pn,children:o("conversation.filePanelCollapseCurrent")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),Fn()},disabled:p||y,children:o("conversation.filePanelUpload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(Gt),disabled:!xn||y,children:o("conversation.filePanelDownload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(It),disabled:!Cn||p||y,children:o("conversation.filePanelRenameMove")}),i.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>Y(Yt),disabled:!gn||p||y,children:o("conversation.filePanelDelete")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Ge("create_file")),disabled:p||y,children:o("conversation.filePanelNewFile")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Ge("create_directory")),disabled:p||y,children:o("conversation.filePanelNewDirectory")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Xe("absolute")),disabled:!Ut,children:o("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Xe("relative")),disabled:!Ut,children:o("conversation.filePanelCopyRelativePath")})]}):null]})}):i.jsxs("div",{className:"file-panel-toolbar","aria-label":o("conversation.filePanelTitle"),children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopy"),"aria-label":o("conversation.filePanelCopy"),onClick:()=>pe("copy"),disabled:!_e,children:i.jsx(Wa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCut"),"aria-label":o("conversation.filePanelCut"),onClick:()=>pe("cut"),disabled:!_e,children:i.jsx(Ha,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelPaste"),"aria-label":o("conversation.filePanelPaste"),onClick:()=>void ct(),disabled:!rt||p||y,children:i.jsx($a,{})}),i.jsxs("div",{className:"file-toolbar-menu-shell",ref:hn,children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopyPath"),"aria-label":o("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":et,"data-active":et,onClick:()=>{B(!1),Q(e=>!e)},disabled:!Ut,children:i.jsx(Ba,{})}),et?i.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Xe("absolute"),children:o("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Xe("relative"),children:o("conversation.filePanelCopyRelativePath")})]}):null]}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCollapseCurrent"),"aria-label":o("conversation.filePanelCollapseCurrent"),onClick:An,disabled:!Pn,children:i.jsx(Aa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelRefresh"),"aria-label":o("conversation.filePanelRefresh"),onClick:()=>void Tn(),disabled:Ae||p||bt,children:i.jsx(La,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),"data-active":Ye,onClick:_n,disabled:Ae,children:i.jsx(ti,{})}),yt.length>0?i.jsx("button",{className:"file-toolbar-button",type:"button",title:ee?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges"),"aria-label":ee?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges"),"data-active":ee,onClick:()=>Ht(e=>!e),children:i.jsx(qa,{})}):null,i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelUpload"),"aria-label":o("conversation.filePanelUpload"),onClick:Fn,disabled:p||y,children:i.jsx(Va,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelDownload"),"aria-label":o("conversation.filePanelDownload"),onClick:()=>void Gt(),disabled:!xn||y,children:i.jsx(Ua,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelRenameMove"),"aria-label":o("conversation.filePanelRenameMove"),onClick:()=>It(),disabled:!Cn||p||y,children:i.jsx(Ga,{})}),i.jsx("button",{className:"file-toolbar-button danger",type:"button",title:o("conversation.filePanelDelete"),"aria-label":o("conversation.filePanelDelete"),onClick:()=>Yt(),disabled:!gn||p||y,children:i.jsx(za,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewFile"),"aria-label":o("conversation.filePanelNewFile"),onClick:()=>void Ge("create_file"),disabled:p||y,children:i.jsx(Oa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewDirectory"),"aria-label":o("conversation.filePanelNewDirectory"),onClick:()=>void Ge("create_directory"),disabled:p||y,children:i.jsx(Ka,{})})]}),oe&&typeof document<"u"?Bi.createPortal(i.jsx("div",{className:"file-web-context-menu",ref:$t,role:"menu","aria-label":o("conversation.filePanelActionsMenu"),style:{left:`${(Ce==null?void 0:Ce.left)??Math.max(8,oe.positionX)}px`,top:`${(Ce==null?void 0:Ce.top)??Math.max(8,oe.positionY)}px`,maxHeight:Ce?`${Ce.maxHeight}px`:void 0},children:oe.items.map(e=>i.jsx("button",{className:["file-web-context-menu-item",e.label===o("conversation.filePanelDelete")?"danger":""].filter(Boolean).join(" "),type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>{V(null),e.onSelect()},children:e.label},e.id))}),document.body):null,jn?i.jsx("p",{className:"file-panel-clipboard-status","data-mode":P==null?void 0:P.mode,children:jn}):null,Ye?i.jsxs("form",{className:"file-toolbar-search",onSubmit:e=>void Di(e),children:[i.jsx("input",{value:L,onChange:e=>Je(e.target.value),placeholder:o("conversation.filePanelSearchPlaceholder")}),vn?i.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":o("conversation.filePanelSearchButton"),disabled:bt,children:o("conversation.filePanelSearchButton")}):i.jsx("button",{className:"file-toolbar-button",type:"submit",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),disabled:bt,children:i.jsx(ti,{})})]}):null,i.jsx("div",{ref:vi,className:"file-tree","data-search-mode":de,"data-scrollbar-autohide":"true",children:Ae&&Ve.length===0?i.jsx("p",{className:"file-tree-status status-text",children:o("common.loading")}):de?Te!=null&&Te.length?Ti(Te):i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSearchEmpty")}):ee?xt.length?Zt(xt,0):i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelNoChanges")}):Ve.length?Zt(Ve,0):i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelEmptyDirectory")})}),i.jsx($n,{open:S!==null,title:(z==null?void 0:z.title)??"",description:z==null?void 0:z.description,onClose:qt,children:i.jsxs("form",{className:"workbench-rename-form",onSubmit:e=>void ki(e),children:[i.jsx(Zi,{label:o("conversation.filePanelPathFieldLabel"),htmlFor:dn,description:(S==null?void 0:S.mode)==="rename"?S.target.path:(S==null?void 0:S.baseDirectory)||void 0,children:i.jsx("input",{id:dn,type:"text",value:Wt??"",placeholder:o("conversation.filePanelPathFieldPlaceholder"),autoFocus:!0,onChange:e=>He(e.target.value)})}),i.jsxs(Ji,{children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:qt,children:o("common.cancel")}),i.jsx("button",{type:"submit",className:"primary-button",disabled:p||!(Wt??"").trim(),children:p?(z==null?void 0:z.pendingLabel)??o("common.loading"):(z==null?void 0:z.submitLabel)??o("common.save")})]})]})}),i.jsxs($n,{open:W!==null,title:o("conversation.filePanelDeleteConfirmTitle"),description:o("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{p||We(null)},children:[i.jsx("p",{className:"workbench-section-empty",children:W!=null&&W.length?W.length===1?((Wn=W[0])==null?void 0:Wn.kind)==="directory"?o("conversation.filePanelDeleteDirectoryConfirm",{path:W[0].path}):o("conversation.filePanelDeleteFileConfirm",{path:W[0].path}):o("conversation.filePanelDeleteSelectionConfirm",{count:W.length}):""}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>We(null),children:o("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{Mi()},children:p?o("conversation.filePanelDeleting"):o("conversation.filePanelDelete")})]})]})]}):$e&&n?i.jsx(ia,{sessionId:n,workspaceId:l,targetHostId:v,showSystemFiles:U,selectedPath:je,refreshVersion:sn,onCountChange:Ot,onSelectFile:me,onOpenFile:Ke}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:o("conversation.filePanelSessionNoSession")})})]}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:o("conversation.filePanelNoWorkspace")})})})}function Kn(t){const n=t==null?void 0:t.targetHostId;return typeof n=="string"&&n.trim()?n.trim():null}function Gn(t,n){return((t==null?void 0:t.trim())||null)===((n==null?void 0:n.trim())||null)}function ye(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):C}function ht(t,n=!1){const l=t.split("/").filter(Boolean),s=n?l.length:l.length-1,h=[];for(let m=0;m<s;m+=1)h.push(l.slice(0,m+1).join("/"));return h}function Xn(t,n){return t||((n==null?void 0:n.kind)==="directory"?n.path:n!=null&&n.path?ye(n.path):C)}function qn(t,n){return t?`${t}/${n}`:n}function ma(t){var n;return((n=t.split(/[/\\]/).pop())==null?void 0:n.trim())??""}function K(t,n){return{path:t,kind:n}}function In(t){return t[t.length-1]??null}function pa(t,n){return t.findIndex(s=>s.path===n.path)>=0?t.filter(s=>s.path!==n.path):[...t,n]}function ba(t,n,l){const s=t.findIndex(g=>g.path===l.path);if(s<0)return[l];const h=n?t.findIndex(g=>g.path===n):s;if(h<0)return[l];const m=Math.min(h,s),b=Math.max(h,s);return t.slice(m,b+1)}function wt(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function va(t){return t.ctrlKey||t.metaKey}function ya(t){if(!(t instanceof HTMLElement))return!1;const n=t.tagName.toLowerCase();return n==="input"||n==="textarea"||n==="select"||t.isContentEditable}function St(t){const n=[...new Map(t.map(s=>[s.path,s])).values()].sort((s,h)=>s.path.localeCompare(h.path)),l=[];for(const s of n)l.some(h=>h.kind==="directory"&&_t(h.path,s.path))||l.push(s);return l}function xa(t,n){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?ye(t.path):n}function ga(t,n){let l=t;for(;l&&n.some(s=>s.kind==="directory"&&_t(s.path,l));)l=ye(l);return l}function ci(t,n,l,s,h,m){const b=[];for(const g of t){if(b.push(K(g.path,g.kind)),g.kind!=="directory"||!l.includes(g.path))continue;const D=n[g.path]??[],R=s?ln(D,n,h,m):D;b.push(...ci(R,n,l,s,h,m))}return b}function Ca(t,n,l){const s=Math.max(0,l.width),h=Math.max(0,l.height),m=Math.max(0,h-ne*2),b=Math.max(0,s-ne*2),g=Math.min(Math.max(n.width,0),b),D=Math.max(0,h-t.y-jt-ne),R=Math.max(0,t.y-jt-ne),T=D<n.height&&R>D,J=en(Math.max(T?R:D,oa),0,m),ge=Math.min(Math.max(n.height,0),J),G=T?t.y-jt-ge:t.y+jt,Ne=Math.max(ne,h-ne-ge),v=Math.max(ne,s-ne-g);return{top:en(G,ne,Ne),left:en(t.x,ne,v),maxHeight:Math.max(0,J)}}function en(t,n,l){return!Number.isFinite(t)||l<n?n:Math.min(Math.max(t,n),l)}function Ie(t,n="posix"){return t?ui(t,n):"."}function Pa(t,n,l){const s=ui(t,l),h=Ie(n,l).replace(/^\.[/\\]?/,"");if(!h)return s;const m=fi(l),b=h.replace(/^[/\\]+/,"");return b?s.endsWith("/")||s.endsWith("\\")?`${s}${b}`:`${s}${m}${b}`:s}function ja(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function ui(t,n){return t&&(fi(n)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function fi(t){return t==="windows"?"\\":"/"}function _t(t,n){return n===t||n.startsWith(`${t}/`)}function di(t,n,l){return t===n?l:t.startsWith(`${n}/`)?`${l}${t.slice(n.length)}`:t}function wa(t,n,l){return t.map(s=>({...s,path:di(s.path,n,l)}))}function Sa(t){return t.mode==="create_file"?{title:o("conversation.filePanelNewFile"),description:o("conversation.filePanelCreateFileDescription"),submitLabel:o("conversation.filePanelCreateFileSubmit"),pendingLabel:o("conversation.filePanelCreatingFile")}:t.mode==="create_directory"?{title:o("conversation.filePanelNewDirectory"),description:o("conversation.filePanelCreateDirectoryDescription"),submitLabel:o("conversation.filePanelCreateDirectorySubmit"),pendingLabel:o("conversation.filePanelCreatingDirectory")}:{title:o("conversation.filePanelRenameMove"),description:o("conversation.filePanelRenameDescription"),submitLabel:o("conversation.filePanelRenameSubmit"),pendingLabel:o("conversation.filePanelRenaming")}}async function Na(t){const n=await t.arrayBuffer(),l=new Uint8Array(n),s=32768;let h="";for(let m=0;m<l.length;m+=s){const b=l.subarray(m,m+s);h+=String.fromCharCode(...b)}return btoa(h)}function Da(t){const n=atob(t),l=new Uint8Array(n.length);for(let s=0;s<n.length;s+=1)l[s]=n.charCodeAt(s);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}function Ea(t,n){if(typeof document>"u")throw new Error(o("conversation.filePanelDownloadFailed"));const l=window.URL.createObjectURL(n),s=document.createElement("a");s.href=l,s.download=t,document.body.append(s),s.click(),s.remove(),window.URL.revokeObjectURL(l)}async function ka(t,n){var l;if(!(n.isDesktop&&(await n.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((l=navigator.clipboard)!=null&&l.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!Ma(t))throw new Error(o("conversation.filePanelCopyPathFailed"))}}function Ma(t){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.left="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n)}}function Ra(t,n){return t&&ht(t,!0).every(h=>h in n)?t:C}function Yn(t,n){if(!n)return[];const l=ht(n,!0);return t.filter(s=>l.includes(s))}function Nt(t,n,l){const s=on(n,l);return Object.entries(t).reduce((h,[m,b])=>(s.has(m)&&(h[m]=b),h),{})}function Ta(t,n,l){const h=[...on(n,l)].filter(m=>m===C||m in t);return h.length?h:[C]}function on(t,n){const l=new Set([C]),s=hi(n,ht(t,!0));for(const h of s){l.add(h);for(const m of ht(h,!0))l.add(m)}return l}function _a(t,n){const l=Object.keys(t),s=Object.keys(n);return l.length!==s.length?!1:l.every(h=>t[h]===n[h])}function Mt(t,n){return t.includes(n)?t:[...t,n]}function hi(t,n){return n.reduce((l,s)=>Mt(l,s),t)}function Zn(t){return`file-panel.workspace-tree.${t}`}function Jn(t,n){return`file-panel.session-change-count.${t}.${n}`}function Qn(t,n){return Object.fromEntries(Object.keys(n).map(l=>[l,t[l]??null]))}function tn(t,n){return[...on(n,t)]}function Z(t,n){return t instanceof ni?t.message:n}function mi(t){return t instanceof Error&&t.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")}function ei(t){return mi(t)||t instanceof Error&&t.message.startsWith("FILE_TREE_ABORTED:")}function Fa(t){return new Promise(n=>{window.setTimeout(n,t)})}function Aa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function La(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M12.8 5.2A5.5 5.5 0 1 0 13.5 8h-1.8A3.7 3.7 0 1 1 10.6 5l-1.4 1.4h4V2l-1.4 1.4z",fill:"currentColor"})})}function ti(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M11.2 10.1l3 3-1.1 1.1-3-3a5 5 0 1 1 1.1-1.1zM6.8 10.3a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z",fill:"currentColor"})})}function Ba(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3.5 4.3h5.2v1.4H4.9v5.4H3.5zm3.8-2.1h5.2v9.5H7.3z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Wa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ha(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M4.2 4.2a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm0 5.4a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm1-3.2 6.6 5.6M5.2 9.6l6.6-5.6",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})}function $a(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Oa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Va(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ua(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 8.5 2.5 2.5 2.5-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function za(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.5 4.5h9M6.2 2.5h3.6l.6 1.4H13v1.2H3V3.9h2.6zM5.2 5.7v6.1m2.8-6.1v6.1m2.8-6.1v6.1M4.4 13.5h7.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ka(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ga(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.2 11.9h2.2l5.9-5.9-2.2-2.2-5.9 5.9zM8.3 3.8l2.2 2.2M2.8 13.2h10.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Xa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function qa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function ln(t,n,l,s){const h=[];for(const m of t){const b=m.path.replace(/\\/g,"/");m.kind==="file"?l.has(b)&&h.push(m):pi(b,n,l,s)&&h.push(m)}return h}function pi(t,n,l,s,h){const m=h??new Set;if(m.has(t))return!1;m.add(t);const b=n[t];if(!b)return s.has(t);for(const g of b){const D=g.path.replace(/\\/g,"/");if(g.kind==="file"){if(l.has(D))return!0}else if(pi(D,n,l,s,m))return!0}return!1}export{rl as FileContextPanel};
@@ -0,0 +1,6 @@
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-Bp1FnRo_.js";import{u as Ii,e as Ui,f as Bi,g as An}from"./App-Pe30N_Dy.js";import{b as Wi,ar as mt,S as Vi,c2 as zi,cb as Ki,cc as Xi,bU as qi,cd as Dn,ce as Yi,cf as Zi,c1 as Ji,cg as Qi,bY as es,ch as ts,bW as Jn,ci as ns,ca as is,cj as Ln,a9 as ss,a8 as as,aa as rs,ck as os,bZ as zt,b_ as Kt,cl as ls,cm as cs,I as us}from"./WorkbenchLayout-CoYxMzzR.js";import{W as $e}from"./WorkbenchModal-2PaCY_Gj.js";import{c as ds}from"./workbench-navigation-Bs4OQYD3.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./host-alias-CeDJeL0T.js";import"./DesktopModal-DyC_e0eF.js";import"./relay-entry-B6UDc5cD.js";import"./MobileSheet-C32hwIFd.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=Wi(),{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,V]=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,We]=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),[Ve,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(""),V(!1),B([]),z(null),oe("unstaged"),Y(null),Z(null),jt(!1),Ct(null),Be(!1),We(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=Wt(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=Wt(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(!Wt(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"){V(!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)),V(!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"}),V(!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),V(!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),We(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;We(_(c,n("git.commitDetailLoadFailed"))),Me(null)}finally{De.current===r&&Be(!1)}}function Mi(){Ct(null),Be(!1),We(null),Me(null)}async function _e(t){try{const s=await Lt(t);await W(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 W(t.commitHash,n("git.copyCommitHashSuccess"))},{id:`copy-message:${t.commitHash}`,label:n("git.copyCommitMessage"),onSelect:()=>void W(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&&V(!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 W(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:()=>{V(!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 W(c,n("git.copyCommitHashSuccess")),onCopyCommitMessage:c=>void W(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"),V(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 W(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void W(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:()=>V(t=>!t),disabled:C,children:e.jsx(Ie,{})}),ne?Rn({desktopFloating:!0}):null]})]}),te?e.jsx(Wn,{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 W(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void W(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:Ve==="push"?n("git.selectRemoteTitle"):n("git.remoteAuthManageTitle"),description:Ve==="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:[Ve==="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")}),Ve==="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(Wn,{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 W(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void W(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(Vi,{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 Wn({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 Vn(a,i){return{kind:"directory",name:a,path:i,children:new Map}}function zn(a,i){const u=Vn("","");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=Vn(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
+
3
+ ${u}`:i}function bs(a){const i=a.changedFiles.map(g=>`- [${g.status}] ${g.path}${g.oldPath?` (from ${g.oldPath})`:""}`).join(`
4
+ `),u=a.diffContent.length>Ut?a.diffContent.slice(0,Ut):a.diffContent,h=a.diffContent.length>Ut||a.diffTruncated?`
5
+ 注意:diff 内容过长,下面已经截断,只分析可见部分,同时明确指出可能遗漏的区域。`:"";return["请你分析下面这个 Git 提交。","输出要求:","1. 先用 3 到 5 句话说明这次改动的核心目的。","2. 按文件说明关键改动点,不要泛泛而谈。","3. 指出潜在风险、边界情况和可能的回归点。","4. 如果提交信息写得差,给出一条更合适的中文提交说明。","",`版本号:${a.versionLabel}`,`Commit Hash:${a.commitHash}`,`提交标题:${a.subject}`,`提交作者:${a.authorName} <${a.authorEmail}>`,`提交时间:${a.authoredAt}`,"","变更文件:",i||"- 无",h,"","Diff:",u||"(empty diff)"].join(`
6
+ `)}function ys(a){if(!a)return;a.style.height="0px";const i=Math.min(Math.max(a.scrollHeight,34),120);a.style.height=`${i}px`,a.style.overflowY=a.scrollHeight>120?"auto":"hidden"}function si(a){switch(a){case"local":return n("git.historyKindLocal");case"remote":return n("git.historyKindRemote");default:return n("git.historyKindShared")}}function ai(a){if(!a)return 0;let i=0;for(const u of a)i=i*33+u.charCodeAt(0)>>>0;return i%6}function js(a){const i=Date.parse(a);return Number.isNaN(i)?a:new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(i)}function _(a,i){return a instanceof Zn?Ss(a)??a.message:typeof a=="object"&&a&&"message"in a?a.message:i}function Cs(a){const i=a==null?void 0:a.targetHostId;return typeof i=="string"&&i.trim()?i.trim():null}function Ns(a,i){return((a==null?void 0:a.trim())||null)===((i==null?void 0:i.trim())||null)}function Ge(a,i){return`git-sidebar.snapshot.${i!=null&&i.trim()?`host.${encodeURIComponent(i.trim())}.`:""}${a}`}function Wt(a){return a?!!(a.status||a.branches||a.history.length>0||a.historyTotalCount>0||a.historyNextCursor||a.revision):!1}function vs(a){return a?a.snapshot.enabled!==!1:!0}function Ss(a){switch(a.errorCode){case"UNAUTHORIZED":return n("git.errors.unauthorized");case"WORKSPACE_NOT_FOUND":return n("git.errors.workspaceNotFound");case"INVALID_WORKSPACE":return n("git.errors.invalidWorkspace");case"NOT_GIT_REPOSITORY":return n("git.errors.notGitRepository");case"GIT_REPO_NOT_FOUND":return n("git.errors.repoNotFound");case"PATH_OUT_OF_WORKSPACE":return n("git.errors.pathOutOfWorkspace");case"INVALID_TARGET":return n("git.errors.invalidTarget");case"NOT_STAGED":return n("git.errors.notStaged");case"EMPTY_STAGED_CHANGES":return n("git.errors.emptyStagedChanges");case"BRANCH_CONFLICT":return n("git.errors.branchConflict");case"BRANCH_NOT_FOUND":return n("git.errors.branchNotFound");case"REMOTE_NOT_FOUND":return n("git.errors.remoteNotFound");case"GIT_REMOTE_AUTH_FAILED":return n("git.errors.remoteAuthFailed");case"GIT_PUSH_FAILED":return n("git.errors.pushFailed");case"GIT_PULL_FAILED":return n("git.errors.pullFailed");case"GIT_REMOTE_FAILED":return n("git.errors.remoteFailed");case"GIT_COMMAND_TIMEOUT":return n("git.errors.commandTimeout");case"GIT_INIT_FAILED":return n("git.errors.initFailed");case"GIT_DISCARD_FAILED":return n("git.discardFailed");case"GIT_UNDO_FAILED":return n("git.undoLastCommitFailed");default:return null}}function Xn(a){return a instanceof Zn&&a.errorCode==="GIT_REMOTE_AUTH_FAILED"}function Ts(a,i=!1){return!a||!a.mode||a.mode==="none"?ft:a.mode==="basic"?{authMode:"basic",username:a.username??"",password:a.password??"",token:"",rememberOnHost:i}:a.mode==="token"?{authMode:"token",username:a.username??"",password:"",token:a.token??"",rememberOnHost:i}:ft}function Ms(a){return a.authMode==="none"?null:a.authMode==="basic"?{mode:"basic",username:a.username.trim(),password:a.password}:{mode:"token",username:a.username.trim()||void 0,token:a.token}}function Hs(a,i){const u=pt(a,i);if(!u)return"generic";const h=u.pushUrl||u.fetchUrl;return Rs(h)?"github":"generic"}function pt(a,i){return a.find(u=>u.name===i)??a.find(u=>u.name==="origin")??a[0]??null}function qn(a){var i;return(i=pt(a))==null?void 0:i.name}function Es(a,i){return i!=null&&i.auth?{kind:"session",label:n("git.remoteAuthConfiguredInSession")}:a.credentialConfigured?{kind:"host",label:n("git.remoteAuthConfiguredOnHost")}:{kind:"missing",label:n("git.remoteAuthNotConfigured")}}function Rs(a){const i=(a==null?void 0:a.trim().toLowerCase())??"";return i.startsWith("https://github.com/")||i.startsWith("http://github.com/")||i.startsWith("ssh://git@github.com/")||i.startsWith("git@github.com:")}function Yn(a,i,u){const h=Math.max(0,u.width),g=Math.max(0,u.height),j=Math.max(0,g-k*2),p=Math.max(0,h-k*2),y=Math.min(Math.max(i.width||Xt,0),p),b=Math.max(0,g-a.bottom-gt-k),N=Math.max(0,a.top-gt-k),M=b<i.height&&N>b,S=Vt(Math.max(M?N:b,ms),0,j),x=Math.min(Math.max(i.height,0),S),o=M?a.top-gt-x:a.bottom+gt,f=Math.max(k,g-k-x),d=Math.max(k,h-k-y);return{top:Vt(o,k,f),left:Vt(a.right-y,k,d),maxHeight:Math.max(0,S),transformOrigin:`${M?"bottom":"top"} right`}}function Vt(a,i,u){return!Number.isFinite(a)||u<i?i:Math.min(Math.max(a,i),u)}function xt({expanded:a}){return e.jsx("svg",{className:"git-chevron-icon",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:a?"rotate(0deg)":"rotate(-90deg)"},"aria-hidden":"true",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Yt({staged:a}){return a?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M5 12h14"})}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"M5 12h14"})]})}function Zt(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M10 7L6 11l4 4",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7 11h7c3.87 0 7 3.13 7 7 0 1.9-.76 3.63-2 4.89",strokeLinecap:"round",strokeLinejoin:"round"})]})}function ws(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z"})})}function Ie(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"5",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"19",cy:"12",r:"1.8"})]})}function ri(a){try{return new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(a))}catch{return a}}export{Us as GitSidebar,Yn as resolveGitOperationsMenuPosition};
@@ -0,0 +1 @@
1
+ import{b as c,j as e,t as n}from"./index-Bp1FnRo_.js";import{M as k,s as j,t as f,u as g,v as M}from"./workbench-navigation-Bs4OQYD3.js";import{M as v}from"./MobileSheet-C32hwIFd.js";import{I as S,S as L}from"./WorkbenchLayout-CoYxMzzR.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-CFyk1rgJ.js";import{g as $}from"./App-BxX5mm9o.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-Bp1FnRo_.js";import{g as $}from"./App-Pe30N_Dy.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};
@@ -0,0 +1 @@
1
+ import{j as n,t as s}from"./index-Bp1FnRo_.js";import{M as a,H as d,t as m,u,v as g}from"./workbench-navigation-Bs4OQYD3.js";import{b as c,a as y,g as f}from"./plugin-permission-copy-Do028HzJ.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,A as h,K as v,I as U,L as x,D as C}from"./index-CFyk1rgJ.js";import{c as D,u as k,v as b,K as S,x as A,M as L,L as j}from"./workbench-navigation-DoDaQR4z.js";import{e as G,i as M,T as F,P as K,c as B,u as z,f as H}from"./App-BxX5mm9o.js";import{c as Q,f as W,h as Y,i as $,o as V,j as X,k as J,w as Z,m as q}from"./plugins-api-CmV7aDGA.js";import{D as ee}from"./DesktopModal-BxsogpLf.js";import{M as ne}from"./MobileSheet-C5IVmUsO.js";import{g as ie,a as te,b as se}from"./plugin-permission-copy-iK3faI3n.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(A,{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(L,{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 Ee(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:Ne(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 J(n,s,p)})}if(i.action==="writeFile"){const p=_((m=i.payload)==null?void 0:m.path,"插件写文件缺少路径"),E=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,E)})}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 X(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 N=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)),N||(N=v.createRoot(I))}function T(e){N&&N.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 Ee(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 Ne(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=z(),{showToast:s}=H(),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(L,{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(A,{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-Bp1FnRo_.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-Bs4OQYD3.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-Pe30N_Dy.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-BOugklJ-.js";import{D as ee}from"./DesktopModal-DyC_e0eF.js";import{M as ne}from"./MobileSheet-C32hwIFd.js";import{g as ie,a as te,b as se}from"./plugin-permission-copy-Do028HzJ.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-CFyk1rgJ.js";import{x as R,N as S,K as o,c as u,u as f,v as d,M as $,O as F}from"./workbench-navigation-DoDaQR4z.js";import{c as H,u as W,f as O}from"./App-BxX5mm9o.js";import{g as z,a as B,b as K,r as U,d as _,e as q}from"./plugins-api-CmV7aDGA.js";import{P as J}from"./PluginAccessOverview-CrQiQxxZ.js";import"./plugin-permission-copy-iK3faI3n.js";function se(){var N,E;const{workspaceId:r="",pluginId:l=""}=H(),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 K(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(F(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-Bp1FnRo_.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-Bs4OQYD3.js";import{c as F,u as W,f as O}from"./App-Pe30N_Dy.js";import{g as z,a as B,b as Q,r as U,d as _,e as q}from"./plugins-api-BOugklJ-.js";import{P as J}from"./PluginAccessOverview-BDiz6fV8.js";import"./plugin-permission-copy-Do028HzJ.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-CFyk1rgJ.js";import{x as m,u as g,v as h,L as x,K as n}from"./workbench-navigation-DoDaQR4z.js";import{c as f,u as j,f as b}from"./App-BxX5mm9o.js";import{l as v}from"./plugins-api-CmV7aDGA.js";function k(){const{workspaceId:d=""}=f(),u=j(),{showToast:r}=b(),[l,p]=i.useState([]),[o,c]=i.useState(!0);return i.useEffect(()=>{let s=!1;return c(!0),v().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(x(d,s.id))},s.id))}):null]})})}export{k as PluginsListPage};
1
+ import{b as i,t as a,j as e}from"./index-Bp1FnRo_.js";import{H as m,t as g,u as h,N as f,v as n}from"./workbench-navigation-Bs4OQYD3.js";import{c as x,u as j,f as b}from"./App-Pe30N_Dy.js";import{l as N}from"./plugins-api-BOugklJ-.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};
@@ -0,0 +1 @@
1
+ import{b as a,j as l}from"./index-Bp1FnRo_.js";import{b as k,b8 as C,b9 as L,ba as x,bb as N,bc as P,bd as A}from"./WorkbenchLayout-CoYxMzzR.js";import{L as D}from"./workbench-navigation-Bs4OQYD3.js";import{c as R,h as W,u as j}from"./App-Pe30N_Dy.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./host-alias-CeDJeL0T.js";import"./DesktopModal-DyC_e0eF.js";import"./relay-entry-B6UDc5cD.js";import"./WorkbenchModal-2PaCY_Gj.js";import"./MobileSheet-C32hwIFd.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{o as m,b as d,e as g,j as n,t as i}from"./index-CFyk1rgJ.js";import{u as p,c as f,d as y}from"./App-BxX5mm9o.js";import{b as E}from"./relay-entry-C8k5qsl5.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-Bp1FnRo_.js";import{u as p,c as f,d as y}from"./App-Pe30N_Dy.js";import{b as E}from"./relay-entry-B6UDc5cD.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-CFyk1rgJ.js";import{r as E,b as k}from"./relay-entry-C8k5qsl5.js";import{a as h,x as O,y as P,z as w}from"./App-BxX5mm9o.js";import{W as T}from"./WorkbenchModal-CsZeLArg.js";import"./DesktopModal-BxsogpLf.js";function A({isOpen:t,onClose:u,onSave:c,theme:$="dark"}){const d=h(e=>e.baseUrl),B=h(e=>e.options),p=h(e=>e.presetOptions),f=P(),[i,o]=n.useState(d),[g,l]=n.useState(null),[v,m]=n.useState(!1),a=n.useMemo(()=>{try{return U(i)}catch{return null}},[i]),x=O(a??i,B),S=p.find(e=>e.value===x)??null,b="server-settings-preset",j="server-settings-address";if(n.useEffect(()=>{t&&(o(d),l(null),m(!1))},[t,d]),!t)return null;async function I(){if(!a){l(s("auth.serverInvalid"));return}m(!0);try{const e=await E(a);e?await N.update(k(N.getState(),e)):w.setBaseUrl(a),c==null||c(a),u()}catch(e){l(e instanceof Error&&e.message.trim()?e.message:s("auth.serverInvalid"))}finally{m(!1)}}function C(){a&&o(a)}return r.jsx(T,{open:t,title:s("auth.serverSettingsTitle"),description:s("auth.serverHint"),className:"server-settings-modal-card",onClose:u,children:r.jsxs("form",{className:"server-settings-modal-form",onSubmit:e=>{e.preventDefault(),I()},children:[r.jsxs("label",{className:"workbench-modal-field",htmlFor:b,children:[r.jsx("span",{children:s("auth.serverPreset")}),r.jsxs("select",{id:b,"aria-label":s("auth.serverPreset"),value:x,onChange:e=>{const y=e.target.value;y!==f&&(o(y),l(null))},children:[p.map(e=>r.jsx("option",{value:e.value,children:V(e)},`${e.source}:${e.value}`)),r.jsx("option",{value:f,children:s("auth.serverCustomOption")})]})]}),S?r.jsx("div",{className:"server-settings-modal-tags","aria-live":"polite",children:S.source==="discovered"?r.jsx("span",{className:"server-settings-modal-tag","data-tone":"discovered",children:s("auth.serverDiscoveredTag")}):null}):null,r.jsxs("label",{className:"workbench-modal-field",htmlFor:j,children:[r.jsx("span",{children:s("auth.serverAddress")}),r.jsx("input",{id:j,"aria-label":s("auth.serverAddress"),value:i,placeholder:s("auth.serverPlaceholder"),disabled:v,onBlur:C,onChange:e=>{o(e.target.value),l(null)}})]}),g?r.jsx("p",{className:"server-settings-modal-status","data-tone":"error",children:g}):r.jsx("p",{className:"server-settings-modal-hint",children:s("auth.serverHint")}),r.jsxs("div",{className:"workbench-modal-actions",children:[r.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:s("common.cancel")}),r.jsx("button",{type:"submit",className:"primary-button",disabled:v,children:v?s("common.loading"):s("auth.saveServerSettings")})]})]})})}function V(t){return t.source==="discovered"?`${t.value} · ${s("auth.serverDiscoveredTag")}`:t.value}export{A as ServerSettingsModal};
1
+ import{b as n,n as U,j as r,t as s,e as N}from"./index-Bp1FnRo_.js";import{r as E,b as k}from"./relay-entry-B6UDc5cD.js";import{a as h,B as O,C as P,D as w}from"./App-Pe30N_Dy.js";import{W as T}from"./WorkbenchModal-2PaCY_Gj.js";import"./DesktopModal-DyC_e0eF.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};
@@ -0,0 +1 @@
1
+ import{b as d,j as e,t as a}from"./index-Bp1FnRo_.js";import{g as pe,u as je}from"./App-Pe30N_Dy.js";import{I as ye,d as fe,J as ce,K as Se,L as Ne,N as ke,b as Me,f as Ae,O as Ce,c as de,y as Ee,M as Pe,x as Ie}from"./WorkbenchLayout-CoYxMzzR.js";import{M as Le}from"./MobileCreateSessionSheet-BS881Agk.js";import{r as De,k as Te,l as Re,m as Ge,n as ue,o as se,p as ne,q as Oe,b as Be,c as We}from"./workbench-navigation-Bs4OQYD3.js";import{w as he}from"./styles-DwSuZo1w.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./host-alias-CeDJeL0T.js";import"./DesktopModal-DyC_e0eF.js";import"./relay-entry-B6UDc5cD.js";import"./WorkbenchModal-2PaCY_Gj.js";import"./MobileSheet-C32hwIFd.js";const Ve=420,$e=156;function Fe({entry:t,isFavorite:i,isActive:u=!1,depth:h=0,variant:c="default",workspaceTone:A="root",hasSubsessions:m=!1,subsessionsExpanded:y=!1,showActions:z=!0,onActivate:q,onToggleSubsessions:B,onToggleFavorite:te,onArchive:W,onUnarchive:ie,onRename:r}){var v;const[w,D]=d.useState(!1),[T,R]=d.useState(null),[j,V]=d.useState(null),C=d.useRef(null),G=d.useRef(!1),O=d.useRef(null),$=ye(),{session:l,workspace:oe}=t,F=l.title??l.sessionId,J=fe(l.provider),H=[J,He(l.lastMessageAt??l.updatedAt??null),ce(l)].filter(Boolean).join(" · "),_=c==="mobile"?null:ce(l),K=_?Se("session-list-activity-badge",l):null,N=c!=="mobile",U=N?De(l.parallelGroup):null,Z=N?Te(l.parallelGroup):null,ae=N?Re(l.parallelGroup):void 0;d.useEffect(()=>()=>{Y()},[]),d.useLayoutEffect(()=>{if(!w||!j||typeof window>"u"){R(null);return}const n=()=>{var I,S;const g=Ne(j,{width:((I=O.current)==null?void 0:I.offsetWidth)??0,height:((S=O.current)==null?void 0:S.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:$e});R({position:"fixed",left:`${Math.round(g.left)}px`,top:`${Math.round(g.top)}px`,width:`${Math.round(g.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(g.maxHeight)}px`,transformOrigin:g.transformOrigin})},x=g=>{var S;const I=g.target;I&&!((S=O.current)!=null&&S.contains(I))&&k()},P=g=>{g.key==="Escape"&&k()};return n(),window.addEventListener("pointerdown",x),window.addEventListener("keydown",P),window.addEventListener("resize",n),window.addEventListener("scroll",n,!0),()=>{window.removeEventListener("pointerdown",x),window.removeEventListener("keydown",P),window.removeEventListener("resize",n),window.removeEventListener("scroll",n,!0)}},[j,w]);function X(n){V(n),D(!0)}function k(){D(!1),V(null)}function Y(){C.current!==null&&(window.clearTimeout(C.current),C.current=null)}function le(n){if(!z||n.pointerType==="mouse")return;const x={x:n.clientX,y:n.clientY};Y(),C.current=window.setTimeout(()=>{G.current=!0,$.trigger("gesture"),X(x)},Ve)}function E(){Y()}function Q(){if(G.current){G.current=!1;return}$.trigger("selection"),q(l.sessionId)}const s=async()=>{const n=window.prompt(a("shell.renameModalDescription"),F);n&&(await r(l.sessionId,n.trim()),k())},o=async()=>{if(l.isArchived){await ie(l.sessionId),k();return}await W(l.sessionId),k()},p=()=>{te(l.sessionId),k()},f=n=>{if(n.key!=="ContextMenu"&&!(n.shiftKey&&n.key==="F10"))return;n.preventDefault(),n.stopPropagation();const x=n.currentTarget.getBoundingClientRect();X({x:x.right,y:x.bottom})},M=w&&typeof document<"u"?pe.createPortal(e.jsxs("div",{ref:O,className:"session-action-menu surface-card",role:"menu","aria-label":a("shell.sessionMoreAction"),style:T??{position:"fixed",top:0,left:0,visibility:"hidden"},onClick:n=>n.stopPropagation(),children:[e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:p,children:i?a("shell.unfavoriteAction"):a("shell.favoriteAction")}),e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void o(),children:l.isArchived?a("shell.unarchiveAction"):a("shell.archiveAction")}),e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void s(),children:a("shell.renameAction")})]}),document.body):null;return e.jsxs("article",{className:"session-list-item","data-depth":h,"data-active":u,"data-workspace-tone":A,"data-has-subsessions":m,"data-variant":c,"data-parallel-group":N&&l.parallelGroup?"true":void 0,"data-parallel-role":N?((v=l.parallelGroup)==null?void 0:v.role)??void 0:void 0,style:ae,onContextMenu:n=>{z&&(n.preventDefault(),n.stopPropagation(),X({x:n.clientX,y:n.clientY}))},children:[m?e.jsx("button",{type:"button",className:"session-list-subsession-toggle","aria-label":y?a("shell.subagentCollapse"):a("shell.subagentExpand"),title:y?a("shell.subagentCollapse"):a("shell.subagentExpand"),"aria-expanded":y,onClick:n=>{n.stopPropagation(),$.trigger("selection"),B==null||B()},children:e.jsx("span",{className:me(l,{isActive:u,hasSubsessions:m}),"aria-hidden":"true"})}):e.jsx("span",{className:me(l,{isActive:u,hasSubsessions:m}),"aria-hidden":"true"}),e.jsx("button",{type:"button",className:"session-list-link",onClick:Q,onPointerDown:le,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onKeyDown:f,children:e.jsxs("div",{className:"session-list-copy",children:[e.jsxs("div",{className:"session-list-title-row",children:[e.jsx("div",{className:"session-list-title",children:F||a("shell.searchEntry")}),U?e.jsx("span",{className:"session-list-parallel-badge",children:U}):null,Z?e.jsx("span",{className:"session-list-parallel-role-badge",children:Z}):null]}),e.jsx("div",{className:"session-list-meta",children:c==="mobile"?e.jsx(e.Fragment,{children:e.jsx("span",{children:H})}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:oe.name}),_&&K?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{className:K,children:_})]}):null,e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:J})]})})]})}),M]})}function me(t,i){return ke("session-list-indicator",t,{isActive:i.isActive,hasSubagents:i.hasSubsessions})}function He(t){return t?new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):a("common.unknown")}const ee=5;function cs(){var Q;const t=je(),{navigationGroups:i,favoriteSessionIds:u,currentWorkspaceId:h,currentSessionId:c,navigationLoading:A,selectWorkspace:m,toggleFavoriteSession:y,archiveSession:z,unarchiveSession:q,renameSession:B,startDraftSession:te}=Me(),W=Ae(i),ie=d.useMemo(()=>Ce(i),[i]),r=de(i,h)??de(i,((Q=i[0])==null?void 0:Q.workspace.id)??null),w=W.find(s=>s.workspace.id===(r==null?void 0:r.workspace.id))??(r?{workspace:r.workspace,label:r.workspace.name,subtitle:r.workspace.path}:null),D=d.useMemo(()=>new Set(u),[u]),T=d.useMemo(()=>r?r.sessions.filter(s=>{if(s.isArchived)return!1;const o=Ge(s,{mode:"mobile"});if(!o)return!0;const p=r.sessions.find(f=>f.sessionId===o);return!p||!p.isArchived}).map(s=>({session:s,workspace:r.workspace})):[],[r]),R=d.useMemo(()=>T.filter(s=>D.has(s.session.sessionId)),[T,D]),j=d.useMemo(()=>ue(T,{mode:"mobile"}),[T]),V=d.useMemo(()=>ue(R,{mode:"mobile"}),[R]),C=d.useMemo(()=>r?r.sessions.filter(Ee):[],[r]),G=(r==null?void 0:r.workspace.id)??"",O=!!G,[$,l]=d.useState([]),[oe,F]=d.useState({}),[J,H]=d.useState(!1),[_,K]=d.useState(!1),[N,U]=d.useState(null);d.useEffect(()=>{F(s=>{const o={};for(const p of j){const f=se(ne(p));if(f.length===0)continue;const M=f.findIndex(v=>v.item.session.sessionId===c);o[p.item.session.sessionId]=Ye(f.length,ee,s[p.item.session.sessionId],M)}return ze(s,o)?s:o})},[c,j]),d.useEffect(()=>{if(!c)return;const s=Oe(j,c,o=>o.session.sessionId);s.length!==0&&l(o=>{const p=new Set(o);let f=!1;for(const M of s)p.has(M)||(p.add(M),f=!0);return f?Array.from(p):o})},[c,j]);function Z(s){l(o=>o.includes(s)?o.filter(p=>p!==s):[...o,s])}function ae(s){return oe[s]??ee}function X(s){F(o=>({...o,[s]:(o[s]??ee)+ee}))}function k(s,o){he("immersive"),t(We(s,o))}function Y(s,o){H(!1),he("immersive"),te(s,o)}async function le(s){U(s);try{await q(s)}finally{U(o=>o===s?null:o)}}function E(s,o=!1,p=[],f=!1,M=!1){var re;const v=s.item.session.sessionId,n=s.children,x=s.depth===0&&n.length>0,P=o||x&&$.includes(v),g=P&&x,I=g?Xe(s,ae(v)):s,S=P?I.children:[],be=se(n).length,xe=se(S).length,ge=g&&xe<be,we=s.depth>0?[...p,f]:[...p];return e.jsxs("div",{className:"session-list-tree-node",children:[e.jsxs("div",{className:"session-list-tree-row",style:{"--session-tree-depth":s.depth},children:[s.depth>0?e.jsxs("div",{className:"session-tree-guides","aria-hidden":"true",style:{"--session-tree-depth":s.depth},children:[p.map((b,L)=>b?e.jsx("span",{className:"session-tree-guide-column",style:{"--session-tree-level":L+1}},`${v}:ancestor:${L}`):null),e.jsx("span",{className:"session-tree-guide-branch","data-continue":f,"data-first":M,style:{"--session-tree-level":s.depth},children:e.jsx("span",{className:"session-tree-guide-branch-horizontal"})})]}):null,e.jsx(Fe,{entry:s.item,isFavorite:D.has(v),isActive:c===v,depth:s.depth,variant:"mobile",workspaceTone:((re=ie[s.item.workspace.id])==null?void 0:re.tone)??"root",hasSubsessions:x,subsessionsExpanded:P,onActivate:b=>k(s.item.workspace.id,b),onToggleSubsessions:x?()=>Z(v):void 0,onToggleFavorite:b=>{y(b)},onArchive:b=>z(b),onUnarchive:b=>q(b),onRename:(b,L)=>B(b,L)})]}),P&&S.length>0?e.jsx("div",{className:"session-list-children",children:S.map((b,L)=>E(b,!0,we,L<S.length-1,L===0))}):null,ge?e.jsx("div",{className:"session-list-children",children:e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>X(v),children:a("shell.subagentExpandMore")})}):null]},`${s.item.workspace.id}:${v}`)}return e.jsxs("main",{className:"session-index-page mobile-feature-page mobile-page-scroll-root mobile-page-with-top-header",children:[e.jsx(Pe,{currentWorkspace:w?{id:w.workspace.id,name:w.label,path:w.subtitle}:null,workspaces:i.map(s=>s.workspace),workspaceOptions:W,onSelectWorkspace:s=>{m(s),t(Be(s))},content:e.jsx("button",{type:"button",className:"primary-button mobile-session-index-create-button",disabled:A||!O,onClick:()=>H(!0),children:a("shell.createSession")})}),e.jsxs("div",{className:"mobile-page-top-body",children:[e.jsx("div",{className:"session-index-archive-actions",children:e.jsxs("button",{type:"button",className:"primary-button mobile-session-index-create-button session-index-archive-button",disabled:A||!r,onClick:()=>K(!0),children:[e.jsx("span",{children:a("shell.archiveViewAction")}),e.jsx("span",{className:"session-index-archive-count",children:C.length})]})}),V.length>0?e.jsxs("section",{className:"session-section session-section-sheet",children:[e.jsxs("header",{className:"session-section-heading",children:[e.jsx("div",{children:e.jsx("h2",{children:a("shell.favoriteSectionTitle")})}),e.jsx("span",{className:"session-section-count",children:R.length})]}),e.jsx("div",{className:"session-current-workspace-list",children:V.map(s=>E(s))})]}):null,e.jsxs("section",{className:"session-section session-section-sheet",children:[e.jsxs("header",{className:"session-section-heading",children:[e.jsx("div",{children:e.jsx("h2",{children:a("shell.mobileConversationCurrentWorkspaceSection")})}),e.jsx("span",{className:"session-section-count",children:j.length})]}),j.length===0?e.jsx("p",{className:"session-section-empty",children:A?a("shell.searchSessionHint"):a("shell.emptyWorkspaceSessions")}):e.jsx("div",{className:"session-current-workspace-list",children:j.map(s=>E(s))})]})]}),e.jsx(Le,{open:J,workspaces:i.map(s=>s.workspace),workspaceOptions:W,initialWorkspaceId:h??G,onClose:()=>H(!1),onSelect:Y}),e.jsx(_e,{open:_,workspaceName:(w==null?void 0:w.label)??(r==null?void 0:r.workspace.name)??null,sessions:C,restoringSessionId:N,onClose:()=>{N||K(!1)},onRestore:s=>void le(s)})]})}function _e({open:t,workspaceName:i,sessions:u,restoringSessionId:h,onClose:c,onRestore:A}){return d.useEffect(()=>{if(!t)return;function m(y){y.key==="Escape"&&!h&&c()}return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m)}},[c,t,h]),!t||typeof document>"u"?null:pe.createPortal(e.jsxs("div",{className:"workbench-modal-layer",children:[e.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":a("common.close"),disabled:!!h,onClick:c}),e.jsxs("section",{className:"workbench-modal-card surface-card",role:"dialog","aria-modal":"true","aria-label":a("shell.archiveModalTitle"),children:[e.jsx("div",{className:"workbench-modal-header",children:e.jsxs("div",{className:"workbench-modal-title-wrap",children:[e.jsx("h2",{children:a("shell.archiveModalTitle")}),e.jsx("p",{children:i?`${i} · ${a("shell.archiveModalDescription")}`:a("shell.archiveModalDescription")})]})}),e.jsx("div",{className:"workbench-modal-body",children:u.length>0?e.jsx("div",{className:"workbench-archive-list",children:u.map(m=>{const y=Ie(m);return e.jsxs("article",{className:"workbench-archive-item",children:[e.jsxs("div",{className:"workbench-archive-item-main",children:[e.jsxs("div",{className:"workbench-archive-title-row",children:[e.jsx("strong",{title:m.title??m.sessionId,children:m.title??m.sessionId}),y?e.jsx("span",{className:"session-fork-badge archive-child",children:y}):null]}),e.jsx("p",{children:Ke(m)})]}),e.jsx("button",{type:"button",className:"secondary-button",disabled:h===m.sessionId,onClick:()=>{A(m.sessionId)},children:a("shell.unarchiveAction")})]},m.sessionId)})}):e.jsx("p",{className:"workbench-section-empty",children:a("shell.archiveEmpty")})})]})]}),document.body)}function Ke(t){const i=fe(t.provider),u=Ue(t.lastMessageAt??t.updatedAt??null);return[i,u].filter(Boolean).join(" · ")}function Ue(t){if(!t)return null;const i=Date.parse(t);return Number.isNaN(i)?null:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(i)}function Xe(t,i){const u=new Set(se(ne(t)).sort((h,c)=>(c.item.session.lastMessageAt??c.item.session.updatedAt).localeCompare(h.item.session.lastMessageAt??h.item.session.updatedAt)).slice(0,i).map(h=>h.item.session.sessionId));return{...t,children:ve(ne(t),u)}}function ve(t,i){return t.flatMap(u=>{const h=ve(ne(u),i);return!i.has(u.item.session.sessionId)&&h.length===0?[]:[{...u,children:h}]})}function Ye(t,i,u,h=-1){if(t<=0)return 0;const c=h>=0?Math.max(i,h+1):i;return Math.min(t,Math.max(u??0,c))}function ze(t,i){const u=Object.keys(t),h=Object.keys(i);return u.length!==h.length?!1:u.every(c=>t[c]===i[c])}export{cs as SessionIndexPage};