@tencent-ai/codebuddy-code 2.134.0-dev.c172de2.202608121546 → 2.135.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/codebuddy-headless.js +118 -118
  3. package/dist/codebuddy.js +80 -80
  4. package/dist/web-ui/assets/{CanvasPaneStandaloneView-DgMTB0Mb.js → CanvasPaneStandaloneView-DeJD7bJv.js} +1 -1
  5. package/dist/web-ui/assets/{CanvasView-3QngUA7x.js → CanvasView-V2DzC5ig.js} +1 -1
  6. package/dist/web-ui/assets/{DocsView-BoczVSee.js → DocsView-BwjfIgJw.js} +1 -1
  7. package/dist/web-ui/assets/EditorView-DEmkNiHo.js +95 -0
  8. package/dist/web-ui/assets/{KeybindingsView-BiwRw-4R.js → KeybindingsView-CLga9s1T.js} +1 -1
  9. package/dist/web-ui/assets/{LogsView-B8XmcVTr.js → LogsView-Bd11aAMW.js} +2 -2
  10. package/dist/web-ui/assets/{MetricsView-lzImG0av.js → MetricsView-Byap1DzP.js} +4 -4
  11. package/dist/web-ui/assets/{RemoteControlView-Bv4Ym4nD.js → RemoteControlView-BqiUehl-.js} +4 -4
  12. package/dist/web-ui/assets/StatsView-Cr230NV8.js +12 -0
  13. package/dist/web-ui/assets/{TracesView-kF2Bi6Uu.js → TracesView-bKA1QIAI.js} +3 -3
  14. package/dist/web-ui/assets/{WorkersView-VzjZfrZu.js → WorkersView-DY0kEifB.js} +4 -4
  15. package/dist/web-ui/assets/{canvas-store-CX4TeurF.js → canvas-store-hkRzwbw-.js} +1 -1
  16. package/dist/web-ui/assets/{cssMode-CEfvy9LI.js → cssMode-DVvwMwN6.js} +1 -1
  17. package/dist/web-ui/assets/{editor.main-BeJ0HdEs.js → editor.main-vO8swxPL.js} +3 -3
  18. package/dist/web-ui/assets/{freemarker2-DnkFzY6t.js → freemarker2-BY-2-rq2.js} +1 -1
  19. package/dist/web-ui/assets/{handlebars-1NAOMqYh.js → handlebars-D_vy9gpm.js} +1 -1
  20. package/dist/web-ui/assets/{html-BP0ejrFF.js → html-GglpzIxT.js} +1 -1
  21. package/dist/web-ui/assets/{htmlMode-Djp_2npQ.js → htmlMode-DUBQpmgz.js} +1 -1
  22. package/dist/web-ui/assets/index-C74qhjeJ.css +32 -0
  23. package/dist/web-ui/assets/{index-DNUXcSh8.js → index-DC-fErwI.js} +216 -216
  24. package/dist/web-ui/assets/{javascript-J-jeSPRJ.js → javascript-C9og_HZL.js} +1 -1
  25. package/dist/web-ui/assets/{jsonMode-DwxnBMDi.js → jsonMode-Cs25xE2e.js} +1 -1
  26. package/dist/web-ui/assets/{liquid-p7dNfV0Z.js → liquid-BQ5j4ocH.js} +1 -1
  27. package/dist/web-ui/assets/{lspLanguageFeatures-DEpBaaQs.js → lspLanguageFeatures-k6vDy77A.js} +1 -1
  28. package/dist/web-ui/assets/{mdx-QX-6YS-2.js → mdx-BnZXGp9g.js} +1 -1
  29. package/dist/web-ui/assets/{minus-CjhfXa84.js → minus-CND1LKfM.js} +1 -1
  30. package/dist/web-ui/assets/{python-DXTI7QZI.js → python-B65aRwBG.js} +1 -1
  31. package/dist/web-ui/assets/{razor-BwsYliyu.js → razor-OgH9GFyd.js} +1 -1
  32. package/dist/web-ui/assets/{server-DTGjlz_2.js → server-C_x9ee7t.js} +1 -1
  33. package/dist/web-ui/assets/{tsMode-CAro1DF_.js → tsMode-DQdvo31S.js} +1 -1
  34. package/dist/web-ui/assets/{typescript-MzPA2Aci.js → typescript-B4pz8IUO.js} +1 -1
  35. package/dist/web-ui/assets/{worker-store-CeRgJcBb.js → worker-store-CC1BvZFl.js} +1 -1
  36. package/dist/web-ui/assets/{xml-_dZXiOu_.js → xml-BWp6ggOb.js} +1 -1
  37. package/dist/web-ui/assets/{yaml-BrzS0hUR.js → yaml-26TypAAl.js} +1 -1
  38. package/dist/web-ui/index.html +21 -5
  39. package/dist/web-ui/sw.js +1 -1
  40. package/package.json +2 -3
  41. package/product.cloudhosted.json +2 -2
  42. package/product.internal.json +2 -2
  43. package/product.ioa.json +2 -2
  44. package/product.json +2 -2
  45. package/product.selfhosted.json +2 -2
  46. package/vendor/shim/brokered-bin/codebuddy-toybox-dispatch +32 -0
  47. package/dist/web-ui/assets/EditorView-BUsQ-90n.js +0 -90
  48. package/dist/web-ui/assets/StatsView-BWPSIETb.js +0 -12
  49. package/dist/web-ui/assets/index-Bcw4ajER.css +0 -32
@@ -1 +1 @@
1
- import{a as r,j as a}from"./markdown-DIY6o85n.js";import{u as f,g as c,a as l,S as x,T as h}from"./index-DNUXcSh8.js";import{u as d}from"./canvas-store-CX4TeurF.js";import"./vendor-D35k0Cos.js";function j(){const{t:i}=f(),[s,u]=r.useState(()=>c().get("paneId")||"");r.useEffect(()=>{const e=()=>{u(c().get("paneId")||"")};return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);const t=d(e=>Object.values(e.tiles).find(n=>n.paneId===s)??null),m=l(e=>{var n;return s?(n=e.panes[s])==null?void 0:n.title:null}),o=d(e=>e.setTilePty),p=r.useCallback(e=>{t&&o(t.id,e.sessionId,e.cwd||null)},[t,o]);return r.useEffect(()=>{if(!s)return;const e=l.getState();e.panes[s]||l.setState({panes:{...e.panes,[s]:{id:s,ptySessionId:(t==null?void 0:t.ptySessionId)??null,ptyStatus:"disconnected",errorMessage:null}}})},[s,t==null?void 0:t.ptySessionId]),s?a.jsxs("div",{className:"flex flex-col h-full w-full bg-bg-primary",children:[a.jsxs("div",{className:"flex items-center gap-2 px-3 select-none",style:{height:32,background:"var(--color-canvas-tile-header)",color:"var(--color-canvas-tile-header-text)",borderBottom:"1px solid var(--color-border-default)"},children:[a.jsx(x,{size:14,style:{opacity:.6}}),a.jsx("span",{className:"text-xs truncate",style:{fontSize:12,fontWeight:500},children:m||i("canvas.defaultTitle")})]}),a.jsx("div",{className:"flex-1 min-h-0 relative",children:a.jsx(h,{paneId:s,initialCwd:(t==null?void 0:t.cwd)??null,onPtyCreated:p})})]}):a.jsx("div",{className:"flex items-center justify-center h-full w-full bg-bg-primary text-text-secondary text-sm",children:i("canvas.standalone.missingPaneId")})}export{j as CanvasPaneStandaloneView};
1
+ import{a as r,j as a}from"./markdown-DIY6o85n.js";import{u as f,g as c,a as l,S as x,T as h}from"./index-DC-fErwI.js";import{u as d}from"./canvas-store-hkRzwbw-.js";import"./vendor-D35k0Cos.js";function j(){const{t:i}=f(),[s,u]=r.useState(()=>c().get("paneId")||"");r.useEffect(()=>{const e=()=>{u(c().get("paneId")||"")};return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);const t=d(e=>Object.values(e.tiles).find(n=>n.paneId===s)??null),m=l(e=>{var n;return s?(n=e.panes[s])==null?void 0:n.title:null}),o=d(e=>e.setTilePty),p=r.useCallback(e=>{t&&o(t.id,e.sessionId,e.cwd||null)},[t,o]);return r.useEffect(()=>{if(!s)return;const e=l.getState();e.panes[s]||l.setState({panes:{...e.panes,[s]:{id:s,ptySessionId:(t==null?void 0:t.ptySessionId)??null,ptyStatus:"disconnected",errorMessage:null}}})},[s,t==null?void 0:t.ptySessionId]),s?a.jsxs("div",{className:"flex flex-col h-full w-full bg-bg-primary",children:[a.jsxs("div",{className:"flex items-center gap-2 px-3 select-none",style:{height:32,background:"var(--color-canvas-tile-header)",color:"var(--color-canvas-tile-header-text)",borderBottom:"1px solid var(--color-border-default)"},children:[a.jsx(x,{size:14,style:{opacity:.6}}),a.jsx("span",{className:"text-xs truncate",style:{fontSize:12,fontWeight:500},children:m||i("canvas.defaultTitle")})]}),a.jsx("div",{className:"flex-1 min-h-0 relative",children:a.jsx(h,{paneId:s,initialCwd:(t==null?void 0:t.cwd)??null,onPtyCreated:p})})]}):a.jsx("div",{className:"flex items-center justify-center h-full w-full bg-bg-primary text-text-secondary text-sm",children:i("canvas.standalone.missingPaneId")})}export{j as CanvasPaneStandaloneView};
@@ -1,4 +1,4 @@
1
- var be=Object.defineProperty;var Se=(o,n,t)=>n in o?be(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t;var H=(o,n,t)=>Se(o,typeof n!="symbol"?n+"":n,t);import{a as f,j as h}from"./markdown-DIY6o85n.js";import{c as de,u as he,P as ke,E as xe,a as Te,S as Ee,C as ze,b as Me,M as Pe,d as Ie,X as je,T as Ce}from"./index-DNUXcSh8.js";import{M as re,a as ie,u as k,C as we,G as Ne,S as Re,R as ve,b as ce,c as le,T as Le}from"./canvas-store-CX4TeurF.js";import{M as He}from"./minus-CjhfXa84.js";import"./vendor-D35k0Cos.js";/**
1
+ var be=Object.defineProperty;var Se=(o,n,t)=>n in o?be(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t;var H=(o,n,t)=>Se(o,typeof n!="symbol"?n+"":n,t);import{a as f,j as h}from"./markdown-DIY6o85n.js";import{c as de,u as he,P as ke,E as xe,a as Te,S as Ee,C as ze,b as Me,M as Pe,d as Ie,X as je,T as Ce}from"./index-DC-fErwI.js";import{M as re,a as ie,u as k,C as we,G as Ne,S as Re,R as ve,b as ce,c as le,T as Le}from"./canvas-store-hkRzwbw-.js";import{M as He}from"./minus-CND1LKfM.js";import"./vendor-D35k0Cos.js";/**
2
2
  * @license lucide-react v1.18.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{a as _,j as a,M as xe,c as ge}from"./markdown-DIY6o85n.js";import{c as pe,e as be,u as H,i as ye,j as we,o as _e,k as ve,l as ie,F as je,m as q,n as Y,p as ke,q as Z,X as ze,E as Se,d as Ce,r as X}from"./index-DNUXcSh8.js";import"./vendor-D35k0Cos.js";/**
1
+ import{a as _,j as a,M as xe,c as ge}from"./markdown-DIY6o85n.js";import{c as pe,e as be,u as H,i as ye,j as we,o as _e,k as ve,l as ie,F as je,m as q,n as Y,p as ke,q as Z,X as ze,E as Se,d as Ce,r as X}from"./index-DC-fErwI.js";import"./vendor-D35k0Cos.js";/**
2
2
  * @license lucide-react v1.18.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1,95 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DC-fErwI.js","assets/markdown-DIY6o85n.js","assets/vendor-D35k0Cos.js","assets/index-C74qhjeJ.css"])))=>i.map(i=>d[i]);
2
+ import{c as ie,u as te,i as gt,s as Xt,L as ve,t as se,v as Yt,w as Jt,x as Ze,y as Zt,h as $e,e as bt,_ as Ue,z as es,A as ts,G as Se,B as ss,P as je,D as vt,H as as,I as Ne,J as xe,K as ns,X as jt,n as ce,N as is,O as rs,Q as yt,d as kt,R as ls,j as cs,o as os,k as ds,U as Ge,p as us,g as wt,V as Ct,W as hs,m as he,Y as ms,Z as Me,$ as fs,a0 as Nt,a1 as ne,a2 as ps,a as xs,M as gs,T as bs,a3 as St,a4 as vs,a5 as js,a6 as nt,l as et,a7 as ys,a8 as ks,a9 as Mt,aa as tt,C as ws,E as Pt,ab as Cs,ac as Ns,ad as Ss,ae as Ms,S as Ps,af as Ds,ag as it,ah as zs,ai as Es,aj as Rs,ak as Ts,al as rt,am as Ls}from"./index-DC-fErwI.js";import{a as n,j as e,M as $s,c as Fs}from"./markdown-DIY6o85n.js";import{M as Fe}from"./minus-CND1LKfM.js";import"./vendor-D35k0Cos.js";/**
3
+ * @license lucide-react v1.18.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const As=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],Is=ie("case-sensitive",As);/**
8
+ * @license lucide-react v1.18.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */const Os=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Bs=ie("chevron-left",Os);/**
13
+ * @license lucide-react v1.18.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */const _s=[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Ws=ie("copy-minus",_s);/**
18
+ * @license lucide-react v1.18.0 - ISC
19
+ *
20
+ * This source code is licensed under the ISC license.
21
+ * See the LICENSE file in the root directory of this source tree.
22
+ */const Hs=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],qs=ie("eye-off",Hs);/**
23
+ * @license lucide-react v1.18.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */const Vs=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Ks=ie("eye",Vs);/**
28
+ * @license lucide-react v1.18.0 - ISC
29
+ *
30
+ * This source code is licensed under the ISC license.
31
+ * See the LICENSE file in the root directory of this source tree.
32
+ */const Us=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Gs=ie("file-exclamation-point",Us);/**
33
+ * @license lucide-react v1.18.0 - ISC
34
+ *
35
+ * This source code is licensed under the ISC license.
36
+ * See the LICENSE file in the root directory of this source tree.
37
+ */const Qs=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]],Xs=ie("file-plus",Qs);/**
38
+ * @license lucide-react v1.18.0 - ISC
39
+ *
40
+ * This source code is licensed under the ISC license.
41
+ * See the LICENSE file in the root directory of this source tree.
42
+ */const Ys=[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]],Dt=ie("files",Ys);/**
43
+ * @license lucide-react v1.18.0 - ISC
44
+ *
45
+ * This source code is licensed under the ISC license.
46
+ * See the LICENSE file in the root directory of this source tree.
47
+ */const Js=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]],Zs=ie("fold-vertical",Js);/**
48
+ * @license lucide-react v1.18.0 - ISC
49
+ *
50
+ * This source code is licensed under the ISC license.
51
+ * See the LICENSE file in the root directory of this source tree.
52
+ */const ea=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ta=ie("folder-plus",ea);/**
53
+ * @license lucide-react v1.18.0 - ISC
54
+ *
55
+ * This source code is licensed under the ISC license.
56
+ * See the LICENSE file in the root directory of this source tree.
57
+ */const sa=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],aa=ie("house",sa);/**
58
+ * @license lucide-react v1.18.0 - ISC
59
+ *
60
+ * This source code is licensed under the ISC license.
61
+ * See the LICENSE file in the root directory of this source tree.
62
+ */const na=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],zt=ie("list",na);/**
63
+ * @license lucide-react v1.18.0 - ISC
64
+ *
65
+ * This source code is licensed under the ISC license.
66
+ * See the LICENSE file in the root directory of this source tree.
67
+ */const ia=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]],ra=ie("panel-bottom",ia);/**
68
+ * @license lucide-react v1.18.0 - ISC
69
+ *
70
+ * This source code is licensed under the ISC license.
71
+ * See the LICENSE file in the root directory of this source tree.
72
+ */const la=[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]],ca=ie("regex",la);/**
73
+ * @license lucide-react v1.18.0 - ISC
74
+ *
75
+ * This source code is licensed under the ISC license.
76
+ * See the LICENSE file in the root directory of this source tree.
77
+ */const oa=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],da=ie("scan",oa);/**
78
+ * @license lucide-react v1.18.0 - ISC
79
+ *
80
+ * This source code is licensed under the ISC license.
81
+ * See the LICENSE file in the root directory of this source tree.
82
+ */const ua=[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]],Et=ie("tree-pine",ua);/**
83
+ * @license lucide-react v1.18.0 - ISC
84
+ *
85
+ * This source code is licensed under the ISC license.
86
+ * See the LICENSE file in the root directory of this source tree.
87
+ */const ha=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]],ma=ie("unfold-vertical",ha);/**
88
+ * @license lucide-react v1.18.0 - ISC
89
+ *
90
+ * This source code is licensed under the ISC license.
91
+ * See the LICENSE file in the root directory of this source tree.
92
+ */const fa=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],pa=ie("whole-word",fa);function xa(t){const s=new Map;function a(r){const c=s.get(r);c!==void 0&&(clearTimeout(c),s.delete(r))}function i(r,c){a(r);const u=setTimeout(()=>{s.get(r)===u&&(s.delete(r),c())},t);s.set(r,u)}function l(){for(const r of s.values())clearTimeout(r);s.clear()}return{schedule:i,cancel:a,dispose:l}}function lt(t,s){const a=se.getState().pendingReveal;if(!a||a.path!==s)return!1;se.getState().setPendingReveal(null);const{line:i,col:l,query:r}=a,c=t.getModel();if(!c)return!1;const u=l&&l>0?l:1;if(t.revealLineInCenter(i),t.setPosition({lineNumber:i,column:u}),t.focus(),r){const d=c.findMatches(r,!1,!1,!1,null,!0);if(d.length>0){const h=d.find(m=>m.range.startLineNumber>=i)||d[0];t.setSelection(h.range),t.revealRangeInCenter(h.range);const g=d.map(m=>({range:m.range,options:{className:"search-find-match",overviewRuler:{color:"#d7ba7d",position:1}}})),b=t.deltaDecorations([],g);setTimeout(()=>{try{t.deltaDecorations(b,[])}catch{}},5e3)}}return!0}function Rt({path:t,content:s,language:a,onContentChange:i,onSave:l,minimap:r=!0,onCursorChange:c}){const{t:u}=te(),{resolved:d}=gt(),h=n.useRef(null),g=n.useRef(c);g.current=c;const b=d==="dark"?"cbc-dark":"cbc-light",[m,C]=n.useState(()=>typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);n.useEffect(()=>{const R=window.matchMedia("(prefers-reduced-motion: reduce)"),x=()=>C(R.matches);return R.addEventListener("change",x),()=>R.removeEventListener("change",x)},[]);const[D,E]=n.useState(!1);n.useEffect(()=>{let R=!1;return Xt().then(()=>{R||E(!0)}),()=>{R=!0}},[]);const S=e.jsxs("div",{className:"flex items-center justify-center h-full gap-2",style:{color:"var(--color-text-tertiary)"},children:[e.jsx(ve,{size:16,className:"animate-spin"}),e.jsx("span",{style:{fontSize:13},children:u("editor.loading")})]}),f=n.useCallback((R,x)=>{h.current=R,x.editor.defineTheme("cbc-dark",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#121314"}}),x.editor.defineTheme("cbc-light",{base:"vs",inherit:!0,rules:[],colors:{"editor.background":"#ffffff"}}),x.editor.setTheme(b),R.addCommand(x.KeyMod.CtrlCmd|x.KeyCode.KeyS,()=>{l()});const T=()=>{const $=g.current;if(!$)return;const j=R.getPosition(),N=R.getSelection();if(!j)return;let A=0,I=0;if(N&&!N.isEmpty()){const O=R.getModel();O&&(A=O.getValueInRange(N).length,I=Math.abs(N.endLineNumber-N.startLineNumber)+1)}$(j.lineNumber,j.column,A,I)};R.onDidChangeCursorPosition(T),R.onDidChangeCursorSelection(T),T()},[l]),y=n.useCallback(R=>{R!==void 0&&i(R)},[i]);n.useEffect(()=>{const R=h.current;if(!R)return;const x=R.getModel();x&&s.length>0&&x.getValue()!==s&&x.setValue(s)},[s]);const P=se(R=>R.pendingReveal);return n.useEffect(()=>{if(!P||P.path!==t)return;if(h.current){lt(h.current,t);return}let R=0;const x=setInterval(()=>{R++,h.current?(lt(h.current,t),clearInterval(x)):R>=50&&clearInterval(x)},50);return()=>clearInterval(x)},[t,P]),D?e.jsx(Yt,{height:"100%",language:a,theme:b,defaultValue:s,onChange:y,onMount:f,loading:S,options:{fontSize:13,fontFamily:"'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace",lineHeight:20,minimap:{enabled:r,maxColumn:80},scrollBeyondLastLine:!1,automaticLayout:!0,wordWrap:"off",tabSize:4,insertSpaces:!0,renderWhitespace:"selection",bracketPairColorization:{enabled:!0},padding:{top:8},smoothScrolling:!m,cursorBlinking:m?"solid":"smooth",cursorSmoothCaretAnimation:m?"off":"on",fixedOverflowWidgets:!0}},t):S}function Tt({tab:t,onRetry:s}){const{t:a}=te();return t.loadStatus==="ready"?null:t.loadStatus==="loading"?e.jsxs("div",{className:"editor-content-state",role:"status","aria-live":"polite",children:[e.jsx("span",{className:"editor-state-spinner","aria-hidden":"true"}),e.jsx("span",{children:a("editor.loadingFile")})]}):t.loadStatus==="too-large"?e.jsxs("div",{className:"editor-content-state",role:"status",children:[e.jsx(Gs,{className:"editor-content-state-icon",size:24,"aria-hidden":"true"}),e.jsx("span",{children:a("editor.fileTooLarge")})]}):e.jsxs("div",{className:"editor-content-state editor-content-state-error",role:"alert",children:[e.jsx(Jt,{className:"editor-content-state-icon",size:24,"aria-hidden":"true"}),e.jsx("span",{children:a("editor.loadError")}),t.loadError&&e.jsx("span",{className:"editor-content-state-reason",children:t.loadError}),e.jsx("button",{type:"button",className:"editor-content-state-retry",onClick:()=>{Promise.resolve(s()).catch(()=>{})},children:a("editor.retryLoad")})]})}async function de(t,s){var c;const a=Ze(),i={...s,...a?{cwd:a}:{}},l=await Zt(`/api/v1/git/${t}`,{method:"POST",headers:{...$e(),"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok){const u=await l.json().catch(()=>({error:{message:l.statusText}}));throw new Error(((c=u.error)==null?void 0:c.message)||`Git API error: ${l.status}`)}const r=await l.json();return r.data??r}async function ga(){return de("status")}async function ct(t){await de("stage",{paths:t})}async function ot(t){await de("unstage",{paths:t})}async function ba(t){return de("commit",{message:t})}async function Lt(t,s){return de("diff",{path:t,staged:s})}async function _e(t,s){await de("discard",{paths:t,useTrash:s})}async function va(){return(await de("branches")).branches}async function ja(t){return de("branch/switch",{name:t})}async function ya(t,s=!0){return de("branch/create",{name:t,checkout:s})}async function ka(){return de("push")}async function wa(){return de("pull")}async function Ca(t){return(await de("log",{limit:t})).entries}const Na=3e3;let Te=null,We=!1,He=!1;async function Sa(){try{const{authHeaders:t}=await Ue(async()=>{const{authHeaders:i}=await import("./index-DC-fErwI.js").then(l=>l.aR);return{authHeaders:i}},__vite__mapDeps([0,1,2,3])),{fetchWithRetry:s}=await Ue(async()=>{const{fetchWithRetry:i}=await import("./index-DC-fErwI.js").then(l=>l.aQ);return{fetchWithRetry:i}},__vite__mapDeps([0,1,2,3])),a=await s("/api/v1/info",{headers:t()});if(a.ok){const i=await a.json();return(i.data??i).cwd||void 0}}catch{}}const me=bt((t,s)=>({isGitRepo:!1,loading:!1,error:null,files:[],currentBranch:null,ahead:0,behind:0,remote:null,branches:[],branchesLoading:!1,selectedFile:null,selectedFileStaged:!1,diffResult:null,diffLoading:!1,commitMessage:"",committing:!1,pushing:!1,pulling:!1,lastOperationMessage:null,refresh:async()=>{if(We)return;We=!0,s().files.length===0&&!s().isGitRepo&&t({loading:!0,error:null});try{const i=await ga();t({isGitRepo:i.isGitRepo,files:i.files,currentBranch:i.branch,ahead:i.ahead,behind:i.behind,remote:i.remote,loading:!1})}catch(i){t({loading:!1,error:i.message})}finally{We=!1}},loadBranches:async()=>{t({branchesLoading:!0});try{const a=await va();t({branches:a,branchesLoading:!1})}catch{t({branchesLoading:!1})}},stageFile:async a=>{await ct([a]),await s().refresh()},unstageFile:async a=>{await ot([a]),await s().refresh()},stageAll:async()=>{const a=s().files.filter(i=>!i.staged).map(i=>i.path);a.length>0&&(await ct(a),await s().refresh())},unstageAll:async()=>{const a=s().files.filter(i=>i.staged).map(i=>i.path);a.length>0&&(await ot(a),await s().refresh())},discardFile:async a=>{await _e([a],!0),await s().refresh()},discardAll:async()=>{const a=s().files.filter(r=>!r.staged),i=a.filter(r=>r.status!=="untracked"),l=a.filter(r=>r.status==="untracked");i.length>0&&await _e(i.map(r=>r.path)),l.length>0&&await _e(l.map(r=>r.path),!0),await s().refresh()},commit:async()=>{const a=s().commitMessage.trim();if(a){t({committing:!0});try{const i=await ba(a);t({committing:!1,commitMessage:"",lastOperationMessage:i.success?"Committed successfully":i.message}),await s().refresh()}catch(i){t({committing:!1,lastOperationMessage:i.message})}}},push:async()=>{t({pushing:!0});try{const a=await ka();t({pushing:!1,lastOperationMessage:a.success?"Pushed successfully":a.message}),await s().refresh()}catch(a){t({pushing:!1,lastOperationMessage:a.message})}},pull:async()=>{t({pulling:!0});try{const a=await wa();t({pulling:!1,lastOperationMessage:a.success?"Pulled successfully":a.message}),await s().refresh()}catch(a){t({pulling:!1,lastOperationMessage:a.message})}},switchBranch:async a=>{try{const i=await ja(a);t({lastOperationMessage:i.success?`Switched to ${a}`:i.message}),await s().refresh()}catch(i){t({lastOperationMessage:i.message})}},createBranch:async a=>{try{const i=await ya(a);t({lastOperationMessage:i.success?`Created branch ${a}`:i.message}),await s().refresh(),await s().loadBranches()}catch(i){t({lastOperationMessage:i.message})}},selectFile:async(a,i)=>{if(s().selectedFile===a&&s().selectedFileStaged===i){t({selectedFile:null,diffResult:null,selectedFileStaged:!1});return}t({selectedFile:a,selectedFileStaged:i,diffLoading:!0,diffResult:null});try{const l=await Lt(a,i);t({diffResult:l,diffLoading:!1})}catch{t({diffLoading:!1})}},clearSelection:()=>t({selectedFile:null,diffResult:null,selectedFileStaged:!1}),setCommitMessage:a=>t({commitMessage:a}),clearOperationMessage:()=>t({lastOperationMessage:null}),startWatching:async()=>{if(He)return;let a=Ze();a||(a=await Sa()),a&&(He=!0,Te=setInterval(()=>{s().refresh()},Na))},stopWatching:async()=>{He=!1,Te&&(clearInterval(Te),Te=null)}}));es(async()=>{const t=me.getState();await t.stopWatching(),t.refresh(),await t.startWatching()});function $t({currentBranch:t,branches:s,branchesLoading:a,onSwitch:i,onCreate:l,onLoadBranches:r,actions:c,defaultOpen:u,onClose:d}){const{t:h}=te(),[g,b]=n.useState(u??!1),[m,C]=n.useState(""),[D,E]=n.useState(""),[S,f]=n.useState(0),[y,P]=n.useState(!1),R=n.useRef(null),x=n.useCallback(o=>{b(o),o||d==null||d()},[d]);n.useEffect(()=>{const o=setTimeout(()=>E(m),100);return()=>clearTimeout(o)},[m]),n.useEffect(()=>{g&&r()},[g,r]),n.useEffect(()=>{g?setTimeout(()=>{var o;return(o=R.current)==null?void 0:o.focus()},0):(C(""),E(""),f(0),P(!1))},[g]);const{localBranches:T,remoteBranches:$,flatList:j}=n.useMemo(()=>{let o;if(D){const z=[];for(const H of s){const _=ts(D,H.name);_.match&&z.push({...H,_score:_.score})}z.sort((H,_)=>_._score-H._score),o=z}else o=s;const w=o.filter(z=>!z.isRemote),G=o.filter(z=>z.isRemote),Y=[...w,...G];return{localBranches:w,remoteBranches:G,flatList:Y}},[s,D]);n.useEffect(()=>{f(0)},[m]);const N=n.useCallback(o=>{o.key==="Escape"?x(!1):o.key==="ArrowDown"?(o.preventDefault(),f(w=>Math.min(w+1,j.length-1))):o.key==="ArrowUp"?(o.preventDefault(),f(w=>Math.max(w-1,0))):o.key==="Enter"&&(o.preventDefault(),y?m.trim()&&(l(m.trim()),x(!1)):j[S]?(i(j[S].name),x(!1)):m.trim()&&j.length===0&&(l(m.trim()),x(!1)))},[j,S,y,m,i,l]),A=n.useCallback(o=>{i(o),x(!1)},[i]),I=n.useCallback(()=>{P(!0),setTimeout(()=>{var o;return(o=R.current)==null?void 0:o.focus()},0)},[]),O=n.useCallback(()=>{m.trim()&&(l(m.trim()),x(!1))},[m,l]);return e.jsxs("div",{className:"branch-picker",children:[!u&&e.jsxs("div",{className:"branch-picker-header",children:[e.jsxs("button",{className:"branch-picker-trigger",onClick:()=>x(!g),title:t||"",children:[e.jsx(Se,{size:14,className:"branch-picker-icon"}),e.jsx("span",{className:"branch-picker-name",children:t||"No branch"})]}),c]}),g&&ss.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"branch-picker-backdrop",onClick:()=>x(!1)}),e.jsxs("div",{className:"branch-picker-dropdown",onKeyDown:N,onMouseDown:o=>o.stopPropagation(),onClick:o=>o.stopPropagation(),children:[e.jsx("div",{className:"branch-picker-search",children:e.jsx("input",{ref:R,className:"branch-picker-input",type:"text",value:m,onChange:o=>C(o.target.value),placeholder:y?h("ide.scm.newBranchPlaceholder")||"New branch name...":h("ide.scm.branchSearchPlaceholder")||"Select a branch or tag to checkout"})}),!y&&e.jsx("div",{className:"branch-picker-actions",children:e.jsxs("button",{className:"branch-picker-action",onClick:I,children:[e.jsx(je,{size:14}),e.jsx("span",{children:h("ide.scm.createBranch")||"Create new branch..."})]})}),y&&e.jsx("div",{className:"branch-picker-actions",children:e.jsxs("button",{className:"branch-picker-action branch-picker-action-confirm",onClick:O,disabled:!m.trim(),children:[e.jsx(je,{size:14}),e.jsx("span",{children:m.trim()?`Create branch "${m.trim()}"`:h("ide.scm.newBranchPlaceholder")||"Type branch name..."})]})}),j.length>0&&e.jsx(Ma,{flatList:j,localCount:T.length,remoteCount:$.length,currentBranch:t,highlightIdx:S,onSelect:A,onHover:f}),a&&j.length===0&&e.jsx("div",{className:"branch-picker-empty",children:"Loading..."}),!a&&j.length===0&&!y&&e.jsx("div",{className:"branch-picker-empty",children:D?h("ide.scm.noBranchMatch")||"No matching branches":h("ide.scm.noBranchMatch")||"No branches found"})]})]}),document.body)]})}const Ce=40,Le=24;function Ma({flatList:t,localCount:s,remoteCount:a,currentBranch:i,highlightIdx:l,onSelect:r,onHover:c}){const u=n.useRef(null),[d,h]=n.useState(0),[g,b]=n.useState(300);n.useEffect(()=>{const f=u.current;if(!f)return;const y=new ResizeObserver(P=>{for(const R of P)b(R.contentRect.height)});return y.observe(f),()=>y.disconnect()},[]),n.useEffect(()=>{const f=u.current;if(!f)return;const y=l*Ce;y<f.scrollTop?f.scrollTop=y:y+Ce>f.scrollTop+g&&(f.scrollTop=y+Ce-g)},[l,g]);const m=n.useCallback(f=>{h(f.target.scrollTop)},[]),C=t.length*Ce+(s>0&&a>0?Le:0)+(a>0?Le:0),D=Math.max(0,Math.floor(d/Ce)-2),E=Math.min(t.length,Math.ceil((d+g)/Ce)+2),S=[];s>0&&a>0&&D===0&&S.push(e.jsx("div",{className:"branch-picker-group-label",style:{height:Le},children:"branches"},"label-local"));for(let f=D;f<E;f++){const y=t[f];y&&(f===s&&a>0&&S.push(e.jsx("div",{className:"branch-picker-group-label",style:{height:Le},children:"remotes"},"label-remote")),S.push(e.jsx(Pa,{branch:y,isCurrent:y.name===i,isHighlighted:f===l,dataIdx:f,onSelect:r,onHover:()=>c(f)},y.name)))}return e.jsx("div",{ref:u,className:"branch-picker-list",onScroll:m,children:e.jsx("div",{style:{height:C,position:"relative"},children:e.jsx("div",{style:{position:"absolute",top:D*Ce,left:0,right:0},children:S})})})}function Pa({branch:t,isCurrent:s,isHighlighted:a,dataIdx:i,onSelect:l,onHover:r}){return e.jsxs("div",{className:`branch-picker-item ${a?"highlighted":""} ${s?"current":""}`,"data-idx":i,onClick:()=>l(t.name),onMouseEnter:r,title:t.lastCommitMessage?`${t.name}
93
+ ${t.lastCommitAuthor} • ${t.lastCommitHash} • ${t.lastCommitMessage}`:t.name,children:[e.jsxs("div",{className:"branch-picker-item-main",children:[e.jsx(Se,{size:14,className:"branch-picker-item-icon"}),e.jsx("span",{className:"branch-picker-item-name",children:t.name}),t.lastCommitDate&&e.jsx("span",{className:"branch-picker-item-date",children:t.lastCommitDate}),s&&e.jsx(vt,{size:14,className:"branch-picker-item-check"}),t.ahead||t.behind?e.jsxs("span",{className:"branch-picker-item-sync",children:[t.ahead?`↑${t.ahead}`:"",t.behind?`↓${t.behind}`:""]}):null]}),t.lastCommitMessage&&e.jsxs("div",{className:"branch-picker-item-detail",children:[e.jsx("span",{className:"branch-picker-item-author",children:t.lastCommitAuthor}),e.jsx("span",{className:"branch-picker-item-separator",children:"•"}),e.jsx("span",{className:"branch-picker-item-hash",children:t.lastCommitHash}),e.jsx("span",{className:"branch-picker-item-separator",children:"•"}),e.jsx("span",{className:"branch-picker-item-message",children:t.lastCommitMessage})]})]})}const dt={image:"Image",svg:"SVG",markdown:"Markdown Preview",pdf:"PDF",binary:"Binary"};function Ft({language:t,cursorLine:s,cursorColumn:a,selectedCount:i,selectedLines:l,viewMode:r="editor",isDirty:c=!1,saveStatus:u="idle",saveError:d,imageInfo:h,zoom:g,extraRight:b}){const{t:m}=te();if(r==="image"||r==="svg")return e.jsxs("div",{className:"editor-statusbar",children:[e.jsxs("div",{className:"editor-statusbar-left",children:[e.jsx(qe,{}),h&&e.jsxs("span",{className:"editor-statusbar-item",children:[h.width," × ",h.height]})]}),e.jsxs("div",{className:"editor-statusbar-right",children:[g!=null&&e.jsxs("span",{className:"editor-statusbar-item",children:[Math.round(g*100),"%"]}),e.jsx("span",{className:"editor-statusbar-item",children:dt[r]}),b]})]});if(r!=="editor")return e.jsxs("div",{className:"editor-statusbar",children:[e.jsx("div",{className:"editor-statusbar-left",children:e.jsx(qe,{})}),e.jsxs("div",{className:"editor-statusbar-right",children:[e.jsx("span",{className:"editor-statusbar-item",children:dt[r]||r}),b]})]});const C=`Ln ${s}, Col ${a}`;let D="";return i&&i>0&&(D=` (${i} ${m("editor.selected")})`,l&&l>1&&(D=` (${i} ${m("editor.selected")}, ${l} ${m("editor.lines")})`)),e.jsxs("div",{className:"editor-statusbar",children:[e.jsxs("div",{className:"editor-statusbar-left",children:[e.jsx(Da,{isDirty:c,saveStatus:u,saveError:d,translate:m}),e.jsx(qe,{}),e.jsxs("span",{className:"editor-statusbar-item editor-statusbar-cursor",children:[C,D]})]}),e.jsxs("div",{className:"editor-statusbar-right",children:[t&&e.jsx("span",{className:"editor-statusbar-item editor-statusbar-language",children:t}),b]})]})}function Da({isDirty:t,saveStatus:s,saveError:a,translate:i}){return s==="saving"?e.jsxs("span",{className:"editor-statusbar-item editor-statusbar-save",role:"status",children:[e.jsx("span",{className:"editor-status-save-spinner","aria-hidden":"true"}),i("editor.saving")]}):s==="error"?e.jsx("span",{className:"editor-statusbar-item editor-statusbar-save editor-statusbar-save-error",role:"status",title:a,children:i("editor.saveFailed")}):t?e.jsxs("span",{className:"editor-statusbar-item editor-statusbar-save editor-statusbar-save-dirty",role:"status",children:[e.jsx("span",{className:"editor-status-save-dot","aria-hidden":"true"}),i("editor.unsaved")]}):null}function qe(){const{currentBranch:t,branches:s,branchesLoading:a,isGitRepo:i,switchBranch:l,createBranch:r,loadBranches:c,refresh:u}=me(),[d,h]=n.useState(!1);n.useEffect(()=>{u()},[u]);const g=n.useCallback(m=>{l(m),h(!1)},[l]),b=n.useCallback(m=>{r(m),h(!1)},[r]);return i?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"editor-statusbar-branch",onClick:m=>{m.stopPropagation(),h(C=>!C)},onPointerDown:m=>m.stopPropagation(),onMouseDown:m=>m.stopPropagation(),"aria-expanded":d,title:t||"No branch",children:[e.jsx(Se,{size:12}),e.jsx("span",{children:t||"No branch"})]}),d&&e.jsx($t,{currentBranch:t,branches:s,branchesLoading:a,onSwitch:g,onCreate:b,onLoadBranches:c,defaultOpen:!0,onClose:()=>h(!1)})]}):null}function Ve(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"}function At({actions:t,onRequestClose:s}){const{t:a}=te(),{tabs:i,activeTabId:l,rootPath:r,setActiveTab:c,closeSavedTabs:u,reorderTabs:d,pinTab:h,unpinTab:g}=se(),[b,m]=n.useState(null),C=n.useRef(null),[D,E]=n.useState(null),S=n.useRef(-1),f=n.useRef(null),[y,P]=n.useState(!1),[R,x]=n.useState(!1),T=n.useMemo(()=>as(i),[i]),$=n.useCallback(()=>{const p=f.current;p&&(P(p.scrollLeft>0),x(p.scrollLeft+p.clientWidth<p.scrollWidth-1))},[]);n.useEffect(()=>{const p=f.current;if(!p)return;$(),p.addEventListener("scroll",$,{passive:!0});const L=new ResizeObserver($);return L.observe(p),()=>{p.removeEventListener("scroll",$),L.disconnect()}},[$,i.length]),n.useEffect(()=>{if(!l||!f.current)return;const L=f.current.querySelector(".editor-tab.active");L&&L.scrollIntoView({block:"nearest",inline:"nearest",behavior:Ve()})},[l]);const j=n.useCallback(()=>{var p;(p=f.current)==null||p.scrollBy({left:-150,behavior:Ve()})},[]),N=n.useCallback(()=>{var p;(p=f.current)==null||p.scrollBy({left:150,behavior:Ve()})},[]),A=n.useCallback(p=>{const L=i[p];L&&(c(L.id),requestAnimationFrame(()=>{var M,Z;const V=(M=f.current)==null?void 0:M.querySelectorAll('[role="tab"]');(Z=V==null?void 0:V[p])==null||Z.focus()}))},[c,i]),I=n.useCallback((p,L)=>{let V=null;p.key==="ArrowLeft"&&(V=(L-1+i.length)%i.length),p.key==="ArrowRight"&&(V=(L+1)%i.length),p.key==="Home"&&(V=0),p.key==="End"&&(V=i.length-1),V!==null&&(p.preventDefault(),A(V))},[A,i.length]),O=n.useCallback((p,L)=>{p.preventDefault(),m({x:p.clientX,y:p.clientY,tabId:L})},[]),o=n.useCallback(()=>{m(null)},[]),w=n.useCallback((p,L)=>{p.button===1&&(p.preventDefault(),s({kind:"single",id:L}).catch(()=>{}))},[s]),G=n.useCallback((p,L)=>{S.current=L,p.dataTransfer.effectAllowed="move",p.currentTarget instanceof HTMLElement&&p.dataTransfer.setDragImage(p.currentTarget,0,0)},[]),Y=n.useCallback((p,L)=>{p.preventDefault(),p.dataTransfer.dropEffect="move",E(L)},[]),z=n.useCallback((p,L)=>{p.preventDefault();const V=S.current;V>=0&&V!==L&&d(V,L),S.current=-1,E(null)},[d]),H=n.useCallback(()=>{S.current=-1,E(null)},[]),_=n.useCallback(p=>{const L=i.find(V=>V.id===p);L&&Ne(L.path),o()},[i,o]),F=n.useCallback(p=>{const L=i.find(V=>V.id===p);if(L&&r){const V=L.path.startsWith(r+"/")?L.path.slice(r.length+1):L.path;Ne(V)}else L&&Ne(L.path);o()},[i,r,o]),B=n.useCallback(p=>{const L=i.find(V=>V.id===p);if(L){const{selectPath:V,toggleExpand:M,expandedPaths:Z}=se.getState(),le=L.path.split("/");for(let ue=1;ue<le.length;ue++){const J=le.slice(0,ue).join("/");J&&!Z.has(J)&&M(J)}V(L.path)}o()},[i,o]),X=n.useCallback(p=>{s(p).catch(()=>{}),o()},[o,s]);if(i.length===0)return null;const q=b?i.find(p=>p.id===b.tabId):null;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"editor-tabs-wrapper",children:[y&&e.jsx("button",{className:"editor-tabs-scroll-btn","aria-label":a("editor.scrollTabsLeft"),onClick:j,children:e.jsx(Bs,{size:14})}),e.jsx("div",{className:"editor-tabs",ref:f,role:"tablist","aria-label":a("editor.openEditors"),children:i.map((p,L)=>{let V=null,M="";p.saveStatus==="saving"?(V="saving",M=a("editor.saving")):p.saveStatus==="error"?(V="error",M=`${a("editor.saveFailed")}${p.saveError?`: ${p.saveError}`:""}`):p.isDirty&&(V="dirty",M=a("editor.unsaved"));const Z=T.get(p.id),le=M?`${p.path} — ${M}`:p.path,ue=M?`${p.name}, ${M}`:p.name;return e.jsxs("div",{className:`editor-tab${p.id===l?" active":""}${D===L?" drag-indicator":""}`,onMouseDown:J=>w(J,p.id),onContextMenu:J=>O(J,p.id),title:le,draggable:!0,onDragStart:J=>G(J,L),onDragOver:J=>Y(J,L),onDrop:J=>z(J,L),onDragEnd:H,children:[e.jsxs("button",{type:"button",className:"editor-tab-main",role:"tab",tabIndex:p.id===l?0:-1,"aria-selected":p.id===l,"aria-label":ue,onClick:()=>c(p.id),onKeyDown:J=>I(J,L),children:[e.jsx(xe,{name:p.name,type:"file",size:14}),e.jsx("span",{className:"editor-tab-name",children:p.name}),Z&&e.jsx("span",{className:"editor-tab-description",children:Z}),p.isPinned&&e.jsx("span",{className:"pin-icon",title:a("editor.pin"),children:e.jsx(ns,{size:14})}),e.jsxs("span",{className:"editor-tab-state",children:[V==="saving"&&e.jsx("span",{className:"tab-save-indicator",title:M,children:e.jsx("span",{className:"tab-save-spinner","aria-hidden":"true"})}),V==="error"&&e.jsx("span",{className:"tab-save-indicator tab-save-error",title:M,"aria-hidden":"true",children:"!"}),V==="dirty"&&e.jsx("span",{className:"tab-save-indicator",title:M,children:e.jsx("span",{className:"dirty-dot","aria-hidden":"true"})})]})]}),e.jsx("button",{type:"button",className:`close-btn${V?"":" clean-close"}`,tabIndex:p.id===l?0:-1,"aria-label":a("editor.closeTabAriaLabel",{name:p.name}),onClick:()=>{s({kind:"single",id:p.id}).catch(()=>{})},children:e.jsx(jt,{size:12})})]},p.id)})}),R&&e.jsx("button",{className:"editor-tabs-scroll-btn","aria-label":a("editor.scrollTabsRight"),onClick:N,children:e.jsx(ce,{size:14})}),t&&e.jsx("div",{className:"editor-tabs-actions",children:t})]}),b&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-context-overlay",onClick:o}),e.jsxs("div",{ref:C,className:"editor-context-menu",style:{left:b.x,top:b.y},children:[q!=null&&q.isPinned?e.jsx("button",{onClick:()=>{g(b.tabId),o()},children:a("editor.unpin")}):e.jsx("button",{onClick:()=>{h(b.tabId),o()},children:a("editor.pin")}),e.jsx("div",{className:"editor-context-separator"}),e.jsx("button",{onClick:()=>_(b.tabId),children:a("editor.copyPath")}),e.jsx("button",{onClick:()=>F(b.tabId),children:a("editor.copyRelativePath")}),e.jsx("button",{onClick:()=>B(b.tabId),children:a("editor.revealInExplorer")}),e.jsx("div",{className:"editor-context-separator"}),e.jsx("button",{onClick:()=>X({kind:"single",id:b.tabId}),children:a("editor.close")}),e.jsx("button",{onClick:()=>X({kind:"others",id:b.tabId}),children:a("editor.closeOthers")}),e.jsx("button",{onClick:()=>X({kind:"right",id:b.tabId}),children:a("editor.closeToRight")}),e.jsx("button",{onClick:()=>{u(),o()},children:a("editor.closeSaved")}),e.jsx("button",{onClick:()=>X({kind:"all"}),children:a("editor.closeAll")})]})]})]})}const za=cs,st=ls;function ut({path:t,onImageInfo:s,onZoomChange:a}){const{t:i}=te(),l=n.useRef(null),r=n.useRef(null),[c,u]=n.useState("fit"),d=yt(st(t)),[h,g]=n.useState(null),[b,m]=n.useState(!1),[C,D]=n.useState({x:0,y:0}),E=n.useRef({x:0,y:0,tx:0,ty:0}),S=n.useCallback(()=>{if(!l.current||!h)return 1;const O=l.current.clientWidth-40,o=l.current.clientHeight-80;return O<=0||o<=0?1:Math.min(O/h.w,o/h.h,1)},[h]),f=c==="fit"?S():c,y=n.useCallback(()=>{const O=r.current;if(!O)return;const o=O.naturalWidth,w=O.naturalHeight;g({w:o,h:w}),s==null||s({width:o,height:w})},[s]);n.useEffect(()=>{a==null||a(f)},[f,a]);const P=n.useCallback(O=>{!O.ctrlKey&&!O.metaKey||(O.preventDefault(),u(o=>{const w=o==="fit"?S():o,G=O.deltaY<0?.1:-.1;return Math.min(5,Math.max(.1,w+G))}))},[S]),R=n.useCallback(O=>{c!=="fit"&&(O.preventDefault(),m(!0),E.current={x:O.clientX,y:O.clientY,tx:C.x,ty:C.y})},[c,C]),x=n.useCallback(O=>{if(!b)return;const o=O.clientX-E.current.x,w=O.clientY-E.current.y;D({x:E.current.tx+o,y:E.current.ty+w})},[b]),T=n.useCallback(()=>{m(!1)},[]),$=()=>u(O=>Math.min(5,(O==="fit"?S():O)+.1)),j=()=>u(O=>Math.max(.1,(O==="fit"?S():O)-.1)),N=()=>{u("fit"),D({x:0,y:0})},A=()=>{u(1),D({x:0,y:0})},I=f>=3;return e.jsxs("div",{ref:l,className:"file-preview-image-container checkerboard",onWheel:P,onMouseDown:R,onMouseMove:x,onMouseUp:T,onMouseLeave:T,style:{cursor:c!=="fit"?b?"grabbing":"grab":"default"},children:[d&&e.jsx("img",{ref:r,src:d,alt:t,onLoad:y,className:I?"pixelated":"",style:{transform:`translate(${C.x}px, ${C.y}px) scale(${f})`,transformOrigin:"center center",maxWidth:"none",maxHeight:"none",userSelect:"none",pointerEvents:"none"},draggable:!1}),e.jsxs("div",{className:"image-zoom-toolbar",children:[e.jsx("button",{onClick:j,title:i("filePreview.zoomOut"),children:e.jsx(Fe,{size:16})}),e.jsxs("span",{className:"image-zoom-label",children:[Math.round(f*100),"%"]}),e.jsx("button",{onClick:$,title:i("filePreview.zoomIn"),children:e.jsx(je,{size:16})}),e.jsx("button",{onClick:N,title:i("filePreview.fitToWindow"),children:e.jsx(kt,{size:16})}),e.jsx("button",{onClick:A,title:i("filePreview.actualSize"),children:e.jsx(da,{size:16})})]})]})}function Ea({className:t,children:s}){const a=gt(r=>r.resolved),i=(t||"").match(/language-(\w+)/),l=String(s).replace(/\n$/,"");return i?e.jsx("div",{className:"relative group my-3",children:e.jsx(za,{style:a==="dark"?os:ds,language:i[1],PreTag:"div",customStyle:{margin:0,borderRadius:"8px",fontSize:"13px",lineHeight:"1.6"},codeTagProps:{style:{background:"transparent",textShadow:"none"}},children:l})}):e.jsx("code",{className:"bg-[var(--color-bg-tertiary)] px-1.5 py-0.5 rounded text-[13px]",children:s})}function Ra({content:t}){return e.jsx("div",{className:"file-preview-markdown",children:e.jsx("div",{className:"file-preview-markdown-content",children:e.jsx($s,{remarkPlugins:[Fs],components:{code:Ea},children:t})})})}function Ta({path:t}){const{t:s}=te(),a=yt(st(t));return a?e.jsx("iframe",{src:a,className:"file-preview-pdf",title:s("filePreview.pdfPreview")}):null}function La({path:t,name:s}){const{t:a}=te(),i=n.useCallback(()=>{fetch(st(t),{headers:$e()}).then(l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);return l.blob()}).then(l=>{const r=URL.createObjectURL(l),c=document.createElement("a");c.href=r,c.download=s,c.click(),URL.revokeObjectURL(r)}).catch(l=>{console.warn("[FilePreview] download failed:",String(l))})},[t,s]);return e.jsxs("div",{className:"file-preview-binary",children:[e.jsx(is,{size:48,className:"text-[var(--color-text-tertiary)]"}),e.jsx("div",{className:"mt-4 text-lg font-medium text-[var(--color-text-primary)]",children:s}),e.jsx("div",{className:"mt-2 text-sm text-[var(--color-text-secondary)]",children:a("filePreview.binaryNotSupported")}),e.jsxs("button",{onClick:i,className:"mt-4 inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-[var(--color-bg-tertiary)] text-[var(--color-text-primary)] hover:bg-[var(--color-bg-quaternary)] transition-colors text-sm",children:[e.jsx(rs,{size:16}),a("filePreview.download")]})]})}function It({path:t,name:s,content:a,viewMode:i,onImageInfo:l,onZoomChange:r}){switch(i){case"image":return e.jsx(ut,{path:t,onImageInfo:l,onZoomChange:r});case"svg":return e.jsx(ut,{path:t,onImageInfo:l,onZoomChange:r});case"markdown":return e.jsx(Ra,{content:a});case"pdf":return e.jsx(Ta,{path:t});case"binary":return e.jsx(La,{path:t,name:s});default:return null}}function $a(t,s=300){const[a,i]=n.useState(!1);return n.useEffect(()=>{if(!t){i(!1);return}const l=setTimeout(()=>i(!0),s);return()=>clearTimeout(l)},[t,s]),a}function Fa(t){switch(t){case"modified":return"M";case"added":return"A";case"untracked":return"U";case"deleted":return"D";case"conflicted":return"C";case"renamed":return"R";case"copied":return"C";default:return""}}function Ot(t){return`file-tree-item-${encodeURIComponent(t)}`}function Bt({node:t,depth:s,isExpanded:a,isSelected:i,isMultiSelected:l,isRenaming:r,expandedPaths:c,selectedPath:u,selectedPaths:d,renamingPath:h,gitStatusMap:g,onToggleExpand:b,onSelect:m,onOpenFile:C,onConfirmRename:D,onCancelRename:E,onContextMenu:S,onDragStart:f,onDrop:y}){const P=t.type==="directory",R=12+s*12,x=g.get(t.path),T=se(M=>M.showHiddenFiles),$=$a(!!t.isLoading),j=n.useMemo(()=>Ge(t.children,T),[t.children,T]),[N,A]=n.useState(t.name),I=n.useRef(null),[O,o]=n.useState(!1);n.useEffect(()=>{if(r&&I.current){A(t.name),I.current.focus();const M=t.name.lastIndexOf(".");!P&&M>0?I.current.setSelectionRange(0,M):I.current.select()}},[r,t.name,P]);const w=n.useCallback(M=>{r||(m(t.path,{ctrl:M.ctrlKey||M.metaKey,shift:M.shiftKey}),P?b(t.path):!M.ctrlKey&&!M.metaKey&&!M.shiftKey&&C(t.path,t.name))},[r,t.path,P,t.name,m,b,C]),G=n.useCallback(()=>{r||P||C(t.path,t.name)},[r,P,t.path,t.name,C]),Y=n.useCallback(M=>{M.stopPropagation(),M.key==="Enter"?(M.preventDefault(),D(t.path,N)):M.key==="Escape"&&(M.preventDefault(),E())},[t.path,N,D,E]),z=n.useCallback(()=>{D(t.path,N)},[t.path,N,D]),H=n.useCallback(M=>{M.preventDefault(),S(M,t.path)},[S,t.path]),_=n.useCallback(M=>{const Z=l?[...d]:[t.path];M.dataTransfer.effectAllowed="copyMove",M.dataTransfer.setData("text/plain",JSON.stringify(Z)),M.dataTransfer.setData("application/x-file-paths",JSON.stringify(Z)),f(Z)},[l,d,t.path,f]),F=n.useCallback(M=>{P&&(M.preventDefault(),M.dataTransfer.dropEffect="move",o(!0))},[P]),B=n.useCallback(()=>{o(!1)},[]),X=n.useCallback(M=>{M.preventDefault(),o(!1),P&&y(t.path)},[P,t.path,y]),q=i||l,p=x?`Git: ${x}`:void 0,L=12,V=12;return e.jsxs("div",{id:Ot(t.path),role:"treeitem","aria-level":s+1,"aria-expanded":P?a:void 0,"aria-selected":q,"aria-label":p?`${t.name}, ${p}`:t.name,"data-path":t.path,title:p?`${t.path} (${p})`:t.path,children:[e.jsxs("div",{className:`file-tree-item ${q?"selected":""} ${O?"drag-over":""}`,onClick:w,onDoubleClick:G,onContextMenu:H,draggable:!r,onDragStart:_,onDragOver:F,onDragLeave:B,onDrop:X,children:[Array.from({length:s},(M,Z)=>e.jsx("span",{className:"file-tree-indent-guide",style:{left:V+Z*L+6}},Z)),e.jsx("span",{style:{width:R,flexShrink:0}}),P?$?e.jsx(ve,{size:16,className:"file-tree-chevron animate-spin"}):e.jsx(ce,{size:16,className:`file-tree-chevron ${a?"expanded":""}`}):e.jsx(xe,{name:t.name,type:t.type,isExpanded:a,size:16}),r?e.jsx("input",{ref:I,className:"file-tree-rename-input",value:N,onChange:M=>A(M.target.value),onKeyDown:Y,onBlur:z,onClick:M=>M.stopPropagation()}):e.jsx("span",{className:`file-tree-item-name${x?` git-status-${x}`:""}`,children:t.name}),x&&!P&&e.jsx("span",{className:`file-tree-git-badge git-status-${x}`,"aria-label":p,title:p,children:Fa(x)})]}),P&&a&&e.jsx("div",{role:"group",children:j.map(M=>e.jsx(Bt,{node:M,depth:s+1,isExpanded:c.has(M.path),isSelected:u===M.path,isMultiSelected:d.has(M.path),isRenaming:h===M.path,expandedPaths:c,selectedPath:u,selectedPaths:d,renamingPath:h,gitStatusMap:g,onToggleExpand:b,onSelect:m,onOpenFile:C,onConfirmRename:D,onCancelRename:E,onContextMenu:S,onDragStart:f,onDrop:y},M.path))})]})}function _t(t){var K;const{t:s}=te(),a=us(v=>v.info),{rootPath:i,tree:l,treeLoading:r,treeError:c,expandedPaths:u,selectedPath:d,selectedPaths:h,tabs:g,renamingPath:b,setRootPath:m,toggleExpand:C,selectPath:D,openFile:E,refreshTree:S,collapseAll:f,createNewFile:y,createNewFolder:P,startRename:R,startCreateFile:x,startCreateFolder:T,confirmRename:$,cancelRename:j,deleteSelected:N,moveToDirectory:A,showHiddenFiles:I,toggleShowHiddenFiles:O}=se(),o=me(v=>v.files),w=n.useMemo(()=>{const v=new Map;if(!o.length||!i)return v;const k={conflicted:6,deleted:5,modified:4,renamed:3,added:2,copied:1,untracked:0};for(const Q of o){const U=Q.path.startsWith("/")?Q.path:`${i}/${Q.path}`;v.set(U,Q.status);let ee=U.substring(0,U.lastIndexOf("/"));for(;ee&&ee.length>=i.length;){const re=v.get(ee);(!re||(k[Q.status]??0)>(k[re]??0))&&v.set(ee,Q.status),ee=ee.substring(0,ee.lastIndexOf("/"))}}return v},[o,i]),G=n.useMemo(()=>Ge(l==null?void 0:l.children,I),[l==null?void 0:l.children,I]),[Y,z]=n.useState(!1),[H,_]=n.useState(!1),[F,B]=n.useState(!1),X=n.useRef(null),[q,p]=n.useState(null),L=n.useRef([]);n.useEffect(()=>{const v=wt().has("path");a!=null&&a.cwd&&!i&&!v?m(a.cwd):i&&!l&&!r&&!c&&m(i)},[a==null?void 0:a.cwd,i,l,r,c,m]);const V=n.useCallback(v=>{_(!1),m(v)},[m]),M=n.useCallback((v,k)=>{E(v,k)},[E]),Z=n.useCallback((v,k)=>{$(v,k)},[$]),le=n.useCallback((v,k)=>{v.preventDefault(),h.has(k)||D(k),p({x:v.clientX,y:v.clientY,path:k})},[h,D]),ue=n.useCallback(()=>p(null),[]),J=n.useCallback(()=>{q&&(R(q.path),p(null))},[q,R]),ae=n.useCallback((v,k)=>{if(!v)return null;if(v.path===k)return v;if(v.children)for(const Q of v.children){const U=ae(Q,k);if(U)return U}return null},[]),ye=q?((K=ae(l,q.path))==null?void 0:K.type)==="directory":!1,ke=n.useCallback(()=>{if(h.size===0)return;const v=[...h],k=v.some(U=>{var ee;return((ee=ae(l,U))==null?void 0:ee.type)==="directory"}),Q=g.some(U=>U.isDirty&&v.some(ee=>U.path===ee||U.path.startsWith(`${ee}/`)));if(v.length>1||k||Q){B(!0);return}N().catch(()=>{})},[N,ae,h,g,l]),Ae=n.useCallback(()=>{p(null),ke()},[ke]),Pe=n.useCallback(()=>{B(!1),N().catch(()=>{})},[N]),De=n.useCallback(v=>{if(!q)return;const k=ae(l,q.path),Q=(k==null?void 0:k.type)==="directory"?q.path:q.path.substring(0,q.path.lastIndexOf("/"));if(Q){u.has(Q)||C(Q);const U=`${Q}/__new_${v}__`;v==="file"?x(U):T(U)}p(null)},[q,u,ae,x,T,C,l]),Ie=n.useCallback(()=>{q&&(Ne(q.path),p(null))},[q]),ze=n.useCallback(()=>{if(q&&i){const v=q.path.startsWith(i+"/")?q.path.slice(i.length+1):q.path;Ne(v),p(null)}},[q,i]),ge=n.useCallback(v=>{L.current=v},[]),Ee=n.useCallback(v=>{const k=L.current;L.current=[],k.length!==0&&A(k,v).catch(Q=>{const U=Q instanceof Error?Q.message:String(Q);Ct.error(`${s("editor.moveFailed")}: ${U}`)})},[A,s]),Re=n.useCallback(v=>{if(b||!l)return;const k=hs(l,u,I);if(k.length===0)return;const Q=d?k.indexOf(d):-1,U=d?ae(l,d):null;function ee(re,Oe=!1){var we,oe;D(re,{shift:Oe}),(oe=(we=X.current)==null?void 0:we.querySelector(`[data-path="${CSS.escape(re)}"]`))==null||oe.scrollIntoView({block:"nearest"})}switch(v.key){case"ArrowDown":{v.preventDefault();const re=Q<k.length-1?Q+1:0;ee(k[re],v.shiftKey);break}case"ArrowUp":{v.preventDefault();const re=Q>0?Q-1:k.length-1;ee(k[re],v.shiftKey);break}case"ArrowRight":{if(v.preventDefault(),(U==null?void 0:U.type)!=="directory")break;if(!u.has(U.path))C(U.path);else{const re=Ge(U.children,I)[0];re&&ee(re.path)}break}case"ArrowLeft":{if(v.preventDefault(),(U==null?void 0:U.type)==="directory"&&u.has(U.path)){C(U.path);break}if(d){const re=d.substring(0,d.lastIndexOf("/"));k.includes(re)&&ee(re)}break}case"Enter":case" ":{v.preventDefault(),(U==null?void 0:U.type)==="directory"?C(U.path):U&&E(U.path,U.name);break}case"F2":{v.preventDefault(),d&&R(d);break}case"Delete":case"Backspace":{v.preventDefault(),h.size>0&&ke();break}}},[l,u,d,h,b,I,ae,D,C,R,E,ke]);n.useEffect(()=>{if(!d)return;const v=setTimeout(()=>{var U;const k=(U=X.current)==null?void 0:U.querySelector(`[data-path="${CSS.escape(d)}"]`),Q=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth";k==null||k.scrollIntoView({block:"nearest",behavior:Q})},60);return()=>clearTimeout(v)},[d]);const W=(l==null?void 0:l.name)||(i==null?void 0:i.split("/").pop())||"WORKSPACE";return e.jsxs("div",{className:"file-tree",children:[e.jsx("div",{className:"file-tree-title-bar",children:e.jsx("span",{className:"file-tree-title-text",children:s("editor.explorer")})}),e.jsxs("div",{className:"file-tree-section-header",children:[e.jsxs("button",{type:"button",className:"file-tree-section-toggle","aria-expanded":!Y,onClick:()=>z(v=>!v),children:[Y?e.jsx(ce,{size:12,style:{flexShrink:0}}):e.jsx(he,{size:12,style:{flexShrink:0}}),e.jsx("span",{className:"file-tree-section-name",children:W.toUpperCase()})]}),e.jsxs("div",{className:"file-tree-section-actions",children:[e.jsx("button",{className:"file-tree-section-action",onClick:y,title:s("editor.newFile"),"aria-label":s("editor.newFile"),children:e.jsx(Xs,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:P,title:s("editor.newFolder"),"aria-label":s("editor.newFolder"),children:e.jsx(ta,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:()=>_(!0),title:s("editor.openFolder"),"aria-label":s("editor.openFolder"),children:e.jsx(ms,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:()=>{S().catch(()=>{})},title:s("editor.refresh"),"aria-label":s("editor.refresh"),children:e.jsx(Me,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:f,title:s("editor.collapseAll"),"aria-label":s("editor.collapseAll"),children:e.jsx(Ws,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:O,title:s(I?"editor.hideHiddenFiles":"editor.showHiddenFiles"),"aria-label":s(I?"editor.hideHiddenFiles":"editor.showHiddenFiles"),children:I?e.jsx(Ks,{size:14}):e.jsx(qs,{size:14})})]})]}),H&&e.jsx(fs,{initialPath:i||(a==null?void 0:a.cwd)||"/",onSelect:V,onClose:()=>_(!1)}),F&&e.jsx(Nt,{title:s("editor.deleteConfirmTitle"),message:s("editor.deleteConfirmMessage",{count:h.size}),confirmLabel:s("editor.delete"),danger:!0,onConfirm:Pe,onCancel:()=>B(!1)}),!Y&&e.jsxs("div",{className:"file-tree-content",ref:X,role:"tree","aria-label":s("editor.fileTreeAriaLabel"),"aria-multiselectable":"true","aria-activedescendant":d?Ot(d):void 0,tabIndex:0,onKeyDown:Re,onClick:()=>{var v;return(v=X.current)==null?void 0:v.focus()},children:[r&&!l&&e.jsx("div",{className:"file-tree-loading",children:e.jsx(ve,{size:16,className:"animate-spin"})}),!r&&!l&&c&&i&&e.jsxs("div",{className:"file-tree-empty",children:[e.jsx("span",{children:s("editor.loadError")}),e.jsxs("button",{className:"file-tree-retry-btn",onClick:()=>m(i),children:[e.jsx(Me,{size:12}),s("editor.refresh")]}),(a==null?void 0:a.cwd)&&i!==a.cwd&&e.jsxs("button",{className:"file-tree-retry-btn",onClick:()=>m(a.cwd),children:[e.jsx(aa,{size:12}),s("editor.backToWorkDir")]})]}),G.map(v=>e.jsx(Bt,{node:v,depth:0,isExpanded:u.has(v.path),isSelected:d===v.path,isMultiSelected:h.has(v.path),isRenaming:b===v.path,expandedPaths:u,selectedPath:d,selectedPaths:h,renamingPath:b,gitStatusMap:w,onToggleExpand:C,onSelect:D,onOpenFile:M,onConfirmRename:Z,onCancelRename:j,onContextMenu:le,onDragStart:ge,onDrop:Ee},v.path)),G.length===0&&(l==null?void 0:l.children)&&e.jsx("div",{className:"file-tree-empty",children:s("editor.emptyFolder")})]}),q&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-context-overlay",onClick:ue}),e.jsxs("div",{className:"editor-context-menu",style:{left:q.x,top:q.y},children:[ye&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>De("file"),children:s("editor.newFile")}),e.jsx("button",{onClick:()=>De("folder"),children:s("editor.newFolder")}),e.jsx("div",{className:"editor-context-separator"})]}),e.jsx("button",{onClick:Ie,children:s("editor.copyPath")}),e.jsx("button",{onClick:ze,children:s("editor.copyRelativePath")}),e.jsx("div",{className:"editor-context-separator"}),h.size<=1&&e.jsx("button",{onClick:J,children:s("editor.rename")}),e.jsx("button",{className:"danger",onClick:Ae,children:h.size>1?`${s("editor.delete")} (${h.size})`:s("editor.delete")})]})]})]})}function Aa(t,s){fetch(`/api/v1/pty/${t}/input/send`,{method:"POST",headers:{...$e(),"Content-Type":"application/json"},body:JSON.stringify({data:s})}).catch(()=>{})}function Ia(t){return/^[a-zA-Z0-9_./-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function Wt(){const{t}=te(),{bottomTerminals:s,activeBottomTerminalId:a,bottomPanelMaximized:i,createBottomTerminal:l,closeBottomTerminal:r,closeOtherBottomTerminals:c,closeBottomTerminalsToRight:u,closeAllBottomTerminals:d,setActiveBottomTerminal:h,setBottomPanelCollapsed:g,toggleBottomPanelMaximize:b}=ne(),m=ps(o=>o.cwd),[C,D]=n.useState(null),E=n.useCallback((o,w)=>{o.preventDefault(),D({x:o.clientX,y:o.clientY,tabId:w})},[]),S=n.useCallback(()=>{D(null)},[]),f=xs(o=>o.panes),y=n.useRef(null);n.useEffect(()=>{const o=setTimeout(()=>{window.dispatchEvent(new Event("resize"))},60);return()=>clearTimeout(o)},[]),n.useEffect(()=>{if(!a||!y.current)return;const w=y.current.querySelector(".ide-bottom-tab.active");w&&w.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})},[a]);const P=n.useCallback(()=>{l()},[l]),R=n.useCallback((o,w)=>{o.stopPropagation(),r(w)},[r]),x=n.useCallback(()=>{g(!0)},[g]),[T,$]=n.useState(!1),j=n.useRef(0),N=n.useCallback(o=>{o.preventDefault(),o.stopPropagation(),j.current++,(o.dataTransfer.types.includes("text/plain")||o.dataTransfer.types.includes("application/x-file-paths"))&&$(!0)},[]),A=n.useCallback(o=>{o.preventDefault(),o.stopPropagation(),o.dataTransfer.dropEffect="copy"},[]),I=n.useCallback(o=>{o.preventDefault(),o.stopPropagation(),j.current--,j.current<=0&&(j.current=0,$(!1))},[]),O=n.useCallback(o=>{o.preventDefault(),o.stopPropagation(),$(!1),j.current=0;let w=[];const G=o.dataTransfer.getData("application/x-file-paths")||o.dataTransfer.getData("text/plain");if(G)try{const _=JSON.parse(G);Array.isArray(_)&&(w=_)}catch{w=[G]}if(w.length===0&&o.dataTransfer.files.length>0)for(let _=0;_<o.dataTransfer.files.length;_++){const F=o.dataTransfer.files[_],B=F.path||F.webkitRelativePath||F.name;B&&w.push(B)}if(w.length===0)return;const Y=a;if(!Y)return;const z=f[Y];if(!(z!=null&&z.ptySessionId))return;const H=w.map(Ia).join(" ");Aa(z.ptySessionId,H),setTimeout(()=>{const _=document.querySelector('.ide-bottom-terminal-wrap[style*="flex"] .xterm-helper-textarea');_==null||_.focus()},50)},[a,f]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`ide-bottom-panel ${T?"drop-highlight":""}`,onDragEnter:N,onDragOver:A,onDragLeave:I,onDrop:O,children:[e.jsxs("div",{className:"ide-bottom-tabs",children:[e.jsx("div",{className:"ide-bottom-tabs-list",ref:y,onDoubleClick:o=>{o.target===o.currentTarget&&P()},children:s.map((o,w)=>{const G=f[o],Y=(G==null?void 0:G.title)||`Terminal ${w+1}`,z=o===a;return e.jsxs("button",{className:`ide-bottom-tab ${z?"active":""}`,onClick:()=>h(o),onDoubleClick:()=>b(),onContextMenu:H=>E(H,o),children:[e.jsx("span",{className:"ide-bottom-tab-title",title:Y,children:Y}),e.jsx("span",{className:"ide-bottom-tab-close",onClick:H=>R(H,o),children:e.jsx(jt,{size:14})})]},o)})}),e.jsxs("div",{className:"ide-bottom-tabs-actions",children:[e.jsx("button",{className:"ide-bottom-action-btn",onClick:P,title:t("ide.newTerminal"),children:e.jsx(je,{size:16})}),e.jsx("button",{className:"ide-bottom-action-btn",onClick:b,title:i?t("ide.restorePanel")||"Restore Panel Size":t("ide.maximizePanel")||"Maximize Panel",children:i?e.jsx(gs,{size:16}):e.jsx(kt,{size:16})}),e.jsx("button",{className:"ide-bottom-action-btn",onClick:x,title:t("ide.hidePanel"),children:e.jsx(he,{size:16})})]})]}),e.jsxs("div",{className:"ide-bottom-content",children:[s.map(o=>e.jsx("div",{className:"ide-bottom-terminal-wrap",style:{display:o===a?"flex":"none"},children:e.jsx(bs,{paneId:o,initialCwd:m})},o)),s.length===0&&e.jsx("div",{className:"ide-bottom-empty",children:e.jsxs("button",{className:"ide-bottom-empty-btn",onClick:P,children:[e.jsx(je,{size:16}),e.jsx("span",{children:t("ide.newTerminal")||"New Terminal"})]})})]})]}),C&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-context-overlay",onClick:S}),e.jsxs("div",{className:"editor-context-menu",style:{left:C.x,top:C.y},children:[e.jsx("button",{onClick:()=>{r(C.tabId),S()},children:t("terminal.close")}),e.jsx("button",{onClick:()=>{c(C.tabId),S()},children:t("terminal.closeOthers")}),e.jsx("button",{onClick:()=>{u(C.tabId),S()},children:t("terminal.closeToRight")}),e.jsx("div",{className:"editor-context-separator"}),e.jsx("button",{onClick:()=>{d(),S()},children:t("terminal.closeAll")})]})]})]})}function ht(t){const{direction:s,initialSize:a,minSize:i=120,maxSize:l,collapsible:r=!0,collapseThreshold:c,defaultCollapsed:u=!1,onResize:d,onCollapse:h,onMaximize:g,maximizeThreshold:b=.92,reverse:m=!1,ariaLabel:C,keyboardStep:D=10}=t,[E,S]=n.useState(a),[f,y]=n.useState(u),[P,R]=n.useState(!1),x=n.useRef(null),T=n.useRef(a);n.useEffect(()=>{f||S(a)},[a,f]),n.useEffect(()=>{y(u)},[u]);const $=c??i*.6,j=n.useCallback(()=>{if(l)return l;const z=x.current;if(!(z!=null&&z.parentElement))return 1/0;const H=z.parentElement.getBoundingClientRect();return(s==="horizontal"?H.width:H.height)*.8},[s,l]),N=n.useCallback(z=>{const H=Math.max(i,Math.min(j(),z));S(H),T.current=H,d==null||d(H)},[i,j,d]),A=n.useCallback(()=>{y(z=>{const H=!z;if(H)T.current=E;else{const _=Math.max(i,T.current);S(_),d==null||d(_)}return h==null||h(H),H})},[E,i,d,h]),I=n.useCallback((z,H)=>{R(!0);const _=x.current;if(!_)return;const F=f?0:E,B=j(),q=(s==="horizontal"?_.clientWidth:_.clientHeight)*b;let p=!1;const L=()=>{R(!1),document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",Z),document.removeEventListener("pointercancel",Z),document.body.style.cursor="",document.body.style.userSelect="",document.body.classList.remove("ide-sash-dragging")},V=(le,ue)=>{if(p)return;let J;s==="horizontal"?J=le-z:J=ue-H,m&&(J=-J);const ae=F+J;if(r&&ae<$){f||(T.current=E>i?E:a,y(!0),h==null||h(!0));return}if(g&&ae>=q){p=!0,g(),L();return}f&&ae>=i&&(y(!1),h==null||h(!1));const ye=Math.max(i,Math.min(B,ae));S(ye),d==null||d(ye)},M=le=>V(le.clientX,le.clientY),Z=()=>L();document.addEventListener("pointermove",M),document.addEventListener("pointerup",Z),document.addEventListener("pointercancel",Z),document.body.style.cursor=s==="horizontal"?"col-resize":"row-resize",document.body.style.userSelect="none",document.body.classList.add("ide-sash-dragging")},[f,E,s,m,r,$,i,a,j,d,h,g,b]),O=n.useCallback(z=>{z.preventDefault(),z.stopPropagation(),I(z.clientX,z.clientY)},[I]),o=n.useCallback(z=>{if((z.key==="Enter"||z.key===" ")&&r){z.preventDefault(),A();return}if(z.key==="Home"){z.preventDefault(),f&&(y(!1),h==null||h(!1)),N(i);return}if(z.key==="End"){z.preventDefault(),f&&(y(!1),h==null||h(!1));const _=j();Number.isFinite(_)&&N(_);return}let H=0;s==="horizontal"?(z.key==="ArrowLeft"&&(H=-D),z.key==="ArrowRight"&&(H=D)):(z.key==="ArrowUp"&&(H=-D),z.key==="ArrowDown"&&(H=D)),H!==0&&(z.preventDefault(),m&&(H=-H),f&&(y(!1),h==null||h(!1)),N((f?i:E)+H))},[f,r,s,j,D,i,h,m,N,E,A]),w=["ide-sash",s==="horizontal"?"ide-sash-vertical":"ide-sash-horizontal",P?"dragging":""].filter(Boolean).join(" "),G=j(),Y=Number.isFinite(G)?G:Math.max(i,E);return{size:f?0:E,collapsed:f,sashProps:{onPointerDown:O,onDoubleClick:A,onKeyDown:o,className:w,role:"separator",tabIndex:0,"aria-label":C,"aria-orientation":s==="horizontal"?"vertical":"horizontal","aria-valuemin":r?0:i,"aria-valuemax":Math.round(Y),"aria-valuenow":Math.round(f?0:E)},containerRef:x,setSize:N,toggleCollapse:A,dragging:P}}function Oa(t){return[...t].sort((s,a)=>s.type==="directory"&&a.type!=="directory"?-1:s.type!=="directory"&&a.type==="directory"?1:s.name.localeCompare(a.name,void 0,{numeric:!0,sensitivity:"base"}))}function Ba({filePath:t,rootPath:s,onSegmentClick:a,onOpenFile:i}){const r=(t.startsWith(s)?t.slice(s.length).replace(/^\//,""):t).split("/").filter(Boolean),[c,u]=n.useState(null),[d,h]=n.useState([]),[g,b]=n.useState(!1),[m,C]=n.useState(-1),D=n.useRef(null),E=n.useRef(null),S=n.useCallback(async(x,T)=>{const $=T.getBoundingClientRect();u({dirPath:x,anchorRect:$}),b(!0),h([]),C(-1);try{const j=await St(x);h(Oa(j.map(N=>({name:N.name,path:N.path,type:N.type}))))}catch{h([])}b(!1)},[]),f=n.useCallback(()=>{u(null),h([]),C(-1)},[]),y=n.useCallback(x=>{x.type==="directory"?(a(x.path),f()):(i(x.path),f())},[a,i,f]);n.useEffect(()=>{if(!c)return;const x=T=>{if(T.key==="Escape"){T.preventDefault(),f();return}T.key==="ArrowDown"?(T.preventDefault(),C($=>$<d.length-1?$+1:0)):T.key==="ArrowUp"?(T.preventDefault(),C($=>$>0?$-1:d.length-1)):T.key==="Enter"&&m>=0&&m<d.length&&(T.preventDefault(),y(d[m]))};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[c,d,m,f,y]),n.useEffect(()=>{var x;m>=0&&E.current&&((x=E.current.querySelectorAll(".breadcrumb-dropdown-item")[m])==null||x.scrollIntoView({block:"nearest"}))},[m]);const P=n.useCallback((x,T)=>{x.stopPropagation();const $=x.currentTarget;c&&c.dirPath===T?f():S(T,$)},[c,S,f]),R=n.useCallback((x,T)=>{x.stopPropagation();const $=x.currentTarget;c&&c.dirPath===T?f():S(T,$)},[c,S,f]);return e.jsxs("div",{className:"editor-breadcrumbs",children:[e.jsx("span",{style:{display:"inline-flex",alignItems:"center"},children:e.jsx("span",{className:`editor-breadcrumb-segment ${r.length===0?"active":""}`,onClick:x=>P(x,s),children:e.jsx("span",{children:s.split("/").pop()||s})})}),r.map((x,T)=>{const $=T===r.length-1,j=s+"/"+r.slice(0,T+1).join("/"),N=T===0?s:s+"/"+r.slice(0,T).join("/");return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center"},children:[e.jsx("span",{className:"editor-breadcrumb-separator",children:e.jsx(ce,{size:10})}),e.jsxs("span",{className:`editor-breadcrumb-segment ${$?"active":""} ${(c==null?void 0:c.dirPath)===($?N:j)?"dropdown-open":""}`,onClick:A=>$?R(A,N):P(A,j),children:[$&&e.jsx(xe,{name:x,type:"file",size:14}),e.jsx("span",{style:$?{fontWeight:500}:void 0,children:x})]})]},j)}),c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"breadcrumb-dropdown-overlay",onClick:f}),e.jsx("div",{ref:D,className:"breadcrumb-dropdown",style:{left:Math.min(c.anchorRect.left,window.innerWidth-260),top:c.anchorRect.bottom+2},children:g?e.jsx("div",{className:"breadcrumb-dropdown-loading",children:e.jsx(ve,{size:14,className:"animate-spin"})}):d.length===0?e.jsx("div",{className:"breadcrumb-dropdown-empty",children:"Empty"}):e.jsx("div",{className:"breadcrumb-dropdown-list",ref:E,children:d.map((x,T)=>{const $=x.path===t,j=T===m;return e.jsxs("div",{className:`breadcrumb-dropdown-item ${$?"current":""} ${j?"highlighted":""}`,onClick:()=>y(x),children:[x.type==="directory"?e.jsx(ce,{size:12,style:{flexShrink:0,opacity:.5}}):e.jsx(xe,{name:x.name,type:x.type,size:16}),e.jsx("span",{className:"breadcrumb-dropdown-item-name",children:x.name})]},x.path)})})})]})]})}function _a(t,s){const a=t.toLowerCase(),i=s.toLowerCase();let l=0,r=0,c=-1;for(let u=0;u<i.length&&l<a.length;u++)i[u]===a[l]&&(r+=u===c+1?2:1,(u===0||i[u-1]==="/"||i[u-1]===".")&&(r+=3),c=u,l++);return{match:l===a.length,score:r}}const mt=20,Wa=3;function Ht({isOpen:t,onClose:s,onSelect:a,rootPath:i,showHiddenFiles:l}){const{t:r}=te(),[c,u]=n.useState(""),[d,h]=n.useState(0),[g,b]=n.useState([]),[m,C]=n.useState(!1),D=n.useRef(null),E=n.useRef(null),S=n.useRef(null),f=n.useId(),y=n.useRef(""),P=n.useRef([]),R=n.useCallback(async(j,N,A)=>{if(N>Wa)return[];try{const I=await St(j),O=[];for(const o of I){if(!l&&vs(o.name))continue;const w=A?`${A}/${o.name}`:o.name;if(o.type==="file"&&!js(o.path))O.push({name:o.name,path:o.path,relativePath:w});else if(o.type==="directory"){const G=await R(o.path,N+1,w);O.push(...G)}}return O}catch{return[]}},[l]);n.useEffect(()=>{if(!t)return;u(""),h(0),S.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const j=window.setTimeout(()=>{var I;return(I=D.current)==null?void 0:I.focus()},0),N=`${i}\0${l?"hidden":"visible"}`;if(y.current===N&&P.current.length>0)return b(P.current),C(!1),()=>{var I;window.clearTimeout(j),(I=S.current)==null||I.focus(),S.current=null};let A=!1;return C(!0),R(i,0,"").then(I=>{A||(y.current=N,P.current=I,b(I),C(!1))}),()=>{var I;A=!0,window.clearTimeout(j),(I=S.current)==null||I.focus(),S.current=null}},[t,i,l,R]);const x=n.useMemo(()=>{if(!c.trim())return g.slice(0,mt);const j=[];for(const N of g){const A=_a(c,N.relativePath);A.match&&j.push({entry:N,score:A.score})}return j.sort((N,A)=>A.score-N.score),j.slice(0,mt).map(N=>N.entry)},[g,c]);n.useEffect(()=>{h(0)},[x.length,c]);const T=n.useCallback(j=>{var N;switch(j.key){case"Tab":j.preventDefault(),(N=D.current)==null||N.focus();break;case"ArrowDown":j.preventDefault(),h(A=>(A+1)%Math.max(x.length,1));break;case"ArrowUp":j.preventDefault(),h(A=>(A-1+x.length)%Math.max(x.length,1));break;case"Enter":j.preventDefault(),x[d]&&a(x[d].path);break;case"Escape":j.preventDefault(),s();break}},[x,d,a,s]);if(n.useEffect(()=>{var N;const j=(N=E.current)==null?void 0:N.children[d];j==null||j.scrollIntoView({block:"nearest"})},[d]),!t)return null;const $=x[d]?`${f}-option-${d}`:void 0;return e.jsx("div",{className:"quick-open-overlay",onClick:s,children:e.jsxs("div",{className:"quick-open-dialog",role:"dialog","aria-modal":"true","aria-label":r("editor.quickOpen"),onClick:j=>j.stopPropagation(),onKeyDown:T,children:[e.jsx("input",{ref:D,className:"quick-open-input",type:"text",role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":f,"aria-activedescendant":$,value:c,onChange:j=>u(j.target.value),placeholder:r("editor.quickOpenPlaceholder")}),e.jsx("div",{className:"quick-open-list",ref:E,id:f,role:"listbox","aria-busy":m,children:m?e.jsx("div",{className:"quick-open-empty",role:"status",children:r("editor.quickOpenLoading")}):x.length===0?e.jsx("div",{className:"quick-open-empty",role:"status",children:r("editor.quickOpenEmpty")}):x.map((j,N)=>e.jsxs("div",{id:`${f}-option-${N}`,role:"option","aria-selected":N===d,className:`quick-open-item${N===d?" active":""}`,onClick:()=>a(j.path),onMouseEnter:()=>h(N),children:[e.jsx(xe,{name:j.name,type:"file",size:14}),e.jsx("span",{className:"quick-open-item-name",children:j.name}),e.jsx("span",{className:"quick-open-item-path",children:j.relativePath})]},j.path))})]})})}function Ha({gitFileCount:t=0}){const{t:s}=te(),a=ne(g=>g.activePanel),i=ne(g=>g.sidePanelCollapsed),l=ne(g=>g.toggleActivePanel),r=ne(g=>g.bottomPanelCollapsed),c=ne(g=>g.toggleBottomPanel),u=nt(g=>g.isOpen),d=nt(g=>g.toggle),h=n.useCallback(g=>a===g&&!i,[a,i]);return e.jsxs("div",{className:"ide-activity-bar",children:[e.jsxs("div",{className:"ide-activity-bar-top",children:[e.jsx("button",{className:`ide-activity-btn ${h("explorer")?"active":""}`,onClick:()=>l("explorer"),title:s("ide.explorer")||"Explorer",children:e.jsx(Dt,{size:22,strokeWidth:1.5})}),e.jsx("button",{className:`ide-activity-btn ${h("search")?"active":""}`,onClick:()=>l("search"),title:s("ide.search")||"Search",children:e.jsx(et,{size:22,strokeWidth:1.5})}),e.jsxs("button",{className:`ide-activity-btn ${h("source-control")?"active":""}`,onClick:()=>l("source-control"),title:s("ide.sourceControl")||"Source Control",children:[e.jsx(Se,{size:22,strokeWidth:1.5}),t>0&&e.jsx("span",{className:"ide-activity-badge",children:t>99?"99+":t})]})]}),e.jsxs("div",{className:"ide-activity-bar-bottom",children:[e.jsx("button",{className:`ide-activity-btn ${r?"":"active"}`,onClick:c,title:s("ide.terminal")||"Terminal",children:e.jsx(ra,{size:22,strokeWidth:1.5})}),e.jsx("button",{className:`ide-activity-btn ${u?"active":""}`,onClick:d,title:s("sidebar.toggle")||"Toggle Sidebar",children:e.jsx(ys,{size:22,strokeWidth:1.5})})]})]})}function qa(){try{const t=localStorage.getItem("cbc_search_prefs");if(t)return{...ft,...JSON.parse(t)}}catch{}return ft}const ft={viewMode:"tree",caseSensitive:!1,isRegex:!1,wholeWord:!1,query:"",includePattern:"",excludePattern:"",useDefaultExcludes:!0};function fe(t){try{localStorage.setItem("cbc_search_prefs",JSON.stringify(t))}catch{}}function pe(t){return{viewMode:t.viewMode,caseSensitive:t.caseSensitive,isRegex:t.isRegex,wholeWord:t.wholeWord,query:t.query,includePattern:t.includePattern,excludePattern:t.excludePattern,useDefaultExcludes:t.useDefaultExcludes}}const be=qa(),Va=bt((t,s)=>({query:be.query,isRegex:be.isRegex,caseSensitive:be.caseSensitive,wholeWord:be.wholeWord,includePattern:be.includePattern,excludePattern:be.excludePattern,useDefaultExcludes:be.useDefaultExcludes,viewMode:be.viewMode,results:[],searching:!1,totalMatches:0,fileCount:0,error:null,setQuery:a=>{t({query:a}),fe(pe({...s(),query:a}))},search:async()=>{var b;const{query:a,isRegex:i,caseSensitive:l,wholeWord:r,includePattern:c,excludePattern:u,useDefaultExcludes:d}=s();if(!a.trim())return;const h=Ze();let g=u||void 0;if(d){const m="node_modules,**/.git,**/dist,**/build,**/.next,**/coverage";g=g?`${g},${m}`:m}t({searching:!0,error:null,results:[],totalMatches:0,fileCount:0});try{const m=await fetch("/api/v1/fs/search-content",{method:"POST",headers:{...$e(),"Content-Type":"application/json"},body:JSON.stringify({query:a.trim(),cwd:h||void 0,isRegex:i,caseSensitive:l,wholeWord:r,includeGlob:c||void 0,excludeGlob:g,maxResults:200})});if(m.ok){const C=await m.json(),E=(C.data??C).results||[],S=new Map;for(const y of E)S.has(y.path)||S.set(y.path,[]),S.get(y.path).push(y);const f=[];for(const[y,P]of S)f.push({path:y,matches:P});t({results:f,totalMatches:E.length,fileCount:f.length,searching:!1})}else{const C=await m.json().catch(()=>null),D=((b=C==null?void 0:C.error)==null?void 0:b.message)||`HTTP ${m.status}`;t({searching:!1,error:D})}}catch(m){t({searching:!1,error:m.message||"Search failed"})}},toggleRegex:()=>{t(a=>({isRegex:!a.isRegex})),fe(pe(s()))},toggleCaseSensitive:()=>{t(a=>({caseSensitive:!a.caseSensitive})),fe(pe(s()))},toggleWholeWord:()=>{t(a=>({wholeWord:!a.wholeWord})),fe(pe(s()))},setIncludePattern:a=>{t({includePattern:a}),fe(pe({...s(),includePattern:a}))},setExcludePattern:a=>{t({excludePattern:a}),fe(pe({...s(),excludePattern:a}))},toggleUseDefaultExcludes:()=>{t(a=>({useDefaultExcludes:!a.useDefaultExcludes})),fe(pe(s()))},setViewMode:a=>{t({viewMode:a}),fe(pe(s()))},clear:()=>{t({query:"",includePattern:"",excludePattern:"",results:[],totalMatches:0,fileCount:0,searching:!1,error:null}),fe(pe(s()))}}));function Ka(t){const s={children:[]};for(const i of t){const l=i.path.split("/");let r=s;for(let c=0;c<l.length;c++){const u=l[c];if(c===l.length-1)r.children.push({name:u,fullPath:i.path,isDir:!1,children:[],matches:i.matches,matchCount:i.matches.length});else{let h=r.children.find(g=>g.isDir&&g.name===u);h||(h={name:u,fullPath:l.slice(0,c+1).join("/"),isDir:!0,children:[],matchCount:0},r.children.push(h)),r=h}}}function a(i){if(i.isDir&&i.children.length===1&&i.children[0].isDir){const c=i.children[0];return a({...c,name:`${i.name}/${c.name}`})}const l=i.children.map(a),r=l.reduce((c,u)=>c+u.matchCount,0);return{...i,children:l,matchCount:i.isDir?r:i.matchCount}}return s.children.map(a)}function qt(){const{t}=te(),{query:s,isRegex:a,caseSensitive:i,wholeWord:l,includePattern:r,excludePattern:c,useDefaultExcludes:u,viewMode:d,results:h,searching:g,totalMatches:b,fileCount:m,error:C,setQuery:D,search:E,toggleRegex:S,toggleCaseSensitive:f,toggleWholeWord:y,setIncludePattern:P,setExcludePattern:R,toggleUseDefaultExcludes:x,setViewMode:T}=Va(),{openFile:$}=se(),j=n.useRef(null),[N,A]=n.useState(new Set),[I,O]=n.useState(!0);n.useEffect(()=>{var F;(F=j.current)==null||F.focus()},[]);const o=n.useCallback(()=>{const F=new Set;for(const B of h){F.add(B.path);const X=B.path.split("/");for(let q=1;q<X.length;q++)F.add(X.slice(0,q).join("/"))}return F},[h]);n.useEffect(()=>{A(o()),O(!0)},[o]);const w=n.useMemo(()=>Ka(h),[h]),G=n.useCallback(F=>{F.key==="Enter"&&(F.preventDefault(),E())},[E]),Y=n.useCallback(F=>{A(B=>{const X=new Set(B);return X.has(F)?X.delete(F):X.add(F),X})},[]),z=n.useCallback(()=>{A(new Set),O(!1)},[]),H=n.useCallback(()=>{A(o()),O(!0)},[o]),_=n.useCallback((F,B)=>{const X=B?{line:B,query:s.trim()}:void 0;$(F,void 0,X)},[$,s]);return e.jsxs("div",{className:"search-panel",children:[e.jsx("div",{className:"scm-header",children:e.jsx("span",{className:"scm-header-title",children:t("ide.search.title")})}),e.jsxs("div",{className:"search-input-section",children:[e.jsxs("div",{className:"search-field",children:[e.jsx("input",{ref:j,className:"search-field-input",value:s,onChange:F=>D(F.target.value),onKeyDown:G,placeholder:t("ide.search.placeholder")}),e.jsxs("div",{className:"search-field-actions",children:[e.jsx("button",{className:`search-field-btn ${i?"active":""}`,onClick:f,title:t("ide.search.matchCase"),children:e.jsx(Is,{size:14})}),e.jsx("button",{className:`search-field-btn ${l?"active":""}`,onClick:y,title:t("ide.search.wholeWord"),children:e.jsx(pa,{size:14})}),e.jsx("button",{className:`search-field-btn ${a?"active":""}`,onClick:S,title:t("ide.search.regex"),children:e.jsx(ca,{size:14})})]})]}),e.jsxs("div",{className:"search-filter-section",children:[e.jsx("span",{className:"search-filter-label",children:t("ide.search.filesToInclude")}),e.jsx("div",{className:"search-field",children:e.jsx("input",{className:"search-field-input",value:r,onChange:F=>P(F.target.value),onKeyDown:G,placeholder:t("ide.search.includePlaceholder")||"e.g. *.ts, src/**/include"})})]}),e.jsxs("div",{className:"search-filter-section",children:[e.jsx("span",{className:"search-filter-label",children:t("ide.search.filesToExclude")}),e.jsxs("div",{className:"search-field",children:[e.jsx("input",{className:"search-field-input",value:c,onChange:F=>R(F.target.value),onKeyDown:G,placeholder:t("ide.search.excludePlaceholder")||"e.g. node_modules, *.min.js"}),e.jsx("div",{className:"search-field-actions",children:e.jsx("button",{className:`search-field-btn ${u?"active":""}`,onClick:x,title:t("ide.search.useExcludeSettings")||"Use Exclude Settings and Ignore Files",children:e.jsx(ks,{size:14})})})]})]})]}),(g||b>0||C)&&e.jsxs("div",{className:"search-status-bar",children:[g&&e.jsxs("div",{className:"search-status",children:[e.jsx(ve,{size:14,className:"animate-spin"}),e.jsx("span",{children:t("ide.search.searching")})]}),!g&&b>0&&e.jsx("div",{className:"search-status",children:e.jsxs("span",{children:[b," results in ",m," files"]})}),C&&e.jsx("div",{className:"search-status search-error",children:C.includes("timed out")?t("ide.search.timedOut"):t("ide.search.failed")}),b>0&&e.jsxs("div",{className:"search-status-actions",children:[e.jsx("button",{className:`scm-icon-btn ${d==="list"?"active":""}`,onClick:()=>T("list"),title:t("ide.listView"),children:e.jsx(zt,{size:14})}),e.jsx("button",{className:`scm-icon-btn ${d==="tree"?"active":""}`,onClick:()=>T("tree"),title:t("ide.treeView"),children:e.jsx(Et,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:I?z:H,title:I?"Collapse All":"Expand All",children:I?e.jsx(Zs,{size:14}):e.jsx(ma,{size:14})})]})]}),e.jsxs("div",{className:"search-results",children:[d==="tree"&&w.map(F=>e.jsx(Vt,{node:F,depth:0,expandedPaths:N,onToggle:Y,onFileClick:_,query:s},F.fullPath)),d==="list"&&h.map(F=>e.jsxs("div",{className:"search-tree-group",children:[e.jsxs("div",{className:"search-tree-file",style:{paddingLeft:"4px"},onClick:()=>Y(F.path),children:[N.has(F.path)?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx(xe,{name:F.path.split("/").pop()||"",type:"file",size:14}),e.jsx("span",{className:"search-tree-name",children:F.path.split("/").pop()}),e.jsx("span",{className:"search-list-filepath",children:F.path}),e.jsx("span",{className:"search-tree-badge",children:F.matches.length})]}),N.has(F.path)&&e.jsx("div",{className:"search-tree-matches",children:F.matches.map((B,X)=>e.jsx("div",{className:"search-tree-match",style:{paddingLeft:"24px"},onClick:()=>_(F.path,B.line),children:e.jsx(Kt,{text:B.text,query:s})},X))})]},F.path)),!g&&s&&b===0&&!C&&e.jsxs("div",{className:"scm-empty",children:[e.jsx(et,{size:20,strokeWidth:1.5,style:{opacity:.3}}),e.jsx("span",{children:t("ide.search.noResults")})]})]})]})}function Vt({node:t,depth:s,expandedPaths:a,onToggle:i,onFileClick:l,query:r}){const c=a.has(t.fullPath),u=s*14;if(t.isDir)return e.jsxs("div",{className:"search-tree-group",children:[e.jsxs("div",{className:"search-tree-dir",style:{paddingLeft:`${u+4}px`},onClick:()=>i(t.fullPath),children:[c?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx(Mt,{size:14,className:"scm-tree-folder-icon"}),e.jsx("span",{className:"search-tree-name",children:t.name}),e.jsx("span",{className:"search-tree-badge",children:t.matchCount})]}),c&&t.children.map(h=>e.jsx(Vt,{node:h,depth:s+1,expandedPaths:a,onToggle:i,onFileClick:l,query:r},h.fullPath))]});const d=t.name;return e.jsxs("div",{className:"search-tree-group",children:[e.jsxs("div",{className:"search-tree-file",style:{paddingLeft:`${u+4}px`},onClick:()=>i(t.fullPath),children:[c?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx(xe,{name:d,type:"file",size:14}),e.jsx("span",{className:"search-tree-name",children:d}),e.jsx("span",{className:"search-tree-badge",children:t.matchCount})]}),c&&t.matches&&e.jsx("div",{className:"search-tree-matches",children:t.matches.map((h,g)=>e.jsx("div",{className:"search-tree-match",style:{paddingLeft:`${u+24}px`},onClick:()=>l(t.fullPath,h.line),children:e.jsx(Kt,{text:h.text,query:r})},g))})]})}function Kt({text:t,query:s}){if(!s)return e.jsx("span",{className:"search-match-text",children:t});const a=[],i=t.toLowerCase(),l=s.toLowerCase();let r=0,c=i.indexOf(l),u=0;for(;c!==-1&&u<10;)c>r&&a.push(e.jsx("span",{children:t.slice(r,c)},u++)),a.push(e.jsx("span",{className:"search-highlight",children:t.slice(c,c+s.length)},u++)),r=c+s.length,c=i.indexOf(l,r);return r<t.length&&a.push(e.jsx("span",{children:t.slice(r)},u++)),e.jsx("span",{className:"search-match-text",children:a})}function Ua(t,s){const a={children:[]};for(const i of t){const l=s(i).split("/");let r=a;for(let c=0;c<l.length;c++){const u=l[c],d=c===l.length-1,h=l.slice(0,c+1).join("/");if(d)r.children.push({name:u,path:h,isDir:!1,children:[],data:i});else{let g=r.children.find(b=>b.isDir&&b.name===u);g||(g={name:u,path:h,isDir:!0,children:[]},r.children.push(g)),r=g}}}return a.children.map(Qe)}function Qe(t){if(t.isDir&&t.children.length===1&&t.children[0].isDir){const s=t.children[0];return Qe({...s,name:`${t.name}/${s.name}`})}return{...t,children:t.children.map(Qe)}}const Ut={modified:{label:"M",color:"var(--color-accent-yellow)"},added:{label:"A",color:"var(--color-accent-green)"},deleted:{label:"D",color:"var(--color-accent-red)"},renamed:{label:"R",color:"var(--color-accent-blue)"},copied:{label:"C",color:"var(--color-accent-blue)"},untracked:{label:"U",color:"var(--color-accent-green)"},conflicted:{label:"!",color:"var(--color-accent-red)"}};function Gt({file:t,onStage:s,onUnstage:a,onDiscard:i,onOpenFile:l}){const{t:r}=te(),c=n.useCallback(u=>{u.stopPropagation(),Ne(t.path)},[t.path]);return e.jsxs("div",{className:"scm-file-actions",children:[e.jsx("button",{className:"scm-file-action-btn",onClick:c,title:r("ide.scm.copyPath"),children:e.jsx(ws,{size:13})}),l&&t.status!=="deleted"&&e.jsx("button",{className:"scm-file-action-btn",onClick:u=>{u.stopPropagation(),l(t.path)},title:r("ide.scm.openFile"),children:e.jsx(Pt,{size:13})}),i&&e.jsx("button",{className:"scm-file-action-btn",onClick:u=>{u.stopPropagation(),i(t.path)},title:r("ide.scm.discard"),children:e.jsx(tt,{size:13})}),s&&e.jsx("button",{className:"scm-file-action-btn",onClick:u=>{u.stopPropagation(),s(t.path)},title:r("ide.scm.stage"),children:e.jsx(je,{size:13})}),a&&e.jsx("button",{className:"scm-file-action-btn",onClick:u=>{u.stopPropagation(),a(t.path)},title:r("ide.scm.unstage"),children:e.jsx(Fe,{size:13})})]})}function Ga({files:t,sectionTitle:s,sectionCount:a,sectionActions:i,onStage:l,onUnstage:r,onDiscard:c,onSelect:u,onOpenFile:d}){const[h,g]=n.useState(!0);return e.jsxs("div",{className:"scm-file-list",children:[s&&e.jsxs("div",{className:"scm-tree-section-root",onClick:()=>g(b=>!b),children:[h?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx("span",{className:"scm-tree-section-title",children:s}),a!==void 0&&e.jsx("span",{className:"scm-section-count",children:a}),i&&e.jsx("div",{className:"scm-file-actions",children:i})]}),(!s||h)&&t.map(b=>{const m=Ut[b.status]||{label:"?",color:"var(--color-text-tertiary)"},C=b.path.split("/").pop()||b.path,D=b.path.includes("/")?b.path.substring(0,b.path.lastIndexOf("/")):"";return e.jsxs("div",{className:"scm-file-item",onClick:()=>u==null?void 0:u(b.path),children:[e.jsx(xe,{name:C,type:"file",size:16}),e.jsx("span",{className:"scm-file-name-text",children:C}),D&&e.jsx("span",{className:"scm-file-path-desc",children:D}),e.jsx(Gt,{file:b,onStage:l,onUnstage:r,onDiscard:c,onOpenFile:d}),e.jsx("span",{className:"scm-file-status",style:{color:m.color},children:m.label})]},`${b.path}-${b.staged}`)})]})}function Xe({node:t,depth:s,onStage:a,onUnstage:i,onDiscard:l,onSelect:r,onOpenFile:c}){const{t:u}=te(),[d,h]=n.useState(!0);function g(f){if(!f.isDir)return null;const y=Je(f);return y.length===0?null:y.some(P=>P.status==="modified")?"var(--color-accent-yellow)":y.some(P=>P.status==="untracked"||P.status==="added")?"var(--color-accent-green)":"var(--color-text-tertiary)"}const b=g(t),m=Je(t),C=n.useCallback(f=>{f.stopPropagation(),a&&m.forEach(y=>a(y.path))},[a,m]),D=n.useCallback(f=>{f.stopPropagation(),l&&m.forEach(y=>l(y.path))},[l,m]),E=n.useCallback(f=>{f.stopPropagation(),i&&m.forEach(y=>i(y.path))},[i,m]),S=s*16+4;return e.jsxs("div",{className:"scm-tree-group",children:[e.jsxs("div",{className:"scm-tree-dir",style:{paddingLeft:`${S}px`},onClick:()=>h(f=>!f),children:[Array.from({length:s},(f,y)=>e.jsx("span",{className:"scm-tree-indent-guide",style:{left:`${y*16+12}px`}},y)),d?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx(Mt,{size:14,className:"scm-tree-folder-icon"}),e.jsx("span",{className:"scm-tree-dir-name",children:t.name}),e.jsxs("div",{className:"scm-file-actions",children:[l&&e.jsx("button",{className:"scm-file-action-btn",onClick:D,title:u("ide.scm.discardAll"),children:e.jsx(tt,{size:13})}),a&&e.jsx("button",{className:"scm-file-action-btn",onClick:C,title:u("ide.scm.stageAll"),children:e.jsx(je,{size:13})}),i&&e.jsx("button",{className:"scm-file-action-btn",onClick:E,title:u("ide.scm.unstageAll"),children:e.jsx(Fe,{size:13})})]}),b&&e.jsx("span",{className:"scm-tree-dir-dot",style:{background:b}})]}),d&&t.children.map(f=>f.isDir?e.jsx(Xe,{node:f,depth:s+1,onStage:a,onUnstage:i,onDiscard:l,onSelect:r,onOpenFile:c},f.path):e.jsx(Ye,{node:f,depth:s+1,onStage:a,onUnstage:i,onDiscard:l,onSelect:r,onOpenFile:c},f.path))]})}function Ye({node:t,depth:s,onStage:a,onUnstage:i,onDiscard:l,onSelect:r,onOpenFile:c}){const u=t.data,d=Ut[u.status]||{label:"?",color:"var(--color-text-tertiary)"};return e.jsxs("div",{className:"scm-file-item",style:{paddingLeft:`${s*16+20}px`},onClick:()=>r==null?void 0:r(u.path),children:[Array.from({length:s},(h,g)=>e.jsx("span",{className:"scm-tree-indent-guide",style:{left:`${g*16+12}px`}},g)),e.jsx(xe,{name:t.name,type:"file",size:16}),e.jsx("span",{className:"scm-file-name-text",children:t.name}),e.jsx(Gt,{file:u,onStage:a,onUnstage:i,onDiscard:l,onOpenFile:c}),e.jsx("span",{className:"scm-file-status",style:{color:d.color},children:d.label})]})}function Je(t){return t.isDir?t.children.flatMap(Je):t.data?[t.data]:[]}function Qa({files:t,sectionTitle:s,sectionCount:a,sectionActions:i,onStage:l,onUnstage:r,onDiscard:c,onSelect:u,onOpenFile:d}){const[h,g]=n.useState(!0),b=Ua(t,m=>m.path);return s?e.jsxs("div",{className:"scm-file-list scm-tree-view",children:[e.jsxs("div",{className:"scm-tree-section-root",onClick:()=>g(m=>!m),children:[h?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx("span",{className:"scm-tree-section-title",children:s}),a!==void 0&&e.jsx("span",{className:"scm-section-count",children:a}),i&&e.jsx("div",{className:"scm-file-actions",children:i})]}),h&&b.map(m=>m.isDir?e.jsx(Xe,{node:m,depth:1,onStage:l,onUnstage:r,onDiscard:c,onSelect:u,onOpenFile:d},m.path):e.jsx(Ye,{node:m,depth:1,onStage:l,onUnstage:r,onDiscard:c,onSelect:u,onOpenFile:d},m.path))]}):e.jsx("div",{className:"scm-file-list scm-tree-view",children:b.map(m=>m.isDir?e.jsx(Xe,{node:m,depth:0,onStage:l,onUnstage:r,onDiscard:c,onSelect:u,onOpenFile:d},m.path):e.jsx(Ye,{node:m,depth:0,onStage:l,onUnstage:r,onDiscard:c,onSelect:u,onOpenFile:d},m.path))})}function pt(t){return t.viewMode==="tree"?e.jsx(Qa,{...t}):e.jsx(Ga,{...t})}const xt=["var(--color-accent-green)","var(--color-accent-blue)","var(--color-accent-yellow)","var(--color-accent-purple)","var(--color-accent-red)"];function Xa(t){try{const s=new Date(t),i=new Date().getTime()-s.getTime(),l=Math.floor(i/6e4);if(l<60)return`${l}m ago`;const r=Math.floor(l/60);if(r<24)return`${r}h ago`;const c=Math.floor(r/24);return c<7?`${c}d ago`:s.toLocaleDateString()}catch{return t}}function Ya(){const{t}=te(),[s,a]=n.useState(!1),[i,l]=n.useState([]),[r,c]=n.useState(!1),u=n.useCallback(async()=>{c(!0);try{const d=await Ca(30);l(d)}catch{}c(!1)},[]);return n.useEffect(()=>{s&&i.length===0&&!r&&u()},[s,i.length,r,u]),e.jsxs("div",{className:"scm-graph",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>a(d=>!d),children:[s?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx("span",{children:t("ide.scm.graph")}),s&&e.jsx("button",{className:"scm-icon-btn",onClick:d=>{d.stopPropagation(),u()},title:t("ide.refresh"),children:e.jsx(Me,{size:12,className:r?"animate-spin":""})})]}),s&&e.jsxs("div",{className:"scm-graph-list",children:[r&&i.length===0&&e.jsx("div",{className:"scm-graph-loading",children:e.jsx(ve,{size:14,className:"animate-spin"})}),i.map((d,h)=>e.jsxs("div",{className:"scm-graph-entry",title:`${d.hash}
94
+ ${d.author}
95
+ ${d.date}`,children:[e.jsx("span",{className:"scm-graph-dot",style:{background:xt[h%xt.length]}}),e.jsx("span",{className:"scm-graph-msg",children:d.message}),e.jsx("span",{className:"scm-graph-time",children:Xa(d.date)})]},d.hash))]})]})}function Qt(){const{t}=te(),{isGitRepo:s,loading:a,files:i,currentBranch:l,ahead:r,behind:c,pushing:u,pulling:d,branches:h,branchesLoading:g,lastOperationMessage:b,refresh:m,loadBranches:C,stageFile:D,unstageFile:E,stageAll:S,unstageAll:f,discardFile:y,discardAll:P,push:R,pull:x,switchBranch:T,createBranch:$,clearOperationMessage:j}=me(),N=se(B=>B.openFile),A=ne(B=>B.scmViewMode),I=ne(B=>B.setScmViewMode),[O,o]=n.useState(!0),[w,G]=n.useState(!0);n.useEffect(()=>{m(),me.getState().startWatching()},[m]),n.useEffect(()=>{if(b){const B=setTimeout(j,3e3);return()=>clearTimeout(B)}},[b,j]);const Y=T,z=n.useCallback(async(B,X)=>{ne.getState().bottomPanelMaximized&&ne.setState({bottomPanelMaximized:!1});try{const q=await Lt(B,X);se.getState().openDiffTab(B,{oldText:q.oldText,newText:q.newText,staged:X})}catch{}},[]),H=N,_=i.filter(B=>B.staged),F=i.filter(B=>!B.staged);return s?e.jsxs("div",{className:"scm-panel",children:[e.jsxs("div",{className:"scm-header",children:[e.jsx("span",{className:"scm-header-title",children:t("ide.scm.title")}),e.jsxs("div",{className:"scm-header-actions",children:[e.jsx("button",{className:`scm-icon-btn ${A==="list"?"active":""}`,onClick:()=>I("list"),title:t("ide.listView"),children:e.jsx(zt,{size:14})}),e.jsx("button",{className:`scm-icon-btn ${A==="tree"?"active":""}`,onClick:()=>I("tree"),title:t("ide.treeView"),children:e.jsx(Et,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:m,disabled:a,title:t("ide.refresh"),children:e.jsx(Me,{size:14,className:a?"animate-spin":""})})]})]}),e.jsxs("div",{className:"scm-scroll",children:[e.jsxs("div",{className:"scm-section",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>o(B=>!B),children:[O?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx("span",{children:t("ide.scm.repositories")})]}),O&&e.jsx($t,{currentBranch:l,branches:h,branchesLoading:g,onSwitch:Y,onCreate:$,onLoadBranches:C,actions:e.jsxs(e.Fragment,{children:[(r>0||c>0)&&e.jsxs("span",{className:"scm-branch-sync",children:[r>0&&e.jsxs("span",{children:["↑",r]}),c>0&&e.jsxs("span",{children:["↓",c]})]}),e.jsxs("div",{className:"scm-branch-actions",children:[e.jsx("button",{className:"scm-icon-btn",onClick:x,disabled:d,title:t("ide.scm.pull"),children:d?e.jsx(ve,{size:14,className:"animate-spin"}):e.jsx(Cs,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:R,disabled:u,title:t("ide.scm.push"),children:u?e.jsx(ve,{size:14,className:"animate-spin"}):e.jsx(Ns,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:m,disabled:a,title:t("ide.refresh"),children:e.jsx(Me,{size:12,className:a?"animate-spin":""})})]})]})})]}),e.jsxs("div",{className:"scm-section",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>G(B=>!B),children:[w?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx("span",{children:t("ide.scm.changes")}),e.jsx("span",{className:"scm-section-count",children:i.length})]}),b&&e.jsx("div",{className:"scm-operation-msg",children:b}),w&&e.jsxs(e.Fragment,{children:[_.length>0&&e.jsx(pt,{files:_,viewMode:A,sectionTitle:t("ide.scm.stagedChanges"),sectionCount:_.length,sectionActions:e.jsx("button",{className:"scm-file-action-btn",onClick:()=>f(),title:t("ide.scm.unstageAll"),children:e.jsx(Fe,{size:13})}),onUnstage:E,onSelect:B=>z(B,!0),onOpenFile:H}),F.length>0&&e.jsx(pt,{files:F,viewMode:A,sectionTitle:t("ide.scm.changes"),sectionCount:F.length,sectionActions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"scm-file-action-btn",onClick:()=>P(),title:t("ide.scm.discardAll"),children:e.jsx(tt,{size:13})}),e.jsx("button",{className:"scm-file-action-btn",onClick:()=>S(),title:t("ide.scm.stageAll"),children:e.jsx(je,{size:13})})]}),onStage:D,onDiscard:y,onSelect:B=>z(B,!1),onOpenFile:H}),i.length===0&&!a&&e.jsxs("div",{className:"scm-empty",children:[e.jsx(vt,{size:20,strokeWidth:1.5,style:{opacity:.3}}),e.jsx("span",{children:t("ide.scm.noChanges")})]})]})]}),e.jsx(Ya,{})]})]}):e.jsxs("div",{className:"scm-panel",children:[e.jsx("div",{className:"scm-header",children:e.jsx("span",{className:"scm-header-title",children:t("ide.scm.title")})}),e.jsxs("div",{className:"ide-panel-placeholder",children:[e.jsx(Se,{size:32,strokeWidth:1,style:{opacity:.2}}),e.jsx("div",{className:"ide-panel-placeholder-text",children:t("ide.scm.notGitRepo")})]})]})}function Ja({activePanel:t,onMenuClick:s}){return e.jsxs("div",{className:"ide-side-panel-content",children:[t==="explorer"&&e.jsx(_t,{onMenuClick:s}),t==="search"&&e.jsx(qt,{}),t==="source-control"&&e.jsx(Qt,{})]})}function Za({onMenuClick:t,activeTab:s,tabActions:a,cursorInfo:i,imageInfo:l,previewZoom:r,isMarkdownSource:c,quickOpenVisible:u,setQuickOpenVisible:d,onContentChange:h,onSave:g,onRequestClose:b,onCursorChange:m,onImageInfo:C,onZoomChange:D}){const{t:E}=te(),{rootPath:S,openFile:f,revealInTree:y,loadTab:P,showHiddenFiles:R}=se(),{activePanel:x,sidePanelWidth:T,sidePanelCollapsed:$,setSidePanelWidth:j,setSidePanelCollapsed:N,bottomPanelHeight:A,bottomPanelCollapsed:I,bottomPanelMaximized:O,setBottomPanelHeight:o,setBottomPanelCollapsed:w,toggleBottomPanelMaximize:G}=ne(),Y=ht({direction:"horizontal",initialSize:T,minSize:160,maxSize:600,collapsible:!0,defaultCollapsed:$,onResize:j,onCollapse:N,ariaLabel:E("ide.resizeSidePanel")}),z=ht({direction:"vertical",initialSize:A,minSize:140,maxSize:typeof window<"u"?Math.max(300,window.innerHeight-80):500,collapsible:!0,defaultCollapsed:I,reverse:!0,onResize:o,onCollapse:w,onMaximize:G,maximizeThreshold:.85,ariaLabel:E("ide.resizeBottomPanel")}),H=me(p=>p.files.length);n.useEffect(()=>(me.getState().refresh(),me.getState().startWatching(),()=>{me.getState().stopWatching()}),[]);const _=typeof navigator<"u"&&navigator.platform.includes("Mac"),F=()=>s?s.loadStatus!=="ready"?e.jsx(Tt,{tab:s,onRetry:()=>P(s.id)}):s.viewMode==="diff"&&s.diffData?e.jsx("div",{className:"editor-container",children:e.jsx(Ss,{path:s.path,oldText:s.diffData.oldText,newText:s.diffData.newText})}):s.viewMode==="editor"||c?e.jsx("div",{className:"editor-container",children:e.jsx(Rt,{path:s.path,content:s.content,language:s.language,onContentChange:h,onSave:g,minimap:!0,onCursorChange:m})}):e.jsx(It,{path:s.path,name:s.name,content:s.content,viewMode:s.viewMode,onImageInfo:C,onZoomChange:D}):e.jsx(en,{isMac:_,t:E}),B=u&&S&&e.jsx(Ht,{isOpen:u,onClose:()=>d(!1),onSelect:p=>{f(p),d(!1)},rootPath:S,showHiddenFiles:R}),X=x&&!Y.collapsed,q=!z.collapsed;return e.jsxs("div",{className:"ide-layout",children:[B,e.jsxs("div",{className:"ide-layout-row",ref:Y.containerRef,children:[e.jsx(Ha,{gitFileCount:H}),X&&e.jsxs("div",{className:"ide-side-panel",style:{width:Y.size},children:[e.jsx(Ja,{activePanel:x,onMenuClick:t}),e.jsx("div",{...Y.sashProps})]}),e.jsxs("div",{className:"ide-main-area",ref:z.containerRef,children:[!O&&e.jsxs("div",{className:"ide-editor-area",style:{flex:q?void 0:1,height:q?`calc(100% - ${z.size}px)`:"100%"},children:[e.jsx(At,{actions:a,onRequestClose:b}),s&&S&&e.jsx(Ba,{filePath:s.path,rootPath:S,onSegmentClick:y,onOpenFile:f}),e.jsx("div",{className:"ide-editor-content",onDragOver:p=>{p.preventDefault(),p.dataTransfer.dropEffect="copy"},onDrop:p=>{p.preventDefault();const L=p.dataTransfer.getData("application/x-file-paths")||p.dataTransfer.getData("text/plain");if(L){try{const V=JSON.parse(L),M=Array.isArray(V)?V:[L];M.length>0&&f(M[0])}catch{L&&f(L)}setTimeout(()=>{const V=document.querySelector(".ide-editor-content .monaco-editor textarea");V==null||V.focus()},100)}},children:F()})]}),q&&e.jsxs(e.Fragment,{children:[!O&&e.jsx("div",{...z.sashProps}),e.jsx("div",{className:"ide-bottom-panel-wrap",style:{height:O?"100%":z.size},children:e.jsx(Wt,{})})]})]})]}),e.jsx("div",{className:"ide-statusbar-drag-zone",onPointerDown:z.sashProps.onPointerDown,onDoubleClick:z.sashProps.onDoubleClick,children:e.jsx(Ft,{language:(s==null?void 0:s.language)||"",cursorLine:i.line,cursorColumn:i.col,selectedCount:i.selectedChars,selectedLines:i.selectedLines,viewMode:s?c?"editor":s.viewMode:"editor",isDirty:s==null?void 0:s.isDirty,saveStatus:s==null?void 0:s.saveStatus,saveError:s==null?void 0:s.saveError,imageInfo:l,zoom:r})})]})}function en({isMac:t,t:s}){const a=n.useRef(null),[i,l]=n.useState(!1);return n.useEffect(()=>{const r=a.current;if(!r)return;const c=new ResizeObserver(u=>{for(const d of u)l(d.contentRect.height<300)});return c.observe(r),()=>c.disconnect()},[]),e.jsxs("div",{className:"editor-empty",ref:a,children:[e.jsx("div",{className:"ide-empty-icon",children:e.jsx("img",{src:Ms,alt:"CodeBuddy",width:"64",height:"64",style:{opacity:.15,filter:"grayscale(1)"}})}),!i&&e.jsxs("div",{className:"editor-empty-shortcuts",children:[e.jsxs("div",{className:"editor-empty-hint",children:[e.jsxs("kbd",{children:[t?"⌘":"Ctrl","+P"]}),e.jsx("span",{children:s("editor.quickOpen")})]}),e.jsxs("div",{className:"editor-empty-hint",children:[e.jsxs("kbd",{children:[t?"⌘":"Ctrl","+B"]}),e.jsx("span",{children:s("ide.toggleSidebar")||"Toggle Sidebar"})]}),e.jsxs("div",{className:"editor-empty-hint",children:[e.jsxs("kbd",{children:[t?"⌃":"Ctrl","+`"]}),e.jsx("span",{children:s("ide.toggleTerminal")||"Toggle Terminal"})]})]})]})}function tn(){const{t}=te(),s=ne(r=>r.activeMobilePanel),a=ne(r=>r.setActiveMobilePanel),i=me(r=>r.files.length),l=[{id:"explorer",icon:e.jsx(Dt,{size:20,strokeWidth:1.5}),label:t("ide.explorer")||"Explorer"},{id:"search",icon:e.jsx(et,{size:20,strokeWidth:1.5}),label:t("ide.search")||"Search"},{id:"source-control",icon:e.jsx(Se,{size:20,strokeWidth:1.5}),label:t("ide.sourceControl")||"Source Control",badge:i},{id:"terminal",icon:e.jsx(Ps,{size:20,strokeWidth:1.5}),label:t("ide.terminal")||"Terminal"}];return e.jsx("div",{className:"mobile-tab-bar",children:l.map(r=>e.jsxs("button",{className:`mobile-tab-bar-btn ${s===r.id?"active":""}`,onClick:()=>a(r.id),children:[e.jsxs("span",{className:"mobile-tab-bar-icon",children:[r.icon,r.badge!=null&&r.badge>0&&e.jsx("span",{className:"mobile-tab-bar-badge",children:r.badge>99?"99+":r.badge})]}),e.jsx("span",{className:"mobile-tab-bar-label",children:r.label})]},r.id))})}const sn=1e3;function Ke(t){return`editor-save:${t}`}function cn({onMenuClick:t,isVisible:s=!0}){const{t:a,resolved:i}=te(),{tabs:l,activeTabId:r,rootPath:c,setRootPath:u,openFile:d,loadTab:h,updateTabContent:g,saveTab:b,requestCloseTabs:m,discardTabs:C,revealInTree:D,pendingReveal:E,showHiddenFiles:S}=se(),[f,y]=n.useState(!1),[P]=n.useState(()=>xa(sn)),R=ne(W=>W.toggleBottomPanel),x=Ds(),[T,$]=n.useState(!1),j=n.useRef(!1),N=n.useRef(null),A=n.useRef(null),I=n.useCallback(()=>{j.current||(A.current=document.activeElement instanceof HTMLElement?document.activeElement:null,j.current=!0,$(!0))},[]),O=n.useCallback(()=>{j.current=!1,$(!1),requestAnimationFrame(()=>{var W;(W=A.current)==null||W.focus(),A.current=null})},[]);n.useEffect(()=>{N.current&&(N.current.inert=!T)},[T,x]);const o=n.useRef("");n.useEffect(()=>{const W=async()=>{if(rt()!=="editor")return;const v=wt(),k=v.get("path");if(!k)return;const Q=v.get("line"),U=v.get("col"),ee=`${k}:${Q}:${U}`;if(ee===o.current)return;if(o.current=ee,!se.getState().rootPath){const oe=v.get("folder")||new URLSearchParams(window.location.search).get("folder");oe&&await u(oe)}const Oe=await Ls(k),we=se.getState().rootPath;if(Oe==="directory")we&&(k===we||k.startsWith(we+"/"))?D(k):(await u(k),Ue(async()=>{const{useFolderStore:oe}=await import("./index-DC-fErwI.js").then(Be=>Be.aS);return{useFolderStore:oe}},__vite__mapDeps([0,1,2,3])).then(({useFolderStore:oe})=>{oe.getState().setFolder(k)}));else{if(!we){const at=k.substring(0,k.lastIndexOf("/"));at&&await u(at)}const oe=Q?parseInt(Q,10):void 0,Be=oe?{line:oe,col:U?parseInt(U,10):1,query:""}:void 0;d(k,void 0,Be),D(k)}};W();const K=()=>W();return window.addEventListener("hashchange",K),()=>window.removeEventListener("hashchange",K)},[]),n.useEffect(()=>{x||(j.current=!1,$(!1))},[x]),n.useEffect(()=>{x&&r&&I()},[x,r,l.length,I]),n.useEffect(()=>{x&&E&&r&&I()},[x,E,r,I]),n.useEffect(()=>{if(!r)return;const W=se.getState().tabs.find(K=>K.id===r);W&&D(W.path)},[r,D]);const w=l.find(W=>W.id===r)||null,G=a("editor.saveFailed"),Y=a("app.retry"),z=n.useRef(new Map);n.useEffect(()=>{const W=z.current,K=new Set,v=it.getState().removeToast;for(const k of l){if(k.saveStatus!=="error")continue;K.add(k.id);const Q=`${i}:${k.saveError??""}`;W.get(k.id)!==Q&&(W.set(k.id,Q),Ct.error(`${G}${k.saveError?`: ${k.saveError}`:""}`,{id:Ke(k.id),durationMs:0,action:{label:Y,onClick:()=>se.getState().saveTab(k.id)}}))}for(const k of W.keys())K.has(k)||(v(Ke(k)),W.delete(k))},[i,Y,G,l]),n.useEffect(()=>()=>{const W=z.current,K=it.getState().removeToast;for(const v of W.keys())K(Ke(v));W.clear()},[]);const H=n.useCallback(W=>{if(!r)return;g(r,W);const K=r;P.schedule(K,()=>{const v=se.getState(),k=v.tabs.find(Q=>Q.id===K);(k==null?void 0:k.loadStatus)==="ready"&&k.isDirty&&v.saveTab(K).catch(()=>!1)})},[r,P,g]);n.useEffect(()=>()=>P.dispose(),[P]),n.useEffect(()=>{const W=K=>{se.getState().tabs.some(k=>k.isDirty||k.saveStatus==="saving")&&(K.preventDefault(),K.returnValue="")};return window.addEventListener("beforeunload",W),()=>window.removeEventListener("beforeunload",W)},[]);const[_,F]=n.useState(null),B=n.useCallback(async W=>{zs(se.getState().tabs,W).forEach(k=>P.cancel(k));const v=await m(W);F(v.closed?null:v)},[P,m]);n.useEffect(()=>{if(!s)return;const W=K=>{if(K.defaultPrevented||!s||rt()!=="editor")return;const v=K.metaKey||K.ctrlKey;if(v&&K.key==="p"&&!K.shiftKey&&(K.preventDefault(),y(!0)),v&&K.key==="w"&&!K.shiftKey&&(K.preventDefault(),r&&B({kind:"single",id:r}).catch(()=>{})),v&&K.key==="b"&&!K.shiftKey){K.preventDefault();const k=ne.getState();k.setSidePanelCollapsed(!k.sidePanelCollapsed)}v&&K.key==="`"&&(K.preventDefault(),R())};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[r,B,s,R]);const X=n.useCallback(()=>{r&&(P.cancel(r),b(r).catch(()=>!1))},[r,P,b]),[q,p]=n.useState({line:1,col:1,selectedChars:0,selectedLines:0}),L=n.useCallback((W,K,v,k)=>{p({line:W,col:K,selectedChars:v,selectedLines:k})},[]),[V,M]=n.useState(null),[Z,le]=n.useState(1),[ue,J]=n.useState(new Set),ae=(w==null?void 0:w.viewMode)==="markdown"&&!ue.has(w.id),ye=n.useCallback(()=>{r&&J(W=>{const K=new Set(W);return K.has(r)?K.delete(r):K.add(r),K})},[r]);let ke=null;(w==null?void 0:w.viewMode)==="markdown"&&(ke=ae?e.jsx("button",{className:"editor-action-btn",onClick:ye,title:a("editor.preview"),"aria-label":a("editor.preview"),children:e.jsx(Es,{size:16})}):e.jsx("button",{className:"editor-action-btn",onClick:ye,title:a("editor.source"),"aria-label":a("editor.source"),children:e.jsx(Rs,{size:16})}));const Ae=n.useCallback(()=>{const W=new URLSearchParams(window.location.search);W.set("standalone","1"),window.open(`#/editor?${W.toString()}`,"_blank","noopener,noreferrer")},[]),Pe=e.jsxs(e.Fragment,{children:[ke,e.jsx("button",{className:"editor-action-btn",onClick:Ae,title:a("editor.openInNewWindow"),"aria-label":a("editor.openInNewWindow"),children:e.jsx(Pt,{size:16})})]}),De=n.useCallback(()=>{_&&(_.targetIds.forEach(W=>P.cancel(W)),C(_.targetIds),F(null))},[P,C,_]),Ie=n.useCallback(()=>{F(null)},[]),ze=_?e.jsx(Nt,{title:a("editor.closeSaveFailedTitle",{count:_.failedTabIds.length}),message:a("editor.closeSaveFailedMessage",{count:_.failedTabIds.length}),confirmLabel:a("editor.discardAndClose"),danger:!0,onConfirm:De,onCancel:Ie}):null,ge=ne(W=>W.activeMobilePanel),Ee=ne(W=>W.createBottomTerminal),Re=ne(W=>W.bottomTerminals);if(n.useEffect(()=>{x&&ge==="terminal"&&Re.length===0&&Ee()},[x,ge,Re.length,Ee]),x){const W=f&&c&&e.jsx(Ht,{isOpen:f,onClose:()=>y(!1),onSelect:v=>{d(v),y(!1)},rootPath:c,showHiddenFiles:S});let K=null;return w&&(w.loadStatus!=="ready"?K=e.jsx(Tt,{tab:w,onRetry:()=>h(w.id)}):w.viewMode==="editor"||ae?K=e.jsx("div",{className:"editor-container",children:e.jsx(Rt,{path:w.path,content:w.content,language:w.language,onContentChange:H,onSave:X,minimap:!1,onCursorChange:L})}):K=e.jsx(It,{path:w.path,name:w.name,content:w.content,viewMode:w.viewMode,onImageInfo:M,onZoomChange:le})),e.jsxs("div",{className:"editor-view editor-view-mobile",children:[W,ze,e.jsxs("div",{className:"mobile-panel-content",children:[ge==="explorer"&&e.jsx("div",{className:"editor-sidebar editor-sidebar-mobile",children:e.jsx(_t,{onMenuClick:t})}),ge==="search"&&e.jsx(qt,{}),ge==="source-control"&&e.jsx(Qt,{}),ge==="terminal"&&e.jsx("div",{className:"mobile-terminal-panel",children:e.jsx(Wt,{})})]}),e.jsx("div",{ref:N,className:`editor-mobile-panel ${T?"open":""}`,"aria-hidden":!T,children:e.jsxs("div",{className:"editor-main",children:[e.jsxs("div",{className:"editor-mobile-header",children:[e.jsx("button",{className:"editor-mobile-back",onClick:O,"aria-label":a("editor.mobileBack"),children:e.jsx(Ts,{size:18})}),e.jsx("div",{className:"editor-mobile-tabs-wrap",children:e.jsx(At,{actions:Pe,onRequestClose:B})})]}),K,w&&e.jsx(Ft,{language:w.language,cursorLine:q.line,cursorColumn:q.col,selectedCount:q.selectedChars,selectedLines:q.selectedLines,viewMode:ae?"editor":w.viewMode,isDirty:w.isDirty,saveStatus:w.saveStatus,saveError:w.saveError,imageInfo:V,zoom:Z})]})}),e.jsx(tn,{})]})}return e.jsxs("div",{className:"editor-view",children:[ze,e.jsx(Za,{onMenuClick:t,activeTab:w,tabActions:Pe,cursorInfo:q,imageInfo:V,previewZoom:Z,isMarkdownSource:ae,quickOpenVisible:f,setQuickOpenVisible:y,onContentChange:H,onSave:X,onRequestClose:B,onCursorChange:L,onImageInfo:M,onZoomChange:le})]})}export{cn as EditorView};
@@ -1,4 +1,4 @@
1
- import{a,j as t}from"./markdown-DIY6o85n.js";import{u as U,ah as P,ai as L,aj as M,ak as I,A as q,l as F,X as J,al as K,am as Q}from"./index-DNUXcSh8.js";import"./vendor-D35k0Cos.js";const V=({isOpen:n,actionId:d,actionName:v,context:i,existingBindings:y,onSave:C,onCancel:g})=>{const{t:b}=U(),[c,S]=a.useState([]),[f,j]=a.useState([]);a.useEffect(()=>{n&&(S([]),j([]))},[n]),a.useEffect(()=>{if(!n)return;const x=l=>{if(l.preventDefault(),l.stopPropagation(),["Control","Shift","Alt","Meta"].includes(l.key))return;const u=L(l);if(!u)return;const k=[...c,u];S(k);const R=M(k).toLowerCase(),D=y.filter(h=>h.action===d&&h.context===i?!1:M(h.chord).toLowerCase()===R&&h.action!==null).map(h=>`${h.action} (${h.context})`);j(D)};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[n,c,y,d,i]);const o=a.useCallback(()=>{if(c.length===0)return;const x=c.map(l=>{const u=[];return l.ctrl&&u.push("ctrl"),l.alt&&u.push("alt"),l.shift&&u.push("shift"),l.super&&u.push("cmd"),u.push(l.key===" "?"space":l.key),u.join("+")});C(x.join(" "))},[c,C]),$=a.useCallback(()=>{S([]),j([])},[]);return n?t.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/50",style:{zIndex:"var(--z-modal, 100)"},onClick:g,children:t.jsxs("div",{className:"bg-[var(--color-bg-primary)] border border-[var(--color-border-default)] rounded-lg p-6 w-[440px] shadow-xl",onClick:x=>x.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-medium text-[var(--color-text-primary)] mb-1",children:b("keybindings.record.title")}),t.jsxs("p",{className:"text-sm text-[var(--color-text-secondary)] mb-4",children:[v," ",t.jsxs("span",{className:"text-[var(--color-text-muted)]",children:["(",i,")"]})]}),t.jsx("div",{className:"border border-[var(--color-border-default)] rounded-md p-4 mb-4 text-center min-h-[60px] flex items-center justify-center bg-[var(--color-bg-secondary)]",children:c.length>0?t.jsx("span",{className:"text-lg font-mono text-[var(--color-text-primary)]",children:c.map((x,l)=>t.jsxs("span",{children:[l>0&&t.jsx("span",{className:"text-[var(--color-text-muted)] mx-1",children:" "}),P(x)]},l))}):t.jsx("span",{className:"text-sm text-[var(--color-text-muted)]",children:b("keybindings.record.hint")})}),f.length>0&&t.jsxs("div",{className:"text-sm text-[var(--color-warning)] mb-4",children:[b("keybindings.record.conflict"),": ",f.join(", ")]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[c.length>0&&t.jsx("button",{className:"px-3 py-1.5 text-sm text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors",onClick:$,children:b("keybindings.action.reset")}),t.jsx("button",{className:"px-3 py-1.5 text-sm text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors",onClick:g,children:b("app.cancel")}),t.jsx("button",{className:`px-4 py-1.5 text-sm rounded-md transition-colors ${c.length===0?"bg-[var(--color-bg-secondary)] text-[var(--color-text-muted)] cursor-not-allowed":"bg-[var(--color-accent-brand)] text-[var(--color-bg-primary)] hover:opacity-90"}`,disabled:c.length===0,onClick:o,children:b("app.confirm")})]})]})}):null},W=()=>{const{t:n,tryT:d}=U(),{defaults:v,userBlocks:i,bindings:y,warnings:C,loaded:g,loadBindings:b,saveUserBindings:c,resetBindings:S}=I(),[f,j]=a.useState(""),[o,$]=a.useState(null),x=a.useCallback(s=>d(`keybindings.ctx.${s}`)??s,[d]),l=a.useCallback(s=>d(`keybindings.ctxDesc.${s}`)??"",[d]),u=a.useCallback(s=>d(`keybindings.act.${s}`)??X(s),[d]);a.useEffect(()=>{g||b()},[g,b]);const k=a.useMemo(()=>{if(!g)return[];const s=new Set;if(i)for(const e of i)for(const[p,m]of Object.entries(e.bindings))s.add(`${e.context}:${m??"null"}:${p}`);const r=new Map;for(const e of y){const p=`${e.context}:${e.action}`,m=M(e.chord),z=e.chord.map(N=>{const w=[];return N.ctrl&&w.push("ctrl"),N.alt&&w.push("alt"),N.shift&&w.push("shift"),N.super&&w.push("cmd"),w.push(N.key===" "?"space":N.key),w.join("+")}).join(" "),A=s.has(`${e.context}:${e.action}:${z}`);r.set(p,{action:e.action??"",displayName:e.action?u(e.action):"",keyDisplay:m,keyRaw:z,context:e.context,source:A?"user":"default",isUnbound:e.action===null})}return Array.from(r.values()).filter(e=>!e.isUnbound)},[g,y,i,u]),R=a.useMemo(()=>f.trim()?k.filter(s=>[s.displayName,s.action,s.keyDisplay,x(s.context)].some(e=>q(f,e).match)):k,[k,f,x]),D=a.useMemo(()=>{const s=new Map;for(const r of R){const e=s.get(r.context)||[];e.push(r),s.set(r.context,e)}return s},[R]),h=a.useCallback(async s=>{if(!o)return;const r=i?JSON.parse(JSON.stringify(i)):[];let e=r.find(p=>p.context===o.context);e||(e={context:o.context,bindings:{}},r.push(e));for(const[p,m]of Object.entries(e.bindings))m===o.action&&delete e.bindings[p];e.bindings[s]=o.action,await c({bindings:r}),$(null)},[o,i,c]),O=a.useCallback(async s=>{const r=i?JSON.parse(JSON.stringify(i)):[];let e=r.find(p=>p.context===s.context);e||(e={context:s.context,bindings:{}},r.push(e)),e.bindings[s.keyRaw]=null,await c({bindings:r})},[i,c]),B=a.useCallback(async s=>{if(!i)return;const r=JSON.parse(JSON.stringify(i)),e=r.find(m=>m.context===s.context);if(!e)return;delete e.bindings[s.keyRaw];for(const[m,E]of Object.entries(e.bindings))if(E===s.action||E===null){const z=v.find(A=>A.context===s.context);z&&z.bindings[m]===s.action&&delete e.bindings[m]}const p=r.filter(m=>Object.keys(m.bindings).length>0);await c({bindings:p})},[i,v,c]);return g?t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-2 border-b border-[var(--color-border-default)] flex items-center gap-2",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(F,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-muted)]"}),t.jsx("input",{type:"text",value:f,onChange:s=>j(s.target.value),placeholder:n("keybindings.search.placeholder"),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-[var(--color-bg-secondary)] text-[var(--color-text-primary)] border border-[var(--color-border-default)] rounded-md outline-none focus:border-[var(--color-accent-blue)]"}),f&&t.jsx("button",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]",onClick:()=>j(""),children:t.jsx(J,{size:14})})]}),t.jsx("button",{className:"p-1.5 text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] transition-colors",onClick:()=>S(),title:n("keybindings.reset.all"),children:t.jsx(K,{size:14})})]}),C.length>0&&t.jsx("div",{className:"px-4 py-2 bg-[var(--color-warning-bg,rgba(255,170,0,0.1))] border-b border-[var(--color-border-default)]",children:C.slice(0,3).map((s,r)=>t.jsxs("p",{className:"text-xs text-[var(--color-warning)]",children:[s.severity==="error"?"x":"!"," ",s.message]},r))}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[Array.from(D.entries()).map(([s,r])=>t.jsxs("div",{className:"mb-2",children:[t.jsxs("div",{className:"sticky top-0 px-4 py-2 bg-[var(--color-bg-secondary)] border-b border-[var(--color-border-default)]",children:[t.jsx("span",{className:"text-xs font-semibold text-[var(--color-text-secondary)] uppercase tracking-wider",children:x(s)}),t.jsx("span",{className:"text-xs text-[var(--color-text-muted)] ml-2 font-normal normal-case tracking-normal",children:l(s)})]}),r.map(e=>t.jsxs("div",{className:`
1
+ import{a,j as t}from"./markdown-DIY6o85n.js";import{u as U,an as P,ao as L,ap as M,aq as q,A as I,l as F,X as J,ar as K,as as Q}from"./index-DC-fErwI.js";import"./vendor-D35k0Cos.js";const V=({isOpen:n,actionId:d,actionName:v,context:i,existingBindings:y,onSave:C,onCancel:g})=>{const{t:b}=U(),[c,S]=a.useState([]),[f,j]=a.useState([]);a.useEffect(()=>{n&&(S([]),j([]))},[n]),a.useEffect(()=>{if(!n)return;const x=l=>{if(l.preventDefault(),l.stopPropagation(),["Control","Shift","Alt","Meta"].includes(l.key))return;const u=L(l);if(!u)return;const k=[...c,u];S(k);const R=M(k).toLowerCase(),D=y.filter(h=>h.action===d&&h.context===i?!1:M(h.chord).toLowerCase()===R&&h.action!==null).map(h=>`${h.action} (${h.context})`);j(D)};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[n,c,y,d,i]);const o=a.useCallback(()=>{if(c.length===0)return;const x=c.map(l=>{const u=[];return l.ctrl&&u.push("ctrl"),l.alt&&u.push("alt"),l.shift&&u.push("shift"),l.super&&u.push("cmd"),u.push(l.key===" "?"space":l.key),u.join("+")});C(x.join(" "))},[c,C]),$=a.useCallback(()=>{S([]),j([])},[]);return n?t.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/50",style:{zIndex:"var(--z-modal, 100)"},onClick:g,children:t.jsxs("div",{className:"bg-[var(--color-bg-primary)] border border-[var(--color-border-default)] rounded-lg p-6 w-[440px] shadow-xl",onClick:x=>x.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-medium text-[var(--color-text-primary)] mb-1",children:b("keybindings.record.title")}),t.jsxs("p",{className:"text-sm text-[var(--color-text-secondary)] mb-4",children:[v," ",t.jsxs("span",{className:"text-[var(--color-text-muted)]",children:["(",i,")"]})]}),t.jsx("div",{className:"border border-[var(--color-border-default)] rounded-md p-4 mb-4 text-center min-h-[60px] flex items-center justify-center bg-[var(--color-bg-secondary)]",children:c.length>0?t.jsx("span",{className:"text-lg font-mono text-[var(--color-text-primary)]",children:c.map((x,l)=>t.jsxs("span",{children:[l>0&&t.jsx("span",{className:"text-[var(--color-text-muted)] mx-1",children:" "}),P(x)]},l))}):t.jsx("span",{className:"text-sm text-[var(--color-text-muted)]",children:b("keybindings.record.hint")})}),f.length>0&&t.jsxs("div",{className:"text-sm text-[var(--color-warning)] mb-4",children:[b("keybindings.record.conflict"),": ",f.join(", ")]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[c.length>0&&t.jsx("button",{className:"px-3 py-1.5 text-sm text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors",onClick:$,children:b("keybindings.action.reset")}),t.jsx("button",{className:"px-3 py-1.5 text-sm text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors",onClick:g,children:b("app.cancel")}),t.jsx("button",{className:`px-4 py-1.5 text-sm rounded-md transition-colors ${c.length===0?"bg-[var(--color-bg-secondary)] text-[var(--color-text-muted)] cursor-not-allowed":"bg-[var(--color-accent-brand)] text-[var(--color-bg-primary)] hover:opacity-90"}`,disabled:c.length===0,onClick:o,children:b("app.confirm")})]})]})}):null},W=()=>{const{t:n,tryT:d}=U(),{defaults:v,userBlocks:i,bindings:y,warnings:C,loaded:g,loadBindings:b,saveUserBindings:c,resetBindings:S}=q(),[f,j]=a.useState(""),[o,$]=a.useState(null),x=a.useCallback(s=>d(`keybindings.ctx.${s}`)??s,[d]),l=a.useCallback(s=>d(`keybindings.ctxDesc.${s}`)??"",[d]),u=a.useCallback(s=>d(`keybindings.act.${s}`)??X(s),[d]);a.useEffect(()=>{g||b()},[g,b]);const k=a.useMemo(()=>{if(!g)return[];const s=new Set;if(i)for(const e of i)for(const[p,m]of Object.entries(e.bindings))s.add(`${e.context}:${m??"null"}:${p}`);const r=new Map;for(const e of y){const p=`${e.context}:${e.action}`,m=M(e.chord),z=e.chord.map(N=>{const w=[];return N.ctrl&&w.push("ctrl"),N.alt&&w.push("alt"),N.shift&&w.push("shift"),N.super&&w.push("cmd"),w.push(N.key===" "?"space":N.key),w.join("+")}).join(" "),A=s.has(`${e.context}:${e.action}:${z}`);r.set(p,{action:e.action??"",displayName:e.action?u(e.action):"",keyDisplay:m,keyRaw:z,context:e.context,source:A?"user":"default",isUnbound:e.action===null})}return Array.from(r.values()).filter(e=>!e.isUnbound)},[g,y,i,u]),R=a.useMemo(()=>f.trim()?k.filter(s=>[s.displayName,s.action,s.keyDisplay,x(s.context)].some(e=>I(f,e).match)):k,[k,f,x]),D=a.useMemo(()=>{const s=new Map;for(const r of R){const e=s.get(r.context)||[];e.push(r),s.set(r.context,e)}return s},[R]),h=a.useCallback(async s=>{if(!o)return;const r=i?JSON.parse(JSON.stringify(i)):[];let e=r.find(p=>p.context===o.context);e||(e={context:o.context,bindings:{}},r.push(e));for(const[p,m]of Object.entries(e.bindings))m===o.action&&delete e.bindings[p];e.bindings[s]=o.action,await c({bindings:r}),$(null)},[o,i,c]),O=a.useCallback(async s=>{const r=i?JSON.parse(JSON.stringify(i)):[];let e=r.find(p=>p.context===s.context);e||(e={context:s.context,bindings:{}},r.push(e)),e.bindings[s.keyRaw]=null,await c({bindings:r})},[i,c]),B=a.useCallback(async s=>{if(!i)return;const r=JSON.parse(JSON.stringify(i)),e=r.find(m=>m.context===s.context);if(!e)return;delete e.bindings[s.keyRaw];for(const[m,E]of Object.entries(e.bindings))if(E===s.action||E===null){const z=v.find(A=>A.context===s.context);z&&z.bindings[m]===s.action&&delete e.bindings[m]}const p=r.filter(m=>Object.keys(m.bindings).length>0);await c({bindings:p})},[i,v,c]);return g?t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-2 border-b border-[var(--color-border-default)] flex items-center gap-2",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(F,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-muted)]"}),t.jsx("input",{type:"text",value:f,onChange:s=>j(s.target.value),placeholder:n("keybindings.search.placeholder"),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-[var(--color-bg-secondary)] text-[var(--color-text-primary)] border border-[var(--color-border-default)] rounded-md outline-none focus:border-[var(--color-accent-blue)]"}),f&&t.jsx("button",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]",onClick:()=>j(""),children:t.jsx(J,{size:14})})]}),t.jsx("button",{className:"p-1.5 text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] transition-colors",onClick:()=>S(),title:n("keybindings.reset.all"),children:t.jsx(K,{size:14})})]}),C.length>0&&t.jsx("div",{className:"px-4 py-2 bg-[var(--color-warning-bg,rgba(255,170,0,0.1))] border-b border-[var(--color-border-default)]",children:C.slice(0,3).map((s,r)=>t.jsxs("p",{className:"text-xs text-[var(--color-warning)]",children:[s.severity==="error"?"x":"!"," ",s.message]},r))}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[Array.from(D.entries()).map(([s,r])=>t.jsxs("div",{className:"mb-2",children:[t.jsxs("div",{className:"sticky top-0 px-4 py-2 bg-[var(--color-bg-secondary)] border-b border-[var(--color-border-default)]",children:[t.jsx("span",{className:"text-xs font-semibold text-[var(--color-text-secondary)] uppercase tracking-wider",children:x(s)}),t.jsx("span",{className:"text-xs text-[var(--color-text-muted)] ml-2 font-normal normal-case tracking-normal",children:l(s)})]}),r.map(e=>t.jsxs("div",{className:`
2
2
  group flex items-center gap-2 px-4 py-2.5 border-b border-[var(--color-border-muted)]
3
3
  hover:bg-[var(--color-bg-secondary)] transition-colors
4
4
  ${e.source==="user"?"border-l-2 border-l-[var(--color-accent-blue)]":"border-l-2 border-l-transparent"}
@@ -1,7 +1,7 @@
1
- import{a as l,j as e}from"./markdown-DIY6o85n.js";import{u as T,i as z,an as W,l as P,X as _,W as k,ao as A,j as I,o as O,k as $}from"./index-DNUXcSh8.js";import{u as F}from"./worker-store-CeRgJcBb.js";import"./vendor-D35k0Cos.js";const H=I,V=5e3,B={telemetry:{zh:"遥测日志",en:"Telemetry"},process:{zh:"进程输出",en:"Process"},debug:{zh:"调试日志",en:"Debug"},transcript:{zh:"对话记录",en:"Transcript"}};function K(){const{t:r,resolved:i}=T(),c=z(t=>t.resolved),{workers:d,fetchWorkers:x,logsContent:s,logsType:n,logsAvailableTypes:u,logsPath:p,fetchLogs:m}=F(),[a,b]=l.useState(""),[h,v]=l.useState(""),[g,L]=l.useState(!1),f=l.useRef(null);l.useEffect(()=>{x();const o=window.location.hash.match(/[?&]worker=(\d+)/);o&&b(o[1])},[x]),l.useEffect(()=>{a&&m(a)},[a,m]),l.useEffect(()=>{if(!a&&d.length>0){const o=window.location.hash.match(/[?&]worker=(\d+)/);if(o)b(o[1]);else{const j=d.find(S=>S.isCurrent);j&&b(String(j.pid))}}},[d,a]),l.useEffect(()=>{if(!g||!a)return;const t=setInterval(()=>{m(a,n||void 0)},V);return()=>clearInterval(t)},[g,a,n,m]),l.useEffect(()=>{f.current&&(f.current.scrollTop=f.current.scrollHeight)},[s]);const C=l.useCallback(()=>{a&&m(a,n||void 0)},[a,n,m]),E=l.useCallback(t=>{a&&m(a,t)},[a,m]),N=l.useMemo(()=>{if(!h.trim()||!s)return s;const t=h.toLowerCase();return s.split(`
1
+ import{a as l,j as e}from"./markdown-DIY6o85n.js";import{u as T,i as z,at as W,l as P,X as _,Z as k,au as A,j as I,o as O,k as $}from"./index-DC-fErwI.js";import{u as F}from"./worker-store-CC1BvZFl.js";import"./vendor-D35k0Cos.js";const H=I,V=5e3,B={telemetry:{zh:"遥测日志",en:"Telemetry"},process:{zh:"进程输出",en:"Process"},debug:{zh:"调试日志",en:"Debug"},transcript:{zh:"对话记录",en:"Transcript"}};function J(){const{t:r,resolved:i}=T(),c=z(t=>t.resolved),{workers:d,fetchWorkers:x,logsContent:s,logsType:n,logsAvailableTypes:u,logsPath:p,fetchLogs:m}=F(),[a,b]=l.useState(""),[h,v]=l.useState(""),[g,L]=l.useState(!1),f=l.useRef(null);l.useEffect(()=>{x();const o=window.location.hash.match(/[?&]worker=(\d+)/);o&&b(o[1])},[x]),l.useEffect(()=>{a&&m(a)},[a,m]),l.useEffect(()=>{if(!a&&d.length>0){const o=window.location.hash.match(/[?&]worker=(\d+)/);if(o)b(o[1]);else{const j=d.find(S=>S.isCurrent);j&&b(String(j.pid))}}},[d,a]),l.useEffect(()=>{if(!g||!a)return;const t=setInterval(()=>{m(a,n||void 0)},V);return()=>clearInterval(t)},[g,a,n,m]),l.useEffect(()=>{f.current&&(f.current.scrollTop=f.current.scrollHeight)},[s]);const C=l.useCallback(()=>{a&&m(a,n||void 0)},[a,n,m]),E=l.useCallback(t=>{a&&m(a,t)},[a,m]),N=l.useMemo(()=>{if(!h.trim()||!s)return s;const t=h.toLowerCase();return s.split(`
2
2
  `).filter(j=>j.toLowerCase().includes(t)).join(`
3
3
  `)},[s,h]),R=l.useMemo(()=>{if(!h.trim()||!s)return 0;const t=h.toLowerCase();return s.split(`
4
4
  `).filter(o=>o.toLowerCase().includes(t)).length},[s,h]),y=d.find(t=>String(t.pid)===a);return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-none px-4 py-3 border-b border-border-primary bg-bg-primary",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{size:18,className:"text-accent-brand"}),e.jsx("h1",{className:"text-base font-semibold text-text-primary",children:r("logs.title")})]}),e.jsxs("select",{value:a,onChange:t=>b(t.target.value),className:`px-2.5 py-1.5 text-xs rounded-lg border border-border-primary bg-bg-secondary
5
5
  text-text-primary focus:outline-none focus:border-accent-brand min-w-[180px]`,children:[e.jsx("option",{value:"",children:r("logs.selectWorker")}),d.map(t=>e.jsxs("option",{value:t.pid,children:["PID ",t.pid," — ",t.name||t.kind,t.isCurrent?` (${r("logs.current")})`:""]},t.pid))]}),u.length>0&&e.jsx("div",{className:"flex items-center gap-0.5 bg-bg-tertiary rounded-lg p-0.5",children:u.map(t=>{var o;return e.jsx("button",{onClick:()=>E(t),className:`px-2.5 py-1 text-[11px] font-medium rounded-md transition-colors ${t===n?"bg-bg-primary text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:((o=B[t])==null?void 0:o[i])||t},t)})}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",children:[e.jsx(P,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-text-tertiary"}),e.jsx("input",{type:"text",value:h,onChange:t=>v(t.target.value),placeholder:r("logs.search"),className:`pl-7 pr-7 py-1.5 text-xs rounded-lg border border-border-primary bg-bg-secondary
6
6
  text-text-primary placeholder:text-text-tertiary focus:outline-none focus:border-accent-brand w-[180px]`}),h&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"absolute right-8 top-1/2 -translate-y-1/2 text-[10px] text-text-tertiary",children:R}),e.jsx("button",{onClick:()=>v(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-tertiary hover:text-text-primary",children:e.jsx(_,{size:12})})]})]}),e.jsxs("button",{onClick:()=>L(!g),className:`flex items-center gap-1 px-2.5 py-1.5 text-xs rounded-lg border transition-colors ${g?"border-accent-brand/40 bg-accent-brand/10 text-accent-brand":"border-border-primary text-text-secondary hover:text-text-primary"}`,title:r("logs.autoRefresh"),children:[e.jsx(k,{size:12,className:g?"animate-spin":""}),r("logs.autoRefresh")]}),e.jsx("button",{onClick:C,className:"p-1.5 rounded-lg text-text-tertiary hover:text-text-primary hover:bg-bg-hover transition-colors",title:r("logs.refresh"),children:e.jsx(k,{size:14})})]}),y&&e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[11px] text-text-tertiary",children:[p&&e.jsx(A,{path:p,className:"font-mono truncate max-w-[400px]"}),y.url&&e.jsx("a",{href:y.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent-brand hover:underline",children:y.url})]})]}),e.jsx("div",{className:"flex-1 overflow-auto bg-bg-primary",children:a?!s&&u.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-text-tertiary text-sm",children:r("logs.empty")}):h?e.jsx("div",{ref:f,className:"p-4 font-mono text-xs leading-5 min-h-full",children:N?N.split(`
7
- `).map((t,o)=>e.jsx(U,{line:t,searchText:h},o)):e.jsx("span",{className:"text-text-tertiary",children:r("logs.empty")})}):e.jsx("div",{ref:f,className:"min-h-full",children:e.jsx(H,{language:"log",style:c==="dark"?O:$,showLineNumbers:!0,wrapLongLines:!0,customStyle:{margin:0,padding:"16px",border:"none",background:"transparent",fontSize:"12px",lineHeight:"1.5"},codeTagProps:{style:{background:"transparent",textShadow:"none"}},lineNumberStyle:{minWidth:"3em",paddingRight:"1em",color:"var(--color-text-tertiary)",userSelect:"none"},children:s||r("logs.empty")})}):e.jsx("div",{className:"flex items-center justify-center h-full text-text-tertiary text-sm",children:r("logs.selectWorker")})})]})}const D={ERROR:"text-red-500 dark:text-red-400",WARN:"text-amber-600 dark:text-amber-400",INFO:"text-blue-500 dark:text-blue-400",DEBUG:"text-text-tertiary"},G={ERROR:"bg-red-50/50 dark:bg-red-900/10",WARN:"bg-amber-50/50 dark:bg-amber-900/10"},M=/^\[(\w+)\]\s/;function U({line:r,searchText:i}){var p;if(!r.trim())return e.jsx("div",{className:"h-5"});const c=r.match(M),d=((p=c==null?void 0:c[1])==null?void 0:p.toUpperCase())||"",x=D[d]||"text-text-secondary",s=G[d]||"",u=i&&r.toLowerCase().includes(i.toLowerCase())?"bg-yellow-100/60 dark:bg-yellow-900/20":"";return e.jsx("div",{className:`whitespace-pre-wrap break-all px-2 py-px rounded-sm ${s} ${u}`,children:c?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:`font-semibold ${x}`,children:["[",c[1],"]"]}),e.jsx("span",{className:"text-text-secondary",children:w(r.slice(c[0].length),i)})]}):e.jsx("span",{className:"text-text-secondary",children:w(r,i)})})}function w(r,i){if(!i)return r;const c=r.toLowerCase(),d=i.toLowerCase(),x=[];let s=0,n=c.indexOf(d);for(;n!==-1;)n>s&&x.push(r.slice(s,n)),x.push(e.jsx("mark",{className:"bg-yellow-300 dark:bg-yellow-700 text-text-primary rounded-sm px-px",children:r.slice(n,n+i.length)},n)),s=n+i.length,n=c.indexOf(d,s);return s<r.length&&x.push(r.slice(s)),x.length>0?e.jsx(e.Fragment,{children:x}):r}export{K as LogsView};
7
+ `).map((t,o)=>e.jsx(U,{line:t,searchText:h},o)):e.jsx("span",{className:"text-text-tertiary",children:r("logs.empty")})}):e.jsx("div",{ref:f,className:"min-h-full",children:e.jsx(H,{language:"log",style:c==="dark"?O:$,showLineNumbers:!0,wrapLongLines:!0,customStyle:{margin:0,padding:"16px",border:"none",background:"transparent",fontSize:"12px",lineHeight:"1.5"},codeTagProps:{style:{background:"transparent",textShadow:"none"}},lineNumberStyle:{minWidth:"3em",paddingRight:"1em",color:"var(--color-text-tertiary)",userSelect:"none"},children:s||r("logs.empty")})}):e.jsx("div",{className:"flex items-center justify-center h-full text-text-tertiary text-sm",children:r("logs.selectWorker")})})]})}const D={ERROR:"text-red-500 dark:text-red-400",WARN:"text-amber-600 dark:text-amber-400",INFO:"text-blue-500 dark:text-blue-400",DEBUG:"text-text-tertiary"},G={ERROR:"bg-red-50/50 dark:bg-red-900/10",WARN:"bg-amber-50/50 dark:bg-amber-900/10"},M=/^\[(\w+)\]\s/;function U({line:r,searchText:i}){var p;if(!r.trim())return e.jsx("div",{className:"h-5"});const c=r.match(M),d=((p=c==null?void 0:c[1])==null?void 0:p.toUpperCase())||"",x=D[d]||"text-text-secondary",s=G[d]||"",u=i&&r.toLowerCase().includes(i.toLowerCase())?"bg-yellow-100/60 dark:bg-yellow-900/20":"";return e.jsx("div",{className:`whitespace-pre-wrap break-all px-2 py-px rounded-sm ${s} ${u}`,children:c?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:`font-semibold ${x}`,children:["[",c[1],"]"]}),e.jsx("span",{className:"text-text-secondary",children:w(r.slice(c[0].length),i)})]}):e.jsx("span",{className:"text-text-secondary",children:w(r,i)})})}function w(r,i){if(!i)return r;const c=r.toLowerCase(),d=i.toLowerCase(),x=[];let s=0,n=c.indexOf(d);for(;n!==-1;)n>s&&x.push(r.slice(s,n)),x.push(e.jsx("mark",{className:"bg-yellow-300 dark:bg-yellow-700 text-text-primary rounded-sm px-px",children:r.slice(n,n+i.length)},n)),s=n+i.length,n=c.indexOf(d,s);return s<r.length&&x.push(r.slice(s)),x.length>0?e.jsx(e.Fragment,{children:x}):r}export{J as LogsView};
@@ -1,12 +1,12 @@
1
- import{a as N,j as r}from"./markdown-DIY6o85n.js";import{c as v,e as M,x as $,h as C,u as c,r as T,ap as z,W as U,aq as k,ao as P,E as F,ar as h}from"./index-DNUXcSh8.js";import{u as S}from"./worker-store-CeRgJcBb.js";import{S as b}from"./server-DTGjlz_2.js";import"./vendor-D35k0Cos.js";/**
1
+ import{a as N,j as r}from"./markdown-DIY6o85n.js";import{c as v,e as M,y as $,h as C,u as c,r as T,av as z,Z as U,aw as k,au as P,E as F,ax as h}from"./index-DC-fErwI.js";import{u as S}from"./worker-store-CC1BvZFl.js";import{S as b}from"./server-C_x9ee7t.js";import"./vendor-D35k0Cos.js";/**
2
2
  * @license lucide-react v1.18.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const W=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],_=v("hard-drive",W);/**
6
+ */const _=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],w=v("hard-drive",_);/**
7
7
  * @license lucide-react v1.18.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const w=[["path",{d:"M12 12v-2",key:"fwoke6"}],["path",{d:"M12 18v-2",key:"qj6yno"}],["path",{d:"M16 12v-2",key:"heuere"}],["path",{d:"M16 18v-2",key:"s1ct0w"}],["path",{d:"M2 11h1.5",key:"15p63e"}],["path",{d:"M20 18v-2",key:"12ehxp"}],["path",{d:"M20.5 11H22",key:"khsy7a"}],["path",{d:"M4 18v-2",key:"1c3oqr"}],["path",{d:"M8 12v-2",key:"1mwtfd"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["rect",{x:"2",y:"6",width:"20",height:"10",rx:"2",key:"1qcswk"}]],u=v("memory-stick",w),E=8e3,L=M((e,t)=>({metrics:null,loading:!1,error:null,_pollTimer:null,fetchMetrics:async()=>{e({loading:!t().metrics,error:null});try{const s=await $("/api/v1/metrics",{headers:C()});if(!s.ok)throw new Error(`Failed to fetch metrics: ${s.status}`);const a=await s.json();e({metrics:a.data,loading:!1})}catch(s){e({error:s.message,loading:!1})}},startPolling:(s=E)=>{const{stopPolling:a,fetchMetrics:i}=t();a(),i();const n=setInterval(i,s);e({_pollTimer:n})},stopPolling:()=>{const{_pollTimer:s}=t();s&&(clearInterval(s),e({_pollTimer:null}))}})),B={interactive:"bg-blue-50 text-blue-700 border border-blue-200 dark:bg-blue-500/10 dark:text-blue-400 dark:border-blue-500/20",bg:"bg-purple-50 text-purple-700 border border-purple-200 dark:bg-purple-500/10 dark:text-purple-400 dark:border-purple-500/20",daemon:"bg-green-50 text-green-700 border border-green-200 dark:bg-green-500/10 dark:text-green-400 dark:border-green-500/20","daemon-worker":"bg-orange-50 text-orange-700 border border-orange-200 dark:bg-orange-500/10 dark:text-orange-400 dark:border-orange-500/20"};function K(){const{t:e}=c(),{metrics:t,loading:s,error:a,fetchMetrics:i,startPolling:n,stopPolling:d}=L(),{workers:x,fetchWorkers:m}=S();if(N.useEffect(()=>(n(8e3),m(),()=>d()),[n,d,m]),s&&!t)return r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(T,{size:"large",text:e("metrics.loading")})});if(a&&!t)return r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-text-secondary mb-4",children:a}),r.jsx("button",{onClick:i,className:"px-4 py-2 bg-accent-brand text-accent-brand-foreground rounded-lg text-sm",children:e("metrics.refresh")})]})});const y=I((t==null?void 0:t.instances)||[],x);return r.jsxs("div",{className:"flex-1 overflow-auto p-4 md:p-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(z,{size:20,className:"text-accent-brand"}),r.jsx("h1",{className:"text-lg font-semibold text-text-primary",children:e("metrics.title")})]}),r.jsxs("button",{onClick:()=>{i(),m()},className:`flex items-center gap-1.5 px-3 py-1.5 text-sm text-text-secondary
12
- hover:text-text-primary hover:bg-bg-hover rounded-lg transition-colors`,title:e("metrics.refresh"),children:[r.jsx(U,{size:14}),r.jsx("span",{children:e("metrics.refresh")})]})]}),t&&r.jsxs(r.Fragment,{children:[r.jsx(q,{metrics:t}),r.jsx(H,{workers:y})]})]})}function I(e,t){return e.map(s=>{const a=t.find(i=>i.pid===s.pid);return{...s,kind:a==null?void 0:a.kind,name:a==null?void 0:a.name,url:(a==null?void 0:a.url)||(a==null?void 0:a.endpoint),status:a==null?void 0:a.status}})}function q({metrics:e}){const{t}=c(),s=e.memTotalMib>0?e.memUsedMib/e.memTotalMib*100:0,a=e.diskTotal>0?e.diskUsed/e.diskTotal*100:0;return r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-6",children:[r.jsx(p,{icon:r.jsx(k,{size:18}),label:t("metrics.cpu"),value:`${e.cpuUsedPct.toFixed(1)}%`,subtext:`${e.cpuCount} ${t("metrics.cores")}`,percent:e.cpuUsedPct,colorClasses:o(e.cpuUsedPct)}),r.jsx(p,{icon:r.jsx(u,{size:18}),label:t("metrics.memory"),value:`${f(e.memUsedMib)} / ${f(e.memTotalMib)}`,subtext:`${s.toFixed(1)}%`,percent:s,colorClasses:o(s)}),r.jsx(p,{icon:r.jsx(_,{size:18}),label:t("metrics.disk"),value:`${g(e.diskUsed)} / ${g(e.diskTotal)}`,subtext:`${a.toFixed(1)}%`,percent:a,colorClasses:o(a)})]})}function p({icon:e,label:t,value:s,subtext:a,percent:i,colorClasses:n}){const[d,x]=n;return r.jsxs("div",{className:"bg-bg-secondary rounded-xl p-4 border border-border-primary",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx("span",{className:d,children:e}),r.jsx("span",{className:"text-sm font-medium text-text-secondary",children:t})]}),r.jsx("div",{className:"text-xl font-semibold text-text-primary mb-1",children:s}),r.jsx("div",{className:"text-xs text-text-tertiary mb-3",children:a}),r.jsx("div",{className:"h-2 bg-bg-tertiary rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${x}`,style:{width:`${Math.min(i,100)}%`}})})]})}function H({workers:e}){const{t}=c();return e.length===0?r.jsx("div",{className:"text-center py-12 text-text-tertiary",children:t("metrics.noWorkers")}):r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[r.jsx(k,{size:18,className:"text-text-secondary"}),r.jsxs("h2",{className:"text-base font-medium text-text-primary",children:["Workers (",e.length,")"]})]}),r.jsx("div",{className:"space-y-3",children:e.map(s=>r.jsx(R,{worker:s},s.id))})]})}function R({worker:e}){const{t}=c();return r.jsx("div",{className:`bg-bg-secondary rounded-xl p-4 md:p-5 border transition-colors hover:border-gray-300 dark:hover:border-gray-600 border-border-primary ${e.error?"opacity-60":""}`,children:r.jsxs("div",{className:"flex flex-col gap-4",children:[r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${e.error?"bg-red-400":"bg-green-400"}`}),e.kind&&r.jsx("span",{className:`inline-block px-2.5 py-0.5 text-xs font-medium rounded-md ${B[e.kind]||"bg-gray-100 text-gray-600"}`,children:e.kind}),r.jsx("span",{className:"text-sm font-medium text-text-primary",children:e.name||e.hostname}),e.isCurrent&&r.jsx("span",{className:"text-[10px] uppercase font-bold tracking-wider px-1.5 py-0.5 bg-accent-brand/10 text-accent-brand rounded",children:t("metrics.current")}),e.error&&r.jsx("span",{className:"text-xs text-red-400",children:e.error})]}),r.jsxs("span",{className:"text-xs text-text-tertiary font-mono bg-bg-tertiary px-2 py-0.5 rounded-md border border-border-primary/50",children:["PID ",e.pid]})]}),r.jsxs("div",{className:"flex flex-col md:flex-row md:items-start justify-between gap-4 md:gap-6",children:[r.jsxs("div",{className:"flex flex-col gap-2.5 flex-1 min-w-0",children:[r.jsx(P,{path:e.cwd,displayMode:"basename",className:"text-[13px] text-text-secondary font-mono truncate max-w-full"}),e.url&&r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(F,{size:14,className:"text-text-tertiary flex-none"}),r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-brand hover:underline truncate",children:e.url})]})]}),e.rssMib>0||e.heapUsedMib>0?r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 flex-none",style:{minWidth:"460px"},children:[r.jsxs("div",{className:"min-w-[100px]",children:[r.jsx(l,{icon:r.jsx(u,{size:14}),label:"RSS",value:`${e.rssMib.toFixed(0)} MiB`}),r.jsx("div",{className:"mt-1.5 h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full rounded-full bg-blue-500 transition-all duration-500",style:{width:`${Math.min(e.rssMib/2048*100,100)}%`}})})]}),r.jsxs("div",{className:"min-w-[140px]",children:[r.jsx(l,{icon:r.jsx(u,{size:14}),label:"Heap",value:`${e.heapUsedMib.toFixed(0)} / ${e.heapTotalMib.toFixed(0)} MiB`}),e.heapTotalMib>0&&r.jsx("div",{className:"mt-1.5 h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${o(e.heapUsedMib/e.heapTotalMib*100)[1]}`,style:{width:`${Math.min(e.heapUsedMib/e.heapTotalMib*100,100)}%`}})})]}),r.jsx("div",{className:"min-w-[80px]",children:r.jsx(l,{icon:r.jsx(h,{size:14}),label:t("metrics.uptime"),value:j(e.uptimeSeconds)})}),r.jsx("div",{className:"min-w-[60px]",children:r.jsx(l,{icon:r.jsx(b,{size:14}),label:t("metrics.version"),value:e.version||"-"})})]}):r.jsxs("div",{className:"grid grid-cols-2 gap-4 flex-none",style:{minWidth:"200px"},children:[r.jsx("div",{className:"min-w-[80px]",children:r.jsx(l,{icon:r.jsx(h,{size:14}),label:t("metrics.uptime"),value:j(e.uptimeSeconds)})}),r.jsx("div",{className:"min-w-[60px]",children:r.jsx(l,{icon:r.jsx(b,{size:14}),label:t("metrics.version"),value:e.version||"-"})})]})]})]})})}function l({icon:e,label:t,value:s}){return r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-text-tertiary",children:[e,r.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wider",children:t})]}),r.jsx("div",{className:"text-sm font-semibold text-text-primary",style:{fontVariantNumeric:"tabular-nums"},children:s})]})}function o(e){return e>=90?["text-red-500","bg-red-500"]:e>=70?["text-amber-500","bg-amber-500"]:["text-green-500","bg-green-500"]}function f(e){return e>=1024?`${(e/1024).toFixed(1)} GiB`:`${e} MiB`}function g(e){if(e===0)return"0 B";const t=e/(1024*1024*1024);return t>=1?`${t.toFixed(1)} GB`:`${(e/(1024*1024)).toFixed(0)} MB`}function j(e){if(e<60)return`${e}s`;if(e<3600)return`${Math.floor(e/60)}m ${e%60}s`;const t=Math.floor(e/3600),s=Math.floor(e%3600/60);return t>=24?`${Math.floor(t/24)}d ${t%24}h`:`${t}h ${s}m`}export{K as MetricsView};
11
+ */const W=[["path",{d:"M12 12v-2",key:"fwoke6"}],["path",{d:"M12 18v-2",key:"qj6yno"}],["path",{d:"M16 12v-2",key:"heuere"}],["path",{d:"M16 18v-2",key:"s1ct0w"}],["path",{d:"M2 11h1.5",key:"15p63e"}],["path",{d:"M20 18v-2",key:"12ehxp"}],["path",{d:"M20.5 11H22",key:"khsy7a"}],["path",{d:"M4 18v-2",key:"1c3oqr"}],["path",{d:"M8 12v-2",key:"1mwtfd"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["rect",{x:"2",y:"6",width:"20",height:"10",rx:"2",key:"1qcswk"}]],p=v("memory-stick",W),E=8e3,L=M((e,t)=>({metrics:null,loading:!1,error:null,_pollTimer:null,fetchMetrics:async()=>{e({loading:!t().metrics,error:null});try{const s=await $("/api/v1/metrics",{headers:C()});if(!s.ok)throw new Error(`Failed to fetch metrics: ${s.status}`);const a=await s.json();e({metrics:a.data,loading:!1})}catch(s){e({error:s.message,loading:!1})}},startPolling:(s=E)=>{const{stopPolling:a,fetchMetrics:i}=t();a(),i();const n=setInterval(i,s);e({_pollTimer:n})},stopPolling:()=>{const{_pollTimer:s}=t();s&&(clearInterval(s),e({_pollTimer:null}))}})),B={interactive:"bg-blue-50 text-blue-700 border border-blue-200 dark:bg-blue-500/10 dark:text-blue-400 dark:border-blue-500/20",bg:"bg-purple-50 text-purple-700 border border-purple-200 dark:bg-purple-500/10 dark:text-purple-400 dark:border-purple-500/20",daemon:"bg-green-50 text-green-700 border border-green-200 dark:bg-green-500/10 dark:text-green-400 dark:border-green-500/20","daemon-worker":"bg-orange-50 text-orange-700 border border-orange-200 dark:bg-orange-500/10 dark:text-orange-400 dark:border-orange-500/20"};function K(){const{t:e}=c(),{metrics:t,loading:s,error:a,fetchMetrics:i,startPolling:n,stopPolling:d}=L(),{workers:x,fetchWorkers:m}=S();if(N.useEffect(()=>(n(8e3),m(),()=>d()),[n,d,m]),s&&!t)return r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(T,{size:"large",text:e("metrics.loading")})});if(a&&!t)return r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-text-secondary mb-4",children:a}),r.jsx("button",{onClick:i,className:"px-4 py-2 bg-accent-brand text-accent-brand-foreground rounded-lg text-sm",children:e("metrics.refresh")})]})});const y=I((t==null?void 0:t.instances)||[],x);return r.jsxs("div",{className:"flex-1 overflow-auto p-4 md:p-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(z,{size:20,className:"text-accent-brand"}),r.jsx("h1",{className:"text-lg font-semibold text-text-primary",children:e("metrics.title")})]}),r.jsxs("button",{onClick:()=>{i(),m()},className:`flex items-center gap-1.5 px-3 py-1.5 text-sm text-text-secondary
12
+ hover:text-text-primary hover:bg-bg-hover rounded-lg transition-colors`,title:e("metrics.refresh"),children:[r.jsx(U,{size:14}),r.jsx("span",{children:e("metrics.refresh")})]})]}),t&&r.jsxs(r.Fragment,{children:[r.jsx(H,{metrics:t}),r.jsx(q,{workers:y})]})]})}function I(e,t){return e.map(s=>{const a=t.find(i=>i.pid===s.pid);return{...s,kind:a==null?void 0:a.kind,name:a==null?void 0:a.name,url:(a==null?void 0:a.url)||(a==null?void 0:a.endpoint),status:a==null?void 0:a.status}})}function H({metrics:e}){const{t}=c(),s=e.memTotalMib>0?e.memUsedMib/e.memTotalMib*100:0,a=e.diskTotal>0?e.diskUsed/e.diskTotal*100:0;return r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-6",children:[r.jsx(u,{icon:r.jsx(k,{size:18}),label:t("metrics.cpu"),value:`${e.cpuUsedPct.toFixed(1)}%`,subtext:`${e.cpuCount} ${t("metrics.cores")}`,percent:e.cpuUsedPct,colorClasses:o(e.cpuUsedPct)}),r.jsx(u,{icon:r.jsx(p,{size:18}),label:t("metrics.memory"),value:`${f(e.memUsedMib)} / ${f(e.memTotalMib)}`,subtext:`${s.toFixed(1)}%`,percent:s,colorClasses:o(s)}),r.jsx(u,{icon:r.jsx(w,{size:18}),label:t("metrics.disk"),value:`${g(e.diskUsed)} / ${g(e.diskTotal)}`,subtext:`${a.toFixed(1)}%`,percent:a,colorClasses:o(a)})]})}function u({icon:e,label:t,value:s,subtext:a,percent:i,colorClasses:n}){const[d,x]=n;return r.jsxs("div",{className:"bg-bg-secondary rounded-xl p-4 border border-border-primary",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx("span",{className:d,children:e}),r.jsx("span",{className:"text-sm font-medium text-text-secondary",children:t})]}),r.jsx("div",{className:"text-xl font-semibold text-text-primary mb-1",children:s}),r.jsx("div",{className:"text-xs text-text-tertiary mb-3",children:a}),r.jsx("div",{className:"h-2 bg-bg-tertiary rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${x}`,style:{width:`${Math.min(i,100)}%`}})})]})}function q({workers:e}){const{t}=c();return e.length===0?r.jsx("div",{className:"text-center py-12 text-text-tertiary",children:t("metrics.noWorkers")}):r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[r.jsx(k,{size:18,className:"text-text-secondary"}),r.jsxs("h2",{className:"text-base font-medium text-text-primary",children:["Workers (",e.length,")"]})]}),r.jsx("div",{className:"space-y-3",children:e.map(s=>r.jsx(R,{worker:s},s.id))})]})}function R({worker:e}){const{t}=c();return r.jsx("div",{className:`bg-bg-secondary rounded-xl p-4 md:p-5 border transition-colors hover:border-gray-300 dark:hover:border-gray-600 border-border-primary ${e.error?"opacity-60":""}`,children:r.jsxs("div",{className:"flex flex-col gap-4",children:[r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${e.error?"bg-red-400":"bg-green-400"}`}),e.kind&&r.jsx("span",{className:`inline-block px-2.5 py-0.5 text-xs font-medium rounded-md ${B[e.kind]||"bg-gray-100 text-gray-600"}`,children:e.kind}),r.jsx("span",{className:"text-sm font-medium text-text-primary",children:e.name||e.hostname}),e.isCurrent&&r.jsx("span",{className:"text-[10px] uppercase font-bold tracking-wider px-1.5 py-0.5 bg-accent-brand/10 text-accent-brand rounded",children:t("metrics.current")}),e.error&&r.jsx("span",{className:"text-xs text-red-400",children:e.error})]}),r.jsxs("span",{className:"text-xs text-text-tertiary font-mono bg-bg-tertiary px-2 py-0.5 rounded-md border border-border-primary/50",children:["PID ",e.pid]})]}),r.jsxs("div",{className:"flex flex-col md:flex-row md:items-start justify-between gap-4 md:gap-6",children:[r.jsxs("div",{className:"flex flex-col gap-2.5 flex-1 min-w-0",children:[r.jsx(P,{path:e.cwd,displayMode:"basename",className:"text-[13px] text-text-secondary font-mono truncate max-w-full"}),e.url&&r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(F,{size:14,className:"text-text-tertiary flex-none"}),r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-brand hover:underline truncate",children:e.url})]})]}),e.rssMib>0||e.heapUsedMib>0?r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 flex-none",style:{minWidth:"460px"},children:[r.jsxs("div",{className:"min-w-[100px]",children:[r.jsx(l,{icon:r.jsx(p,{size:14}),label:"RSS",value:`${e.rssMib.toFixed(0)} MiB`}),r.jsx("div",{className:"mt-1.5 h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full rounded-full bg-blue-500 transition-all duration-500",style:{width:`${Math.min(e.rssMib/2048*100,100)}%`}})})]}),r.jsxs("div",{className:"min-w-[140px]",children:[r.jsx(l,{icon:r.jsx(p,{size:14}),label:"Heap",value:`${e.heapUsedMib.toFixed(0)} / ${e.heapTotalMib.toFixed(0)} MiB`}),e.heapTotalMib>0&&r.jsx("div",{className:"mt-1.5 h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${o(e.heapUsedMib/e.heapTotalMib*100)[1]}`,style:{width:`${Math.min(e.heapUsedMib/e.heapTotalMib*100,100)}%`}})})]}),r.jsx("div",{className:"min-w-[80px]",children:r.jsx(l,{icon:r.jsx(h,{size:14}),label:t("metrics.uptime"),value:j(e.uptimeSeconds)})}),r.jsx("div",{className:"min-w-[60px]",children:r.jsx(l,{icon:r.jsx(b,{size:14}),label:t("metrics.version"),value:e.version||"-"})})]}):r.jsxs("div",{className:"grid grid-cols-2 gap-4 flex-none",style:{minWidth:"200px"},children:[r.jsx("div",{className:"min-w-[80px]",children:r.jsx(l,{icon:r.jsx(h,{size:14}),label:t("metrics.uptime"),value:j(e.uptimeSeconds)})}),r.jsx("div",{className:"min-w-[60px]",children:r.jsx(l,{icon:r.jsx(b,{size:14}),label:t("metrics.version"),value:e.version||"-"})})]})]})]})})}function l({icon:e,label:t,value:s}){return r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-text-tertiary",children:[e,r.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wider",children:t})]}),r.jsx("div",{className:"text-sm font-semibold text-text-primary",style:{fontVariantNumeric:"tabular-nums"},children:s})]})}function o(e){return e>=90?["text-red-500","bg-red-500"]:e>=70?["text-amber-500","bg-amber-500"]:["text-green-500","bg-green-500"]}function f(e){return e>=1024?`${(e/1024).toFixed(1)} GiB`:`${e} MiB`}function g(e){if(e===0)return"0 B";const t=e/(1024*1024*1024);return t>=1?`${t.toFixed(1)} GB`:`${(e/(1024*1024)).toFixed(0)} MB`}function j(e){if(e<60)return`${e}s`;if(e<3600)return`${Math.floor(e/60)}m ${e%60}s`;const t=Math.floor(e/3600),s=Math.floor(e%3600/60);return t>=24?`${Math.floor(t/24)}d ${t%24}h`:`${t}h ${s}m`}export{K as MetricsView};