@axhub/genie 0.2.3 → 0.2.4

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 (59) hide show
  1. package/dist/assets/App-BxazfNJn.js +484 -0
  2. package/dist/assets/{ReviewApp-DOAHmxVe.js → ReviewApp-CsqTAlGU.js} +1 -1
  3. package/dist/assets/{_basePickBy-CAs6HGVw.js → _basePickBy-CFRQvihx.js} +1 -1
  4. package/dist/assets/{_baseUniq-qvm36g_v.js → _baseUniq-Dhh8nCvs.js} +1 -1
  5. package/dist/assets/{arc-60yKSsVt.js → arc-DQ0v3dU4.js} +1 -1
  6. package/dist/assets/{architectureDiagram-2XIMDMQ5-C5Ik86xM.js → architectureDiagram-2XIMDMQ5-DmUHdvQH.js} +1 -1
  7. package/dist/assets/{blockDiagram-WCTKOSBZ-CGqfB5z7.js → blockDiagram-WCTKOSBZ-Bbxhj5KC.js} +1 -1
  8. package/dist/assets/{c4Diagram-IC4MRINW-C02h4qfL.js → c4Diagram-IC4MRINW-BOivDlQU.js} +1 -1
  9. package/dist/assets/channel-Cj8xVD0X.js +1 -0
  10. package/dist/assets/{chunk-4BX2VUAB-BVVwu3tU.js → chunk-4BX2VUAB-DlvtrM0q.js} +1 -1
  11. package/dist/assets/{chunk-55IACEB6-Dyehrd1R.js → chunk-55IACEB6-DJUSHyTa.js} +1 -1
  12. package/dist/assets/{chunk-FMBD7UC4-ByEz0wOl.js → chunk-FMBD7UC4-C6Ch-htf.js} +1 -1
  13. package/dist/assets/{chunk-JSJVCQXG-BXHZvm_e.js → chunk-JSJVCQXG-DzQIht58.js} +1 -1
  14. package/dist/assets/{chunk-KX2RTZJC-DJPATr22.js → chunk-KX2RTZJC-C05jARMH.js} +1 -1
  15. package/dist/assets/{chunk-NQ4KR5QH-RgZbucc4.js → chunk-NQ4KR5QH-Ci-n7jfu.js} +1 -1
  16. package/dist/assets/{chunk-QZHKN3VN-DMIXCLGh.js → chunk-QZHKN3VN-jxti9HTX.js} +1 -1
  17. package/dist/assets/{chunk-WL4C6EOR-Bg4bzqqP.js → chunk-WL4C6EOR-C559Mk71.js} +1 -1
  18. package/dist/assets/classDiagram-VBA2DB6C-CI2zklxw.js +1 -0
  19. package/dist/assets/classDiagram-v2-RAHNMMFH-CI2zklxw.js +1 -0
  20. package/dist/assets/clone-BEVqubrI.js +1 -0
  21. package/dist/assets/{cose-bilkent-S5V4N54A-BZeDiX7Y.js → cose-bilkent-S5V4N54A-DNO9ncXL.js} +1 -1
  22. package/dist/assets/{dagre-KLK3FWXG-BrwI_1JI.js → dagre-KLK3FWXG-DJ3dNSYk.js} +1 -1
  23. package/dist/assets/{diagram-E7M64L7V-CxAlKNFG.js → diagram-E7M64L7V-Ba_LGLun.js} +1 -1
  24. package/dist/assets/{diagram-IFDJBPK2-VClYIYo3.js → diagram-IFDJBPK2-Da6K4aP-.js} +1 -1
  25. package/dist/assets/{diagram-P4PSJMXO-CYRL57cP.js → diagram-P4PSJMXO-vZZKB92A.js} +1 -1
  26. package/dist/assets/{erDiagram-INFDFZHY-ZySJDqNG.js → erDiagram-INFDFZHY-Csb8dFdP.js} +1 -1
  27. package/dist/assets/{flowDiagram-PKNHOUZH-Ct9-q2zS.js → flowDiagram-PKNHOUZH-DUV13pHi.js} +1 -1
  28. package/dist/assets/{ganttDiagram-A5KZAMGK-Qn4VUvVR.js → ganttDiagram-A5KZAMGK-B5Kv9Wfz.js} +1 -1
  29. package/dist/assets/{gitGraphDiagram-K3NZZRJ6-CaveIlg3.js → gitGraphDiagram-K3NZZRJ6-BZ5gW69I.js} +1 -1
  30. package/dist/assets/{graph-B1tvcjpq.js → graph-BbvHswRd.js} +1 -1
  31. package/dist/assets/{highlighted-body-TPN3WLV5-Cx4aCKGT.js → highlighted-body-TPN3WLV5-DZJajMGm.js} +1 -1
  32. package/dist/assets/{index-Q-dfaLIv.js → index-BiErUGrv.js} +2 -2
  33. package/dist/assets/{infoDiagram-LFFYTUFH-FNMZEktA.js → infoDiagram-LFFYTUFH-8auUIPKW.js} +1 -1
  34. package/dist/assets/{ishikawaDiagram-PHBUUO56-D9db2Pov.js → ishikawaDiagram-PHBUUO56-JmsNlo2I.js} +1 -1
  35. package/dist/assets/{journeyDiagram-4ABVD52K-BzYKMYOM.js → journeyDiagram-4ABVD52K-Cuudv7Vv.js} +1 -1
  36. package/dist/assets/{kanban-definition-K7BYSVSG-qC9Xmf0j.js → kanban-definition-K7BYSVSG-Bappd2YO.js} +1 -1
  37. package/dist/assets/{layout-dbzqH_4Q.js → layout-BmbfFZKy.js} +1 -1
  38. package/dist/assets/{linear-HOAktq-3.js → linear-WZnF-PT6.js} +1 -1
  39. package/dist/assets/{mermaid-O7DHMXV3-CazKksAH.js → mermaid-O7DHMXV3-D-2fQRvw.js} +5 -5
  40. package/dist/assets/{mindmap-definition-YRQLILUH-DlfKip6Z.js → mindmap-definition-YRQLILUH-BQHnzzud.js} +1 -1
  41. package/dist/assets/{pieDiagram-SKSYHLDU-BYv9DU8d.js → pieDiagram-SKSYHLDU-uxjlAy1t.js} +1 -1
  42. package/dist/assets/{quadrantDiagram-337W2JSQ-l21TFCGi.js → quadrantDiagram-337W2JSQ-DpwZU-f_.js} +1 -1
  43. package/dist/assets/{requirementDiagram-Z7DCOOCP-DwM1YiVc.js → requirementDiagram-Z7DCOOCP-C_9ClOWm.js} +1 -1
  44. package/dist/assets/{sankeyDiagram-WA2Y5GQK-DaSSXYkb.js → sankeyDiagram-WA2Y5GQK-2-FHHM-R.js} +1 -1
  45. package/dist/assets/{sequenceDiagram-2WXFIKYE-BPBhAefs.js → sequenceDiagram-2WXFIKYE-egns-0XI.js} +1 -1
  46. package/dist/assets/{stateDiagram-RAJIS63D-Cs4xILlc.js → stateDiagram-RAJIS63D-DoW8U53H.js} +1 -1
  47. package/dist/assets/stateDiagram-v2-FVOUBMTO-BoFZZ4Ds.js +1 -0
  48. package/dist/assets/{timeline-definition-YZTLITO2-BPnQPJ2R.js → timeline-definition-YZTLITO2-chPa8ppH.js} +1 -1
  49. package/dist/assets/{treemap-KZPCXAKY-BRWkr5mn.js → treemap-KZPCXAKY-ajdAP-72.js} +1 -1
  50. package/dist/assets/{vennDiagram-LZ73GAT5-DioBg_XD.js → vennDiagram-LZ73GAT5-C9If0AT0.js} +1 -1
  51. package/dist/assets/{xychartDiagram-JWTSCODW-Bh2R2Uzh.js → xychartDiagram-JWTSCODW-DD42U6Or.js} +1 -1
  52. package/dist/index.html +1 -1
  53. package/package.json +1 -1
  54. package/dist/assets/App-Ddoy7BIl.js +0 -484
  55. package/dist/assets/channel-B3JUshOm.js +0 -1
  56. package/dist/assets/classDiagram-VBA2DB6C-DZEYhtwP.js +0 -1
  57. package/dist/assets/classDiagram-v2-RAHNMMFH-DZEYhtwP.js +0 -1
  58. package/dist/assets/clone-B2sPtF_O.js +0 -1
  59. package/dist/assets/stateDiagram-v2-FVOUBMTO-DeUj7MLk.js +0 -1
@@ -1,484 +0,0 @@
1
- import{j as r,S as Yn,F as Qs,T as Ec,P as Ic,E as mr,V as Zs,a as Ya,g as Jp,D as Rr,R as $s,G as Xa,W as Qa,l as Ac,h as ba,b as Tc,C as Yp,c as Xp,d as Qp,e as Sn,f as Zp,i as em,u as tm,k as al,s as rm,m as nm,n as sm,o as om,p as am,q as im,r as lm,t as cm,v as dm,w as um,x as pm,y as mm}from"./vendor-codemirror-Dz7_EqNA.js";import{a as l,c as fm,R as Mn,d as Xo,g as _c,B as hm,e as gm,f as Qo,u as xm,h as vm,i as ym}from"./vendor-react-Cpt6D04s.js";import{bJ as Ee,bK as er,bL as wa,bM as an,bN as Mc,bO as Bs,bP as Pe,bQ as eo,bR as Za,bS as vr,bT as Dc,bU as bm,bV as wm,bW as km,bX as jm,bY as Sm,bZ as Nm,b_ as Cm,b$ as Em,c0 as Im,c1 as Am,c2 as Tm,c3 as ct,c4 as ei,c5 as $t,c6 as yr,c7 as _m,c8 as De,c9 as qn,ca as wn,cb as Tr,cc as ln,cd as ti,ce as Rc,cf as Mm,cg as Dm,ch as Rm,ci as Pm,cj as Lm,ck as il,cl as ll,cm as cl,cn as Zo,co as Om,cp as Fm,cq as $m,cr as Bm,cs as zm,ct as Um,cu as Wm,cv as Hm,cw as qm,cx as Vm,cy as Pc,cz as ri,cA as Gm,cB as Km,I as Jm,T as Ym,U as Xm}from"./mermaid-O7DHMXV3-CazKksAH.js";import{r as Qm,a as Zm,b as ef}from"./vendor-xterm-DfaPXD3y.js";import{l as dl,i as tf}from"./index-Q-dfaLIv.js";/**
2
- * @license lucide-react v0.515.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const rf=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],nf=Ee("arrow-down",rf);/**
7
- * @license lucide-react v0.515.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const sf=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Lc=Ee("chevron-left",sf);/**
12
- * @license lucide-react v0.515.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const of=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],ka=Ee("download",of);/**
17
- * @license lucide-react v0.515.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const af=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],bs=Ee("ellipsis",af);/**
22
- * @license lucide-react v0.515.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const lf=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ja=Ee("external-link",lf);/**
27
- * @license lucide-react v0.515.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const cf=[["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"}]],Oc=Ee("eye",cf);/**
32
- * @license lucide-react v0.515.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const df=[["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"}]],uf=Ee("eye-off",df);/**
37
- * @license lucide-react v0.515.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const pf=[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]],mf=Ee("file-pen-line",pf);/**
42
- * @license lucide-react v0.515.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const ff=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]],hf=Ee("file-plus-2",ff);/**
47
- * @license lucide-react v0.515.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const gf=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]],xf=Ee("file-search",gf);/**
52
- * @license lucide-react v0.515.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */const vf=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ni=Ee("file-text",vf);/**
57
- * @license lucide-react v0.515.0 - ISC
58
- *
59
- * This source code is licensed under the ISC license.
60
- * See the LICENSE file in the root directory of this source tree.
61
- */const yf=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],nn=Ee("folder-open",yf);/**
62
- * @license lucide-react v0.515.0 - ISC
63
- *
64
- * This source code is licensed under the ISC license.
65
- * See the LICENSE file in the root directory of this source tree.
66
- */const bf=[["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"}]],rn=Ee("folder-plus",bf);/**
67
- * @license lucide-react v0.515.0 - ISC
68
- *
69
- * This source code is licensed under the ISC license.
70
- * See the LICENSE file in the root directory of this source tree.
71
- */const wf=[["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"}]],ea=Ee("folder",wf);/**
72
- * @license lucide-react v0.515.0 - ISC
73
- *
74
- * This source code is licensed under the ISC license.
75
- * See the LICENSE file in the root directory of this source tree.
76
- */const kf=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],ta=Ee("git-branch",kf);/**
77
- * @license lucide-react v0.515.0 - ISC
78
- *
79
- * This source code is licensed under the ISC license.
80
- * See the LICENSE file in the root directory of this source tree.
81
- */const jf=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],ra=Ee("git-commit-horizontal",jf);/**
82
- * @license lucide-react v0.515.0 - ISC
83
- *
84
- * This source code is licensed under the ISC license.
85
- * See the LICENSE file in the root directory of this source tree.
86
- */const Sf=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ul=Ee("globe",Sf);/**
87
- * @license lucide-react v0.515.0 - ISC
88
- *
89
- * This source code is licensed under the ISC license.
90
- * See the LICENSE file in the root directory of this source tree.
91
- */const Nf=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Cf=Ee("grip-vertical",Nf);/**
92
- * @license lucide-react v0.515.0 - ISC
93
- *
94
- * This source code is licensed under the ISC license.
95
- * See the LICENSE file in the root directory of this source tree.
96
- */const Ef=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],pl=Ee("history",Ef);/**
97
- * @license lucide-react v0.515.0 - ISC
98
- *
99
- * This source code is licensed under the ISC license.
100
- * See the LICENSE file in the root directory of this source tree.
101
- */const If=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Af=Ee("info",If);/**
102
- * @license lucide-react v0.515.0 - ISC
103
- *
104
- * This source code is licensed under the ISC license.
105
- * See the LICENSE file in the root directory of this source tree.
106
- */const Tf=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Fc=Ee("key",Tf);/**
107
- * @license lucide-react v0.515.0 - ISC
108
- *
109
- * This source code is licensed under the ISC license.
110
- * See the LICENSE file in the root directory of this source tree.
111
- */const _f=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],$c=Ee("languages",_f);/**
112
- * @license lucide-react v0.515.0 - ISC
113
- *
114
- * This source code is licensed under the ISC license.
115
- * See the LICENSE file in the root directory of this source tree.
116
- */const Mf=[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],ml=Ee("list-todo",Mf);/**
117
- * @license lucide-react v0.515.0 - ISC
118
- *
119
- * This source code is licensed under the ISC license.
120
- * See the LICENSE file in the root directory of this source tree.
121
- */const Df=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Bc=Ee("maximize-2",Df);/**
122
- * @license lucide-react v0.515.0 - ISC
123
- *
124
- * This source code is licensed under the ISC license.
125
- * See the LICENSE file in the root directory of this source tree.
126
- */const Rf=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]],Pf=Ee("message-square-plus",Rf);/**
127
- * @license lucide-react v0.515.0 - ISC
128
- *
129
- * This source code is licensed under the ISC license.
130
- * See the LICENSE file in the root directory of this source tree.
131
- */const Lf=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]],Vn=Ee("message-square",Lf);/**
132
- * @license lucide-react v0.515.0 - ISC
133
- *
134
- * This source code is licensed under the ISC license.
135
- * See the LICENSE file in the root directory of this source tree.
136
- */const Of=[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]],Fs=Ee("mic",Of);/**
137
- * @license lucide-react v0.515.0 - ISC
138
- *
139
- * This source code is licensed under the ISC license.
140
- * See the LICENSE file in the root directory of this source tree.
141
- */const Ff=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],$f=Ee("minimize-2",Ff);/**
142
- * @license lucide-react v0.515.0 - ISC
143
- *
144
- * This source code is licensed under the ISC license.
145
- * See the LICENSE file in the root directory of this source tree.
146
- */const Bf=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],Sa=Ee("moon",Bf);/**
147
- * @license lucide-react v0.515.0 - ISC
148
- *
149
- * This source code is licensed under the ISC license.
150
- * See the LICENSE file in the root directory of this source tree.
151
- */const zf=[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]],fl=Ee("pen-line",zf);/**
152
- * @license lucide-react v0.515.0 - ISC
153
- *
154
- * This source code is licensed under the ISC license.
155
- * See the LICENSE file in the root directory of this source tree.
156
- */const Uf=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],hl=Ee("pen",Uf);/**
157
- * @license lucide-react v0.515.0 - ISC
158
- *
159
- * This source code is licensed under the ISC license.
160
- * See the LICENSE file in the root directory of this source tree.
161
- */const Wf=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Nn=Ee("plus",Wf);/**
162
- * @license lucide-react v0.515.0 - ISC
163
- *
164
- * This source code is licensed under the ISC license.
165
- * See the LICENSE file in the root directory of this source tree.
166
- */const Hf=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Ar=Ee("refresh-cw",Hf);/**
167
- * @license lucide-react v0.515.0 - ISC
168
- *
169
- * This source code is licensed under the ISC license.
170
- * See the LICENSE file in the root directory of this source tree.
171
- */const qf=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Vf=Ee("save",qf);/**
172
- * @license lucide-react v0.515.0 - ISC
173
- *
174
- * This source code is licensed under the ISC license.
175
- * See the LICENSE file in the root directory of this source tree.
176
- */const Gf=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Na=Ee("search",Gf);/**
177
- * @license lucide-react v0.515.0 - ISC
178
- *
179
- * This source code is licensed under the ISC license.
180
- * See the LICENSE file in the root directory of this source tree.
181
- */const Kf=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Jf=Ee("server",Kf);/**
182
- * @license lucide-react v0.515.0 - ISC
183
- *
184
- * This source code is licensed under the ISC license.
185
- * See the LICENSE file in the root directory of this source tree.
186
- */const Yf=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],zc=Ee("settings",Yf);/**
187
- * @license lucide-react v0.515.0 - ISC
188
- *
189
- * This source code is licensed under the ISC license.
190
- * See the LICENSE file in the root directory of this source tree.
191
- */const Xf=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Qf=Ee("settings-2",Xf);/**
192
- * @license lucide-react v0.515.0 - ISC
193
- *
194
- * This source code is licensed under the ISC license.
195
- * See the LICENSE file in the root directory of this source tree.
196
- */const Zf=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],eh=Ee("square-terminal",Zf);/**
197
- * @license lucide-react v0.515.0 - ISC
198
- *
199
- * This source code is licensed under the ISC license.
200
- * See the LICENSE file in the root directory of this source tree.
201
- */const th=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],gl=Ee("star",th);/**
202
- * @license lucide-react v0.515.0 - ISC
203
- *
204
- * This source code is licensed under the ISC license.
205
- * See the LICENSE file in the root directory of this source tree.
206
- */const rh=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Ca=Ee("sun",rh);/**
207
- * @license lucide-react v0.515.0 - ISC
208
- *
209
- * This source code is licensed under the ISC license.
210
- * See the LICENSE file in the root directory of this source tree.
211
- */const nh=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],pr=Ee("trash-2",nh);/**
212
- * @license lucide-react v0.515.0 - ISC
213
- *
214
- * This source code is licensed under the ISC license.
215
- * See the LICENSE file in the root directory of this source tree.
216
- */const sh=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ea=Ee("triangle-alert",sh);/**
217
- * @license lucide-react v0.515.0 - ISC
218
- *
219
- * This source code is licensed under the ISC license.
220
- * See the LICENSE file in the root directory of this source tree.
221
- */const oh=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],ws=Ee("upload",oh);/**
222
- * @license lucide-react v0.515.0 - ISC
223
- *
224
- * This source code is licensed under the ISC license.
225
- * See the LICENSE file in the root directory of this source tree.
226
- */const ah=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],ih=Ee("wrench",ah);/**
227
- * @license lucide-react v0.515.0 - ISC
228
- *
229
- * This source code is licensed under the ISC license.
230
- * See the LICENSE file in the root directory of this source tree.
231
- */const lh=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ar=Ee("x",lh);function ch(e,t){return l.useReducer((n,s)=>t[n][s]??n,e)}var kr=e=>{const{present:t,children:n}=e,s=dh(t),o=typeof n=="function"?n({present:s.isPresent}):l.Children.only(n),a=er(s.ref,uh(o));return typeof n=="function"||s.isPresent?l.cloneElement(o,{ref:a}):null};kr.displayName="Presence";function dh(e){const[t,n]=l.useState(),s=l.useRef(null),o=l.useRef(e),a=l.useRef("none"),i=e?"mounted":"unmounted",[c,d]=ch(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const u=ks(s.current);a.current=c==="mounted"?u:"none"},[c]),wa(()=>{const u=s.current,p=o.current;if(p!==e){const h=a.current,g=ks(u);e?d("MOUNT"):g==="none"||u?.display==="none"?d("UNMOUNT"):d(p&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),wa(()=>{if(t){let u;const p=t.ownerDocument.defaultView??window,m=g=>{const j=ks(s.current).includes(CSS.escape(g.animationName));if(g.target===t&&j&&(d("ANIMATION_END"),!o.current)){const k=t.style.animationFillMode;t.style.animationFillMode="forwards",u=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=k)})}},h=g=>{g.target===t&&(a.current=ks(s.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{p.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:l.useCallback(u=>{s.current=u?getComputedStyle(u):null,n(u)},[])}}function ks(e){return e?.animationName||"none"}function uh(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function ph(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,j=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(j.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,mh(o,...t)]}function mh(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Uc(e){const t=fh(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(gh);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function fh(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=vh(o),c=xh(a,o.props);return o.type!==l.Fragment&&(c.ref=s?an(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var hh=Symbol("radix.slottable");function gh(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===hh}function xh(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function vh(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var yh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Xn=yh.reduce((e,t)=>{const n=Uc(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function bh(e,t){e&&fm.flushSync(()=>e.dispatchEvent(t))}function wh(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,j=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(j.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,kh(o,...t)]}function kh(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function jh(e){const t=Sh(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(Ch);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Sh(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=Ih(o),c=Eh(a,o.props);return o.type!==l.Fragment&&(c.ref=s?an(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Nh=Symbol("radix.slottable");function Ch(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Nh}function Eh(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Ih(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Ah=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Wc=Ah.reduce((e,t)=>{const n=jh(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),na="rovingFocusGroup.onEntryFocus",Th={bubbles:!1,cancelable:!0},Qn="RovingFocusGroup",[Ia,Hc,_h]=Mc(Qn),[Mh,to]=wh(Qn,[_h]),[Dh,Rh]=Mh(Qn),qc=l.forwardRef((e,t)=>r.jsx(Ia.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Ia.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Ph,{...e,ref:t})})}));qc.displayName=Qn;var Ph=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...m}=e,h=l.useRef(null),g=er(t,h),x=eo(a),[j,k]=Za({prop:i,defaultProp:c??null,onChange:d,caller:Qn}),[A,T]=l.useState(!1),w=vr(u),D=Hc(n),N=l.useRef(!1),[b,L]=l.useState(0);return l.useEffect(()=>{const q=h.current;if(q)return q.addEventListener(na,w),()=>q.removeEventListener(na,w)},[w]),r.jsx(Dh,{scope:n,orientation:s,dir:x,loop:o,currentTabStopId:j,onItemFocus:l.useCallback(q=>k(q),[k]),onItemShiftTab:l.useCallback(()=>T(!0),[]),onFocusableItemAdd:l.useCallback(()=>L(q=>q+1),[]),onFocusableItemRemove:l.useCallback(()=>L(q=>q-1),[]),children:r.jsx(Wc.div,{tabIndex:A||b===0?-1:0,"data-orientation":s,...m,ref:g,style:{outline:"none",...e.style},onMouseDown:Pe(e.onMouseDown,()=>{N.current=!0}),onFocus:Pe(e.onFocus,q=>{const P=!N.current;if(q.target===q.currentTarget&&P&&!A){const Y=new CustomEvent(na,Th);if(q.currentTarget.dispatchEvent(Y),!Y.defaultPrevented){const ge=D().filter(Ie=>Ie.focusable),le=ge.find(Ie=>Ie.active),M=ge.find(Ie=>Ie.id===j),xe=[le,M,...ge].filter(Boolean).map(Ie=>Ie.ref.current);Kc(xe,p)}}N.current=!1}),onBlur:Pe(e.onBlur,()=>T(!1))})})}),Vc="RovingFocusGroupItem",Gc=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:i,...c}=e,d=Bs(),u=a||d,p=Rh(Vc,n),m=p.currentTabStopId===u,h=Hc(n),{onFocusableItemAdd:g,onFocusableItemRemove:x,currentTabStopId:j}=p;return l.useEffect(()=>{if(s)return g(),()=>x()},[s,g,x]),r.jsx(Ia.ItemSlot,{scope:n,id:u,focusable:s,active:o,children:r.jsx(Wc.span,{tabIndex:m?0:-1,"data-orientation":p.orientation,...c,ref:t,onMouseDown:Pe(e.onMouseDown,k=>{s?p.onItemFocus(u):k.preventDefault()}),onFocus:Pe(e.onFocus,()=>p.onItemFocus(u)),onKeyDown:Pe(e.onKeyDown,k=>{if(k.key==="Tab"&&k.shiftKey){p.onItemShiftTab();return}if(k.target!==k.currentTarget)return;const A=Fh(k,p.orientation,p.dir);if(A!==void 0){if(k.metaKey||k.ctrlKey||k.altKey||k.shiftKey)return;k.preventDefault();let w=h().filter(D=>D.focusable).map(D=>D.ref.current);if(A==="last")w.reverse();else if(A==="prev"||A==="next"){A==="prev"&&w.reverse();const D=w.indexOf(k.currentTarget);w=p.loop?$h(w,D+1):w.slice(D+1)}setTimeout(()=>Kc(w))}}),children:typeof i=="function"?i({isCurrentTabStop:m,hasTabStop:j!=null}):i})})});Gc.displayName=Vc;var Lh={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Oh(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Fh(e,t,n){const s=Oh(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Lh[s]}function Kc(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function $h(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Jc=qc,Yc=Gc,Aa=["Enter"," "],Bh=["ArrowDown","PageUp","Home"],Xc=["ArrowUp","PageDown","End"],zh=[...Bh,...Xc],Uh={ltr:[...Aa,"ArrowRight"],rtl:[...Aa,"ArrowLeft"]},Wh={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Zn="Menu",[Gn,Hh,qh]=Mc(Zn),[cn,Qc]=ph(Zn,[qh,Dc,to]),ro=Dc(),Zc=to(),[Vh,dn]=cn(Zn),[Gh,es]=cn(Zn),ed=e=>{const{__scopeMenu:t,open:n=!1,children:s,dir:o,onOpenChange:a,modal:i=!0}=e,c=ro(t),[d,u]=l.useState(null),p=l.useRef(!1),m=vr(a),h=eo(o);return l.useEffect(()=>{const g=()=>{p.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>p.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),r.jsx(bm,{...c,children:r.jsx(Vh,{scope:t,open:n,onOpenChange:m,content:d,onContentChange:u,children:r.jsx(Gh,{scope:t,onClose:l.useCallback(()=>m(!1),[m]),isUsingKeyboardRef:p,dir:h,modal:i,children:s})})})};ed.displayName=Zn;var Kh="MenuAnchor",si=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,o=ro(n);return r.jsx(wm,{...o,...s,ref:t})});si.displayName=Kh;var oi="MenuPortal",[Jh,td]=cn(oi,{forceMount:void 0}),rd=e=>{const{__scopeMenu:t,forceMount:n,children:s,container:o}=e,a=dn(oi,t);return r.jsx(Jh,{scope:t,forceMount:n,children:r.jsx(kr,{present:n||a.open,children:r.jsx(km,{asChild:!0,container:o,children:s})})})};rd.displayName=oi;var ir="MenuContent",[Yh,ai]=cn(ir),nd=l.forwardRef((e,t)=>{const n=td(ir,e.__scopeMenu),{forceMount:s=n.forceMount,...o}=e,a=dn(ir,e.__scopeMenu),i=es(ir,e.__scopeMenu);return r.jsx(Gn.Provider,{scope:e.__scopeMenu,children:r.jsx(kr,{present:s||a.open,children:r.jsx(Gn.Slot,{scope:e.__scopeMenu,children:i.modal?r.jsx(Xh,{...o,ref:t}):r.jsx(Qh,{...o,ref:t})})})})}),Xh=l.forwardRef((e,t)=>{const n=dn(ir,e.__scopeMenu),s=l.useRef(null),o=er(t,s);return l.useEffect(()=>{const a=s.current;if(a)return jm(a)},[]),r.jsx(ii,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Qh=l.forwardRef((e,t)=>{const n=dn(ir,e.__scopeMenu);return r.jsx(ii,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Zh=Uc("MenuContent.ScrollLock"),ii=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:s=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:h,onDismiss:g,disableOutsideScroll:x,...j}=e,k=dn(ir,n),A=es(ir,n),T=ro(n),w=Zc(n),D=Hh(n),[N,b]=l.useState(null),L=l.useRef(null),q=er(t,L,k.onContentChange),P=l.useRef(0),Y=l.useRef(""),ge=l.useRef(0),le=l.useRef(null),M=l.useRef("right"),V=l.useRef(0),xe=x?Nm:l.Fragment,Ie=x?{as:Zh,allowPinchZoom:!0}:void 0,qe=U=>{const fe=Y.current+U,O=D().filter(R=>!R.disabled),S=document.activeElement,B=O.find(R=>R.ref.current===S)?.textValue,Z=O.map(R=>R.textValue),ke=ug(Z,fe,B),ve=O.find(R=>R.textValue===ke)?.ref.current;(function R(re){Y.current=re,window.clearTimeout(P.current),re!==""&&(P.current=window.setTimeout(()=>R(""),1e3))})(fe),ve&&setTimeout(()=>ve.focus())};l.useEffect(()=>()=>window.clearTimeout(P.current),[]),Sm();const Se=l.useCallback(U=>M.current===le.current?.side&&mg(U,le.current?.area),[]);return r.jsx(Yh,{scope:n,searchRef:Y,onItemEnter:l.useCallback(U=>{Se(U)&&U.preventDefault()},[Se]),onItemLeave:l.useCallback(U=>{Se(U)||(L.current?.focus(),b(null))},[Se]),onTriggerLeave:l.useCallback(U=>{Se(U)&&U.preventDefault()},[Se]),pointerGraceTimerRef:ge,onPointerGraceIntentChange:l.useCallback(U=>{le.current=U},[]),children:r.jsx(xe,{...Ie,children:r.jsx(Cm,{asChild:!0,trapped:o,onMountAutoFocus:Pe(a,U=>{U.preventDefault(),L.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:r.jsx(Em,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:h,onDismiss:g,children:r.jsx(Jc,{asChild:!0,...w,dir:A.dir,orientation:"vertical",loop:s,currentTabStopId:N,onCurrentTabStopIdChange:b,onEntryFocus:Pe(d,U=>{A.isUsingKeyboardRef.current||U.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(Im,{role:"menu","aria-orientation":"vertical","data-state":yd(k.open),"data-radix-menu-content":"",dir:A.dir,...T,...j,ref:q,style:{outline:"none",...j.style},onKeyDown:Pe(j.onKeyDown,U=>{const O=U.target.closest("[data-radix-menu-content]")===U.currentTarget,S=U.ctrlKey||U.altKey||U.metaKey,B=U.key.length===1;O&&(U.key==="Tab"&&U.preventDefault(),!S&&B&&qe(U.key));const Z=L.current;if(U.target!==Z||!zh.includes(U.key))return;U.preventDefault();const ve=D().filter(R=>!R.disabled).map(R=>R.ref.current);Xc.includes(U.key)&&ve.reverse(),cg(ve)}),onBlur:Pe(e.onBlur,U=>{U.currentTarget.contains(U.target)||(window.clearTimeout(P.current),Y.current="")}),onPointerMove:Pe(e.onPointerMove,Kn(U=>{const fe=U.target,O=V.current!==U.clientX;if(U.currentTarget.contains(fe)&&O){const S=U.clientX>V.current?"right":"left";M.current=S,V.current=U.clientX}}))})})})})})})});nd.displayName=ir;var eg="MenuGroup",li=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(Xn.div,{role:"group",...s,ref:t})});li.displayName=eg;var tg="MenuLabel",sd=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(Xn.div,{...s,ref:t})});sd.displayName=tg;var zs="MenuItem",xl="menu.itemSelect",no=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:s,...o}=e,a=l.useRef(null),i=es(zs,e.__scopeMenu),c=ai(zs,e.__scopeMenu),d=er(t,a),u=l.useRef(!1),p=()=>{const m=a.current;if(!n&&m){const h=new CustomEvent(xl,{bubbles:!0,cancelable:!0});m.addEventListener(xl,g=>s?.(g),{once:!0}),bh(m,h),h.defaultPrevented?u.current=!1:i.onClose()}};return r.jsx(od,{...o,ref:d,disabled:n,onClick:Pe(e.onClick,p),onPointerDown:m=>{e.onPointerDown?.(m),u.current=!0},onPointerUp:Pe(e.onPointerUp,m=>{u.current||m.currentTarget?.click()}),onKeyDown:Pe(e.onKeyDown,m=>{const h=c.searchRef.current!=="";n||h&&m.key===" "||Aa.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})});no.displayName=zs;var od=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:s=!1,textValue:o,...a}=e,i=ai(zs,n),c=Zc(n),d=l.useRef(null),u=er(t,d),[p,m]=l.useState(!1),[h,g]=l.useState("");return l.useEffect(()=>{const x=d.current;x&&g((x.textContent??"").trim())},[a.children]),r.jsx(Gn.ItemSlot,{scope:n,disabled:s,textValue:o??h,children:r.jsx(Yc,{asChild:!0,...c,focusable:!s,children:r.jsx(Xn.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...a,ref:u,onPointerMove:Pe(e.onPointerMove,Kn(x=>{s?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,Kn(x=>i.onItemLeave(x))),onFocus:Pe(e.onFocus,()=>m(!0)),onBlur:Pe(e.onBlur,()=>m(!1))})})})}),rg="MenuCheckboxItem",ad=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:s,...o}=e;return r.jsx(ud,{scope:e.__scopeMenu,checked:n,children:r.jsx(no,{role:"menuitemcheckbox","aria-checked":Us(n)?"mixed":n,...o,ref:t,"data-state":di(n),onSelect:Pe(o.onSelect,()=>s?.(Us(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ad.displayName=rg;var id="MenuRadioGroup",[ng,sg]=cn(id,{value:void 0,onValueChange:()=>{}}),ld=l.forwardRef((e,t)=>{const{value:n,onValueChange:s,...o}=e,a=vr(s);return r.jsx(ng,{scope:e.__scopeMenu,value:n,onValueChange:a,children:r.jsx(li,{...o,ref:t})})});ld.displayName=id;var cd="MenuRadioItem",dd=l.forwardRef((e,t)=>{const{value:n,...s}=e,o=sg(cd,e.__scopeMenu),a=n===o.value;return r.jsx(ud,{scope:e.__scopeMenu,checked:a,children:r.jsx(no,{role:"menuitemradio","aria-checked":a,...s,ref:t,"data-state":di(a),onSelect:Pe(s.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});dd.displayName=cd;var ci="MenuItemIndicator",[ud,og]=cn(ci,{checked:!1}),pd=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:s,...o}=e,a=og(ci,n);return r.jsx(kr,{present:s||Us(a.checked)||a.checked===!0,children:r.jsx(Xn.span,{...o,ref:t,"data-state":di(a.checked)})})});pd.displayName=ci;var ag="MenuSeparator",md=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(Xn.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});md.displayName=ag;var ig="MenuArrow",fd=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,o=ro(n);return r.jsx(Am,{...o,...s,ref:t})});fd.displayName=ig;var lg="MenuSub",[gw,hd]=cn(lg),Bn="MenuSubTrigger",gd=l.forwardRef((e,t)=>{const n=dn(Bn,e.__scopeMenu),s=es(Bn,e.__scopeMenu),o=hd(Bn,e.__scopeMenu),a=ai(Bn,e.__scopeMenu),i=l.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=a,u={__scopeMenu:e.__scopeMenu},p=l.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return l.useEffect(()=>p,[p]),l.useEffect(()=>{const m=c.current;return()=>{window.clearTimeout(m),d(null)}},[c,d]),r.jsx(si,{asChild:!0,...u,children:r.jsx(od,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":yd(n.open),...e,ref:an(t,o.onTriggerChange),onClick:m=>{e.onClick?.(m),!(e.disabled||m.defaultPrevented)&&(m.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Pe(e.onPointerMove,Kn(m=>{a.onItemEnter(m),!m.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),p()},100))})),onPointerLeave:Pe(e.onPointerLeave,Kn(m=>{p();const h=n.content?.getBoundingClientRect();if(h){const g=n.content?.dataset.side,x=g==="right",j=x?-5:5,k=h[x?"left":"right"],A=h[x?"right":"left"];a.onPointerGraceIntentChange({area:[{x:m.clientX+j,y:m.clientY},{x:k,y:h.top},{x:A,y:h.top},{x:A,y:h.bottom},{x:k,y:h.bottom}],side:g}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(m),m.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Pe(e.onKeyDown,m=>{const h=a.searchRef.current!=="";e.disabled||h&&m.key===" "||Uh[s.dir].includes(m.key)&&(n.onOpenChange(!0),n.content?.focus(),m.preventDefault())})})})});gd.displayName=Bn;var xd="MenuSubContent",vd=l.forwardRef((e,t)=>{const n=td(ir,e.__scopeMenu),{forceMount:s=n.forceMount,...o}=e,a=dn(ir,e.__scopeMenu),i=es(ir,e.__scopeMenu),c=hd(xd,e.__scopeMenu),d=l.useRef(null),u=er(t,d);return r.jsx(Gn.Provider,{scope:e.__scopeMenu,children:r.jsx(kr,{present:s||a.open,children:r.jsx(Gn.Slot,{scope:e.__scopeMenu,children:r.jsx(ii,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{i.isUsingKeyboardRef.current&&d.current?.focus(),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Pe(e.onFocusOutside,p=>{p.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:Pe(e.onEscapeKeyDown,p=>{i.onClose(),p.preventDefault()}),onKeyDown:Pe(e.onKeyDown,p=>{const m=p.currentTarget.contains(p.target),h=Wh[i.dir].includes(p.key);m&&h&&(a.onOpenChange(!1),c.trigger?.focus(),p.preventDefault())})})})})})});vd.displayName=xd;function yd(e){return e?"open":"closed"}function Us(e){return e==="indeterminate"}function di(e){return Us(e)?"indeterminate":e?"checked":"unchecked"}function cg(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function dg(e,t){return e.map((n,s)=>e[(t+s)%e.length])}function ug(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=dg(e,Math.max(a,0));o.length===1&&(i=i.filter(u=>u!==n));const d=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function pg(e,t){const{x:n,y:s}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const c=t[a],d=t[i],u=c.x,p=c.y,m=d.x,h=d.y;p>s!=h>s&&n<(m-u)*(s-p)/(h-p)+u&&(o=!o)}return o}function mg(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return pg(n,t)}function Kn(e){return t=>t.pointerType==="mouse"?e(t):void 0}var fg=ed,hg=si,gg=rd,xg=nd,vg=li,yg=sd,bg=no,wg=ad,kg=ld,jg=dd,Sg=pd,Ng=md,Cg=fd,Eg=gd,Ig=vd;function Ag(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,j=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(j.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,Tg(o,...t)]}function Tg(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function _g(e){const t=Mg(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(Rg);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Mg(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=Lg(o),c=Pg(a,o.props);return o.type!==l.Fragment&&(c.ref=s?an(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Dg=Symbol("radix.slottable");function Rg(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Dg}function Pg(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Lg(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Og=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Fg=Og.reduce((e,t)=>{const n=_g(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),so="DropdownMenu",[$g,xw]=Ag(so,[Qc]),Vt=Qc(),[Bg,bd]=$g(so),wd=e=>{const{__scopeDropdownMenu:t,children:n,dir:s,open:o,defaultOpen:a,onOpenChange:i,modal:c=!0}=e,d=Vt(t),u=l.useRef(null),[p,m]=Za({prop:o,defaultProp:a??!1,onChange:i,caller:so});return r.jsx(Bg,{scope:t,triggerId:Bs(),triggerRef:u,contentId:Bs(),open:p,onOpenChange:m,onOpenToggle:l.useCallback(()=>m(h=>!h),[m]),modal:c,children:r.jsx(fg,{...d,open:p,onOpenChange:m,dir:s,modal:c,children:n})})};wd.displayName=so;var kd="DropdownMenuTrigger",jd=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:s=!1,...o}=e,a=bd(kd,n),i=Vt(n);return r.jsx(hg,{asChild:!0,...i,children:r.jsx(Fg.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":s?"":void 0,disabled:s,...o,ref:an(t,a.triggerRef),onPointerDown:Pe(e.onPointerDown,c=>{!s&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:Pe(e.onKeyDown,c=>{s||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});jd.displayName=kd;var zg="DropdownMenuPortal",Sd=e=>{const{__scopeDropdownMenu:t,...n}=e,s=Vt(t);return r.jsx(gg,{...s,...n})};Sd.displayName=zg;var Nd="DropdownMenuContent",Cd=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=bd(Nd,n),a=Vt(n),i=l.useRef(!1);return r.jsx(xg,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...s,ref:t,onCloseAutoFocus:Pe(e.onCloseAutoFocus,c=>{i.current||o.triggerRef.current?.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:Pe(e.onInteractOutside,c=>{const d=c.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,p=d.button===2||u;(!o.modal||p)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Cd.displayName=Nd;var Ug="DropdownMenuGroup",Wg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Vt(n);return r.jsx(vg,{...o,...s,ref:t})});Wg.displayName=Ug;var Hg="DropdownMenuLabel",qg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Vt(n);return r.jsx(yg,{...o,...s,ref:t})});qg.displayName=Hg;var Vg="DropdownMenuItem",Ed=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Vt(n);return r.jsx(bg,{...o,...s,ref:t})});Ed.displayName=Vg;var Gg="DropdownMenuCheckboxItem",Kg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Vt(n);return r.jsx(wg,{...o,...s,ref:t})});Kg.displayName=Gg;var Jg="DropdownMenuRadioGroup",Yg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Vt(n);return r.jsx(kg,{...o,...s,ref:t})});Yg.displayName=Jg;var Xg="DropdownMenuRadioItem",Qg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Vt(n);return r.jsx(jg,{...o,...s,ref:t})});Qg.displayName=Xg;var Zg="DropdownMenuItemIndicator",ex=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Vt(n);return r.jsx(Sg,{...o,...s,ref:t})});ex.displayName=Zg;var tx="DropdownMenuSeparator",Id=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Vt(n);return r.jsx(Ng,{...o,...s,ref:t})});Id.displayName=tx;var rx="DropdownMenuArrow",nx=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Vt(n);return r.jsx(Cg,{...o,...s,ref:t})});nx.displayName=rx;var sx="DropdownMenuSubTrigger",ox=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Vt(n);return r.jsx(Eg,{...o,...s,ref:t})});ox.displayName=sx;var ax="DropdownMenuSubContent",ix=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Vt(n);return r.jsx(Ig,{...o,...s,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ix.displayName=ax;var js=wd,Ss=jd,Ns=Sd,Cs=Cd,gr=Ed,vl=Id;function lx(e){const t=cx(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(ux);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function cx(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=mx(o),c=px(a,o.props);return o.type!==l.Fragment&&(c.ref=s?an(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var dx=Symbol("radix.slottable");function ux(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===dx}function px(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function mx(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var fx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ts=fx.reduce((e,t)=>{const n=lx(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function hx(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,j=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(j.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,gx(o,...t)]}function gx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function xx(e,t){return l.useReducer((n,s)=>t[n][s]??n,e)}var ui="ScrollArea",[Ad,vw]=hx(ui),[vx,cr]=Ad(ui),Td=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:s="hover",dir:o,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[u,p]=l.useState(null),[m,h]=l.useState(null),[g,x]=l.useState(null),[j,k]=l.useState(null),[A,T]=l.useState(0),[w,D]=l.useState(0),[N,b]=l.useState(!1),[L,q]=l.useState(!1),P=er(t,ge=>d(ge)),Y=eo(o);return r.jsx(vx,{scope:n,type:s,dir:Y,scrollHideDelay:a,scrollArea:c,viewport:u,onViewportChange:p,content:m,onContentChange:h,scrollbarX:g,onScrollbarXChange:x,scrollbarXEnabled:N,onScrollbarXEnabledChange:b,scrollbarY:j,onScrollbarYChange:k,scrollbarYEnabled:L,onScrollbarYEnabledChange:q,onCornerWidthChange:T,onCornerHeightChange:D,children:r.jsx(ts.div,{dir:Y,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":A+"px","--radix-scroll-area-corner-height":w+"px",...e.style}})})});Td.displayName=ui;var _d="ScrollAreaViewport",Md=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:s,nonce:o,...a}=e,i=cr(_d,n),c=l.useRef(null),d=er(t,c,i.onViewportChange);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),r.jsx(ts.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:r.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});Md.displayName=_d;var jr="ScrollAreaScrollbar",Dd=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=cr(jr,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=o,c=e.orientation==="horizontal";return l.useEffect(()=>(c?a(!0):i(!0),()=>{c?a(!1):i(!1)}),[c,a,i]),o.type==="hover"?r.jsx(yx,{...s,ref:t,forceMount:n}):o.type==="scroll"?r.jsx(bx,{...s,ref:t,forceMount:n}):o.type==="auto"?r.jsx(Rd,{...s,ref:t,forceMount:n}):o.type==="always"?r.jsx(pi,{...s,ref:t}):null});Dd.displayName=jr;var yx=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=cr(jr,e.__scopeScrollArea),[a,i]=l.useState(!1);return l.useEffect(()=>{const c=o.scrollArea;let d=0;if(c){const u=()=>{window.clearTimeout(d),i(!0)},p=()=>{d=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",u),c.addEventListener("pointerleave",p),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",u),c.removeEventListener("pointerleave",p)}}},[o.scrollArea,o.scrollHideDelay]),r.jsx(kr,{present:n||a,children:r.jsx(Rd,{"data-state":a?"visible":"hidden",...s,ref:t})})}),bx=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=cr(jr,e.__scopeScrollArea),a=e.orientation==="horizontal",i=ao(()=>d("SCROLL_END"),100),[c,d]=xx("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return l.useEffect(()=>{if(c==="idle"){const u=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[c,o.scrollHideDelay,d]),l.useEffect(()=>{const u=o.viewport,p=a?"scrollLeft":"scrollTop";if(u){let m=u[p];const h=()=>{const g=u[p];m!==g&&(d("SCROLL"),i()),m=g};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,a,d,i]),r.jsx(kr,{present:n||c!=="hidden",children:r.jsx(pi,{"data-state":c==="hidden"?"hidden":"visible",...s,ref:t,onPointerEnter:Pe(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Pe(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Rd=l.forwardRef((e,t)=>{const n=cr(jr,e.__scopeScrollArea),{forceMount:s,...o}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=ao(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,p=n.viewport.offsetHeight<n.viewport.scrollHeight;i(c?u:p)}},10);return Cn(n.viewport,d),Cn(n.content,d),r.jsx(kr,{present:s||a,children:r.jsx(pi,{"data-state":a?"visible":"hidden",...o,ref:t})})}),pi=l.forwardRef((e,t)=>{const{orientation:n="vertical",...s}=e,o=cr(jr,e.__scopeScrollArea),a=l.useRef(null),i=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=$d(c.viewport,c.content),p={...s,sizes:c,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:h=>a.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function m(h,g){return Cx(h,i.current,c,g)}return n==="horizontal"?r.jsx(wx,{...p,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollLeft,g=yl(h,c,o.dir);a.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=m(h,o.dir))}}):n==="vertical"?r.jsx(kx,{...p,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollTop,g=yl(h,c);a.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=m(h))}}):null}),wx=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,a=cr(jr,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=er(t,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(Ld,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":oo(n)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.x),onDragScroll:p=>e.onDragScroll(p.x),onWheelScroll:(p,m)=>{if(a.viewport){const h=a.viewport.scrollLeft+p.deltaX;e.onWheelScroll(h),zd(h,m)&&p.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&s({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Hs(i.paddingLeft),paddingEnd:Hs(i.paddingRight)}})}})}),kx=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,a=cr(jr,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=er(t,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(Ld,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":oo(n)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.y),onDragScroll:p=>e.onDragScroll(p.y),onWheelScroll:(p,m)=>{if(a.viewport){const h=a.viewport.scrollTop+p.deltaY;e.onWheelScroll(h),zd(h,m)&&p.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&s({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Hs(i.paddingTop),paddingEnd:Hs(i.paddingBottom)}})}})}),[jx,Pd]=Ad(jr),Ld=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:s,hasThumb:o,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:p,onResize:m,...h}=e,g=cr(jr,n),[x,j]=l.useState(null),k=er(t,P=>j(P)),A=l.useRef(null),T=l.useRef(""),w=g.viewport,D=s.content-s.viewport,N=vr(p),b=vr(d),L=ao(m,10);function q(P){if(A.current){const Y=P.clientX-A.current.left,ge=P.clientY-A.current.top;u({x:Y,y:ge})}}return l.useEffect(()=>{const P=Y=>{const ge=Y.target;x?.contains(ge)&&N(Y,D)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[w,x,D,N]),l.useEffect(b,[s,b]),Cn(x,L),Cn(g.content,L),r.jsx(jx,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:vr(a),onThumbPointerUp:vr(i),onThumbPositionChange:b,onThumbPointerDown:vr(c),children:r.jsx(ts.div,{...h,ref:k,style:{position:"absolute",...h.style},onPointerDown:Pe(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),A.current=x.getBoundingClientRect(),T.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),q(P))}),onPointerMove:Pe(e.onPointerMove,q),onPointerUp:Pe(e.onPointerUp,P=>{const Y=P.target;Y.hasPointerCapture(P.pointerId)&&Y.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=T.current,g.viewport&&(g.viewport.style.scrollBehavior=""),A.current=null})})})}),Ws="ScrollAreaThumb",Od=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=Pd(Ws,e.__scopeScrollArea);return r.jsx(kr,{present:n||o.hasThumb,children:r.jsx(Sx,{ref:t,...s})})}),Sx=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:s,...o}=e,a=cr(Ws,n),i=Pd(Ws,n),{onThumbPositionChange:c}=i,d=er(t,m=>i.onThumbChange(m)),u=l.useRef(void 0),p=ao(()=>{u.current&&(u.current(),u.current=void 0)},100);return l.useEffect(()=>{const m=a.viewport;if(m){const h=()=>{if(p(),!u.current){const g=Ex(m,c);u.current=g,c()}};return c(),m.addEventListener("scroll",h),()=>m.removeEventListener("scroll",h)}},[a.viewport,p,c]),r.jsx(ts.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:Pe(e.onPointerDownCapture,m=>{const g=m.target.getBoundingClientRect(),x=m.clientX-g.left,j=m.clientY-g.top;i.onThumbPointerDown({x,y:j})}),onPointerUp:Pe(e.onPointerUp,i.onThumbPointerUp)})});Od.displayName=Ws;var mi="ScrollAreaCorner",Fd=l.forwardRef((e,t)=>{const n=cr(mi,e.__scopeScrollArea),s=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&s?r.jsx(Nx,{...e,ref:t}):null});Fd.displayName=mi;var Nx=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,...s}=e,o=cr(mi,n),[a,i]=l.useState(0),[c,d]=l.useState(0),u=!!(a&&c);return Cn(o.scrollbarX,()=>{const p=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(p),d(p)}),Cn(o.scrollbarY,()=>{const p=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(p),i(p)}),u?r.jsx(ts.div,{...s,ref:t,style:{width:a,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Hs(e){return e?parseInt(e,10):0}function $d(e,t){const n=e/t;return isNaN(n)?0:n}function oo(e){const t=$d(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=(e.scrollbar.size-n)*t;return Math.max(s,18)}function Cx(e,t,n,s="ltr"){const o=oo(n),a=o/2,i=t||a,c=o-i,d=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-c,p=n.content-n.viewport,m=s==="ltr"?[0,p]:[p*-1,0];return Bd([d,u],m)(e)}function yl(e,t,n="ltr"){const s=oo(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-o,i=t.content-t.viewport,c=a-s,d=n==="ltr"?[0,i]:[i*-1,0],u=Tm(e,d);return Bd([0,i],[0,c])(u)}function Bd(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const s=(t[1]-t[0])/(e[1]-e[0]);return t[0]+s*(n-e[0])}}function zd(e,t){return e>0&&e<t}var Ex=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},s=0;return function o(){const a={left:e.scrollLeft,top:e.scrollTop},i=n.left!==a.left,c=n.top!==a.top;(i||c)&&t(),n=a,s=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(s)};function ao(e,t){const n=vr(e),s=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(s.current),[]),l.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(n,t)},[n,t])}function Cn(e,t){const n=vr(t);wa(()=>{let s=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(s),s=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(s),o.unobserve(e)}}},[e,n])}var Ud=Td,Ix=Md,Wd=Dd,Ax=Od,Tx=Fd;function _x(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,j=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(j.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,Mx(o,...t)]}function Mx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Dx(e){const t=Rx(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(Lx);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Rx(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=Fx(o),c=Ox(a,o.props);return o.type!==l.Fragment&&(c.ref=s?an(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Px=Symbol("radix.slottable");function Lx(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Px}function Ox(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Fx(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var $x=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],io=$x.reduce((e,t)=>{const n=Dx(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),lo="Tabs",[Bx,yw]=_x(lo,[to]),Hd=to(),[zx,fi]=Bx(lo),qd=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...u}=e,p=eo(c),[m,h]=Za({prop:s,onChange:o,defaultProp:a??"",caller:lo});return r.jsx(zx,{scope:n,baseId:Bs(),value:m,onValueChange:h,orientation:i,dir:p,activationMode:d,children:r.jsx(io.div,{dir:p,"data-orientation":i,...u,ref:t})})});qd.displayName=lo;var Vd="TabsList",Gd=l.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=fi(Vd,n),i=Hd(n);return r.jsx(Jc,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:s,children:r.jsx(io.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});Gd.displayName=Vd;var Kd="TabsTrigger",Jd=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,i=fi(Kd,n),c=Hd(n),d=Qd(i.baseId,s),u=Zd(i.baseId,s),p=s===i.value;return r.jsx(Yc,{asChild:!0,...c,focusable:!o,active:p,children:r.jsx(io.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...a,ref:t,onMouseDown:Pe(e.onMouseDown,m=>{!o&&m.button===0&&m.ctrlKey===!1?i.onValueChange(s):m.preventDefault()}),onKeyDown:Pe(e.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&i.onValueChange(s)}),onFocus:Pe(e.onFocus,()=>{const m=i.activationMode!=="manual";!p&&!o&&m&&i.onValueChange(s)})})})});Jd.displayName=Kd;var Yd="TabsContent",Xd=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...i}=e,c=fi(Yd,n),d=Qd(c.baseId,s),u=Zd(c.baseId,s),p=s===c.value,m=l.useRef(p);return l.useEffect(()=>{const h=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(h)},[]),r.jsx(kr,{present:o||p,children:({present:h})=>r.jsx(io.div,{"data-state":p?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!h,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:m.current?"0s":void 0},children:h&&a})})});Xd.displayName=Yd;function Qd(e,t){return`${e}-trigger-${t}`}function Zd(e,t){return`${e}-content-${t}`}var Ux=qd,eu=Gd,tu=Jd,ru=Xd;const nu=l.forwardRef(({className:e,orientation:t="vertical",...n},s)=>r.jsx(Wd,{ref:s,orientation:t,className:ct("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:r.jsx(Ax,{className:"relative flex-1 rounded-full bg-border/80"})}));nu.displayName=Wd.displayName;const su=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Ud,{ref:s,className:ct("relative overflow-hidden",e),...n,children:[r.jsx(Ix,{className:"h-full w-full rounded-[inherit]",children:t}),r.jsx(nu,{}),r.jsx(Tx,{})]}));su.displayName=Ud.displayName;const Ft=l.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:ct("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:s,...n}));Ft.displayName="Input";const rs=({className:e="w-5 h-5"})=>r.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),co=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=ei();return r.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},uo=({className:e="w-5 h-5"})=>{const t=l.useId(),n=l.useId(),s=l.useId();return r.jsxs("svg",{"aria-label":"Gemini",className:e,role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("title",{children:"Gemini"}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"#3186FF"}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:`url(#${t})`}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:`url(#${n})`}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:`url(#${s})`}),r.jsxs("defs",{children:[r.jsxs("linearGradient",{id:t,x1:"7",x2:"11",y1:"15.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#08B962"}),r.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),r.jsxs("linearGradient",{id:n,x1:"8",x2:"11.5",y1:"5.5",y2:"11",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#F94543"}),r.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),r.jsxs("linearGradient",{id:s,x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#FABC12"}),r.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]})},po=({className:e="h-5 w-auto",style:t,...n})=>r.jsxs("svg",{"aria-label":"OpenCode",className:e,role:"img",style:{width:"auto",maxWidth:"100%",...t},viewBox:"0 0 32 24",preserveAspectRatio:"xMidYMid meet",xmlns:"http://www.w3.org/2000/svg",...n,children:[r.jsx("title",{children:"OpenCode"}),r.jsx("rect",{x:"6",y:"2",width:"20",height:"20",rx:"5",fill:"currentColor"}),r.jsx("path",{d:"M20 6h-8v12h8V6zm4 16H8V2h16v20z",fill:"white"})]}),Wx=!1,oe=(e,t={})=>{const n=localStorage.getItem("auth-token"),s={};return t.body instanceof FormData||(s["Content-Type"]="application/json"),n&&(s.Authorization=`Bearer ${n}`),fetch(e,{...t,headers:{...s,...t.headers}})},mt={auth:{status:()=>fetch("/api/auth/status"),login:(e,t)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),register:(e,t)=>fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),user:()=>oe("/api/auth/user"),logout:()=>oe("/api/auth/logout",{method:"POST"})},projects:()=>oe("/api/projects"),sessions:(e,t=5,n=0)=>oe(`/api/projects/${e}/sessions?limit=${t}&offset=${n}`),historyIndex:e=>oe(`/api/session-core/projects/${e}/history-index`),providerDiscovery:(e,t=null)=>{const n=new URLSearchParams;return t&&n.append("projectPath",t),oe(`/api/session-core/providers/${e}${n.toString()?`?${n.toString()}`:""}`)},providersDiscovery:(e=null)=>{const t=new URLSearchParams;return e&&t.append("projectPath",e),oe(`/api/session-core/providers${t.toString()?`?${t.toString()}`:""}`)},sessionEvents:(e,t,n=null,s=null,o=null,a=0)=>{const i=new URLSearchParams;return n&&i.append("projectName",n),s&&i.append("projectPath",s),o!==null&&(i.append("limit",o),i.append("offset",a)),oe(`/api/session-core/sessions/${e}/${t}/events${i.toString()?`?${i.toString()}`:""}`)},sessionMessages:(e,t,n=null,s=0,o="claude")=>{const a=new URLSearchParams;return e&&a.append("projectName",e),n!==null&&(a.append("limit",n),a.append("offset",s)),oe(`/api/session-core/sessions/${o}/${t}/events${a.toString()?`?${a.toString()}`:""}`)},resolveSession:(e,t=null)=>{const n=new URLSearchParams;return t&&n.append("provider",t),oe(`/api/session-core/sessions/${e}/resolve${n.toString()?`?${n.toString()}`:""}`)},renameProject:(e,t)=>oe(`/api/projects/${e}/rename`,{method:"PUT",body:JSON.stringify({displayName:t})}),deleteSession:(e,t)=>oe(`/api/projects/${e}/sessions/${t}`,{method:"DELETE"}),deleteCodexSession:e=>oe(`/api/codex/sessions/${e}`,{method:"DELETE"}),deleteOpencodeSession:e=>oe(`/api/opencode/sessions/${e}`,{method:"DELETE"}),deleteProject:(e,t=!1)=>oe(`/api/projects/${e}${t?"?force=true":""}`,{method:"DELETE"}),createProject:e=>oe("/api/projects/create",{method:"POST",body:JSON.stringify({path:e})}),createWorkspace:e=>oe("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(e)}),readFile:(e,t)=>oe(`/api/projects/${e}/file?filePath=${encodeURIComponent(t)}`),saveFile:(e,t,n)=>oe(`/api/projects/${e}/file`,{method:"PUT",body:JSON.stringify({filePath:t,content:n})}),getFiles:e=>oe(`/api/projects/${e}/files`),transcribe:e=>oe("/api/transcribe",{method:"POST",body:e,headers:{}}),browseFilesystem:(e=null)=>{const t=new URLSearchParams;return e&&t.append("path",e),oe(`/api/browse-filesystem?${t}`)},createFolder:e=>oe("/api/create-folder",{method:"POST",body:JSON.stringify({path:e})}),get:e=>oe(`/api${e}`)},Hx=({onClose:e,onProjectCreated:t})=>{const{t:n}=$t(),[s,o]=l.useState(1),[a,i]=l.useState("existing"),[c,d]=l.useState(""),[u,p]=l.useState(!1),[m,h]=l.useState(null),[g,x]=l.useState([]),[j,k]=l.useState(!1),[A,T]=l.useState(!1),[w,D]=l.useState("~"),[N,b]=l.useState([]),[L,q]=l.useState(!1),[P,Y]=l.useState(!1),[ge,le]=l.useState(!1),[M,V]=l.useState(""),[xe,Ie]=l.useState(!1);l.useEffect(()=>{c.length>2?qe(c):(x([]),k(!1))},[c]);const qe=async R=>{try{const re=R.lastIndexOf("/"),Fe=re>0?R.substring(0,re):"~",ce=await(await mt.browseFilesystem(Fe)).json();if(ce.suggestions){const $e=ce.suggestions.filter(ft=>ft.path.toLowerCase().startsWith(R.toLowerCase())&&ft.path.toLowerCase()!==R.toLowerCase());x($e.slice(0,5)),k($e.length>0)}}catch(re){console.error("Error loading path suggestions:",re)}},Se=()=>{if(h(null),s===1){if(!a){h(n("projectWizard.errors.selectType"));return}o(2)}else if(s===2){if(!c.trim()){h(n("projectWizard.errors.providePath"));return}o(3)}},U=()=>{h(null),o(s-1)},fe=async()=>{p(!0),h(null);try{const R={workspaceType:a,path:c.trim()},re=await mt.createWorkspace(R),Fe=await re.json();if(!re.ok)throw new Error(Fe.details||Fe.error||n("projectWizard.errors.failedToCreate"));t&&t(Fe.project),e()}catch(R){console.error("Error creating workspace:",R),h(R.message||n("projectWizard.errors.failedToCreate"))}finally{p(!1)}},O=R=>{d(R.path),k(!1)},S=async()=>{T(!0),await B("~")},B=async R=>{try{q(!0);const Fe=await(await mt.browseFilesystem(R)).json();D(Fe.path||R),b(Fe.suggestions||[])}catch(re){console.error("Error loading folders:",re)}finally{q(!1)}},Z=(R,re=!1)=>{d(R),T(!1),re&&o(3)},ke=async R=>{await B(R)},ve=async()=>{if(M.trim()){Ie(!0),h(null);try{const R=w.includes("\\")?"\\":"/",re=`${w}${R}${M.trim()}`,Fe=await mt.createFolder(re),Ce=await Fe.json();if(!Fe.ok)throw new Error(Ce.error||n("projectWizard.errors.failedToCreateFolder","Failed to create folder"));V(""),le(!1),await B(Ce.path||re)}catch(R){console.error("Error creating folder:",R),h(R.message||n("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}finally{Ie(!1)}}};return r.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:[r.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-2xl border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 bg-primary/15 dark:bg-primary/30 rounded-lg flex items-center justify-center",children:r.jsx(rn,{className:"w-4 h-4 text-primary"})}),r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:n("projectWizard.title")})]}),r.jsx("button",{onClick:e,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:u,children:r.jsx(ar,{className:"w-5 h-5"})})]}),r.jsx("div",{className:"px-6 pt-4 pb-2",children:r.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(R=>r.jsxs(Mn.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${R<s?"bg-green-500 text-white":R===s?"bg-primary text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:R<s?r.jsx(yr,{className:"w-4 h-4"}):R}),r.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:n(R===1?"projectWizard.steps.type":R===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),R<3&&r.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${R<s?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},R))})}),r.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[m&&r.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[r.jsx(_m,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),r.jsx("div",{className:"flex-1",children:r.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:m})})]}),s===1&&r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:n("projectWizard.step1.question")}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsx("button",{onClick:()=>i("existing"),className:`p-4 border-2 rounded-lg text-left transition-all ${a==="existing"?"border-primary bg-primary/10 dark:bg-primary/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:r.jsx(rn,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:n("projectWizard.step1.existing.title")}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.step1.existing.description")})]})]})}),r.jsx("button",{onClick:()=>i("new"),className:`p-4 border-2 rounded-lg text-left transition-all ${a==="new"?"border-primary bg-primary/10 dark:bg-primary/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:r.jsx(rn,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:n("projectWizard.step1.new.title")}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.step1.new.description")})]})]})})]})]})}),s===2&&r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:n(a==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),r.jsxs("div",{className:"relative flex gap-2",children:[r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(Ft,{type:"text",value:c,onChange:R=>d(R.target.value),placeholder:a==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),j&&g.length>0&&r.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:g.map((R,re)=>r.jsxs("button",{onClick:()=>O(R),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[r.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:R.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:R.path})]},re))})]}),r.jsx(De,{type:"button",variant:"outline",onClick:S,className:"px-3",title:"Browse folders",children:r.jsx(nn,{className:"w-4 h-4"})})]}),r.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:n(a==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]})}),s===3&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[r.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:n("projectWizard.step3.reviewConfig")}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.workspaceType")}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:n(a==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.path")}),r.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:c})]})]})]}),r.jsx("div",{className:"bg-primary/10 dark:bg-primary/20 rounded-lg p-4 border border-primary/30 dark:border-primary/60",children:r.jsx("p",{className:"text-sm text-primary",children:n(a==="existing"?"projectWizard.step3.existingInfo":"projectWizard.step3.newEmpty")})})]})]}),r.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[r.jsx(De,{variant:"outline",onClick:s===1?e:U,disabled:u,children:s===1?n("projectWizard.buttons.cancel"):r.jsxs(r.Fragment,{children:[r.jsx(Lc,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.back")]})}),r.jsx(De,{onClick:s===3?fe:Se,disabled:u||s===1&&!a,children:u?r.jsxs(r.Fragment,{children:[r.jsx(qn,{className:"w-4 h-4 mr-2 animate-spin"}),n("projectWizard.buttons.creating")]}):s===3?r.jsxs(r.Fragment,{children:[r.jsx(yr,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.createProject")]}):r.jsxs(r.Fragment,{children:[n("projectWizard.buttons.next"),r.jsx(wn,{className:"w-4 h-4 ml-1"})]})})]})]}),A&&r.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:r.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] border border-gray-200 dark:border-gray-700 flex flex-col",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 bg-primary/15 dark:bg-primary/30 rounded-lg flex items-center justify-center",children:r.jsx(nn,{className:"w-4 h-4 text-primary"})}),r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Select Folder"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>Y(!P),className:`p-2 rounded-md transition-colors ${P?"text-primary bg-primary/10 dark:bg-primary/25":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:P?"Hide hidden folders":"Show hidden folders",children:P?r.jsx(Oc,{className:"w-5 h-5"}):r.jsx(uf,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>le(!ge),className:`p-2 rounded-md transition-colors ${ge?"text-primary bg-primary/10 dark:bg-primary/25":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:"Create new folder",children:r.jsx(Nn,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>T(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:r.jsx(ar,{className:"w-5 h-5"})})]})]}),ge&&r.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-primary/10 dark:bg-primary/20",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ft,{type:"text",value:M,onChange:R=>V(R.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:R=>{R.key==="Enter"&&ve(),R.key==="Escape"&&(le(!1),V(""))},autoFocus:!0}),r.jsx(De,{size:"sm",onClick:ve,disabled:!M.trim()||xe,children:xe?r.jsx(qn,{className:"w-4 h-4 animate-spin"}):"Create"}),r.jsx(De,{size:"sm",variant:"ghost",onClick:()=>{le(!1),V("")},children:"Cancel"})]})}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:L?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(qn,{className:"w-6 h-6 animate-spin text-gray-400"})}):r.jsxs("div",{className:"space-y-1",children:[w!=="~"&&w!=="/"&&!/^[A-Za-z]:\\?$/.test(w)&&r.jsxs("button",{onClick:()=>{const R=Math.max(w.lastIndexOf("/"),w.lastIndexOf("\\"));let re;R<=0?re="/":R===2&&/^[A-Za-z]:/.test(w)?re=w.substring(0,3):re=w.substring(0,R),ke(re)},className:"w-full px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[r.jsx(nn,{className:"w-5 h-5 text-gray-400"}),r.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),N.length===0?r.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):N.filter(R=>P||!R.name.startsWith(".")).sort((R,re)=>R.name.toLowerCase().localeCompare(re.name.toLowerCase())).map((R,re)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:()=>ke(R.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[r.jsx(rn,{className:"w-5 h-5 text-primary"}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:R.name})]}),r.jsx(De,{variant:"ghost",size:"sm",onClick:()=>Z(R.path,a==="existing"),className:"text-xs px-3",children:"Select"})]},re))]})}),r.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),r.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:w})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[r.jsx(De,{variant:"outline",onClick:()=>{T(!1),le(!1),V("")},children:"Cancel"}),r.jsx(De,{variant:"outline",onClick:()=>Z(w,a==="existing"),children:"Use this folder"})]})]})]})})]})},qx=(e,t,n)=>{const s=new Date(e),o=t;if(isNaN(s.getTime()))return n?n("status.unknown"):"Unknown";const a=o-s,i=Math.floor(a/1e3),c=Math.floor(a/(1e3*60)),d=Math.floor(a/(1e3*60*60)),u=Math.floor(a/(1e3*60*60*24));return i<60?n?n("time.justNow"):"Just now":c===1?n?n("time.oneMinuteAgo"):"1 min ago":c<60?n?n("time.minutesAgo",{count:c}):`${c} mins ago`:d===1?n?n("time.oneHourAgo"):"1 hour ago":d<24?n?n("time.hoursAgo",{count:d}):`${d} hours ago`:u===1?n?n("time.oneDayAgo"):"1 day ago":u<7?n?n("time.daysAgo",{count:u}):`${u} days ago`:s.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},Vx=(e,t)=>{if(typeof e!="string")return"";const n=e.trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`},vn="flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",Es="flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-red-600 outline-none transition-colors hover:bg-red-50 hover:text-red-600 focus:bg-red-50 focus:text-red-600 dark:hover:bg-red-900/20 dark:focus:bg-red-900/20",sa="block min-w-0 w-full max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium text-foreground",bl=({provider:e,className:t="h-3.5 w-3.5"})=>e==="codex"||e==="openai"?r.jsx(co,{className:t}):e==="gemini"?r.jsx(uo,{className:t}):e==="opencode"?r.jsx(po,{className:"h-3.5 w-auto max-w-full"}):r.jsx(rs,{className:t});function wl({projects:e,selectedProject:t,selectedSession:n,onProjectSelect:s,onSessionSelect:o,onNewSession:a,onSessionDelete:i,onProjectDelete:c,isLoading:d,loadingProgress:u,onRefresh:p,updateAvailable:m,latestVersion:h,currentVersion:g,releaseInfo:x,onShowVersionModal:j,isPWA:k,isMobile:A,onToggleSidebar:T,lockedProjectName:w,showNewProject:D,setShowNewProject:N}){const{t:b}=$t("sidebar"),[L,q]=l.useState(new Set),[P,Y]=l.useState(null),[ge,le]=l.useState(""),[M,V]=l.useState({}),[xe,Ie]=l.useState({}),[qe,Se]=l.useState(new Set),[U,fe]=l.useState(new Date),[O,S]=l.useState("name"),[B,Z]=l.useState(!1),[ke,ve]=l.useState(null),[R,re]=l.useState(""),[Fe,Ce]=l.useState(null),[ce,$e]=l.useState(null),[ft,at]=l.useState({}),[Ve,Ze]=l.useState(""),[yt,Tt]=l.useState(new Set),[he,Ke]=l.useState(null),[_t,kt]=l.useState(null),[St,J]=l.useState(()=>{try{const _=localStorage.getItem("starredProjects");return _?new Set(JSON.parse(_)):new Set}catch(_){return console.error("Error loading starred projects:",_),new Set}}),ee=_=>pe=>{pe.target.closest(".overflow-y-auto")||pe.target.closest("[data-scroll-container]")||(pe.preventDefault(),pe.stopPropagation(),_())};l.useEffect(()=>{const _=setInterval(()=>{fe(new Date)},6e4);return()=>clearInterval(_)},[]),l.useEffect(()=>{Ie({}),Se(new Set)},[e]),l.useEffect(()=>{n&&t&&q(_=>new Set([..._,t.name]))},[n,t]),l.useEffect(()=>{w&&q(new Set([w]))},[w,e.length]),l.useEffect(()=>{if(e.length>0&&!d){const _=new Set;e.forEach(pe=>{pe.sessions&&pe.sessions.length>=0&&_.add(pe.name)}),Se(_)}},[e,d]),l.useEffect(()=>{const _=()=>{try{const X=localStorage.getItem("claude-settings");if(X){const C=JSON.parse(X);S(C.projectSortOrder||"name")}}catch(X){console.error("Error loading sort order:",X)}};_();const pe=X=>{X.key==="claude-settings"&&_()};window.addEventListener("storage",pe);const Ae=setInterval(()=>{document.hasFocus()&&_()},1e3);return()=>{window.removeEventListener("storage",pe),clearInterval(Ae)}},[]);const je=_=>{const pe=new Set;L.has(_)||pe.add(_),q(pe)},_e=(_,pe)=>{o({..._,__projectName:pe})},et=_=>{const pe=new Set(St);pe.has(_)?pe.delete(_):pe.add(_),J(pe);try{localStorage.setItem("starredProjects",JSON.stringify([...pe]))}catch(Ae){console.error("Error saving starred projects:",Ae)}},tt=_=>St.has(_),Je=_=>{let pe={};try{pe=JSON.parse(localStorage.getItem("session-provider-map")||"{}")}catch{}const Ae=[..._.sessions||[],...xe[_.name]||[]].map(be=>({...be,__provider:pe[be.id]||"claude"})),X=(_.codexSessions||[]).map(be=>({...be,__provider:"codex"})),C=(_.geminiSessions||[]).map(be=>({...be,__provider:"gemini"})),F=(_.opencodeSessions||[]).map(be=>({...be,__provider:"opencode"})),ie=be=>be.__provider==="codex"?new Date(be.createdAt||be.lastActivity):be.__provider==="gemini"?new Date(be.createdAt||be.lastActivity):be.__provider==="opencode"?new Date(be.createdAt||be.lastActivity):new Date(be.lastActivity);return[...Ae,...X,...C,...F].sort((be,dt)=>ie(dt)-ie(be))},Mt=_=>{const pe=Je(_);return pe.length===0?new Date(0):pe.reduce((X,C)=>{const F=new Date(C.lastActivity);return F>X?F:X},new Date(0))},ue=[...e].sort((_,pe)=>{const Ae=tt(_.name),X=tt(pe.name);if(Ae&&!X)return-1;if(!Ae&&X)return 1;if(O==="date")return Mt(pe)-Mt(_);{const C=_.displayName||_.name,F=pe.displayName||pe.name;return C.localeCompare(F)}}),bt=_=>{Y(_.name),le(_.displayName)},Ye=()=>{Y(null),le("")},rt=async _=>{try{(await mt.renameProject(_,ge)).ok?window.refreshProjects?window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(pe){console.error("Error renaming project:",pe)}Y(null),le("")},Ue=(_,pe,Ae,X="claude")=>{kt({projectName:_,sessionId:pe,sessionTitle:Ae,provider:X})},Nt=async()=>{if(!_t)return;const{projectName:_,sessionId:pe,provider:Ae}=_t;kt(null);try{console.log("[Sidebar] Deleting session:",{projectName:_,sessionId:pe,provider:Ae});let X;if(Ae==="codex"?X=await mt.deleteCodexSession(pe):Ae==="opencode"?X=await mt.deleteOpencodeSession(pe):X=await mt.deleteSession(_,pe),console.log("[Sidebar] Delete response:",{ok:X.ok,status:X.status}),X.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),i?i(pe):console.warn("[Sidebar] No onSessionDelete callback provided");else{const C=await X.text();console.error("[Sidebar] Failed to delete session:",{status:X.status,error:C}),alert(b("messages.deleteSessionFailed"))}}catch(X){console.error("[Sidebar] Error deleting session:",X),alert(b("messages.deleteSessionError"))}},Pt=_=>{const pe=Je(_).length;Ke({project:_,sessionCount:pe})},ht=async()=>{if(!he)return;const{project:_,sessionCount:pe}=he,Ae=pe===0;Ke(null),Tt(X=>new Set([...X,_.name]));try{const X=await mt.deleteProject(_.name,!Ae);if(X.ok)c&&c(_.name);else{const C=await X.json();console.error("Failed to delete project"),alert(C.error||b("messages.deleteProjectFailed"))}}catch(X){console.error("Error deleting project:",X),alert(b("messages.deleteProjectError"))}finally{Tt(X=>{const C=new Set(X);return C.delete(_.name),C})}},Ct=async _=>{if(!(!(_.sessionMeta?.hasMore!==!1)||M[_.name])){V(Ae=>({...Ae,[_.name]:!0}));try{const Ae=(_.sessions?.length||0)+(xe[_.name]?.length||0),X=await mt.sessions(_.name,5,Ae);if(X.ok){const C=await X.json();Ie(F=>({...F,[_.name]:[...F[_.name]||[],...C.sessions]})),C.hasMore===!1&&(_.sessionMeta={..._.sessionMeta,hasMore:!1})}}catch(Ae){console.error("Error loading more sessions:",Ae)}finally{V(Ae=>({...Ae,[_.name]:!1}))}}},tr=ue.filter(_=>{if(!Ve.trim())return!0;const pe=Ve.toLowerCase(),Ae=(_.displayName||_.name).toLowerCase(),X=_.name.toLowerCase();return Ae.includes(pe)||X.includes(pe)}),Xe=!!w,Lt=Xe?ue.filter(_=>_.name===w):tr,jt=t||Lt[0]||null,Ot=A?"bottom":"right",rr=A?"end":"start",zt=A?4:8;return r.jsxs(r.Fragment,{children:[D&&Xo.createPortal(r.jsx(Hx,{onClose:()=>N(!1),onProjectCreated:_=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),he&&Xo.createPortal(r.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:r.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[r.jsx("div",{className:"p-6",children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:r.jsx(Ea,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:b("deleteConfirmation.deleteProject")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[b("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:he.project.displayName||he.project.name}),"?"]}),he.sessionCount>0&&r.jsxs("div",{className:"mt-3 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[r.jsx("p",{className:"text-sm text-red-700 dark:text-red-300 font-medium",children:b("deleteConfirmation.sessionCount",{count:he.sessionCount})}),r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:b("deleteConfirmation.allConversationsDeleted")})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:b("deleteConfirmation.cannotUndo")})]})]})}),r.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[r.jsx(De,{variant:"outline",className:"flex-1",onClick:()=>Ke(null),children:b("actions.cancel")}),r.jsxs(De,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:ht,children:[r.jsx(pr,{className:"w-4 h-4 mr-2"}),b("actions.delete")]})]})]})}),document.body),_t&&Xo.createPortal(r.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:r.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[r.jsx("div",{className:"p-6",children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:r.jsx(Ea,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:b("deleteConfirmation.deleteSession")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[b("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:_t.sessionTitle||b("sessions.unnamed")}),"?"]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:b("deleteConfirmation.cannotUndo")})]})]})}),r.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[r.jsx(De,{variant:"outline",className:"flex-1",onClick:()=>kt(null),children:b("actions.cancel")}),r.jsxs(De,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:Nt,children:[r.jsx(pr,{className:"w-4 h-4 mr-2"}),b("actions.delete")]})]})]})}),document.body),r.jsxs("div",{className:"h-full flex flex-col bg-muted/40 md:select-none",style:k&&A?{paddingTop:"44px"}:{},children:[r.jsxs("div",{className:"md:flex-shrink-0 md:px-3 md:pt-3",children:[r.jsxs("div",{className:"hidden h-[60px] items-center justify-between gap-3 rounded-2xl bg-background/70 px-3 md:flex",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-foreground text-background flex-shrink-0",children:r.jsx(Vn,{className:"w-4 h-4 text-primary-foreground"})}),r.jsx("div",{className:"min-w-0",children:r.jsx("h1",{className:"text-base font-semibold leading-none text-foreground truncate",children:b("app.title")})})]}),T&&r.jsx(De,{variant:"ghost",size:"sm",className:"h-8 w-8 flex-shrink-0 rounded-xl bg-muted/70 px-0 text-muted-foreground transition-colors duration-200 hover:bg-muted hover:text-foreground",onClick:T,title:b("tooltips.hideSidebar"),children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),r.jsx("div",{className:"chat-header bg-white p-3 dark:bg-background md:hidden",style:k&&A?{paddingTop:"16px"}:{},children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 bg-primary rounded-lg flex items-center justify-center",children:r.jsx(Vn,{className:"w-4 h-4 text-primary-foreground"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-foreground",children:b("app.title")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.title")})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-muted/70 text-foreground transition-all duration-150 active:scale-95",onClick:async()=>{Z(!0);try{await p()}finally{Z(!1)}},disabled:B,children:r.jsx(Ar,{className:`w-4 h-4 text-foreground ${B?"animate-spin":""}`})}),!Xe&&r.jsx("button",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-foreground text-background transition-all duration-150 active:scale-95",onClick:()=>N(!0),children:r.jsx(rn,{className:"w-4 h-4"})})]})]})})]}),!d&&!A&&!Xe&&r.jsx("div",{className:"hidden"}),e.length>0&&!d&&!Xe&&r.jsx("div",{className:"px-3 py-3 md:px-3",children:r.jsxs("div",{className:"relative",children:[r.jsx(Na,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),r.jsx(Ft,{type:"text",placeholder:b("projects.searchPlaceholder"),value:Ve,onChange:_=>Ze(_.target.value),className:"h-10 rounded-xl border-0 bg-background/80 pl-9 text-sm shadow-none focus:bg-background focus:ring-2 focus:ring-primary/20"}),Ve&&r.jsx("button",{onClick:()=>Ze(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:r.jsx(ar,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.length>0&&!d&&jt&&r.jsx("div",{className:"px-3 pb-2",children:r.jsxs(De,{variant:"subtle",className:"h-9 w-full justify-start gap-2 rounded-lg px-3 text-sm",onClick:()=>a(jt),children:[r.jsx(Nn,{className:"h-4 w-4"}),b("sessions.newSession")]})}),r.jsx(su,{className:"flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-2 py-2 md:px-3 md:py-2",children:r.jsx("div",{className:"space-y-1 overflow-x-hidden pb-safe-area-inset-bottom",children:d?r.jsx("div",{className:"flex min-h-[240px] items-start justify-center px-4 pt-10 md:min-h-[280px] md:px-6 md:pt-12",children:r.jsx("div",{className:"w-full max-w-[320px] text-center space-y-4",children:r.jsxs("div",{className:"space-y-2.5",children:[r.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:u&&u.total>0?r.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${u.current/u.total*100}%`}}):r.jsx("div",{className:"h-full w-1/3 rounded-full bg-primary animate-pulse"})}),u?.currentProject&&r.jsx("p",{className:"mx-auto max-w-[260px] break-words text-base font-medium leading-6 text-foreground",title:u.currentProject,children:u.currentProject.split("-").slice(-2).join("/")}),u&&u.total>0?r.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.current,"/",u.total,r.jsx("span",{className:"ml-1 text-sm text-muted-foreground",children:b("projects.projects")})]}):r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.loadingProjects")})]})})}):e.length===0?r.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[r.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:r.jsx(ea,{className:"w-6 h-6 text-muted-foreground"})}),r.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:b("projects.noProjects")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.runClaudeCli")})]}):Lt.length===0?r.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[r.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:r.jsx(Na,{className:"w-6 h-6 text-muted-foreground"})}),r.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:b("projects.noMatchingProjects")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.tryDifferentSearch")})]}):Lt.map(_=>{const pe=L.has(_.name),Ae=t?.name===_.name,X=tt(_.name),C=yt.has(_.name),F=Xe&&_.name===w,ie=F||pe,be=_.displayName||_.name,dt=Vx(be,A?22:28);return r.jsxs("div",{className:ct("space-y-2",C&&"pointer-events-none opacity-50"),children:[!F&&r.jsxs("div",{className:"group md:group",children:[r.jsx("div",{className:"md:hidden",children:r.jsxs("div",{className:ct("mx-1 flex min-h-10 items-center gap-2 px-2 py-2 text-muted-foreground transition-colors active:scale-[0.98]",Ae?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==_.name&&s(_),je(_.name)},onTouchEnd:ee(()=>{t?.name!==_.name&&s(_),je(_.name)}),children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[r.jsx("div",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:pe?r.jsx(nn,{className:ct("h-4 w-4",X?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(ea,{className:ct("h-4 w-4",X?"text-yellow-600 dark:text-yellow-400":Ae?"text-foreground":"text-muted-foreground")})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:P===_.name?r.jsx("input",{type:"text",value:ge,onChange:W=>le(W.target.value),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-primary",placeholder:b("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:W=>W.stopPropagation(),onKeyDown:W=>{W.key==="Enter"&&rt(_.name),W.key==="Escape"&&Ye()},style:{fontSize:"16px"}}):r.jsx("div",{className:ct(sa,Ae&&"font-semibold"),children:dt})})]}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:P===_.name?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:W=>{W.stopPropagation(),rt(_.name)},title:b("tooltips.save"),children:r.jsx(yr,{className:"h-3.5 w-3.5"})}),r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:W=>{W.stopPropagation(),Ye()},title:b("tooltips.cancel"),children:r.jsx(ar,{className:"h-3.5 w-3.5"})})]}):r.jsxs(js,{children:[r.jsx(Ss,{asChild:!0,children:r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md p-0 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground",onClick:W=>W.stopPropagation(),"aria-label":b("actions.settings"),children:r.jsx(bs,{className:"h-4 w-4"})})}),r.jsx(Ns,{children:r.jsxs(Cs,{side:Ot,align:rr,sideOffset:zt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:W=>W.stopPropagation(),children:[r.jsxs(gr,{className:vn,onSelect:W=>{W.preventDefault(),bt(_)},children:[r.jsx(fl,{className:"h-4 w-4"}),b("tooltips.renameProject")]}),r.jsxs(gr,{className:vn,onSelect:W=>{W.preventDefault(),et(_.name)},children:[r.jsx(gl,{className:ct("h-4 w-4",X&&"fill-yellow-400 text-yellow-500")}),b(X?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx(vl,{className:"my-1 h-px bg-border"}),r.jsxs(gr,{className:Es,onSelect:W=>{W.preventDefault(),Pt(_)},children:[r.jsx(pr,{className:"h-4 w-4"}),b("tooltips.deleteProject")]})]})})]})})]})}),r.jsxs("div",{role:"button",tabIndex:0,className:ct("group relative hidden w-full items-center justify-start gap-2 px-2 py-2 text-left font-normal text-muted-foreground transition-colors md:flex",P===_.name?"h-auto":"h-9",Ae?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==_.name&&s(_),je(_.name)},onTouchEnd:ee(()=>{t?.name!==_.name&&s(_),je(_.name)}),onKeyDown:W=>{(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),t?.name!==_.name&&s(_),je(_.name))},title:_.fullPath||be,children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[r.jsx("div",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:pe?r.jsx(nn,{className:ct("h-4 w-4",X?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(ea,{className:ct("h-4 w-4",X?"text-yellow-600 dark:text-yellow-400":Ae?"text-foreground":"text-muted-foreground")})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-hidden text-left",children:P===_.name?r.jsx("input",{type:"text",value:ge,onChange:W=>le(W.target.value),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-primary",placeholder:b("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:W=>{W.key==="Enter"&&rt(_.name),W.key==="Escape"&&Ye()},onClick:W=>W.stopPropagation()}):r.jsx("div",{className:ct(sa,Ae&&"font-semibold"),children:dt})})]}),r.jsx("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:P===_.name?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:W=>{W.stopPropagation(),rt(_.name)},title:b("tooltips.save"),children:r.jsx(yr,{className:"h-3.5 w-3.5"})}),r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:W=>{W.stopPropagation(),Ye()},title:b("tooltips.cancel"),children:r.jsx(ar,{className:"h-3.5 w-3.5"})})]}):r.jsxs(js,{children:[r.jsx(Ss,{asChild:!0,children:r.jsx("button",{className:ct("flex h-7 w-7 items-center justify-center rounded-md p-0 text-muted-foreground transition-all hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground"),onClick:W=>W.stopPropagation(),"aria-label":b("actions.settings"),children:r.jsx(bs,{className:"h-4 w-4"})})}),r.jsx(Ns,{children:r.jsxs(Cs,{side:Ot,align:rr,sideOffset:zt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:W=>W.stopPropagation(),children:[r.jsxs(gr,{className:vn,onSelect:W=>{W.preventDefault(),bt(_)},children:[r.jsx(fl,{className:"h-4 w-4"}),b("tooltips.renameProject")]}),r.jsxs(gr,{className:vn,onSelect:W=>{W.preventDefault(),et(_.name)},children:[r.jsx(gl,{className:ct("h-4 w-4",X&&"fill-yellow-400 text-yellow-500")}),b(X?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx(vl,{className:"my-1 h-px bg-border"}),r.jsxs(gr,{className:Es,onSelect:W=>{W.preventDefault(),Pt(_)},children:[r.jsx(pr,{className:"h-4 w-4"}),b("tooltips.deleteProject")]})]})})]})})]})]}),ie&&r.jsxs("div",{className:ct("space-y-1",F?"px-1 md:px-0":"px-0"),children:[qe.has(_.name)?Je(_).length===0&&!M[_.name]?r.jsx("div",{className:"px-3 py-2 text-left",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:b("sessions.noSessions")})}):Je(_).map(W=>{const Et=W.__provider==="codex",$=W.__provider==="gemini",z=W.__provider==="opencode",ne=Et||$||z,Re=ke===W.id&&!Et,I=n?.id===W.id,Q=Et?W.summary||W.name||b("projects.codexSession"):z?W.summary||W.name||b("projects.opencodeSession"):W.summary||W.name||b("projects.newSession"),te=ne&&W.createdAt||W.lastActivity,ye=Fe===W.id||ce===W.id;return r.jsxs("div",{className:"group/session relative w-full min-w-0 max-w-full",onMouseEnter:()=>Ce(W.id),onMouseLeave:()=>Ce(H=>H===W.id?null:H),children:[r.jsx("div",{className:"w-full min-w-0 max-w-full md:hidden",children:r.jsxs("div",{className:ct("mx-1 grid min-h-9 min-w-0 grid-cols-[auto,minmax(0,1fr),auto] items-center gap-2 overflow-hidden rounded-lg px-2 py-2 transition-colors",I?"chat-sidebar-item-active":"chat-sidebar-item"),onClick:()=>{s(_),_e(W,_.name)},onTouchEnd:ee(()=>{s(_),_e(W,_.name)}),children:[r.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:r.jsx(bl,{provider:W.__provider})}),r.jsx("div",{className:"min-w-0 flex-1 basis-0 overflow-hidden",children:Re?r.jsx("input",{type:"text",value:R,onChange:H=>re(H.target.value),onKeyDown:H=>{H.stopPropagation(),H.key==="Enter"?updateSessionSummary(_.name,W.id,R):H.key==="Escape"&&(ve(null),re(""))},onClick:H=>H.stopPropagation(),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}):r.jsx("div",{className:sa,title:Q,children:Q})}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:Re?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:H=>{H.stopPropagation(),updateSessionSummary(_.name,W.id,R)},title:b("tooltips.save"),children:r.jsx(yr,{className:"h-3.5 w-3.5"})}),r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:H=>{H.stopPropagation(),ve(null),re("")},title:b("tooltips.cancel"),children:r.jsx(ar,{className:"h-3.5 w-3.5"})})]}):r.jsx(r.Fragment,{children:r.jsxs(js,{children:[r.jsx(Ss,{asChild:!0,children:r.jsx("button",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md p-0 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground",onClick:H=>H.stopPropagation(),"aria-label":b("actions.settings"),children:r.jsx(bs,{className:"h-4 w-4"})})}),r.jsx(Ns,{children:r.jsxs(Cs,{side:Ot,align:rr,sideOffset:zt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:H=>H.stopPropagation(),children:[!Et&&r.jsxs(gr,{className:vn,onSelect:H=>{H.preventDefault(),ve(W.id),re(W.summary||W.name||b("projects.newSession"))},children:[r.jsx(hl,{className:"h-4 w-4"}),b("tooltips.editSessionName")]}),r.jsxs(gr,{className:Es,onSelect:H=>{H.preventDefault(),Ue(_.name,W.id,Q,W.__provider)},children:[r.jsx(pr,{className:"h-4 w-4"}),b("tooltips.deleteSession")]})]})})]})})})]})}),r.jsx("div",{className:"hidden w-full min-w-0 max-w-full md:block",children:r.jsxs("div",{className:ct("grid min-h-9 min-w-0 grid-cols-[minmax(0,1fr),auto] items-center gap-2 overflow-hidden rounded-lg px-2 py-1 transition-colors",I?"chat-sidebar-item-active":"chat-sidebar-item"),children:[r.jsxs("button",{className:"flex w-full min-w-0 items-center gap-2 overflow-hidden text-left",onClick:()=>_e(W,_.name),onTouchEnd:ee(()=>_e(W,_.name)),children:[r.jsx("span",{className:ct("flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-opacity",I||Re?"opacity-100":"opacity-0 group-hover/session:opacity-100"),children:r.jsx(bl,{provider:W.__provider})}),Re?r.jsx("input",{type:"text",value:R,onChange:H=>re(H.target.value),onKeyDown:H=>{H.stopPropagation(),H.key==="Enter"?updateSessionSummary(_.name,W.id,R):H.key==="Escape"&&(ve(null),re(""))},onClick:H=>H.stopPropagation(),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}):r.jsx("span",{className:"block min-w-0 w-full flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-sm text-foreground",title:Q,children:Q})]}),r.jsx("div",{className:"flex shrink-0 items-center justify-end pl-1",children:Re?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:H=>{H.stopPropagation(),updateSessionSummary(_.name,W.id,R)},title:b("tooltips.save"),children:r.jsx(yr,{className:"h-3.5 w-3.5"})}),r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:H=>{H.stopPropagation(),ve(null),re("")},title:b("tooltips.cancel"),children:r.jsx(ar,{className:"h-3.5 w-3.5"})})]}):r.jsx(r.Fragment,{children:ye?r.jsxs(js,{onOpenChange:H=>$e(H?W.id:null),children:[r.jsx(Ss,{asChild:!0,children:r.jsx("button",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md p-0 text-muted-foreground transition-all hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground",onClick:H=>H.stopPropagation(),onFocus:()=>Ce(W.id),"aria-label":b("actions.settings"),children:r.jsx(bs,{className:"h-4 w-4"})})}),r.jsx(Ns,{children:r.jsxs(Cs,{side:Ot,align:rr,sideOffset:zt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:H=>H.stopPropagation(),children:[!Et&&r.jsxs(gr,{className:vn,onSelect:H=>{H.preventDefault(),ve(W.id),re(W.summary||W.name||b("projects.newSession"))},children:[r.jsx(hl,{className:"h-4 w-4"}),b("tooltips.editSessionName")]}),r.jsxs(gr,{className:Es,onSelect:H=>{H.preventDefault(),Ue(_.name,W.id,Q,W.__provider)},children:[r.jsx(pr,{className:"h-4 w-4"}),b("tooltips.deleteSession")]})]})})]}):r.jsx("span",{className:"text-[11px] text-muted-foreground",children:qx(te,U,b)})})})]})})]},W.id)}):Array.from({length:3}).map((W,Et)=>r.jsx("div",{className:"flex h-9 items-center rounded-lg px-3",children:r.jsx("div",{className:"h-3 w-full animate-pulse rounded bg-muted",style:{width:`${60+Et*15}%`}})},Et)),Je(_).length>0&&_.sessionMeta?.hasMore!==!1&&r.jsx(De,{variant:"subtle",size:"sm",className:"mt-2 w-full justify-center gap-2 rounded-xl text-muted-foreground hover:text-foreground",onClick:()=>Ct(_),disabled:M[_.name],children:M[_.name]?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),b("sessions.loading")]}):r.jsxs(r.Fragment,{children:[r.jsx(Tr,{className:"w-3 h-3"}),b("sessions.showMore")]})})]})]},_.name)})})}),m&&r.jsxs("div",{className:"px-3 py-3 flex-shrink-0",children:[r.jsx("div",{className:"hidden md:block",children:r.jsxs(De,{variant:"ghost",className:"mb-2 h-auto w-full justify-start gap-3 rounded-lg bg-blue-50/90 p-3 text-left font-normal transition-colors duration-200 hover:bg-blue-100 dark:bg-blue-900/20 dark:hover:bg-blue-900/30",onClick:j,children:[r.jsxs("div",{className:"relative",children:[r.jsx("svg",{className:"w-4 h-4 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})}),r.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:x?.title||`Version ${h}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:b("version.updateAvailable")})]})]})}),r.jsx("div",{className:"md:hidden p-3 pb-2",children:r.jsxs("button",{className:"flex h-12 w-full items-center justify-start gap-3 rounded-xl bg-blue-50 dark:bg-blue-900/20 px-4 transition-all duration-150 active:scale-[0.98]",onClick:j,children:[r.jsxs("div",{className:"relative",children:[r.jsx("svg",{className:"w-5 h-5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})}),r.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),r.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[r.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:x?.title||`Version ${h}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:b("version.updateAvailable")})]})]})})]}),r.jsx("div",{className:"md:p-2 flex-shrink-0",children:r.jsxs("div",{className:"hidden md:flex items-center justify-between gap-2",children:[!Xe&&r.jsxs(De,{variant:"ghost",className:"flex h-10 flex-1 items-center justify-center gap-2 rounded-xl bg-background/80 px-3 font-normal text-muted-foreground transition-colors duration-200 hover:bg-background hover:text-foreground",onClick:()=>N(!0),title:b("tooltips.createProject"),children:[r.jsx(rn,{className:"w-4 h-4"}),r.jsx("span",{className:"text-xs leading-none",children:b("projects.newProject").includes("Project")?"New":b("projects.newProject").substring(0,2)})]}),r.jsxs(De,{variant:"ghost",className:"flex h-10 flex-1 items-center justify-center gap-2 rounded-xl bg-background/80 px-3 font-normal text-muted-foreground transition-colors duration-200 hover:bg-background hover:text-foreground",onClick:async()=>{Z(!0);try{await p()}finally{Z(!1)}},disabled:B,title:b("tooltips.refresh"),children:[r.jsx(Ar,{className:`w-4 h-4 ${B?"animate-spin":""}`}),r.jsx("span",{className:"text-xs leading-none",children:b("actions.refresh")||"Sync"})]})]})})]})]})}var oa={exports:{}},aa,kl;function Gx(){if(kl)return aa;kl=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return aa=e,aa}var ia,jl;function Kx(){if(jl)return ia;jl=1;var e=Gx();function t(){}function n(){}return n.resetWarningCache=t,ia=function(){function s(i,c,d,u,p,m){if(m!==e){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}s.isRequired=s;function o(){return s}var a={array:s,bigint:s,bool:s,func:s,number:s,object:s,string:s,symbol:s,any:s,arrayOf:o,element:s,elementType:s,instanceOf:o,node:s,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a},ia}var Sl;function Jx(){return Sl||(Sl=1,oa.exports=Kx()()),oa.exports}var Yx=Jx();const lt=_c(Yx),Xx=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function En(e,t,n){const s=Qx(e),{webkitRelativePath:o}=e,a=typeof t=="string"?t:typeof o=="string"&&o.length>0?o:`./${e.name}`;return typeof s.path!="string"&&Nl(s,"path",a),Nl(s,"relativePath",a),s}function Qx(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const s=t.split(".").pop().toLowerCase(),o=Xx.get(s);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e}function Nl(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}const Zx=[".DS_Store","Thumbs.db"];function e0(e){return ln(this,void 0,void 0,function*(){return qs(e)&&t0(e.dataTransfer)?o0(e.dataTransfer,e.type):r0(e)?n0(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?s0(e):[]})}function t0(e){return qs(e)}function r0(e){return qs(e)&&qs(e.target)}function qs(e){return typeof e=="object"&&e!==null}function n0(e){return Ta(e.target.files).map(t=>En(t))}function s0(e){return ln(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>n.getFile()))).map(n=>En(n))})}function o0(e,t){return ln(this,void 0,void 0,function*(){if(e.items){const n=Ta(e.items).filter(o=>o.kind==="file");if(t!=="drop")return n;const s=yield Promise.all(n.map(a0));return Cl(ou(s))}return Cl(Ta(e.files).map(n=>En(n)))})}function Cl(e){return e.filter(t=>Zx.indexOf(t.name)===-1)}function Ta(e){if(e===null)return[];const t=[];for(let n=0;n<e.length;n++){const s=e[n];t.push(s)}return t}function a0(e){if(typeof e.webkitGetAsEntry!="function")return El(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?au(t):El(e,t)}function ou(e){return e.reduce((t,n)=>[...t,...Array.isArray(n)?ou(n):[n]],[])}function El(e,t){return ln(this,void 0,void 0,function*(){var n;if(globalThis.isSecureContext&&typeof e.getAsFileSystemHandle=="function"){const a=yield e.getAsFileSystemHandle();if(a===null)throw new Error(`${e} is not a File`);if(a!==void 0){const i=yield a.getFile();return i.handle=a,En(i)}}const s=e.getAsFile();if(!s)throw new Error(`${e} is not a File`);return En(s,(n=t?.fullPath)!==null&&n!==void 0?n:void 0)})}function i0(e){return ln(this,void 0,void 0,function*(){return e.isDirectory?au(e):l0(e)})}function au(e){const t=e.createReader();return new Promise((n,s)=>{const o=[];function a(){t.readEntries(i=>ln(this,void 0,void 0,function*(){if(i.length){const c=Promise.all(i.map(i0));o.push(c),a()}else try{const c=yield Promise.all(o);n(c)}catch(c){s(c)}}),i=>{s(i)})}a()})}function l0(e){return ln(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(s=>{const o=En(s,e.fullPath);t(o)},s=>{n(s)})})})}var Is={},Il;function c0(){return Il||(Il=1,Is.__esModule=!0,Is.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var s=e.name||"",o=(e.type||"").toLowerCase(),a=o.replace(/\/.*$/,"");return n.some(function(i){var c=i.trim().toLowerCase();return c.charAt(0)==="."?s.toLowerCase().endsWith(c):c.endsWith("/*")?a===c.replace(/\/.*$/,""):o===c})}return!0}),Is}var d0=c0();const la=_c(d0);function Al(e){return m0(e)||p0(e)||lu(e)||u0()}function u0(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
232
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function p0(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function m0(e){if(Array.isArray(e))return _a(e)}function Tl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function _l(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Tl(Object(n),!0).forEach(function(s){iu(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tl(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function iu(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Jn(e,t){return g0(e)||h0(e,t)||lu(e,t)||f0()}function f0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
233
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lu(e,t){if(e){if(typeof e=="string")return _a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _a(e,t)}}function _a(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function h0(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,i,c;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(d){a=!0,c=d}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw c}}return s}}function g0(e){if(Array.isArray(e))return e}var x0=typeof la=="function"?la:la.default,v0="file-invalid-type",y0="file-too-large",b0="file-too-small",w0="too-many-files",k0=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=t.split(","),s=n.length>1?"one of ".concat(n.join(", ")):n[0];return{code:v0,message:"File type must be ".concat(s)}},Ml=function(t){return{code:y0,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},Dl=function(t){return{code:b0,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},j0={code:w0,message:"Too many files"};function cu(e,t){var n=e.type==="application/x-moz-file"||x0(e,t);return[n,n?null:k0(t)]}function du(e,t,n){if(en(e.size))if(en(t)&&en(n)){if(e.size>n)return[!1,Ml(n)];if(e.size<t)return[!1,Dl(t)]}else{if(en(t)&&e.size<t)return[!1,Dl(t)];if(en(n)&&e.size>n)return[!1,Ml(n)]}return[!0,null]}function en(e){return e!=null}function S0(e){var t=e.files,n=e.accept,s=e.minSize,o=e.maxSize,a=e.multiple,i=e.maxFiles,c=e.validator;return!a&&t.length>1||a&&i>=1&&t.length>i?!1:t.every(function(d){var u=cu(d,n),p=Jn(u,1),m=p[0],h=du(d,s,o),g=Jn(h,1),x=g[0],j=c?c(d):null;return m&&x&&!j})}function Vs(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function As(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(t){return t==="Files"||t==="application/x-moz-file"}):!!e.target&&!!e.target.files}function Rl(e){e.preventDefault()}function N0(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function C0(e){return e.indexOf("Edge/")!==-1}function E0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return N0(e)||C0(e)}function xr(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(s){for(var o=arguments.length,a=new Array(o>1?o-1:0),i=1;i<o;i++)a[i-1]=arguments[i];return t.some(function(c){return!Vs(s)&&c&&c.apply(void 0,[s].concat(a)),Vs(s)})}}function I0(){return"showOpenFilePicker"in window}function A0(e){if(en(e)){var t=Object.entries(e).filter(function(n){var s=Jn(n,2),o=s[0],a=s[1],i=!0;return uu(o)||(console.warn('Skipped "'.concat(o,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),i=!1),(!Array.isArray(a)||!a.every(pu))&&(console.warn('Skipped "'.concat(o,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(n,s){var o=Jn(s,2),a=o[0],i=o[1];return _l(_l({},n),{},iu({},a,i))},{});return[{description:"Files",accept:t}]}return e}function T0(e){if(en(e))return Object.entries(e).reduce(function(t,n){var s=Jn(n,2),o=s[0],a=s[1];return[].concat(Al(t),[o],Al(a))},[]).filter(function(t){return uu(t)||pu(t)}).join(",")}function _0(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function M0(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function uu(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||e==="application/*"||/\w+\/[-+.\w]+/g.test(e)}function pu(e){return/^.*\.[\w]+$/.test(e)}var D0=["children"],R0=["open"],P0=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],L0=["refKey","onChange","onClick"];function O0(e){return B0(e)||$0(e)||mu(e)||F0()}function F0(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
234
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $0(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function B0(e){if(Array.isArray(e))return Ma(e)}function ca(e,t){return W0(e)||U0(e,t)||mu(e,t)||z0()}function z0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
235
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mu(e,t){if(e){if(typeof e=="string")return Ma(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ma(e,t)}}function Ma(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function U0(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,i,c;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(d){a=!0,c=d}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw c}}return s}}function W0(e){if(Array.isArray(e))return e}function Pl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function vt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Pl(Object(n),!0).forEach(function(s){Da(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pl(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function Da(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Gs(e,t){if(e==null)return{};var n=H0(e,t),s,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)s=a[o],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(n[s]=e[s])}return n}function H0(e,t){if(e==null)return{};var n={},s=Object.keys(e),o,a;for(a=0;a<s.length;a++)o=s[a],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var hi=l.forwardRef(function(e,t){var n=e.children,s=Gs(e,D0),o=hu(s),a=o.open,i=Gs(o,R0);return l.useImperativeHandle(t,function(){return{open:a}},[a]),Mn.createElement(l.Fragment,null,n(vt(vt({},i),{},{open:a})))});hi.displayName="Dropzone";var fu={disabled:!1,getFilesFromEvent:e0,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};hi.defaultProps=fu;hi.propTypes={children:lt.func,accept:lt.objectOf(lt.arrayOf(lt.string)),multiple:lt.bool,preventDropOnDocument:lt.bool,noClick:lt.bool,noKeyboard:lt.bool,noDrag:lt.bool,noDragEventsBubbling:lt.bool,minSize:lt.number,maxSize:lt.number,maxFiles:lt.number,disabled:lt.bool,getFilesFromEvent:lt.func,onFileDialogCancel:lt.func,onFileDialogOpen:lt.func,useFsAccessApi:lt.bool,autoFocus:lt.bool,onDragEnter:lt.func,onDragLeave:lt.func,onDragOver:lt.func,onDrop:lt.func,onDropAccepted:lt.func,onDropRejected:lt.func,onError:lt.func,validator:lt.func};var Ra={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function hu(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=vt(vt({},fu),e),n=t.accept,s=t.disabled,o=t.getFilesFromEvent,a=t.maxSize,i=t.minSize,c=t.multiple,d=t.maxFiles,u=t.onDragEnter,p=t.onDragLeave,m=t.onDragOver,h=t.onDrop,g=t.onDropAccepted,x=t.onDropRejected,j=t.onFileDialogCancel,k=t.onFileDialogOpen,A=t.useFsAccessApi,T=t.autoFocus,w=t.preventDropOnDocument,D=t.noClick,N=t.noKeyboard,b=t.noDrag,L=t.noDragEventsBubbling,q=t.onError,P=t.validator,Y=l.useMemo(function(){return T0(n)},[n]),ge=l.useMemo(function(){return A0(n)},[n]),le=l.useMemo(function(){return typeof k=="function"?k:Ll},[k]),M=l.useMemo(function(){return typeof j=="function"?j:Ll},[j]),V=l.useRef(null),xe=l.useRef(null),Ie=l.useReducer(q0,Ra),qe=ca(Ie,2),Se=qe[0],U=qe[1],fe=Se.isFocused,O=Se.isFileDialogActive,S=l.useRef(typeof window<"u"&&window.isSecureContext&&A&&I0()),B=function(){!S.current&&O&&setTimeout(function(){if(xe.current){var ee=xe.current.files;ee.length||(U({type:"closeDialog"}),M())}},300)};l.useEffect(function(){return window.addEventListener("focus",B,!1),function(){window.removeEventListener("focus",B,!1)}},[xe,O,M,S]);var Z=l.useRef([]),ke=function(ee){V.current&&V.current.contains(ee.target)||(ee.preventDefault(),Z.current=[])};l.useEffect(function(){return w&&(document.addEventListener("dragover",Rl,!1),document.addEventListener("drop",ke,!1)),function(){w&&(document.removeEventListener("dragover",Rl),document.removeEventListener("drop",ke))}},[V,w]),l.useEffect(function(){return!s&&T&&V.current&&V.current.focus(),function(){}},[V,T,s]);var ve=l.useCallback(function(J){q?q(J):console.error(J)},[q]),R=l.useCallback(function(J){J.preventDefault(),J.persist(),Ke(J),Z.current=[].concat(O0(Z.current),[J.target]),As(J)&&Promise.resolve(o(J)).then(function(ee){if(!(Vs(J)&&!L)){var je=ee.length,_e=je>0&&S0({files:ee,accept:Y,minSize:i,maxSize:a,multiple:c,maxFiles:d,validator:P}),et=je>0&&!_e;U({isDragAccept:_e,isDragReject:et,isDragActive:!0,type:"setDraggedFiles"}),u&&u(J)}}).catch(function(ee){return ve(ee)})},[o,u,ve,L,Y,i,a,c,d,P]),re=l.useCallback(function(J){J.preventDefault(),J.persist(),Ke(J);var ee=As(J);if(ee&&J.dataTransfer)try{J.dataTransfer.dropEffect="copy"}catch{}return ee&&m&&m(J),!1},[m,L]),Fe=l.useCallback(function(J){J.preventDefault(),J.persist(),Ke(J);var ee=Z.current.filter(function(_e){return V.current&&V.current.contains(_e)}),je=ee.indexOf(J.target);je!==-1&&ee.splice(je,1),Z.current=ee,!(ee.length>0)&&(U({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),As(J)&&p&&p(J))},[V,p,L]),Ce=l.useCallback(function(J,ee){var je=[],_e=[];J.forEach(function(et){var tt=cu(et,Y),Je=ca(tt,2),Mt=Je[0],ue=Je[1],bt=du(et,i,a),Ye=ca(bt,2),rt=Ye[0],Ue=Ye[1],Nt=P?P(et):null;if(Mt&&rt&&!Nt)je.push(et);else{var Pt=[ue,Ue];Nt&&(Pt=Pt.concat(Nt)),_e.push({file:et,errors:Pt.filter(function(ht){return ht})})}}),(!c&&je.length>1||c&&d>=1&&je.length>d)&&(je.forEach(function(et){_e.push({file:et,errors:[j0]})}),je.splice(0)),U({acceptedFiles:je,fileRejections:_e,isDragReject:_e.length>0,type:"setFiles"}),h&&h(je,_e,ee),_e.length>0&&x&&x(_e,ee),je.length>0&&g&&g(je,ee)},[U,c,Y,i,a,d,h,g,x,P]),ce=l.useCallback(function(J){J.preventDefault(),J.persist(),Ke(J),Z.current=[],As(J)&&Promise.resolve(o(J)).then(function(ee){Vs(J)&&!L||Ce(ee,J)}).catch(function(ee){return ve(ee)}),U({type:"reset"})},[o,Ce,ve,L]),$e=l.useCallback(function(){if(S.current){U({type:"openDialog"}),le();var J={multiple:c,types:ge};window.showOpenFilePicker(J).then(function(ee){return o(ee)}).then(function(ee){Ce(ee,null),U({type:"closeDialog"})}).catch(function(ee){_0(ee)?(M(ee),U({type:"closeDialog"})):M0(ee)?(S.current=!1,xe.current?(xe.current.value=null,xe.current.click()):ve(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):ve(ee)});return}xe.current&&(U({type:"openDialog"}),le(),xe.current.value=null,xe.current.click())},[U,le,M,A,Ce,ve,ge,c]),ft=l.useCallback(function(J){!V.current||!V.current.isEqualNode(J.target)||(J.key===" "||J.key==="Enter"||J.keyCode===32||J.keyCode===13)&&(J.preventDefault(),$e())},[V,$e]),at=l.useCallback(function(){U({type:"focus"})},[]),Ve=l.useCallback(function(){U({type:"blur"})},[]),Ze=l.useCallback(function(){D||(E0()?setTimeout($e,0):$e())},[D,$e]),yt=function(ee){return s?null:ee},Tt=function(ee){return N?null:yt(ee)},he=function(ee){return b?null:yt(ee)},Ke=function(ee){L&&ee.stopPropagation()},_t=l.useMemo(function(){return function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ee=J.refKey,je=ee===void 0?"ref":ee,_e=J.role,et=J.onKeyDown,tt=J.onFocus,Je=J.onBlur,Mt=J.onClick,ue=J.onDragEnter,bt=J.onDragOver,Ye=J.onDragLeave,rt=J.onDrop,Ue=Gs(J,P0);return vt(vt(Da({onKeyDown:Tt(xr(et,ft)),onFocus:Tt(xr(tt,at)),onBlur:Tt(xr(Je,Ve)),onClick:yt(xr(Mt,Ze)),onDragEnter:he(xr(ue,R)),onDragOver:he(xr(bt,re)),onDragLeave:he(xr(Ye,Fe)),onDrop:he(xr(rt,ce)),role:typeof _e=="string"&&_e!==""?_e:"presentation"},je,V),!s&&!N?{tabIndex:0}:{}),Ue)}},[V,ft,at,Ve,Ze,R,re,Fe,ce,N,b,s]),kt=l.useCallback(function(J){J.stopPropagation()},[]),St=l.useMemo(function(){return function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ee=J.refKey,je=ee===void 0?"ref":ee,_e=J.onChange,et=J.onClick,tt=Gs(J,L0),Je=Da({accept:Y,multiple:c,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:yt(xr(_e,ce)),onClick:yt(xr(et,kt)),tabIndex:-1},je,xe);return vt(vt({},Je),tt)}},[xe,n,c,ce,s]);return vt(vt({},Se),{},{isFocused:fe&&!s,getRootProps:_t,getInputProps:St,rootRef:V,inputRef:xe,open:yt($e)})}function q0(e,t){switch(t.type){case"focus":return vt(vt({},e),{},{isFocused:!0});case"blur":return vt(vt({},e),{},{isFocused:!1});case"openDialog":return vt(vt({},Ra),{},{isFileDialogActive:!0});case"closeDialog":return vt(vt({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return vt(vt({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return vt(vt({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:t.isDragReject});case"reset":return vt({},Ra);default:return e}}function Ll(){}const zn=({children:e,content:t,position:n="top",className:s="",delay:o=500})=>{const[a,i]=l.useState(!1),[c,d]=l.useState(null),u=()=>{const g=setTimeout(()=>{i(!0)},o);d(g)},p=()=>{c&&(clearTimeout(c),d(null)),i(!1)},m=()=>{switch(n){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},h=()=>{switch(n){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return t?r.jsxs("div",{className:"relative inline-block",onMouseEnter:u,onMouseLeave:p,children:[e,a&&r.jsxs("div",{className:ct("absolute z-50 w-max max-w-[min(32rem,calc(100vw-2rem))] px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-normal break-words pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",m(),s),children:[t,r.jsx("div",{className:ct("absolute w-0 h-0 border-4 border-transparent",h())})]})]}):e};function V0(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ol(e){return e==null?null:typeof e=="string"?{content:e,isError:!1,toolUseResult:null}:{content:V0(e.content??e.output??e.result??""),isError:!!e.isError,toolUseResult:e.toolUseResult||null,exitCode:e.exitCode??e.exit_code}}function Fl(e,t){return e||""}function G0(e){const t=String(e||"").replace(/\\\s*\n\s*/g," ").trim();if(!t)return"";const s=t.split(/\s*(?:&&|\|\||;|\|)\s*/).map(o=>o.trim()).filter(Boolean).map(o=>o.split(/\s+/)[0]).filter(Boolean);return s.length===0?t:s.slice(0,4).join(" · ")+(s.length>4?"…":"")}function K0(e,t,n){return t?.file_path?t.file_path:t?.path?t.path:e==="Read"&&typeof n=="string"?n:""}function J0(e,t,n,s){const o=K0(e,t,t),a=Fl(o);if(e==="Bash"){const i=t?.command||"";return{activityKind:"command",title:s("activity.actions.runCommand"),summary:G0(i)||s("activity.actions.commandPending"),filePath:o,icon:eh,heavy:!0}}if(e==="Grep"||e==="Glob"){const i=t?.pattern||t?.glob||"",c=Fl(t?.path||""),d=[];return i&&d.push(i),c&&d.push(c),{activityKind:"search",title:s("activity.actions.searchContent"),summary:d.join(" · ")||s("activity.actions.searchPending"),filePath:t?.path||"",icon:Na,heavy:!1}}return e==="Read"?{activityKind:"read",title:s("activity.actions.readFile"),summary:a||s("activity.actions.readPending"),filePath:o,icon:xf,heavy:!1}:e==="Edit"||e==="ApplyPatch"?{activityKind:"edit",title:s("activity.actions.updateFile"),summary:a||s("activity.actions.filePending"),filePath:o,icon:mf,heavy:!0}:e==="Write"?{activityKind:"write",title:s("activity.actions.createFile"),summary:a||s("activity.actions.filePending"),filePath:o,icon:hf,heavy:!0}:e==="TodoWrite"?{activityKind:"todo-write",title:s("activity.actions.updateTodo"),summary:s("activity.actions.todoSummary"),filePath:"",icon:ml,heavy:!0}:e==="TodoRead"?{activityKind:"todo-read",title:s("activity.actions.readTodo"),summary:s("activity.actions.todoSummary"),filePath:"",icon:ml,heavy:!1}:e==="exit_plan_mode"?{activityKind:"plan",title:s("activity.actions.generatePlan"),summary:s("activity.actions.planSummary"),filePath:"",icon:ni,heavy:!0}:{activityKind:"tool",title:s("activity.actions.runTool"),summary:e,filePath:o,icon:ih,heavy:!0}}function Y0({children:e,tone:t="default"}){const n=t==="danger"?"border-red-200/70 bg-red-50/80 text-red-900 dark:border-red-900/70 dark:bg-red-950/20 dark:text-red-100":"border-border/70 bg-muted/40 text-foreground";return r.jsx("pre",{className:ct("overflow-x-auto rounded-lg border px-3 py-2 text-xs whitespace-pre-wrap break-words font-mono",n),children:e})}function X0({status:e,messages:t=[],pendingPermissionRequests:n=[],t:s}){if(n.length>0){const a=n[0];return{phaseText:s("activity.stage.waitingPermission"),detailText:s("activity.requestTool",{tool:a.toolName||s("messageTypes.tool")}),canAbort:!0,startedAt:e?.startedAt||Date.now()}}const o=[...t].reverse().find(a=>a?.isToolUse);if(o&&!Ol(o.toolResult)){const a=ti(o.toolInput)||{},i=Ol(o.toolResult),c=J0(o.toolName,a,null,s);return{phaseText:i?.isError?s("activity.stage.toolFailed"):c.activityKind==="search"?s("activity.stage.searching"):c.activityKind==="command"?s("activity.stage.runningCommand"):c.activityKind==="edit"||c.activityKind==="write"?s("activity.stage.editingFile"):c.activityKind==="read"?s("activity.stage.readingFile"):c.activityKind.startsWith("todo")?s("activity.stage.updatingTodo"):s("activity.stage.working"),detailText:c.summary,canAbort:e?.canAbort??!0,startedAt:e?.startedAt||Date.now()}}return e||null}function Q0({request:e,permissionEntry:t,alreadyAllowed:n,rawInput:s,onAllowOnce:o,onAllowRemember:a,onDeny:i,className:c}){const{t:d}=$t("chat"),u=d(n?"activity.permission.rememberSaved":"activity.permission.remember"),p=Rc(e.toolName);return r.jsx("div",{className:ct("rounded-2xl border border-amber-200/80 bg-amber-50/85 p-4 shadow-sm dark:border-amber-900/70 dark:bg-amber-950/20",c),children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-200",children:r.jsx(Mm,{className:"h-4 w-4"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("div",{className:"text-sm font-semibold text-amber-950 dark:text-amber-100",children:d("activity.permission.title")}),r.jsx("span",{className:"rounded-full border border-amber-300/70 px-2 py-0.5 text-[11px] text-amber-700 dark:border-amber-800 dark:text-amber-200",children:p})]}),r.jsx("div",{className:"mt-1 text-xs text-amber-800 dark:text-amber-200",children:d("activity.requestTool",{tool:p||d("messageTypes.tool")})}),t?r.jsxs("div",{className:"mt-2 text-xs text-amber-700/90 dark:text-amber-300/80",children:[d("activity.permission.rule")," ",r.jsx("span",{className:"font-mono",children:t})]}):null,s?r.jsxs("details",{className:"mt-3 group",children:[r.jsxs("summary",{className:"flex cursor-pointer items-center gap-2 text-xs font-medium text-amber-800 transition-colors hover:text-amber-900 dark:text-amber-200 dark:hover:text-amber-100",children:[r.jsx(Tr,{className:"h-3.5 w-3.5 transition-transform group-open:rotate-180"}),d("activity.permission.viewInput")]}),r.jsx(Y0,{tone:"default",children:s})]}):null,r.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[r.jsx("button",{type:"button",onClick:o,className:"inline-flex items-center gap-2 rounded-md bg-amber-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-amber-700",children:d("activity.permission.allowOnce")}),r.jsx("button",{type:"button",onClick:a,disabled:!t,className:ct("inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium transition-colors",t?"border-amber-300 text-amber-800 hover:bg-amber-100 dark:border-amber-800 dark:text-amber-100 dark:hover:bg-amber-900/30":"cursor-not-allowed border-border text-muted-foreground opacity-60"),children:u}),r.jsx("button",{type:"button",onClick:i,className:"inline-flex items-center gap-2 rounded-md border border-red-300 px-3 py-1.5 text-xs font-medium text-red-700 transition-colors hover:bg-red-50 dark:border-red-900 dark:text-red-200 dark:hover:bg-red-950/20",children:d("activity.permission.deny")})]})]})]})})}function Mr(e){return Array.isArray?Array.isArray(e):vu(e)==="[object Array]"}function Z0(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function ev(e){return e==null?"":Z0(e)}function br(e){return typeof e=="string"}function gu(e){return typeof e=="number"}function tv(e){return e===!0||e===!1||rv(e)&&vu(e)=="[object Boolean]"}function xu(e){return typeof e=="object"}function rv(e){return xu(e)&&e!==null}function Zt(e){return e!=null}function da(e){return!e.trim().length}function vu(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const nv="Incorrect 'index' type",sv=e=>`Invalid value for key ${e}`,ov=e=>`Pattern length exceeds max of ${e}.`,av=e=>`Missing ${e} property in key`,iv=e=>`Property 'weight' in key '${e}' must be a positive integer`,$l=Object.prototype.hasOwnProperty;class lv{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(s=>{let o=yu(s);this._keys.push(o),this._keyMap[o.id]=o,n+=o.weight}),this._keys.forEach(s=>{s.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function yu(e){let t=null,n=null,s=null,o=1,a=null;if(br(e)||Mr(e))s=e,t=Bl(e),n=Pa(e);else{if(!$l.call(e,"name"))throw new Error(av("name"));const i=e.name;if(s=i,$l.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(iv(i));t=Bl(i),n=Pa(i),a=e.getFn}return{path:t,id:n,weight:o,src:s,getFn:a}}function Bl(e){return Mr(e)?e:e.split(".")}function Pa(e){return Mr(e)?e.join("."):e}function cv(e,t){let n=[],s=!1;const o=(a,i,c)=>{if(Zt(a))if(!i[c])n.push(a);else{let d=i[c];const u=a[d];if(!Zt(u))return;if(c===i.length-1&&(br(u)||gu(u)||tv(u)))n.push(ev(u));else if(Mr(u)){s=!0;for(let p=0,m=u.length;p<m;p+=1)o(u[p],i,c+1)}else i.length&&o(u,i,c+1)}};return o(e,br(t)?t.split("."):t,0),s?n:n[0]}const dv={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},uv={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},pv={location:0,threshold:.6,distance:100},mv={useExtendedSearch:!1,getFn:cv,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Ne={...uv,...dv,...pv,...mv};const fv=/[^ ]+/g;function hv(e=1,t=3){const n=new Map,s=Math.pow(10,t);return{get(o){const a=o.match(fv).length;if(n.has(a))return n.get(a);const i=1/Math.pow(a,.5*e),c=parseFloat(Math.round(i*s)/s);return n.set(a,c),c},clear(){n.clear()}}}class gi{constructor({getFn:t=Ne.getFn,fieldNormWeight:n=Ne.fieldNormWeight}={}){this.norm=hv(n,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((n,s)=>{this._keysMap[n.id]=s})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,br(this.docs[0])?this.docs.forEach((t,n)=>{this._addString(t,n)}):this.docs.forEach((t,n)=>{this._addObject(t,n)}),this.norm.clear())}add(t){const n=this.size();br(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,s=this.size();n<s;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(t,n){return t[this._keysMap[n]]}size(){return this.records.length}_addString(t,n){if(!Zt(t)||da(t))return;let s={v:t,i:n,n:this.norm.get(t)};this.records.push(s)}_addObject(t,n){let s={i:n,$:{}};this.keys.forEach((o,a)=>{let i=o.getFn?o.getFn(t):this.getFn(t,o.path);if(Zt(i)){if(Mr(i)){let c=[];const d=[{nestedArrIndex:-1,value:i}];for(;d.length;){const{nestedArrIndex:u,value:p}=d.pop();if(Zt(p))if(br(p)&&!da(p)){let m={v:p,i:u,n:this.norm.get(p)};c.push(m)}else Mr(p)&&p.forEach((m,h)=>{d.push({nestedArrIndex:h,value:m})})}s.$[a]=c}else if(br(i)&&!da(i)){let c={v:i,n:this.norm.get(i)};s.$[a]=c}}}),this.records.push(s)}toJSON(){return{keys:this.keys,records:this.records}}}function bu(e,t,{getFn:n=Ne.getFn,fieldNormWeight:s=Ne.fieldNormWeight}={}){const o=new gi({getFn:n,fieldNormWeight:s});return o.setKeys(e.map(yu)),o.setSources(t),o.create(),o}function gv(e,{getFn:t=Ne.getFn,fieldNormWeight:n=Ne.fieldNormWeight}={}){const{keys:s,records:o}=e,a=new gi({getFn:t,fieldNormWeight:n});return a.setKeys(s),a.setIndexRecords(o),a}function Ts(e,{errors:t=0,currentLocation:n=0,expectedLocation:s=0,distance:o=Ne.distance,ignoreLocation:a=Ne.ignoreLocation}={}){const i=t/e.length;if(a)return i;const c=Math.abs(s-n);return o?i+c/o:c?1:i}function xv(e=[],t=Ne.minMatchCharLength){let n=[],s=-1,o=-1,a=0;for(let i=e.length;a<i;a+=1){let c=e[a];c&&s===-1?s=a:!c&&s!==-1&&(o=a-1,o-s+1>=t&&n.push([s,o]),s=-1)}return e[a-1]&&a-s>=t&&n.push([s,a-1]),n}const tn=32;function vv(e,t,n,{location:s=Ne.location,distance:o=Ne.distance,threshold:a=Ne.threshold,findAllMatches:i=Ne.findAllMatches,minMatchCharLength:c=Ne.minMatchCharLength,includeMatches:d=Ne.includeMatches,ignoreLocation:u=Ne.ignoreLocation}={}){if(t.length>tn)throw new Error(ov(tn));const p=t.length,m=e.length,h=Math.max(0,Math.min(s,m));let g=a,x=h;const j=c>1||d,k=j?Array(m):[];let A;for(;(A=e.indexOf(t,x))>-1;){let L=Ts(t,{currentLocation:A,expectedLocation:h,distance:o,ignoreLocation:u});if(g=Math.min(L,g),x=A+p,j){let q=0;for(;q<p;)k[A+q]=1,q+=1}}x=-1;let T=[],w=1,D=p+m;const N=1<<p-1;for(let L=0;L<p;L+=1){let q=0,P=D;for(;q<P;)Ts(t,{errors:L,currentLocation:h+P,expectedLocation:h,distance:o,ignoreLocation:u})<=g?q=P:D=P,P=Math.floor((D-q)/2+q);D=P;let Y=Math.max(1,h-P+1),ge=i?m:Math.min(h+P,m)+p,le=Array(ge+2);le[ge+1]=(1<<L)-1;for(let V=ge;V>=Y;V-=1){let xe=V-1,Ie=n[e.charAt(xe)];if(j&&(k[xe]=+!!Ie),le[V]=(le[V+1]<<1|1)&Ie,L&&(le[V]|=(T[V+1]|T[V])<<1|1|T[V+1]),le[V]&N&&(w=Ts(t,{errors:L,currentLocation:xe,expectedLocation:h,distance:o,ignoreLocation:u}),w<=g)){if(g=w,x=xe,x<=h)break;Y=Math.max(1,2*h-x)}}if(Ts(t,{errors:L+1,currentLocation:h,expectedLocation:h,distance:o,ignoreLocation:u})>g)break;T=le}const b={isMatch:x>=0,score:Math.max(.001,w)};if(j){const L=xv(k,c);L.length?d&&(b.indices=L):b.isMatch=!1}return b}function yv(e){let t={};for(let n=0,s=e.length;n<s;n+=1){const o=e.charAt(n);t[o]=(t[o]||0)|1<<s-n-1}return t}const Ks=String.prototype.normalize?e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,""):e=>e;class wu{constructor(t,{location:n=Ne.location,threshold:s=Ne.threshold,distance:o=Ne.distance,includeMatches:a=Ne.includeMatches,findAllMatches:i=Ne.findAllMatches,minMatchCharLength:c=Ne.minMatchCharLength,isCaseSensitive:d=Ne.isCaseSensitive,ignoreDiacritics:u=Ne.ignoreDiacritics,ignoreLocation:p=Ne.ignoreLocation}={}){if(this.options={location:n,threshold:s,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:p},t=d?t:t.toLowerCase(),t=u?Ks(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const m=(g,x)=>{this.chunks.push({pattern:g,alphabet:yv(g),startIndex:x})},h=this.pattern.length;if(h>tn){let g=0;const x=h%tn,j=h-x;for(;g<j;)m(this.pattern.substr(g,tn),g),g+=tn;if(x){const k=h-tn;m(this.pattern.substr(k),k)}}else m(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,ignoreDiacritics:s,includeMatches:o}=this.options;if(t=n?t:t.toLowerCase(),t=s?Ks(t):t,this.pattern===t){let j={isMatch:!0,score:0};return o&&(j.indices=[[0,t.length-1]]),j}const{location:a,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,ignoreLocation:p}=this.options;let m=[],h=0,g=!1;this.chunks.forEach(({pattern:j,alphabet:k,startIndex:A})=>{const{isMatch:T,score:w,indices:D}=vv(t,j,k,{location:a+A,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,includeMatches:o,ignoreLocation:p});T&&(g=!0),h+=w,T&&D&&(m=[...m,...D])});let x={isMatch:g,score:g?h/this.chunks.length:1};return g&&o&&(x.indices=m),x}}class Vr{constructor(t){this.pattern=t}static isMultiMatch(t){return zl(t,this.multiRegex)}static isSingleMatch(t){return zl(t,this.singleRegex)}search(){}}function zl(e,t){const n=e.match(t);return n?n[1]:null}class bv extends Vr{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const n=t===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class wv extends Vr{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const s=t.indexOf(this.pattern)===-1;return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class kv extends Vr{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const n=t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class jv extends Vr{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const n=!t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class Sv extends Vr{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const n=t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Nv extends Vr{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const n=!t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class ku extends Vr{constructor(t,{location:n=Ne.location,threshold:s=Ne.threshold,distance:o=Ne.distance,includeMatches:a=Ne.includeMatches,findAllMatches:i=Ne.findAllMatches,minMatchCharLength:c=Ne.minMatchCharLength,isCaseSensitive:d=Ne.isCaseSensitive,ignoreDiacritics:u=Ne.ignoreDiacritics,ignoreLocation:p=Ne.ignoreLocation}={}){super(t),this._bitapSearch=new wu(t,{location:n,threshold:s,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:p})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class ju extends Vr{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,s;const o=[],a=this.pattern.length;for(;(s=t.indexOf(this.pattern,n))>-1;)n=s+a,o.push([s,n-1]);const i=!!o.length;return{isMatch:i,score:i?0:1,indices:o}}}const La=[bv,ju,kv,jv,Nv,Sv,wv,ku],Ul=La.length,Cv=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Ev="|";function Iv(e,t={}){return e.split(Ev).map(n=>{let s=n.trim().split(Cv).filter(a=>a&&!!a.trim()),o=[];for(let a=0,i=s.length;a<i;a+=1){const c=s[a];let d=!1,u=-1;for(;!d&&++u<Ul;){const p=La[u];let m=p.isMultiMatch(c);m&&(o.push(new p(m,t)),d=!0)}if(!d)for(u=-1;++u<Ul;){const p=La[u];let m=p.isSingleMatch(c);if(m){o.push(new p(m,t));break}}}return o})}const Av=new Set([ku.type,ju.type]);class Tv{constructor(t,{isCaseSensitive:n=Ne.isCaseSensitive,ignoreDiacritics:s=Ne.ignoreDiacritics,includeMatches:o=Ne.includeMatches,minMatchCharLength:a=Ne.minMatchCharLength,ignoreLocation:i=Ne.ignoreLocation,findAllMatches:c=Ne.findAllMatches,location:d=Ne.location,threshold:u=Ne.threshold,distance:p=Ne.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:s,includeMatches:o,minMatchCharLength:a,findAllMatches:c,ignoreLocation:i,location:d,threshold:u,distance:p},t=n?t:t.toLowerCase(),t=s?Ks(t):t,this.pattern=t,this.query=Iv(this.pattern,this.options)}static condition(t,n){return n.useExtendedSearch}searchIn(t){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:s,isCaseSensitive:o,ignoreDiacritics:a}=this.options;t=o?t:t.toLowerCase(),t=a?Ks(t):t;let i=0,c=[],d=0;for(let u=0,p=n.length;u<p;u+=1){const m=n[u];c.length=0,i=0;for(let h=0,g=m.length;h<g;h+=1){const x=m[h],{isMatch:j,indices:k,score:A}=x.search(t);if(j){if(i+=1,d+=A,s){const T=x.constructor.type;Av.has(T)?c=[...c,...k]:c.push(k)}}else{d=0,i=0,c.length=0;break}}if(i){let h={isMatch:!0,score:d/i};return s&&(h.indices=c),h}}return{isMatch:!1,score:1}}}const Oa=[];function _v(...e){Oa.push(...e)}function Fa(e,t){for(let n=0,s=Oa.length;n<s;n+=1){let o=Oa[n];if(o.condition(e,t))return new o(e,t)}return new wu(e,t)}const Js={AND:"$and",OR:"$or"},$a={PATH:"$path",PATTERN:"$val"},Ba=e=>!!(e[Js.AND]||e[Js.OR]),Mv=e=>!!e[$a.PATH],Dv=e=>!Mr(e)&&xu(e)&&!Ba(e),Wl=e=>({[Js.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Su(e,t,{auto:n=!0}={}){const s=o=>{let a=Object.keys(o);const i=Mv(o);if(!i&&a.length>1&&!Ba(o))return s(Wl(o));if(Dv(o)){const d=i?o[$a.PATH]:a[0],u=i?o[$a.PATTERN]:o[d];if(!br(u))throw new Error(sv(d));const p={keyId:Pa(d),pattern:u};return n&&(p.searcher=Fa(u,t)),p}let c={children:[],operator:a[0]};return a.forEach(d=>{const u=o[d];Mr(u)&&u.forEach(p=>{c.children.push(s(p))})}),c};return Ba(e)||(e=Wl(e)),s(e)}function Rv(e,{ignoreFieldNorm:t=Ne.ignoreFieldNorm}){e.forEach(n=>{let s=1;n.matches.forEach(({key:o,norm:a,score:i})=>{const c=o?o.weight:null;s*=Math.pow(i===0&&c?Number.EPSILON:i,(c||1)*(t?1:a))}),n.score=s})}function Pv(e,t){const n=e.matches;t.matches=[],Zt(n)&&n.forEach(s=>{if(!Zt(s.indices)||!s.indices.length)return;const{indices:o,value:a}=s;let i={indices:o,value:a};s.key&&(i.key=s.key.src),s.idx>-1&&(i.refIndex=s.idx),t.matches.push(i)})}function Lv(e,t){t.score=e.score}function Ov(e,t,{includeMatches:n=Ne.includeMatches,includeScore:s=Ne.includeScore}={}){const o=[];return n&&o.push(Pv),s&&o.push(Lv),e.map(a=>{const{idx:i}=a,c={item:t[i],refIndex:i};return o.length&&o.forEach(d=>{d(a,c)}),c})}class Dn{constructor(t,n={},s){this.options={...Ne,...n},this.options.useExtendedSearch,this._keyStore=new lv(this.options.keys),this.setCollection(t,s)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof gi))throw new Error(nv);this._myIndex=n||bu(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Zt(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const n=[];for(let s=0,o=this._docs.length;s<o;s+=1){const a=this._docs[s];t(a,s)&&(this.removeAt(s),s-=1,o-=1,n.push(a))}return n}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:n=-1}={}){const{includeMatches:s,includeScore:o,shouldSort:a,sortFn:i,ignoreFieldNorm:c}=this.options;let d=br(t)?br(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return Rv(d,{ignoreFieldNorm:c}),a&&d.sort(i),gu(n)&&n>-1&&(d=d.slice(0,n)),Ov(d,this._docs,{includeMatches:s,includeScore:o})}_searchStringList(t){const n=Fa(t,this.options),{records:s}=this._myIndex,o=[];return s.forEach(({v:a,i,n:c})=>{if(!Zt(a))return;const{isMatch:d,score:u,indices:p}=n.searchIn(a);d&&o.push({item:a,idx:i,matches:[{score:u,value:a,norm:c,indices:p}]})}),o}_searchLogical(t){const n=Su(t,this.options),s=(c,d,u)=>{if(!c.children){const{keyId:m,searcher:h}=c,g=this._findMatches({key:this._keyStore.get(m),value:this._myIndex.getValueForItemAtKeyId(d,m),searcher:h});return g&&g.length?[{idx:u,item:d,matches:g}]:[]}const p=[];for(let m=0,h=c.children.length;m<h;m+=1){const g=c.children[m],x=s(g,d,u);if(x.length)p.push(...x);else if(c.operator===Js.AND)return[]}return p},o=this._myIndex.records,a={},i=[];return o.forEach(({$:c,i:d})=>{if(Zt(c)){let u=s(n,c,d);u.length&&(a[d]||(a[d]={idx:d,item:c,matches:[]},i.push(a[d])),u.forEach(({matches:p})=>{a[d].matches.push(...p)}))}}),i}_searchObjectList(t){const n=Fa(t,this.options),{keys:s,records:o}=this._myIndex,a=[];return o.forEach(({$:i,i:c})=>{if(!Zt(i))return;let d=[];s.forEach((u,p)=>{d.push(...this._findMatches({key:u,value:i[p],searcher:n}))}),d.length&&a.push({idx:c,item:i,matches:d})}),a}_findMatches({key:t,value:n,searcher:s}){if(!Zt(n))return[];let o=[];if(Mr(n))n.forEach(({v:a,i,n:c})=>{if(!Zt(a))return;const{isMatch:d,score:u,indices:p}=s.searchIn(a);d&&o.push({score:u,key:t,value:a,idx:i,norm:c,indices:p})});else{const{v:a,n:i}=n,{isMatch:c,score:d,indices:u}=s.searchIn(a);c&&o.push({score:d,key:t,value:a,norm:i,indices:u})}return o}}Dn.version="7.1.0";Dn.createIndex=bu;Dn.parseIndex=gv;Dn.config=Ne;Dn.parseQuery=Su;_v(Tv);const Fv=({commands:e=[],selectedIndex:t=-1,onSelect:n,onClose:s,position:o={top:0,left:0},isOpen:a=!1,frequentCommands:i=[]})=>{const c=l.useRef(null),d=l.useRef(null),p=(()=>{const T=window.innerWidth<640,w=window.innerHeight;return T?{position:"fixed",bottom:`${o.bottom||90}px`,left:"16px",right:"16px",width:"auto",maxWidth:"calc(100vw - 32px)",maxHeight:"min(50vh, 300px)"}:{position:"fixed",top:`${Math.max(16,Math.min(o.top,w-316))}px`,left:`${o.left}px`,width:"min(400px, calc(100vw - 32px))",maxWidth:"calc(100vw - 32px)",maxHeight:"300px"}})();if(l.useEffect(()=>{const T=w=>{c.current&&!c.current.contains(w.target)&&a&&s()};if(a)return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},[a,s]),l.useEffect(()=>{if(d.current&&c.current){const T=c.current.getBoundingClientRect(),w=d.current.getBoundingClientRect();w.bottom>T.bottom?d.current.scrollIntoView({block:"nearest",behavior:"smooth"}):w.top<T.top&&d.current.scrollIntoView({block:"nearest",behavior:"smooth"})}},[t]),!a)return null;if(e.length===0)return r.jsx("div",{ref:c,className:"command-menu command-menu-empty",style:{...p,maxHeight:"300px",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"20px",opacity:1,transform:"translateY(0)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out",textAlign:"center"},children:"No commands available"});const m=i.length>0,h=e.reduce((T,w)=>{const D=w.namespace||w.type||"other";return T[D]||(T[D]=[]),T[D].push(w),T},{});m&&(h.frequent=i);const x=(m?["frequent","builtin","project","user","other"]:["builtin","project","user","other"]).filter(T=>h[T]),j={frequent:"⭐ Frequently Used",builtin:"Built-in Commands",project:"Project Commands",user:"User Commands",other:"Other Commands"};let k=0;const A=[];return x.forEach(T=>{h[T].forEach(w=>{A.push({...w,globalIndex:k++,namespace:T})})}),r.jsxs("div",{ref:c,role:"listbox","aria-label":"Available commands",className:"command-menu",style:{...p,maxHeight:"300px",overflowY:"auto",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"8px",opacity:a?1:0,transform:a?"translateY(0)":"translateY(-10px)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out"},children:[x.map(T=>r.jsxs("div",{className:"command-group",children:[x.length>1&&r.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"#6b7280",padding:"8px 12px 4px",letterSpacing:"0.05em"},children:j[T]||T}),h[T].map(w=>{const D=A.find(b=>b.name===w.name&&b.namespace===T),N=D&&D.globalIndex===t;return r.jsxs("div",{ref:N?d:null,role:"option","aria-selected":N,className:"command-item",onMouseEnter:()=>n&&n(w,D.globalIndex,!0),onClick:()=>n&&n(w,D.globalIndex,!1),style:{display:"flex",alignItems:"flex-start",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",backgroundColor:N?"#eff6ff":"transparent",transition:"background-color 100ms ease-in-out",marginBottom:"2px"},onMouseDown:b=>b.preventDefault(),children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:w.description?"4px":0},children:[r.jsxs("span",{style:{fontSize:"16px",flexShrink:0},children:[T==="builtin"&&"⚡",T==="project"&&"📁",T==="user"&&"👤",T==="other"&&"📝"]}),r.jsx("span",{style:{fontWeight:600,fontSize:"14px",color:"#111827",fontFamily:"monospace"},children:w.name}),w.metadata?.type&&r.jsx("span",{className:"command-metadata-badge",style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",backgroundColor:"#f3f4f6",color:"#6b7280",fontWeight:500},children:w.metadata.type})]}),w.description&&r.jsx("div",{style:{fontSize:"13px",color:"#6b7280",marginLeft:"24px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:w.description})]}),N&&r.jsx("span",{style:{marginLeft:"8px",color:"#3b82f6",fontSize:"12px",fontWeight:600},children:"↵"})]},`${T}-${w.name}`)})]},T)),r.jsx("style",{children:`
236
- .command-menu {
237
- background-color: white;
238
- border: 1px solid #e5e7eb;
239
- }
240
- .command-menu-empty {
241
- color: #6b7280;
242
- }
243
-
244
- @media (prefers-color-scheme: dark) {
245
- .command-menu {
246
- background-color: #1f2937 !important;
247
- border: 1px solid #374151 !important;
248
- }
249
- .command-menu-empty {
250
- color: #9ca3af !important;
251
- }
252
- .command-item[aria-selected="true"] {
253
- background-color: #1e40af !important;
254
- }
255
- .command-item span:not(.command-metadata-badge) {
256
- color: #f3f4f6 !important;
257
- }
258
- .command-metadata-badge {
259
- background-color: #f3f4f6 !important;
260
- color: #6b7280 !important;
261
- }
262
- .command-item div {
263
- color: #d1d5db !important;
264
- }
265
- .command-group > div:first-child {
266
- color: #9ca3af !important;
267
- }
268
- }
269
- `})]})},Nu={OPTIONS:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"},{value:"opusplan",label:"Opus Plan"},{value:"sonnet[1m]",label:"Sonnet [1M]"}],DEFAULT:"sonnet"},xi={OPTIONS:[{value:"gpt-5",label:"GPT-5"},{value:"gpt-5-codex",label:"GPT-5 Codex"},{value:"gpt-5-codex-mini",label:"GPT-5 Codex Mini"},{value:"gpt-5.1",label:"GPT-5.1"},{value:"gpt-5.1-codex",label:"GPT-5.1 Codex"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"gpt-5.1-codex-mini",label:"GPT-5.1 Codex Mini"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.2-codex",label:"GPT-5.2 Codex"},{value:"gpt-5.2-high",label:"GPT-5.2 High"},{value:"gpt-5.2-low",label:"GPT-5.2 Low"},{value:"gpt-5.2-medium",label:"GPT-5.2 Medium"},{value:"gpt-5.2-xhigh",label:"GPT-5.2 XHigh"},{value:"gpt-5.3-codex",label:"GPT-5.3 Codex"},{value:"gpt-5.3-codex-high",label:"GPT-5.3 Codex High"},{value:"gpt-5.3-codex-low",label:"GPT-5.3 Codex Low"},{value:"gpt-5.3-codex-medium",label:"GPT-5.3 Codex Medium"},{value:"gpt-5.3-codex-xhigh",label:"GPT-5.3 Codex XHigh"}],DEFAULT:"gpt-5.2-codex"},Cu={OPTIONS:[{value:"gemini-2.5-pro",label:"Gemini 2.5 Pro"},{value:"gemini-2.5-flash",label:"Gemini 2.5 Flash"},{value:"gemini-3-pro-preview",label:"Gemini 3 Pro Preview"},{value:"gemini-3-flash-preview",label:"Gemini 3 Flash Preview"}],DEFAULT:"gemini-3-pro-preview"},Eu={OPTIONS:[{value:"kimi-k2.5",label:"Kimi K2.5"}],DEFAULT:"kimi-k2.5"},Me={USER_MESSAGE:"user_message",ASSISTANT_TEXT_START:"assistant_text_start",ASSISTANT_TEXT_DELTA:"assistant_text_delta",ASSISTANT_TEXT_END:"assistant_text_end",REASONING_START:"reasoning_start",REASONING_DELTA:"reasoning_delta",REASONING_END:"reasoning_end",TOOL_CALL_START:"tool_call_start",TOOL_CALL_INPUT:"tool_call_input",TOOL_CALL_END:"tool_call_end",TOOL_RESULT:"tool_result",APPROVAL_REQUEST:"approval_request",APPROVAL_RESOLVED:"approval_resolved",SESSION_STATE_CHANGED:"session_state_changed",SYSTEM_NOTICE:"system_notice",ERROR:"error"};function ur(e="evt"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}:${crypto.randomUUID()}`:`${e}:${Date.now()}:${Math.random().toString(36).slice(2,10)}`}function Iu(e){if(!e)return new Date().toISOString();if(e instanceof Date)return e.toISOString();const t=new Date(e);return Number.isNaN(t.getTime())?new Date().toISOString():t.toISOString()}function Ht({kind:e,provider:t="claude",sessionId:n=null,timestamp:s,payload:o={},extensions:a={},rawRef:i=null,eventId:c=null}){return{eventId:c||ur(e),kind:e,provider:t,sessionId:n,timestamp:Iu(s),payload:o,extensions:a,rawRef:i}}function Au(e){return!!(e&&typeof e=="object"&&typeof e.kind=="string"&&typeof e.eventId=="string")}function ua({kindPrefix:e="assistant_text",text:t,provider:n,sessionId:s,timestamp:o,messageId:a,extensions:i={},rawRef:c=null}){if(typeof t!="string"||!t.trim())return[];const d=a||ur(e),u={...i,messageId:d};return[Ht({kind:`${e}_start`,provider:n,sessionId:s,timestamp:o,payload:{messageId:d},extensions:u,rawRef:c}),Ht({kind:`${e}_delta`,provider:n,sessionId:s,timestamp:o,payload:{messageId:d,text:t},extensions:u,rawRef:c}),Ht({kind:`${e}_end`,provider:n,sessionId:s,timestamp:o,payload:{messageId:d},extensions:u,rawRef:c})]}function $v(e){const t=String(e||"").trim();if(!t||t.startsWith("# AGENTS.md instructions for ")||t.includes("<environment_context>"))return"";if(t.startsWith("[DYNAMIC CONTEXT V1]")){const s=`
270
-
271
- [USER MESSAGE]
272
- `,o=t.indexOf(s);return o>=0?t.slice(o+s.length).trim():""}const n=t.match(/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i);return n?String(n[1]||"").trim():t}function pa(e){const t=String(e||"").trim();return!t||t.startsWith("[System Context]")||t.startsWith("[Attached Context]")||t.startsWith("[Dynamic Context]")||t.startsWith("[Hidden Context]")||t.startsWith("# AGENTS.md instructions for ")||t.startsWith("[DYNAMIC CONTEXT V1]")?!0:/^<dynamic_context(?:\s|>)/i.test(t)||t.includes("<environment_context>")}function bn(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e)}catch{return String(e)}}function Bv(e){const t=new Map;for(const n of e||[])if(!(n?.message?.role!=="user"||!Array.isArray(n?.message?.content)))for(const s of n.message.content)s?.type==="tool_result"&&s.tool_use_id&&t.set(s.tool_use_id,{content:s.content,isError:!!s.is_error,timestamp:n.timestamp,toolUseResult:n.toolUseResult||null});return t}function Ys(e,t){for(let n=e.length-1;n>=0;n-=1)if(t(e[n],n))return n;return-1}function Hl(e="",t=""){return t?e?e.endsWith(t)?e:`${e}${t}`:t:e}function _s(e,{messageId:t,timestamp:n,provider:s,isThinking:o=!1,kind:a="assistant"}){const i=Ys(e,d=>d?.eventMessageId===t&&!!d?.isStreaming&&!d.isToolUse&&!!d.isThinking==!!o);if(i>=0){const d={...e[i]};return d.isStreaming=!0,s&&(d.provider=s),n&&(d.timestamp=d.timestamp||n),e[i]=d,{messages:e,index:i}}const c={type:a,content:"",timestamp:n,provider:s,isStreaming:!0,eventMessageId:t};return o&&(c.isThinking=!0),e.push(c),{messages:e,index:e.length-1}}function Ms(e,{toolCallId:t,toolName:n,timestamp:s,provider:o}){const a=Ys(e,i=>i?.isToolUse&&(i.toolId===t||i.toolCallId===t));if(a>=0){const i={...e[a]};return n&&(i.toolName=n),o&&(i.provider=o),s&&!i.timestamp&&(i.timestamp=s),e[a]=i,{messages:e,index:a}}return e.push({type:"assistant",content:"",timestamp:s,provider:o,isToolUse:!0,toolName:n||"Unknown Tool",toolId:t,toolCallId:t}),{messages:e,index:e.length-1}}function zv(e=[],t="claude",n=null){if(!Array.isArray(e))return[];const s=[],o=Bv(e);for(const a of e){const i=Iu(a?.timestamp),c={provider:t,timestamp:i,type:a?.type||a?.message?.role||"unknown"};if(a?.message?.role==="user"&&a?.message?.content){let d="";Array.isArray(a.message.content)?d=a.message.content.filter(p=>p?.type==="text").map(p=>p?.text||"").join(`
273
- `):d=typeof a.message.content=="string"?a.message.content:String(a.message.content||"");const u=$v(d);u&&(!pa(d)||u!==d)&&s.push(Ht({kind:Me.USER_MESSAGE,provider:t,sessionId:n,timestamp:i,payload:{text:u},rawRef:c}));continue}if(a?.type==="thinking"&&a?.message?.content){s.push(...ua({kindPrefix:"reasoning",text:a.message.content,provider:t,sessionId:n,timestamp:i,rawRef:c}));continue}if(a?.type==="tool_use"&&a?.toolName){const d=a.toolCallId||ur("tool"),u=a.toolResult||null;s.push(Ht({kind:Me.TOOL_CALL_START,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),s.push(Ht({kind:Me.TOOL_CALL_INPUT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,input:a.toolInput||""},rawRef:c})),s.push(Ht({kind:Me.TOOL_CALL_END,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),u&&s.push(Ht({kind:Me.TOOL_RESULT,provider:t,sessionId:n,timestamp:u.timestamp||i,payload:{toolCallId:d,content:bn(u.content),isError:!!u.isError,toolUseResult:u.toolUseResult||null},rawRef:c}));continue}if(a?.type==="tool_result"){s.push(Ht({kind:Me.TOOL_RESULT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:a.toolCallId||null,content:bn(a.output||""),isError:!1},rawRef:c}));continue}if(a?.message?.role==="assistant"&&a?.message?.content){if(Array.isArray(a.message.content)){for(const d of a.message.content)if(d?.type==="text"&&!pa(d.text))s.push(...ua({text:d.text,provider:t,sessionId:n,timestamp:i,rawRef:c}));else if(d?.type==="tool_use"){const u=d.id||ur("tool"),p=o.get(d.id);s.push(Ht({kind:Me.TOOL_CALL_START,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,toolName:d.name},rawRef:c})),s.push(Ht({kind:Me.TOOL_CALL_INPUT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,input:bn(d.input||{})},rawRef:c})),s.push(Ht({kind:Me.TOOL_CALL_END,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,toolName:d.name},rawRef:c})),p&&s.push(Ht({kind:Me.TOOL_RESULT,provider:t,sessionId:n,timestamp:p.timestamp||i,payload:{toolCallId:u,content:bn(p.content),isError:!!p.isError,toolUseResult:p.toolUseResult||null},rawRef:c}))}}else pa(a.message.content)||s.push(...ua({text:a.message.content,provider:t,sessionId:n,timestamp:i,rawRef:c}));continue}a?.type&&/error/i.test(a.type)&&s.push(Ht({kind:Me.ERROR,provider:t,sessionId:n,timestamp:i,payload:{message:a.error||a.message||"Provider error"},rawRef:c}))}return s.sort((a,i)=>new Date(a.timestamp)-new Date(i.timestamp))}function Tu(e=[],t,n="claude"){const s=Array.isArray(e)?[...e]:[];if(!Au(t))return s;const o=t.provider||n,a=t.timestamp||new Date().toISOString(),i=t.payload||{};switch(t.kind){case Me.USER_MESSAGE:s.push({type:"user",content:i.text||"",timestamp:a,provider:o});break;case Me.ASSISTANT_TEXT_START:{const c=i.messageId||t.extensions?.messageId||ur("assistant_text");_s(s,{messageId:c,timestamp:a,provider:o,isThinking:!1});break}case Me.ASSISTANT_TEXT_DELTA:{const c=i.messageId||t.extensions?.messageId||ur("assistant_text"),{index:d}=_s(s,{messageId:c,timestamp:a,provider:o,isThinking:!1}),u={...s[d]};u.content=Hl(u.content||"",i.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||o,s[d]=u;break}case Me.ASSISTANT_TEXT_END:{const c=i.messageId||t.extensions?.messageId;if(!c)break;const d=Ys(s,u=>u?.eventMessageId===c&&!u.isToolUse&&!u.isThinking);d>=0&&(s[d]={...s[d],isStreaming:!1});break}case Me.REASONING_START:{const c=i.messageId||t.extensions?.messageId||ur("reasoning");_s(s,{messageId:c,timestamp:a,provider:o,isThinking:!0});break}case Me.REASONING_DELTA:{const c=i.messageId||t.extensions?.messageId||ur("reasoning"),{index:d}=_s(s,{messageId:c,timestamp:a,provider:o,isThinking:!0}),u={...s[d]};u.content=Hl(u.content||"",i.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||o,u.isThinking=!0,s[d]=u;break}case Me.REASONING_END:{const c=i.messageId||t.extensions?.messageId;if(!c)break;const d=Ys(s,u=>u?.eventMessageId===c&&!!u.isThinking);d>=0&&(s[d]={...s[d],isStreaming:!1,isThinking:!0});break}case Me.TOOL_CALL_START:{const c=i.toolCallId||ur("tool"),{index:d}=Ms(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolName:i.toolName||s[d].toolName};break}case Me.TOOL_CALL_INPUT:{const c=i.toolCallId||ur("tool"),{index:d}=Ms(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolInput:bn(i.input||""),provider:s[d].provider||o};break}case Me.TOOL_CALL_END:{const c=i.toolCallId||t.extensions?.toolCallId;if(!c)break;const{index:d}=Ms(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolName:i.toolName||s[d].toolName};break}case Me.TOOL_RESULT:{const c=i.toolCallId||t.extensions?.toolCallId||ur("tool"),{index:d}=Ms(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolResult:{content:bn(i.content||""),isError:!!i.isError,toolUseResult:i.toolUseResult||null,timestamp:a},toolError:!!i.isError,provider:s[d].provider||o};break}case Me.APPROVAL_REQUEST:i.message&&s.push({type:"assistant",content:i.message,timestamp:a,provider:o,isApprovalRequest:!0,approvalRequest:i});break;case Me.APPROVAL_RESOLVED:i.message&&s.push({type:"assistant",content:i.message,timestamp:a,provider:o,approvalResolution:i});break;case Me.SYSTEM_NOTICE:if(i.message){const c=s[s.length-1];c&&c.type==="assistant"&&!c.isToolUse&&(c.content||"").trim()===String(i.message).trim()||s.push({type:"assistant",content:i.message,timestamp:a,provider:o,isSystemNotice:!0})}break;case Me.ERROR:s.push({type:"error",content:i.message||"Provider error",timestamp:a,provider:o,rawRef:t.rawRef||null,extensions:t.extensions||{}});break}return s}function _u(e=[],t="claude"){return Array.isArray(e)?e.length>0&&!Au(e[0])?_u(zv(e,t),t):e.reduce((n,s)=>Tu(n,s,t),[]):[]}const ql={claude:{defaultMode:"default",modes:["default","acceptEdits","bypassPermissions","plan"]},codex:{defaultMode:"default",modes:["default","acceptEdits","bypassPermissions"]},gemini:{defaultMode:"default",modes:["default","acceptEdits","bypassPermissions"]},opencode:{defaultMode:"default",modes:["default","acceptEdits","bypassPermissions","plan"]}},Vl={claude:{enabled:!0,defaultMode:"none",strategy:"prompt-prefix",modes:["none","think","think-hard","think-harder","ultrathink"]},codex:{enabled:!1,defaultMode:"none",strategy:"native-effort",modes:["none"]},gemini:{enabled:!1,defaultMode:"none",strategy:"model-or-api-param",modes:["none"]},opencode:{enabled:!1,defaultMode:"none",strategy:"provider-pass-through",modes:["none"]}};function Gl(e){return ql[e]||ql.claude}function Kl(e){return Vl[e]||Vl.claude}function Uv(e){return e==="claude"||e==="codex"}function Wv(e){if(e==="think")return"low";if(e==="think-hard")return"medium";if(e==="think-harder")return"high";if(e==="ultrathink")return"xhigh"}const se={IDLE:"idle",CONNECTING:"connecting",QUEUED:"queued",STREAMING:"streaming",AWAITING_APPROVAL:"awaiting_approval",COMPLETED:"completed",ABORTED:"aborted",ERRORED:"errored"},Xs=new Set([se.CONNECTING,se.QUEUED,se.STREAMING,se.AWAITING_APPROVAL]);function Ir(e){return e==null?"":String(e).replace(/\r\n/g,`
274
- `).trim()}function Jl(e){return!e||typeof e!="object"?{content:"",isError:!1}:{content:Ir(e.content),isError:!!e.isError}}function Hv(e,t){if(!e||!t)return!1;const n=String(e.type||""),s=String(t.type||"");if(n!==s)return!1;const o=!!e.isToolUse,a=!!t.isToolUse;if(o!==a)return!1;if(o&&a){const i=Jl(e.toolResult),c=Jl(t.toolResult);return Ir(e.toolName)===Ir(t.toolName)&&Ir(e.toolInput)===Ir(t.toolInput)&&i.content===c.content&&i.isError===c.isError}return!!e.isThinking!=!!t.isThinking?!1:Ir(e.content)===Ir(t.content)}function qv(e,t){const n=Math.min(e.length,t.length);let s=0;for(;s<n&&Hv(e[s],t[s]);)s+=1;return s}function Vv(e=[],t=[],n={}){const s=Array.isArray(e)?e:[],o=Array.isArray(t)?t:[],a=!!n.preserveLocalTail;if(s.length===0)return o;if(o.length===0)return a?s:o;const i=qv(s,o);return i===s.length&&i===o.length?o:a&&i===o.length&&s.length>o.length?s:o}function Ds(e,t){return typeof t=="function"?t(e):t}function Yl(e,t={}){const n=Xs.has(e),s=Xs.has(e);return{isLoading:n,canAbortSession:s,...t}}function za(e,t=se.IDLE){const n=String(e||"").trim().toLowerCase();return Object.values(se).includes(n)?n:t}function Gv(e,t){return!e||typeof e!="object"?t:e.kind===Me.SESSION_STATE_CHANGED?za(e.payload?.state,t):e.kind===Me.APPROVAL_REQUEST?se.AWAITING_APPROVAL:e.kind===Me.APPROVAL_RESOLVED?se.STREAMING:e.kind===Me.ERROR?se.ERRORED:e.kind===Me.ASSISTANT_TEXT_START||e.kind===Me.ASSISTANT_TEXT_DELTA||e.kind===Me.REASONING_START||e.kind===Me.REASONING_DELTA||e.kind===Me.TOOL_CALL_START||e.kind===Me.TOOL_CALL_INPUT||e.kind===Me.TOOL_CALL_END||e.kind===Me.TOOL_RESULT||e.kind===Me.SYSTEM_NOTICE?se.STREAMING:t}function Kv(e,t){const n=t?.payload||{},s=n.requestId||t?.extensions?.requestId||null;return!s||e.some(o=>o?.requestId===s)?e:[...e,{requestId:s,toolName:n.toolName||"UnknownTool",input:n.input,context:n.context,sessionId:t?.sessionId||n.sessionId||null,receivedAt:t?.timestamp||new Date().toISOString()}]}function Jv(e,t){const s=(t?.payload||{}).requestId||t?.extensions?.requestId||null;return s?e.filter(o=>o?.requestId!==s):e}function Yv(e,t){return t?e===se.AWAITING_APPROVAL||Xs.has(e)?e:se.STREAMING:e===se.COMPLETED||e===se.ABORTED||e===se.ERRORED?e:se.IDLE}function Xv(e=[]){return{messages:e,pendingPermissionRequests:[],phase:se.IDLE,isLoading:!1,canAbortSession:!1}}function Qv(e,t){switch(t.type){case"replace_messages":return{...e,messages:Ds(e.messages,t.value)};case"replace_permissions":return{...e,pendingPermissionRequests:Ds(e.pendingPermissionRequests,t.value)};case"set_phase":{const n=za(t.phase,e.phase);return{...e,phase:n,...Yl(n,t.overrides)}}case"set_loading":{const n=!!Ds(e.isLoading,t.value),s=Yv(e.phase,n);return{...e,phase:s,isLoading:n,canAbortSession:n?e.canAbortSession||Xs.has(s):!1}}case"set_can_abort":return{...e,canAbortSession:!!Ds(e.canAbortSession,t.value)};case"apply_conversation_event":{const n=Tu(e.messages,t.event,t.provider),s=Gv(t.event,e.phase);let o=e.pendingPermissionRequests;if(t.event?.kind===Me.APPROVAL_REQUEST)o=Kv(o,t.event);else if(t.event?.kind===Me.APPROVAL_RESOLVED)o=Jv(o,t.event);else if(t.event?.kind===Me.SESSION_STATE_CHANGED){const a=za(t.event?.payload?.state,"");(a===se.COMPLETED||a===se.ABORTED||a===se.ERRORED||a===se.IDLE)&&(o=[])}return{...e,messages:n,pendingPermissionRequests:o,phase:s,...Yl(s)}}default:return e}}const Zv=["claude","codex","gemini","opencode"];function Jt(e){const t=String(e||"").trim().toLowerCase();return Zv.includes(t)?t:"claude"}function ey(e){return new Promise((t,n)=>{if(!(e instanceof Blob)){n(new Error("无效的图片文件"));return}const s=new FileReader;s.onload=()=>t(typeof s.result=="string"?s.result:""),s.onerror=()=>n(s.error||new Error("读取图片失败")),s.readAsDataURL(e)})}async function ty(e=[]){const t=Array.isArray(e)?e:[];return Promise.all(t.map(async(n,s)=>{const o=await ey(n);if(!o)throw new Error("图片编码失败");return{name:n?.name||`image-${s+1}.png`,data:o,size:Number(n?.size)||0,mimeType:n?.type||"application/octet-stream"}}))}function ry(e){switch(e){case"codex":return xi;case"gemini":return Cu;case"opencode":return Eu;case"claude":default:return Nu}}function mo(e){return`${Jt(e)}-model`}function vi(e){return`${mo(e)}-selection-source`}function Rs(e){const t=Jt(e),n=mo(t),s=vi(t);return localStorage.getItem(s)!=="manual"?"":localStorage.getItem(n)||""}function ny(e,t){const n=Jt(e);localStorage.setItem(mo(n),t),localStorage.setItem(vi(n),"manual")}function sy(e){const t=Jt(e);localStorage.removeItem(mo(t)),localStorage.removeItem(vi(t))}function oy(e,t){return!e||!t?!1:e.eventId&&t.eventId?e.eventId===t.eventId:e.kind===t.kind&&e.provider===t.provider&&e.sessionId===t.sessionId&&e.timestamp===t.timestamp&&JSON.stringify(e.payload||{})===JSON.stringify(t.payload||{})}function Zr(e){return e&&e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function ay(e){if(!e||typeof e!="string")return e;try{return e.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return e}}function iy(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ua(e){if(typeof e!="string")return"";try{return decodeURIComponent(e).trim()}catch{return e.trim()}}function ly(e,t){if(e?.__threadMessageId)return String(e.__threadMessageId);const n=e?.id||e?.eventMessageId||e?.messageId||e?.toolCallId||e?.toolId||e?.requestId;if(n)return String(n);const s=(()=>{const c=e?.timestamp instanceof Date?e.timestamp.getTime():new Date(e?.timestamp||Date.now()).getTime();return Number.isNaN(c)?Date.now():c})(),o=String(e?.content||e?.toolName||e?.type||"").slice(0,32),a=String(e?.role||e?.type||"assistant"),i=String(e?.provider||e?.__provider||"");return`${a}:${i}:${s}:${t}:${o}`}const In="1",Xl=5,Ql="replace",Wa="append",Ps="unknown",cy="installed",ma="not_installed",dy="checking",uy=["claude","codex","gemini","opencode"],py=300*1e3,my=15e3;function _r(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function wr(e){return typeof e=="string"&&e.trim().length>0}function Mu(e){if(typeof e!="string")return!1;const t=e.trim().toLowerCase();return t.length>0&&t!=="custom"&&t!=="default"}const fy=new Set(xi.OPTIONS.map(e=>String(e?.value||"").trim().toLowerCase()).filter(Boolean));function hy(e){if(!Mu(e))return!1;const t=e.trim().toLowerCase();return fy.has(t)?!0:/^(gpt-\d|o[1345](?:$|[-.])|codex(?:$|[-.]))/i.test(t)}function gy(e,t){return Jt(e)==="codex"?hy(t):Mu(t)}function Ls(e){return typeof e=="string"&&/^codex-\d+$/.test(e.trim())}function xy(e){if(typeof e!="string")return"";const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]||e}function fo(e,{allowEmptyPath:t=!0}={}){return typeof e=="string"?!t&&!e.trim()?null:{path:e,displayName:""}:!_r(e)||typeof e.path!="string"||!t&&!e.path.trim()||e.displayName!==void 0&&typeof e.displayName!="string"?null:{path:e.path,displayName:e.displayName||""}}function kn(e){return fo(e)?.path||""}function vy(e){const t=fo(e);return t?wr(t.displayName)?t.displayName:xy(t.path):""}function yy(e,t=72){if(typeof e!="string")return"";const n=e.trim().replace(/\s+/g," ");if(n.length<=t)return n;const s=n.split(/\s*>\s*/).filter(Boolean);if(s.length<=1)return`...${n.slice(-(t-3))}`;const o=[];let a=3;for(let c=s.length-1;c>=0;c-=1){const d=s[c],u=a+d.length+(o.length>0?3:0);if(o.length>0&&u>t)break;o.unshift(d),a=u}const i=`... > ${o.join(" > ")}`;return i.length<=t?i:`...${i.slice(-(t-3))}`}function Zl(e){if(!e)return"";const t=[];wr(e.label)&&t.push(e.label.trim());const n=yy(e.selector);return n&&t.push(n),t.join(" · ")}function by(e){return e?wr(e.systemContext)||wr(kn(e.currentFile))||Array.isArray(e.selectedElements)&&e.selectedElements.length>0?!0:_r(e.extensions)&&Object.keys(e.extensions).length>0:!1}function wy(e){return e?wr(e.systemContext)||wr(kn(e.currentFile))?!0:Array.isArray(e.selectedElements)&&e.selectedElements.length>0:!1}function Du(e){if(!_r(e)||e.version!==In||typeof e.systemContext!="string")return null;const t=fo(e.currentFile);if(!t||!Array.isArray(e.selectedElements))return null;const n=[];for(const o of e.selectedElements){if(!_r(o)||typeof o.tag!="string"||typeof o.selector!="string"||typeof o.label!="string")return null;n.push({tag:o.tag,selector:o.selector,label:o.label})}if(e.extensions!==void 0&&!_r(e.extensions))return null;const s={version:In,systemContext:e.systemContext,currentFile:t,selectedElements:n};return e.extensions!==void 0&&(s.extensions={...e.extensions}),s}function ky(e){if(!_r(e)||e.version!==void 0&&e.version!==In||e.systemContext!==void 0&&typeof e.systemContext!="string"||e.selectedElements!==void 0&&!Array.isArray(e.selectedElements))return null;const t={};if(e.systemContext!==void 0&&(t.systemContext=e.systemContext),e.currentFile!==void 0){const n=fo(e.currentFile);if(!n)return null;t.currentFile=n}if(e.selectedElements!==void 0){const n=[];for(const s of e.selectedElements){if(!_r(s)||typeof s.tag!="string"||typeof s.selector!="string"||typeof s.label!="string")return null;n.push({tag:s.tag,selector:s.selector,label:s.label})}t.selectedElements=n}if(e.extensions!==void 0){if(!_r(e.extensions))return null;t.extensions={...e.extensions}}return t}function jy(e){return`${e.tag}::${e.selector}::${e.label}`}function Sy(e){if(!Array.isArray(e)||e.length===0)return[];const t=new Set,n=[];for(const s of e){const o=jy(s);t.has(o)||(t.add(o),n.push(s))}return n}function Ny(){return{version:In,systemContext:"",currentFile:{path:"",displayName:""},selectedElements:[]}}function Cy(e,t){const n=Du(e)||Ny(),s=ky(t);if(!s)return null;const o={...n};return s.systemContext!==void 0&&(o.systemContext=s.systemContext),s.currentFile!==void 0&&(o.currentFile=s.currentFile),s.selectedElements!==void 0&&(o.selectedElements=Sy([...Array.isArray(n.selectedElements)?n.selectedElements:[],...s.selectedElements])),s.extensions!==void 0&&(o.extensions=s.extensions),o}function Ey(e){return typeof e!="string"?Ql:e.trim().toLowerCase()===Wa?Wa:Ql}function ec(e){if(e==null||e==="")return null;let t=e;if(typeof e=="string"){const s=Ua(e);if(!s)return null;try{t=JSON.parse(s)}catch{return console.warn("[DynamicContext] Ignored invalid context JSON string."),null}}const n=Du(t);return n||(console.warn("[DynamicContext] Ignored invalid context payload."),null)}function Iy(e){if(!e)return null;const t={version:In,systemContext:e.systemContext||"",currentFile:kn(e.currentFile),selectedElements:Array.isArray(e.selectedElements)?e.selectedElements:[]};return e.extensions!==void 0&&(t.extensions=e.extensions),t}function Ay(e,t){return`<dynamic_context version="${In}">
275
- ${JSON.stringify(e,null,2)}
276
- </dynamic_context>
277
-
278
- <user_message>
279
- ${t}
280
- </user_message>`}let tc=!1;function Ty(e){const t=String(e||"").trim();if(!t||t.startsWith("# AGENTS.md instructions for ")||t.includes("<environment_context>"))return"";if(t.startsWith("[DYNAMIC CONTEXT V1]")){const s=`
281
-
282
- [USER MESSAGE]
283
- `,o=t.indexOf(s);return o>=0?t.slice(o+s.length).trim():""}const n=t.match(/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i);return n?String(n[1]||"").trim():t}function fa(e=[]){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];if(typeof t.content!="string")return[t];const n=Ty(t.content);return n?n===t.content?[t]:[{...t,content:n}]:[]}):[]}function _y(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const s=e[n],o=t[n];if(s?.type!==o?.type||s?.role!==o?.role||s?.content!==o?.content||s?.timestamp!==o?.timestamp||!!s?.isToolUse!=!!o?.isToolUse)return!1}return!0}const Ha=({children:e,className:t})=>{const n=ay(String(e??"")),s=l.useMemo(()=>[Bm,zm],[]),o=l.useMemo(()=>[Um],[]);return r.jsx("div",{className:t,children:r.jsx(Wm,{remarkPlugins:s,rehypePlugins:o,components:Ly,children:n})})};function qa(e){try{return typeof e!="string"?e:e.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(t,n)=>{let s=parseInt(n,10);if(!Number.isFinite(s))return t;s<1e12&&(s*=1e3);const o=new Date(s),a=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(o),i=-o.getTimezoneOffset(),c=i>=0?"+":"-",d=Math.abs(i),u=Math.floor(d/60),p=d%60,m=`GMT${c}${u}${p?":"+String(p).padStart(2,"0"):""}`,x=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,T=>T.toUpperCase()),j=x?`${m} (${x})`:m,k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],A=`${o.getDate()} ${k[o.getMonth()]} ${o.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${a} ${j}** - ${A}`})}catch{return e}}const It={setItem:(e,t)=>{try{if(e.startsWith("chat_messages_")&&typeof t=="string")try{const n=JSON.parse(t);if(Array.isArray(n)&&n.length>50){console.warn(`Truncating chat history for ${e} from ${n.length} to 50 messages`);const s=n.slice(-50);t=JSON.stringify(s)}}catch(n){console.warn("Could not parse chat messages for truncation:",n)}localStorage.setItem(e,t)}catch(n){if(n.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const s=Object.keys(localStorage),o=s.filter(i=>i.startsWith("chat_messages_")).sort();o.length>3&&o.slice(0,o.length-3).forEach(i=>{localStorage.removeItem(i),console.log(`Removed old chat data: ${i}`)}),s.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(e,t)}catch(i){if(console.error("Failed to save to localStorage even after cleanup:",i),e.startsWith("chat_messages_")&&typeof t=="string")try{const c=JSON.parse(t);if(Array.isArray(c)&&c.length>10){const d=c.slice(-10);localStorage.setItem(e,JSON.stringify(d)),console.warn("Saved only last 10 messages due to quota constraints")}}catch(c){console.error("Final save attempt failed:",c)}}}else console.error("localStorage error:",n)}},getItem:e=>{try{return localStorage.getItem(e)}catch(t){return console.error("localStorage getItem error:",t),null}},removeItem:e=>{try{localStorage.removeItem(e)}catch(t){console.error("localStorage removeItem error:",t)}}},Ru="claude-settings";function yi(){const e=It.getItem(Ru);if(!e)return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"};try{const t=JSON.parse(e);return{...t,allowedTools:Array.isArray(t.allowedTools)?t.allowedTools:[],disallowedTools:Array.isArray(t.disallowedTools)?t.disallowedTools:[],skipPermissions:!!t.skipPermissions,projectSortOrder:t.projectSortOrder||"name"}}catch{return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"}}}function Va(e,t){if(!e)return null;if(e!=="Bash")return e;const n=ti(t),s=typeof n?.command=="string"?n.command.trim():"";if(!s)return e;const o=s.split(/\s+/);return o.length===0?e:o[0]==="git"&&o[1]?`Bash(${o[0]} ${o[1]}:*)`:`Bash(${o[0]}:*)`}function rc(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function My(e,t){if(t!=="claude"||!e?.toolResult?.isError)return null;const n=e?.toolName,s=Va(n,e.toolInput);if(!s)return null;const a=yi().allowedTools.includes(s);return{toolName:n,entry:s,isAllowed:a}}function Dy(e){if(!e)return{success:!1};const t=yi(),n=t.allowedTools.includes(e),s=n?t.allowedTools:[...t.allowedTools,e],o=t.disallowedTools.filter(i=>i!==e),a={...t,allowedTools:s,disallowedTools:o,lastUpdated:new Date().toISOString()};return It.setItem(Ru,JSON.stringify(a)),{success:!0,alreadyAllowed:n,updatedSettings:a}}function Ga({phaseText:e,detailText:t="",canAbort:n=!0,startedAt:s=Date.now(),elapsedSeconds:o}={}){return{phaseText:e,detailText:t,canAbort:n,startedAt:s,elapsedSeconds:o}}function Ry(e,t,n=null){const s=n?.startedAt||Date.now(),o=typeof e=="string"?e:e?.message||e?.status||e?.text||"",a=String(o||"").trim(),i=a.toLowerCase();let c=t("activity.stage.working");return i.includes("permission")?c=t("activity.stage.waitingPermission"):i.includes("think")?c=t("activity.stage.thinking"):i.includes("search")||i.includes("grep")||i.includes("glob")?c=t("activity.stage.searching"):i.includes("command")||i.includes("bash")?c=t("activity.stage.runningCommand"):i.includes("read")?c=t("activity.stage.readingFile"):i.includes("write")||i.includes("edit")||i.includes("patch")?c=t("activity.stage.editingFile"):i.includes("todo")?c=t("activity.stage.updatingTodo"):(i.includes("respond")||i.includes("reply"))&&(c=t("activity.stage.generatingReply")),Ga({phaseText:c,detailText:a,canAbort:e?.can_interrupt!==!1,startedAt:s,elapsedSeconds:e?.elapsedSeconds})}const Py=({node:e,inline:t,className:n,children:s,...o})=>{const{t:a}=$t("chat"),[i,c]=Mn.useState(!1),d=Array.isArray(s)?s.join(""):String(s??""),u=/[\r\n]/.test(d);if(t||e&&e.type==="inlineCode"||!u)return r.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${n||""}`,...o,children:s});const h=/language-(\w+)/.exec(n||""),g=h?h[1]:"text",x=d,j=()=>{const k=()=>{c(!0),setTimeout(()=>c(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(x).then(k).catch(()=>{const A=document.createElement("textarea");A.value=x,A.style.position="fixed",A.style.opacity="0",document.body.appendChild(A),A.select();try{document.execCommand("copy")}catch{}document.body.removeChild(A),k()});else{const A=document.createElement("textarea");A.value=x,A.style.position="fixed",A.style.opacity="0",document.body.appendChild(A),A.select();try{document.execCommand("copy")}catch{}document.body.removeChild(A),k()}}catch{}};return r.jsxs("div",{className:"relative group my-2",children:[g&&g!=="text"&&r.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:g}),r.jsx("button",{type:"button",onClick:j,className:"absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 focus:opacity-100 active:opacity-100 transition-opacity text-xs px-2 py-1 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600",title:a(i?"codeBlock.copied":"codeBlock.copyCode"),"aria-label":a(i?"codeBlock.copied":"codeBlock.copyCode"),children:i?r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:r.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),a("codeBlock.copied")]}):r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),a("codeBlock.copy")]})}),r.jsx(Hm,{language:g,style:qm,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:g&&g!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:d})]})},Ly={code:Py,blockquote:({children:e})=>r.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:e}),a:({href:e,children:t})=>r.jsx("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:t}),p:({children:e})=>r.jsx("div",{className:"mb-2 last:mb-0",children:e}),table:({children:e})=>r.jsx("div",{className:"overflow-x-auto my-2",children:r.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:e})}),thead:({children:e})=>r.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e}),th:({children:e})=>r.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:e}),td:({children:e})=>r.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:e})};l.memo(({message:e,index:t,prevMessage:n,createDiff:s,onFileOpen:o,onShowSettings:a,onGrantToolPermission:i,autoExpandTools:c,showRawParameters:d,showThinking:u,selectedProject:p,provider:m,isActiveStreamingCard:h})=>{const{t:g}=$t("chat"),x=e.provider||e.__provider||m||"claude",j=x==="codex",k=x==="gemini",A=x==="opencode",T=n&&n.type===e.type&&(n.type==="assistant"||n.type==="user"||n.type==="tool"||n.type==="error");return My(e,m),r.jsx("div",{className:`chat-message ${e.type} ${T?"grouped":""} ${e.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:e.type==="user"?r.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[r.jsxs("div",{className:"bg-primary text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[r.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:e.content}),e.images&&e.images.length>0&&r.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:e.images.map((w,D)=>r.jsx("img",{src:w.data,alt:w.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(w.data,"_blank")},D))}),r.jsx("div",{className:"text-xs text-primary-foreground/80 mt-1 text-right",children:new Date(e.timestamp).toLocaleTimeString()})]}),!T&&r.jsx("div",{className:"hidden sm:flex w-8 h-8 bg-primary rounded-full items-center justify-center text-white text-sm flex-shrink-0",children:"U"})]}):r.jsxs("div",{className:"w-full",children:[!T&&r.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.type==="error"?r.jsx("div",{className:"w-8 h-8 bg-red-600 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"!"}):e.type==="tool"?r.jsx("div",{className:"w-8 h-8 bg-gray-600 dark:bg-gray-700 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"🔧"}):r.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:j?r.jsx(co,{className:"w-full h-full"}):k?r.jsx(uo,{className:"w-full h-full"}):A?r.jsx(po,{className:"h-full w-auto max-w-full text-gray-900 dark:text-white"}):r.jsx(rs,{className:"w-full h-full"})}),r.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.type==="error"?g("messageTypes.error"):e.type==="tool"?g("messageTypes.tool"):j?g("messageTypes.codex"):k?g("messageTypes.gemini"):A?"OpenCode":g("messageTypes.claude")})]}),r.jsxs("div",{className:"w-full",children:[e.isToolUse?r.jsx(Vm,{toolName:e.toolName||"Tool",argsText:typeof e.toolInput=="string"?e.toolInput:JSON.stringify(e.toolInput??{},null,2),result:e.toolResult,isError:!!(e.toolResult?.isError||e.isError),status:e.isStreaming||e.toolResult==null?{type:"running"}:e.toolResult?.isError||e.isError?{type:"incomplete",reason:"error"}:{type:"complete"}}):e.isThinking?r.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:r.jsxs("details",{className:"group",open:h,children:[r.jsxs("summary",{className:"cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 font-medium flex items-center gap-2",children:[r.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r.jsx("span",{children:g("thinking.emoji")})]}),r.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm",children:r.jsx(Ha,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:e.content})})]})}):r.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[u&&e.reasoning&&r.jsxs("details",{className:"mb-3",open:h,children:[r.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 font-medium",children:g("thinking.emoji")}),r.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 italic text-gray-600 dark:text-gray-400 text-sm",children:r.jsx("div",{className:"whitespace-pre-wrap",children:e.reasoning})})]}),(()=>{const w=qa(String(e.content||"")),D=w.trim();if((D.startsWith("{")||D.startsWith("["))&&(D.endsWith("}")||D.endsWith("]")))try{const N=JSON.parse(D),b=JSON.stringify(N,null,2);return r.jsxs("div",{className:"my-2",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),r.jsx("span",{className:"font-medium",children:"JSON Response"})]}),r.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:r.jsx("pre",{className:"p-4 overflow-x-auto",children:r.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:b})})})]})}catch{}return e.type==="assistant"?r.jsx(Ha,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:w}):r.jsx("div",{className:"whitespace-pre-wrap",children:w})})()]}),r.jsx("div",{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 ${T?"opacity-0 group-hover:opacity-100":""}`,children:new Date(e.timestamp).toLocaleTimeString()})]})]})})});const Oy=({file:e,onRemove:t,uploadProgress:n,error:s})=>{const[o,a]=l.useState(null);return l.useEffect(()=>{const i=URL.createObjectURL(e);return a(i),()=>URL.revokeObjectURL(i)},[e]),r.jsxs("div",{className:"relative group",children:[r.jsx("img",{src:o,alt:e.name,className:"w-20 h-20 object-cover rounded"}),n!==void 0&&n<100&&r.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:r.jsxs("div",{className:"text-white text-xs",children:[n,"%"]})}),s&&r.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:r.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),r.jsx("button",{onClick:t,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-0 group-hover:opacity-100",children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})};function Fy({selectedProject:e,selectedSession:t,ws:n,sendMessage:s,latestMessage:o,onFileOpen:a,onInputFocusChange:i,onSessionActive:c,onSessionInactive:d,onSessionProcessing:u,onSessionNotProcessing:p,processingSessions:m,onReplaceTemporarySession:h,onNavigateToSession:g,onShowSettings:x,autoExpandTools:j,showRawParameters:k,showThinking:A,autoScrollToBottom:T,sendByCtrlEnter:w,externalMessageUpdate:D,urlProvider:N,urlModel:b,urlContext:L,urlPrompt:q,integrationClientId:P,latestIntegrationMessage:Y,sendIntegrationMessage:ge,newSessionResetNonce:le=0}){const{t:M}=$t("chat"),[V,xe]=l.useState(()=>typeof window<"u"&&e&&It.getItem(`draft_input_${e.name}`)||""),Ie=l.useMemo(()=>{if(typeof window<"u"&&e){const f=It.getItem(`chat_messages_${e.name}`);return f?fa(JSON.parse(f)):[]}return[]},[e]),[qe,Se]=l.useReducer(Qv,Ie,Xv),U=qe.messages,fe=qe.phase,O=qe.isLoading,S=qe.canAbortSession,B=qe.pendingPermissionRequests,Z=e?.fullPath||e?.path||null,ke=l.useRef(!1),ve=l.useRef(U),R=l.useRef(e),re=l.useRef(!1),Fe=l.useRef(le),Ce=l.useRef(tc),[ce,$e]=l.useState(t?.id||null),[ft,at]=l.useState(!1),[Ve,Ze]=l.useState([]),[yt,Tt]=l.useState(!1),[he,Ke]=l.useState(!1),[_t,kt]=l.useState(0),[St,J]=l.useState(!1),[ee,je]=l.useState(0),_e=100,[et,tt]=l.useState(!1),[Je,Mt]=l.useState(()=>{const f=Jt(localStorage.getItem("selected-provider"));return Gl(f).defaultMode}),ue=l.useCallback(f=>{Se({type:"replace_messages",value:f})},[]),bt=l.useCallback(f=>{Se({type:"replace_permissions",value:f})},[]),Ye=l.useCallback(f=>{Se({type:"set_loading",value:f})},[]),rt=l.useCallback(f=>{Se({type:"set_can_abort",value:f})},[]),Ue=l.useCallback((f,v)=>{Se({type:"set_phase",phase:f,overrides:v})},[]),Nt=l.useCallback((f,v)=>{Se({type:"apply_conversation_event",event:f,provider:v})},[]),Pt=l.useCallback(f=>{!f||typeof f!="object"||Ze(v=>{const y=Array.isArray(v)?v:[];return y.some(E=>oy(E,f))?y:[...y,f]})},[]),ht=l.useRef({sessionId:null,startedAt:0}),Ct=l.useCallback(f=>{ht.current={sessionId:f||null,startedAt:Date.now()}},[]),tr=l.useCallback(f=>{!f||!ht.current.startedAt||(ht.current={...ht.current,sessionId:f})},[]),Xe=l.useCallback((f=null)=>{const v=ht.current;v.startedAt&&(f&&v.sessionId&&v.sessionId!==f||(ht.current={sessionId:null,startedAt:0}))},[]),Lt=l.useCallback((f,v=null)=>{if(v&&v!=="session-status")return!1;const y=ht.current;return!!(y.startedAt&&f&&y.sessionId===f&&Date.now()-y.startedAt<my&&(fe===se.CONNECTING||fe===se.QUEUED||fe===se.STREAMING||fe===se.AWAITING_APPROVAL||fe===se.COMPLETED||fe===se.ABORTED||fe===se.ERRORED))},[fe]),[jt,Ot]=l.useState([]),[rr,zt]=l.useState(new Map),[_,pe]=l.useState(new Map),Ae=l.useRef(null),X=l.useRef(null),C=l.useRef(null),F=l.useRef(null),ie=l.useRef(null),be=l.useRef(!1),dt=l.useRef(!1),W=l.useRef(0),Et=l.useRef(!1),$=l.useRef(null),z=l.useRef(""),ne=l.useRef(null),Re=l.useCallback(()=>{ne.current&&(clearTimeout(ne.current),ne.current=null),z.current=""},[]),I=l.useRef(null),Q=l.useRef(new Set),te=l.useRef(new Map),ye=l.useRef(D),H=l.useRef(null),[We,Qe]=l.useState(""),[wt,ut]=l.useState(!1),[ot,Ge]=l.useState([]),[Dt,Ut]=l.useState([]),[Gt,Pr]=l.useState([]),[Bt,un]=l.useState(-1),[Ni,ns]=l.useState(0),[Ci,ss]=l.useState(-1),[xo,Rn]=l.useState(!1),vo=l.useRef({height:0,top:0}),[yo,Lr]=l.useState(!1),[Or,bo]=l.useState([]),[Gr,wo]=l.useState([]),[os,Fr]=l.useState(""),[lp,Kr]=l.useState(!1),[fr,$r]=l.useState(null),[ko,Br]=l.useState(-1),[Ei,zr]=l.useState(-1),[Pn,cp]=l.useState(100),[jo,xt]=l.useState(null),Ii=l.useRef(null),[Jr,as]=l.useState("none"),[So,dp]=l.useState(!1),[Ai,up]=l.useState(!1),No=l.useRef(null),Co=l.useRef(null),[ae,is]=l.useState(()=>Jt(localStorage.getItem("selected-provider"))),Ur=l.useMemo(()=>Gl(ae),[ae]),Yr=l.useMemo(()=>Kl(ae),[ae]),Eo=l.useCallback((f,{short:v=!1}={})=>{let y=M("codex.modes.default");return f==="acceptEdits"?y=M("codex.modes.acceptEdits"):f==="bypassPermissions"?y=M("codex.modes.bypassPermissions"):f==="plan"&&(y=M("codex.modes.plan")),v?y.replace(/\s*模式$/,"").replace(/\s*Mode$/,""):y},[M]),pp=l.useMemo(()=>Eo(Je,{short:!0}),[Eo,Je]),Ti=l.useMemo(()=>M("codex.permissionMode").replace(/^权限/,"").replace(/^Permission\s+/i,""),[M]),[Io,Ao]=l.useState({});l.useEffect(()=>{Ii.current=jo},[jo]),l.useEffect(()=>()=>{te.current.forEach(f=>clearTimeout(f)),te.current.clear()},[]);const[mp,_i]=l.useState({}),[fp,Mi]=l.useState({}),Di=l.useRef(null),Ln=l.useCallback(async(f,{force:v=!1}={})=>{if(!uy.includes(f))return null;_i(y=>({...y,[f]:!0})),Mi(y=>({...y,[f]:null})),Ao(y=>({...y,[f]:{status:dy}}));try{const E=await oe(`/api/cli/providers/${f}/installation-status${v?"?force=true":""}`),K=await E.json().catch(()=>({}));if(!E.ok||K?.success!==!0)throw new Error(K?.error||`Failed to check ${f} installation`);const de=K.installed?cy:ma;return Ao(we=>({...we,[f]:{status:de,command:K.command||null,resolvedPath:K.resolvedPath||null,reason:K.reason||null,installHint:K.installHint||null,checkedAt:K.checkedAt||null,cacheHit:!!K.cacheHit}})),de}catch(y){return Ao(E=>({...E,[f]:{status:Ps}})),Mi(E=>({...E,[f]:y.message})),Ps}finally{_i(y=>({...y,[f]:!1}))}},[]),Ri=l.useCallback(()=>{if(!N||t)return null;const f=N.trim().toLowerCase();return{claude:"claude",anthropic:"claude",codex:"codex",openai:"codex",gemini:"gemini",google:"gemini",opencode:"opencode"}[f]||null},[N,t]),Pi=l.useCallback(()=>{if(!b)return null;const f=b.trim().toLowerCase();if(!f)return null;const v={claude:Nu.OPTIONS.some(E=>E.value===f),codex:xi.OPTIONS.some(E=>E.value===f),gemini:Cu.OPTIONS.some(E=>E.value===f),opencode:Eu.OPTIONS.some(E=>E.value===f)},y=Object.entries(v).filter(([,E])=>E).map(([E])=>E);return y.length===0?null:y.length===1?{provider:y[0],model:f}:v[ae]?{provider:ae,model:f}:{provider:y[0],model:f}},[b,ae]),[To,_o]=l.useState(()=>Rs("claude")),[Mo,Do]=l.useState(()=>Rs("codex")),[Ro,Po]=l.useState(()=>Rs("gemini")),[Lo,Oo]=l.useState(()=>Rs("opencode")),[Li,Fo]=l.useState({}),[lw,Oi]=l.useState({}),[hp,Fi]=l.useState({}),ls=ae==="claude"?To:ae==="codex"?Mo:ae==="gemini"?Ro:Lo,$i=l.useMemo(()=>ry(ae).OPTIONS,[ae]),$o=l.useMemo(()=>(Li[ae]||[]).map(f=>({value:f,label:f})),[Li,ae]),Xr=t?.__provider===ae&&gy(ae,t?.model)?t.model.trim():"",Yt=Xr||ls,cs=l.useMemo(()=>{const f=$o.length>0?$o:$i;return!Xr||f.some(v=>v.value===Xr)?f:[{value:Xr,label:Xr},...f]},[$o,$i,Xr]),gp=cs.find(f=>f.value===Yt)?.label||Yt||M("providerSelection.selectModel"),xp=!!Xr,ds=ae==="opencode"&&!!hp.opencode,us=l.useCallback(f=>{if(!f)return;const v=Jt(f);is(v),localStorage.setItem("selected-provider",v),Ln(v)},[Ln]),pn=l.useMemo(()=>ec(L),[L]),[cw,Bo]=l.useState(pn),[Sr,mn]=l.useState(pn),[ps,ms]=l.useState(!1),Bi=l.useRef(pn),zi=l.useRef(ae);l.useEffect(()=>{const f=Ri();if(f&&(Di.current!==f&&(Di.current=f,Ln(f)),f!==ae)){const v=Jt(f);is(v),localStorage.setItem("selected-provider",v)}},[Ri,ae,Ln]),l.useEffect(()=>{if(!b||t)return;const f=Pi();if(f){if(f.provider!==ae){const v=Jt(f.provider);is(v),localStorage.setItem("selected-provider",v)}f.provider==="claude"?_o(f.model):f.provider==="codex"?Do(f.model):f.provider==="gemini"?Po(f.model):f.provider==="opencode"&&Oo(f.model)}},[b,Pi,ae,t]),l.useEffect(()=>{const f=cs.map(v=>v.value);ls&&(f.includes(ls)||(ae==="claude"?_o(""):ae==="codex"?Do(""):ae==="gemini"?Po(""):ae==="opencode"&&Oo(""),sy(ae)))},[ae,ls,cs]),l.useEffect(()=>{if(!e)return;const f=e.fullPath||e.path;if(!f)return;const v=`runtime-models:v2:${ae}:${f}`,y=ti(It.getItem(v)),E=Array.isArray(y?.models)?y.models:[],K=typeof y?.currentModel=="string"?y.currentModel.trim():"",de=Number(y?.timestamp||0);if(E.length>0&&Date.now()-de<py){Fo(Le=>({...Le,[ae]:E})),K&&Oi(Le=>({...Le,[ae]:{...Le?.[ae]||{},currentModel:K}}));return}let Be=!1;return Fi(Le=>({...Le,[ae]:!0})),mt.providerDiscovery(ae,f).then(async Le=>{if(!Le.ok)throw new Error(`HTTP ${Le.status}`);return Le.json()}).then(Le=>{if(Be)return;const gt=Array.isArray(Le?.models)?Le.models.map(nt=>nt.id):[],Rt=typeof Le?.currentModel=="string"?Le.currentModel.trim():"";Oi(nt=>({...nt,[ae]:Le})),Fo(nt=>({...nt,[ae]:gt})),gt.length>0&&It.setItem(v,JSON.stringify({models:gt,currentModel:Rt||"",timestamp:Date.now()}))}).catch(()=>{Be||Fo(Le=>({...Le,[ae]:E}))}).finally(()=>{Be||Fi(Le=>({...Le,[ae]:!1}))}),()=>{Be=!0}},[ae,e,So]),l.useEffect(()=>{if(!So)return;const f=v=>{No.current&&!No.current.contains(v.target)&&dp(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[So]),l.useEffect(()=>{if(!Ai)return;const f=v=>{Co.current&&!Co.current.contains(v.target)&&up(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[Ai]),l.useEffect(()=>{ke.current=O},[O]),l.useEffect(()=>{ve.current=U},[U]),l.useEffect(()=>{R.current=e},[e]),l.useEffect(()=>{Fe.current!==le&&(Fe.current=le,!t&&(Re(),Xe(),I.current=null,sessionStorage.removeItem("pendingSessionId"),$e(null),Ze([]),ue([]),bt([]),tt(!1),Ue(se.IDLE),xt(null),rt(!1),xe(""),$r(null),Rn(!1),e?.name&&(It.removeItem(`chat_messages_${e.name}`),It.removeItem(`draft_input_${e.name}`))))},[Xe,le,Re,e?.name,t,rt,ue,bt,Ue]),l.useEffect(()=>{Bi.current=Sr},[Sr]),l.useEffect(()=>{if(Ce.current)return;const f=Ua(q);f&&(xe(f),re.current=!0,Ce.current=!0,tc=!0)},[q]),l.useEffect(()=>{Bo(pn),mn(pn),ms(!1)},[pn]);const dr=l.useCallback((f,v,y={})=>{!v||typeof ge!="function"||ge({type:f,requestId:v,payload:{...y,clientId:P||null}})},[P,ge]),Ui=l.useCallback((f,v=null)=>{if(!_r(f?.context)){console.warn("[DynamicContext] Ignored integration.context.update because context is not an object."),dr("integration.error",v,{code:"INVALID_PAYLOAD",message:"context must be an object"});return}if(Ey(f.mode)===Wa){const K=Cy(Bi.current,f.context);if(!K){console.warn("[DynamicContext] Ignored invalid append context payload."),dr("integration.error",v,{code:"INVALID_PAYLOAD",message:"append context payload is invalid"});return}Bo(K),mn(K),ms(!1),dr("integration.ack",v,{accepted:!0,applied:!0});return}const E=ec(f.context);if(!E){dr("integration.error",v,{code:"INVALID_PAYLOAD",message:"context payload does not satisfy contextV1"});return}Bo(E),mn(E),ms(!1),dr("integration.ack",v,{accepted:!0,applied:!0})},[dr]),Wi=l.useCallback((f,v=null)=>{if(typeof f?.prompt!="string"){dr("integration.error",v,{code:"INVALID_PAYLOAD",message:"prompt must be a string"});return}const y=Ua(f.prompt);if(xe(y),re.current=!0,f.autoSend===!0&&y&&R.current&&!ke.current&&On.current){const E={preventDefault:()=>{}};On.current(E,y)}dr("integration.ack",v,{accepted:!0,applied:!0})},[dr]),Hi=l.useCallback((f=null)=>{dr("integration.ack",f,{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:t?.id||null})},[t?.id,dr]);l.useEffect(()=>{if(!Y?.__messageSeq)return;const v=Y?.type;if(v==="integration.context.update"){Ui(Y.payload||{},Y.requestId||null);return}if(v==="integration.prompt.update"){Wi(Y.payload||{},Y.requestId||null);return}v==="integration.ping"&&Hi(Y.requestId||null)},[Ui,Wi,Y,Hi]);const nr=l.useMemo(()=>ps||!Sr||!wy(Sr)?null:Sr,[ps,Sr]),vp=l.useMemo(()=>nr?.selectedElements?.length?nr.selectedElements.slice(0,Xl):[],[nr]),zo=l.useMemo(()=>nr?.selectedElements?.length?nr.selectedElements.slice(Xl):[],[nr]),yp=l.useCallback(()=>{mn(f=>!f||!wr(f.systemContext)?f:{...f,systemContext:""})},[]),bp=l.useCallback(()=>{mn(f=>!f||!wr(kn(f.currentFile))?f:{...f,currentFile:{path:"",displayName:""}})},[]),wp=l.useCallback(f=>{mn(v=>{if(!v||!Array.isArray(v.selectedElements)||v.selectedElements.length===0)return v;const y=v.selectedElements.findIndex(E=>E.tag===f.tag&&E.selector===f.selector&&E.label===f.label);return y<0?v:{...v,selectedElements:v.selectedElements.filter((E,K)=>K!==y)}})},[]);l.useEffect(()=>{if(t?.id){const f=localStorage.getItem(`permissionMode-${t.id}`);f&&Ur.modes.includes(f)?Mt(f):Mt(Ur.defaultMode)}},[t?.id,Ur]),l.useEffect(()=>{Ur.modes.includes(Je)||Mt(Ur.defaultMode)},[Je,Ur]),l.useEffect(()=>{if(!Yr.enabled){Jr!==Yr.defaultMode&&as(Yr.defaultMode);return}Yr.modes.includes(Jr)||as(Yr.defaultMode)},[Yr,Jr]),l.useEffect(()=>{if(t&&t.__provider&&t.__provider!==ae){const f=Jt(t.__provider);is(f),localStorage.setItem("selected-provider",f)}if(t?.id&&t?.__provider)try{const f=localStorage.getItem("session-provider-map"),v=f?JSON.parse(f):{};v[t.id]!==t.__provider&&(v[t.id]=t.__provider,localStorage.setItem("session-provider-map",JSON.stringify(v)))}catch{}},[t]),l.useEffect(()=>{zi.current!==ae&&(bt([]),zi.current=ae)},[ae]),l.useEffect(()=>{bt(f=>f.filter(v=>!v.sessionId||v.sessionId===t?.id))},[t?.id]),l.useEffect(()=>{(async()=>{if(e)try{const v=await oe("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:e.path})});if(!v.ok)throw new Error("Failed to fetch commands");const y=await v.json(),E=[...(y.builtIn||[]).map(we=>({...we,type:"built-in"})),...(y.custom||[]).map(we=>({...we,type:"custom"}))];bo(E);const K=`command_history_${e.name}`,de=It.getItem(K);if(de)try{const we=JSON.parse(de),Be=E.sort((Le,gt)=>{const Rt=we[Le.name]||0;return(we[gt.name]||0)-Rt});bo(Be)}catch(we){console.error("Error parsing command history:",we)}}catch(v){console.error("Error fetching slash commands:",v),bo([])}})()},[e]);const Uo=l.useMemo(()=>Or.length?new Dn(Or,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[Or]);l.useEffect(()=>{if(!os){wo(Or);return}if(!Uo){wo([]);return}const f=Uo.search(os);wo(f.map(v=>v.item))},[os,Or,Uo]);const kp=l.useMemo(()=>{if(!e||Or.length===0)return[];const f=`command_history_${e.name}`,v=It.getItem(f);if(!v)return[];try{const y=JSON.parse(v);return Or.map(K=>({...K,usageCount:y[K.name]||0})).filter(K=>K.usageCount>0).sort((K,de)=>de.usageCount-K.usageCount).slice(0,5)}catch(y){return console.error("Error parsing command history:",y),[]}},[e,Or]),jp=l.useCallback((f,v,y)=>{if(!f||!e)return;if(y){Br(v);return}const E=`command_history_${e.name}`,K=It.getItem(E);let de={};try{de=K?JSON.parse(K):{}}catch(we){console.error("Error parsing command history:",we)}de[f.name]=(de[f.name]||0)+1,It.setItem(E,JSON.stringify(de)),qi(f)},[e]),Sp=l.useCallback(f=>{const{action:v,data:y}=f;switch(v){case"clear":ue([]),Ze([]);break;case"help":ue(E=>[...E,{role:"assistant",content:y.content,timestamp:Date.now()}]);break;case"model":{const E=Object.entries(y.available||{}).filter(([,de])=>Array.isArray(de)&&de.length>0).map(([de,we])=>`**${de.charAt(0).toUpperCase()+de.slice(1)}**: ${we.join(", ")}`).join(`
284
-
285
- `),K=y.current.provider==="opencode"?y.opencodeDiscovery?"_OpenCode source: runtime provider registry._":"_OpenCode source: local fallback list._":"";ue(de=>[...de,{role:"assistant",content:`**Current Model**: ${y.current.model}
286
-
287
- **Available Models**:
288
-
289
- ${E}${K?`
290
-
291
- ${K}`:""}`,timestamp:Date.now()}])}break;case"cost":{const E=`**Token Usage**: ${y.tokenUsage.used.toLocaleString()} / ${y.tokenUsage.total.toLocaleString()} (${y.tokenUsage.percentage}%)
292
-
293
- **Estimated Cost**:
294
- - Input: $${y.cost.input}
295
- - Output: $${y.cost.output}
296
- - **Total**: $${y.cost.total}
297
-
298
- **Model**: ${y.model}`;ue(K=>[...K,{role:"assistant",content:E,timestamp:Date.now()}]);break}case"status":{const E=`**System Status**
299
-
300
- - Version: ${y.version}
301
- - Uptime: ${y.uptime}
302
- - Model: ${y.model}
303
- - Provider: ${y.provider}
304
- - Node.js: ${y.nodeVersion}
305
- - Platform: ${y.platform}`;ue(K=>[...K,{role:"assistant",content:E,timestamp:Date.now()}]);break}case"memory":y.error?ue(E=>[...E,{role:"assistant",content:`⚠️ ${y.message}`,timestamp:Date.now()}]):(ue(E=>[...E,{role:"assistant",content:`📝 ${y.message}
306
-
307
- Path: \`${y.path}\``,timestamp:Date.now()}]),y.exists&&a&&a(y.path));break;case"config":x&&x();break;case"rewind":y.error?ue(E=>[...E,{role:"assistant",content:`⚠️ ${y.message}`,timestamp:Date.now()}]):(ue(E=>E.slice(0,-y.steps*2)),ue(E=>[...E,{role:"assistant",content:`⏪ ${y.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",v)}},[a,x]),On=l.useRef(null),Np=l.useCallback(async(f,v)=>{const{content:y,hasBashCommands:E,hasFileIncludes:K}=f;if(E&&!window.confirm("这条命令包含将要执行的 Bash 命令,是否继续?")){ue(we=>[...we,{role:"assistant",content:"❌ 已取消命令执行",timestamp:Date.now()}]);return}xe(y),setTimeout(()=>{if(On.current){const de={preventDefault:()=>{}};On.current(de)}},50)},[]),qi=l.useCallback(async f=>{if(!(!f||!e))try{const v=V.match(new RegExp(`${f.name}\\s*(.*)`)),y=v&&v[1]?v[1].trim().split(/\s+/):[],E={projectPath:e.path,projectName:e.name,sessionId:ce,provider:ae,...Yt?{model:Yt}:{},tokenUsage:fr},K=await oe("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:f.name,commandPath:f.path,args:y,context:E})});if(!K.ok)throw new Error("Failed to execute command");const de=await K.json();de.type==="builtin"?Sp(de):de.type==="custom"&&await Np(de,y),xe(""),Lr(!1),zr(-1),Fr(""),Br(-1)}catch(v){console.error("Error executing command:",v),ue(y=>[...y,{role:"assistant",content:`Error executing command: ${v.message}`,timestamp:Date.now()}])}},[V,e,ce,ae,Mo,Ro,Lo,To,fr]),Cp=l.useMemo(()=>{const f=new Map;return(v,y)=>{const E=`${v.length}-${y.length}-${v.slice(0,50)}`;if(f.has(E))return f.get(E);const K=Ep(v,y);if(f.set(E,K),f.size>100){const de=f.keys().next().value;f.delete(de)}return K}},[]),Nr=l.useCallback(async(f,v,y=!1,E="claude",K=null)=>{if(!f||!v)return[];const de=!y;de?Tt(!0):Ke(!0);try{const we=K??(y?W.current:0),Be=Z,Le=await mt.sessionEvents(E,v,f,Be,_e,we);if(!Le.ok)throw new Error("Failed to load session messages");const gt=await Le.json();if(de&&gt.tokenUsage&&$r(gt.tokenUsage),gt.hasMore!==void 0){J(gt.hasMore),je(gt.total);const Rt=we+(gt.events?.length||0);return W.current=Rt,kt(Rt),gt.events||[]}else{const Rt=gt.events||gt.messages||[];return J(!1),je(Rt.length),W.current=Rt.length,kt(Rt.length),Rt}}catch(we){return console.error("Error loading session messages:",we),[]}finally{de?Tt(!1):Ke(!1)}},[Z]),Ep=(f,v)=>{const y=f.split(`
308
- `),E=v.split(`
309
- `),K=[];let de=0,we=0;for(;de<y.length||we<E.length;){const Be=y[de],Le=E[we];de>=y.length?(K.push({type:"added",content:Le,lineNum:we+1}),we++):we>=E.length?(K.push({type:"removed",content:Be,lineNum:de+1}),de++):Be===Le?(de++,we++):(K.push({type:"removed",content:Be,lineNum:de+1}),K.push({type:"added",content:Le,lineNum:we+1}),de++,we++)}return K},Ip=(f,v="claude")=>_u(f,v).map(y=>({...y,provider:y.provider||v})),Wt=t?.__provider||ae||"claude",Vi=l.useMemo(()=>Ip(Ve,Wt),[Ve,Wt]),Wr=l.useCallback((f=[])=>{let v=null;for(const y of f)if(!(!y||typeof y!="object")){if(y.kind==="error"){v=se.ERRORED;continue}if(y.kind==="session_state_changed"){const E=String(y.payload?.state||"").trim().toLowerCase();Object.values(se).includes(E)&&(v=E);continue}if(y.kind==="approval_request"){v=se.AWAITING_APPROVAL;continue}if(y.kind==="approval_resolved"){v=se.STREAMING;continue}(y.kind==="assistant_text_start"||y.kind==="assistant_text_delta"||y.kind==="reasoning_start"||y.kind==="reasoning_delta"||y.kind==="tool_call_start"||y.kind==="tool_call_input"||y.kind==="tool_call_end"||y.kind==="tool_result"||y.kind==="system_notice")&&(v=se.STREAMING)}return v},[]),fs=l.useCallback((f=[])=>{const v=Wr(f);return v===se.COMPLETED||v===se.ABORTED||v===se.ERRORED?v:null},[Wr]),Gi=l.useCallback(f=>!(f===se.COMPLETED||f===se.ABORTED||f===se.ERRORED),[]),fn=l.useCallback((f,v)=>v&&(Ue(v),(v===se.COMPLETED||v===se.ABORTED||v===se.ERRORED)&&(Xe(f),xt(null),f&&(d&&d(f),p&&p(f))),v),[Xe,d,p,Ue]),Ki=l.useCallback(async(f,v)=>{const y=R.current;if(!y?.name||!f)return null;const E=await Nr(y.name,f,!1,v||Wt);return Array.isArray(E)&&E.length>0&&Ze(E),Wr(E)},[Wt,Wr,Nr]),Hr=l.useCallback(async(f,v)=>{const y=await Ki(f,v);return fn(f,y)},[Ki,fn]),Ji=l.useCallback((f,v=[])=>{const y=Wr(v);return fn(f,y),y},[Wr,fn]),Yi=l.useCallback((f,v)=>v===se.COMPLETED||v===se.ABORTED||v===se.ERRORED?(fn(f,v),v):null,[fn]),Wo=l.useCallback((f,v)=>{if(!f)return;const y=te.current.get(f);y&&clearTimeout(y);const E=setTimeout(()=>{te.current.delete(f);const K=t?.id||ce||null;!K||K!==f||(Hr(f,v),s&&s({type:"check-session-status",sessionId:f,provider:v||Wt}))},1200);te.current.set(f,E)},[Wt,ce,Hr,t?.id,s]),Cr=l.useCallback(()=>{ie.current&&(ie.current.scrollTop=ie.current.scrollHeight)},[]),hs=l.useCallback(()=>{if(!ie.current)return!1;const{scrollTop:f,scrollHeight:v,clientHeight:y}=ie.current;return v-f-y<50},[]),gs=l.useCallback(async(f=null)=>{const v=f||ie.current;if(!v||dt.current||he||!St||!t||!e)return!1;const y=t.__provider||ae||"claude";dt.current=!0;const E=v.scrollHeight,K=v.scrollTop,de=W.current;try{const we=await Nr(e.name,t.id,!0,y,de);return we.length>0&&($.current={height:E,top:K},Ze(Be=>[...we,...Be])),!0}finally{dt.current=!1}},[St,he,t,e,Nr,ae]),xs=l.useCallback(async()=>{if(ie.current){const f=ie.current,v=hs();Rn(!v),f.scrollTop<100?Et.current||await gs(f)&&(Et.current=!0):Et.current=!1}},[hs,gs]);l.useLayoutEffect(()=>{if(!$.current||!ie.current)return;const{height:f,top:v}=$.current,y=ie.current,K=y.scrollHeight-f;y.scrollTop=v+Math.max(K,0),$.current=null},[U.length]),l.useEffect(()=>{(async()=>{if(t&&e){const v=t.__provider||Jt(localStorage.getItem("selected-provider"));be.current=!0,sessionStorage.removeItem("pendingSessionId");const y=ce!==null&&ce!==t.id;let E=null;if(y?(et||(Re(),Xe(),I.current=null,ue([]),Ze([]),xt(null),rt(!1)),W.current=0,kt(0),J(!1),je(0),$r(null),Ye(!1)):ce===null&&(W.current=0,kt(0),J(!1),je(0)),$e(t.id),et)tt(!1);else{const K=await Nr(e.name,t.id,!1,t.__provider||v||"claude");Ze(K),E=Ji(t.id,K),E||Ue(se.IDLE),n&&s&&Gi(E)&&s({type:"check-session-status",sessionId:t.id,provider:v})}}else{const y=I.current?.sessionId||null||ke.current&&(ce||ht.current.sessionId)||null,E=!!(y||ke.current);et||E||(Re(),Xe(),I.current=null,ue([]),Ze([]),xt(null),rt(!1),Ye(!1)),$e(y),W.current=0,kt(0),J(!1),je(0),$r(null)}setTimeout(()=>{be.current=!1},250)})()},[t?.id,t?.__provider,e?.name,e?.fullPath,e?.path,Nr,Cr,et,Re,Xe,Ji,s,Ue,Gi,n]),l.useEffect(()=>{const f=ye.current;if(D<=f||(ye.current=D,!t||!e))return;(async()=>{try{const y=t.__provider||Jt(localStorage.getItem("selected-provider")),E=await Nr(e.name,t.id,!1,t.__provider||y||"claude");Ze(E),T&&hs()&&setTimeout(()=>Cr(),200)}catch(y){console.error("Error reloading messages from external update:",y)}})()},[D,t,e,Nr,hs,T,Cr]),l.useEffect(()=>{ye.current=D},[D,e?.name,t?.id]),l.useEffect(()=>{t?.id&&(I.current=null)},[t?.id]),l.useEffect(()=>{const f=t?.id||ce||null,v=ht.current,y=!!(v.startedAt&&(!v.sessionId||!f||v.sessionId===f)&&fe!==se.IDLE);ue(E=>Vv(E,Vi,{preserveLocalTail:y}))},[Vi,ce,fe,t?.id,ue]),l.useEffect(()=>{i&&i(ft)},[ft,i]),l.useEffect(()=>{e&&V!==""?It.setItem(`draft_input_${e.name}`,V):e&&V===""&&It.removeItem(`draft_input_${e.name}`)},[V,e]),l.useEffect(()=>{e&&U.length>0&&It.setItem(`chat_messages_${e.name}`,JSON.stringify(fa(U)))},[U,e]),l.useEffect(()=>{const f=fa(U);_y(U,f)||ue(f)},[U,ue]),l.useEffect(()=>{if(e){if(re.current){re.current=!1;return}const f=It.getItem(`draft_input_${e.name}`)||"";f!==V&&xe(f)}},[e?.name]),l.useEffect(()=>{ce&&O&&u&&u(ce)},[O,ce,u]),l.useEffect(()=>{if(ce&&m){const f=m.has(ce),v=fs(Ve);if(f&&v){p&&p(ce);return}f&&!O&&fe!==se.COMPLETED&&fe!==se.ABORTED&&fe!==se.ERRORED&&Ue(se.STREAMING,{canAbortSession:!0})}},[ce,fs,O,p,m,fe,Ve]),l.useEffect(()=>{if(o){const f=o.data?.message||o.data,y=["projects_updated","session-created"].includes(o.type),E=new Set(["claude-complete","codex-complete","session-aborted","claude-error","codex-error"]),de=o.type==="claude-response"&&f&&f.type==="system"&&f.subtype==="init"?f?.session_id:null,we=sessionStorage.getItem("pendingSessionId");let Be=t?.id||ce||I.current?.sessionId||null;const Le=de&&(!Be||de===Be),gt=y||Le,Rt=!o.sessionId&&I.current&&!I.current.sessionId&&(/error/i.test(o.type||"")||o.type==="conversation-event"&&o.event?.kind==="error"),nt=ze=>{ze&&(d&&d(ze),p&&p(ze))};if(!gt){if(!Be&&o.sessionId&&!Ls(o.sessionId)&&I.current&&!I.current.sessionId&&(Be=o.sessionId,I.current.sessionId=o.sessionId,$e(o.sessionId)),!Be&&(o.sessionId&&E.has(o.type)&&nt(o.sessionId),!Rt)||!o.sessionId&&!Rt)return;if(!Rt&&o.sessionId!==Be){const ze=Ls(Be),pt=!!(o.sessionId&&we&&o.sessionId===we);if(ze&&(pt||!Ls(o.sessionId||"")))$e(o.sessionId),I.current&&(I.current.sessionId=o.sessionId);else{o.sessionId&&E.has(o.type)&&nt(o.sessionId),console.log("??-?,? Skipping message for different session:",o.sessionId,"current:",Be);return}}}const ys=o?.event?.sessionId||o.sessionId||Be||null,sr=!!(ys&&Q.current.has(ys));if(o.type==="conversation-event"&&o.event){const ze=o.event.sessionId||o.sessionId||Be||null,pt=o.event.rawRef?.type||null,or=o.event.kind==="session_state_changed"?String(o.event.payload?.state||"").trim().toLowerCase():"";if(ze&&Q.current.add(ze),or==="idle"&&Lt(ze,pt)){Wo(ze,o.event.provider||Wt);return}if(!!(ze&&(ze===(t?.id||null)||ze===(ce||null)||ze===(I.current?.sessionId||null)))&&Pt(o.event),Nt(o.event,o.event.provider||Wt),o.event.kind==="approval_request"&&Ue(se.AWAITING_APPROVAL),o.event.kind==="approval_resolved"&&Ue(se.STREAMING),(o.event.kind==="assistant_text_start"||o.event.kind==="assistant_text_delta"||o.event.kind==="reasoning_start"||o.event.kind==="reasoning_delta"||o.event.kind==="tool_call_start"||o.event.kind==="tool_call_input"||o.event.kind==="tool_call_end"||o.event.kind==="tool_result")&&Ue(se.STREAMING),(o.event.kind==="error"||o.event.payload?.state==="errored")&&(Xe(ze),Ue(se.ERRORED),xt(null),ze&&(nt(ze),Hr(ze,o.event.provider||Wt))),o.event.kind==="session_state_changed"){const Xt=or;Xt==="streaming"?(Ue(se.STREAMING),ze&&u&&u(ze)):Xt==="awaiting_approval"?(Ue(se.AWAITING_APPROVAL),ze&&u&&u(ze)):Xt==="completed"?(Xe(ze),Ue(se.COMPLETED),xt(null),ze&&(nt(ze),Hr(ze,o.event.provider||Wt))):Xt==="aborted"?(Xe(ze),Ue(se.ABORTED),xt(null),ze&&(nt(ze),Hr(ze,o.event.provider||Wt))):Xt==="errored"&&(Xe(ze),Ue(se.ERRORED),xt(null),ze&&(nt(ze),Hr(ze,o.event.provider||Wt)))}return}switch(o.type){case"ws-connection-state":o.state==="connecting"&&(fe===se.QUEUED||O)?Ue(se.CONNECTING,{canAbortSession:!1}):o.state==="connected"&&fe===se.CONNECTING&&Ue(se.QUEUED);break;case"connection-error":Ue(se.ERRORED),xt(null),ue(G=>[...G,{type:"error",content:o.error||"Unable to reach the chat server. Message was not sent.",timestamp:new Date}]);break;case"error":Ue(se.ERRORED),rt(!1),xt(null),ue(G=>[...G,{type:"error",content:o.error||"The chat server reported an unexpected error.",timestamp:new Date}]);break;case"session-created":if(o.sessionId){const G=Jt(o.provider||Wt),me=I.current?.sessionId||ce||null,Te=Ls(o.sessionId);if(!(!ce||G==="codex"&&o.sessionId!==ce)||Te)break;sessionStorage.setItem("pendingSessionId",o.sessionId);try{const st=localStorage.getItem("session-provider-map"),it=st?JSON.parse(st):{};it[o.sessionId]=G,localStorage.setItem("session-provider-map",JSON.stringify(it))}catch{}I.current&&(I.current.sessionId=o.sessionId),$e(o.sessionId),tr(o.sessionId),u&&u(o.sessionId),tt(!0),h&&h(o.sessionId,me),bt(st=>st.map(it=>it.sessionId?it:{...it,sessionId:o.sessionId})),g&&g(o.sessionId),typeof window<"u"&&typeof window.refreshProjects=="function"&&window.refreshProjects()}break;case"token-budget":o.data&&$r(o.data);break;case"claude-response":const ze=sr&&!(o.data?.type==="system"&&o.data?.subtype==="init");if(!ze&&f&&typeof f=="object"&&f.type){if(f.type==="content_block_delta"&&f.delta?.text){const G=Zr(f.delta.text);z.current+=G,ne.current||(ne.current=setTimeout(()=>{const me=z.current;z.current="",ne.current=null,me&&ue(Te=>{const He=[...Te],st=He[He.length-1];return st&&st.type==="assistant"&&!st.isToolUse&&st.isStreaming?st.content=(st.content||"")+me:He.push({type:"assistant",content:me,timestamp:new Date,isStreaming:!0}),He})},100));return}if(f.type==="content_block_stop"){ne.current&&(clearTimeout(ne.current),ne.current=null);const G=z.current;z.current="",G&&ue(me=>{const Te=[...me],He=Te[Te.length-1];return He&&He.type==="assistant"&&!He.isToolUse&&He.isStreaming?He.content=(He.content||"")+G:Te.push({type:"assistant",content:G,timestamp:new Date,isStreaming:!0}),Te}),ue(me=>{const Te=[...me],He=Te[Te.length-1];return He&&He.type==="assistant"&&He.isStreaming&&(He.isStreaming=!1),Te});return}}if(o.data.type==="system"&&o.data.subtype==="init"&&o.data.session_id&&ce&&o.data.session_id!==ce&&Le){console.log("🔄 Claude CLI session duplication detected:",{originalSession:ce,newSession:o.data.session_id}),tt(!0),g&&g(o.data.session_id);return}if(o.data.type==="system"&&o.data.subtype==="init"&&o.data.session_id&&!ce&&Le){console.log("🔄 New session init detected:",{newSession:o.data.session_id}),tt(!0),g&&g(o.data.session_id);return}if(o.data.type==="system"&&o.data.subtype==="init"&&o.data.session_id&&ce&&o.data.session_id===ce&&Le){console.log("🔄 System init message for current session, ignoring");return}if(ze)break;if(Array.isArray(f.content)){for(const G of f.content)if(G.type==="tool_use"){const me=G.input?JSON.stringify(G.input,null,2):"";ue(Te=>[...Te,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:G.name,toolInput:me,toolId:G.id,toolResult:null}])}else if(G.type==="text"&&G.text?.trim()){let me=Zr(G.text);me=qa(me),ue(Te=>[...Te,{type:"assistant",content:me,timestamp:new Date}])}}else if(typeof f.content=="string"&&f.content.trim()){let G=Zr(f.content);G=qa(G),ue(me=>[...me,{type:"assistant",content:G,timestamp:new Date}])}if(f.role==="user"&&Array.isArray(f.content))for(const G of f.content)G.type==="tool_result"&&ue(me=>me.map(Te=>Te.isToolUse&&Te.toolId===G.tool_use_id?{...Te,toolResult:{content:G.content,isError:G.is_error,timestamp:new Date}}:Te));break;case"claude-output":if(sr)break;{const G=String(o.data||"");G.trim()&&(z.current+=z.current?`
310
- ${G}`:G,ne.current||(ne.current=setTimeout(()=>{const me=z.current;z.current="",ne.current=null,me&&ue(Te=>{const He=[...Te],st=He[He.length-1];return st&&st.type==="assistant"&&!st.isToolUse&&st.isStreaming?st.content=st.content?`${st.content}
311
- ${me}`:me:He.push({type:"assistant",content:me,timestamp:new Date,isStreaming:!0}),He})},100)))}break;case"claude-interactive-prompt":ue(G=>[...G,{type:"assistant",content:o.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":{if(sr||ae!=="claude"||!o.requestId)break;bt(G=>G.some(me=>me.requestId===o.requestId)?G:[...G,{requestId:o.requestId,toolName:o.toolName||"UnknownTool",input:o.input,context:o.context,sessionId:o.sessionId||null,receivedAt:new Date}]),Ye(!0),rt(!0),xt(Ga({phaseText:M("activity.stage.waitingPermission"),detailText:o.toolName?M("activity.requestTool",{tool:Rc(o.toolName)}):M("activity.permission.title"),canAbort:!0}));break}case"claude-permission-cancelled":{if(sr||!o.requestId)break;bt(G=>{const me=G.filter(Te=>Te.requestId!==o.requestId);return me.length===0&&xt(null),me});break}case"claude-error":if(sr)break;Xe(o.sessionId||ce||null),Ye(!1),rt(!1),xt(null),ue(G=>[...G,{type:"error",content:`出错了:${o.error}`,timestamp:new Date}]);break;case"claude-complete":if(sr)break;const pt=o.sessionId||ce||sessionStorage.getItem("pendingSessionId");Xe(pt),(pt===ce||!ce)&&(Ye(!1),rt(!1),xt(null)),pt&&(d&&d(pt),p&&p(pt));const or=sessionStorage.getItem("pendingSessionId");or&&!ce&&o.exitCode===0&&($e(or),sessionStorage.removeItem("pendingSessionId"),console.log("✅ New session complete, ID set to:",or)),e&&o.exitCode===0&&It.removeItem(`chat_messages_${e.name}`),bt([]);break;case"codex-response":const Oe=o.data;if(Oe){if(sr)break;if(Oe.type==="item_delta"&&Oe.delta){const G=Zr(String(Oe.delta));if(G){const me=`codex:${Oe.itemType||"item"}:${Oe.itemId||"unknown"}`;ue(Te=>{const He=[...Te];let st=-1;for(let it=He.length-1;it>=0;it--){const hr=He[it];if(hr?.codexItemKey===me&&hr.type==="assistant"&&!hr.isToolUse){st=it;break}}if(st===-1)He.push({type:"assistant",content:G,timestamp:new Date,isStreaming:!0,isThinking:!!Oe.isReasoning,codexItemKey:me});else{const it=He[st],hr=it.content||"";hr.endsWith(G)||(it.content=hr+G),it.isStreaming=!0}return He})}break}if(Oe.type==="item_done"){const G=`codex:${Oe.itemType||"item"}:${Oe.itemId||"unknown"}`,me=typeof Oe.content=="string"?Zr(Oe.content):"";ue(Te=>{const He=[...Te];let st=-1;for(let it=He.length-1;it>=0;it--){const hr=He[it];if(hr?.codexItemKey===G&&hr.type==="assistant"&&!hr.isToolUse){st=it;break}}if(st!==-1){const it=He[st];me&&me!==(it.content||"")&&(it.content=me),it.isStreaming=!1}else me.trim()&&He.push({type:"assistant",content:me,timestamp:new Date,isStreaming:!1,isThinking:!!Oe.isReasoning});return He});break}if(Oe.type==="item")switch(Oe.itemType){case"agent_message":if(Oe.message?.content?.trim()){const G=Zr(Oe.message.content);ue(me=>{const Te=me[me.length-1];return Te&&Te.type==="assistant"&&!Te.isToolUse&&!Te.isThinking&&(Te.content||"").trim()===G.trim()?me:[...me,{type:"assistant",content:G,timestamp:new Date}]})}break;case"reasoning":if(Oe.message?.content?.trim()){const G=Zr(Oe.message.content);ue(me=>{const Te=me[me.length-1];return Te&&Te.type==="assistant"&&!Te.isToolUse&&Te.isThinking&&(Te.content||"").trim()===G.trim()?me:[...me,{type:"assistant",content:G,timestamp:new Date,isThinking:!0}]})}break;case"command_execution":Oe.command&&ue(G=>[...G,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:Oe.command,toolResult:Oe.output||null,exitCode:Oe.exitCode}]);break;case"file_change":if(Oe.changes?.length>0){const G=Oe.changes.map(me=>`${me.kind}: ${me.path}`).join(`
312
- `);ue(me=>[...me,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:G,toolResult:`Status: ${Oe.status}`}])}break;case"mcp_tool_call":ue(G=>[...G,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${Oe.server}:${Oe.tool}`,toolInput:JSON.stringify(Oe.arguments,null,2),toolResult:Oe.result?JSON.stringify(Oe.result,null,2):Oe.error?.message||null}]);break;case"error":Oe.message?.content&&ue(G=>[...G,{type:"error",content:Oe.message.content,timestamp:new Date}]);break;default:console.log("[Codex] Unhandled item type:",Oe.itemType,Oe)}Oe.type==="turn_complete"&&Ye(!1),Oe.type==="turn_failed"&&(Ye(!1),ue(G=>[...G,{type:"error",content:Oe.error?.message||"Turn failed",timestamp:new Date}]))}break;case"codex-complete":if(sr)break;const Xt=o.sessionId||ce||sessionStorage.getItem("pendingSessionId");Xe(Xt),(Xt===ce||!ce)&&(Ye(!1),rt(!1),xt(null),ue(G=>G.map(me=>me?.codexItemKey&&me.isStreaming?{...me,isStreaming:!1}:me))),Xt&&(d&&d(Xt),p&&p(Xt));const Yo=sessionStorage.getItem("pendingSessionId"),ol=o.actualSessionId||Yo;Yo&&!ce&&($e(ol),tt(!0),g&&g(ol),sessionStorage.removeItem("pendingSessionId"),console.log("Codex session complete, ID set to:",Yo)),e&&Xt&&Nr(e.name,Xt,!1,"codex").then(G=>{Array.isArray(G)&&G.length>0&&Ze(G)}).catch(G=>{console.error("Error reloading Codex session after completion:",G)}),e&&It.removeItem(`chat_messages_${e.name}`);break;case"codex-error":if(sr)break;Xe(o.sessionId||ce||null),Ye(!1),rt(!1),ue(G=>G.map(me=>me?.codexItemKey&&me.isStreaming?{...me,isStreaming:!1}:me)),ue(G=>[...G,{type:"error",content:o.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{if(sr)break;const G=o.sessionId||ce;Xe(G),G===ce&&(Ye(!1),rt(!1),xt(null)),G&&(d&&d(G),p&&p(G)),bt([]),ue(me=>[...me,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}]);break}case"session-status":{if(sr)break;const G=o.sessionId,me=o.provider||t?.__provider||Wt,Te=G===ce||t&&G===t.id,He=Wr(Ve),st=fs(Ve);if(Te&&o.isProcessing){if(st){Yi(G,st);break}Ye(!0),rt(!0),u&&u(G)}else if(Te&&o.isProcessing===!1){if(Lt(G,"session-status")){Wo(G,me);break}Hr(G,me).then(it=>{if(!(it===se.COMPLETED||it===se.ABORTED||it===se.ERRORED)){if(He===se.STREAMING||He===se.AWAITING_APPROVAL){Ue(He);return}Ye(!1),rt(!1),xt(null)}})}break}case"claude-status":const Kt=o.data;if(Kt){let G={text:"Working...",tokens:0,can_interrupt:!0};Kt.message?G.text=Kt.message:Kt.status?G.text=Kt.status:typeof Kt=="string"&&(G.text=Kt),Kt.tokens?G.tokens=Kt.tokens:Kt.token_count&&(G.tokens=Kt.token_count),Kt.can_interrupt!==void 0&&(G.can_interrupt=Kt.can_interrupt),xt(Ry(Kt,M,Ii.current)),Ye(!0),rt(G.can_interrupt)}break}}},[Wt,Pt,Xe,ce,Wr,fs,O,o,Hr,Yi,fe,Wo,t,Lt,tr,M]),l.useEffect(()=>{e&&Ap()},[e]);const Ap=async()=>{try{const f=await mt.getFiles(e.name);if(f.ok){const v=await f.json(),y=Xi(v);Ge(y)}}catch(f){console.error("Error fetching files:",f)}},Xi=(f,v="")=>{let y=[];for(const E of f){const K=v?`${v}/${E.name}`:E.name;E.type==="directory"&&E.children?y=y.concat(Xi(E.children,K)):E.type==="file"&&y.push({name:E.name,path:K,relativePath:E.path})}return y};l.useEffect(()=>{const f=V.slice(0,Ni),v=f.lastIndexOf("@");if(v!==-1){const y=f.slice(v+1);if(y.includes(" "))ut(!1),ss(-1);else{ss(v),ut(!0);const E=ot.filter(K=>K.name.toLowerCase().includes(y.toLowerCase())||K.path.toLowerCase().includes(y.toLowerCase())).slice(0,10);Pr(E),un(-1)}}else ut(!1),ss(-1)},[V,Ni,ot]);const Ho=l.useMemo(()=>!V||Dt.length===0?[]:Dt.filter(f=>V.includes(f)),[Dt,V]),Fn=l.useMemo(()=>Ho.length===0?[]:Array.from(new Set(Ho)).sort((v,y)=>y.length-v.length),[Ho]),qo=l.useMemo(()=>{if(Fn.length===0)return null;const f=Fn.map(iy).join("|");return new RegExp(`(${f})`,"g")},[Fn]),Qi=l.useMemo(()=>new Set(Fn),[Fn]),Tp=l.useCallback(f=>f?qo?f.split(qo).map((y,E)=>Qi.has(y)?r.jsx("span",{className:"bg-primary/20 -ml-0.5 dark:bg-primary/25 px-0.5 rounded-md box-decoration-clone text-transparent",children:y},`mention-${E}`):r.jsx("span",{children:y},`text-${E}`)):f:"",[qo,Qi]);l.useEffect(()=>{const f=setTimeout(()=>{Qe(V)},150);return()=>clearTimeout(f)},[V]);const hn=l.useMemo(()=>t||U.length<=Pn?U:U.slice(-Pn),[U,Pn,t]),_p=l.useMemo(()=>{const f=hn.map((y,E)=>({...y,__threadMessageId:ly(y,E)}));return f.length===0||!O||f.some(y=>y?.type!=="assistant"?!1:!!(y.isStreaming||y.isToolUse||y.isThinking||y.reasoning))?f:[...f,{id:"__assistant-loading-indicator__",type:"assistant",content:"",timestamp:new Date,isLoadingIndicator:!0,__provider:t?.__provider||ae||"claude"}]},[hn,O,t?.__provider,ae]);l.useMemo(()=>{if(!O||hn.length===0)return-1;for(let f=hn.length-1;f>=0;f--){const v=hn[f];if(v.type==="assistant"&&(v.isStreaming||v.isToolUse||v.isThinking||v.reasoning))return f}return-1},[hn,O]),l.useEffect(()=>{if(!T&&ie.current){const f=ie.current;vo.current={height:f.scrollHeight,top:f.scrollTop}}}),l.useEffect(()=>{if(ie.current&&U.length>0)if(T)xo||setTimeout(()=>Cr(),50);else{const f=ie.current,v=vo.current.height,y=vo.current.top,K=f.scrollHeight-v;K>0&&y>0&&(f.scrollTop=y+K)}},[U.length,xo,Cr,T]),l.useEffect(()=>{ie.current&&U.length>0&&!be.current&&(Rn(!1),setTimeout(()=>{Cr()},200))},[t?.id,e?.name]),l.useEffect(()=>{const f=ie.current;if(f)return f.addEventListener("scroll",xs),()=>f.removeEventListener("scroll",xs)},[xs]),l.useEffect(()=>{if(X.current){X.current.style.height="auto",X.current.style.height=X.current.scrollHeight+"px";const f=parseInt(window.getComputedStyle(X.current).lineHeight),v=X.current.scrollHeight>f*2;Kr(v)}},[]),l.useEffect(()=>{X.current&&!V.trim()&&(X.current.style.height="auto",Kr(!1))},[V]),l.useEffect(()=>{if(!e||!t?.id||t.id.startsWith("new-session-")){$r(null);return}if((t.__provider||ae||"claude")!=="claude")return;(async()=>{try{const y=`/api/projects/${e.name}/sessions/${t.id}/token-usage`,E=await oe(y);if(E.ok){const K=await E.json();$r(K)}else $r(null)}catch(y){console.error("Failed to fetch initial token usage:",y)}})()},[t?.id,t?.__provider,e?.path]),l.useCallback(f=>{f.trim()&&xe(v=>{const y=v.trim()?`${v} ${f}`:f;return setTimeout(()=>{if(X.current){X.current.style.height="auto",X.current.style.height=X.current.scrollHeight+"px";const E=parseInt(window.getComputedStyle(X.current).lineHeight),K=X.current.scrollHeight>E*2;Kr(K)}},0),y})},[]);const Mp=l.useCallback(()=>{cp(f=>f+100)},[]),Dp=l.useCallback(()=>{gs()},[gs]),vs=l.useCallback(f=>{const v=f.filter(y=>{try{if(!y||typeof y!="object")return console.warn("Invalid file object:",y),!1;if(!y.type||!y.type.startsWith("image/"))return!1;if(!y.size||y.size>5242880){const E=y.name||"Unknown file";return pe(K=>{const de=new Map(K);return de.set(E,"File too large (max 5MB)"),de}),!1}return!0}catch(E){return console.error("Error validating file:",E,y),!1}});v.length>0&&Ot(y=>[...y,...v].slice(0,5))},[]),Rp=l.useCallback(async f=>{const v=Array.from(f.clipboardData.items);for(const y of v)if(y.type.startsWith("image/")){const E=y.getAsFile();E&&vs([E])}if(v.length===0&&f.clipboardData.files.length>0){const E=Array.from(f.clipboardData.files).filter(K=>K.type.startsWith("image/"));E.length>0&&vs(E)}},[vs]),{getRootProps:Pp,getInputProps:Lp,isDragActive:Op,open:Fp}=hu({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:vs,noClick:!0,noKeyboard:!0}),Qr=l.useCallback(async(f,v=null)=>{f.preventDefault();const y=typeof v=="string"?v:V,E=t?.__provider||ae||"claude";if((Io[E]?.status||Ps)===ma||!y.trim()||O||!e)return;let de=y;const we=Kl(E),Be=we.enabled?Dm.find(pt=>pt.id===Jr):null;we.strategy==="prompt-prefix"&&Be&&Be.prefix&&(de=`${Be.prefix}: ${y}`);const Le=!ps&&by(Sr)?Iy(Sr):null;Le&&(de=Ay(Le,de)),Ue(se.QUEUED),xt(Ga({phaseText:M("activity.stage.generatingReply"),detailText:M("activity.detail.preparingReply"),canAbort:!0}));let gt=[];if(jt.length>0){if(!Uv(E)){Ue(se.IDLE),rt(!1),xt(null),ue(pt=>[...pt,{type:"error",content:`${E} 当前不支持图片输入`,timestamp:new Date}]);return}try{gt=await ty(jt)}catch(pt){console.error("Image preparation failed:",pt),Ue(se.IDLE),rt(!1),xt(null),ue(or=>[...or,{type:"error",content:`图片处理失败:${pt.message}`,timestamp:new Date}]);return}}const Rt={type:"user",content:y,images:gt,timestamp:new Date};ue(pt=>[...pt,Rt]),Rn(!1),setTimeout(()=>Cr(),100);const nt=ce||t?.id;Ct(nt||t?.id||null),nt&&Pt(Ht({kind:"user_message",provider:E,sessionId:nt,timestamp:Rt.timestamp,payload:{text:y}}));const ys=nt||`new-session-${Date.now()}`;!nt&&!t?.id&&(I.current={sessionId:null,startedAt:Date.now()}),c&&c(ys);const ze=(()=>{try{const pt=ae==="codex"?"codex-settings":"claude-settings",or=It.getItem(pt);if(or)return JSON.parse(or)}catch(pt){console.error("Error loading tools settings:",pt)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();if(E==="codex"){const pt=we.enabled&&we.strategy==="native-effort"?Wv(Jr):void 0;s({type:"codex-command",command:de,sessionId:nt,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:nt,resume:!!nt,permissionMode:Je==="plan"?"default":Je,...Yt?{model:Yt}:{},...pt?{modelReasoningEffort:pt}:{},images:gt}})}else s(E==="gemini"?{type:"gemini-command",command:de,sessionId:nt,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:nt,resume:!!nt,permissionMode:Je==="plan"?"default":Je,...Yt?{model:Yt}:{}}}:E==="opencode"?{type:"opencode-command",command:de,sessionId:nt,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:nt,resume:!!nt,permissionMode:Je==="plan"?"default":Je,...Yt?{model:Yt}:{}}}:{type:"claude-command",command:de,options:{projectPath:e.path,cwd:e.fullPath,sessionId:nt,resume:!!nt,toolsSettings:ze,permissionMode:Je,...Yt?{model:Yt}:{},images:gt}});Le&&ms(!0),xe(""),Ot([]),zt(new Map),pe(new Map),Kr(!1),as("none"),X.current&&(X.current.style.height="auto"),e&&It.removeItem(`draft_input_${e.name}`)},[V,O,e,jt,ce,t,ae,Io,Je,c,To,Mo,Ro,Lo,s,xe,Ot,zt,pe,Kr,X,ue,Ye,rt,xt,Rn,Cr,Jr,Sr,ps,Ct,Pt]),Zi=l.useCallback(f=>!f||ae!=="claude"?{success:!1}:Dy(f.entry),[ae]),Vo=l.useCallback((f,v)=>{const E=(Array.isArray(f)?f:[f]).filter(Boolean);E.length!==0&&(E.forEach(K=>{s({type:"claude-permission-response",requestId:K,allow:!!v?.allow,updatedInput:v?.updatedInput,message:v?.message,rememberEntry:v?.rememberEntry})}),bt(K=>{const de=K.filter(we=>!E.includes(we.requestId));return de.length===0&&xt(null),de}))},[s]);l.useEffect(()=>{On.current=Qr},[Qr]);const el=f=>{if(!f)return;const v=V.slice(0,Ei),y=V.slice(Ei),E=y.indexOf(" "),K=E!==-1?y.slice(E):"",de=v+f.name+" "+K;xe(de),Lr(!1),zr(-1),Fr(""),Br(-1),H.current&&clearTimeout(H.current),qi(f)},$p=f=>{if(yo&&Gr.length>0){if(f.key==="ArrowDown"){f.preventDefault(),Br(v=>v<Gr.length-1?v+1:0);return}if(f.key==="ArrowUp"){f.preventDefault(),Br(v=>v>0?v-1:Gr.length-1);return}if(f.key==="Tab"||f.key==="Enter"){f.preventDefault(),ko>=0?el(Gr[ko]):Gr.length>0&&el(Gr[0]);return}if(f.key==="Escape"){f.preventDefault(),Lr(!1),zr(-1),Fr(""),Br(-1),H.current&&clearTimeout(H.current);return}}if(wt&&Gt.length>0){if(f.key==="ArrowDown"){f.preventDefault(),un(v=>v<Gt.length-1?v+1:0);return}if(f.key==="ArrowUp"){f.preventDefault(),un(v=>v>0?v-1:Gt.length-1);return}if(f.key==="Tab"||f.key==="Enter"){f.preventDefault(),Bt>=0?Go(Gt[Bt]):Gt.length>0&&Go(Gt[0]);return}if(f.key==="Escape"){f.preventDefault(),ut(!1);return}}if(f.key==="Tab"&&!wt&&!yo){f.preventDefault();const v=Ur.modes,E=(v.indexOf(Je)+1)%v.length,K=v[E];Mt(K),t?.id&&localStorage.setItem(`permissionMode-${t.id}`,K);return}if(f.key==="Enter"){if(f.nativeEvent.isComposing)return;(f.ctrlKey||f.metaKey)&&!f.shiftKey?(f.preventDefault(),Qr(f)):!f.shiftKey&&!f.ctrlKey&&!f.metaKey&&(w||(f.preventDefault(),Qr(f)))}},Go=f=>{const v=V.slice(0,Ci),y=V.slice(Ci),E=y.indexOf(" "),K=E!==-1?y.slice(E):"",de=v+f.path+" "+K,we=v.length+f.path.length+1;X.current&&!X.current.matches(":focus")&&X.current.focus(),xe(de),ns(we),Ut(Be=>Be.includes(f.path)?Be:[...Be,f.path]),ut(!1),ss(-1),X.current&&requestAnimationFrame(()=>{X.current&&(X.current.setSelectionRange(we,we),X.current.matches(":focus")||X.current.focus())})},Bp=f=>{const v=f.target.value,y=f.target.selectionStart;if(!ce&&v.trim(),xe(v),ns(y),!v.trim()){f.target.style.height="auto",Kr(!1),Lr(!1),zr(-1),Fr("");return}const E=v.slice(0,y);if((E.match(/```/g)||[]).length%2===1){Lr(!1),zr(-1),Fr("");return}const we=/(^|\s)\/(\S*)$/,Be=E.match(we);if(Be){const Le=Be.index+Be[1].length,gt=Be[2];zr(Le),Lr(!0),Br(-1),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{Fr(gt)},150)}else Lr(!1),zr(-1),Fr(""),H.current&&clearTimeout(H.current)},tl=l.useCallback(f=>{!F.current||!f||(F.current.scrollTop=f.scrollTop,F.current.scrollLeft=f.scrollLeft)},[]),zp=f=>{ns(f.target.selectionStart)},Up=()=>{ce&&S&&s({type:"abort-session",sessionId:ce,provider:ae})};if(!e)return r.jsx("div",{className:"flex h-full items-center justify-center px-4 py-8 sm:px-6",children:r.jsxs("div",{className:"max-w-lg px-8 py-10 text-center text-muted-foreground",children:[r.jsx("div",{className:"mx-auto mb-5 flex h-14 w-14 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:r.jsx(Vn,{className:"h-7 w-7"})}),r.jsx("p",{className:"text-base font-medium text-foreground",children:"Select a project to start chatting"})]})});const Er=t?.__provider||ae||"claude",Ko=Io[Er],Jo=(Ko?.status||Ps)===ma,Wp=Ko?.reason||fp[Er]||null,rl=Ko?.installHint||null,nl=!!mp[Er],gn=O||Jo,xn=X0({status:jo,messages:U,pendingPermissionRequests:B,t:M}),Hp=O&&!!xn,qp=Er==="opencode"?"OpenCode":M(`messageTypes.${Er}`),sl=M("input.providerNotInstalledWithName",{provider:qp}),Vp=ae==="codex"?"Codex":ae==="gemini"?"Gemini":ae==="opencode"?"OpenCode":"Claude",Gp=U.length===0?null:r.jsxs(r.Fragment,{children:[he&&r.jsx("div",{className:"pb-3 text-center text-gray-500 dark:text-gray-400",children:r.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[r.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),r.jsx("p",{className:"text-sm",children:M("session.loading.olderMessages")})]})}),St&&!he&&r.jsx("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:ee>0&&r.jsxs("span",{children:[M("session.messages.showingOf",{shown:Ve.length,total:ee})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:Dp,children:M("session.messages.loadEarlier")}),r.jsx("span",{className:"ml-1 text-xs",children:M("session.messages.scrollToLoad")})]})}),!t&&!St&&U.length>Pn&&r.jsxs("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:[M("session.messages.showingLast",{count:Pn,total:U.length})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:Mp,children:M("session.messages.loadEarlier")})]})]}),Kp=U.length===0?null:r.jsx(r.Fragment,{children:B.map(f=>{const v=rc(f.input),y=Va(f.toolName,v),E=yi(),K=y?E.allowedTools.includes(y):!1,de=y?B.filter(we=>Va(we.toolName,rc(we.input))===y).map(we=>we.requestId):[f.requestId];return r.jsx(Q0,{request:f,permissionEntry:y,alreadyAllowed:K,rawInput:v,className:"mx-1 my-3 sm:mx-0",onAllowOnce:()=>Vo(f.requestId,{allow:!0}),onAllowRemember:()=>{y&&!K&&Zi({entry:y,toolName:f.toolName}),Vo(de,{allow:!0,rememberEntry:y})},onDeny:()=>Vo(f.requestId,{allow:!1,message:M("activity.permission.deniedMessage")})},f.requestId)})});return r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
313
- details[open] .details-chevron {
314
- transform: rotate(180deg);
315
- }
316
- `}),r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:yt&&U.length===0?r.jsx("div",{className:"px-3 py-4 text-center text-gray-500 dark:text-gray-400 sm:px-6 sm:py-5 mt-8",children:r.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[r.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),r.jsx("p",{children:M("session.loading.sessionMessages")})]})}):U.length===0?r.jsxs("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:[!t&&!ce&&r.jsxs("div",{className:"w-full max-w-3xl text-center",children:[r.jsx("h2",{className:"mb-2 text-3xl font-semibold tracking-tight text-foreground sm:text-4xl",children:M("providerSelection.title")}),r.jsx("p",{className:"mx-auto mb-8 max-w-xl text-base text-muted-foreground",children:M("providerSelection.description")}),r.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-2",children:[r.jsx("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{us("claude")},className:`group relative w-full h-auto rounded-xl px-3 py-3 transition-colors duration-150 ${ae==="claude"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"}`,children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(rs,{className:"h-10 w-10 flex-shrink-0"}),r.jsx("div",{className:"text-left",children:r.jsx("p",{className:"text-base font-medium text-foreground",children:"Claude Code"})})]})}),r.jsx("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{us("codex")},className:`group relative w-full h-auto rounded-xl px-3 py-3 transition-colors duration-150 ${ae==="codex"?"border-foreground bg-accent/70 text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"}`,children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(co,{className:"h-10 w-10 flex-shrink-0"}),r.jsx("div",{className:"text-left",children:r.jsx("p",{className:"text-base font-medium text-foreground",children:"Codex"})})]})}),r.jsx("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{us("gemini")},className:`group relative w-full h-auto rounded-xl px-3 py-3 transition-colors duration-150 ${ae==="gemini"?"border-foreground bg-accent/70 text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"}`,children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(uo,{className:"h-10 w-10 flex-shrink-0"}),r.jsx("div",{className:"text-left",children:r.jsx("p",{className:"text-base font-medium text-foreground",children:"Gemini"})})]})}),r.jsx("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{us("opencode")},className:`group relative w-full h-auto rounded-xl px-3 py-3 transition-colors duration-150 ${ae==="opencode"?"border-foreground bg-accent/70 text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"}`,children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(po,{className:"h-10 w-auto max-w-full flex-shrink-0 text-foreground"}),r.jsx("div",{className:"text-left",children:r.jsx("p",{className:"text-base font-medium text-foreground",children:"OpenCode"})})]})})]})]}),t&&r.jsxs("div",{className:"px-6 text-center text-muted-foreground sm:px-4",children:[r.jsx("p",{className:"mb-3 text-2xl font-semibold text-foreground",children:M("session.continue.title")}),r.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:M("session.continue.description")})]})]}):r.jsx(Rm,{messages:_p,convertMessage:Pm,isRunning:O,scrollContainerRef:ie,onScroll:xs,messagesEndRef:Ae,provider:ae,providerLabel:Vp,createDiff:Cp,onFileOpen:a,onShowSettings:x,onGrantToolPermission:Zi,showRawParameters:k,autoExpandTools:j,selectedProject:e,markdownRenderer:Ha,topContent:Gp,bottomContent:Kp})}),r.jsxs("div",{className:"flex-shrink-0 bg-background px-3 py-3 sm:px-4 sm:py-4 pb-2 sm:pb-4 md:pb-6",children:[r.jsx("div",{className:"flex-1",children:r.jsx(Lm,{phaseText:xn?.phaseText,detailText:xn?.detailText,elapsedSeconds:xn?.elapsedSeconds,startedAt:xn?.startedAt,canAbort:xn?.canAbort,isLoading:Hp,onAbort:Up,provider:ae})}),r.jsx("div",{ref:C,className:"mx-auto mb-3 w-full max-w-4xl"}),r.jsxs("form",{onSubmit:Qr,className:"relative mx-auto w-full max-w-4xl",children:[xo&&U.length>0&&r.jsx("button",{type:"button",onClick:Cr,className:"absolute -top-12 right-0 z-10 flex h-8 w-8 items-center justify-center rounded-full bg-muted/80 text-muted-foreground transition-all duration-200 hover:bg-muted hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring",title:"滚动到底部",children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})}),Op&&r.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center rounded-2xl border border-dashed border-primary bg-primary/5",children:r.jsxs("div",{className:"rounded-xl border border-border/70 bg-background p-4",children:[r.jsx("svg",{className:"w-8 h-8 text-primary mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),r.jsx("p",{className:"text-sm font-medium",children:"将图片拖到这里"})]})}),jt.length>0&&r.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:r.jsx("div",{className:"flex flex-wrap gap-2",children:jt.map((f,v)=>r.jsx(Oy,{file:f,onRemove:()=>{Ot(y=>y.filter((E,K)=>K!==v))},uploadProgress:rr.get(f.name),error:_.get(f.name)},v))})}),nr&&r.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[wr(nr.systemContext)&&r.jsx(zn,{content:nr.systemContext,className:"whitespace-normal break-words max-w-sm",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[260px] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-300 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5h16M4 12h16M4 19h16"})}),r.jsx("span",{className:"truncate",children:M("input.dynamicContext.systemChip")}),r.jsx("button",{type:"button",onClick:yp,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:M("input.dynamicContext.removeSystem"),"aria-label":M("input.dynamicContext.removeSystem"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),wr(kn(nr.currentFile))&&r.jsx(zn,{content:kn(nr.currentFile),className:"whitespace-normal break-words max-w-sm",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[260px] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-emerald-500 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l4.414 4.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),r.jsx("span",{className:"truncate",children:vy(nr.currentFile)}),r.jsx("button",{type:"button",onClick:bp,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:M("input.dynamicContext.removeCurrentFile"),"aria-label":M("input.dynamicContext.removeCurrentFile"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),vp.map((f,v)=>r.jsx(zn,{content:Zl(f),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-normal break-words",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[min(22rem,calc(100vw-4rem))] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",title:f.selector,children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-primary flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 15l2 5L7 17l3-10 10 3-5 2z"})}),r.jsx("span",{className:"truncate",children:f.tag||M("input.dynamicContext.elementFallback")}),r.jsx("button",{type:"button",onClick:()=>wp(f),className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:M("input.dynamicContext.removeElement"),"aria-label":M("input.dynamicContext.removeElement"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},`${f.selector}-${v}`)),zo.length>0&&r.jsx(zn,{content:zo.map(Zl).join(`
317
- `),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-pre-wrap break-words",delay:200,children:r.jsxs("div",{className:"inline-flex items-center gap-1 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-muted-foreground",children:["+",zo.length]})})]})}),wt&&Gt.length>0&&r.jsx("div",{className:"chat-floating-panel absolute bottom-full left-0 right-0 z-50 mb-2 max-h-48 overflow-y-auto rounded-2xl",children:Gt.map((f,v)=>r.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 touch-manipulation ${v===Bt?"bg-primary/10 dark:bg-primary/20 text-primary":"hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300"}`,onMouseDown:y=>{y.preventDefault(),y.stopPropagation()},onClick:y=>{y.preventDefault(),y.stopPropagation(),Go(f)},children:[r.jsx("div",{className:"font-medium text-sm",children:f.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:f.path})]},f.path))}),r.jsx(Fv,{commands:Gr,selectedIndex:ko,onSelect:jp,onClose:()=>{Lr(!1),zr(-1),Fr(""),Br(-1)},position:{top:X.current?Math.max(16,X.current.getBoundingClientRect().top-316):0,left:X.current?X.current.getBoundingClientRect().left:16,bottom:X.current?window.innerHeight-X.current.getBoundingClientRect().top+8:90},isOpen:yo,frequentCommands:os?[]:kp}),r.jsxs("div",{...Pp(),className:`chat-composer-shell relative overflow-visible rounded-[20px] transition-all duration-200 ${lp?"chat-input-expanded":""} ${ft?"border-primary/40 ring-2 ring-primary/10":"hover:border-border hover:shadow-md"}`,children:[r.jsx("input",{...Lp()}),r.jsx("div",{ref:F,"aria-hidden":"true",className:"absolute inset-0 pointer-events-none overflow-hidden rounded-[24px]",children:r.jsx("div",{className:"chat-input-placeholder block w-full px-4 pt-4 pb-14 text-xs leading-5 text-transparent whitespace-pre-wrap break-words sm:text-base sm:leading-6",children:Tp(V)})}),r.jsxs("div",{className:"relative z-10 flex flex-col",children:[r.jsx("div",{className:"relative px-4 pt-4",children:r.jsx("textarea",{ref:X,value:V,onChange:Bp,onClick:zp,onKeyDown:$p,onPaste:Rp,onScroll:f=>tl(f.target),onFocus:()=>at(!0),onBlur:()=>at(!1),onInput:f=>{f.target.style.height="auto",f.target.style.height=f.target.scrollHeight+"px",ns(f.target.selectionStart),tl(f.target);const v=parseInt(window.getComputedStyle(f.target).lineHeight),y=f.target.scrollHeight>v*2;Kr(y)},placeholder:Jo?sl:M("input.placeholder",{provider:Er==="codex"?M("messageTypes.codex"):Er==="gemini"?M("messageTypes.gemini"):Er==="opencode"?"OpenCode":M("messageTypes.claude")}),disabled:gn,className:"chat-input-placeholder block w-full bg-transparent resize-none focus:outline-none text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 disabled:opacity-50 min-h-[50px] sm:min-h-[60px] max-h-[40vh] sm:max-h-[300px] overflow-y-auto text-xs leading-5 sm:text-base sm:leading-6 transition-all duration-200",style:{height:"50px"}})}),Jo&&r.jsxs("div",{className:"mx-3 mt-2 rounded-xl border border-amber-200 bg-amber-50/80 px-3 py-2 text-xs text-amber-900 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-100",children:[r.jsx("div",{children:Wp||sl}),rl&&r.jsx("div",{className:"mt-1 font-mono text-[11px] opacity-90 break-all",children:rl}),r.jsx("div",{className:"mt-2",children:r.jsx("button",{type:"button",onClick:()=>Ln(Er,{force:!0}),className:"rounded-md border border-amber-300 px-2 py-1 text-[11px] font-medium hover:bg-amber-100 dark:border-amber-700 dark:hover:bg-amber-900/40",disabled:nl,children:M(nl?"input.checkingInstallation":"input.recheckInstallation")})})]}),r.jsxs("div",{className:"flex items-end justify-between gap-2 px-3 pb-3 pt-2 sm:items-center",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 sm:flex-nowrap sm:gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>{gn||Fp()},disabled:gn,className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground sm:h-9 sm:w-9 sm:rounded-lg",title:M("input.attachImages"),children:[r.jsx(Nn,{className:"h-4 w-4 sm:hidden"}),r.jsx("svg",{className:"hidden h-5 w-5 sm:block",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})]}),r.jsx("div",{ref:No,className:"relative min-w-0 max-w-full flex-[0_1_auto]",children:r.jsxs(il,{value:Yt||void 0,onValueChange:f=>{ae==="claude"?_o(f):ae==="codex"?Do(f):ae==="gemini"?Po(f):ae==="opencode"&&Oo(f),ny(ae,f)},disabled:gn||ds||xp,children:[r.jsx(ll,{className:"h-8 w-auto !min-w-0 max-w-full shrink justify-start gap-1 rounded-full border-0 bg-transparent px-1.5 text-xs font-normal text-muted-foreground shadow-none hover:bg-accent/60 hover:text-muted-foreground focus:ring-0 sm:h-8 sm:px-1.5 sm:text-xs",children:r.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[ds&&r.jsx(qn,{className:"h-3.5 w-3.5 flex-shrink-0 animate-spin text-muted-foreground"}),r.jsx("span",{className:"truncate text-xs font-normal text-muted-foreground",children:ds?M("input.loadingModels"):gp}),r.jsx(Tr,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),r.jsx(cl,{children:ds?r.jsx(Zo,{value:"__loading",disabled:!0,children:M("input.loadingModels")}):cs.map(({value:f,label:v})=>r.jsx(Zo,{value:f,children:v},f))})]})}),r.jsx("div",{className:"relative min-w-0 max-w-full flex-[0_1_auto]",ref:Co,children:r.jsxs(il,{value:Je,onValueChange:f=>{Mt(f),t&&localStorage.setItem(`permissionMode-${t.id}`,f)},disabled:gn,children:[r.jsx(ll,{className:"h-8 w-auto !min-w-0 max-w-full shrink justify-start gap-1 rounded-full border-0 bg-transparent px-1.5 text-xs font-normal text-muted-foreground shadow-none hover:bg-accent/60 hover:text-muted-foreground focus:ring-0 sm:h-8 sm:px-1.5 sm:text-xs",children:r.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[r.jsx("span",{className:"truncate text-xs font-normal text-muted-foreground",children:pp||Ti||M("input.clickToChangeMode")}),r.jsx(Tr,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),r.jsx(cl,{children:r.jsxs(Om,{children:[r.jsx(Fm,{children:Ti}),Ur.modes.map(f=>r.jsx(Zo,{value:f,children:Eo(f,{short:!0})},f))]})})]})}),Yr.enabled&&r.jsx($m,{selectedMode:Jr,onModeChange:as,className:"sm:flex-none"}),fr!==null&&r.jsxs("div",{className:"hidden cursor-help items-center gap-1.5 px-2 py-1.5 text-xs text-muted-foreground sm:flex",title:"Token Budget",children:[r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"})}),r.jsx("span",{children:(()=>{if(typeof fr?.percentage=="number")return`${Math.min(100,Math.max(0,fr.percentage))}%`;if(typeof fr?.used=="number"&&typeof fr?.total=="number"&&fr.total>0){const f=Math.round(fr.used/fr.total*100);return`${Math.min(100,Math.max(0,f))}%`}return"0%"})()})]}),r.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700 mx-1 hidden sm:block"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative group hidden sm:block",children:[r.jsx("button",{type:"button",className:"rounded-lg p-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",title:M("input.commands"),children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),r.jsx("div",{className:"chat-floating-panel absolute bottom-full right-0 z-50 mb-2 hidden w-64 rounded-lg p-3 text-xs text-muted-foreground group-hover:block",children:r.jsx("p",{children:M(w?"input.hintText.ctrlEnter":"input.hintText.enter")})})]}),r.jsx("button",{type:"submit",disabled:!V.trim()||gn,onMouseDown:f=>{f.preventDefault(),Qr(f)},onTouchStart:f=>{f.preventDefault(),Qr(f)},className:"flex h-9 w-9 items-center justify-center rounded-full bg-foreground text-background transition-colors hover:opacity-90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",children:r.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h12m-5-5 5 5-5 5"})})})]})]})]})]})]})]})]})]})}const $y=Mn.memo(Fy);class At{constructor(t,n,s,o){this.fromA=t,this.toA=n,this.fromB=s,this.toB=o}offset(t,n=t){return new At(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}}function on(e,t,n,s,o,a){if(e==s)return[];let i=wi(e,t,n,s,o,a),c=ki(e,t+i,n,s,o+i,a);t+=i,n-=c,o+=i,a-=c;let d=n-t,u=a-o;if(!d||!u)return[new At(t,n,o,a)];if(d>u){let m=e.slice(t,n).indexOf(s.slice(o,a));if(m>-1)return[new At(t,t+m,o,o),new At(t+m+u,n,a,a)]}else if(u>d){let m=s.slice(o,a).indexOf(e.slice(t,n));if(m>-1)return[new At(t,t,o,o+m),new At(n,n,o+m+d,a)]}if(d==1||u==1)return[new At(t,n,o,a)];let p=Ou(e,t,n,s,o,a);if(p){let[m,h,g]=p;return on(e,t,m,s,o,h).concat(on(e,m+g,n,s,h+g,a))}return By(e,t,n,s,o,a)}let Un=1e9,Wn=0,bi=!1;function By(e,t,n,s,o,a){let i=n-t,c=a-o;if(Un<1e9&&Math.min(i,c)>Un*16||Wn>0&&Date.now()>Wn)return Math.min(i,c)>Un*64?[new At(t,n,o,a)]:nc(e,t,n,s,o,a);let d=Math.ceil((i+c)/2);ha.reset(d),ga.reset(d);let u=(g,x)=>e.charCodeAt(t+g)==s.charCodeAt(o+x),p=(g,x)=>e.charCodeAt(n-g-1)==s.charCodeAt(a-x-1),m=(i-c)%2!=0?ga:null,h=m?null:ha;for(let g=0;g<d;g++){if(g>Un||Wn>0&&!(g&63)&&Date.now()>Wn)return nc(e,t,n,s,o,a);let x=ha.advance(g,i,c,d,m,!1,u)||ga.advance(g,i,c,d,h,!0,p);if(x)return zy(e,t,n,t+x[0],s,o,a,o+x[1])}return[new At(t,n,o,a)]}class Pu{constructor(){this.vec=[]}reset(t){this.len=t<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[t+1]=0,this.start=this.end=0}advance(t,n,s,o,a,i,c){for(let d=-t+this.start;d<=t-this.end;d+=2){let u=o+d,p=d==-t||d!=t&&this.vec[u-1]<this.vec[u+1]?this.vec[u+1]:this.vec[u-1]+1,m=p-d;for(;p<n&&m<s&&c(p,m);)p++,m++;if(this.vec[u]=p,p>n)this.end+=2;else if(m>s)this.start+=2;else if(a){let h=o+(n-s)-d;if(h>=0&&h<this.len&&a.vec[h]!=-1)if(i){let g=a.vec[h];if(g>=n-p)return[g,o+g-h]}else{let g=n-a.vec[h];if(p>=g)return[p,m]}}}return null}}const ha=new Pu,ga=new Pu;function zy(e,t,n,s,o,a,i,c){let d=!1;return!An(e,s)&&++s==n&&(d=!0),!An(o,c)&&++c==i&&(d=!0),d?[new At(t,n,a,i)]:on(e,t,s,o,a,c).concat(on(e,s,n,o,c,i))}function Lu(e,t){let n=1,s=Math.min(e,t);for(;n<s;)n=n<<1;return n}function wi(e,t,n,s,o,a){if(t==n||t==a||e.charCodeAt(t)!=s.charCodeAt(o))return 0;let i=Lu(n-t,a-o);for(let c=t,d=o;;){let u=c+i,p=d+i;if(u>n||p>a||e.slice(c,u)!=s.slice(d,p)){if(i==1)return c-t-(An(e,c)?0:1);i=i>>1}else{if(u==n||p==a)return u-t;c=u,d=p}}}function ki(e,t,n,s,o,a){if(t==n||o==a||e.charCodeAt(n-1)!=s.charCodeAt(a-1))return 0;let i=Lu(n-t,a-o);for(let c=n,d=a;;){let u=c-i,p=d-i;if(u<t||p<o||e.slice(u,c)!=s.slice(p,d)){if(i==1)return n-c-(An(e,c)?0:1);i=i>>1}else{if(u==t||p==o)return n-u;c=u,d=p}}}function Ka(e,t,n,s,o,a,i,c){let d=s.slice(o,a),u=null;for(;;){if(u||i<c)return u;for(let p=t+i;;){An(e,p)||p++;let m=p+i;if(An(e,m)||(m+=m==p+1?1:-1),m>=n)break;let h=e.slice(p,m),g=-1;for(;(g=d.indexOf(h,g+1))!=-1;){let x=wi(e,m,n,s,o+g+h.length,a),j=ki(e,t,p,s,o,o+g),k=h.length+x+j;(!u||u[2]<k)&&(u=[p-j,o+g-j,k])}p=m}if(c<0)return u;i=i>>1}}function Ou(e,t,n,s,o,a){let i=n-t,c=a-o;if(i<c){let d=Ou(s,o,a,e,t,n);return d&&[d[1],d[0],d[2]]}return i<4||c*2<i?null:Ka(e,t,n,s,o,a,Math.floor(i/4),-1)}function nc(e,t,n,s,o,a){bi=!0;let i=n-t,c=a-o,d;if(i<c){let h=Ka(s,o,a,e,t,n,Math.floor(i/6),50);d=h&&[h[1],h[0],h[2]]}else d=Ka(e,t,n,s,o,a,Math.floor(c/6),50);if(!d)return[new At(t,n,o,a)];let[u,p,m]=d;return on(e,t,u,s,o,p).concat(on(e,u+m,n,s,p+m,a))}function Fu(e,t){for(let n=1;n<e.length;n++){let s=e[n-1],o=e[n];s.toA>o.fromA-t&&s.toB>o.fromB-t&&(e[n-1]=new At(s.fromA,o.toA,s.fromB,o.toB),e.splice(n--,1))}}function Uy(e,t,n){for(;;){Fu(n,1);let s=!1;for(let o=0;o<n.length;o++){let a=n[o],i,c;(i=wi(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[o]=new At(a.fromA+i,a.toA,a.fromB+i,a.toB)),(c=ki(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[o]=new At(a.fromA,a.toA-c,a.fromB,a.toB-c));let d=a.toA-a.fromA,u=a.toB-a.fromB;if(d&&u)continue;let p=a.fromA-(o?n[o-1].toA:0),m=(o<n.length-1?n[o+1].fromA:e.length)-a.toA;if(!p||!m)continue;let h=d?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);p<=h.length&&e.slice(a.fromA-p,a.fromA)==h.slice(h.length-p)?(n[o]=new At(a.fromA-p,a.toA-p,a.fromB-p,a.toB-p),s=!0):m<=h.length&&e.slice(a.toA,a.toA+m)==h.slice(0,m)&&(n[o]=new At(a.fromA+m,a.toA+m,a.fromB+m,a.toB+m),s=!0)}if(!s)break}return n}function Wy(e,t,n){for(let s=0,o=0;o<e.length;o++){let a=e[o],i=a.toA-a.fromA,c=a.toB-a.fromB;if(i&&c||i>3||c>3){let d=o==e.length-1?t.length:e[o+1].fromA,u=a.fromA-s,p=d-a.toA,m=oc(t,a.fromA,u),h=sc(t,a.toA,p),g=a.fromA-m,x=h-a.toA;if((!i||!c)&&g&&x){let j=Math.max(i,c),[k,A,T]=i?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];j>g&&t.slice(m,a.fromA)==k.slice(T-g,T)?(a=e[o]=new At(m,m+i,a.fromB-g,a.toB-g),m=a.fromA,h=sc(t,a.toA,d-a.toA)):j>x&&t.slice(a.toA,h)==k.slice(A,A+x)&&(a=e[o]=new At(h-i,h,a.fromB+x,a.toB+x),h=a.toA,m=oc(t,a.fromA,a.fromA-s)),g=a.fromA-m,x=h-a.toA}if(g||x)a=e[o]=new At(a.fromA-g,a.toA+x,a.fromB-g,a.toB+x);else if(i){if(!c){let j=ic(t,a.fromA,a.toA),k,A=j<0?-1:ac(t,a.toA,a.fromA);j>-1&&(k=j-a.fromA)<=p&&t.slice(a.fromA,j)==t.slice(a.toA,a.toA+k)?a=e[o]=a.offset(k):A>-1&&(k=a.toA-A)<=u&&t.slice(a.fromA-k,a.fromA)==t.slice(A,a.toA)&&(a=e[o]=a.offset(-k))}}else{let j=ic(n,a.fromB,a.toB),k,A=j<0?-1:ac(n,a.toB,a.fromB);j>-1&&(k=j-a.fromB)<=p&&n.slice(a.fromB,j)==n.slice(a.toB,a.toB+k)?a=e[o]=a.offset(k):A>-1&&(k=a.toB-A)<=u&&n.slice(a.fromB-k,a.fromB)==n.slice(A,a.toB)&&(a=e[o]=a.offset(-k))}}s=a.toA}return Fu(e,3),e}let sn;try{sn=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function $u(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Bu(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?$u(n)?1:0:sn?!Wu(n)||t==e.length-1?sn.test(String.fromCharCode(n))?1:0:sn.test(e.slice(t,t+2))?2:0:0}function zu(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?$u(n)?1:0:sn?!Hu(n)||t==1?sn.test(String.fromCharCode(n))?1:0:sn.test(e.slice(t-2,t))?2:0:0}const Uu=8;function sc(e,t,n){if(t==e.length||!zu(e,t))return t;for(let s=t,o=t+n,a=0;a<Uu;a++){let i=Bu(e,s);if(!i||s+i>o)return s;s+=i}return t}function oc(e,t,n){if(!t||!Bu(e,t))return t;for(let s=t,o=t-n,a=0;a<Uu;a++){let i=zu(e,s);if(!i||s-i<o)return s;s-=i}return t}function ac(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function ic(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}const Wu=e=>e>=55296&&e<=56319,Hu=e=>e>=56320&&e<=57343;function An(e,t){return!t||t==e.length||!Wu(e.charCodeAt(t-1))||!Hu(e.charCodeAt(t))}function Hy(e,t,n){var s;return Un=((s=n?.scanLimit)!==null&&s!==void 0?s:1e9)>>1,Wn=n?.timeout?Date.now()+n.timeout:0,bi=!1,Uy(e,t,on(e,0,e.length,t,0,t.length))}function qu(){return!bi}function Vu(e,t,n){return Wy(Hy(e,t,n),e,t)}const Dr=Qs.define({combine:e=>e[0]}),qy=Ya.define(),Gu=Qs.define(),lr=Yn.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(qy)&&(e=n.value);for(let n of t.state.facet(Gu))e=n(e,t);return e}});function xa(e){let t=e.field(lr,!1);if(!t)return null;let n=e.facet(Dr);return{chunks:t,side:n?n.side:null}}class jn{constructor(t,n,s,o,a,i=!0){this.changes=t,this.fromA=n,this.toA=s,this.fromB=o,this.toB=a,this.precise=i}offset(t,n){return t||n?new jn(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(t,n,s){let o=Vu(t.toString(),n.toString(),s);return Ku(o,t,n,0,0,qu())}static updateA(t,n,s,o,a){return pc(uc(t,o,!0,s.length),t,n,s,a)}static updateB(t,n,s,o,a){return pc(uc(t,o,!1,n.length),t,n,s,a)}}function lc(e,t,n,s){let o=n.lineAt(e),a=s.lineAt(t);return o.to==e&&a.to==t&&e<n.length&&t<s.length?[e+1,t+1]:[o.from,a.from]}function cc(e,t,n,s){let o=n.lineAt(e),a=s.lineAt(t);return o.from==e&&a.from==t?[e,t]:[o.to+1,a.to+1]}function Ku(e,t,n,s,o,a){let i=[];for(let c=0;c<e.length;c++){let d=e[c],[u,p]=lc(d.fromA+s,d.fromB+o,t,n),[m,h]=cc(d.toA+s,d.toB+o,t,n),g=[d.offset(-u+s,-p+o)];for(;c<e.length-1;){let x=e[c+1],[j,k]=lc(x.fromA+s,x.fromB+o,t,n);if(j>m+1&&k>h+1)break;g.push(x.offset(-u+s,-p+o)),[m,h]=cc(x.toA+s,x.toB+o,t,n),c++}i.push(new jn(g,u,Math.max(u,m),p,Math.max(p,h),a))}return i}const Os=1e3;function dc(e,t,n,s){let o=0,a=e.length;for(;;){if(o==a){let p=0,m=0;o&&({toA:p,toB:m}=e[o-1]);let h=t-(n?p:m);return[p+h,m+h]}let i=o+a>>1,c=e[i],[d,u]=n?[c.fromA,c.toA]:[c.fromB,c.toB];if(d>t)a=i;else if(u<=t)o=i+1;else return s?[c.fromA,c.fromB]:[c.toA,c.toB]}}function uc(e,t,n,s){let o=[];return t.iterChangedRanges((a,i,c,d)=>{let u=0,p=n?t.length:s,m=0,h=n?s:t.length;a>Os&&([u,m]=dc(e,a-Os,n,!0)),i<t.length-Os&&([p,h]=dc(e,i+Os,n,!1));let g=d-c-(i-a),x,[j,k]=n?[g,0]:[0,g];o.length&&(x=o[o.length-1]).toA>=u?o[o.length-1]={fromA:x.fromA,fromB:x.fromB,toA:p,toB:h,diffA:x.diffA+j,diffB:x.diffB+k}:o.push({fromA:u,toA:p,fromB:m,toB:h,diffA:j,diffB:k})}),o}function pc(e,t,n,s,o){if(!e.length)return t;let a=[];for(let i=0,c=0,d=0,u=0;;i++){let p=i==e.length?null:e[i],m=p?p.fromA+c:n.length,h=p?p.fromB+d:s.length;for(;u<t.length;){let k=t[u];if(k.toA+c>m||k.toB+d>h)break;a.push(k.offset(c,d)),u++}if(!p)break;let g=p.toA+c+p.diffA,x=p.toB+d+p.diffB,j=Vu(n.sliceString(m,g),s.sliceString(h,x),o);for(let k of Ku(j,n,s,m,h,qu()))a.push(k);for(c+=p.diffA,d+=p.diffB;u<t.length;){let k=t[u];if(k.fromA+c>g&&k.fromB+d>x)break;u++}}return a}const Vy={scanLimit:500},Ju=Zs.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=hc(e))}update(e){(e.docChanged||e.viewportChanged||Gy(e.startState,e.state)||Ky(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=hc(e.view))}},{decorations:e=>e.deco});function Gy(e,t){return e.field(lr,!1)!=t.field(lr,!1)}function Ky(e,t){return e.facet(Dr)!=t.facet(Dr)}const mc=Rr.line({class:"cm-changedLine"}),Yu=Rr.mark({class:"cm-changedText"}),Jy=Rr.mark({tagName:"ins",class:"cm-insertedLine"}),Yy=Rr.mark({tagName:"del",class:"cm-deletedLine"}),fc=new class extends Xa{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Xy(e,t,n,s,o,a){let i=n?e.fromA:e.fromB,c=n?e.toA:e.toB,d=0;if(i!=c){o.add(i,i,mc),o.add(i,c,n?Yy:Jy),a&&a.add(i,i,fc);for(let u=t.iterRange(i,c-1),p=i;!u.next().done;){if(u.lineBreak){p++,o.add(p,p,mc),a&&a.add(p,p,fc);continue}let m=p+u.value.length;if(s)for(;d<e.changes.length;){let h=e.changes[d],g=i+(n?h.fromA:h.fromB),x=i+(n?h.toA:h.toB),j=Math.max(p,g),k=Math.min(m,x);if(j<k&&o.add(j,k,Yu),x<m)d++;else break}p=m}}}function hc(e){let t=e.state.field(lr),{side:n,highlightChanges:s,markGutter:o,overrideChunk:a}=e.state.facet(Dr),i=n=="a",c=new $s,d=o?new $s:null,{from:u,to:p}=e.viewport;for(let m of t){if((i?m.fromA:m.fromB)>=p)break;(i?m.toA:m.toB)>u&&(!a||!a(e.state,m,c,d))&&Xy(m,e.state.doc,i,s,c,d)}return{deco:c.finish(),gutter:d&&d.finish()}}const Ja=Ya.define({map:(e,t)=>t.mapPos(e)});class Qy extends Qa{constructor(t){super(),this.lines=t}eq(t){return this.lines==t.lines}toDOM(t){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=t.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",s=>{let o=t.posAtDOM(s.target);t.dispatch({effects:Ja.of(o)});let{side:a,sibling:i}=t.state.facet(Dr);i&&i().dispatch({effects:Ja.of(Zy(o,t.state.field(lr),a=="a"))})}),n}ignoreEvent(t){return t instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function Zy(e,t,n){let s=0,o=0;for(let a=0;;a++){let i=a<t.length?t[a]:null;if(!i||(n?i.fromA:i.fromB)>=e)return o+(e-s);[s,o]=n?[i.toA,i.toB]:[i.toB,i.toA]}}const eb=Yn.define({create(e){return Rr.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Ja)&&(e=e.update({filter:s=>s!=n.value}));return e},provide:e=>mr.decorations.from(e)});function tb({margin:e=3,minSize:t=4}){return eb.init(n=>rb(n,e,t))}function rb(e,t,n){let s=new $s,o=e.facet(Dr).side=="a",a=e.field(lr),i=1;for(let c=0;;c++){let d=c<a.length?a[c]:null,u=c?i+t:1,p=d?e.doc.lineAt(o?d.fromA:d.fromB).number-1-t:e.doc.lines,m=p-u+1;if(m>=n&&s.add(e.doc.line(u).from,e.doc.line(p).to,Rr.replace({widget:new Qy(m),block:!0})),!d)break;i=e.doc.lineAt(Math.min(e.doc.length,o?d.toA:d.toB)).number}return s.finish()}const nb=mr.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),sb=new class extends Xa{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},ob=Ic.low(Jp({class:"cm-changeGutter",markers:e=>{var t;return((t=e.plugin(Ju))===null||t===void 0?void 0:t.gutter)||Xp.empty},widgetMarker:(e,t)=>t instanceof Xu?sb:null}));function ab(e){var t;let n=typeof e.original=="string"?Ec.of(e.original.split(/\r?\n/)):e.original,s=e.diffConfig||Vy;return[Ic.low(Ju),db,nb,mr.editorAttributes.of({class:"cm-merge-b"}),Gu.of((o,a)=>{let i=a.effects.find(c=>c.is(ji));return i&&(o=jn.updateA(o,i.value.doc,a.startState.doc,i.value.changes,s)),a.docChanged&&(o=jn.updateB(o,a.state.field(Tn),a.newDoc,a.changes,s)),o}),Dr.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(t=e.mergeControls)!==null&&t!==void 0?t:!0,overrideChunk:e.allowInlineDiffs?fb:void 0,side:"b"}),Tn.init(()=>n),e.gutter!==!1?ob:[],e.collapseUnchanged?tb(e.collapseUnchanged):[],lr.init(o=>jn.build(n,o.doc,s))]}const ji=Ya.define(),Tn=Yn.define({create:()=>Ec.empty,update(e,t){for(let n of t.effects)n.is(ji)&&(e=n.value.doc);return e}}),gc=new WeakMap;class Xu extends Qa{constructor(t){super(),this.buildDOM=t,this.dom=null}eq(t){return this.dom==t.dom}toDOM(t){return this.dom||(this.dom=this.buildDOM(t))}}function ib(e,t,n){let s=gc.get(t.changes);if(s)return s;let o=i=>{let{highlightChanges:c,syntaxHighlightDeletions:d,syntaxHighlightDeletionsMaxLength:u,mergeControls:p}=e.facet(Dr),m=document.createElement("div");if(m.className="cm-deletedChunk",p){let D=m.appendChild(document.createElement("div"));D.className="cm-chunkButtons";let N=L=>{L.preventDefault(),lb(i,i.posAtDOM(m))},b=L=>{L.preventDefault(),cb(i,i.posAtDOM(m))};if(typeof p=="function")D.appendChild(p("accept",N)),D.appendChild(p("reject",b));else{let L=D.appendChild(document.createElement("button"));L.name="accept",L.textContent=e.phrase("Accept"),L.onmousedown=N;let q=D.appendChild(document.createElement("button"));q.name="reject",q.textContent=e.phrase("Reject"),q.onmousedown=b}}if(n||t.fromA>=t.toA)return m;let h=i.state.field(Tn).sliceString(t.fromA,t.endA),g=d&&e.facet(Ac),x=T(),j=t.changes,k=0,A=!1;function T(){let D=m.appendChild(document.createElement("div"));return D.className="cm-deletedLine",D.appendChild(document.createElement("del"))}function w(D,N,b){for(let L=D;L<N;){if(h.charAt(L)==`
318
- `){x.firstChild||x.appendChild(document.createElement("br")),x=T(),L++;continue}let q=N,P=b+(A?" cm-deletedText":""),Y=!1,ge=h.indexOf(`
319
- `,L);if(ge>-1&&ge<N&&(q=ge),c&&k<j.length){let le=Math.max(0,A?j[k].toA:j[k].fromA);le<=q&&(q=le,A&&k++,Y=!0)}if(q>L){let le=document.createTextNode(h.slice(L,q));if(P){let M=x.appendChild(document.createElement("span"));M.className=P,M.appendChild(le)}else x.appendChild(le);L=q}Y&&(A=!A)}}if(g&&t.toA-t.fromA<=u){let D=g.parser.parse(h),N=0;ba(D,{style:b=>Tc(e,b)},(b,L,q)=>{b>N&&w(N,b,""),w(b,L,q),N=L}),w(N,h.length,"")}else w(0,h.length,"");return x.firstChild||x.appendChild(document.createElement("br")),m},a=Rr.widget({block:!0,side:-1,widget:new Xu(o)});return gc.set(t.changes,a),a}function lb(e,t){let{state:n}=e,s=t??n.selection.main.head,o=e.state.field(lr).find(d=>d.fromB<=s&&d.endB>=s);if(!o)return!1;let a=e.state.sliceDoc(o.fromB,Math.max(o.fromB,o.toB-1)),i=e.state.field(Tn);o.fromB!=o.toB&&o.toA<=i.length&&(a+=e.state.lineBreak);let c=Yp.of({from:o.fromA,to:Math.min(i.length,o.toA),insert:a},i.length);return e.dispatch({effects:ji.of({doc:c.apply(i),changes:c}),userEvent:"accept"}),!0}function cb(e,t){let{state:n}=e,s=t??n.selection.main.head,o=n.field(lr).find(c=>c.fromB<=s&&c.endB>=s);if(!o)return!1;let i=n.field(Tn).sliceString(o.fromA,Math.max(o.fromA,o.toA-1));return o.fromA!=o.toA&&o.toB<=n.doc.length&&(i+=n.lineBreak),e.dispatch({changes:{from:o.fromB,to:Math.min(n.doc.length,o.toB),insert:i},userEvent:"revert"}),!0}function xc(e){let t=new $s;for(let n of e.field(lr)){let s=e.facet(Dr).overrideChunk&&Qu(e,n);t.add(n.fromB,n.fromB,ib(e,n,!!s))}return t.finish()}const db=Yn.define({create:e=>xc(e),update(e,t){return t.state.field(lr,!1)!=t.startState.field(lr,!1)?xc(t.state):e},provide:e=>mr.decorations.from(e)}),vc=new WeakMap;function Qu(e,t){let n=vc.get(t);if(n!==void 0)return n;n=null;let s=e.field(Tn),o=e.doc,a=s.lineAt(t.endA).number-s.lineAt(t.fromA).number+1,i=o.lineAt(t.endB).number-o.lineAt(t.fromB).number+1;e:if(a==i&&a<10){let c=[],d=0,u=t.fromA,p=t.fromB;for(let m of t.changes){if(m.fromA<m.toA){d+=m.toA-m.fromA;let h=s.sliceString(u+m.fromA,u+m.toA);if(/\n/.test(h))break e;c.push(Rr.widget({widget:new ub(h),side:-1}).range(p+m.fromB))}m.fromB<m.toB&&c.push(Yu.range(p+m.fromB,p+m.toB))}d<t.endA-t.fromA-a*2&&(n=c)}return vc.set(t,n),n}class ub extends Qa{constructor(t){super(),this.text=t}eq(t){return this.text==t.text}toDOM(t){let n=document.createElement("del");return n.className="cm-deletedText",n.textContent=this.text,n}}const pb=new class extends Xa{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},mb=Rr.line({class:"cm-inlineChangedLine"});function fb(e,t,n,s){let o=Qu(e,t),a=0;if(!o)return!1;for(let i=e.doc.lineAt(t.fromB);;){for(s&&s.add(i.from,i.from,pb),n.add(i.from,i.from,mb);a<o.length&&o[a].to<=i.to;){let c=o[a++];n.add(c.from,c.to,c.value)}if(i.to>=t.endB)break;i=e.doc.lineAt(i.to+1)}return!0}var hb=function(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(n[s[o]]=e[s[o]]);return n};const qt=Qs.define({combine:e=>{const t=[];for(let n of e){if(!n)continue;const{create:s,gutters:o}=n,a=hb(n,["create","gutters"]);t.push(Object.assign(Object.assign({},a),{enabled:!0,gutters:o?o.filter(i=>Object.keys(i).length>0):void 0}))}return Qp(t,{enabled:t.length>0,displayText:"characters",eventHandlers:{},showOverlay:"always",gutters:[]})}}),Qt={PixelMultiplier:2,SizeRatio:4,MaxWidth:120},gb=mr.theme({".cm-minimap-overlay-container":{position:"absolute",top:0,height:"100%",width:"100%","&.cm-minimap-overlay-mouse-over":{opacity:0,transition:"visibility 0s linear 300ms, opacity 300ms"},"&.cm-minimap-overlay-mouse-over:hover":{opacity:1,transition:"visibility 0s linear 0ms, opacity 300ms"},"&.cm-minimap-overlay-off":{display:"none"},"& .cm-minimap-overlay":{background:"rgb(121, 121, 121)",opacity:"0.2",position:"absolute",right:0,top:0,width:"100%",transition:"top 0s ease-in 0ms","&:hover":{opacity:"0.3"}},"&.cm-minimap-overlay-active":{opacity:1,visibility:"visible",transition:"visibility 0s linear 0ms, opacity 300ms","& .cm-minimap-overlay":{opacity:"0.4"}}}}),qr=Qt.PixelMultiplier*Qt.SizeRatio,xb=Zs.fromClass(class{constructor(e){this.view=e,this._isDragging=!1,e.state.facet(qt).enabled&&this.create(e)}create(e){this.container=Sn("div",{class:"cm-minimap-overlay-container"}),this.dom=Sn("div",{class:"cm-minimap-overlay"}),this.container.appendChild(this.dom),this.container.addEventListener("mousedown",this.onMouseDown.bind(this)),window.addEventListener("mouseup",this.onMouseUp.bind(this)),window.addEventListener("mousemove",this.onMouseMove.bind(this));const t=e.dom.querySelector(".cm-minimap-inner");t&&t.appendChild(this.container),this.computeShowOverlay(),this.computeHeight(),this.computeTop()}remove(){this.container&&(this.container.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),this.container.remove())}update(e){const t=e.startState.facet(qt).enabled,n=e.state.facet(qt).enabled;if(t&&!n){this.remove();return}!t&&n&&this.create(e.view),n&&(this.computeShowOverlay(),e.geometryChanged&&(this.computeHeight(),this.computeTop()))}computeHeight(){if(!this.dom)return;const e=this.view.dom.clientHeight/qr;this.dom.style.height=e+"px"}computeTop(){if(!this._isDragging&&this.dom){const{clientHeight:e,scrollHeight:t,scrollTop:n}=this.view.scrollDOM,s=t-e,o=n/qr,a=e/qr,i=e-a;let c=n/s;isNaN(c)&&(c=0);const d=i*c,u=Math.min(d,o);this.dom.style.top=u+"px"}}computeShowOverlay(){if(!this.container)return;const{showOverlay:e}=this.view.state.facet(qt);e==="mouse-over"?this.container.classList.add("cm-minimap-overlay-mouse-over"):this.container.classList.remove("cm-minimap-overlay-mouse-over");const{clientHeight:t,scrollHeight:n}=this.view.scrollDOM;t===n?this.container.classList.add("cm-minimap-overlay-off"):this.container.classList.remove("cm-minimap-overlay-off")}onMouseDown(e){if(!this.container||e.button===2)return;const{clientY:t,target:n}=e;if(n===this.dom){this._dragStartY=e.clientY,this._isDragging=!0,this.container.classList.add("cm-minimap-overlay-active");return}const{clientHeight:s,scrollHeight:o,scrollTop:a}=this.view.scrollDOM,i=n.getBoundingClientRect().top,c=(t-i)*qr,d=a/(o-s),p=(s*qr-s)*d,m=Math.max(0,a-p);this.view.scrollDOM.scrollTop=m+c-s/2}onMouseUp(e){this._isDragging&&this.container&&(this._dragStartY=void 0,this._isDragging=!1,this.container.classList.remove("cm-minimap-overlay-active"))}onMouseMove(e){if(!this._isDragging||!this.dom)return;if(e.preventDefault(),e.stopPropagation(),!this._dragStartY){this._dragStartY=e.clientY;return}const t=e.clientY-this._dragStartY,n=t<0,s=t>0;this._dragStartY=e.clientY;const o=this.dom.getBoundingClientRect().height,a=this.dom.getBoundingClientRect().y,i=a+o,c=parseFloat(this.dom.style.top),d=this.view.scrollDOM.scrollTop,u=this.view.scrollDOM.clientHeight,p=this.view.scrollDOM.scrollHeight,m=d===0,h=Math.round(d)>=Math.round(p-u);if(m&&n||m&&e.clientY<a||h&&s||h&&e.clientY>i)return;const g=this.view.scrollDOM.scrollHeight,x=this.view.scrollDOM.clientHeight,j=(g-x)/qr,k=x-x/qr,A=c+t,T=A/k,w=(g-x)*T,D=A*qr;this.view.scrollDOM.scrollTop=Math.max(w,D);const N=Math.min(Math.max(0,A),Math.min(k,j));this.dom.style.top=N+"px"}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.computeTop())}}}),vb=[gb,xb];class Si{constructor(t){this.map=new Map,this.view=t}get(t){return this.map.get(t)}set(t,n){this.map.set(t,n)}}function yc(e){var t;if(!e.facet(qt).enabled)return[];const n=[],s=e.doc.iterLines(),o=Zp(e).iter();let a=0;for(s.next();!s.done;){const i=s.value;let c=a,d=c+i.length;for(;o.value&&o.to<c;)o.next();const{from:u,to:p}=o,m=c>=u&&c<p,h=d>u&&d<=p;if(m){let g=(t=n.pop())!==null&&t!==void 0?t:[],x=g.pop();x&&x.folded&&(x.to=p),x&&g.push(x),(!x||!x.folded)&&g.push({from:u,to:p,folded:!0}),h||g.push({from:p,to:d,folded:!1}),n.push(g)}else h?n.push([{from:c,to:u,folded:!1},{from:u,to:p,folded:!0}]):n.push([{from:c,to:d,folded:!1}]);a=d+1,s.next()}return n}const _n=Yn.define({create:e=>yc(e),update:(e,t)=>ho([t])||t.docChanged?yc(t.state):e});function ho(e){return e.find(t=>t.effects.find(n=>n.is(em)||n.is(tm)))}class yb extends Si{constructor(t){super(t),this.count=void 0}shouldUpdate(t){if(!t.state.facet(qt).enabled)return!1;if(t.docChanged)return!0;for(const n of t.transactions)for(const s of n.effects)if(s.is(rm))return!0;return!!(ho(t.transactions)||this.count===void 0)}update(t){if(!this.shouldUpdate(t))return;this.map.clear();const n=t.state.field(_n);this.count=nm(t.state),sm(t.state,(s,o,a)=>{const i=this.findLine(o,n),c=this.findLine(a,n);let d=s.severity;for(let u=i;u<=c;u++){const p=this.get(u);p&&(d=[d,p].sort(this.sort.bind(this)).slice(0,1)[0]),this.set(u,d)}})}drawLine(t,n){const{context:s,lineHeight:o,offsetX:a,offsetY:i}=t,c=this.get(n);c&&(s.globalAlpha=.65,s.beginPath(),s.rect(a,i,s.canvas.width-a,o),s.fillStyle=this.color(c),s.fill())}findLine(t,n){return n.findIndex(o=>{const a=o.slice(0,1)[0],i=o.slice(-1)[0];return!a||!i?!1:a.from<=t&&t<=i.to})+1}color(t){return t==="error"?"#d11":t==="warning"?"orange":"#999"}sort(t,n){return this.score(n)-this.score(t)}score(t){switch(t){case"error":return 3;case"warning":return 2;default:return 1}}}function bb(e){return new yb(e)}class wb extends Si{constructor(t){super(t),this.getDrawInfo(),this._themeClasses=t.dom.classList.value}shouldUpdate(t){return t.state.facet(qt).enabled?!!(t.docChanged||t.selectionSet||this._themeClasses!==this.view.dom.classList.value||ho(t.transactions)):!1}update(t){if(!this.shouldUpdate(t))return;this.map.clear(),this._themeClasses!==this.view.dom.classList.value&&(this._drawInfo=void 0,this._themeClasses=this.view.dom.classList.value);const{ranges:n}=t.state.selection;let s=0;for(const[o,a]of t.state.field(_n).entries()){const i=[];let c=0;for(const u of a){do{if(s>=n.length||u.to<n[s].from)continue;if(n[s].from===n[s].to){s++;continue}const p=n[s],m={from:c+Math.max(u.from,p.from)-u.from,to:c+Math.min(u.to,p.to)-u.from,extends:p.to>u.to},h=i.slice(-1)[0];if(h&&h.to===m.from){let{to:g}=m;u.folded&&m.extends?g=m.from+1:u.folded&&!m.extends&&(g=h.to),i[i.length-1]=Object.assign(Object.assign({},h),{to:g,extends:m.extends})}else u.folded||i.push(m);if(m.extends)break;s++}while(s<n.length&&u.to>=n[s].from);c+=u.folded?1:u.to-u.from}if(i.length===0)continue;const d=o+1;this.map.set(d,i)}}drawLine(t,n){let{context:s,lineHeight:o,charWidth:a,offsetX:i,offsetY:c}=t;const d=this.get(n);if(d)for(const u of d){const p=i+u.from*a,m=(u.to-u.from)*a,h=s.canvas.width-p;u.extends&&(s.globalAlpha=.65,s.beginPath(),s.rect(p,c,h,o),s.fillStyle=this.getDrawInfo().backgroundColor,s.fill()),s.globalAlpha=1,s.beginPath(),s.rect(p,c,m,o),s.fillStyle=this.getDrawInfo().backgroundColor,s.fill()}}getDrawInfo(){if(this._drawInfo)return this._drawInfo;const t=document.createElement("span");t.setAttribute("class","cm-selectionBackground"),this.view.dom.appendChild(t);const s={backgroundColor:window.getComputedStyle(t).backgroundColor};return this._drawInfo=s,this.view.dom.removeChild(t),s}}function kb(e){return new wb(e)}class jb extends Si{constructor(t){super(t),this._fontInfoMap=new Map,this._themeClasses=new Set(t.dom.classList.values()),t.state.facet(qt).enabled&&this.updateImpl(t.state)}shouldUpdate(t){return!!(t.docChanged||t.state.facet(qt)!==t.startState.facet(qt)||this.themeChanged()||ho(t.transactions))}update(t){this.shouldUpdate(t)&&(this._highlightingCallbackId&&(typeof window.requestIdleCallback<"u"?cancelIdleCallback(this._highlightingCallbackId):clearTimeout(this._highlightingCallbackId)),this.updateImpl(t.state,t.changes))}updateImpl(t,n){var s;this.map.clear(),this._displayText=t.facet(qt).displayText,this.themeChanged()&&this._fontInfoMap.clear();let o;if(this._previousTree&&n){const m=al.addTree(this._previousTree),h=[];n.iterChangedRanges((g,x,j,k)=>h.push({fromA:g,toA:x,fromB:j,toB:k})),o=al.applyChanges(m,h)}const a=t.doc.toString(),i=(s=t.facet(Ac))===null||s===void 0?void 0:s.parser,c=i?i.parse(a,o):void 0;this._previousTree=c;const d={style:m=>Tc(t,m)};let u=[];if(c){const m=t.doc.lineAt(this.view.viewport.from).number,h=t.doc.lineAt(this.view.viewport.to).number,g=h-m,x=m/(t.doc.lines-g),{SizeRatio:j,PixelMultiplier:k}=Qt,A=g*j*k,T=x*A,w=Math.max(1,Math.floor(m-T)),D=Math.min(h+Math.floor(A-T),t.doc.lines);ba(c,d,(N,b,L)=>{u.push({from:N,to:b,tags:L})},t.doc.line(w).from,t.doc.line(D).to)}this.updateMapImpl(t,u),u=[];const p=()=>{c&&(ba(c,d,(m,h,g)=>{u.push({from:m,to:h,tags:g})}),this.updateMapImpl(t,u),this._highlightingCallbackId=void 0)};this._highlightingCallbackId=typeof window.requestIdleCallback<"u"?requestIdleCallback(p):setTimeout(p)}updateMapImpl(t,n){this.map.clear();const s=t.doc.toString(),o=n.values();let a=o.next();for(const[i,c]of t.field(_n).entries()){const d=[];for(const p of c){if(p.from===p.to)continue;if(p.folded){d.push({text:"…",tags:""});continue}let m=p.from;for(;!a.done&&a.value.from<p.to;){const{from:h,to:g,tags:x}=a.value;if(g<m){a=o.next();continue}h>m&&d.push({text:s.slice(m,h),tags:""});const j=Math.max(h,p.from),k=Math.min(g,p.to);if(d.push({text:s.slice(j,k),tags:x}),m=k,g>k)break;a=o.next()}m!==p.to&&d.push({text:s.slice(m,p.to),tags:""})}const u=i+1;this.map.set(u,d)}}measure(t){const{color:n,font:s,lineHeight:o}=this.getFontInfo("");return t.textBaseline="ideographic",t.fillStyle=n,t.font=s,{charWidth:t.measureText("_").width,lineHeight:o}}beforeDraw(){this._fontInfoMap.clear()}drawLine(t,n){const s=this.get(n);if(!s)return;let{context:o,charWidth:a,lineHeight:i,offsetX:c,offsetY:d}=t,u;o.textBaseline="ideographic";for(const p of s){const m=this.getFontInfo(p.tags);switch((!u||u.color!==m.color)&&(o.fillStyle=m.color),(!u||u.font!==m.font)&&(o.font=m.font),u=m,i=Math.max(i,m.lineHeight),this._displayText){case"characters":{o.fillText(p.text,c,d+i),c+=p.text.length*a;break}case"blocks":{const h=/\S+/g;let g;for(;(g=h.exec(p.text))!==null;){const x=c+g.index*a;let j=(h.lastIndex-g.index)*a;if(x>o.canvas.width)break;x+j>o.canvas.width&&(j=o.canvas.width-x);const k=2/Qt.SizeRatio,A=i-k;o.fillStyle=m.color,o.globalAlpha=.65,o.beginPath(),o.rect(x,d,j,A),o.fill()}c+=p.text.length*a;break}}}}getFontInfo(t){const n=this._fontInfoMap.get(t);if(n)return n;const s=Sn("span",{class:t}),o=Sn("div",{class:"cm-line",style:"display: none"},s);this.view.contentDOM.appendChild(o);const a=window.getComputedStyle(s),i=parseFloat(a.lineHeight)/Qt.SizeRatio,c={color:a.color,font:`${a.fontStyle} ${a.fontWeight} ${i}px ${a.fontFamily}`,lineHeight:i};return this._fontInfoMap.set(t,c),this.view.contentDOM.removeChild(o),c}themeChanged(){const t=this._themeClasses,n=new Set(this.view.dom.classList.values());if(this._themeClasses=n,!t||(t.delete("cm-focused"),n.delete("cm-focused"),t.size!==n.size))return!0;let s=!0;return t.forEach(o=>{n.has(o)||(s=!1)}),!s}}function Sb(e){return new jb(e)}const Zu=4;function Nb(e,t,n){const s=e[n];s&&(t.context.fillStyle=s,t.context.globalAlpha=1,t.context.beginPath(),t.context.rect(t.offsetX,t.offsetY,Zu,t.lineHeight),t.context.fill())}const Cb=mr.theme({"&":{height:"100%",overflowY:"auto"},"& .cm-minimap-gutter":{borderRight:0,flexShrink:0,left:"unset",position:"sticky",right:0,top:0},"& .cm-minimap-inner":{height:"100%",position:"absolute",right:0,top:0,overflowY:"hidden","& canvas":{display:"block"}},"& .cm-minimap-box-shadow":{boxShadow:"12px 0px 20px 5px #6c6c6c"}}),bc=6,Eb=Zs.fromClass(class{constructor(e){this.view=e,this.text=Sb(e),this.selection=kb(e),this.diagnostic=bb(e),e.state.facet(Hn)&&this.create(e)}create(e){const t=e.state.facet(Hn);if(!t)throw Error("Expected nonnull");this.inner=Sn("div",{class:"cm-minimap-inner"}),this.canvas=Sn("canvas"),this.dom=t.create(e).dom,this.dom.classList.add("cm-gutters"),this.dom.classList.add("cm-minimap-gutter"),this.inner.appendChild(this.canvas),this.dom.appendChild(this.inner),this.view.scrollDOM.insertBefore(this.dom,this.view.contentDOM.nextSibling);for(const n in this.view.state.facet(qt).eventHandlers){const s=this.view.state.facet(qt).eventHandlers[n];s&&this.dom.addEventListener(n,o=>s(o,this.view))}}remove(){this.dom&&this.dom.remove()}update(e){const t=e.startState.facet(Hn),n=e.state.facet(Hn);if(t&&!n){this.remove();return}!t&&n&&this.create(e.view),n&&(this.text.update(e),this.selection.update(e),this.diagnostic.update(e),this.render())}getWidth(){const e=this.view.dom.clientWidth;if(e<=Qt.MaxWidth*bc){const t=e/(Qt.MaxWidth*bc);return Qt.MaxWidth*t}return Qt.MaxWidth}render(){if(!this.dom||!this.canvas||!this.inner)return;this.text.beforeDraw(),this.updateBoxShadow(),this.dom.style.width=this.getWidth()+"px",this.canvas.style.maxWidth=this.getWidth()+"px",this.canvas.width=this.getWidth()*Qt.PixelMultiplier;const e=this.view.dom.getBoundingClientRect().height;this.inner.style.minHeight=e+"px",this.canvas.height=e*Qt.PixelMultiplier,this.canvas.style.height=e+"px";const t=this.canvas.getContext("2d");if(!t)return;t.clearRect(0,0,this.canvas.width,this.canvas.height);const{charWidth:n,lineHeight:s}=this.text.measure(t);let{startIndex:o,endIndex:a,offsetY:i}=this.canvasStartAndEndIndex(t,s);const c=this.view.state.facet(qt).gutters;for(let d=o;d<a;d++){const u=this.view.state.field(_n);if(d>=u.length)break;const p={offsetX:0,offsetY:i,context:t,lineHeight:s,charWidth:n};if(c.length){p.offsetX+=2;for(let m of c)Nb(m,p,d+1),p.offsetX+=Zu;p.offsetX+=2}this.text.drawLine(p,d+1),this.selection.drawLine(p,d+1),this.diagnostic.drawLine(p,d+1),i+=s}t.restore()}canvasStartAndEndIndex(e,t){let{top:n,bottom:s}=this.view.documentPadding;n/=Qt.SizeRatio,s/=Qt.SizeRatio;const o=e.canvas.height,{clientHeight:a,scrollHeight:i,scrollTop:c}=this.view.scrollDOM;let d=c/(i-a);isNaN(d)&&(d=0);const u=this.view.state.field(_n).length,p=n+s+u*t,m=Math.max(0,d*(p-o)),h=Math.max(0,n-m),g=Math.round(Math.max(0,m-n)/t),x=Math.round((o-h)/t);return{startIndex:g,endIndex:g+x,offsetY:h}}updateBoxShadow(){if(!this.canvas)return;const{clientWidth:e,scrollWidth:t,scrollLeft:n}=this.view.scrollDOM;e+n<t?this.canvas.classList.add("cm-minimap-box-shadow"):this.canvas.classList.remove("cm-minimap-box-shadow")}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.render())}},provide:e=>mr.scrollMargins.of(t=>{var n;const s=(n=t.plugin(e))===null||n===void 0?void 0:n.getWidth();return s?{right:s}:null})}),Hn=Qs.define({combine:e=>{var t;return(t=e.find(n=>n!==null))!==null&&t!==void 0?t:null},enables:e=>[[qt.compute([e],t=>t.facet(e)),Cb,_n,Eb,vb]]});function wc({file:e,onClose:t,projectPath:n,isSidebar:s=!1,isExpanded:o=!1,onToggleExpand:a=null}){const{t:i}=$t("codeEditor"),[c,d]=l.useState(""),[u,p]=l.useState(!0),[m,h]=l.useState(!1),[g,x]=l.useState(!1),[j,k]=l.useState(()=>{const O=localStorage.getItem("codeEditorTheme");return O?O==="dark":!0}),[A,T]=l.useState(!1),[w,D]=l.useState(!!e.diffInfo),[N,b]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[L,q]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[P,Y]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[ge,le]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),M=l.useRef(null),V=l.useMemo(()=>{if(!e.diffInfo||!w||!L)return[];const O={};return[Hn.compute(["doc"],S=>{const Z=xa(S)?.chunks||[];return Object.keys(O).forEach(ke=>delete O[ke]),Z.forEach(ke=>{const ve=S.doc.lineAt(ke.fromB).number,R=S.doc.lineAt(Math.min(ke.toB,S.doc.length)).number;for(let re=ve;re<=R;re++)O[re]=j?"rgba(34, 197, 94, 0.8)":"rgba(34, 197, 94, 1)"}),{create:()=>({dom:document.createElement("div")}),displayText:"blocks",showOverlay:"always",gutters:[O]}})]},[e.diffInfo,w,L,j]),xe=l.useMemo(()=>!e.diffInfo||!w?[]:[Zs.fromClass(class{constructor(O){setTimeout(()=>{const B=xa(O.state)?.chunks||[];if(B.length>0){const Z=B[0];O.dispatch({effects:mr.scrollIntoView(Z.fromB,{y:"center"})})}},100)}update(){}destroy(){}})],[e.diffInfo,w]),Ie=l.useMemo(()=>{const O=S=>{const B=document.createElement("div");B.className="cm-editor-toolbar-panel";let Z=0;const ke=()=>{const ve=e.diffInfo&&w,re=(ve?xa(S.state):null)?.chunks||[],Fe=re.length;let Ce='<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';if(Ce+='<div style="display: flex; align-items: center; gap: 8px;">',ve&&(Ce+=`
320
- <span style="font-weight: 500;">${Fe>0?`${Z+1}/${Fe}`:"0"} ${i("toolbar.changes")}</span>
321
- <button class="cm-diff-nav-btn cm-diff-nav-prev" title="${i("toolbar.previousChange")}" ${Fe===0?"disabled":""}>
322
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
323
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
324
- </svg>
325
- </button>
326
- <button class="cm-diff-nav-btn cm-diff-nav-next" title="${i("toolbar.nextChange")}" ${Fe===0?"disabled":""}>
327
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
328
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
329
- </svg>
330
- </button>
331
- `),Ce+="</div>",Ce+='<div style="display: flex; align-items: center; gap: 4px;">',e.diffInfo&&(Ce+=`
332
- <button class="cm-toolbar-btn cm-toggle-diff-btn" title="${i(w?"toolbar.hideDiff":"toolbar.showDiff")}">
333
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
334
- ${w?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />'}
335
- </svg>
336
- </button>
337
- `),Ce+=`
338
- <button class="cm-toolbar-btn cm-settings-btn" title="${i("toolbar.settings")}">
339
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
340
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
341
- </svg>
342
- </button>
343
- `,s&&a&&(Ce+=`
344
- <button class="cm-toolbar-btn cm-expand-btn" title="${i(o?"toolbar.collapse":"toolbar.expand")}">
345
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
346
- ${o?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />'}
347
- </svg>
348
- </button>
349
- `),Ce+="</div>",Ce+="</div>",B.innerHTML=Ce,ve){const $e=B.querySelector(".cm-diff-nav-prev"),ft=B.querySelector(".cm-diff-nav-next");$e?.addEventListener("click",()=>{if(re.length===0)return;Z=Z>0?Z-1:re.length-1;const at=re[Z];at&&S.dispatch({effects:mr.scrollIntoView(at.fromB,{y:"center"})}),ke()}),ft?.addEventListener("click",()=>{if(re.length===0)return;Z=Z<re.length-1?Z+1:0;const at=re[Z];at&&S.dispatch({effects:mr.scrollIntoView(at.fromB,{y:"center"})}),ke()})}e.diffInfo&&B.querySelector(".cm-toggle-diff-btn")?.addEventListener("click",()=>{D(!w)}),B.querySelector(".cm-settings-btn")?.addEventListener("click",()=>{window.openSettings&&window.openSettings("appearance")}),s&&a&&B.querySelector(".cm-expand-btn")?.addEventListener("click",()=>{a()})};return ke(),{top:!0,dom:B,update:ke}};return[om.of(O)]},[e.diffInfo,w,s,o,a]),qe=O=>{const S=O.split(".").pop()?.toLowerCase();switch(S){case"js":case"jsx":case"ts":case"tsx":return[mm({jsx:!0,typescript:S.includes("ts")})];case"py":return[pm()];case"html":case"htm":return[um()];case"css":case"scss":case"less":return[dm()];case"json":return[cm()];case"md":case"markdown":return[lm()];default:return[]}};l.useEffect(()=>{(async()=>{try{if(p(!0),e.diffInfo&&e.diffInfo.new_string!==void 0&&e.diffInfo.old_string!==void 0){d(e.diffInfo.new_string),p(!1);return}const S=await mt.readFile(e.projectName,e.path);if(!S.ok)throw new Error(`Failed to load file: ${S.status} ${S.statusText}`);const B=await S.json();d(B.content)}catch(S){console.error("Error loading file:",S),d(`// Error loading file: ${S.message}
350
- // File: ${e.name}
351
- // Path: ${e.path}`)}finally{p(!1)}})()},[e,n]);const Se=async()=>{h(!0);try{console.log("Saving file:",{projectName:e.projectName,path:e.path,contentLength:c?.length});const O=await mt.saveFile(e.projectName,e.path,c);if(console.log("Save response:",{status:O.status,ok:O.ok,contentType:O.headers.get("content-type")}),!O.ok){const B=O.headers.get("content-type");if(B&&B.includes("application/json")){const Z=await O.json();throw new Error(Z.error||`Save failed: ${O.status}`)}else{const Z=await O.text();throw console.error("Non-JSON error response:",Z),new Error(`Save failed: ${O.status} ${O.statusText}`)}}const S=await O.json();console.log("Save successful:",S),T(!0),setTimeout(()=>T(!1),2e3)}catch(O){console.error("Error saving file:",O),alert(`Error saving file: ${O.message}`)}finally{h(!1)}},U=()=>{const O=new Blob([c],{type:"text/plain"}),S=URL.createObjectURL(O),B=document.createElement("a");B.href=S,B.download=e.name,document.body.appendChild(B),B.click(),document.body.removeChild(B),URL.revokeObjectURL(S)},fe=()=>{x(!g)};return l.useEffect(()=>{localStorage.setItem("codeEditorTheme",j?"dark":"light")},[j]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",N.toString())},[N]),l.useEffect(()=>{const O=()=>{const S=localStorage.getItem("codeEditorTheme");S&&k(S==="dark");const B=localStorage.getItem("codeEditorWordWrap");B!==null&&b(B==="true");const Z=localStorage.getItem("codeEditorShowMinimap");Z!==null&&q(Z!=="false");const ke=localStorage.getItem("codeEditorLineNumbers");ke!==null&&Y(ke!=="false");const ve=localStorage.getItem("codeEditorFontSize");ve&&le(ve)};return window.addEventListener("storage",O),window.addEventListener("codeEditorSettingsChanged",O),()=>{window.removeEventListener("storage",O),window.removeEventListener("codeEditorSettingsChanged",O)}},[]),l.useEffect(()=>{const O=S=>{(S.ctrlKey||S.metaKey)&&(S.key==="s"?(S.preventDefault(),Se()):S.key==="Escape"&&(S.preventDefault(),t()))};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[c]),u?r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
352
- .code-editor-loading {
353
- background-color: ${j?"#111827":"#ffffff"} !important;
354
- }
355
- .code-editor-loading:hover {
356
- background-color: ${j?"#111827":"#ffffff"} !important;
357
- }
358
- `}),s?r.jsx("div",{className:"w-full h-full flex items-center justify-center bg-background",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"}),r.jsx("span",{className:"text-gray-900 dark:text-white",children:i("loading",{fileName:e.name})})]})}):r.jsx("div",{className:"fixed inset-0 z-40 md:bg-black/50 md:flex md:items-center md:justify-center",children:r.jsx("div",{className:"code-editor-loading w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"}),r.jsx("span",{className:"text-gray-900 dark:text-white",children:i("loading",{fileName:e.name})})]})})})]}):r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
359
- /* Light background for full line changes */
360
- .cm-deletedChunk {
361
- background-color: ${j?"rgba(239, 68, 68, 0.15)":"rgba(255, 235, 235, 1)"} !important;
362
- border-left: 3px solid ${j?"rgba(239, 68, 68, 0.6)":"rgb(239, 68, 68)"} !important;
363
- padding-left: 4px !important;
364
- }
365
-
366
- .cm-insertedChunk {
367
- background-color: ${j?"rgba(34, 197, 94, 0.15)":"rgba(230, 255, 237, 1)"} !important;
368
- border-left: 3px solid ${j?"rgba(34, 197, 94, 0.6)":"rgb(34, 197, 94)"} !important;
369
- padding-left: 4px !important;
370
- }
371
-
372
- /* Override linear-gradient underline and use solid darker background for partial changes */
373
- .cm-editor.cm-merge-b .cm-changedText {
374
- background: ${j?"rgba(34, 197, 94, 0.4)":"rgba(34, 197, 94, 0.3)"} !important;
375
- padding-top: 2px !important;
376
- padding-bottom: 2px !important;
377
- margin-top: -2px !important;
378
- margin-bottom: -2px !important;
379
- }
380
-
381
- .cm-editor .cm-deletedChunk .cm-changedText {
382
- background: ${j?"rgba(239, 68, 68, 0.4)":"rgba(239, 68, 68, 0.3)"} !important;
383
- padding-top: 2px !important;
384
- padding-bottom: 2px !important;
385
- margin-top: -2px !important;
386
- margin-bottom: -2px !important;
387
- }
388
-
389
- /* Minimap gutter styling */
390
- .cm-gutter.cm-gutter-minimap {
391
- background-color: ${j?"#1e1e1e":"#f5f5f5"};
392
- }
393
-
394
- /* Editor toolbar panel styling */
395
- .cm-editor-toolbar-panel {
396
- padding: 8px 12px;
397
- background-color: ${j?"#1f2937":"#ffffff"};
398
- border-bottom: 1px solid ${j?"#374151":"#e5e7eb"};
399
- color: ${j?"#d1d5db":"#374151"};
400
- font-size: 14px;
401
- }
402
-
403
- .cm-diff-nav-btn,
404
- .cm-toolbar-btn {
405
- padding: 4px;
406
- background: transparent;
407
- border: none;
408
- cursor: pointer;
409
- border-radius: 4px;
410
- display: inline-flex;
411
- align-items: center;
412
- justify-content: center;
413
- color: inherit;
414
- transition: background-color 0.2s;
415
- }
416
-
417
- .cm-diff-nav-btn:hover,
418
- .cm-toolbar-btn:hover {
419
- background-color: ${j?"#374151":"#f3f4f6"};
420
- }
421
-
422
- .cm-diff-nav-btn:disabled {
423
- opacity: 0.5;
424
- cursor: not-allowed;
425
- }
426
- `}),r.jsx("div",{className:s?"w-full h-full flex flex-col":`fixed inset-0 z-40 md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${g?"md:p-0":""}`,children:r.jsxs("div",{className:s?"bg-background flex flex-col w-full h-full":`bg-background shadow-2xl flex flex-col ${"w-full h-full md:rounded-lg md:shadow-2xl"+(g?" md:w-full md:h-full md:rounded-none":" md:w-full md:max-w-6xl md:h-[80vh] md:max-h-[80vh]")}`,children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border flex-shrink-0 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("h3",{className:"font-medium text-gray-900 dark:text-white truncate",children:e.name}),e.diffInfo&&r.jsx("span",{className:"text-xs bg-primary/15 dark:bg-primary/30 text-primary dark:text-primary/80 px-2 py-1 rounded whitespace-nowrap",children:i("header.showingChanges")})]}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 truncate",children:e.path})]})}),r.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:U,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:i("actions.download"),children:r.jsx(ka,{className:"w-5 h-5 md:w-4 md:h-4"})}),r.jsx("button",{onClick:Se,disabled:m,className:`px-3 py-2 text-white rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors min-h-[44px] md:min-h-0 ${A?"bg-green-600 hover:bg-green-700":"bg-primary hover:bg-primary/90"}`,children:A?r.jsxs(r.Fragment,{children:[r.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),r.jsx("span",{className:"hidden sm:inline",children:i("actions.saved")})]}):r.jsxs(r.Fragment,{children:[r.jsx(Vf,{className:"w-5 h-5 md:w-4 md:h-4"}),r.jsx("span",{className:"hidden sm:inline",children:i(m?"actions.saving":"actions.save")})]})}),!s&&r.jsx("button",{onClick:fe,className:"hidden md:flex p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:i(g?"actions.exitFullscreen":"actions.fullscreen"),children:g?r.jsx($f,{className:"w-4 h-4"}):r.jsx(Bc,{className:"w-4 h-4"})}),r.jsx("button",{onClick:t,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:i("actions.close"),children:r.jsx(ar,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(am,{ref:M,value:c,onChange:d,extensions:[...qe(e.name),...Ie,...e.diffInfo&&w&&e.diffInfo.old_string!==void 0?[ab({original:e.diffInfo.old_string,mergeControls:!1,highlightChanges:!0,syntaxHighlightDeletions:!1,gutter:!0}),...V,...xe]:[],...N?[mr.lineWrapping]:[]],theme:j?im:void 0,height:"100%",style:{fontSize:`${ge}px`,height:"100%"},basicSetup:{lineNumbers:P,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),r.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-border bg-muted flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[r.jsxs("span",{children:[i("footer.lines")," ",c.split(`
427
- `).length]}),r.jsxs("span",{children:[i("footer.characters")," ",c.length]})]}),r.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:i("footer.shortcuts")})]})]})})]})}var Ib=Qm(),Ab=Zm(),Tb=ef(),va={exports:{}},kc;function _b(){return kc||(kc=1,function(e,t){(function(n,s){e.exports=s()})(self,()=>(()=>{var n={6:(i,c)=>{function d(p){try{const m=new URL(p),h=m.password&&m.username?`${m.protocol}//${m.username}:${m.password}@${m.host}`:m.username?`${m.protocol}//${m.username}@${m.host}`:`${m.protocol}//${m.host}`;return p.toLocaleLowerCase().startsWith(h.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(c,"__esModule",{value:!0}),c.LinkComputer=c.WebLinkProvider=void 0,c.WebLinkProvider=class{constructor(p,m,h,g={}){this._terminal=p,this._regex=m,this._handler=h,this._options=g}provideLinks(p,m){const h=u.computeLink(p,this._regex,this._terminal,this._handler);m(this._addCallbacks(h))}_addCallbacks(p){return p.map(m=>(m.leave=this._options.leave,m.hover=(h,g)=>{if(this._options.hover){const{range:x}=m;this._options.hover(h,g,x)}},m))}};class u{static computeLink(m,h,g,x){const j=new RegExp(h.source,(h.flags||"")+"g"),[k,A]=u._getWindowedLineStrings(m-1,g),T=k.join("");let w;const D=[];for(;w=j.exec(T);){const N=w[0];if(!d(N))continue;const[b,L]=u._mapStrIdx(g,A,0,w.index),[q,P]=u._mapStrIdx(g,b,L,N.length);if(b===-1||L===-1||q===-1||P===-1)continue;const Y={start:{x:L+1,y:b+1},end:{x:P,y:q+1}};D.push({range:Y,text:N,activate:x})}return D}static _getWindowedLineStrings(m,h){let g,x=m,j=m,k=0,A="";const T=[];if(g=h.buffer.active.getLine(m)){const w=g.translateToString(!0);if(g.isWrapped&&w[0]!==" "){for(k=0;(g=h.buffer.active.getLine(--x))&&k<2048&&(A=g.translateToString(!0),k+=A.length,T.push(A),g.isWrapped&&A.indexOf(" ")===-1););T.reverse()}for(T.push(w),k=0;(g=h.buffer.active.getLine(++j))&&g.isWrapped&&k<2048&&(A=g.translateToString(!0),k+=A.length,T.push(A),A.indexOf(" ")===-1););}return[T,x]}static _mapStrIdx(m,h,g,x){const j=m.buffer.active,k=j.getNullCell();let A=g;for(;x;){const T=j.getLine(h);if(!T)return[-1,-1];for(let w=A;w<T.length;++w){T.getCell(w,k);const D=k.getChars();if(k.getWidth()&&(x-=D.length||1,w===T.length-1&&D==="")){const N=j.getLine(h+1);N&&N.isWrapped&&(N.getCell(0,k),k.getWidth()===2&&(x+=1))}if(x<0)return[h,w]}h++,A=0}return[h,A]}}c.LinkComputer=u}},s={};function o(i){var c=s[i];if(c!==void 0)return c.exports;var d=s[i]={exports:{}};return n[i](d,d.exports,o),d.exports}var a={};return(()=>{var i=a;Object.defineProperty(i,"__esModule",{value:!0}),i.WebLinksAddon=void 0;const c=o(6),d=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function u(p,m){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=m}else console.warn("Opening link blocked as opener could not be cleared")}i.WebLinksAddon=class{constructor(p=u,m={}){this._handler=p,this._options=m}activate(p){this._terminal=p;const m=this._options,h=m.urlRegex||d;this._linkProvider=this._terminal.registerLinkProvider(new c.WebLinkProvider(this._terminal,h,this._handler,m))}dispose(){this._linkProvider?.dispose()}}})(),a})())}(va)),va.exports}var Mb=_b();const Db=`
428
- .xterm .xterm-screen {
429
- outline: none !important;
430
- }
431
- .xterm:focus .xterm-screen {
432
- outline: none !important;
433
- }
434
- .xterm-screen:focus {
435
- outline: none !important;
436
- }
437
- `;if(typeof document<"u"){const e=document.createElement("style");e.type="text/css",e.innerText=Db,document.head.appendChild(e)}function Rb({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:s=!1,onProcessComplete:o,minimal:a=!1,autoConnect:i=!1}){const{t:c}=$t("chat"),d=l.useRef(null),u=l.useRef(null),p=l.useRef(null),m=l.useRef(null),[h,g]=l.useState(!1),[x,j]=l.useState(!1),[k,A]=l.useState(!1),[T,w]=l.useState(null),[D,N]=l.useState(!1),b=l.useRef(e),L=l.useRef(t),q=l.useRef(n),P=l.useRef(s),Y=l.useRef(o);l.useEffect(()=>{b.current=e,L.current=t,q.current=n,P.current=s,Y.current=o});const ge=l.useCallback(async()=>{if(!(D||h))try{let Se;if(!Wx){const U=localStorage.getItem("auth-token");if(!U){console.error("No authentication token found for Shell WebSocket connection");return}Se=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(U)}`}m.current=new WebSocket(Se),m.current.onopen=()=>{g(!0),N(!1),setTimeout(()=>{p.current&&u.current&&(p.current.fit(),m.current.send(JSON.stringify({type:"init",projectPath:b.current.fullPath||b.current.path,sessionId:P.current?null:L.current?.id,hasSession:P.current?!1:!!L.current,provider:P.current?"plain-shell":L.current?.__provider||"claude",cols:u.current.cols,rows:u.current.rows,initialCommand:q.current,isPlainShell:P.current})))},100)},m.current.onmessage=U=>{try{const fe=JSON.parse(U.data);if(fe.type==="output"){let O=fe.data;if(P.current&&Y.current){const S=O.replace(/\x1b\[[0-9;]*m/g,"");if(S.includes("Process exited with code 0"))Y.current(0);else if(S.match(/Process exited with code (\d+)/)){const B=parseInt(S.match(/Process exited with code (\d+)/)[1]);B!==0&&Y.current(B)}}u.current&&u.current.write(O)}else fe.type==="url_open"&&window.open(fe.url,"_blank")}catch(fe){console.error("[Shell] Error handling WebSocket message:",fe,U.data)}},m.current.onclose=U=>{g(!1),N(!1),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H"))},m.current.onerror=U=>{g(!1),N(!1)}}catch{g(!1),N(!1)}},[D,h]),le=l.useCallback(()=>{!x||h||D||(N(!0),ge())},[x,h,D,ge]),M=l.useCallback(()=>{m.current&&(m.current.close(),m.current=null),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H")),g(!1),N(!1)},[]),V=l.useMemo(()=>t?t.summary||t.name||"New Session":null,[t]),xe=l.useMemo(()=>V?V.slice(0,30):null,[V]),Ie=l.useMemo(()=>V?V.slice(0,50):null,[V]),qe=()=>{A(!0),m.current&&(m.current.close(),m.current=null),u.current&&(u.current.dispose(),u.current=null,p.current=null),g(!1),j(!1),setTimeout(()=>{A(!1)},200)};return l.useEffect(()=>{const Se=t?.id||null;T!==null&&T!==Se&&x&&M(),w(Se)},[t?.id,x,M]),l.useEffect(()=>{if(!d.current||!e||k||u.current)return;u.current=new Ib.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),p.current=new Ab.FitAddon;const Se=new Tb.WebglAddon,U=new Mb.WebLinksAddon;u.current.loadAddon(p.current),u.current.loadAddon(U);try{u.current.loadAddon(Se)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}u.current.open(d.current),u.current.attachCustomKeyEventHandler(O=>(O.ctrlKey||O.metaKey)&&O.key==="c"&&u.current.hasSelection()?(document.execCommand("copy"),!1):(O.ctrlKey||O.metaKey)&&O.key==="v"?(navigator.clipboard.readText().then(S=>{m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:S}))}).catch(()=>{}),!1):!0),setTimeout(()=>{p.current&&(p.current.fit(),u.current&&m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows})))},100),j(!0),u.current.onData(O=>{m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:O}))});const fe=new ResizeObserver(()=>{p.current&&u.current&&setTimeout(()=>{p.current.fit(),m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows}))},50)});return d.current&&fe.observe(d.current),()=>{fe.disconnect(),m.current&&(m.current.readyState===WebSocket.OPEN||m.current.readyState===WebSocket.CONNECTING)&&m.current.close(),m.current=null,u.current&&(u.current.dispose(),u.current=null)}},[e?.path||e?.fullPath,k]),l.useEffect(()=>{!i||!x||D||h||le()},[i,x,D,h,le]),e?a?r.jsx("div",{className:"h-full w-full bg-gray-900",children:r.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):r.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[r.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("div",{className:`w-2 h-2 rounded-full ${h?"bg-green-500":"bg-red-500"}`}),t&&r.jsxs("span",{className:"text-xs text-primary/80",children:["(",xe,"...)"]}),!t&&r.jsx("span",{className:"text-xs text-gray-400",children:c("shell.status.newSession")}),!x&&r.jsx("span",{className:"text-xs text-yellow-400",children:c("shell.status.initializing")}),k&&r.jsx("span",{className:"text-xs text-primary",children:c("shell.status.restarting")})]}),r.jsxs("div",{className:"flex items-center space-x-3",children:[h&&r.jsxs("button",{onClick:M,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:c("shell.actions.disconnectTitle"),children:[r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),r.jsx("span",{children:c("shell.actions.disconnect")})]}),r.jsxs("button",{onClick:qe,disabled:k||h,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:c("shell.actions.restartTitle"),children:[r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),r.jsx("span",{children:c("shell.actions.restart")})]})]})]})}),r.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[r.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!x&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:r.jsx("div",{className:"text-white",children:c("shell.loading")})}),x&&!h&&!D&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:r.jsxs("div",{className:"text-center max-w-sm w-full",children:[r.jsxs("button",{onClick:le,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",title:c("shell.actions.connectTitle"),children:[r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),r.jsx("span",{children:c("shell.actions.connect")})]}),r.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:s?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:Ie}):c("shell.startSession")})]})}),D&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:r.jsxs("div",{className:"text-center max-w-sm w-full",children:[r.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[r.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),r.jsx("span",{className:"text-base font-medium",children:c("shell.connecting")})]}),r.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:s?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName})})]})})]})]}):r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:c("shell.selectProject.title")}),r.jsx("p",{children:c("shell.selectProject.description")})]})})}function ep({project:e,session:t=null,command:n=null,isPlainShell:s=null,autoConnect:o=!0,onComplete:a=null,onClose:i=null,title:c=null,className:d="",showHeader:u=!0,compact:p=!1,minimal:m=!1}){const[h,g]=l.useState(!1),x=s!==null?s:n!==null,j=l.useCallback(k=>{g(!0),a&&a(k)},[a]);return e?r.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[!m&&u&&c&&r.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-200",children:c}),h&&r.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),i&&r.jsx("button",{onClick:i,className:"text-gray-400 hover:text-white",title:"Close",children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),r.jsx("div",{className:"flex-1 w-full min-h-0",children:r.jsx(Rb,{selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:x,onProcessComplete:j,minimal:m,autoConnect:m?!0:o})})]}):r.jsx("div",{className:`h-full flex items-center justify-center ${d}`,children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Project Selected"}),r.jsx("p",{children:"A project is required to open a shell"})]})})}async function Pb(e,t){const n=new FormData,s=`recording_${Date.now()}.webm`,o=new File([e],s,{type:e.type});n.append("audio",o);const a=window.localStorage.getItem("whisperMode")||"default";n.append("mode",a);try{const i=await mt.transcribe(n);if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(d.error||`Transcription error: ${i.status} ${i.statusText}`)}return(await i.json()).text||""}catch(i){throw i.name==="TypeError"&&i.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):i}}function Lb({onTranscript:e,className:t=""}){const[n,s]=l.useState("idle"),[o,a]=l.useState(null),[i,c]=l.useState(!0),d=l.useRef(null),u=l.useRef(null),p=l.useRef([]),m=l.useRef(0);l.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){c(!1),a("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){c(!1),a("Microphone requires HTTPS. Please use a secure connection.");return}c(!0),a(null)})()},[]);const h=async()=>{try{if(console.log("Starting recording..."),a(null),p.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const w=await navigator.mediaDevices.getUserMedia({audio:!0});u.current=w;const D=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",N=new MediaRecorder(w,{mimeType:D});d.current=N,N.ondataavailable=b=>{b.data.size>0&&p.current.push(b.data)},N.onstop=async()=>{console.log("Recording stopped, creating blob...");const b=new Blob(p.current,{type:D});u.current&&(u.current.getTracks().forEach(Y=>Y.stop()),u.current=null),s("transcribing");const L=window.localStorage.getItem("whisperMode")||"default",q=L==="prompt"||L==="vibe"||L==="instructions"||L==="architect";let P;q&&(P=setTimeout(()=>{s("processing")},2e3));try{const Y=await Pb(b);Y&&e&&e(Y)}catch(Y){console.error("Transcription error:",Y),a(Y.message)}finally{P&&clearTimeout(P),s("idle")}},N.start(),s("recording"),console.log("Recording started successfully")}catch(w){console.error("Failed to start recording:",w);let D="Microphone access failed";w.name==="NotAllowedError"?D="Microphone access denied. Please allow microphone permissions.":w.name==="NotFoundError"?D="No microphone found. Please check your audio devices.":w.name==="NotSupportedError"?D="Microphone not supported by this browser.":w.name==="NotReadableError"?D="Microphone is being used by another application.":w.message.includes("HTTPS")&&(D=w.message),a(D),s("idle")}},g=()=>{console.log("Stopping recording..."),d.current&&d.current.state==="recording"?d.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),u.current&&(u.current.getTracks().forEach(w=>w.stop()),u.current=null),s("idle"))},x=w=>{if(w&&(w.preventDefault(),w.stopPropagation()),!i)return;const D=Date.now();if(D-m.current<300){console.log("Ignoring rapid tap");return}m.current=D,console.log("Button clicked, current state:",n),n==="idle"?h():n==="recording"&&g()};l.useEffect(()=>()=>{u.current&&u.current.getTracks().forEach(w=>w.stop())},[]);const j=()=>{if(!i)return{icon:r.jsx(Fs,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(n){case"recording":return{icon:r.jsx(Fs,{className:"w-5 h-5 text-white"}),className:"bg-red-500 hover:bg-red-600 animate-pulse",disabled:!1};case"transcribing":return{icon:r.jsx(qn,{className:"w-5 h-5 animate-spin"}),className:"bg-primary hover:bg-primary/90",disabled:!0};case"processing":return{icon:r.jsx(Pc,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:r.jsx(Fs,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:k,className:A,disabled:T}=j();return r.jsxs("div",{className:"relative",children:[r.jsx("button",{type:"button",style:{backgroundColor:n==="recording"?"#ef4444":n==="transcribing"?"#3b82f6":n==="processing"?"#a855f7":"#374151"},className:`
438
- flex items-center justify-center
439
- w-12 h-12 rounded-full
440
- text-white transition-all duration-200
441
- focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-ring
442
- dark:ring-offset-gray-800
443
- touch-action-manipulation
444
- ${T?"cursor-not-allowed opacity-75":"cursor-pointer"}
445
- ${n==="recording"?"animate-pulse":""}
446
- hover:opacity-90
447
- ${t}
448
- `,onClick:x,disabled:T,children:k}),o&&r.jsx("div",{className:`absolute top-full mt-2 left-1/2 transform -translate-x-1/2
449
- bg-red-500 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-10
450
- animate-fade-in`,children:o}),n==="recording"&&r.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),n==="processing"&&r.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}function jc({diff:e,fileName:t,isMobile:n,wrapText:s}){if(!e)return r.jsx("div",{className:"p-4 text-center text-gray-500 dark:text-gray-400 text-sm",children:"No diff available"});const o=(a,i)=>{const c=a.startsWith("+")&&!a.startsWith("+++"),d=a.startsWith("-")&&!a.startsWith("---"),u=a.startsWith("@@");return r.jsx("div",{className:`font-mono text-xs p-2 ${n&&s?"whitespace-pre-wrap break-all":"whitespace-pre overflow-x-auto"} ${c?"bg-green-50 dark:bg-green-950 text-green-700 dark:text-green-300":d?"bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300":u?"bg-primary/10 dark:bg-primary/20 text-primary":"text-gray-600 dark:text-gray-400"}`,children:a},i)};return r.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-background/95 shadow-sm",children:[t&&r.jsx("div",{className:"border-b border-border/70 px-3 py-2 text-xs font-medium text-muted-foreground",children:t}),e.split(`
451
- `).map((a,i)=>o(a,i))]})}function Ob({selectedProject:e,isMobile:t,onFileOpen:n}){const[s,o]=l.useState(null),[a,i]=l.useState({}),[c,d]=l.useState(!1),[u,p]=l.useState(""),[m,h]=l.useState(new Set),[g,x]=l.useState(new Set),[j,k]=l.useState(!1),[A,T]=l.useState(""),[w,D]=l.useState([]),[N,b]=l.useState(!0),[L,q]=l.useState(!1),[P,Y]=l.useState(!1),[ge,le]=l.useState(!1),[M,V]=l.useState(""),[xe,Ie]=l.useState(!1),[qe,Se]=l.useState("changes"),[U,fe]=l.useState([]),[O,S]=l.useState(new Set),[B,Z]=l.useState({}),[ke,ve]=l.useState(!1),[R,re]=l.useState(null),[Fe,Ce]=l.useState(!1),[ce,$e]=l.useState(!1),[ft,at]=l.useState(!1),[Ve,Ze]=l.useState(!1),[yt,Tt]=l.useState(t),[he,Ke]=l.useState(null),[_t,kt]=l.useState(!1),St=l.useRef(null),J=l.useRef(null),[ee,je]=l.useState(()=>localStorage.getItem("selected-provider")||"claude");l.useEffect(()=>{const C=()=>{const F=localStorage.getItem("selected-provider")||"claude";je(F)};return window.addEventListener("storage",C),()=>window.removeEventListener("storage",C)},[]),l.useEffect(()=>{e&&(_e(),et(),tt(),qe==="history"&&tr())},[e,qe]),l.useEffect(()=>{const C=F=>{J.current&&!J.current.contains(F.target)&&Y(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]);const _e=async()=>{if(e){d(!0);try{const F=await(await oe(`/api/git/status?project=${encodeURIComponent(e.name)}`)).json();if(F.error)console.error("Git status error:",F.error),o({error:F.error,details:F.details});else{o(F),T(F.branch||"main");const ie=new Set([...F.modified||[],...F.added||[],...F.deleted||[],...F.untracked||[]]);x(ie);for(const be of F.modified||[])ht(be);for(const be of F.added||[])ht(be);for(const be of F.deleted||[])ht(be);for(const be of F.untracked||[])ht(be)}}catch(C){console.error("Error fetching git status:",C)}finally{d(!1)}}},et=async()=>{try{const F=await(await oe(`/api/git/branches?project=${encodeURIComponent(e.name)}`)).json();!F.error&&F.branches&&D(F.branches)}catch(C){console.error("Error fetching branches:",C)}},tt=async()=>{if(e)try{const F=await(await oe(`/api/git/remote-status?project=${encodeURIComponent(e.name)}`)).json();F.error?re(null):re(F)}catch(C){console.error("Error fetching remote status:",C),re(null)}},Je=async C=>{try{const ie=await(await oe("/api/git/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:C})})).json();ie.success?(T(C),Y(!1),_e()):console.error("Failed to switch branch:",ie.error)}catch(F){console.error("Error switching branch:",F)}},Mt=async()=>{if(M.trim()){Ie(!0);try{const F=await(await oe("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:M.trim()})})).json();F.success?(T(M.trim()),le(!1),Y(!1),V(""),et(),_e()):console.error("Failed to create branch:",F.error)}catch(C){console.error("Error creating branch:",C)}finally{Ie(!1)}}},ue=async()=>{Ce(!0);try{const F=await(await oe("/api/git/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(_e(),tt()):console.error("Fetch failed:",F.error)}catch(C){console.error("Error fetching from remote:",C)}finally{Ce(!1)}},bt=async()=>{$e(!0);try{const F=await(await oe("/api/git/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(_e(),tt()):console.error("Pull failed:",F.error)}catch(C){console.error("Error pulling from remote:",C)}finally{$e(!1)}},Ye=async()=>{at(!0);try{const F=await(await oe("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(_e(),tt()):console.error("Push failed:",F.error)}catch(C){console.error("Error pushing to remote:",C)}finally{at(!1)}},rt=async()=>{Ze(!0);try{const F=await(await oe("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:A})})).json();F.success?(_e(),tt()):console.error("Publish failed:",F.error)}catch(C){console.error("Error publishing branch:",C)}finally{Ze(!1)}},Ue=async C=>{try{const ie=await(await oe("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:C})})).json();ie.success?(x(be=>{const dt=new Set(be);return dt.delete(C),dt}),_e()):console.error("Discard failed:",ie.error)}catch(F){console.error("Error discarding changes:",F)}},Nt=async C=>{try{const ie=await(await oe("/api/git/delete-untracked",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:C})})).json();ie.success?(x(be=>{const dt=new Set(be);return dt.delete(C),dt}),_e()):console.error("Delete failed:",ie.error)}catch(F){console.error("Error deleting untracked file:",F)}},Pt=async()=>{if(!he)return;const{type:C,file:F,message:ie}=he;Ke(null);try{switch(C){case"discard":await Ue(F);break;case"delete":await Nt(F);break;case"commit":await zt();break;case"pull":await bt();break;case"push":await Ye();break;case"publish":await rt();break}}catch(be){console.error(`Error executing ${C}:`,be)}},ht=async C=>{try{const ie=await(await oe(`/api/git/diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(C)}`)).json();!ie.error&&ie.diff&&i(be=>({...be,[C]:ie.diff}))}catch(F){console.error("Error fetching file diff:",F)}},Ct=async C=>{if(n)try{const ie=await(await oe(`/api/git/file-with-diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(C)}`)).json();if(ie.error){console.error("Error fetching file with diff:",ie.error),n(C);return}const be={old_string:ie.oldContent||"",new_string:ie.currentContent||""};n(C,be)}catch(F){console.error("Error opening file:",F),n(C)}},tr=async()=>{try{const F=await(await oe(`/api/git/commits?project=${encodeURIComponent(e.name)}&limit=10`)).json();!F.error&&F.commits&&fe(F.commits)}catch(C){console.error("Error fetching commits:",C)}},Xe=async C=>{try{const ie=await(await oe(`/api/git/commit-diff?project=${encodeURIComponent(e.name)}&commit=${C}`)).json();!ie.error&&ie.diff&&Z(be=>({...be,[C]:ie.diff}))}catch(F){console.error("Error fetching commit diff:",F)}},Lt=async()=>{ve(!0);try{const F=await(await oe("/api/git/generate-commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,files:Array.from(g),provider:ee})})).json();F.message?p(F.message):console.error("Failed to generate commit message:",F.error)}catch(C){console.error("Error generating commit message:",C)}finally{ve(!1)}},jt=C=>{h(F=>{const ie=new Set(F);return ie.has(C)?ie.delete(C):ie.add(C),ie})},Ot=C=>{S(F=>{const ie=new Set(F);return ie.has(C)?ie.delete(C):(ie.add(C),B[C]||Xe(C)),ie})},rr=C=>{x(F=>{const ie=new Set(F);return ie.has(C)?ie.delete(C):ie.add(C),ie})},zt=async()=>{if(!(!u.trim()||g.size===0)){k(!0);try{const F=await(await oe("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,message:u,files:Array.from(g)})})).json();F.success?(p(""),x(new Set),_e(),tt()):console.error("Commit failed:",F.error)}catch(C){console.error("Error committing changes:",C)}finally{k(!1)}}},_=async()=>{kt(!0);try{const F=await(await oe("/api/git/initial-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(_e(),tt()):(console.error("Initial commit failed:",F.error),alert(F.error||"Failed to create initial commit"))}catch(C){console.error("Error creating initial commit:",C),alert("Failed to create initial commit")}finally{kt(!1)}},pe=C=>{switch(C){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"U":return"Untracked";default:return C}},Ae=C=>{const F=O.has(C.hash),ie=B[C.hash];return r.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700 last:border-0",children:[r.jsxs("div",{className:"flex items-start p-3 hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer",onClick:()=>Ot(C.hash),children:[r.jsx("div",{className:"mr-2 mt-1 p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:F?r.jsx(Tr,{className:"w-3 h-3"}):r.jsx(wn,{className:"w-3 h-3"})}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:C.message}),r.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[C.author," • ",C.date]})]}),r.jsx("span",{className:"text-xs font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:C.hash.substring(0,7)})]})})]}),F&&ie&&r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900",children:r.jsxs("div",{className:"max-h-96 overflow-y-auto p-2",children:[r.jsx("div",{className:"text-xs font-mono text-gray-600 dark:text-gray-400 mb-2",children:C.stats}),r.jsx(jc,{diff:ie,fileName:"commit",isMobile:t,wrapText:N})]})})]},C.hash)},X=(C,F)=>{const ie=m.has(C),be=g.has(C),dt=a[C];return r.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700 last:border-0",children:[r.jsxs("div",{className:`flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 ${t?"px-2 py-1.5":"px-3 py-2"}`,children:[r.jsx("input",{type:"checkbox",checked:be,onChange:()=>rr(C),onClick:W=>W.stopPropagation(),className:`rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:focus:ring-ring dark:bg-gray-800 dark:checked:bg-primary ${t?"mr-1.5":"mr-2"}`}),r.jsxs("div",{className:"flex items-center flex-1",children:[r.jsx("div",{className:`p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded cursor-pointer ${t?"mr-1":"mr-2"}`,onClick:W=>{W.stopPropagation(),jt(C)},children:r.jsx(wn,{className:`w-3 h-3 transition-transform duration-200 ease-in-out ${ie?"rotate-90":"rotate-0"}`})}),r.jsx("span",{className:`flex-1 truncate ${t?"text-xs":"text-sm"} cursor-pointer hover:text-primary hover:underline`,onClick:W=>{W.stopPropagation(),Ct(C)},title:"Click to open file",children:C}),r.jsxs("div",{className:"flex items-center gap-1",children:[(F==="M"||F==="D")&&r.jsxs("button",{onClick:W=>{W.stopPropagation(),Ke({type:"discard",file:C,message:`Discard all changes to "${C}"? This action cannot be undone.`})},className:`${t?"px-2 py-1 text-xs":"p-1"} hover:bg-red-100 dark:hover:bg-red-900 rounded text-red-600 dark:text-red-400 font-medium flex items-center gap-1`,title:"Discard changes",children:[r.jsx(pr,{className:"w-3 h-3"}),t&&r.jsx("span",{children:"Discard"})]}),F==="U"&&r.jsxs("button",{onClick:W=>{W.stopPropagation(),Ke({type:"delete",file:C,message:`Delete untracked file "${C}"? This action cannot be undone.`})},className:`${t?"px-2 py-1 text-xs":"p-1"} hover:bg-red-100 dark:hover:bg-red-900 rounded text-red-600 dark:text-red-400 font-medium flex items-center gap-1`,title:"Delete untracked file",children:[r.jsx(pr,{className:"w-3 h-3"}),t&&r.jsx("span",{children:"Delete"})]}),r.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-xs font-bold border ${F==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":F==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":F==="D"?"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 border-red-200 dark:border-red-800":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 border-gray-300 dark:border-gray-600"}`,title:pe(F),children:F})]})]})]}),r.jsxs("div",{className:`bg-gray-50 dark:bg-gray-900 transition-all duration-400 ease-in-out overflow-hidden ${ie&&dt?"max-h-[600px] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-1"}`,children:[r.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-xs font-bold border ${F==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":F==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":F==="D"?"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 border-red-200 dark:border-red-800":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 border-gray-300 dark:border-gray-600"}`,children:F}),r.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:pe(F)})]}),t&&r.jsx("button",{onClick:W=>{W.stopPropagation(),b(!N)},className:"text-xs text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",title:N?"Switch to horizontal scroll":"Switch to text wrap",children:N?"↔️ Scroll":"↩️ Wrap"})]}),r.jsx("div",{className:"max-h-96 overflow-y-auto",children:dt&&r.jsx(jc,{diff:dt,fileName:C,isMobile:t,wrapText:N})})]})]},C)};return e?r.jsxs("div",{className:"h-full flex flex-col bg-background",children:[r.jsxs("div",{className:`flex items-center justify-between border-b border-gray-200 dark:border-gray-700 ${t?"px-3 py-2":"px-4 py-3"}`,children:[r.jsxs("div",{className:"relative",ref:J,children:[r.jsxs("button",{onClick:()=>Y(!P),className:`flex items-center hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors ${t?"space-x-1 px-2 py-1":"space-x-2 px-3 py-1.5"}`,children:[r.jsx(ta,{className:`text-gray-600 dark:text-gray-400 ${t?"w-3 h-3":"w-4 h-4"}`}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:`font-medium ${t?"text-xs":"text-sm"}`,children:A}),R?.hasRemote&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[R.ahead>0&&r.jsxs("span",{className:"text-green-600 dark:text-green-400",title:`${R.ahead} commit${R.ahead!==1?"s":""} ahead`,children:["↑",R.ahead]}),R.behind>0&&r.jsxs("span",{className:"text-primary",title:`${R.behind} commit${R.behind!==1?"s":""} behind`,children:["↓",R.behind]}),R.isUpToDate&&r.jsx("span",{className:"text-gray-500 dark:text-gray-400",title:"Up to date with remote",children:"✓"})]})]}),r.jsx(Tr,{className:`w-3 h-3 text-gray-500 transition-transform ${P?"rotate-180":""}`})]}),P&&r.jsxs("div",{className:"absolute top-full left-0 mt-1 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-50",children:[r.jsx("div",{className:"py-1 max-h-64 overflow-y-auto",children:w.map(C=>r.jsx("button",{onClick:()=>Je(C),className:`w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 ${C===A?"bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`,children:r.jsxs("div",{className:"flex items-center space-x-2",children:[C===A&&r.jsx(yr,{className:"w-3 h-3 text-green-600 dark:text-green-400"}),r.jsx("span",{className:C===A?"font-medium":"",children:C})]})},C))}),r.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 py-1",children:r.jsxs("button",{onClick:()=>{le(!0),Y(!1)},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center space-x-2",children:[r.jsx(Nn,{className:"w-3 h-3"}),r.jsx("span",{children:"Create new branch"})]})})]})]}),r.jsxs("div",{className:`flex items-center ${t?"gap-1":"gap-2"}`,children:[R?.hasRemote&&r.jsxs(r.Fragment,{children:[!R?.hasUpstream&&r.jsxs("button",{onClick:()=>Ke({type:"publish",message:`Publish branch "${A}" to ${R.remoteName}?`}),disabled:Ve,className:"px-2 py-1 text-xs bg-purple-600 text-white rounded hover:bg-purple-700 disabled:opacity-50 flex items-center gap-1",title:`Publish branch "${A}" to ${R.remoteName}`,children:[r.jsx(ws,{className:`w-3 h-3 ${Ve?"animate-pulse":""}`}),r.jsx("span",{children:Ve?"Publishing...":"Publish"})]}),R?.hasUpstream&&!R?.isUpToDate&&r.jsxs(r.Fragment,{children:[R.behind>0&&r.jsxs("button",{onClick:()=>Ke({type:"pull",message:`Pull ${R.behind} commit${R.behind!==1?"s":""} from ${R.remoteName}?`}),disabled:ce,className:"px-2 py-1 text-xs bg-green-600 text-white rounded hover:bg-green-700 disabled:opacity-50 flex items-center gap-1",title:`Pull ${R.behind} commit${R.behind!==1?"s":""} from ${R.remoteName}`,children:[r.jsx(ka,{className:`w-3 h-3 ${ce?"animate-pulse":""}`}),r.jsx("span",{children:ce?"Pulling...":`Pull ${R.behind}`})]}),R.ahead>0&&r.jsxs("button",{onClick:()=>Ke({type:"push",message:`Push ${R.ahead} commit${R.ahead!==1?"s":""} to ${R.remoteName}?`}),disabled:ft,className:"px-2 py-1 text-xs bg-orange-600 text-white rounded hover:bg-orange-700 disabled:opacity-50 flex items-center gap-1",title:`Push ${R.ahead} commit${R.ahead!==1?"s":""} to ${R.remoteName}`,children:[r.jsx(ws,{className:`w-3 h-3 ${ft?"animate-pulse":""}`}),r.jsx("span",{children:ft?"Pushing...":`Push ${R.ahead}`})]}),(R.ahead>0||R.behind>0&&R.ahead>0)&&r.jsxs("button",{onClick:ue,disabled:Fe,className:"px-2 py-1 text-xs bg-primary text-white rounded hover:bg-primary/80 disabled:opacity-50 flex items-center gap-1",title:`Fetch from ${R.remoteName}`,children:[r.jsx(Ar,{className:`w-3 h-3 ${Fe?"animate-spin":""}`}),r.jsx("span",{children:Fe?"Fetching...":"Fetch"})]})]})]}),r.jsx("button",{onClick:()=>{_e(),et(),tt()},disabled:c,className:`hover:bg-gray-100 dark:hover:bg-gray-800 rounded ${t?"p-1":"p-1.5"}`,children:r.jsx(Ar,{className:`${c?"animate-spin":""} ${t?"w-3 h-3":"w-4 h-4"}`})})]})]}),s?.error?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-gray-500 dark:text-gray-400 px-6 py-12",children:[r.jsx(ta,{className:"w-20 h-20 mb-6 opacity-30"}),r.jsx("h3",{className:"text-xl font-medium mb-3 text-center",children:s.error}),s.details&&r.jsx("p",{className:"text-sm text-center leading-relaxed mb-6 max-w-md",children:s.details}),r.jsx("div",{className:"p-4 bg-primary/10 dark:bg-primary/20 rounded-lg border border-primary/30 dark:border-primary/60 max-w-md",children:r.jsxs("p",{className:"text-sm text-primary text-center",children:[r.jsx("strong",{children:"Tip:"})," Run ",r.jsx("code",{className:"bg-primary/15 dark:bg-primary/30 px-2 py-1 rounded font-mono text-xs",children:"git init"})," in your project directory to initialize git source control."]})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:`flex border-b border-gray-200 dark:border-gray-700 transition-all duration-300 ease-in-out ${m.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[r.jsx("button",{onClick:()=>Se("changes"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${qe==="changes"?"text-primary border-b-2 border-primary dark:border-primary":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r.jsx(ni,{className:"w-4 h-4"}),r.jsx("span",{children:"Changes"})]})}),r.jsx("button",{onClick:()=>Se("history"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${qe==="history"?"text-primary border-b-2 border-primary dark:border-primary":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r.jsx(pl,{className:"w-4 h-4"}),r.jsx("span",{children:"History"})]})})]}),qe==="changes"&&r.jsx(r.Fragment,{children:r.jsx("div",{className:`transition-all duration-300 ease-in-out ${m.size===0?"max-h-96 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:t&&yt?r.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700",children:r.jsxs("button",{onClick:()=>Tt(!1),className:"w-full flex items-center justify-center gap-2 px-3 py-2 text-sm bg-primary text-white rounded-md hover:bg-primary/80",children:[r.jsx(ra,{className:"w-4 h-4"}),r.jsxs("span",{children:["Commit ",g.size," file",g.size!==1?"s":""]}),r.jsx(Tr,{className:"w-3 h-3"})]})}):r.jsx(r.Fragment,{children:r.jsxs("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:[t&&r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-sm font-medium",children:"Commit Changes"}),r.jsx("button",{onClick:()=>Tt(!0),className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-800 rounded",children:r.jsx(Tr,{className:"w-4 h-4 rotate-180"})})]}),r.jsxs("div",{className:"relative",children:[r.jsx("textarea",{ref:St,value:u,onChange:C=>p(C.target.value),placeholder:"Message (Ctrl+Enter to commit)",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 resize-none pr-20",rows:"3",onKeyDown:C=>{C.key==="Enter"&&(C.ctrlKey||C.metaKey)&&zt()}}),r.jsxs("div",{className:"absolute right-2 top-2 flex gap-1",children:[r.jsx("button",{onClick:Lt,disabled:g.size===0||ke,className:"p-1.5 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",title:"Generate commit message",children:ke?r.jsx(Ar,{className:"w-4 h-4 animate-spin"}):r.jsx(ri,{className:"w-4 h-4"})}),r.jsx("div",{style:{display:"none"},children:r.jsx(Lb,{onTranscript:C=>p(C),mode:"default",className:"p-1.5"})})]})]}),r.jsxs("div",{className:"flex items-center justify-between mt-2",children:[r.jsxs("span",{className:"text-xs text-gray-500",children:[g.size," file",g.size!==1?"s":""," selected"]}),r.jsxs("button",{onClick:()=>Ke({type:"commit",message:`Commit ${g.size} file${g.size!==1?"s":""} with message: "${u.trim()}"?`}),disabled:!u.trim()||g.size===0||j,className:"px-3 py-1 text-sm bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",children:[r.jsx(yr,{className:"w-3 h-3"}),r.jsx("span",{children:j?"Committing...":"Commit"})]})]})]})})})}),qe==="changes"&&s&&!s.error&&r.jsxs("div",{className:`border-b border-gray-200 dark:border-gray-700 flex items-center justify-between transition-all duration-300 ease-in-out ${t?"px-3 py-1.5":"px-4 py-2"} ${m.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[r.jsxs("span",{className:"text-gray-600 dark:text-gray-400 text-xs",children:[g.size," of ",(s?.modified?.length||0)+(s?.added?.length||0)+(s?.deleted?.length||0)+(s?.untracked?.length||0)," ",t?"":"files"," selected"]}),r.jsxs("div",{className:`flex ${t?"gap-1":"gap-2"}`,children:[r.jsx("button",{onClick:()=>{const C=new Set([...s?.modified||[],...s?.added||[],...s?.deleted||[],...s?.untracked||[]]);x(C)},className:"text-primary hover:text-primary text-xs",children:t?"All":"Select All"}),r.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),r.jsx("button",{onClick:()=>x(new Set),className:"text-primary hover:text-primary text-xs",children:t?"None":"Deselect All"})]})]}),!s?.error&&!t&&r.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("button",{onClick:()=>q(!L),className:"w-full px-4 py-2 bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-750 text-xs text-gray-600 dark:text-gray-400 flex items-center justify-center gap-1",children:[r.jsx(Af,{className:"w-3 h-3"}),r.jsx("span",{children:"File Status Guide"}),L?r.jsx(Tr,{className:"w-3 h-3"}):r.jsx(wn,{className:"w-3 h-3"})]}),L&&r.jsx("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-800 text-xs",children:r.jsxs("div",{className:`${t?"grid grid-cols-2 gap-3 justify-items-center":"flex justify-center gap-6"}`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 rounded border border-yellow-200 dark:border-yellow-800 font-bold text-xs",children:"M"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Modified"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 rounded border border-green-200 dark:border-green-800 font-bold text-xs",children:"A"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Added"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 rounded border border-red-200 dark:border-red-800 font-bold text-xs",children:"D"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Deleted"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 rounded border border-gray-300 dark:border-gray-600 font-bold text-xs",children:"U"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Untracked"})]})]})})]})]}),qe==="changes"&&!s?.error&&r.jsx("div",{className:`flex-1 overflow-y-auto ${t?"pb-mobile-nav":""}`,children:c?r.jsx("div",{className:"flex items-center justify-center h-32",children:r.jsx(Ar,{className:"w-6 h-6 animate-spin text-gray-400"})}):s?.hasCommits===!1?r.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[r.jsx(ta,{className:"w-16 h-16 mb-4 opacity-30 text-gray-400 dark:text-gray-500"}),r.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-900 dark:text-white",children:"No commits yet"}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-md",children:"This repository doesn't have any commits yet. Create your first commit to start tracking changes."}),r.jsx("button",{onClick:_,disabled:_t,className:"px-4 py-2 bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:_t?r.jsxs(r.Fragment,{children:[r.jsx(Ar,{className:"w-4 h-4 animate-spin"}),r.jsx("span",{children:"Creating Initial Commit..."})]}):r.jsxs(r.Fragment,{children:[r.jsx(ra,{className:"w-4 h-4"}),r.jsx("span",{children:"Create Initial Commit"})]})})]}):!s||!s.modified?.length&&!s.added?.length&&!s.deleted?.length&&!s.untracked?.length?r.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:[r.jsx(ra,{className:"w-12 h-12 mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:"No changes detected"})]}):r.jsxs("div",{className:t?"pb-4":"",children:[s.modified?.map(C=>X(C,"M")),s.added?.map(C=>X(C,"A")),s.deleted?.map(C=>X(C,"D")),s.untracked?.map(C=>X(C,"U"))]})}),qe==="history"&&!s?.error&&r.jsx("div",{className:`flex-1 overflow-y-auto ${t?"pb-mobile-nav":""}`,children:c?r.jsx("div",{className:"flex items-center justify-center h-32",children:r.jsx(Ar,{className:"w-6 h-6 animate-spin text-gray-400"})}):U.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:[r.jsx(pl,{className:"w-12 h-12 mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:"No commits found"})]}):r.jsx("div",{className:t?"pb-4":"",children:U.map(C=>Ae(C))})}),ge&&r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[r.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>le(!1)}),r.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full",children:r.jsxs("div",{className:"p-6",children:[r.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Create New Branch"}),r.jsxs("div",{className:"mb-4",children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Branch Name"}),r.jsx("input",{type:"text",value:M,onChange:C=>V(C.target.value),onKeyDown:C=>{C.key==="Enter"&&!xe&&Mt()},placeholder:"feature/new-feature",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-ring",autoFocus:!0})]}),r.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-4",children:["This will create a new branch from the current branch (",A,")"]}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{onClick:()=>{le(!1),V("")},className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md",children:"Cancel"}),r.jsx("button",{onClick:Mt,disabled:!M.trim()||xe,className:"px-4 py-2 text-sm bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2",children:xe?r.jsxs(r.Fragment,{children:[r.jsx(Ar,{className:"w-3 h-3 animate-spin"}),r.jsx("span",{children:"Creating..."})]}):r.jsxs(r.Fragment,{children:[r.jsx(Nn,{className:"w-3 h-3"}),r.jsx("span",{children:"Create Branch"})]})})]})]})})]}),he&&r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[r.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>Ke(null)}),r.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full",children:r.jsxs("div",{className:"p-6",children:[r.jsxs("div",{className:"flex items-center mb-4",children:[r.jsx("div",{className:`p-2 rounded-full mr-3 ${he.type==="discard"||he.type==="delete"?"bg-red-100 dark:bg-red-900":"bg-yellow-100 dark:bg-yellow-900"}`,children:r.jsx(Ea,{className:`w-5 h-5 ${he.type==="discard"||he.type==="delete"?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400"}`})}),r.jsx("h3",{className:"text-lg font-semibold",children:he.type==="discard"?"Discard Changes":he.type==="delete"?"Delete File":he.type==="commit"?"Confirm Commit":he.type==="pull"?"Confirm Pull":he.type==="publish"?"Publish Branch":"Confirm Push"})]}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:he.message}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{onClick:()=>Ke(null),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md",children:"Cancel"}),r.jsx("button",{onClick:Pt,className:`px-4 py-2 text-sm text-white rounded-md ${he.type==="discard"||he.type==="delete"?"bg-red-600 hover:bg-red-700":he.type==="commit"?"bg-primary hover:bg-primary/90":he.type==="pull"?"bg-green-600 hover:bg-green-700":he.type==="publish"?"bg-purple-600 hover:bg-purple-700":"bg-orange-600 hover:bg-orange-700"} flex items-center space-x-2`,children:he.type==="discard"?r.jsxs(r.Fragment,{children:[r.jsx(pr,{className:"w-4 h-4"}),r.jsx("span",{children:"Discard"})]}):he.type==="delete"?r.jsxs(r.Fragment,{children:[r.jsx(pr,{className:"w-4 h-4"}),r.jsx("span",{children:"Delete"})]}):he.type==="commit"?r.jsxs(r.Fragment,{children:[r.jsx(yr,{className:"w-4 h-4"}),r.jsx("span",{children:"Commit"})]}):he.type==="pull"?r.jsxs(r.Fragment,{children:[r.jsx(ka,{className:"w-4 h-4"}),r.jsx("span",{children:"Pull"})]}):he.type==="publish"?r.jsxs(r.Fragment,{children:[r.jsx(ws,{className:"w-4 h-4"}),r.jsx("span",{children:"Publish"})]}):r.jsxs(r.Fragment,{children:[r.jsx(ws,{className:"w-4 h-4"}),r.jsx("span",{children:"Push"})]})})]})]})})]})]}):r.jsx("div",{className:"h-full flex items-center justify-center text-gray-500 dark:text-gray-400",children:r.jsx("p",{children:"Select a project to view source control"})})}class Fb extends Mn.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0}}componentDidCatch(t,n){console.error("ErrorBoundary caught an error:",t,n),this.setState({error:t,errorInfo:n})}render(){return this.state.hasError?r.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:r.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[r.jsxs("div",{className:"flex items-center mb-4",children:[r.jsx("div",{className:"flex-shrink-0",children:r.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:r.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),r.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"Something went wrong"})]}),r.jsxs("div",{className:"text-sm text-red-700",children:[r.jsx("p",{className:"mb-2",children:"An error occurred while loading the chat interface."}),this.props.showDetails&&this.state.error&&r.jsxs("details",{className:"mt-4",children:[r.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"Error Details"}),r.jsxs("pre",{className:"mt-2 text-xs bg-red-100 p-2 rounded overflow-auto max-h-40",children:[this.state.error.toString(),this.state.errorInfo&&this.state.errorInfo.componentStack]})]})]}),r.jsx("div",{className:"mt-4",children:r.jsx("button",{onClick:()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onRetry&&this.props.onRetry()},className:"bg-red-600 text-white px-4 py-2 rounded text-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500",children:"Try Again"})})]})}):this.props.children}}const $b=Ux,tp=l.forwardRef(({className:e,...t},n)=>r.jsx(eu,{ref:n,className:ct("inline-flex h-10 items-center justify-center rounded-xl bg-muted/60 p-1 text-muted-foreground",e),...t}));tp.displayName=eu.displayName;const rp=l.forwardRef(({className:e,...t},n)=>r.jsx(tu,{ref:n,className:ct("inline-flex items-center justify-center whitespace-nowrap rounded-lg px-3 py-2 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));rp.displayName=tu.displayName;const Bb=l.forwardRef(({className:e,...t},n)=>r.jsx(ru,{ref:n,className:ct("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20",e),...t}));Bb.displayName=ru.displayName;function zb({selectedProject:e,selectedSession:t,activeTab:n,setActiveTab:s,ws:o,sendMessage:a,latestMessage:i,isMobile:c,isPWA:d,onMenuClick:u,isLoading:p,onInputFocusChange:m,onSessionActive:h,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:j,processingSessions:k,onReplaceTemporarySession:A,onNavigateToSession:T,onShowSettings:w,autoExpandTools:D,showRawParameters:N,showThinking:b,autoScrollToBottom:L,sendByCtrlEnter:q,externalMessageUpdate:P,urlProvider:Y,urlModel:ge,urlContext:le,urlPrompt:M,integrationClientId:V,latestIntegrationMessage:xe,sendIntegrationMessage:Ie,onShowNewProject:qe,onNewSession:Se,newSessionResetNonce:U}){const{t:fe}=$t(),[O,S]=l.useState(null),[B,Z]=l.useState(600),[ke,ve]=l.useState(!1),[R,re]=l.useState(!1),Fe=l.useRef(null),Ce=(he,Ke=null)=>{const _t={name:he.split("/").pop(),path:he,projectName:e?.name,diffInfo:Ke};S(_t)},ce=()=>{S(null),re(!1)},$e=()=>{re(!R)},ft=he=>{c||(ve(!0),he.preventDefault())};if(l.useEffect(()=>{n==="files"&&s("chat")},[n,s]),l.useEffect(()=>{const he=_t=>{if(!ke)return;const kt=Fe.current?.parentElement;if(!kt)return;const St=kt.getBoundingClientRect(),J=St.right-_t.clientX,ee=300,je=St.width*.8;J>=ee&&J<=je&&Z(J)},Ke=()=>{ve(!1)};return ke&&(document.addEventListener("mousemove",he),document.addEventListener("mouseup",Ke),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",Ke),document.body.style.cursor="",document.body.style.userSelect=""}},[ke]),p)return r.jsxs("div",{className:"h-full flex flex-col",children:[c&&r.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:r.jsx("button",{onClick:u,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:r.jsx("div",{className:"w-full h-full rounded-full border-4 border-gray-200 border-t-primary",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),r.jsx("h2",{className:"text-xl font-semibold",children:fe("mainContent.loading")})]})})]});if(!e)return r.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[c&&r.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:r.jsx("button",{onClick:u,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),r.jsx("div",{className:"flex flex-1 items-center justify-center px-4 py-8 sm:px-6",children:r.jsxs("div",{className:"w-full max-w-xl px-8 py-10 text-center text-muted-foreground",children:[r.jsx("div",{className:"mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})})}),r.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:fe("mainContent.chooseProject")}),r.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:fe("mainContent.selectProjectDescription")}),r.jsx("div",{className:"mx-auto flex w-fit items-center",children:r.jsxs("button",{onClick:qe,className:"inline-flex items-center gap-2 rounded-xl bg-foreground px-4 py-2 text-sm font-medium text-background transition hover:opacity-90",title:fe("tooltips.createProject")||"New Chat",children:[r.jsx(rn,{className:"w-5 h-5"}),r.jsx("span",{children:fe("tooltips.createProject")||"New Chat"})]})})]})})]});const at=t?.__provider||t?.provider||"claude",Ve=at==="openai"?"codex":at,Ze=Ve==="codex"&&typeof t?.id=="string"?t.id.trim():"",yt=Ze?`codex://threads/${encodeURIComponent(Ze)}`:"",Tt=()=>{yt&&(window.location.href=yt)};return r.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[r.jsx("div",{className:"chat-header flex-shrink-0 px-3 py-3 sm:px-4 sm:py-3 pwa-header-safe",children:r.jsxs("div",{className:"relative flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center space-x-2",children:[c&&r.jsx("button",{onClick:u,onTouchStart:he=>{he.preventDefault(),u()},className:"pwa-menu-button flex-shrink-0 rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground touch-manipulation active:scale-95",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),r.jsxs("div",{className:"flex flex-1 items-center gap-3 overflow-x-auto scrollbar-hide min-w-0",children:[n==="chat"&&t&&r.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl bg-muted/60",children:Ve==="codex"?r.jsx(co,{className:"w-4 h-4"}):Ve==="gemini"?r.jsx(uo,{className:"w-4 h-4"}):Ve==="opencode"?r.jsx(po,{className:"h-4 w-auto max-w-full"}):r.jsx(rs,{className:"w-4 h-4"})}),r.jsx("div",{className:"min-w-0 flex-1",children:n==="chat"&&t?r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"overflow-x-auto whitespace-nowrap scrollbar-hide text-sm font-semibold text-gray-900 dark:text-white sm:text-base",children:Ve==="codex"?t.summary||t.name||"Codex Session":Ve==="gemini"?t.summary||t.name||"Gemini Session":Ve==="opencode"?t.summary||t.name||"OpenCode Session":t.summary||"New Session"}),r.jsx("div",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:e.displayName})]}):n==="chat"&&!t?r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:fe("mainContent.newSession")}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:n==="git"?fe("tabs.git"):"Project"}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]})})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[n==="chat"&&Ve==="codex"&&yt&&r.jsx("button",{onClick:Tt,className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:fe("mainContent.openInCodexClient"),"aria-label":fe("mainContent.openInCodexClient"),children:r.jsx(ja,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>Se&&Se(e),className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:fe("tooltips.newChat","New Chat"),children:r.jsx(Pf,{className:"w-5 h-5"})}),r.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:r.jsx($b,{value:n,onValueChange:s,children:r.jsx(tp,{children:r.jsx(zn,{content:fe("tabs.chat"),position:"bottom",children:r.jsx(rp,{value:"chat",children:r.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[r.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),r.jsx("span",{className:"hidden lg:inline",children:fe("tabs.chat")})]})})})})})})]})]})}),r.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[r.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${O?"mr-0":""} ${R?"hidden":""}`,children:[r.jsx("div",{className:`h-full ${n==="chat"?"block":"hidden"}`,children:r.jsx(Fb,{showDetails:!0,children:r.jsx($y,{selectedProject:e,selectedSession:t,ws:o,sendMessage:a,latestMessage:i,onFileOpen:Ce,onInputFocusChange:m,onSessionActive:h,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:j,processingSessions:k,onReplaceTemporarySession:A,onNavigateToSession:T,onShowSettings:w,autoExpandTools:D,showRawParameters:N,showThinking:b,autoScrollToBottom:L,sendByCtrlEnter:q,externalMessageUpdate:P,urlProvider:Y,urlModel:ge,urlContext:le,urlPrompt:M,integrationClientId:V,latestIntegrationMessage:xe,sendIntegrationMessage:Ie,newSessionResetNonce:U},`${e?.name||"no-project"}:${t?.id||`new-${U}`}`)})}),n==="shell"&&r.jsx("div",{className:"h-full w-full overflow-hidden",children:r.jsx(ep,{project:e,session:t,showHeader:!1})}),n==="git"&&r.jsx("div",{className:"chat-surface h-full overflow-hidden",children:r.jsx(Ob,{selectedProject:e,isMobile:c,onFileOpen:Ce})}),r.jsx("div",{className:`h-full overflow-hidden ${n==="preview"?"block":"hidden"}`})]}),O&&!c&&r.jsxs(r.Fragment,{children:[!R&&r.jsx("div",{ref:Fe,onMouseDown:ft,className:"group relative w-1 flex-shrink-0 cursor-col-resize bg-border/70 transition-colors hover:bg-primary",title:"Drag to resize",children:r.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-primary dark:bg-primary opacity-0 group-hover:opacity-100 transition-opacity"})}),r.jsx("div",{className:`chat-surface h-full flex-shrink-0 overflow-hidden bg-muted/20 ${R?"flex-1":""}`,style:R?{}:{width:`${B}px`},children:r.jsx(wc,{file:O,onClose:ce,projectPath:e?.path,isSidebar:!0,isExpanded:R,onToggleExpand:$e})})]})]}),O&&c&&r.jsx(wc,{file:O,onClose:ce,projectPath:e?.path,isSidebar:!1})]})}const Ub=Mn.memo(zb),np="0.2.3",sp=()=>{const[e,t]=l.useState(!1),[n,s]=l.useState(null),[o,a]=l.useState(null);return l.useEffect(()=>{(async()=>{try{const c=await oe("/api/system/version");if(!c.ok)throw new Error(`Version API failed: ${c.status}`);const d=await c.json();if(!d?.success)throw new Error(d?.error||"Version API returned unsuccessful result");if(d.latestVersion){const u=String(d.latestVersion).replace(/^v/,"");s(u),t(!!d.updateAvailable),a({title:d.releaseInfo?.title||`v${u}`,body:d.releaseInfo?.body||"",htmlUrl:d.releaseInfo?.htmlUrl||`https://www.npmjs.com/package/${d.packageName||"@axhub/genie"}`,publishedAt:d.releaseInfo?.publishedAt||null})}else t(!1),s(null),a(null)}catch(c){console.error("Version check failed:",c.message||c),t(!1),s(null),a(null)}})()},[]),{updateAvailable:e,latestVersion:n,currentVersion:np,releaseInfo:o}};function Wb(){const{t:e}=$t("settings"),[t,n]=l.useState([]),[s,o]=l.useState(!0),[a,i]=l.useState(!1),[c,d]=l.useState(""),[u,p]=l.useState(null),[m,h]=l.useState(null),{updateAvailable:g,latestVersion:x,releaseInfo:j}=sp();l.useEffect(()=>{k()},[]);const k=async()=>{try{o(!0);const b=await(await oe("/api/settings/api-keys")).json();n(b.apiKeys||[])}catch(N){console.error("Error fetching settings:",N)}finally{o(!1)}},A=async()=>{if(c.trim())try{const b=await(await oe("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:c})})).json();b.success&&(h(b.apiKey),d(""),i(!1),k())}catch(N){console.error("Error creating API key:",N)}},T=async N=>{if(confirm(e("apiKeys.confirmDelete")))try{await oe(`/api/settings/api-keys/${N}`,{method:"DELETE"}),k()}catch(b){console.error("Error deleting API key:",b)}},w=async(N,b)=>{try{await oe(`/api/settings/api-keys/${N}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!b})}),k()}catch(L){console.error("Error toggling API key:",L)}},D=(N,b)=>{navigator.clipboard.writeText(N),p(b),setTimeout(()=>p(null),2e3)};return s?r.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):r.jsxs("div",{className:"space-y-8",children:[m&&r.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[r.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:e("apiKeys.newKey.alertTitle")}),r.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e("apiKeys.newKey.alertMessage")}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:m.apiKey}),r.jsx(De,{size:"sm",variant:"outline",onClick:()=>D(m.apiKey,"new"),children:u==="new"?r.jsx(yr,{className:"h-4 w-4"}):r.jsx(Gm,{className:"h-4 w-4"})})]}),r.jsx(De,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>h(null),children:e("apiKeys.newKey.iveSavedIt")})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Fc,{className:"h-5 w-5"}),r.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),r.jsxs(De,{size:"sm",onClick:()=>i(!a),children:[r.jsx(Nn,{className:"h-4 w-4 mr-1"}),e("apiKeys.newButton")]})]}),r.jsxs("div",{className:"mb-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e("apiKeys.description")}),r.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[e("apiKeys.apiDocsLink"),r.jsx(ja,{className:"h-3 w-3"})]})]}),a&&r.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[r.jsx(Ft,{placeholder:e("apiKeys.form.placeholder"),value:c,onChange:N=>d(N.target.value),className:"mb-2"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(De,{onClick:A,children:e("apiKeys.form.createButton")}),r.jsx(De,{variant:"outline",onClick:()=>i(!1),children:e("apiKeys.form.cancelButton")})]})]}),r.jsx("div",{className:"space-y-2",children:t.length===0?r.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.empty")}):t.map(N=>r.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"font-medium",children:N.key_name}),r.jsx("code",{className:"text-xs text-muted-foreground",children:N.api_key}),r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.list.created")," ",new Date(N.created_at).toLocaleDateString(),N.last_used&&` • ${e("apiKeys.list.lastUsed")} ${new Date(N.last_used).toLocaleDateString()}`]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(De,{size:"sm",variant:N.is_active?"outline":"secondary",onClick:()=>w(N.id,N.is_active),children:N.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),r.jsx(De,{size:"sm",variant:"ghost",onClick:()=>T(N.id),children:r.jsx(pr,{className:"h-4 w-4"})})]})]},N.id))})]}),r.jsx("div",{className:"pt-6 border-t border-border/50",children:r.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[r.jsxs("a",{href:j?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",np]}),g&&x&&r.jsxs("a",{href:j?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[r.jsx("span",{className:"text-[10px]",children:e("apiKeys.version.updateAvailable",{version:x})}),r.jsx(ja,{className:"h-2.5 w-2.5"})]})]})})]})}const Hb=["claude","cursor","codex","gemini","opencode"],Sc=["lark","dingtalk"],Nc={lark:{appId:"",appSecret:"",hasAppSecret:!1,encryptKey:"",verificationToken:"",hasEncryptKey:!1,hasVerificationToken:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""},dingtalk:{clientId:"",clientSecret:"",hasClientSecret:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""}},ya={running:!1,status:"stopped",error:null};function qb({projects:e=[]}){const{t}=$t("settings"),[n,s]=l.useState("lark"),[o,a]=l.useState(Nc),[i,c]=l.useState({lark:{...ya},dingtalk:{...ya}}),[d,u]=l.useState({lark:[],dingtalk:[]}),[p,m]=l.useState(!1),[h,g]=l.useState(!1),[x,j]=l.useState(!1),[k,A]=l.useState(!1),[T,w]=l.useState(null),[D,N]=l.useState(null),[b,L]=l.useState({userId:"",displayName:"",note:""}),q=l.useMemo(()=>e.map(S=>({label:S.displayName||S.name||S.path||S.fullPath,value:S.path||S.fullPath||""})).filter(S=>S.value),[e]),P=o[n]||Nc[n],Y=i[n]||ya,ge=d[n]||[],le=async(S,B=!1)=>{B||N(null);const[Z,ke,ve]=await Promise.all([oe(`/api/channels/${S}/config`),oe(`/api/channels/${S}/status`),oe(`/api/channels/${S}/allowed-users`)]),R=await Z.json(),re=await ke.json(),Fe=await ve.json();R?.success&&R?.config&&a(Ce=>({...Ce,[S]:{...Ce[S],...R.config}})),re?.success&&re?.status&&c(Ce=>({...Ce,[S]:re.status})),Fe?.success&&u(Ce=>({...Ce,[S]:Fe.users||[]}))},M=async(S=!1)=>{m(!0);try{await Promise.all(Sc.map(B=>le(B,S)))}catch(B){N(B.message||t("channels.errors.loadFailed","加载渠道设置失败"))}finally{m(!1)}};l.useEffect(()=>{M()},[]);const V=S=>{a(B=>({...B,[n]:{...B[n],...S}}))},xe=async()=>{m(!0),w(null),N(null);try{const S=n==="dingtalk"?{clientId:P.clientId,clientSecret:P.clientSecret,defaultBackend:P.defaultBackend,defaultModel:P.defaultModel,defaultProjectPath:P.defaultProjectPath}:{appId:P.appId,appSecret:P.appSecret,encryptKey:P.encryptKey,verificationToken:P.verificationToken,defaultBackend:P.defaultBackend,defaultModel:P.defaultModel,defaultProjectPath:P.defaultProjectPath},B=await oe(`/api/channels/${n}/config`,{method:"PUT",body:JSON.stringify(S)}),Z=await B.json();if(!B.ok||!Z.success)throw new Error(Z.error||t("channels.errors.saveFailed","保存失败"));V(n==="dingtalk"?{...Z.config,clientSecret:""}:{...Z.config,appSecret:"",encryptKey:"",verificationToken:""}),w(t(`channels.messages.${n}.configSaved`,n==="dingtalk"?"DingTalk 配置已保存":"Lark 配置已保存")),await le(n,!0)}catch(S){N(S.message||t("channels.errors.saveFailed","保存失败"))}finally{m(!1)}},Ie=async()=>{if(n==="dingtalk"){const S=String(P.clientId||"").trim(),B=String(P.clientSecret||"").trim();if(!S||!B&&!P.hasClientSecret){N(t("channels.errors.testNeedCredentialsDingTalk","测试连接需要填写 Client ID 和 Client Secret"));return}}else{const S=String(P.appId||"").trim(),B=String(P.appSecret||"").trim();if(!S||!B&&!P.hasAppSecret){N(t("channels.errors.testNeedCredentials","测试连接需要填写 App ID 和 App Secret"));return}}g(!0),N(null),w(null);try{const S=await oe(`/api/channels/${n}/test`,{method:"POST",body:JSON.stringify(n==="dingtalk"?{clientId:P.clientId,clientSecret:P.clientSecret}:{appId:P.appId,appSecret:P.appSecret})}),B=await S.json();if(!S.ok||!B.success)throw new Error(B.error||t("channels.errors.testFailed","连接测试失败"));w(t(`channels.messages.${n}.testSuccess`,n==="dingtalk"?"DingTalk 连接测试成功":"Lark 连接测试成功"))}catch(S){N(S.message||t("channels.errors.testFailed","连接测试失败"))}finally{g(!1)}},qe=async()=>{j(!0),N(null),w(null);try{const S=await oe(`/api/channels/${n}/start`,{method:"POST"}),B=await S.json();if(!S.ok||!B.success)throw new Error(B.error||t("channels.errors.startFailed","启动失败"));c(Z=>({...Z,[n]:B.status||Z[n]})),w(t(`channels.messages.${n}.started`,n==="dingtalk"?"DingTalk 已启动":"Lark 已启动")),await le(n,!0)}catch(S){N(S.message||t("channels.errors.startFailed","启动失败"))}finally{j(!1)}},Se=async()=>{A(!0),N(null),w(null);try{const S=await oe(`/api/channels/${n}/stop`,{method:"POST"}),B=await S.json();if(!S.ok||!B.success)throw new Error(B.error||t("channels.errors.stopFailed","停止失败"));c(Z=>({...Z,[n]:B.status||Z[n]})),w(t(`channels.messages.${n}.stopped`,n==="dingtalk"?"DingTalk 已停止":"Lark 已停止")),await le(n,!0)}catch(S){N(S.message||t("channels.errors.stopFailed","停止失败"))}finally{A(!1)}},U=async()=>{if(!b.userId.trim()){N(t("channels.errors.userIdRequired","请输入用户ID"));return}m(!0),N(null),w(null);try{const B=await oe(`/api/channels/${n}/allowed-users`,{method:"POST",body:JSON.stringify(b)}),Z=await B.json();if(!B.ok||!Z.success)throw new Error(Z.error||t("channels.errors.addUserFailed","新增用户失败"));L({userId:"",displayName:"",note:""}),w(t("channels.messages.userAdded","用户已添加")),await le(n,!0)}catch(B){N(B.message||t("channels.errors.addUserFailed","新增用户失败"))}finally{m(!1)}},fe=async S=>{m(!0),N(null);try{const B=await oe(`/api/channels/${n}/allowed-users/${S.id}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!S.isActive})}),Z=await B.json();if(!B.ok||!Z.success)throw new Error(Z.error||t("channels.errors.toggleUserFailed","更新用户状态失败"));await le(n,!0)}catch(B){N(B.message||t("channels.errors.toggleUserFailed","更新用户状态失败"))}finally{m(!1)}},O=async S=>{if(window.confirm(t("channels.confirmDeleteUser","确定要删除这个用户ID吗?"))){m(!0),N(null);try{const B=await oe(`/api/channels/${n}/allowed-users/${S}`,{method:"DELETE"}),Z=await B.json();if(!B.ok||!Z.success)throw new Error(Z.error||t("channels.errors.deleteUserFailed","删除用户失败"));await le(n,!0)}catch(B){N(B.message||t("channels.errors.deleteUserFailed","删除用户失败"))}finally{m(!1)}}};return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground",children:t("channels.title","第三方 IM")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:t(`channels.platformDescriptions.${n}`,n==="dingtalk"?"配置 DingTalk 机器人连接、默认执行环境,并通过用户ID白名单控制访问。":"配置飞书机器人连接、默认执行环境,并通过用户ID白名单控制访问。")})]}),r.jsx("div",{className:"border-b border-border",children:r.jsx("div",{className:"flex items-end gap-1 -mb-px",role:"tablist","aria-label":t("channels.title","第三方 IM"),children:Sc.map(S=>{const B=S===n;return r.jsx("button",{type:"button",role:"tab","aria-selected":B,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors rounded-t-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 ${B?"border-primary text-primary bg-primary/5":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,onClick:()=>{s(S),w(null),N(null)},children:t(`channels.platforms.${S}`,S==="dingtalk"?"DingTalk / 钉钉":"Lark / 飞书")},S)})})}),(T||D)&&r.jsx("div",{className:`rounded-lg border p-3 text-sm ${D?"border-red-300 bg-red-50 text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300":"border-green-300 bg-green-50 text-green-700 dark:border-green-800 dark:bg-green-900/20 dark:text-green-300"}`,children:D||T}),r.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[r.jsx("h4",{className:"font-medium text-foreground",children:t("channels.connection.title","连接配置")}),n==="dingtalk"?r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"Client ID"}),r.jsx(Ft,{value:P.clientId,onChange:S=>V({clientId:S.target.value}),placeholder:"dingxxxxxxxx"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"Client Secret"}),r.jsx(Ft,{type:"password",value:P.clientSecret,onChange:S=>V({clientSecret:S.target.value}),placeholder:P.hasClientSecret?"••••••••(已保存)":"输入 Client Secret"})]})]}):r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"App ID"}),r.jsx(Ft,{value:P.appId,onChange:S=>V({appId:S.target.value}),placeholder:"cli_xxx"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"App Secret"}),r.jsx(Ft,{type:"password",value:P.appSecret,onChange:S=>V({appSecret:S.target.value}),placeholder:P.hasAppSecret?"••••••••(已保存)":"输入 App Secret"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:t("channels.defaults.backend","默认后端")}),r.jsx("select",{value:P.defaultBackend,onChange:S=>V({defaultBackend:S.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg",children:Hb.map(S=>r.jsx("option",{value:S,children:S},S))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:t("channels.defaults.project","默认项目")}),r.jsxs("select",{value:P.defaultProjectPath,onChange:S=>V({defaultProjectPath:S.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg",children:[r.jsx("option",{value:"",children:t("channels.defaults.projectPlaceholder","请选择项目")}),q.map(S=>r.jsx("option",{value:S.value,children:S.label},S.value))]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(De,{onClick:xe,disabled:p,children:t("channels.actions.saveConfig","保存配置")}),r.jsx(De,{variant:"outline",onClick:Ie,disabled:h,children:h?t("channels.actions.testing","测试中..."):t("channels.actions.test","测试连接")})]})]}),r.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[r.jsx("h4",{className:"font-medium text-foreground",children:t("channels.runtime.title","运行状态")}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[t("channels.runtime.currentStatus","当前状态"),": ",r.jsx("span",{className:"font-medium text-foreground",children:Y.status||"stopped"}),Y.error?r.jsx("span",{className:"text-red-500 ml-2",children:Y.error}):null]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(De,{onClick:qe,disabled:x||Y.running,children:x?t("channels.actions.starting","启动中..."):t("channels.actions.start","启动")}),r.jsx(De,{variant:"outline",onClick:Se,disabled:k||!Y.running,children:k?t("channels.actions.stopping","停止中..."):t("channels.actions.stop","停止")}),r.jsx(De,{variant:"ghost",onClick:()=>void le(n),disabled:p,children:t("channels.actions.refresh","刷新")})]})]}),r.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[r.jsx("h4",{className:"font-medium text-foreground",children:t("channels.allowedUsers.title","允许用户ID(白名单)")}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-2",children:[r.jsx(Ft,{placeholder:t("channels.allowedUsers.userId","用户ID"),value:b.userId,onChange:S=>L(B=>({...B,userId:S.target.value}))}),r.jsx(Ft,{placeholder:t("channels.allowedUsers.displayName","显示名(可选)"),value:b.displayName,onChange:S=>L(B=>({...B,displayName:S.target.value}))}),r.jsx(Ft,{placeholder:t("channels.allowedUsers.note","备注(可选)"),value:b.note,onChange:S=>L(B=>({...B,note:S.target.value}))}),r.jsx(De,{onClick:U,disabled:p,children:t("channels.allowedUsers.add","新增")})]}),r.jsx("div",{className:"space-y-2",children:ge.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:t("channels.allowedUsers.empty","暂无白名单用户")}):ge.map(S=>r.jsxs("div",{className:"border border-border rounded-lg p-3 flex flex-col md:flex-row md:items-center md:justify-between gap-2",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:S.userId}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[S.displayName||"-",S.note?` · ${S.note}`:""]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`text-xs px-2 py-1 rounded ${S.isActive?"bg-green-100 text-green-700 dark:bg-green-900/20 dark:text-green-300":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"}`,children:S.isActive?t("channels.allowedUsers.active","启用"):t("channels.allowedUsers.inactive","停用")}),r.jsx(De,{size:"sm",variant:"outline",onClick:()=>void fe(S),children:S.isActive?t("channels.allowedUsers.disable","停用"):t("channels.allowedUsers.enable","启用")}),r.jsx(De,{size:"sm",variant:"ghost",onClick:()=>void O(S.id),children:t("channels.allowedUsers.delete","删除")})]})]},S.id))})]}),r.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/10 dark:border-primary/40 dark:bg-primary/15 p-4",children:[r.jsx("h5",{className:"font-medium text-foreground mb-2",children:t("channels.help.title","使用说明")}),r.jsxs("ul",{className:"text-sm text-muted-foreground list-disc pl-5 space-y-1",children:[r.jsx("li",{children:t(`channels.help.${n}.step1`,n==="dingtalk"?"未绑定用户给机器人发消息时,机器人会返回该用户的钉钉用户ID。":"未绑定用户给机器人发消息时,机器人会返回该用户的飞书用户ID。")}),r.jsx("li",{children:t(`channels.help.${n}.step2`,"管理员将该ID加入白名单后,用户即可正常对话。")}),r.jsx("li",{children:t(`channels.help.${n}.step3`,"请先配置默认项目,否则机器人不会执行任务。")})]})]})]})}function Vb({isOpen:e,onClose:t,provider:n="claude",project:s,onComplete:o,customCommand:a,isAuthenticated:i=!1}){if(!e)return null;const c=()=>{if(a)return a;switch(n){case"claude":return i?"claude setup-token --dangerously-skip-permissions":"claude /exit --dangerously-skip-permissions";case"codex":return"codex login";case"gemini":return"npx -y @google/gemini-cli";case"opencode":return"npx -y opencode-ai@latest login";default:return i?"claude setup-token --dangerously-skip-permissions":"claude /exit --dangerously-skip-permissions"}},d=()=>{switch(n){case"claude":return"Claude CLI Login";case"codex":return"Codex CLI Login";case"gemini":return"Gemini CLI Login";case"opencode":return"OpenCode CLI Login";default:return"CLI Login"}},u=p=>{o?.(p),p===0&&t()};return r.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] max-md:items-stretch max-md:justify-stretch",children:r.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-3/4 flex flex-col md:max-w-4xl md:h-3/4 md:rounded-lg md:m-4 max-md:max-w-none max-md:h-full max-md:rounded-none max-md:m-0",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:d()}),r.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:r.jsx(ar,{className:"w-6 h-6"})})]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(ep,{project:s,command:c(),onComplete:u,minimal:!0})})]})})}function op({compact:e=!1}){const{i18n:t,t:n}=$t("settings"),s=o=>{const a=o.target.value;t.changeLanguage(a)};return e?r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx($c,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),n("account.language")]}),r.jsx("select",{value:t.language,onChange:s,className:"w-[100px] text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 focus:outline-none focus:ring-2",children:dl.map(o=>r.jsx("option",{value:o.value,children:o.nativeName},o.value))})]}):r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:n("account.languageLabel")}),r.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("account.languageDescription")})]}),r.jsx("select",{value:t.language,onChange:s,className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 w-36",children:dl.map(o=>r.jsx("option",{value:o.value,children:o.nativeName},o.value))})]})})}function Gb({isOpen:e,onClose:t,projects:n=[],initialTab:s="appearance"}){const{isDarkMode:o,toggleDarkMode:a}=ei(),{t:i}=$t("settings"),[c,d]=l.useState([]),[u,p]=l.useState([]),[m,h]=l.useState(""),[g,x]=l.useState(""),[j,k]=l.useState(!1),[A,T]=l.useState(!1),[w,D]=l.useState(null),[N,b]=l.useState("name"),[L,q]=l.useState([]),[P,Y]=l.useState(!1),[ge,le]=l.useState(null),[M,V]=l.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[xe,Ie]=l.useState(!1),[qe,Se]=l.useState({}),[U,fe]=l.useState({}),[O,S]=l.useState({}),[B,Z]=l.useState(s),[ke,ve]=l.useState(""),R=["appearance","api","channels"],[re,Fe]=l.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[Ce,ce]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[$e,ft]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[at,Ve]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Ze,yt]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[Tt,he]=l.useState([]),[Ke,_t]=l.useState("default"),[kt,St]=l.useState(!1),[J,ee]=l.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[je,_e]=l.useState(null),[et,tt]=l.useState(!1),[Je,Mt]=l.useState(!1),[ue,bt]=l.useState(""),[Ye,rt]=l.useState(null),[Ue,Nt]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Pt,ht]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Ct,tr]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),Xe=async()=>{try{const $=await oe("/api/codex/mcp/config/read");if($.ok){const ne=await $.json();if(ne.success&&ne.servers){he(ne.servers);return}}const z=await oe("/api/codex/mcp/cli/list");if(z.ok){const ne=await z.json();if(ne.success&&ne.servers){const Re=ne.servers.map(I=>({id:I.name,name:I.name,type:I.type||"stdio",scope:"user",config:{command:I.command||"",args:I.args||[],env:I.env||{}}}));he(Re)}}}catch($){console.error("Error fetching Codex MCP servers:",$)}},Lt=async()=>{try{const $=await oe("/api/mcp/config/read");if($.ok){const Re=await $.json();if(Re.success&&Re.servers){q(Re.servers);return}}const z=await oe("/api/mcp/cli/list");if(z.ok){const Re=await z.json();if(Re.success&&Re.servers){const I=Re.servers.map(Q=>({id:Q.name,name:Q.name,type:Q.type,scope:"user",config:{command:Q.command||"",args:Q.args||[],env:Q.env||{},url:Q.url||"",headers:Q.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));q(I);return}}const ne=await oe("/api/mcp/servers?scope=user");if(ne.ok){const Re=await ne.json();q(Re.servers||[])}else console.error("Failed to fetch MCP servers")}catch($){console.error("Error fetching MCP servers:",$)}},jt=async $=>{try{ge&&await Ot(ge.id,"user");const z=await oe("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:$.name,type:$.type,scope:$.scope,projectPath:$.projectPath,command:$.config?.command,args:$.config?.args||[],url:$.config?.url,headers:$.config?.headers||{},env:$.config?.env||{}})});if(z.ok){const ne=await z.json();if(ne.success)return await Lt(),!0;throw new Error(ne.error||"Failed to save server via Claude CLI")}else{const ne=await z.json();throw new Error(ne.error||"Failed to save server")}}catch(z){throw console.error("Error saving MCP server:",z),z}},Ot=async($,z="user")=>{try{const ne=await oe(`/api/mcp/cli/remove/${$}?scope=${z}`,{method:"DELETE"});if(ne.ok){const Re=await ne.json();if(Re.success)return await Lt(),!0;throw new Error(Re.error||"Failed to delete server via Claude CLI")}else{const Re=await ne.json();throw new Error(Re.error||"Failed to delete server")}}catch(ne){throw console.error("Error deleting MCP server:",ne),ne}},rr=async $=>{try{je&&await zt(je.id);const z=await oe("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:$.name,command:$.config?.command,args:$.config?.args||[],env:$.config?.env||{}})});if(z.ok){const ne=await z.json();if(ne.success)return await Xe(),!0;throw new Error(ne.error||"Failed to save Codex MCP server")}else{const ne=await z.json();throw new Error(ne.error||"Failed to save server")}}catch(z){throw console.error("Error saving Codex MCP server:",z),z}},zt=async $=>{try{const z=await oe(`/api/codex/mcp/cli/remove/${$}`,{method:"DELETE"});if(z.ok){const ne=await z.json();if(ne.success)return await Xe(),!0;throw new Error(ne.error||"Failed to delete Codex MCP server")}else{const ne=await z.json();throw new Error(ne.error||"Failed to delete server")}}catch(z){throw console.error("Error deleting Codex MCP server:",z),z}},_=()=>{ee({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),_e(null),St(!1)},pe=async $=>{$.preventDefault(),tt(!0);try{je&&await zt(je.name),await rr(J),_(),D("success")}catch(z){alert(`Error: ${z.message}`),D("error")}finally{tt(!1)}};l.useEffect(()=>{e&&(Ae(),X(),C(),F(),Z(R.includes(s)?s:"appearance"))},[e,s]),l.useEffect(()=>{localStorage.setItem("codeEditorTheme",re),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[re]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",Ce.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ce]),l.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",$e.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[$e]),l.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",at.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[at]),l.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Ze),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ze]);const Ae=async()=>{try{const $=localStorage.getItem("claude-settings");if($){const ne=JSON.parse($);d(ne.allowedTools||[]),p(ne.disallowedTools||[]),k(ne.skipPermissions||!1),b(ne.projectSortOrder||"name")}else d([]),p([]),k(!1),b("name");const z=localStorage.getItem("codex-settings");if(z){const ne=JSON.parse(z);_t(ne.permissionMode||"default")}else _t("default");await Lt(),await Xe()}catch($){console.error("Error loading tool settings:",$),d([]),p([]),k(!1),b("name")}},X=async()=>{try{const $=await oe("/api/cli/claude/status");if($.ok){const z=await $.json();Nt({authenticated:z.authenticated,email:z.email,loading:!1,error:z.error||null})}else Nt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch($){console.error("Error checking Claude auth status:",$),Nt({authenticated:!1,email:null,loading:!1,error:$.message})}},C=async()=>{try{const $=await oe("/api/cli/codex/status");if($.ok){const z=await $.json();ht({authenticated:z.authenticated,email:z.email,loading:!1,error:z.error||null})}else ht({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch($){console.error("Error checking Codex auth status:",$),ht({authenticated:!1,email:null,loading:!1,error:$.message})}},F=async()=>{try{const $=await oe("/api/cli/gemini/status");if($.ok){const z=await $.json();tr({authenticated:z.authenticated,email:z.email,loading:!1,error:z.error||null})}else tr({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch($){console.error("Error checking Gemini auth status:",$),tr({authenticated:!1,email:null,loading:!1,error:$.message})}},ie=$=>{$===0&&(D("success"),ue==="claude"?X():ue==="codex"?C():ue==="gemini"&&F())},be=()=>{T(!0),D(null);try{const $={allowedTools:c,disallowedTools:u,skipPermissions:j,projectSortOrder:N,lastUpdated:new Date().toISOString()},z={permissionMode:Ke,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify($)),localStorage.setItem("codex-settings",JSON.stringify(z)),D("success"),setTimeout(()=>{t()},1e3)}catch($){console.error("Error saving tool settings:",$),D("error")}finally{T(!1)}},dt=()=>{V({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),le(null),Y(!1),ve("")},W=async $=>{$.preventDefault(),Ie(!0);try{if(M.importMode==="json"){const z=await oe("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:M.name,jsonConfig:M.jsonInput,scope:M.scope,projectPath:M.projectPath})});if(z.ok){const ne=await z.json();if(ne.success)await Lt(),dt(),D("success");else throw new Error(ne.error||"Failed to add server via JSON")}else{const ne=await z.json();throw new Error(ne.error||"Failed to add server")}}else await jt(M),dt(),D("success")}catch(z){alert(`Error: ${z.message}`),D("error")}finally{Ie(!1)}},Et=($,z)=>{V(ne=>({...ne,config:{...ne.config,[$]:z}}))};return e?r.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[r.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(zc,{className:"w-5 h-5 md:w-6 md:h-6 text-primary"}),r.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:i("title")})]}),r.jsx(De,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:r.jsx(ar,{className:"w-5 h-5"})})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r.jsx("div",{className:"border-b border-border",children:r.jsxs("div",{className:"flex px-4 md:px-6",children:[r.jsx("button",{onClick:()=>Z("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${B==="appearance"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.appearance")}),r.jsxs("button",{onClick:()=>Z("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${B==="api"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[r.jsx(Fc,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.apiTokens")]}),r.jsxs("button",{onClick:()=>Z("channels"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${B==="channels"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[r.jsx(Jf,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.channels","Channels")]})]})}),r.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[B==="appearance"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:B==="appearance"&&r.jsxs("div",{className:"space-y-6 md:space-y-8",children:[r.jsx("div",{className:"space-y-4",children:r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.darkMode.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.darkMode.description")})]}),r.jsxs("button",{onClick:a,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":o,"aria-label":"Toggle dark mode",children:[r.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),r.jsx("span",{className:`${o?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:o?r.jsx(Sa,{className:"w-3.5 h-3.5 text-gray-700"}):r.jsx(Ca,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),r.jsx("div",{className:"space-y-4",children:r.jsx(op,{})}),r.jsx("div",{className:"space-y-4",children:r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.projectSorting.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.projectSorting.description")})]}),r.jsxs("select",{value:N,onChange:$=>b($.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 w-32",children:[r.jsx("option",{value:"name",children:i("appearanceSettings.projectSorting.alphabetical")}),r.jsx("option",{value:"date",children:i("appearanceSettings.projectSorting.recentActivity")})]})]})})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground",children:i("appearanceSettings.codeEditor.title")}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.theme.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.theme.description")})]}),r.jsxs("button",{onClick:()=>Fe(re==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":re==="dark","aria-label":"Toggle editor theme",children:[r.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),r.jsx("span",{className:`${re==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:re==="dark"?r.jsx(Sa,{className:"w-3.5 h-3.5 text-gray-700"}):r.jsx(Ca,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.wordWrap.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.wordWrap.description")})]}),r.jsxs("button",{onClick:()=>ce(!Ce),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ce,"aria-label":"Toggle word wrap",children:[r.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),r.jsx("span",{className:`${Ce?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.showMinimap.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.showMinimap.description")})]}),r.jsxs("button",{onClick:()=>ft(!$e),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":$e,"aria-label":"Toggle minimap",children:[r.jsx("span",{className:"sr-only",children:"Toggle minimap"}),r.jsx("span",{className:`${$e?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.description")})]}),r.jsxs("button",{onClick:()=>Ve(!at),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":at,"aria-label":"Toggle line numbers",children:[r.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),r.jsx("span",{className:`${at?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.fontSize.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.fontSize.description")})]}),r.jsxs("select",{value:Ze,onChange:$=>yt($.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 w-24",children:[r.jsx("option",{value:"10",children:"10px"}),r.jsx("option",{value:"11",children:"11px"}),r.jsx("option",{value:"12",children:"12px"}),r.jsx("option",{value:"13",children:"13px"}),r.jsx("option",{value:"14",children:"14px"}),r.jsx("option",{value:"15",children:"15px"}),r.jsx("option",{value:"16",children:"16px"}),r.jsx("option",{value:"18",children:"18px"}),r.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),P&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:r.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[r.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(ge?"mcpForm.title.edit":"mcpForm.title.add")}),r.jsx(De,{variant:"ghost",size:"sm",onClick:dt,children:r.jsx(ar,{className:"w-4 h-4"})})]}),r.jsxs("form",{onSubmit:W,className:"p-4 space-y-4",children:[!ge&&r.jsxs("div",{className:"flex gap-2 mb-4",children:[r.jsx("button",{type:"button",onClick:()=>V($=>({...$,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${M.importMode==="form"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.form")}),r.jsx("button",{type:"button",onClick:()=>V($=>({...$,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${M.importMode==="json"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.json")})]}),M.importMode==="form"&&ge&&r.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.scope.label")}),r.jsxs("div",{className:"flex items-center gap-2",children:[M.scope==="user"?r.jsx(ul,{className:"w-4 h-4"}):r.jsx(nn,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm",children:M.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),M.scope==="local"&&M.projectPath&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",M.projectPath]})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),M.importMode==="form"&&!ge&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.scope.label")," *"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{type:"button",onClick:()=>V($=>({...$,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${M.scope==="user"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r.jsx(ul,{className:"w-4 h-4"}),r.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),r.jsx("button",{type:"button",onClick:()=>V($=>({...$,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${M.scope==="local"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r.jsx(nn,{className:"w-4 h-4"}),r.jsx("span",{children:i("mcpForm.scope.projectLocal")})]})})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:M.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),M.scope==="local"&&!ge&&r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.selectProject")," *"]}),r.jsxs("select",{value:M.projectPath,onChange:$=>V(z=>({...z,projectPath:$.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",required:M.scope==="local",children:[r.jsxs("option",{value:"",children:[i("mcpForm.fields.selectProject"),"..."]}),n.map($=>r.jsx("option",{value:$.path||$.fullPath,children:$.displayName||$.name},$.name))]}),M.projectPath&&r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:M.projectPath})})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{className:M.importMode==="json"?"md:col-span-2":"",children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),r.jsx(Ft,{value:M.name,onChange:$=>{V(z=>({...z,name:$.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),M.importMode==="form"&&r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.transportType")," *"]}),r.jsxs("select",{value:M.type,onChange:$=>{V(z=>({...z,type:$.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",children:[r.jsx("option",{value:"stdio",children:"stdio"}),r.jsx("option",{value:"sse",children:"SSE"}),r.jsx("option",{value:"http",children:"HTTP"})]})]})]}),ge&&M.raw&&M.importMode==="form"&&r.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:i("mcpForm.configDetails",{configFile:ge.scope==="global"?"~/.claude.json":"project config"})}),r.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(M.raw,null,2)})]}),M.importMode==="json"&&r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.jsonConfig")," *"]}),r.jsx("textarea",{value:M.jsonInput,onChange:$=>{V(z=>({...z,jsonInput:$.target.value}));try{if($.target.value.trim()){const z=JSON.parse($.target.value);z.type?z.type==="stdio"&&!z.command?ve(i("mcpForm.validation.stdioRequiresCommand")):(z.type==="http"||z.type==="sse")&&!z.url?ve(i("mcpForm.validation.httpRequiresUrl",{type:z.type})):ve(""):ve(i("mcpForm.validation.missingType"))}}catch{$.target.value.trim()?ve(i("mcpForm.validation.invalidJson")):ve("")}},className:`w-full px-3 py-2 border ${ke?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary font-mono text-sm`,rows:"8",placeholder:`{
452
- "type": "stdio",
453
- "command": "/path/to/server",
454
- "args": ["--api-key", "abc123"],
455
- "env": {
456
- "CACHE_DIR": "/tmp"
457
- }
458
- }`,required:!0}),ke&&r.jsx("p",{className:"text-xs text-red-500 mt-1",children:ke}),r.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[i("mcpForm.validation.jsonHelp"),r.jsx("br",{}),"• stdio: ",'{"type":"stdio","command":"npx","args":["@upstash/context7-mcp"]}',r.jsx("br",{}),"• http/sse: ",'{"type":"http","url":"https://api.example.com/mcp"}']})]})}),M.importMode==="form"&&M.type==="stdio"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.command")," *"]}),r.jsx(Ft,{value:M.config.command,onChange:$=>Et("command",$.target.value),placeholder:"/path/to/mcp-server",required:!0})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.arguments")}),r.jsx("textarea",{value:Array.isArray(M.config.args)?M.config.args.join(`
459
- `):"",onChange:$=>Et("args",$.target.value.split(`
460
- `).filter(z=>z.trim())),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",rows:"3",placeholder:`--api-key
461
- abc123`})]})]}),M.importMode==="form"&&(M.type==="sse"||M.type==="http")&&r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.url")," *"]}),r.jsx(Ft,{value:M.config.url,onChange:$=>Et("url",$.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),M.importMode==="form"&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),r.jsx("textarea",{value:Object.entries(M.config.env||{}).map(([$,z])=>`${$}=${z}`).join(`
462
- `),onChange:$=>{const z={};$.target.value.split(`
463
- `).forEach(ne=>{const[Re,...I]=ne.split("=");Re&&Re.trim()&&(z[Re.trim()]=I.join("=").trim())}),Et("env",z)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",rows:"3",placeholder:`API_KEY=your-key
464
- DEBUG=true`})]}),M.importMode==="form"&&(M.type==="sse"||M.type==="http")&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.headers")}),r.jsx("textarea",{value:Object.entries(M.config.headers||{}).map(([$,z])=>`${$}=${z}`).join(`
465
- `),onChange:$=>{const z={};$.target.value.split(`
466
- `).forEach(ne=>{const[Re,...I]=ne.split("=");Re&&Re.trim()&&(z[Re.trim()]=I.join("=").trim())}),Et("headers",z)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",rows:"3",placeholder:`Authorization=Bearer token
467
- X-API-Key=your-key`})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(De,{type:"button",variant:"outline",onClick:dt,children:i("mcpForm.actions.cancel")}),r.jsx(De,{type:"submit",disabled:xe,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:i(xe?"mcpForm.actions.saving":ge?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),kt&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:r.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[r.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(je?"mcpForm.title.edit":"mcpForm.title.add")}),r.jsx(De,{variant:"ghost",size:"sm",onClick:_,children:r.jsx(ar,{className:"w-4 h-4"})})]}),r.jsxs("form",{onSubmit:pe,className:"p-4 space-y-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),r.jsx(Ft,{value:J.name,onChange:$=>ee(z=>({...z,name:$.target.value})),placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.command")," *"]}),r.jsx(Ft,{value:J.config?.command||"",onChange:$=>ee(z=>({...z,config:{...z.config,command:$.target.value}})),placeholder:"npx @my-org/mcp-server",required:!0})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.arguments")}),r.jsx("textarea",{value:(J.config?.args||[]).join(`
468
- `),onChange:$=>ee(z=>({...z,config:{...z.config,args:$.target.value.split(`
469
- `).filter(ne=>ne.trim())}})),placeholder:`--port
470
- 3000`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),r.jsx("textarea",{value:Object.entries(J.config?.env||{}).map(([$,z])=>`${$}=${z}`).join(`
471
- `),onChange:$=>{const z={};$.target.value.split(`
472
- `).forEach(ne=>{const[Re,...I]=ne.split("=");Re&&I.length>0&&(z[Re.trim()]=I.join("=").trim())}),ee(ne=>({...ne,config:{...ne.config,env:z}}))},placeholder:`API_KEY=xxx
473
- DEBUG=true`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border",children:[r.jsx(De,{type:"button",variant:"outline",onClick:_,children:i("mcpForm.actions.cancel")}),r.jsx(De,{type:"submit",disabled:et||!J.name||!J.config?.command,className:"bg-green-600 hover:bg-green-700 text-white",children:i(et?"mcpForm.actions.saving":je?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),B==="api"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:r.jsx(Wb,{})}),B==="channels"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:r.jsx(qb,{projects:n})})]})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-4 md:p-6 border-t border-border flex-shrink-0 gap-3 pb-safe-area-inset-bottom",children:[r.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:[w==="success"&&r.jsxs("div",{className:"text-green-600 dark:text-green-400 text-sm flex items-center gap-1",children:[r.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),i("saveStatus.success")]}),w==="error"&&r.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[r.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),i("saveStatus.error")]})]}),r.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[r.jsx(De,{variant:"outline",onClick:t,disabled:A,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:i("footerActions.cancel")}),B!=="channels"&&r.jsx(De,{onClick:be,disabled:A,className:"flex-1 sm:flex-none h-10 bg-primary hover:bg-primary/90 disabled:opacity-50 touch-manipulation",children:A?r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-4 h-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),i("saveStatus.saving")]}):i("footerActions.save")})]})]})]}),r.jsx(Vb,{isOpen:Je,onClose:()=>Mt(!1),provider:ue,project:Ye,onComplete:ie,isAuthenticated:ue==="claude"?Ue.authenticated:ue==="codex"?Pt.authenticated:!1},ue)]}):null}const Kb=({isOpen:e,onToggle:t,autoExpandTools:n,onAutoExpandChange:s,showRawParameters:o,onShowRawParametersChange:a,showThinking:i,onShowThinkingChange:c,autoScrollToBottom:d,onAutoScrollChange:u,sendByCtrlEnter:p,onSendByCtrlEnterChange:m,isMobile:h})=>{const{t:g}=$t("settings"),[x,j]=l.useState(e),[k,A]=l.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:T}=ei(),[w,D]=l.useState(()=>{const O=localStorage.getItem("quickSettingsHandlePosition");if(O)try{return JSON.parse(O).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[N,b]=l.useState(!1),[L,q]=l.useState(0),[P,Y]=l.useState(0),[ge,le]=l.useState(!1),M=l.useRef(null),V=l.useRef({min:10,max:90}),xe=5;l.useEffect(()=>{j(e)},[e]),l.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:w}))},[w]);const Ie=l.useCallback(()=>h?{bottom:`${window.innerHeight*w/100}px`}:{top:`${w}%`,transform:"translateY(-50%)"},[w,h]),qe=l.useCallback(O=>{O.stopPropagation();const S=O.type.includes("touch")?O.touches[0].clientY:O.clientY;q(S),Y(w),le(!1),b(!1)},[w]),Se=l.useCallback(O=>{if(L===0)return;const S=O.type.includes("touch")?O.touches[0].clientY:O.clientY,B=Math.abs(S-L);if(!N&&B>xe&&(b(!0),le(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",O.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!N)return;O.type.includes("touch")&&O.preventDefault();const Z=S-L;let ke;h?ke=-(Z/window.innerHeight)*100:ke=Z/window.innerHeight*100;let ve=P+ke;ve=Math.max(V.current.min,Math.min(V.current.max,ve)),D(ve)},[N,L,P,h,xe]),U=l.useCallback(()=>{b(!1),q(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);l.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),l.useEffect(()=>{if(L!==0){const O=ke=>Se(ke),S=()=>U(),B=ke=>Se(ke),Z=()=>U();return document.addEventListener("mousemove",O),document.addEventListener("mouseup",S),document.addEventListener("touchmove",B,{passive:!1}),document.addEventListener("touchend",Z),()=>{document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",S),document.removeEventListener("touchmove",B),document.removeEventListener("touchend",Z)}}},[L,Se,U]);const fe=O=>{if(ge){O.preventDefault(),le(!1);return}const S=!x;j(S),t(S)};return r.jsxs(r.Fragment,{children:[r.jsx("button",{ref:M,onClick:fe,onMouseDown:O=>{qe(O)},onTouchStart:O=>{qe(O)},className:`fixed ${x?"right-64":"right-0"} z-50 ${N?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${N?"border-primary":"border-gray-200 dark:border-gray-700"} rounded-l-md p-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors shadow-lg ${N?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...Ie(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":g(N?"quickSettings.dragHandle.dragging":x?"quickSettings.dragHandle.closePanel":"quickSettings.dragHandle.openPanel"),title:g(N?"quickSettings.dragHandle.draggingStatus":"quickSettings.dragHandle.toggleAndMove"),children:N?r.jsx(Cf,{className:"h-5 w-5 text-primary"}):x?r.jsx(wn,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):r.jsx(Lc,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),r.jsx("div",{className:`fixed top-0 right-0 h-full w-64 bg-background border-l border-border shadow-xl transform transition-transform duration-150 ease-out z-40 ${x?"translate-x-0":"translate-x-full"} ${h?"h-screen":""}`,children:r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:r.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[r.jsx(Qf,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),g("quickSettings.title")]})}),r.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${h?"pb-mobile-nav":""}`,children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.appearance")}),r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[T?r.jsx(Sa,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):r.jsx(Ca,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.darkMode")]}),r.jsx(Km,{})]}),r.jsx("div",{children:r.jsx(op,{compact:!0})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.toolDisplay")}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(Bc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.autoExpandTools")]}),r.jsx("input",{type:"checkbox",checked:n,onChange:O=>s(O.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(Oc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.showRawParameters")]}),r.jsx("input",{type:"checkbox",checked:o,onChange:O=>a(O.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(Pc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.showThinking")]}),r.jsx("input",{type:"checkbox",checked:i,onChange:O=>c(O.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.viewOptions")}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(nf,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.autoScrollToBottom")]}),r.jsx("input",{type:"checkbox",checked:d,onChange:O=>u(O.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.inputSettings")}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx($c,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.sendByCtrlEnter")]}),r.jsx("input",{type:"checkbox",checked:p,onChange:O=>m(O.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 ml-3",children:g("quickSettings.sendByCtrlEnterDescription")})]}),r.jsxs("div",{className:"space-y-2",style:{display:"none"},children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.whisperDictation")}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsx("input",{type:"radio",name:"whisperMode",value:"default",checked:k==="default",onChange:()=>{A("default"),localStorage.setItem("whisperMode","default"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:bg-gray-800 checked:bg-primary"}),r.jsxs("div",{className:"ml-3 flex-1",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[r.jsx(Fs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.whisper.modes.default")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:g("quickSettings.whisper.modes.defaultDescription")})]})]}),r.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsx("input",{type:"radio",name:"whisperMode",value:"prompt",checked:k==="prompt",onChange:()=>{A("prompt"),localStorage.setItem("whisperMode","prompt"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:bg-gray-800 checked:bg-primary"}),r.jsxs("div",{className:"ml-3 flex-1",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[r.jsx(ri,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.whisper.modes.prompt")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:g("quickSettings.whisper.modes.promptDescription")})]})]}),r.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsx("input",{type:"radio",name:"whisperMode",value:"vibe",checked:k==="vibe"||k==="instructions"||k==="architect",onChange:()=>{A("vibe"),localStorage.setItem("whisperMode","vibe"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:bg-gray-800 checked:bg-primary"}),r.jsxs("div",{className:"ml-3 flex-1",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[r.jsx(ni,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.whisper.modes.vibe")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:g("quickSettings.whisper.modes.vibeDescription")})]})]})]})]})]})]})}),x&&r.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:fe})]})},ap=l.createContext({user:null,token:null,login:()=>{},register:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,error:null}),go=()=>{const e=l.useContext(ap);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},Jb=({children:e})=>{const[t,n]=l.useState(null),[s,o]=l.useState(localStorage.getItem("auth-token")),[a,i]=l.useState(!0),[c,d]=l.useState(!1),[u,p]=l.useState(null);l.useEffect(()=>{m()},[]);const m=async()=>{try{if(i(!0),p(null),(await(await mt.auth.status()).json()).needsSetup){d(!0),i(!1);return}if(s)try{const T=await mt.auth.user();if(T.ok){const w=await T.json();n(w.user),d(!1)}else localStorage.removeItem("auth-token"),o(null),n(null)}catch(T){console.error("Token verification failed:",T),localStorage.removeItem("auth-token"),o(null),n(null)}}catch(k){console.error("[AuthContext] Auth status check failed:",k),p("Failed to check authentication status")}finally{i(!1)}},j={user:t,token:s,login:async(k,A)=>{try{p(null);const T=await mt.auth.login(k,A),w=await T.json();return T.ok?(o(w.token),n(w.user),localStorage.setItem("auth-token",w.token),{success:!0}):(p(w.error||"Login failed"),{success:!1,error:w.error||"Login failed"})}catch(T){console.error("Login error:",T);const w="Network error. Please try again.";return p(w),{success:!1,error:w}}},register:async(k,A)=>{try{p(null);const T=await mt.auth.register(k,A),w=await T.json();return T.ok?(o(w.token),n(w.user),d(!1),localStorage.setItem("auth-token",w.token),{success:!0}):(p(w.error||"Registration failed"),{success:!1,error:w.error||"Registration failed"})}catch(T){console.error("Registration error:",T);const w="Network error. Please try again.";return p(w),{success:!1,error:w}}},logout:()=>{o(null),n(null),localStorage.removeItem("auth-token"),s&&mt.auth.logout().catch(k=>{console.error("Logout endpoint error:",k)})},isLoading:a,needsSetup:c,error:u};return r.jsx(ap.Provider,{value:j,children:e})},ip=l.createContext(null),Yb=()=>{const e=l.useContext(ip);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},Xb=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},Qb=()=>{const e=l.useRef(null),t=l.useRef(!1),[n,s]=l.useState(null),[o,a]=l.useState(!1),i=l.useRef(null),c=l.useRef(!1),d=l.useRef([]),u=l.useRef([]),p=l.useRef(null),m=l.useRef(0),{token:h}=go(),g=l.useCallback(()=>{if(p.current||t.current)return;const b=()=>{if(p.current=null,t.current){u.current=[];return}const L=u.current.shift();L&&(m.current+=1,s({...L,__messageSeq:m.current}),u.current.length>0&&(p.current=setTimeout(b,0)))};p.current=setTimeout(b,0)},[]),x=l.useCallback(b=>{u.current.push(b),g()},[g]),j=l.useCallback((b,L)=>{x({type:"connection-error",error:L,provider:b?.provider||(typeof b?.type=="string"?b.type.replace(/-command$/,""):"claude"),sessionId:b?.sessionId||b?.options?.sessionId||null,clientRequestId:b?.clientRequestId||null})},[x]),k=l.useCallback(b=>{b.timeoutId&&(clearTimeout(b.timeoutId),b.timeoutId=null)},[]),A=l.useCallback(b=>{if(b.readyState!==WebSocket.OPEN)return;d.current.splice(0,d.current.length).forEach(q=>{k(q),b.send(JSON.stringify(q.payload))})},[k]),T=l.useCallback(b=>{if(!b||typeof b!="object"||b.clientRequestId)return b;const L=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`;return{...b,clientRequestId:L}},[]),w=l.useCallback(()=>{if(t.current||c.current)return;const b=e.current;if(!(b&&(b.readyState===WebSocket.OPEN||b.readyState===WebSocket.CONNECTING)))try{const L=Xb(h);if(!L){d.current.splice(0,d.current.length).forEach(Y=>{k(Y),j(Y.payload,"No authentication token found for WebSocket connection")});return}c.current=!0;const q=new WebSocket(L);e.current=q,q.onopen=()=>{c.current=!1,a(!0),e.current=q,x({type:"ws-connection-state",state:"connected"}),A(q)},q.onmessage=P=>{try{const Y=JSON.parse(P.data);x(Y)}catch(Y){console.error("Error parsing WebSocket message:",Y)}},q.onclose=()=>{c.current=!1,a(!1),e.current===q&&(e.current=null),x({type:"ws-connection-state",state:"disconnected"}),i.current=setTimeout(()=>{t.current||w()},3e3)},q.onerror=P=>{console.error("WebSocket error:",P)}}catch(L){c.current=!1,console.error("Error creating WebSocket connection:",L)}},[k,j,A,h]);l.useEffect(()=>(t.current=!1,w(),()=>{c.current=!1,i.current&&clearTimeout(i.current),p.current&&(clearTimeout(p.current),p.current=null),u.current=[],e.current&&(e.current.close(),e.current=null)}),[w,h]),l.useEffect(()=>()=>{t.current=!0,c.current=!1,i.current&&clearTimeout(i.current),p.current&&(clearTimeout(p.current),p.current=null),u.current=[],d.current.splice(0,d.current.length).forEach(L=>k(L)),e.current&&(e.current.close(),e.current=null)},[k]);const D=l.useCallback(b=>{const L=T(b),q=e.current;if(q&&q.readyState===WebSocket.OPEN){try{q.send(JSON.stringify(L))}catch(Y){throw Y}return}x({type:"ws-connection-state",state:"connecting",sessionId:L?.sessionId||L?.options?.sessionId||null,clientRequestId:L?.clientRequestId||null});const P={payload:L,timeoutId:setTimeout(()=>{d.current=d.current.filter(Y=>Y!==P),j(L,"Unable to reach the chat server. Message was not sent.")},1e4)};d.current.push(P),w()},[w,j,x,T]);return l.useMemo(()=>({ws:e.current,sendMessage:D,latestMessage:n,isConnected:o}),[D,n,o])},Zb=({children:e})=>{const t=Qb();return r.jsx(ip.Provider,{value:t,children:e})},ew=()=>{const[e,t]=l.useState(""),[n,s]=l.useState(""),[o,a]=l.useState(""),[i,c]=l.useState(!1),[d,u]=l.useState(""),{register:p}=go(),m=async h=>{if(h.preventDefault(),u(""),n!==o){u("Passwords do not match");return}if(e.length<3){u("Username must be at least 3 characters long");return}if(n.length<6){u("Password must be at least 6 characters long");return}c(!0);const g=await p(e,n);g.success||u(g.error),c(!1)};return r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsx("div",{className:"w-full max-w-md",children:r.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx(rs,{size:64})}),r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Welcome to Axhub Genie"}),r.jsx("p",{className:"text-muted-foreground mt-2",children:"Set up your account to get started"})]}),r.jsxs("form",{onSubmit:m,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-foreground mb-1",children:"Username"}),r.jsx("input",{type:"text",id:"username",value:e,onChange:h=>t(h.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:"Enter your username",required:!0,disabled:i})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:"Password"}),r.jsx("input",{type:"password",id:"password",value:n,onChange:h=>s(h.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:"Enter your password",required:!0,disabled:i})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"confirmPassword",className:"block text-sm font-medium text-foreground mb-1",children:"Confirm Password"}),r.jsx("input",{type:"password",id:"confirmPassword",value:o,onChange:h=>a(h.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:"Confirm your password",required:!0,disabled:i})]}),d&&r.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:r.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:d})}),r.jsx("button",{type:"submit",disabled:i,className:"w-full bg-primary hover:bg-primary/90 disabled:bg-primary/60 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:i?"Setting up...":"Create Account"})]}),r.jsx("div",{className:"text-center",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:"This is a single-user system. Only one account can be created."})})]})})})},tw=()=>{const{t:e}=$t("auth"),[t,n]=l.useState(""),[s,o]=l.useState(""),[a,i]=l.useState(!1),[c,d]=l.useState(""),{login:u}=go(),p=async m=>{if(m.preventDefault(),d(""),!t||!s){d(e("errors.requiredFields"));return}i(!0);const h=await u(t,s);h.success||d(h.error),i(!1)};return r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsx("div",{className:"w-full max-w-md",children:r.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:r.jsx(Vn,{className:"w-8 h-8 text-primary-foreground"})})}),r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e("login.title")}),r.jsx("p",{className:"text-muted-foreground mt-2",children:e("login.description")})]}),r.jsxs("form",{onSubmit:p,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-foreground mb-1",children:e("login.username")}),r.jsx("input",{type:"text",id:"username",value:t,onChange:m=>n(m.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("login.placeholders.username"),required:!0,disabled:a})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:e("login.password")}),r.jsx("input",{type:"password",id:"password",value:s,onChange:m=>o(m.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("login.placeholders.password"),required:!0,disabled:a})]}),c&&r.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:r.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:c})}),r.jsx("button",{type:"submit",disabled:a,className:"w-full bg-primary hover:bg-primary/90 disabled:bg-primary/60 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:e(a?"login.loading":"login.submit")})]}),r.jsx("div",{className:"text-center",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter your credentials to access Axhub Genie"})})]})})})},rw=()=>r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:r.jsx(Vn,{className:"w-8 h-8 text-primary-foreground"})})}),r.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Axhub Genie"}),r.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce"}),r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),r.jsx("p",{className:"text-muted-foreground mt-2",children:"Loading..."})]})}),nw=({children:e})=>{const{user:t,isLoading:n,needsSetup:s}=go();return n?r.jsx(rw,{}):s?r.jsx(ew,{}):t?e:r.jsx(tw,{})};function yn(e,t){const[n,s]=l.useState(()=>{if(typeof window>"u")return t;try{const a=window.localStorage.getItem(e);return a?JSON.parse(a):t}catch(a){return console.log(a),t}});return[n,a=>{if(!(typeof window>"u"))try{const i=a instanceof Function?a(n):a;window.localStorage.setItem(e,JSON.stringify(i)),s(i)}catch(i){console.log(i)}}]}const sw=3e3;function $n(e){return typeof e=="string"&&e.trim().length>0}function ow(e="integration"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}_${crypto.randomUUID()}`:`${e}_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function aw(){return typeof window>"u"?null:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/agent/ws`}function iw({enabled:e,channel:t,clientId:n,sessionId:s}){const o=l.useRef(null),a=l.useRef(null),i=l.useRef(!1),c=l.useRef(!1),d=l.useRef(0),u=l.useRef($n(s)?s.trim():null),[p,m]=l.useState(null),[h,g]=l.useState(!1),x=l.useMemo(()=>e===!0&&$n(t)&&$n(n),[e,t,n]);l.useEffect(()=>{u.current=$n(s)?s.trim():null},[s]);const j=l.useCallback(N=>{d.current+=1,m({...N,__messageSeq:d.current})},[]),k=l.useCallback(()=>{const N=o.current;N&&(N.close(),o.current=null),g(!1),i.current=!1},[]),A=l.useCallback((N,b=o.current)=>!N||!b||b.readyState!==WebSocket.OPEN?!1:(b.send(JSON.stringify({type:"integration.ack",requestId:N,payload:{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:u.current}})),!0),[]),T=l.useCallback((N=o.current)=>{!x||!N||N.readyState!==WebSocket.OPEN||N.send(JSON.stringify({type:"integration.connect",requestId:ow("integration_connect"),payload:{role:"frontend-page",channel:t.trim(),clientId:n.trim(),pageUrl:typeof window<"u"?window.location.href:null,sessionId:$n(s)?s.trim():null,capabilities:["context.update","prompt.update","presence.report"]}}))},[t,n,x,s]),w=l.useCallback(()=>{if(!x||c.current||i.current)return;const N=o.current;if(N&&(N.readyState===WebSocket.OPEN||N.readyState===WebSocket.CONNECTING))return;const b=aw();if(!b)return;i.current=!0;const L=new WebSocket(b);o.current=L,L.onopen=()=>{i.current=!1,o.current=L,g(!0),T(L)},L.onmessage=q=>{try{const P=JSON.parse(q.data);P&&typeof P.type=="string"&&P.type.startsWith("integration.")&&(P.type==="integration.ping"&&A(P.requestId||null,L),j(P))}catch(P){console.error("Error parsing integration WebSocket message:",P)}},L.onclose=()=>{o.current===L&&(o.current=null),i.current=!1,g(!1),!c.current&&x&&(a.current=setTimeout(()=>{a.current=null,w()},sw))},L.onerror=q=>{console.error("Integration WebSocket error:",q)}},[T,j,x,A]);l.useEffect(()=>{if(c.current=!1,!x){a.current&&(clearTimeout(a.current),a.current=null),k();return}return w(),()=>{a.current&&(clearTimeout(a.current),a.current=null),k()}},[k,w,x]),l.useEffect(()=>()=>{c.current=!0,a.current&&(clearTimeout(a.current),a.current=null),k()},[k]),l.useEffect(()=>{x&&T()},[T,x,s]);const D=l.useCallback(N=>{const b=o.current;return!b||b.readyState!==WebSocket.OPEN?!1:(b.send(JSON.stringify(N)),!0)},[]);return{integrationWs:o.current,latestIntegrationMessage:p,sendIntegrationMessage:D,isIntegrationConnected:h,isIntegrationEnabled:x}}function Cc(){const e=xm(),{sessionId:t}=vm(),[n]=ym(),{t:s}=$t("common");l.useRef(0);const{updateAvailable:o,latestVersion:a,currentVersion:i,releaseInfo:c}=sp(),[d,u]=l.useState(!1),[p,m]=l.useState([]),[h,g]=l.useState(null),[x,j]=l.useState(null),[k,A]=l.useState(0),[T,w]=l.useState("chat"),[D,N]=l.useState(!1),b=D&&!1,[L,q]=l.useState(!1),[P,Y]=l.useState(!0),[ge,le]=l.useState(null),[M,V]=l.useState(!1),[xe,Ie]=l.useState(!1),[qe,Se]=l.useState("appearance"),[U,fe]=l.useState(!1),[O,S]=yn("autoExpandTools",!1),[B,Z]=yn("showRawParameters",!1),[ke,ve]=yn("showThinking",!0),[R,re]=yn("autoScrollToBottom",!0),[Fe,Ce]=yn("sendByCtrlEnter",!1),[ce,$e]=yn("sidebarVisible",!0),[ft,at]=l.useState(!1),[Ve,Ze]=l.useState(new Set),[yt,Tt]=l.useState(new Set),he=l.useRef({sessionId:null,status:"idle"}),Ke=l.useCallback((I,Q="claude")=>{if(!I)return Q;try{const te=localStorage.getItem("session-provider-map");if(!te)return Q;const H=JSON.parse(te)?.[I];return typeof H=="string"&&H?H:Q}catch{return Q}},[]),[_t,kt]=l.useState(0),St=l.useRef({selectionKey:null}),J=l.useRef({attemptedKeys:new Set}),ee=n.get("cwd")||n.get("workdir"),je=n.get("project")||n.get("projectName"),_e=n.get("provider")||n.get("tool")||n.get("cli"),et=n.get("model"),tt=n.get("context"),Je=n.get("prompt"),Mt=n.get("integrationWs"),ue=n.get("integrationClientId"),bt=n.get("integrationChannel"),Ye=n.toString(),Ue=p.find(I=>!!(ee&&(I.fullPath===ee||I.path===ee)||je&&(I.fullPath===je||I.path===je)))?.name||null,Nt=l.useCallback((I,Q)=>{const te=n.toString(),ye=te?`${I}?${te}`:I;e(ye,Q)},[e,n]),{ws:Pt,sendMessage:ht,latestMessage:Ct}=Yb(),{latestIntegrationMessage:tr,sendIntegrationMessage:Xe}=iw({enabled:Mt==="1",clientId:ue,channel:bt,sessionId:x?.id||t||null}),Lt=l.useCallback(I=>typeof I!="string"?!1:/^new-session-\d+$/i.test(I)||/^codex-\d+$/i.test(I),[]),jt=l.useRef(null),[Ot,rr]=l.useState(!1);l.useEffect(()=>{T==="files"&&w("chat")},[T]),l.useEffect(()=>{const I=()=>{const Q=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");rr(Q),document.addEventListener("touchstart",{}),Q?(document.documentElement.classList.add("pwa-mode"),document.body.classList.add("pwa-mode")):(document.documentElement.classList.remove("pwa-mode"),document.body.classList.remove("pwa-mode"))};return I(),window.matchMedia("(display-mode: standalone)").addEventListener("change",I),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",I)}},[]),l.useEffect(()=>{const I=()=>{N(window.innerWidth<768)};return I(),window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]),l.useEffect(()=>{Ae()},[]),l.useEffect(()=>{if(!ee&&!je||p.length===0)return;const I=`${ee||""}::${je||""}`;if(St.current.selectionKey===I)return;if(x){St.current.selectionKey=I;return}let Q=null;if(ee&&(Q=p.find(te=>te.fullPath===ee||te.path===ee)),!Q&&je){const te=je.trim().toLowerCase();Q=p.find(ye=>[ye.name,ye.displayName,ye.path,ye.fullPath].some(We=>typeof We=="string"&&We.toLowerCase()===te))}Q&&g(Q),St.current.selectionKey=I},[ee,je,p,x]),l.useEffect(()=>{if(!ee||!ee.trim()||P||x)return;const I=ee.trim();if(p.some(We=>We.fullPath===I||We.path===I))return;const te=`cwd:${I}`;if(J.current.attemptedKeys.has(te))return;J.current.attemptedKeys.add(te);let ye=!1;return(async()=>{try{const We=await mt.createProject(I),Qe=await We.json().catch(()=>({}));if(!We.ok){const wt=Qe?.error||"Unknown error";if(wt.includes("Project already configured")){await Ae();return}console.warn(`[URL] Failed to auto-create project for cwd "${I}": ${wt}`);return}if(ye)return;Qe?.project&&g(Qe.project),await Ae()}catch(We){console.error(`[URL] Error auto-creating project for cwd "${I}":`,We)}})(),()=>{ye=!0}},[ee,p,P,x]);const zt=(I,Q,te,ye)=>{if(!te||!ye)return!0;const H=I?.find(Ge=>Ge.name===te.name),We=Q?.find(Ge=>Ge.name===te.name);if(!H||!We)return!1;const Qe=Ge=>[...Ge.sessions||[],...Ge.codexSessions||[],...Ge.geminiSessions||[],...Ge.opencodeSessions||[]].find(Ut=>Ut.id===ye.id),wt=Qe(H),ut=Qe(We);return!wt||!ut?!1:wt.id===ut.id&&wt.title===ut.title&&wt.created_at===ut.created_at&&wt.updated_at===ut.updated_at},_=(I,Q)=>!I||!Q?I!==Q:I.name!==Q.name||I.displayName!==Q.displayName||I.fullPath!==Q.fullPath||I.path!==Q.path,pe=I=>{if(!I)return!1;if(t===I)return!0;const Q=he.current;return Q?.sessionId===I&&Q?.status!=="missing"&&Q?.status!=="error"?!0:Ve.has(I)||yt.has(I)};l.useEffect(()=>{if(Ct){if(Ct.type==="loading_progress"){jt.current&&(clearTimeout(jt.current),jt.current=null),le(Ct),Ct.phase==="complete"&&(jt.current=setTimeout(()=>{le(null),jt.current=null},500));return}if(Ct.type==="projects_updated"){if(Ct.changedFile&&x&&h){const ye=Ct.changedFile.replace(/\\/g,"/").split("/"),H=ye[ye.length-1]||"",We=H.replace(".jsonl","").match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i)?.[1]||H.replace(".jsonl","");if((Ct.changedSessionId||We)===x.id){const wt=Ve.has(x.id),ut=x.__provider==="codex";(!wt||ut)&&kt(ot=>ot+1)}}if(x&&Ve.has(x.id)||Ve.size>0&&Array.from(Ve).some(te=>te.startsWith("new-session-"))){const te=Ct.projects;if(!zt(p,te,h,x))return}const Q=Ct.projects;if(m(Q),h){const te=Q.find(ye=>ye.name===h.name);if(te&&(_(h,te)&&g(te),x)){const H=[...te.sessions||[],...te.codexSessions||[],...te.geminiSessions||[],...te.opencodeSessions||[]].find(We=>We.id===x.id);if(!H)pe(x.id)||j(null);else{const We={...H,__provider:x.__provider||Ke(H.id,"claude"),__projectName:x.__projectName||te.name};(We.title!==x.title||We.updated_at!==x.updated_at||We.__provider!==x.__provider||We.__projectName!==x.__projectName)&&j(We)}}}}}return()=>{jt.current&&(clearTimeout(jt.current),jt.current=null)}},[Ve,Ct,yt,Ke,h,x,t]);const Ae=async(I={})=>{const{background:Q=!1}=I;try{Q||Y(!0);const ye=await(await mt.projects()).json();m(H=>H.length===0||ye.some((Qe,wt)=>{const ut=H[wt];return ut?Qe.name!==ut.name||Qe.displayName!==ut.displayName||Qe.fullPath!==ut.fullPath||JSON.stringify(Qe.sessionMeta)!==JSON.stringify(ut.sessionMeta)||JSON.stringify(Qe.sessions)!==JSON.stringify(ut.sessions)||JSON.stringify(Qe.codexSessions)!==JSON.stringify(ut.codexSessions)||JSON.stringify(Qe.geminiSessions)!==JSON.stringify(ut.geminiSessions)||JSON.stringify(Qe.opencodeSessions)!==JSON.stringify(ut.opencodeSessions):!0})||ye.length!==H.length?ye:H)}catch(te){console.error("Error fetching projects:",te)}finally{Q||Y(!1)}};window.refreshProjects=(I={})=>Ae({background:!0,...I}),window.openSettings=l.useCallback((I="appearance")=>{Se(I),Ie(!0)},[]),l.useEffect(()=>{if(!t||p.length===0)return;const I=x?.id||null;h?.name;const Q=I!==t,te=_e||x?.__provider||localStorage.getItem("selected-provider")||"claude",ye=Ke(t,te),H=`${t}::${Ye}`,We=Lt(t),Qe=(ot,Ge,Dt)=>{if(!ot||!Ge)return!1;const Ut=p.find(Bt=>Bt.name===ot.name)||ot,Pr={...Ge,__provider:Dt||ye,__projectName:Ut.name};return g(Bt=>Bt?.name===Ut.name?Bt:Ut),j(Bt=>Bt?.id===Pr.id&&Bt?.__provider===Pr.__provider&&Bt?.__projectName===Pr.__projectName?Bt:Pr),Q&&w("chat"),he.current={sessionId:t,status:"resolved",resolutionKey:H},!0};for(const ot of p){const Ge=[{items:ot.sessions,provider:Ke(t,te)},{items:ot.codexSessions,provider:"codex"},{items:ot.geminiSessions,provider:"gemini"},{items:ot.opencodeSessions,provider:"opencode"}];for(const Dt of Ge){const Ut=Dt.items?.find(Gt=>Gt.id===t);if(Ut){Qe(ot,Ut,Dt.provider);return}}}if(h&&(j({id:t,title:"New Session",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),__provider:ye,__projectName:h.name}),Q&&w("chat"),he.current={sessionId:t,status:"placeholder",resolutionKey:H}),We||he.current.sessionId===t&&he.current.status==="resolving"&&he.current.resolutionKey===H)return;he.current={sessionId:t,status:"resolving",resolutionKey:H};let wt=!1;return(async()=>{try{const ot=await mt.resolveSession(t,ye),Ge=await ot.json().catch(()=>({}));if(wt)return;if(!ot.ok||!Ge?.found||!Ge?.project||!Ge?.session){he.current={sessionId:t,status:"missing",resolutionKey:H};return}if(Ge?.provider)try{const Bt=localStorage.getItem("session-provider-map"),un=Bt?JSON.parse(Bt):{};un[t]=Ge.provider,localStorage.setItem("session-provider-map",JSON.stringify(un))}catch{}if(!Qe(Ge.project,Ge.session,Ge.provider||ye))return;const Ut=new URLSearchParams(Ye);(Ge.project.fullPath||Ge.project.path)&&Ut.set("project",Ge.project.fullPath||Ge.project.path),Ge.provider&&Ut.set("provider",Ge.provider);const Gt=`/session/${t}${Ut.toString()?`?${Ut.toString()}`:""}`,Pr=`${window.location.pathname}${window.location.search}`;Gt!==Pr&&e(Gt,{replace:!0})}catch(ot){wt||(console.error("Error resolving session route:",ot),he.current={sessionId:t,status:"error",resolutionKey:H})}})(),()=>{wt=!0}},[Lt,e,p,Ke,Ye,h?.name,x?.id,t]);const X=I=>{g(I),j(null),Nt("/"),D&&q(!1)},C=I=>{if(j(I),T!=="git"&&T!=="preview"&&w("chat"),D){const Q=I.__projectName,te=h?.name;Q!==te&&q(!1)}Nt(`/session/${I.id}`)},F=I=>{if(I?.name&&typeof window<"u")try{localStorage.removeItem(`chat_messages_${I.name}`),localStorage.removeItem(`draft_input_${I.name}`)}catch(Q){console.warn("Failed to clear local chat cache for new session:",Q)}g(I),j(null),A(Q=>Q+1),w("chat"),Nt("/"),D&&q(!1)},ie=I=>{x?.id===I&&(j(null),Nt("/")),m(Q=>Q.map(te=>({...te,sessions:te.sessions?.filter(ye=>ye.id!==I)||[],sessionMeta:{...te.sessionMeta,total:Math.max(0,(te.sessionMeta?.total||0)-1)}})))},be=async()=>{try{const Q=await(await mt.projects()).json();if(m(te=>Q.some((H,We)=>{const Qe=te[We];return Qe?H.name!==Qe.name||H.displayName!==Qe.displayName||H.fullPath!==Qe.fullPath||JSON.stringify(H.sessionMeta)!==JSON.stringify(Qe.sessionMeta)||JSON.stringify(H.sessions)!==JSON.stringify(Qe.sessions):!0})||Q.length!==te.length?Q:te),h){const te=Q.find(ye=>ye.name===h.name);if(te&&(_(h,te)&&g(te),x)){const H=[...te.sessions||[],...te.codexSessions||[],...te.geminiSessions||[],...te.opencodeSessions||[]].find(We=>We.id===x.id);if(!H)pe(x.id)||j(null);else{const We={...H,__provider:x.__provider||Ke(H.id,"claude"),__projectName:x.__projectName||te.name};(We.title!==x.title||We.updated_at!==x.updated_at||We.__provider!==x.__provider||We.__projectName!==x.__projectName)&&j(We)}}}}catch(I){console.error("Error refreshing sidebar:",I)}},dt=I=>{h?.name===I&&(g(null),j(null),Nt("/")),m(Q=>Q.filter(te=>te.name!==I))},W=l.useCallback(I=>{I&&Ze(Q=>new Set([...Q,I]))},[]),Et=l.useCallback(I=>{I&&Ze(Q=>{const te=new Set(Q);return te.delete(I),te})},[]),$=l.useCallback(I=>{I&&Tt(Q=>new Set([...Q,I]))},[]),z=l.useCallback(I=>{I&&Tt(Q=>{const te=new Set(Q);return te.delete(I),te})},[]),ne=l.useCallback((I,Q=null)=>{I&&(Ze(te=>{const ye=new Set;for(const H of te)Q&&H===Q||H.startsWith("new-session-")||ye.add(H);return ye.add(I),ye}),Tt(te=>{const ye=new Set;for(const H of te)Q&&H===Q||H.startsWith("new-session-")||ye.add(H);return ye.add(I),ye}))},[]),Re=()=>{const{t:I}=$t("common"),[Q,te]=l.useState(!1),[ye,H]=l.useState(""),[We,Qe]=l.useState("");if(!d)return null;const wt=ot=>ot?ot.replace(/\b[0-9a-f]{40}\b/gi,"").replace(/(?:^|\s|-)([0-9a-f]{7,10})\b/gi,"").replace(/\*\*Full Changelog\*\*:.*$/gim,"").replace(/https?:\/\/github\.com\/[^\/]+\/[^\/]+\/compare\/[^\s)]+/gi,"").replace(/\n\s*\n\s*\n/g,`
474
-
475
- `).trim():"",ut=async()=>{te(!0),H(`Starting update...
476
- `),Qe("");try{const ot=await oe("/api/system/update",{method:"POST"}),Ge=await ot.json();ot.ok?(H(Dt=>Dt+Ge.output+`
477
- `),H(Dt=>Dt+`
478
- ✅ Update completed successfully!
479
- `),H(Dt=>Dt+`Please restart the server to apply changes.
480
- `)):(Qe(Ge.error||"Update failed"),H(Dt=>Dt+`
481
- ❌ Update failed: `+(Ge.error||"Unknown error")+`
482
- `))}catch(ot){Qe(ot.message),H(Ge=>Ge+`
483
- ❌ Update failed: `+ot.message+`
484
- `)}finally{te(!1)}};return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[r.jsx("button",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>u(!1),"aria-label":I("versionUpdate.ariaLabels.closeModal")}),r.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-2xl mx-4 p-6 space-y-4 max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 bg-primary/15 dark:bg-primary/25 rounded-lg flex items-center justify-center",children:r.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:I("versionUpdate.title")}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:c?.title||I("versionUpdate.newVersionReady")})]})]}),r.jsx("button",{onClick:()=>u(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between items-center p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg",children:[r.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:I("versionUpdate.currentVersion")}),r.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:i})]}),r.jsxs("div",{className:"flex justify-between items-center p-3 bg-primary/10 dark:bg-primary/20 rounded-lg border border-primary/30 dark:border-primary/50",children:[r.jsx("span",{className:"text-sm font-medium text-primary",children:I("versionUpdate.latestVersion")}),r.jsx("span",{className:"text-sm text-primary font-mono",children:a})]})]}),c?.body&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:I("versionUpdate.whatsNew")}),c?.htmlUrl&&r.jsxs("a",{href:c.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:text-primary hover:underline flex items-center gap-1",children:[I("versionUpdate.viewFullRelease"),r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4 border border-gray-200 dark:border-gray-600 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap prose prose-sm dark:prose-invert max-w-none",children:wt(c.body)})})]}),ye&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:I("versionUpdate.updateProgress")}),r.jsx("div",{className:"bg-gray-900 dark:bg-gray-950 rounded-lg p-4 border border-gray-700 max-h-48 overflow-y-auto",children:r.jsx("pre",{className:"text-xs text-green-400 font-mono whitespace-pre-wrap",children:ye})})]}),!Q&&!ye&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:I("versionUpdate.manualUpgrade")}),r.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-lg p-3 border",children:r.jsx("code",{className:"text-sm text-gray-800 dark:text-gray-200 font-mono",children:"npm update -g @axhub/genie"})}),r.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:I("versionUpdate.manualUpgradeHint")})]}),r.jsxs("div",{className:"flex gap-2 pt-2",children:[r.jsx("button",{onClick:()=>u(!1),className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition-colors",children:I(ye?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!ye&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>{navigator.clipboard.writeText("npm update -g @axhub/genie")},className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition-colors",children:I("versionUpdate.buttons.copyCommand")}),r.jsx("button",{onClick:ut,disabled:Q,className:"flex-1 px-4 py-2 text-sm font-medium text-white bg-primary hover:bg-primary/90 disabled:bg-primary/60 disabled:cursor-not-allowed rounded-md transition-colors flex items-center justify-center gap-2",children:Q?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),I("versionUpdate.buttons.updating")]}):I("versionUpdate.buttons.updateNow")})]})]})]})]})};return r.jsxs("div",{className:"chat-app-shell fixed inset-0 flex overflow-hidden bg-background",style:{"--mobile-nav-total":"0px"},children:[!D&&r.jsx("div",{className:`chat-sidebar h-full flex-shrink-0 overflow-hidden transition-all duration-300 ${ce?"w-[22rem]":"w-[4.25rem]"}`,children:r.jsx("div",{className:"h-full overflow-hidden",children:ce?r.jsx(wl,{projects:p,selectedProject:h,selectedSession:x,onProjectSelect:X,onSessionSelect:C,onNewSession:F,onSessionDelete:ie,onProjectDelete:dt,isLoading:P,loadingProgress:ge,onRefresh:be,onShowSettings:()=>Ie(!0),updateAvailable:o,latestVersion:a,currentVersion:i,releaseInfo:c,onShowVersionModal:()=>u(!0),isPWA:Ot,isMobile:D,onToggleSidebar:()=>$e(!1),lockedProjectName:Ue,showNewProject:ft,setShowNewProject:at}):r.jsxs("div",{className:"h-full flex flex-col items-center gap-3 py-4",children:[r.jsx("button",{onClick:()=>$e(!0),className:"flex h-10 w-10 items-center justify-center rounded-xl bg-background/80 text-foreground shadow-sm transition-colors duration-200 hover:bg-background","aria-label":s("versionUpdate.ariaLabels.showSidebar"),title:s("versionUpdate.ariaLabels.showSidebar"),children:r.jsx(wn,{className:"w-4 h-4 text-foreground"})}),r.jsx("button",{onClick:()=>Ie(!0),className:"rounded-xl bg-background/80 p-2 text-muted-foreground shadow-sm transition-colors duration-200 hover:bg-background hover:text-foreground","aria-label":s("versionUpdate.ariaLabels.settings"),title:s("versionUpdate.ariaLabels.settings"),children:r.jsx(zc,{className:"w-5 h-5 text-muted-foreground hover:text-foreground transition-colors"})}),o&&r.jsxs("button",{onClick:()=>u(!0),className:"relative rounded-xl bg-background/80 p-2 text-muted-foreground shadow-sm transition-colors duration-200 hover:bg-background hover:text-foreground","aria-label":s("versionUpdate.ariaLabels.updateAvailable"),title:s("versionUpdate.ariaLabels.updateAvailable"),children:[r.jsx(ri,{className:"w-5 h-5 text-primary"}),r.jsx("span",{className:"absolute top-1 right-1 w-2 h-2 bg-primary rounded-full animate-pulse"})]})]})})}),D&&r.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${L?"opacity-100 visible":"opacity-0 invisible"}`,children:[r.jsx("button",{className:"fixed inset-0 bg-black/40 transition-opacity duration-150 ease-out",onClick:I=>{I.stopPropagation(),q(!1)},onTouchStart:I=>{I.preventDefault(),I.stopPropagation(),q(!1)},"aria-label":s("versionUpdate.ariaLabels.closeSidebar")}),r.jsx("div",{className:`chat-sidebar relative h-full w-[85vw] max-w-sm bg-white shadow-xl transform dark:bg-background sm:w-80 ${L?"translate-x-0":"-translate-x-full"}`,onClick:I=>I.stopPropagation(),onTouchStart:I=>I.stopPropagation(),children:r.jsx(wl,{projects:p,selectedProject:h,selectedSession:x,onProjectSelect:X,onSessionSelect:C,onNewSession:F,onSessionDelete:ie,onProjectDelete:dt,isLoading:P,loadingProgress:ge,onRefresh:be,onShowSettings:()=>Ie(!0),updateAvailable:o,latestVersion:a,currentVersion:i,releaseInfo:c,onShowVersionModal:()=>u(!0),isPWA:Ot,isMobile:D,onToggleSidebar:()=>$e(!1),lockedProjectName:Ue,showNewProject:ft,setShowNewProject:at})})]}),r.jsx("div",{className:"chat-shell flex-1 flex min-w-0 flex-col overflow-hidden ",children:r.jsx(Ub,{selectedProject:h,selectedSession:x,activeTab:T,setActiveTab:w,ws:Pt,sendMessage:ht,latestMessage:Ct,isMobile:D,isPWA:Ot,onMenuClick:()=>q(!0),isLoading:P,onInputFocusChange:V,onSessionActive:W,onSessionInactive:Et,onSessionProcessing:$,onSessionNotProcessing:z,processingSessions:yt,onReplaceTemporarySession:ne,onNavigateToSession:I=>Nt(`/session/${I}`),onShowSettings:()=>Ie(!0),autoExpandTools:O,showRawParameters:B,showThinking:ke,autoScrollToBottom:R,sendByCtrlEnter:Fe,externalMessageUpdate:_t,urlProvider:_e,urlModel:et,urlContext:tt,urlPrompt:Je,integrationClientId:ue,latestIntegrationMessage:tr,sendIntegrationMessage:Xe,onShowNewProject:()=>at(!0),onNewSession:F,newSessionResetNonce:k})}),b,T==="chat"&&r.jsx(Kb,{isOpen:U,onToggle:fe,autoExpandTools:O,onAutoExpandChange:S,showRawParameters:B,onShowRawParametersChange:Z,showThinking:ke,onShowThinkingChange:ve,autoScrollToBottom:R,onAutoScrollChange:re,sendByCtrlEnter:Fe,onSendByCtrlEnterChange:Ce,isMobile:D}),r.jsx(Gb,{isOpen:xe,onClose:()=>Ie(!1),projects:p,initialTab:qe}),r.jsx(Re,{})]})}function bw(){return r.jsx(Jm,{i18n:tf,children:r.jsx(Ym,{children:r.jsx(Jb,{children:r.jsx(Zb,{children:r.jsx(nw,{children:r.jsx(hm,{basename:window.__ROUTER_BASENAME__||"",children:r.jsxs(gm,{children:[r.jsx(Qo,{path:"/",element:r.jsx(Cc,{})}),r.jsx(Qo,{path:"/session/:sessionId",element:r.jsx(Cc,{})}),r.jsx(Qo,{path:"/review",element:r.jsx(Xm,{})})]})})})})})})})}export{bw as default};