@axhub/genie 0.2.2 → 0.2.3

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 (72) hide show
  1. package/dist/assets/App-Ddoy7BIl.js +484 -0
  2. package/dist/assets/{ReviewApp-Bp_y3xff.js → ReviewApp-DOAHmxVe.js} +1 -1
  3. package/dist/assets/{_basePickBy-C5f221Kr.js → _basePickBy-CAs6HGVw.js} +1 -1
  4. package/dist/assets/{_baseUniq-CeEXFlBh.js → _baseUniq-qvm36g_v.js} +1 -1
  5. package/dist/assets/{arc-CZVQXROF.js → arc-60yKSsVt.js} +1 -1
  6. package/dist/assets/{architectureDiagram-2XIMDMQ5-D91MBXeh.js → architectureDiagram-2XIMDMQ5-C5Ik86xM.js} +1 -1
  7. package/dist/assets/{blockDiagram-WCTKOSBZ-CsHP3zT2.js → blockDiagram-WCTKOSBZ-CGqfB5z7.js} +1 -1
  8. package/dist/assets/{c4Diagram-IC4MRINW-DakKlk21.js → c4Diagram-IC4MRINW-C02h4qfL.js} +1 -1
  9. package/dist/assets/channel-B3JUshOm.js +1 -0
  10. package/dist/assets/{chunk-4BX2VUAB-BXZoxrtv.js → chunk-4BX2VUAB-BVVwu3tU.js} +1 -1
  11. package/dist/assets/{chunk-55IACEB6-V9_WXk3w.js → chunk-55IACEB6-Dyehrd1R.js} +1 -1
  12. package/dist/assets/{chunk-FMBD7UC4-IgdHo6Dd.js → chunk-FMBD7UC4-ByEz0wOl.js} +1 -1
  13. package/dist/assets/{chunk-JSJVCQXG-CnaAsDTd.js → chunk-JSJVCQXG-BXHZvm_e.js} +1 -1
  14. package/dist/assets/{chunk-KX2RTZJC-D0qksU2H.js → chunk-KX2RTZJC-DJPATr22.js} +1 -1
  15. package/dist/assets/{chunk-NQ4KR5QH-rd6KG4-c.js → chunk-NQ4KR5QH-RgZbucc4.js} +1 -1
  16. package/dist/assets/{chunk-QZHKN3VN-Cyltgv4l.js → chunk-QZHKN3VN-DMIXCLGh.js} +1 -1
  17. package/dist/assets/{chunk-WL4C6EOR-DkNtSo86.js → chunk-WL4C6EOR-Bg4bzqqP.js} +1 -1
  18. package/dist/assets/classDiagram-VBA2DB6C-DZEYhtwP.js +1 -0
  19. package/dist/assets/classDiagram-v2-RAHNMMFH-DZEYhtwP.js +1 -0
  20. package/dist/assets/clone-B2sPtF_O.js +1 -0
  21. package/dist/assets/{cose-bilkent-S5V4N54A-D_Wsd3iv.js → cose-bilkent-S5V4N54A-BZeDiX7Y.js} +1 -1
  22. package/dist/assets/{dagre-KLK3FWXG-CrrmZeGu.js → dagre-KLK3FWXG-BrwI_1JI.js} +1 -1
  23. package/dist/assets/{diagram-E7M64L7V-WzO26pGn.js → diagram-E7M64L7V-CxAlKNFG.js} +1 -1
  24. package/dist/assets/{diagram-IFDJBPK2-COynsdO3.js → diagram-IFDJBPK2-VClYIYo3.js} +1 -1
  25. package/dist/assets/{diagram-P4PSJMXO-CSqD5HJx.js → diagram-P4PSJMXO-CYRL57cP.js} +1 -1
  26. package/dist/assets/{erDiagram-INFDFZHY-BiFhS6xi.js → erDiagram-INFDFZHY-ZySJDqNG.js} +1 -1
  27. package/dist/assets/{flowDiagram-PKNHOUZH-9jdAJSs0.js → flowDiagram-PKNHOUZH-Ct9-q2zS.js} +1 -1
  28. package/dist/assets/{ganttDiagram-A5KZAMGK-pGyMKWCo.js → ganttDiagram-A5KZAMGK-Qn4VUvVR.js} +1 -1
  29. package/dist/assets/{gitGraphDiagram-K3NZZRJ6-D4jvwoW1.js → gitGraphDiagram-K3NZZRJ6-CaveIlg3.js} +1 -1
  30. package/dist/assets/{graph-DMknFkkX.js → graph-B1tvcjpq.js} +1 -1
  31. package/dist/assets/{highlighted-body-TPN3WLV5-DhMGh1O7.js → highlighted-body-TPN3WLV5-Cx4aCKGT.js} +1 -1
  32. package/dist/assets/index-BFX9lxRB.css +1 -0
  33. package/dist/assets/index-Q-dfaLIv.js +2 -0
  34. package/dist/assets/{infoDiagram-LFFYTUFH-CP5zYiVP.js → infoDiagram-LFFYTUFH-FNMZEktA.js} +1 -1
  35. package/dist/assets/{ishikawaDiagram-PHBUUO56-BplLZAQ5.js → ishikawaDiagram-PHBUUO56-D9db2Pov.js} +1 -1
  36. package/dist/assets/{journeyDiagram-4ABVD52K-CYVgkl-y.js → journeyDiagram-4ABVD52K-BzYKMYOM.js} +1 -1
  37. package/dist/assets/{kanban-definition-K7BYSVSG-D3on0q66.js → kanban-definition-K7BYSVSG-qC9Xmf0j.js} +1 -1
  38. package/dist/assets/{layout-DoKWZNVk.js → layout-dbzqH_4Q.js} +1 -1
  39. package/dist/assets/{linear-D4YTLdon.js → linear-HOAktq-3.js} +1 -1
  40. package/dist/assets/{mermaid-O7DHMXV3-KLW3VWsF.js → mermaid-O7DHMXV3-CazKksAH.js} +5 -5
  41. package/dist/assets/{mindmap-definition-YRQLILUH-EEAggxM3.js → mindmap-definition-YRQLILUH-DlfKip6Z.js} +1 -1
  42. package/dist/assets/{pieDiagram-SKSYHLDU-Da-_fmYg.js → pieDiagram-SKSYHLDU-BYv9DU8d.js} +1 -1
  43. package/dist/assets/{quadrantDiagram-337W2JSQ-Dq4gr7Sw.js → quadrantDiagram-337W2JSQ-l21TFCGi.js} +1 -1
  44. package/dist/assets/{requirementDiagram-Z7DCOOCP-DNSXyCNU.js → requirementDiagram-Z7DCOOCP-DwM1YiVc.js} +1 -1
  45. package/dist/assets/{sankeyDiagram-WA2Y5GQK-CT4ST2HW.js → sankeyDiagram-WA2Y5GQK-DaSSXYkb.js} +1 -1
  46. package/dist/assets/{sequenceDiagram-2WXFIKYE-CshVYjrF.js → sequenceDiagram-2WXFIKYE-BPBhAefs.js} +1 -1
  47. package/dist/assets/{stateDiagram-RAJIS63D-hsG5Yi2A.js → stateDiagram-RAJIS63D-Cs4xILlc.js} +1 -1
  48. package/dist/assets/stateDiagram-v2-FVOUBMTO-DeUj7MLk.js +1 -0
  49. package/dist/assets/{timeline-definition-YZTLITO2-EztFFK5F.js → timeline-definition-YZTLITO2-BPnQPJ2R.js} +1 -1
  50. package/dist/assets/{treemap-KZPCXAKY-D5UZCcq_.js → treemap-KZPCXAKY-BRWkr5mn.js} +1 -1
  51. package/dist/assets/{vennDiagram-LZ73GAT5-9Qwv8UTR.js → vennDiagram-LZ73GAT5-DioBg_XD.js} +1 -1
  52. package/dist/assets/{xychartDiagram-JWTSCODW-BBjpC1Qv.js → xychartDiagram-JWTSCODW-Bh2R2Uzh.js} +1 -1
  53. package/dist/index.html +2 -2
  54. package/package.json +2 -2
  55. package/server/database/db.js +0 -45
  56. package/server/external-agent/service.js +39 -490
  57. package/server/external-agent/service.test.js +12 -0
  58. package/server/index.js +21 -43
  59. package/server/middleware/auth.js +15 -1
  60. package/server/routes/agent.js +15 -1136
  61. package/server/routes/cli-auth.js +60 -52
  62. package/server/routes/projects.js +10 -304
  63. package/server/routes/settings.js +4 -0
  64. package/server/routes/user.js +0 -102
  65. package/dist/assets/App-Cay5kE3A.js +0 -504
  66. package/dist/assets/channel-CnzaP2H9.js +0 -1
  67. package/dist/assets/classDiagram-VBA2DB6C-CUcYxMZ8.js +0 -1
  68. package/dist/assets/classDiagram-v2-RAHNMMFH-CUcYxMZ8.js +0 -1
  69. package/dist/assets/clone-DJXJGSg2.js +0 -1
  70. package/dist/assets/index-2198VgsK.css +0 -1
  71. package/dist/assets/index-EMGPq9Uy.js +0 -2
  72. package/dist/assets/stateDiagram-v2-FVOUBMTO-BQa1Ppoo.js +0 -1
@@ -1,504 +0,0 @@
1
- import{j as t,S as Qn,F as to,T as Ac,P as _c,E as fr,V as ro,a as Ya,g as Xp,D as Rr,R as Ws,G as Xa,W as Qa,l as Mc,h as ba,b as Dc,C as Qp,c as Zp,d as em,e as In,f as tm,i as rm,u as nm,k as cl,s as sm,m as om,n as am,o as im,p as lm,q as cm,r as dm,t as um,v as pm,w as mm,x as fm,y as hm}from"./vendor-codemirror-Dz7_EqNA.js";import{a as i,c as gm,R as dn,d as Qo,g as Rc,B as xm,e as ym,f as Zo,u as vm,h as bm,i as wm}from"./vendor-react-Cpt6D04s.js";import{bJ as Ie,bK as tr,bL as wa,bM as un,bN as Pc,bO as Us,bP as Fe,bQ as no,bR as Za,bS as vr,bT as Lc,bU as km,bV as jm,bW as Nm,bX as Sm,bY as Cm,bZ as Em,b_ as Im,b$ as Tm,c0 as Am,c1 as _m,c2 as Mm,c3 as ut,c4 as ei,c5 as Lt,c6 as Gt,c7 as Dm,c8 as _e,c9 as qr,ca as sn,cb as Ar,cc as pn,cd as ti,ce as Oc,cf as Rm,cg as Pm,ch as Lm,ci as Om,cj as Fm,ck as dl,cl as ul,cm as pl,cn as ea,co as $m,cp as zm,cq as Bm,cr as Wm,cs as Um,ct as Hm,cu as Gm,cv as qm,cw as Km,cx as Vm,cy as Fc,cz as ri,cA as Jm,cB as Ym,I as Xm,T as Qm,U as Zm}from"./mermaid-O7DHMXV3-KLW3VWsF.js";import{r as ef,a as tf,b as rf}from"./vendor-xterm-DfaPXD3y.js";import{l as ml,i as nf}from"./index-EMGPq9Uy.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 sf=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],of=Ie("arrow-down",sf);/**
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 af=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ni=Ie("chevron-left",af);/**
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 lf=[["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=Ie("download",lf);/**
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 cf=[["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"}]],js=Ie("ellipsis",cf);/**
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 df=[["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=Ie("external-link",df);/**
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 uf=[["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"}]],si=Ie("eye",uf);/**
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 pf=[["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"}]],$c=Ie("eye-off",pf);/**
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 mf=[["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"}]],ff=Ie("file-pen-line",mf);/**
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 hf=[["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"}]],gf=Ie("file-plus-2",hf);/**
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 xf=[["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"}]],yf=Ie("file-search",xf);/**
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"}]],oi=Ie("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 bf=[["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"}]],on=Ie("folder-open",bf);/**
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 wf=[["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"}]],Sn=Ie("folder-plus",wf);/**
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 kf=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ta=Ie("folder",kf);/**
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 jf=[["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"}]],Kr=Ie("git-branch",jf);/**
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 Nf=[["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=Ie("git-commit-horizontal",Nf);/**
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=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],Cf=Ie("github",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 Ef=[["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"}]],fl=Ie("globe",Ef);/**
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 If=[["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"}]],Tf=Ie("grip-vertical",If);/**
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 Af=[["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"}]],hl=Ie("history",Af);/**
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 _f=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Mf=Ie("info",_f);/**
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 Df=[["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"}]],ai=Ie("key",Df);/**
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 Rf=[["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"}]],zc=Ie("languages",Rf);/**
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 Pf=[["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"}]],gl=Ie("list-todo",Pf);/**
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 Lf=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],Of=Ie("log-in",Lf);/**
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 Ff=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],$f=Ie("mail",Ff);/**
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 zf=[["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=Ie("maximize-2",zf);/**
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 Bf=[["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"}]],Wf=Ie("message-square-plus",Bf);/**
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 Uf=[["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=Ie("message-square",Uf);/**
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 Hf=[["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"}]],Bs=Ie("mic",Hf);/**
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 Gf=[["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"}]],qf=Ie("minimize-2",Gf);/**
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 Kf=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],Na=Ie("moon",Kf);/**
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 Vf=[["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"}]],xl=Ie("pen-line",Vf);/**
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 Jf=[["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"}]],yl=Ie("pen",Jf);/**
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 Yf=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ln=Ie("plus",Yf);/**
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 Xf=[["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"}]],Tr=Ie("refresh-cw",Xf);/**
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 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"}]],Zf=Ie("save",Qf);/**
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 eh=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Sa=Ie("search",eh);/**
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 th=[["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"}]],rh=Ie("server",th);/**
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 nh=[["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"}]],Wc=Ie("settings",nh);/**
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 sh=[["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"}]],oh=Ie("settings-2",sh);/**
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 ah=[["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"}]],ih=Ie("square-terminal",ah);/**
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 lh=[["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"}]],vl=Ie("star",lh);/**
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 ch=[["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=Ie("sun",ch);/**
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 dh=[["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"}]],ir=Ie("trash-2",dh);/**
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 uh=[["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=Ie("triangle-alert",uh);/**
232
- * @license lucide-react v0.515.0 - ISC
233
- *
234
- * This source code is licensed under the ISC license.
235
- * See the LICENSE file in the root directory of this source tree.
236
- */const ph=[["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"}]],Ns=Ie("upload",ph);/**
237
- * @license lucide-react v0.515.0 - ISC
238
- *
239
- * This source code is licensed under the ISC license.
240
- * See the LICENSE file in the root directory of this source tree.
241
- */const mh=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],fh=Ie("user",mh);/**
242
- * @license lucide-react v0.515.0 - ISC
243
- *
244
- * This source code is licensed under the ISC license.
245
- * See the LICENSE file in the root directory of this source tree.
246
- */const hh=[["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"}]],gh=Ie("wrench",hh);/**
247
- * @license lucide-react v0.515.0 - ISC
248
- *
249
- * This source code is licensed under the ISC license.
250
- * See the LICENSE file in the root directory of this source tree.
251
- */const xh=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],lr=Ie("x",xh);function yh(e,r){return i.useReducer((n,s)=>r[n][s]??n,e)}var kr=e=>{const{present:r,children:n}=e,s=vh(r),o=typeof n=="function"?n({present:s.isPresent}):i.Children.only(n),a=tr(s.ref,bh(o));return typeof n=="function"||s.isPresent?i.cloneElement(o,{ref:a}):null};kr.displayName="Presence";function vh(e){const[r,n]=i.useState(),s=i.useRef(null),o=i.useRef(e),a=i.useRef("none"),l=e?"mounted":"unmounted",[c,d]=yh(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const u=Ss(s.current);a.current=c==="mounted"?u:"none"},[c]),wa(()=>{const u=s.current,m=o.current;if(m!==e){const h=a.current,g=Ss(u);e?d("MOUNT"):g==="none"||u?.display==="none"?d("UNMOUNT"):d(m&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),wa(()=>{if(r){let u;const m=r.ownerDocument.defaultView??window,p=g=>{const k=Ss(s.current).includes(CSS.escape(g.animationName));if(g.target===r&&k&&(d("ANIMATION_END"),!o.current)){const w=r.style.animationFillMode;r.style.animationFillMode="forwards",u=m.setTimeout(()=>{r.style.animationFillMode==="forwards"&&(r.style.animationFillMode=w)})}},h=g=>{g.target===r&&(a.current=Ss(s.current))};return r.addEventListener("animationstart",h),r.addEventListener("animationcancel",p),r.addEventListener("animationend",p),()=>{m.clearTimeout(u),r.removeEventListener("animationstart",h),r.removeEventListener("animationcancel",p),r.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[r,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:i.useCallback(u=>{s.current=u?getComputedStyle(u):null,n(u)},[])}}function Ss(e){return e?.animationName||"none"}function bh(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function wh(e,r=[]){let n=[];function s(a,l){const c=i.createContext(l),d=n.length;n=[...n,l];const u=p=>{const{scope:h,children:g,...x}=p,k=h?.[e]?.[d]||c,w=i.useMemo(()=>x,Object.values(x));return t.jsx(k.Provider,{value:w,children:g})};u.displayName=a+"Provider";function m(p,h){const g=h?.[e]?.[d]||c,x=i.useContext(g);if(x)return x;if(l!==void 0)return l;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const o=()=>{const a=n.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,kh(o,...r)]}function kh(...e){const r=e[0];if(e.length===1)return r;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const l=s.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return i.useMemo(()=>({[`__scope${r.scopeName}`]:l}),[l])}};return n.scopeName=r.scopeName,n}function Uc(e){const r=jh(e),n=i.forwardRef((s,o)=>{const{children:a,...l}=s,c=i.Children.toArray(a),d=c.find(Sh);if(d){const u=d.props.children,m=c.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return t.jsx(r,{...l,ref:o,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return t.jsx(r,{...l,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function jh(e){const r=i.forwardRef((n,s)=>{const{children:o,...a}=n;if(i.isValidElement(o)){const l=Eh(o),c=Ch(a,o.props);return o.type!==i.Fragment&&(c.ref=s?un(s,l):l),i.cloneElement(o,c)}return i.Children.count(o)>1?i.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var Nh=Symbol("radix.slottable");function Sh(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Nh}function Ch(e,r){const n={...r};for(const s in r){const o=e[s],a=r[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 Eh(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Ih=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Zn=Ih.reduce((e,r)=>{const n=Uc(`Primitive.${r}`),s=i.forwardRef((o,a)=>{const{asChild:l,...c}=o,d=l?n:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${r}`,{...e,[r]:s}},{});function Th(e,r){e&&gm.flushSync(()=>e.dispatchEvent(r))}function Ah(e,r=[]){let n=[];function s(a,l){const c=i.createContext(l),d=n.length;n=[...n,l];const u=p=>{const{scope:h,children:g,...x}=p,k=h?.[e]?.[d]||c,w=i.useMemo(()=>x,Object.values(x));return t.jsx(k.Provider,{value:w,children:g})};u.displayName=a+"Provider";function m(p,h){const g=h?.[e]?.[d]||c,x=i.useContext(g);if(x)return x;if(l!==void 0)return l;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const o=()=>{const a=n.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,_h(o,...r)]}function _h(...e){const r=e[0];if(e.length===1)return r;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const l=s.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return i.useMemo(()=>({[`__scope${r.scopeName}`]:l}),[l])}};return n.scopeName=r.scopeName,n}function Mh(e){const r=Dh(e),n=i.forwardRef((s,o)=>{const{children:a,...l}=s,c=i.Children.toArray(a),d=c.find(Ph);if(d){const u=d.props.children,m=c.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return t.jsx(r,{...l,ref:o,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return t.jsx(r,{...l,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Dh(e){const r=i.forwardRef((n,s)=>{const{children:o,...a}=n;if(i.isValidElement(o)){const l=Oh(o),c=Lh(a,o.props);return o.type!==i.Fragment&&(c.ref=s?un(s,l):l),i.cloneElement(o,c)}return i.Children.count(o)>1?i.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var Rh=Symbol("radix.slottable");function Ph(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Rh}function Lh(e,r){const n={...r};for(const s in r){const o=e[s],a=r[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 Oh(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Fh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Hc=Fh.reduce((e,r)=>{const n=Mh(`Primitive.${r}`),s=i.forwardRef((o,a)=>{const{asChild:l,...c}=o,d=l?n:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${r}`,{...e,[r]:s}},{}),na="rovingFocusGroup.onEntryFocus",$h={bubbles:!1,cancelable:!0},es="RovingFocusGroup",[Ia,Gc,zh]=Pc(es),[Bh,so]=Ah(es,[zh]),[Wh,Uh]=Bh(es),qc=i.forwardRef((e,r)=>t.jsx(Ia.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Ia.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Hh,{...e,ref:r})})}));qc.displayName=es;var Hh=i.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:a,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:m=!1,...p}=e,h=i.useRef(null),g=tr(r,h),x=no(a),[k,w]=Za({prop:l,defaultProp:c??null,onChange:d,caller:es}),[A,L]=i.useState(!1),j=vr(u),S=Gc(n),D=i.useRef(!1),[b,I]=i.useState(0);return i.useEffect(()=>{const G=h.current;if(G)return G.addEventListener(na,j),()=>G.removeEventListener(na,j)},[j]),t.jsx(Wh,{scope:n,orientation:s,dir:x,loop:o,currentTabStopId:k,onItemFocus:i.useCallback(G=>w(G),[w]),onItemShiftTab:i.useCallback(()=>L(!0),[]),onFocusableItemAdd:i.useCallback(()=>I(G=>G+1),[]),onFocusableItemRemove:i.useCallback(()=>I(G=>G-1),[]),children:t.jsx(Hc.div,{tabIndex:A||b===0?-1:0,"data-orientation":s,...p,ref:g,style:{outline:"none",...e.style},onMouseDown:Fe(e.onMouseDown,()=>{D.current=!0}),onFocus:Fe(e.onFocus,G=>{const P=!D.current;if(G.target===G.currentTarget&&P&&!A){const V=new CustomEvent(na,$h);if(G.currentTarget.dispatchEvent(V),!V.defaultPrevented){const ve=S().filter(se=>se.focusable),ae=ve.find(se=>se.active),R=ve.find(se=>se.id===k),de=[ae,R,...ve].filter(Boolean).map(se=>se.ref.current);Jc(de,m)}}D.current=!1}),onBlur:Fe(e.onBlur,()=>L(!1))})})}),Kc="RovingFocusGroupItem",Vc=i.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:l,...c}=e,d=Us(),u=a||d,m=Uh(Kc,n),p=m.currentTabStopId===u,h=Gc(n),{onFocusableItemAdd:g,onFocusableItemRemove:x,currentTabStopId:k}=m;return i.useEffect(()=>{if(s)return g(),()=>x()},[s,g,x]),t.jsx(Ia.ItemSlot,{scope:n,id:u,focusable:s,active:o,children:t.jsx(Hc.span,{tabIndex:p?0:-1,"data-orientation":m.orientation,...c,ref:r,onMouseDown:Fe(e.onMouseDown,w=>{s?m.onItemFocus(u):w.preventDefault()}),onFocus:Fe(e.onFocus,()=>m.onItemFocus(u)),onKeyDown:Fe(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){m.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const A=Kh(w,m.orientation,m.dir);if(A!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let j=h().filter(S=>S.focusable).map(S=>S.ref.current);if(A==="last")j.reverse();else if(A==="prev"||A==="next"){A==="prev"&&j.reverse();const S=j.indexOf(w.currentTarget);j=m.loop?Vh(j,S+1):j.slice(S+1)}setTimeout(()=>Jc(j))}}),children:typeof l=="function"?l({isCurrentTabStop:p,hasTabStop:k!=null}):l})})});Vc.displayName=Kc;var Gh={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function qh(e,r){return r!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Kh(e,r,n){const s=qh(e.key,n);if(!(r==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(r==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Gh[s]}function Jc(e,r=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:r}),document.activeElement!==n))return}function Vh(e,r){return e.map((n,s)=>e[(r+s)%e.length])}var Yc=qc,Xc=Vc,Ta=["Enter"," "],Jh=["ArrowDown","PageUp","Home"],Qc=["ArrowUp","PageDown","End"],Yh=[...Jh,...Qc],Xh={ltr:[...Ta,"ArrowRight"],rtl:[...Ta,"ArrowLeft"]},Qh={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ts="Menu",[Jn,Zh,eg]=Pc(ts),[mn,Zc]=wh(ts,[eg,Lc,so]),oo=Lc(),ed=so(),[tg,fn]=mn(ts),[rg,rs]=mn(ts),td=e=>{const{__scopeMenu:r,open:n=!1,children:s,dir:o,onOpenChange:a,modal:l=!0}=e,c=oo(r),[d,u]=i.useState(null),m=i.useRef(!1),p=vr(a),h=no(o);return i.useEffect(()=>{const g=()=>{m.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>m.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})}},[]),t.jsx(km,{...c,children:t.jsx(tg,{scope:r,open:n,onOpenChange:p,content:d,onContentChange:u,children:t.jsx(rg,{scope:r,onClose:i.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:m,dir:h,modal:l,children:s})})})};td.displayName=ts;var ng="MenuAnchor",ii=i.forwardRef((e,r)=>{const{__scopeMenu:n,...s}=e,o=oo(n);return t.jsx(jm,{...o,...s,ref:r})});ii.displayName=ng;var li="MenuPortal",[sg,rd]=mn(li,{forceMount:void 0}),nd=e=>{const{__scopeMenu:r,forceMount:n,children:s,container:o}=e,a=fn(li,r);return t.jsx(sg,{scope:r,forceMount:n,children:t.jsx(kr,{present:n||a.open,children:t.jsx(Nm,{asChild:!0,container:o,children:s})})})};nd.displayName=li;var cr="MenuContent",[og,ci]=mn(cr),sd=i.forwardRef((e,r)=>{const n=rd(cr,e.__scopeMenu),{forceMount:s=n.forceMount,...o}=e,a=fn(cr,e.__scopeMenu),l=rs(cr,e.__scopeMenu);return t.jsx(Jn.Provider,{scope:e.__scopeMenu,children:t.jsx(kr,{present:s||a.open,children:t.jsx(Jn.Slot,{scope:e.__scopeMenu,children:l.modal?t.jsx(ag,{...o,ref:r}):t.jsx(ig,{...o,ref:r})})})})}),ag=i.forwardRef((e,r)=>{const n=fn(cr,e.__scopeMenu),s=i.useRef(null),o=tr(r,s);return i.useEffect(()=>{const a=s.current;if(a)return Sm(a)},[]),t.jsx(di,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Fe(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),ig=i.forwardRef((e,r)=>{const n=fn(cr,e.__scopeMenu);return t.jsx(di,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),lg=Uc("MenuContent.ScrollLock"),di=i.forwardRef((e,r)=>{const{__scopeMenu:n,loop:s=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:h,onDismiss:g,disableOutsideScroll:x,...k}=e,w=fn(cr,n),A=rs(cr,n),L=oo(n),j=ed(n),S=Zh(n),[D,b]=i.useState(null),I=i.useRef(null),G=tr(r,I,w.onContentChange),P=i.useRef(0),V=i.useRef(""),ve=i.useRef(0),ae=i.useRef(null),R=i.useRef("right"),q=i.useRef(0),de=x?Em:i.Fragment,se=x?{as:lg,allowPinchZoom:!0}:void 0,he=B=>{const z=V.current+B,_=S().filter(re=>!re.disabled),N=document.activeElement,O=_.find(re=>re.ref.current===N)?.textValue,ne=_.map(re=>re.textValue),Ce=bg(ne,z,O),be=_.find(re=>re.textValue===Ce)?.ref.current;(function re(Ee){V.current=Ee,window.clearTimeout(P.current),Ee!==""&&(P.current=window.setTimeout(()=>re(""),1e3))})(z),be&&setTimeout(()=>be.focus())};i.useEffect(()=>()=>window.clearTimeout(P.current),[]),Cm();const Se=i.useCallback(B=>R.current===ae.current?.side&&kg(B,ae.current?.area),[]);return t.jsx(og,{scope:n,searchRef:V,onItemEnter:i.useCallback(B=>{Se(B)&&B.preventDefault()},[Se]),onItemLeave:i.useCallback(B=>{Se(B)||(I.current?.focus(),b(null))},[Se]),onTriggerLeave:i.useCallback(B=>{Se(B)&&B.preventDefault()},[Se]),pointerGraceTimerRef:ve,onPointerGraceIntentChange:i.useCallback(B=>{ae.current=B},[]),children:t.jsx(de,{...se,children:t.jsx(Im,{asChild:!0,trapped:o,onMountAutoFocus:Fe(a,B=>{B.preventDefault(),I.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:t.jsx(Tm,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:h,onDismiss:g,children:t.jsx(Yc,{asChild:!0,...j,dir:A.dir,orientation:"vertical",loop:s,currentTabStopId:D,onCurrentTabStopIdChange:b,onEntryFocus:Fe(d,B=>{A.isUsingKeyboardRef.current||B.preventDefault()}),preventScrollOnEntryFocus:!0,children:t.jsx(Am,{role:"menu","aria-orientation":"vertical","data-state":bd(w.open),"data-radix-menu-content":"",dir:A.dir,...L,...k,ref:G,style:{outline:"none",...k.style},onKeyDown:Fe(k.onKeyDown,B=>{const _=B.target.closest("[data-radix-menu-content]")===B.currentTarget,N=B.ctrlKey||B.altKey||B.metaKey,O=B.key.length===1;_&&(B.key==="Tab"&&B.preventDefault(),!N&&O&&he(B.key));const ne=I.current;if(B.target!==ne||!Yh.includes(B.key))return;B.preventDefault();const be=S().filter(re=>!re.disabled).map(re=>re.ref.current);Qc.includes(B.key)&&be.reverse(),yg(be)}),onBlur:Fe(e.onBlur,B=>{B.currentTarget.contains(B.target)||(window.clearTimeout(P.current),V.current="")}),onPointerMove:Fe(e.onPointerMove,Yn(B=>{const z=B.target,_=q.current!==B.clientX;if(B.currentTarget.contains(z)&&_){const N=B.clientX>q.current?"right":"left";R.current=N,q.current=B.clientX}}))})})})})})})});sd.displayName=cr;var cg="MenuGroup",ui=i.forwardRef((e,r)=>{const{__scopeMenu:n,...s}=e;return t.jsx(Zn.div,{role:"group",...s,ref:r})});ui.displayName=cg;var dg="MenuLabel",od=i.forwardRef((e,r)=>{const{__scopeMenu:n,...s}=e;return t.jsx(Zn.div,{...s,ref:r})});od.displayName=dg;var Hs="MenuItem",bl="menu.itemSelect",ao=i.forwardRef((e,r)=>{const{disabled:n=!1,onSelect:s,...o}=e,a=i.useRef(null),l=rs(Hs,e.__scopeMenu),c=ci(Hs,e.__scopeMenu),d=tr(r,a),u=i.useRef(!1),m=()=>{const p=a.current;if(!n&&p){const h=new CustomEvent(bl,{bubbles:!0,cancelable:!0});p.addEventListener(bl,g=>s?.(g),{once:!0}),Th(p,h),h.defaultPrevented?u.current=!1:l.onClose()}};return t.jsx(ad,{...o,ref:d,disabled:n,onClick:Fe(e.onClick,m),onPointerDown:p=>{e.onPointerDown?.(p),u.current=!0},onPointerUp:Fe(e.onPointerUp,p=>{u.current||p.currentTarget?.click()}),onKeyDown:Fe(e.onKeyDown,p=>{const h=c.searchRef.current!=="";n||h&&p.key===" "||Ta.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});ao.displayName=Hs;var ad=i.forwardRef((e,r)=>{const{__scopeMenu:n,disabled:s=!1,textValue:o,...a}=e,l=ci(Hs,n),c=ed(n),d=i.useRef(null),u=tr(r,d),[m,p]=i.useState(!1),[h,g]=i.useState("");return i.useEffect(()=>{const x=d.current;x&&g((x.textContent??"").trim())},[a.children]),t.jsx(Jn.ItemSlot,{scope:n,disabled:s,textValue:o??h,children:t.jsx(Xc,{asChild:!0,...c,focusable:!s,children:t.jsx(Zn.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...a,ref:u,onPointerMove:Fe(e.onPointerMove,Yn(x=>{s?l.onItemLeave(x):(l.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Fe(e.onPointerLeave,Yn(x=>l.onItemLeave(x))),onFocus:Fe(e.onFocus,()=>p(!0)),onBlur:Fe(e.onBlur,()=>p(!1))})})})}),ug="MenuCheckboxItem",id=i.forwardRef((e,r)=>{const{checked:n=!1,onCheckedChange:s,...o}=e;return t.jsx(pd,{scope:e.__scopeMenu,checked:n,children:t.jsx(ao,{role:"menuitemcheckbox","aria-checked":Gs(n)?"mixed":n,...o,ref:r,"data-state":mi(n),onSelect:Fe(o.onSelect,()=>s?.(Gs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});id.displayName=ug;var ld="MenuRadioGroup",[pg,mg]=mn(ld,{value:void 0,onValueChange:()=>{}}),cd=i.forwardRef((e,r)=>{const{value:n,onValueChange:s,...o}=e,a=vr(s);return t.jsx(pg,{scope:e.__scopeMenu,value:n,onValueChange:a,children:t.jsx(ui,{...o,ref:r})})});cd.displayName=ld;var dd="MenuRadioItem",ud=i.forwardRef((e,r)=>{const{value:n,...s}=e,o=mg(dd,e.__scopeMenu),a=n===o.value;return t.jsx(pd,{scope:e.__scopeMenu,checked:a,children:t.jsx(ao,{role:"menuitemradio","aria-checked":a,...s,ref:r,"data-state":mi(a),onSelect:Fe(s.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});ud.displayName=dd;var pi="MenuItemIndicator",[pd,fg]=mn(pi,{checked:!1}),md=i.forwardRef((e,r)=>{const{__scopeMenu:n,forceMount:s,...o}=e,a=fg(pi,n);return t.jsx(kr,{present:s||Gs(a.checked)||a.checked===!0,children:t.jsx(Zn.span,{...o,ref:r,"data-state":mi(a.checked)})})});md.displayName=pi;var hg="MenuSeparator",fd=i.forwardRef((e,r)=>{const{__scopeMenu:n,...s}=e;return t.jsx(Zn.div,{role:"separator","aria-orientation":"horizontal",...s,ref:r})});fd.displayName=hg;var gg="MenuArrow",hd=i.forwardRef((e,r)=>{const{__scopeMenu:n,...s}=e,o=oo(n);return t.jsx(_m,{...o,...s,ref:r})});hd.displayName=gg;var xg="MenuSub",[Cw,gd]=mn(xg),Un="MenuSubTrigger",xd=i.forwardRef((e,r)=>{const n=fn(Un,e.__scopeMenu),s=rs(Un,e.__scopeMenu),o=gd(Un,e.__scopeMenu),a=ci(Un,e.__scopeMenu),l=i.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=a,u={__scopeMenu:e.__scopeMenu},m=i.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return i.useEffect(()=>m,[m]),i.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),t.jsx(ii,{asChild:!0,...u,children:t.jsx(ad,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":bd(n.open),...e,ref:un(r,o.onTriggerChange),onClick:p=>{e.onClick?.(p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Fe(e.onPointerMove,Yn(p=>{a.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!l.current&&(a.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:Fe(e.onPointerLeave,Yn(p=>{m();const h=n.content?.getBoundingClientRect();if(h){const g=n.content?.dataset.side,x=g==="right",k=x?-5:5,w=h[x?"left":"right"],A=h[x?"right":"left"];a.onPointerGraceIntentChange({area:[{x:p.clientX+k,y:p.clientY},{x:w,y:h.top},{x:A,y:h.top},{x:A,y:h.bottom},{x:w,y:h.bottom}],side:g}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(p),p.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Fe(e.onKeyDown,p=>{const h=a.searchRef.current!=="";e.disabled||h&&p.key===" "||Xh[s.dir].includes(p.key)&&(n.onOpenChange(!0),n.content?.focus(),p.preventDefault())})})})});xd.displayName=Un;var yd="MenuSubContent",vd=i.forwardRef((e,r)=>{const n=rd(cr,e.__scopeMenu),{forceMount:s=n.forceMount,...o}=e,a=fn(cr,e.__scopeMenu),l=rs(cr,e.__scopeMenu),c=gd(yd,e.__scopeMenu),d=i.useRef(null),u=tr(r,d);return t.jsx(Jn.Provider,{scope:e.__scopeMenu,children:t.jsx(kr,{present:s||a.open,children:t.jsx(Jn.Slot,{scope:e.__scopeMenu,children:t.jsx(di,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:u,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{l.isUsingKeyboardRef.current&&d.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Fe(e.onFocusOutside,m=>{m.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:Fe(e.onEscapeKeyDown,m=>{l.onClose(),m.preventDefault()}),onKeyDown:Fe(e.onKeyDown,m=>{const p=m.currentTarget.contains(m.target),h=Qh[l.dir].includes(m.key);p&&h&&(a.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});vd.displayName=yd;function bd(e){return e?"open":"closed"}function Gs(e){return e==="indeterminate"}function mi(e){return Gs(e)?"indeterminate":e?"checked":"unchecked"}function yg(e){const r=document.activeElement;for(const n of e)if(n===r||(n.focus(),document.activeElement!==r))return}function vg(e,r){return e.map((n,s)=>e[(r+s)%e.length])}function bg(e,r,n){const o=r.length>1&&Array.from(r).every(u=>u===r[0])?r[0]:r,a=n?e.indexOf(n):-1;let l=vg(e,Math.max(a,0));o.length===1&&(l=l.filter(u=>u!==n));const d=l.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function wg(e,r){const{x:n,y:s}=e;let o=!1;for(let a=0,l=r.length-1;a<r.length;l=a++){const c=r[a],d=r[l],u=c.x,m=c.y,p=d.x,h=d.y;m>s!=h>s&&n<(p-u)*(s-m)/(h-m)+u&&(o=!o)}return o}function kg(e,r){if(!r)return!1;const n={x:e.clientX,y:e.clientY};return wg(n,r)}function Yn(e){return r=>r.pointerType==="mouse"?e(r):void 0}var jg=td,Ng=ii,Sg=nd,Cg=sd,Eg=ui,Ig=od,Tg=ao,Ag=id,_g=cd,Mg=ud,Dg=md,Rg=fd,Pg=hd,Lg=xd,Og=vd;function Fg(e,r=[]){let n=[];function s(a,l){const c=i.createContext(l),d=n.length;n=[...n,l];const u=p=>{const{scope:h,children:g,...x}=p,k=h?.[e]?.[d]||c,w=i.useMemo(()=>x,Object.values(x));return t.jsx(k.Provider,{value:w,children:g})};u.displayName=a+"Provider";function m(p,h){const g=h?.[e]?.[d]||c,x=i.useContext(g);if(x)return x;if(l!==void 0)return l;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const o=()=>{const a=n.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,$g(o,...r)]}function $g(...e){const r=e[0];if(e.length===1)return r;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const l=s.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return i.useMemo(()=>({[`__scope${r.scopeName}`]:l}),[l])}};return n.scopeName=r.scopeName,n}function zg(e){const r=Bg(e),n=i.forwardRef((s,o)=>{const{children:a,...l}=s,c=i.Children.toArray(a),d=c.find(Ug);if(d){const u=d.props.children,m=c.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return t.jsx(r,{...l,ref:o,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return t.jsx(r,{...l,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Bg(e){const r=i.forwardRef((n,s)=>{const{children:o,...a}=n;if(i.isValidElement(o)){const l=Gg(o),c=Hg(a,o.props);return o.type!==i.Fragment&&(c.ref=s?un(s,l):l),i.cloneElement(o,c)}return i.Children.count(o)>1?i.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var Wg=Symbol("radix.slottable");function Ug(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Wg}function Hg(e,r){const n={...r};for(const s in r){const o=e[s],a=r[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 Gg(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var qg=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Kg=qg.reduce((e,r)=>{const n=zg(`Primitive.${r}`),s=i.forwardRef((o,a)=>{const{asChild:l,...c}=o,d=l?n:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${r}`,{...e,[r]:s}},{}),io="DropdownMenu",[Vg,Ew]=Fg(io,[Zc]),Kt=Zc(),[Jg,wd]=Vg(io),kd=e=>{const{__scopeDropdownMenu:r,children:n,dir:s,open:o,defaultOpen:a,onOpenChange:l,modal:c=!0}=e,d=Kt(r),u=i.useRef(null),[m,p]=Za({prop:o,defaultProp:a??!1,onChange:l,caller:io});return t.jsx(Jg,{scope:r,triggerId:Us(),triggerRef:u,contentId:Us(),open:m,onOpenChange:p,onOpenToggle:i.useCallback(()=>p(h=>!h),[p]),modal:c,children:t.jsx(jg,{...d,open:m,onOpenChange:p,dir:s,modal:c,children:n})})};kd.displayName=io;var jd="DropdownMenuTrigger",Nd=i.forwardRef((e,r)=>{const{__scopeDropdownMenu:n,disabled:s=!1,...o}=e,a=wd(jd,n),l=Kt(n);return t.jsx(Ng,{asChild:!0,...l,children:t.jsx(Kg.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:un(r,a.triggerRef),onPointerDown:Fe(e.onPointerDown,c=>{!s&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:Fe(e.onKeyDown,c=>{s||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});Nd.displayName=jd;var Yg="DropdownMenuPortal",Sd=e=>{const{__scopeDropdownMenu:r,...n}=e,s=Kt(r);return t.jsx(Sg,{...s,...n})};Sd.displayName=Yg;var Cd="DropdownMenuContent",Ed=i.forwardRef((e,r)=>{const{__scopeDropdownMenu:n,...s}=e,o=wd(Cd,n),a=Kt(n),l=i.useRef(!1);return t.jsx(Cg,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...s,ref:r,onCloseAutoFocus:Fe(e.onCloseAutoFocus,c=>{l.current||o.triggerRef.current?.focus(),l.current=!1,c.preventDefault()}),onInteractOutside:Fe(e.onInteractOutside,c=>{const d=c.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,m=d.button===2||u;(!o.modal||m)&&(l.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)"}})});Ed.displayName=Cd;var Xg="DropdownMenuGroup",Qg=i.forwardRef((e,r)=>{const{__scopeDropdownMenu:n,...s}=e,o=Kt(n);return t.jsx(Eg,{...o,...s,ref:r})});Qg.displayName=Xg;var Zg="DropdownMenuLabel",ex=i.forwardRef((e,r)=>{const{__scopeDropdownMenu:n,...s}=e,o=Kt(n);return t.jsx(Ig,{...o,...s,ref:r})});ex.displayName=Zg;var tx="DropdownMenuItem",Id=i.forwardRef((e,r)=>{const{__scopeDropdownMenu:n,...s}=e,o=Kt(n);return t.jsx(Tg,{...o,...s,ref:r})});Id.displayName=tx;var rx="DropdownMenuCheckboxItem",nx=i.forwardRef((e,r)=>{const{__scopeDropdownMenu:n,...s}=e,o=Kt(n);return t.jsx(Ag,{...o,...s,ref:r})});nx.displayName=rx;var sx="DropdownMenuRadioGroup",ox=i.forwardRef((e,r)=>{const{__scopeDropdownMenu:n,...s}=e,o=Kt(n);return t.jsx(_g,{...o,...s,ref:r})});ox.displayName=sx;var ax="DropdownMenuRadioItem",ix=i.forwardRef((e,r)=>{const{__scopeDropdownMenu:n,...s}=e,o=Kt(n);return t.jsx(Mg,{...o,...s,ref:r})});ix.displayName=ax;var lx="DropdownMenuItemIndicator",cx=i.forwardRef((e,r)=>{const{__scopeDropdownMenu:n,...s}=e,o=Kt(n);return t.jsx(Dg,{...o,...s,ref:r})});cx.displayName=lx;var dx="DropdownMenuSeparator",Td=i.forwardRef((e,r)=>{const{__scopeDropdownMenu:n,...s}=e,o=Kt(n);return t.jsx(Rg,{...o,...s,ref:r})});Td.displayName=dx;var ux="DropdownMenuArrow",px=i.forwardRef((e,r)=>{const{__scopeDropdownMenu:n,...s}=e,o=Kt(n);return t.jsx(Pg,{...o,...s,ref:r})});px.displayName=ux;var mx="DropdownMenuSubTrigger",fx=i.forwardRef((e,r)=>{const{__scopeDropdownMenu:n,...s}=e,o=Kt(n);return t.jsx(Lg,{...o,...s,ref:r})});fx.displayName=mx;var hx="DropdownMenuSubContent",gx=i.forwardRef((e,r)=>{const{__scopeDropdownMenu:n,...s}=e,o=Kt(n);return t.jsx(Og,{...o,...s,ref:r,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)"}})});gx.displayName=hx;var Cs=kd,Es=Nd,Is=Sd,Ts=Ed,xr=Id,wl=Td;function xx(e){const r=yx(e),n=i.forwardRef((s,o)=>{const{children:a,...l}=s,c=i.Children.toArray(a),d=c.find(bx);if(d){const u=d.props.children,m=c.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return t.jsx(r,{...l,ref:o,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return t.jsx(r,{...l,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function yx(e){const r=i.forwardRef((n,s)=>{const{children:o,...a}=n;if(i.isValidElement(o)){const l=kx(o),c=wx(a,o.props);return o.type!==i.Fragment&&(c.ref=s?un(s,l):l),i.cloneElement(o,c)}return i.Children.count(o)>1?i.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var vx=Symbol("radix.slottable");function bx(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===vx}function wx(e,r){const n={...r};for(const s in r){const o=e[s],a=r[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 kx(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var jx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ns=jx.reduce((e,r)=>{const n=xx(`Primitive.${r}`),s=i.forwardRef((o,a)=>{const{asChild:l,...c}=o,d=l?n:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${r}`,{...e,[r]:s}},{});function Nx(e,r=[]){let n=[];function s(a,l){const c=i.createContext(l),d=n.length;n=[...n,l];const u=p=>{const{scope:h,children:g,...x}=p,k=h?.[e]?.[d]||c,w=i.useMemo(()=>x,Object.values(x));return t.jsx(k.Provider,{value:w,children:g})};u.displayName=a+"Provider";function m(p,h){const g=h?.[e]?.[d]||c,x=i.useContext(g);if(x)return x;if(l!==void 0)return l;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const o=()=>{const a=n.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,Sx(o,...r)]}function Sx(...e){const r=e[0];if(e.length===1)return r;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const l=s.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return i.useMemo(()=>({[`__scope${r.scopeName}`]:l}),[l])}};return n.scopeName=r.scopeName,n}function Cx(e,r){return i.useReducer((n,s)=>r[n][s]??n,e)}var fi="ScrollArea",[Ad,Iw]=Nx(fi),[Ex,ur]=Ad(fi),_d=i.forwardRef((e,r)=>{const{__scopeScrollArea:n,type:s="hover",dir:o,scrollHideDelay:a=600,...l}=e,[c,d]=i.useState(null),[u,m]=i.useState(null),[p,h]=i.useState(null),[g,x]=i.useState(null),[k,w]=i.useState(null),[A,L]=i.useState(0),[j,S]=i.useState(0),[D,b]=i.useState(!1),[I,G]=i.useState(!1),P=tr(r,ve=>d(ve)),V=no(o);return t.jsx(Ex,{scope:n,type:s,dir:V,scrollHideDelay:a,scrollArea:c,viewport:u,onViewportChange:m,content:p,onContentChange:h,scrollbarX:g,onScrollbarXChange:x,scrollbarXEnabled:D,onScrollbarXEnabledChange:b,scrollbarY:k,onScrollbarYChange:w,scrollbarYEnabled:I,onScrollbarYEnabledChange:G,onCornerWidthChange:L,onCornerHeightChange:S,children:t.jsx(ns.div,{dir:V,...l,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":A+"px","--radix-scroll-area-corner-height":j+"px",...e.style}})})});_d.displayName=fi;var Md="ScrollAreaViewport",Dd=i.forwardRef((e,r)=>{const{__scopeScrollArea:n,children:s,nonce:o,...a}=e,l=ur(Md,n),c=i.useRef(null),d=tr(r,c,l.onViewportChange);return t.jsxs(t.Fragment,{children:[t.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}),t.jsx(ns.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:t.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});Dd.displayName=Md;var jr="ScrollAreaScrollbar",Rd=i.forwardRef((e,r)=>{const{forceMount:n,...s}=e,o=ur(jr,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:l}=o,c=e.orientation==="horizontal";return i.useEffect(()=>(c?a(!0):l(!0),()=>{c?a(!1):l(!1)}),[c,a,l]),o.type==="hover"?t.jsx(Ix,{...s,ref:r,forceMount:n}):o.type==="scroll"?t.jsx(Tx,{...s,ref:r,forceMount:n}):o.type==="auto"?t.jsx(Pd,{...s,ref:r,forceMount:n}):o.type==="always"?t.jsx(hi,{...s,ref:r}):null});Rd.displayName=jr;var Ix=i.forwardRef((e,r)=>{const{forceMount:n,...s}=e,o=ur(jr,e.__scopeScrollArea),[a,l]=i.useState(!1);return i.useEffect(()=>{const c=o.scrollArea;let d=0;if(c){const u=()=>{window.clearTimeout(d),l(!0)},m=()=>{d=window.setTimeout(()=>l(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",u),c.addEventListener("pointerleave",m),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",u),c.removeEventListener("pointerleave",m)}}},[o.scrollArea,o.scrollHideDelay]),t.jsx(kr,{present:n||a,children:t.jsx(Pd,{"data-state":a?"visible":"hidden",...s,ref:r})})}),Tx=i.forwardRef((e,r)=>{const{forceMount:n,...s}=e,o=ur(jr,e.__scopeScrollArea),a=e.orientation==="horizontal",l=co(()=>d("SCROLL_END"),100),[c,d]=Cx("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 i.useEffect(()=>{if(c==="idle"){const u=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[c,o.scrollHideDelay,d]),i.useEffect(()=>{const u=o.viewport,m=a?"scrollLeft":"scrollTop";if(u){let p=u[m];const h=()=>{const g=u[m];p!==g&&(d("SCROLL"),l()),p=g};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,a,d,l]),t.jsx(kr,{present:n||c!=="hidden",children:t.jsx(hi,{"data-state":c==="hidden"?"hidden":"visible",...s,ref:r,onPointerEnter:Fe(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Fe(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Pd=i.forwardRef((e,r)=>{const n=ur(jr,e.__scopeScrollArea),{forceMount:s,...o}=e,[a,l]=i.useState(!1),c=e.orientation==="horizontal",d=co(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,m=n.viewport.offsetHeight<n.viewport.scrollHeight;l(c?u:m)}},10);return Tn(n.viewport,d),Tn(n.content,d),t.jsx(kr,{present:s||a,children:t.jsx(hi,{"data-state":a?"visible":"hidden",...o,ref:r})})}),hi=i.forwardRef((e,r)=>{const{orientation:n="vertical",...s}=e,o=ur(jr,e.__scopeScrollArea),a=i.useRef(null),l=i.useRef(0),[c,d]=i.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=zd(c.viewport,c.content),m={...s,sizes:c,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:h=>a.current=h,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:h=>l.current=h};function p(h,g){return Px(h,l.current,c,g)}return n==="horizontal"?t.jsx(Ax,{...m,ref:r,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollLeft,g=kl(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=p(h,o.dir))}}):n==="vertical"?t.jsx(_x,{...m,ref:r,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollTop,g=kl(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=p(h))}}):null}),Ax=i.forwardRef((e,r)=>{const{sizes:n,onSizesChange:s,...o}=e,a=ur(jr,e.__scopeScrollArea),[l,c]=i.useState(),d=i.useRef(null),u=tr(r,d,a.onScrollbarXChange);return i.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),t.jsx(Od,{"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":lo(n)+"px",...e.style},onThumbPointerDown:m=>e.onThumbPointerDown(m.x),onDragScroll:m=>e.onDragScroll(m.x),onWheelScroll:(m,p)=>{if(a.viewport){const h=a.viewport.scrollLeft+m.deltaX;e.onWheelScroll(h),Wd(h,p)&&m.preventDefault()}},onResize:()=>{d.current&&a.viewport&&l&&s({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Ks(l.paddingLeft),paddingEnd:Ks(l.paddingRight)}})}})}),_x=i.forwardRef((e,r)=>{const{sizes:n,onSizesChange:s,...o}=e,a=ur(jr,e.__scopeScrollArea),[l,c]=i.useState(),d=i.useRef(null),u=tr(r,d,a.onScrollbarYChange);return i.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),t.jsx(Od,{"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":lo(n)+"px",...e.style},onThumbPointerDown:m=>e.onThumbPointerDown(m.y),onDragScroll:m=>e.onDragScroll(m.y),onWheelScroll:(m,p)=>{if(a.viewport){const h=a.viewport.scrollTop+m.deltaY;e.onWheelScroll(h),Wd(h,p)&&m.preventDefault()}},onResize:()=>{d.current&&a.viewport&&l&&s({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Ks(l.paddingTop),paddingEnd:Ks(l.paddingBottom)}})}})}),[Mx,Ld]=Ad(jr),Od=i.forwardRef((e,r)=>{const{__scopeScrollArea:n,sizes:s,hasThumb:o,onThumbChange:a,onThumbPointerUp:l,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:m,onResize:p,...h}=e,g=ur(jr,n),[x,k]=i.useState(null),w=tr(r,P=>k(P)),A=i.useRef(null),L=i.useRef(""),j=g.viewport,S=s.content-s.viewport,D=vr(m),b=vr(d),I=co(p,10);function G(P){if(A.current){const V=P.clientX-A.current.left,ve=P.clientY-A.current.top;u({x:V,y:ve})}}return i.useEffect(()=>{const P=V=>{const ve=V.target;x?.contains(ve)&&D(V,S)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[j,x,S,D]),i.useEffect(b,[s,b]),Tn(x,I),Tn(g.content,I),t.jsx(Mx,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:vr(a),onThumbPointerUp:vr(l),onThumbPositionChange:b,onThumbPointerDown:vr(c),children:t.jsx(ns.div,{...h,ref:w,style:{position:"absolute",...h.style},onPointerDown:Fe(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),A.current=x.getBoundingClientRect(),L.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),G(P))}),onPointerMove:Fe(e.onPointerMove,G),onPointerUp:Fe(e.onPointerUp,P=>{const V=P.target;V.hasPointerCapture(P.pointerId)&&V.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=L.current,g.viewport&&(g.viewport.style.scrollBehavior=""),A.current=null})})})}),qs="ScrollAreaThumb",Fd=i.forwardRef((e,r)=>{const{forceMount:n,...s}=e,o=Ld(qs,e.__scopeScrollArea);return t.jsx(kr,{present:n||o.hasThumb,children:t.jsx(Dx,{ref:r,...s})})}),Dx=i.forwardRef((e,r)=>{const{__scopeScrollArea:n,style:s,...o}=e,a=ur(qs,n),l=Ld(qs,n),{onThumbPositionChange:c}=l,d=tr(r,p=>l.onThumbChange(p)),u=i.useRef(void 0),m=co(()=>{u.current&&(u.current(),u.current=void 0)},100);return i.useEffect(()=>{const p=a.viewport;if(p){const h=()=>{if(m(),!u.current){const g=Lx(p,c);u.current=g,c()}};return c(),p.addEventListener("scroll",h),()=>p.removeEventListener("scroll",h)}},[a.viewport,m,c]),t.jsx(ns.div,{"data-state":l.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:Fe(e.onPointerDownCapture,p=>{const g=p.target.getBoundingClientRect(),x=p.clientX-g.left,k=p.clientY-g.top;l.onThumbPointerDown({x,y:k})}),onPointerUp:Fe(e.onPointerUp,l.onThumbPointerUp)})});Fd.displayName=qs;var gi="ScrollAreaCorner",$d=i.forwardRef((e,r)=>{const n=ur(gi,e.__scopeScrollArea),s=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&s?t.jsx(Rx,{...e,ref:r}):null});$d.displayName=gi;var Rx=i.forwardRef((e,r)=>{const{__scopeScrollArea:n,...s}=e,o=ur(gi,n),[a,l]=i.useState(0),[c,d]=i.useState(0),u=!!(a&&c);return Tn(o.scrollbarX,()=>{const m=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(m),d(m)}),Tn(o.scrollbarY,()=>{const m=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(m),l(m)}),u?t.jsx(ns.div,{...s,ref:r,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 Ks(e){return e?parseInt(e,10):0}function zd(e,r){const n=e/r;return isNaN(n)?0:n}function lo(e){const r=zd(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=(e.scrollbar.size-n)*r;return Math.max(s,18)}function Px(e,r,n,s="ltr"){const o=lo(n),a=o/2,l=r||a,c=o-l,d=n.scrollbar.paddingStart+l,u=n.scrollbar.size-n.scrollbar.paddingEnd-c,m=n.content-n.viewport,p=s==="ltr"?[0,m]:[m*-1,0];return Bd([d,u],p)(e)}function kl(e,r,n="ltr"){const s=lo(r),o=r.scrollbar.paddingStart+r.scrollbar.paddingEnd,a=r.scrollbar.size-o,l=r.content-r.viewport,c=a-s,d=n==="ltr"?[0,l]:[l*-1,0],u=Mm(e,d);return Bd([0,l],[0,c])(u)}function Bd(e,r){return n=>{if(e[0]===e[1]||r[0]===r[1])return r[0];const s=(r[1]-r[0])/(e[1]-e[0]);return r[0]+s*(n-e[0])}}function Wd(e,r){return e>0&&e<r}var Lx=(e,r=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},s=0;return function o(){const a={left:e.scrollLeft,top:e.scrollTop},l=n.left!==a.left,c=n.top!==a.top;(l||c)&&r(),n=a,s=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(s)};function co(e,r){const n=vr(e),s=i.useRef(0);return i.useEffect(()=>()=>window.clearTimeout(s.current),[]),i.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(n,r)},[n,r])}function Tn(e,r){const n=vr(r);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=_d,Ox=Dd,Hd=Rd,Fx=Fd,$x=$d;function zx(e,r=[]){let n=[];function s(a,l){const c=i.createContext(l),d=n.length;n=[...n,l];const u=p=>{const{scope:h,children:g,...x}=p,k=h?.[e]?.[d]||c,w=i.useMemo(()=>x,Object.values(x));return t.jsx(k.Provider,{value:w,children:g})};u.displayName=a+"Provider";function m(p,h){const g=h?.[e]?.[d]||c,x=i.useContext(g);if(x)return x;if(l!==void 0)return l;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const o=()=>{const a=n.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,Bx(o,...r)]}function Bx(...e){const r=e[0];if(e.length===1)return r;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const l=s.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return i.useMemo(()=>({[`__scope${r.scopeName}`]:l}),[l])}};return n.scopeName=r.scopeName,n}function Wx(e){const r=Ux(e),n=i.forwardRef((s,o)=>{const{children:a,...l}=s,c=i.Children.toArray(a),d=c.find(Gx);if(d){const u=d.props.children,m=c.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return t.jsx(r,{...l,ref:o,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return t.jsx(r,{...l,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Ux(e){const r=i.forwardRef((n,s)=>{const{children:o,...a}=n;if(i.isValidElement(o)){const l=Kx(o),c=qx(a,o.props);return o.type!==i.Fragment&&(c.ref=s?un(s,l):l),i.cloneElement(o,c)}return i.Children.count(o)>1?i.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var Hx=Symbol("radix.slottable");function Gx(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Hx}function qx(e,r){const n={...r};for(const s in r){const o=e[s],a=r[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 Kx(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Vx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],uo=Vx.reduce((e,r)=>{const n=Wx(`Primitive.${r}`),s=i.forwardRef((o,a)=>{const{asChild:l,...c}=o,d=l?n:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${r}`,{...e,[r]:s}},{}),po="Tabs",[Jx,Tw]=zx(po,[so]),Gd=so(),[Yx,xi]=Jx(po),qd=i.forwardRef((e,r)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:l="horizontal",dir:c,activationMode:d="automatic",...u}=e,m=no(c),[p,h]=Za({prop:s,onChange:o,defaultProp:a??"",caller:po});return t.jsx(Yx,{scope:n,baseId:Us(),value:p,onValueChange:h,orientation:l,dir:m,activationMode:d,children:t.jsx(uo.div,{dir:m,"data-orientation":l,...u,ref:r})})});qd.displayName=po;var Kd="TabsList",Vd=i.forwardRef((e,r)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=xi(Kd,n),l=Gd(n);return t.jsx(Yc,{asChild:!0,...l,orientation:a.orientation,dir:a.dir,loop:s,children:t.jsx(uo.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:r})})});Vd.displayName=Kd;var Jd="TabsTrigger",Yd=i.forwardRef((e,r)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,l=xi(Jd,n),c=Gd(n),d=Zd(l.baseId,s),u=eu(l.baseId,s),m=s===l.value;return t.jsx(Xc,{asChild:!0,...c,focusable:!o,active:m,children:t.jsx(uo.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":u,"data-state":m?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...a,ref:r,onMouseDown:Fe(e.onMouseDown,p=>{!o&&p.button===0&&p.ctrlKey===!1?l.onValueChange(s):p.preventDefault()}),onKeyDown:Fe(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&l.onValueChange(s)}),onFocus:Fe(e.onFocus,()=>{const p=l.activationMode!=="manual";!m&&!o&&p&&l.onValueChange(s)})})})});Yd.displayName=Jd;var Xd="TabsContent",Qd=i.forwardRef((e,r)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...l}=e,c=xi(Xd,n),d=Zd(c.baseId,s),u=eu(c.baseId,s),m=s===c.value,p=i.useRef(m);return i.useEffect(()=>{const h=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(h)},[]),t.jsx(kr,{present:o||m,children:({present:h})=>t.jsx(uo.div,{"data-state":m?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!h,id:u,tabIndex:0,...l,ref:r,style:{...e.style,animationDuration:p.current?"0s":void 0},children:h&&a})})});Qd.displayName=Xd;function Zd(e,r){return`${e}-trigger-${r}`}function eu(e,r){return`${e}-content-${r}`}var Xx=qd,tu=Vd,ru=Yd,nu=Qd;const su=i.forwardRef(({className:e,orientation:r="vertical",...n},s)=>t.jsx(Hd,{ref:s,orientation:r,className:ut("flex touch-none select-none transition-colors",r==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",r==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:t.jsx(Fx,{className:"relative flex-1 rounded-full bg-border/80"})}));su.displayName=Hd.displayName;const ou=i.forwardRef(({className:e,children:r,...n},s)=>t.jsxs(Ud,{ref:s,className:ut("relative overflow-hidden",e),...n,children:[t.jsx(Ox,{className:"h-full w-full rounded-[inherit]",children:r}),t.jsx(su,{}),t.jsx($x,{})]}));ou.displayName=Ud.displayName;const gt=i.forwardRef(({className:e,type:r,...n},s)=>t.jsx("input",{type:r,className:ut("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}));gt.displayName="Input";const Pn=({className:e="w-5 h-5"})=>t.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),ss=({className:e="w-5 h-5"})=>{const{isDarkMode:r}=ei();return t.jsx("img",{src:r?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},mo=({className:e="w-5 h-5"})=>{const r=i.useId(),n=i.useId(),s=i.useId();return t.jsxs("svg",{"aria-label":"Gemini",className:e,role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("title",{children:"Gemini"}),t.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"}),t.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(#${r})`}),t.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})`}),t.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})`}),t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:r,x1:"7",x2:"11",y1:"15.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{stopColor:"#08B962"}),t.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),t.jsxs("linearGradient",{id:n,x1:"8",x2:"11.5",y1:"5.5",y2:"11",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{stopColor:"#F94543"}),t.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),t.jsxs("linearGradient",{id:s,x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{stopColor:"#FABC12"}),t.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]})},fo=({className:e="h-5 w-auto",style:r,...n})=>t.jsxs("svg",{"aria-label":"OpenCode",className:e,role:"img",style:{width:"auto",maxWidth:"100%",...r},viewBox:"0 0 32 24",preserveAspectRatio:"xMidYMid meet",xmlns:"http://www.w3.org/2000/svg",...n,children:[t.jsx("title",{children:"OpenCode"}),t.jsx("rect",{x:"6",y:"2",width:"20",height:"20",rx:"5",fill:"currentColor"}),t.jsx("path",{d:"M20 6h-8v12h8V6zm4 16H8V2h16v20z",fill:"white"})]}),Qx=!1,ee=(e,r={})=>{const n=localStorage.getItem("auth-token"),s={};return r.body instanceof FormData||(s["Content-Type"]="application/json"),n&&(s.Authorization=`Bearer ${n}`),fetch(e,{...r,headers:{...s,...r.headers}})},pt={auth:{status:()=>fetch("/api/auth/status"),login:(e,r)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:r})}),register:(e,r)=>fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:r})}),user:()=>ee("/api/auth/user"),logout:()=>ee("/api/auth/logout",{method:"POST"})},projects:()=>ee("/api/projects"),sessions:(e,r=5,n=0)=>ee(`/api/projects/${e}/sessions?limit=${r}&offset=${n}`),historyIndex:e=>ee(`/api/session-core/projects/${e}/history-index`),providerDiscovery:(e,r=null)=>{const n=new URLSearchParams;return r&&n.append("projectPath",r),ee(`/api/session-core/providers/${e}${n.toString()?`?${n.toString()}`:""}`)},providersDiscovery:(e=null)=>{const r=new URLSearchParams;return e&&r.append("projectPath",e),ee(`/api/session-core/providers${r.toString()?`?${r.toString()}`:""}`)},sessionEvents:(e,r,n=null,s=null,o=null,a=0)=>{const l=new URLSearchParams;return n&&l.append("projectName",n),s&&l.append("projectPath",s),o!==null&&(l.append("limit",o),l.append("offset",a)),ee(`/api/session-core/sessions/${e}/${r}/events${l.toString()?`?${l.toString()}`:""}`)},sessionMessages:(e,r,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)),ee(`/api/session-core/sessions/${o}/${r}/events${a.toString()?`?${a.toString()}`:""}`)},resolveSession:(e,r=null)=>{const n=new URLSearchParams;return r&&n.append("provider",r),ee(`/api/session-core/sessions/${e}/resolve${n.toString()?`?${n.toString()}`:""}`)},renameProject:(e,r)=>ee(`/api/projects/${e}/rename`,{method:"PUT",body:JSON.stringify({displayName:r})}),deleteSession:(e,r)=>ee(`/api/projects/${e}/sessions/${r}`,{method:"DELETE"}),deleteCodexSession:e=>ee(`/api/codex/sessions/${e}`,{method:"DELETE"}),deleteOpencodeSession:e=>ee(`/api/opencode/sessions/${e}`,{method:"DELETE"}),deleteProject:(e,r=!1)=>ee(`/api/projects/${e}${r?"?force=true":""}`,{method:"DELETE"}),createProject:e=>ee("/api/projects/create",{method:"POST",body:JSON.stringify({path:e})}),createWorkspace:e=>ee("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(e)}),readFile:(e,r)=>ee(`/api/projects/${e}/file?filePath=${encodeURIComponent(r)}`),saveFile:(e,r,n)=>ee(`/api/projects/${e}/file`,{method:"PUT",body:JSON.stringify({filePath:r,content:n})}),getFiles:e=>ee(`/api/projects/${e}/files`),transcribe:e=>ee("/api/transcribe",{method:"POST",body:e,headers:{}}),browseFilesystem:(e=null)=>{const r=new URLSearchParams;return e&&r.append("path",e),ee(`/api/browse-filesystem?${r}`)},createFolder:e=>ee("/api/create-folder",{method:"POST",body:JSON.stringify({path:e})}),user:{gitConfig:()=>ee("/api/user/git-config"),updateGitConfig:(e,r)=>ee("/api/user/git-config",{method:"POST",body:JSON.stringify({gitName:e,gitEmail:r})}),onboardingStatus:()=>ee("/api/user/onboarding-status"),completeOnboarding:()=>ee("/api/user/complete-onboarding",{method:"POST"})},get:e=>ee(`/api${e}`)},Zx=({onClose:e,onProjectCreated:r})=>{const{t:n}=Lt(),[s,o]=i.useState(1),[a,l]=i.useState("existing"),[c,d]=i.useState(""),[u,m]=i.useState(""),[p,h]=i.useState(""),[g,x]=i.useState("stored"),[k,w]=i.useState(""),[A,L]=i.useState(!1),[j,S]=i.useState(null),[D,b]=i.useState([]),[I,G]=i.useState(!1),[P,V]=i.useState([]),[ve,ae]=i.useState(!1),[R,q]=i.useState(!1),[de,se]=i.useState("~"),[he,Se]=i.useState([]),[B,z]=i.useState(!1),[_,N]=i.useState(!1),[O,ne]=i.useState(!1),[Ce,be]=i.useState(""),[re,Ee]=i.useState(!1),[nt,De]=i.useState("");i.useEffect(()=>{s===2&&a==="new"&&u&&fe()},[s,a,u]),i.useEffect(()=>{c.length>2?Ge(c):(V([]),ae(!1))},[c]);const fe=async()=>{try{G(!0);const W=((await(await pt.get("/settings/credentials?type=github_token")).json()).credentials||[]).filter(Z=>Z.is_active);b(W),W.length>0&&!p&&h(W[0].id.toString())}catch(X){console.error("Error loading GitHub tokens:",X)}finally{G(!1)}},Ge=async X=>{try{const Te=X.lastIndexOf("/"),W=Te>0?X.substring(0,Te):"~",we=await(await pt.browseFilesystem(W)).json();if(we.suggestions){const Ae=we.suggestions.filter(Xe=>Xe.path.toLowerCase().startsWith(X.toLowerCase())&&Xe.path.toLowerCase()!==X.toLowerCase());V(Ae.slice(0,5)),ae(Ae.length>0)}}catch(Te){console.error("Error loading path suggestions:",Te)}},bt=()=>{if(S(null),s===1){if(!a){S(n("projectWizard.errors.selectType"));return}o(2)}else if(s===2){if(!c.trim()){S(n("projectWizard.errors.providePath"));return}o(3)}},st=()=>{S(null),o(s-1)},Be=async()=>{L(!0),S(null),De("");try{if(a==="new"&&u){const Z=new URLSearchParams({path:c.trim(),githubUrl:u.trim()});g==="stored"&&p?Z.append("githubTokenId",p):g==="new"&&k&&Z.append("newGithubToken",k.trim());const we=localStorage.getItem("auth-token"),Ae=`/api/projects/clone-progress?${Z}${we?`&token=${we}`:""}`;await new Promise((Xe,Qe)=>{const We=new EventSource(Ae);We.onmessage=Et=>{try{const ie=JSON.parse(Et.data);ie.type==="progress"?De(ie.message):ie.type==="complete"?(We.close(),r&&r(ie.project),e(),Xe()):ie.type==="error"&&(We.close(),Qe(new Error(ie.message)))}catch(ie){console.error("Error parsing SSE event:",ie)}},We.onerror=()=>{We.close(),Qe(new Error("Connection lost during clone"))}});return}const X={workspaceType:a,path:c.trim()},Te=await pt.createWorkspace(X),W=await Te.json();if(!Te.ok)throw new Error(W.details||W.error||n("projectWizard.errors.failedToCreate"));r&&r(W.project),e()}catch(X){console.error("Error creating workspace:",X),S(X.message||n("projectWizard.errors.failedToCreate"))}finally{L(!1)}},Ze=X=>{d(X.path),ae(!1)},xt=async()=>{q(!0),await wt("~")},wt=async X=>{try{z(!0);const W=await(await pt.browseFilesystem(X)).json();se(W.path||X),Se(W.suggestions||[])}catch(Te){console.error("Error loading folders:",Te)}finally{z(!1)}},ye=(X,Te=!1)=>{d(X),q(!1),Te&&o(3)},qe=async X=>{await wt(X)},Nt=async()=>{if(Ce.trim()){Ee(!0),S(null);try{const X=de.includes("\\")?"\\":"/",Te=`${de}${X}${Ce.trim()}`,W=await pt.createFolder(Te),Z=await W.json();if(!W.ok)throw new Error(Z.error||n("projectWizard.errors.failedToCreateFolder","Failed to create folder"));be(""),ne(!1),await wt(Z.path||Te)}catch(X){console.error("Error creating folder:",X),S(X.message||n("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}finally{Ee(!1)}}};return t.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:[t.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:[t.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 bg-primary/15 dark:bg-primary/30 rounded-lg flex items-center justify-center",children:t.jsx(Sn,{className:"w-4 h-4 text-primary"})}),t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:n("projectWizard.title")})]}),t.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:A,children:t.jsx(lr,{className:"w-5 h-5"})})]}),t.jsx("div",{className:"px-6 pt-4 pb-2",children:t.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(X=>t.jsxs(dn.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${X<s?"bg-green-500 text-white":X===s?"bg-primary text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:X<s?t.jsx(Gt,{className:"w-4 h-4"}):X}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:n(X===1?"projectWizard.steps.type":X===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),X<3&&t.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${X<s?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},X))})}),t.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[j&&t.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:[t.jsx(Dm,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),t.jsx("div",{className:"flex-1",children:t.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:j})})]}),s===1&&t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:n("projectWizard.step1.question")}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx("button",{onClick:()=>l("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:t.jsxs("div",{className:"flex items-start gap-3",children:[t.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:t.jsx(Sn,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:n("projectWizard.step1.existing.title")}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.step1.existing.description")})]})]})}),t.jsx("button",{onClick:()=>l("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:t.jsxs("div",{className:"flex items-start gap-3",children:[t.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:t.jsx(Kr,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:n("projectWizard.step1.new.title")}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.step1.new.description")})]})]})})]})]})}),s===2&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.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")}),t.jsxs("div",{className:"relative flex gap-2",children:[t.jsxs("div",{className:"flex-1 relative",children:[t.jsx(gt,{type:"text",value:c,onChange:X=>d(X.target.value),placeholder:a==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),ve&&P.length>0&&t.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:P.map((X,Te)=>t.jsxs("button",{onClick:()=>Ze(X),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:X.name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:X.path})]},Te))})]}),t.jsx(_e,{type:"button",variant:"outline",onClick:xt,className:"px-3",title:"Browse folders",children:t.jsx(on,{className:"w-4 h-4"})})]}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:n(a==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]}),a==="new"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:n("projectWizard.step2.githubUrl")}),t.jsx(gt,{type:"text",value:u,onChange:X=>m(X.target.value),placeholder:"https://github.com/username/repository",className:"w-full"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:n("projectWizard.step2.githubHelp")})]}),u&&!u.startsWith("git@")&&!u.startsWith("ssh://")&&t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(ai,{className:"w-5 h-5 text-gray-600 dark:text-gray-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h5",{className:"font-medium text-gray-900 dark:text-white mb-1",children:n("projectWizard.step2.githubAuth")}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.step2.githubAuthHelp")})]})]}),I?t.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[t.jsx(qr,{className:"w-4 h-4 animate-spin"}),n("projectWizard.step2.loadingTokens")]}):D.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[t.jsx("button",{onClick:()=>x("stored"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="stored"?"bg-primary text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:n("projectWizard.step2.storedToken")}),t.jsx("button",{onClick:()=>x("new"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="new"?"bg-primary text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:n("projectWizard.step2.newToken")}),t.jsx("button",{onClick:()=>{x("none"),h(""),w("")},className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="none"?"bg-green-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:n("projectWizard.step2.nonePublic")})]}),g==="stored"?t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:n("projectWizard.step2.selectToken")}),t.jsxs("select",{value:p,onChange:X=>h(X.target.value),className:"w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm",children:[t.jsx("option",{value:"",children:n("projectWizard.step2.selectTokenPlaceholder")}),D.map(X=>t.jsx("option",{value:X.id,children:X.credential_name},X.id))]})]}):g==="new"?t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:n("projectWizard.step2.newToken")}),t.jsx(gt,{type:"password",value:k,onChange:X=>w(X.target.value),placeholder:"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:"w-full"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:n("projectWizard.step2.tokenHelp")})]}):null]}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"bg-primary/10 dark:bg-primary/20 rounded-lg p-3 border border-primary/30 dark:border-primary/60",children:t.jsx("p",{className:"text-sm text-primary",children:n("projectWizard.step2.publicRepoInfo")})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:n("projectWizard.step2.optionalTokenPublic")}),t.jsx(gt,{type:"password",value:k,onChange:X=>w(X.target.value),placeholder:n("projectWizard.step2.tokenPublicPlaceholder"),className:"w-full"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:n("projectWizard.step2.noTokensHelp")})]})]})]})]})]}),s===3&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:n("projectWizard.step3.reviewConfig")}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.workspaceType")}),t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:n(a==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.path")}),t.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:c})]}),a==="new"&&u&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.cloneFrom")}),t.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:u})]}),t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.authentication")}),t.jsx("span",{className:"text-xs text-gray-900 dark:text-white",children:g==="stored"&&p?`${n("projectWizard.step3.usingStoredToken")} ${D.find(X=>X.id.toString()===p)?.credential_name||"Unknown"}`:g==="new"&&k?n("projectWizard.step3.usingProvidedToken"):u.startsWith("git@")||u.startsWith("ssh://")?n("projectWizard.step3.sshKey","SSH Key"):n("projectWizard.step3.noAuthentication")})]})]})]})]}),t.jsx("div",{className:"bg-primary/10 dark:bg-primary/20 rounded-lg p-4 border border-primary/30 dark:border-primary/60",children:A&&nt?t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm font-medium text-primary",children:n("projectWizard.step3.cloningRepository","Cloning repository...")}),t.jsx("code",{className:"block text-xs font-mono text-primary whitespace-pre-wrap break-all",children:nt})]}):t.jsx("p",{className:"text-sm text-primary",children:n(a==="existing"?"projectWizard.step3.existingInfo":u?"projectWizard.step3.newWithClone":"projectWizard.step3.newEmpty")})})]})]}),t.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[t.jsx(_e,{variant:"outline",onClick:s===1?e:st,disabled:A,children:s===1?n("projectWizard.buttons.cancel"):t.jsxs(t.Fragment,{children:[t.jsx(ni,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.back")]})}),t.jsx(_e,{onClick:s===3?Be:bt,disabled:A||s===1&&!a,children:A?t.jsxs(t.Fragment,{children:[t.jsx(qr,{className:"w-4 h-4 mr-2 animate-spin"}),u?n("projectWizard.buttons.cloning","Cloning..."):n("projectWizard.buttons.creating")]}):s===3?t.jsxs(t.Fragment,{children:[t.jsx(Gt,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.createProject")]}):t.jsxs(t.Fragment,{children:[n("projectWizard.buttons.next"),t.jsx(sn,{className:"w-4 h-4 ml-1"})]})})]})]}),R&&t.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:t.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:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 bg-primary/15 dark:bg-primary/30 rounded-lg flex items-center justify-center",children:t.jsx(on,{className:"w-4 h-4 text-primary"})}),t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Select Folder"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>N(!_),className:`p-2 rounded-md transition-colors ${_?"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:_?"Hide hidden folders":"Show hidden folders",children:_?t.jsx(si,{className:"w-5 h-5"}):t.jsx($c,{className:"w-5 h-5"})}),t.jsx("button",{onClick:()=>ne(!O),className:`p-2 rounded-md transition-colors ${O?"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:t.jsx(ln,{className:"w-5 h-5"})}),t.jsx("button",{onClick:()=>q(!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:t.jsx(lr,{className:"w-5 h-5"})})]})]}),O&&t.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-primary/10 dark:bg-primary/20",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(gt,{type:"text",value:Ce,onChange:X=>be(X.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:X=>{X.key==="Enter"&&Nt(),X.key==="Escape"&&(ne(!1),be(""))},autoFocus:!0}),t.jsx(_e,{size:"sm",onClick:Nt,disabled:!Ce.trim()||re,children:re?t.jsx(qr,{className:"w-4 h-4 animate-spin"}):"Create"}),t.jsx(_e,{size:"sm",variant:"ghost",onClick:()=>{ne(!1),be("")},children:"Cancel"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:B?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx(qr,{className:"w-6 h-6 animate-spin text-gray-400"})}):t.jsxs("div",{className:"space-y-1",children:[de!=="~"&&de!=="/"&&!/^[A-Za-z]:\\?$/.test(de)&&t.jsxs("button",{onClick:()=>{const X=Math.max(de.lastIndexOf("/"),de.lastIndexOf("\\"));let Te;X<=0?Te="/":X===2&&/^[A-Za-z]:/.test(de)?Te=de.substring(0,3):Te=de.substring(0,X),qe(Te)},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:[t.jsx(on,{className:"w-5 h-5 text-gray-400"}),t.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),he.length===0?t.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):he.filter(X=>_||!X.name.startsWith(".")).sort((X,Te)=>X.name.toLowerCase().localeCompare(Te.name.toLowerCase())).map((X,Te)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{onClick:()=>qe(X.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:[t.jsx(Sn,{className:"w-5 h-5 text-primary"}),t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:X.name})]}),t.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>ye(X.path,a==="existing"),className:"text-xs px-3",children:"Select"})]},Te))]})}),t.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),t.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:de})]}),t.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[t.jsx(_e,{variant:"outline",onClick:()=>{q(!1),ne(!1),be("")},children:"Cancel"}),t.jsx(_e,{variant:"outline",onClick:()=>ye(de,a==="existing"),children:"Use this folder"})]})]})]})})]})},e0=(e,r,n)=>{const s=new Date(e),o=r;if(isNaN(s.getTime()))return n?n("status.unknown"):"Unknown";const a=o-s,l=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 l<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"})},t0=(e,r)=>{if(typeof e!="string")return"";const n=e.trim();return n.length<=r?n:`${n.slice(0,Math.max(0,r-1))}…`},kn="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",As="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",jl=({provider:e,className:r="h-3.5 w-3.5"})=>e==="codex"||e==="openai"?t.jsx(ss,{className:r}):e==="gemini"?t.jsx(mo,{className:r}):e==="opencode"?t.jsx(fo,{className:"h-3.5 w-auto max-w-full"}):t.jsx(Pn,{className:r});function Nl({projects:e,selectedProject:r,selectedSession:n,onProjectSelect:s,onSessionSelect:o,onNewSession:a,onSessionDelete:l,onProjectDelete:c,isLoading:d,loadingProgress:u,onRefresh:m,updateAvailable:p,latestVersion:h,currentVersion:g,releaseInfo:x,onShowVersionModal:k,isPWA:w,isMobile:A,onToggleSidebar:L,lockedProjectName:j,showNewProject:S,setShowNewProject:D}){const{t:b}=Lt("sidebar"),[I,G]=i.useState(new Set),[P,V]=i.useState(null),[ve,ae]=i.useState(""),[R,q]=i.useState({}),[de,se]=i.useState({}),[he,Se]=i.useState(new Set),[B,z]=i.useState(new Date),[_,N]=i.useState("name"),[O,ne]=i.useState(!1),[Ce,be]=i.useState(null),[re,Ee]=i.useState(""),[nt,De]=i.useState(null),[fe,Ge]=i.useState(null),[bt,st]=i.useState({}),[Be,Ze]=i.useState(""),[xt,wt]=i.useState(new Set),[ye,qe]=i.useState(null),[Nt,X]=i.useState(null),[Te,W]=i.useState(()=>{try{const M=localStorage.getItem("starredProjects");return M?new Set(JSON.parse(M)):new Set}catch(M){return console.error("Error loading starred projects:",M),new Set}}),Z=M=>ge=>{ge.target.closest(".overflow-y-auto")||ge.target.closest("[data-scroll-container]")||(ge.preventDefault(),ge.stopPropagation(),M())};i.useEffect(()=>{const M=setInterval(()=>{z(new Date)},6e4);return()=>clearInterval(M)},[]),i.useEffect(()=>{se({}),Se(new Set)},[e]),i.useEffect(()=>{n&&r&&G(M=>new Set([...M,r.name]))},[n,r]),i.useEffect(()=>{j&&G(new Set([j]))},[j,e.length]),i.useEffect(()=>{if(e.length>0&&!d){const M=new Set;e.forEach(ge=>{ge.sessions&&ge.sessions.length>=0&&M.add(ge.name)}),Se(M)}},[e,d]),i.useEffect(()=>{const M=()=>{try{const Q=localStorage.getItem("claude-settings");if(Q){const C=JSON.parse(Q);N(C.projectSortOrder||"name")}}catch(Q){console.error("Error loading sort order:",Q)}};M();const ge=Q=>{Q.key==="claude-settings"&&M()};window.addEventListener("storage",ge);const Re=setInterval(()=>{document.hasFocus()&&M()},1e3);return()=>{window.removeEventListener("storage",ge),clearInterval(Re)}},[]);const we=M=>{const ge=new Set;I.has(M)||ge.add(M),G(ge)},Ae=(M,ge)=>{o({...M,__projectName:ge})},Xe=M=>{const ge=new Set(Te);ge.has(M)?ge.delete(M):ge.add(M),W(ge);try{localStorage.setItem("starredProjects",JSON.stringify([...ge]))}catch(Re){console.error("Error saving starred projects:",Re)}},Qe=M=>Te.has(M),We=M=>{let ge={};try{ge=JSON.parse(localStorage.getItem("session-provider-map")||"{}")}catch{}const Re=[...M.sessions||[],...de[M.name]||[]].map(je=>({...je,__provider:ge[je.id]||"claude"})),Q=(M.codexSessions||[]).map(je=>({...je,__provider:"codex"})),C=(M.geminiSessions||[]).map(je=>({...je,__provider:"gemini"})),F=(M.opencodeSessions||[]).map(je=>({...je,__provider:"opencode"})),pe=je=>je.__provider==="codex"?new Date(je.createdAt||je.lastActivity):je.__provider==="gemini"?new Date(je.createdAt||je.lastActivity):je.__provider==="opencode"?new Date(je.createdAt||je.lastActivity):new Date(je.lastActivity);return[...Re,...Q,...C,...F].sort((je,mt)=>pe(mt)-pe(je))},Et=M=>{const ge=We(M);return ge.length===0?new Date(0):ge.reduce((Q,C)=>{const F=new Date(C.lastActivity);return F>Q?F:Q},new Date(0))},ie=[...e].sort((M,ge)=>{const Re=Qe(M.name),Q=Qe(ge.name);if(Re&&!Q)return-1;if(!Re&&Q)return 1;if(_==="date")return Et(ge)-Et(M);{const C=M.displayName||M.name,F=ge.displayName||ge.name;return C.localeCompare(F)}}),St=M=>{V(M.name),ae(M.displayName)},et=()=>{V(null),ae("")},ot=async M=>{try{(await pt.renameProject(M,ve)).ok?window.refreshProjects?window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(ge){console.error("Error renaming project:",ge)}V(null),ae("")},Ke=(M,ge,Re,Q="claude")=>{X({projectName:M,sessionId:ge,sessionTitle:Re,provider:Q})},Tt=async()=>{if(!Nt)return;const{projectName:M,sessionId:ge,provider:Re}=Nt;X(null);try{console.log("[Sidebar] Deleting session:",{projectName:M,sessionId:ge,provider:Re});let Q;if(Re==="codex"?Q=await pt.deleteCodexSession(ge):Re==="opencode"?Q=await pt.deleteOpencodeSession(ge):Q=await pt.deleteSession(M,ge),console.log("[Sidebar] Delete response:",{ok:Q.ok,status:Q.status}),Q.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),l?l(ge):console.warn("[Sidebar] No onSessionDelete callback provided");else{const C=await Q.text();console.error("[Sidebar] Failed to delete session:",{status:Q.status,error:C}),alert(b("messages.deleteSessionFailed"))}}catch(Q){console.error("[Sidebar] Error deleting session:",Q),alert(b("messages.deleteSessionError"))}},Ot=M=>{const ge=We(M).length;qe({project:M,sessionCount:ge})},yt=async()=>{if(!ye)return;const{project:M,sessionCount:ge}=ye,Re=ge===0;qe(null),wt(Q=>new Set([...Q,M.name]));try{const Q=await pt.deleteProject(M.name,!Re);if(Q.ok)c&&c(M.name);else{const C=await Q.json();console.error("Failed to delete project"),alert(C.error||b("messages.deleteProjectFailed"))}}catch(Q){console.error("Error deleting project:",Q),alert(b("messages.deleteProjectError"))}finally{wt(Q=>{const C=new Set(Q);return C.delete(M.name),C})}},At=async M=>{if(!(!(M.sessionMeta?.hasMore!==!1)||R[M.name])){q(Re=>({...Re,[M.name]:!0}));try{const Re=(M.sessions?.length||0)+(de[M.name]?.length||0),Q=await pt.sessions(M.name,5,Re);if(Q.ok){const C=await Q.json();se(F=>({...F,[M.name]:[...F[M.name]||[],...C.sessions]})),C.hasMore===!1&&(M.sessionMeta={...M.sessionMeta,hasMore:!1})}}catch(Re){console.error("Error loading more sessions:",Re)}finally{q(Re=>({...Re,[M.name]:!1}))}}},rr=ie.filter(M=>{if(!Be.trim())return!0;const ge=Be.toLowerCase(),Re=(M.displayName||M.name).toLowerCase(),Q=M.name.toLowerCase();return Re.includes(ge)||Q.includes(ge)}),tt=!!j,Ft=tt?ie.filter(M=>M.name===j):rr,It=r||Ft[0]||null,$t=A?"bottom":"right",nr=A?"end":"start",Bt=A?4:8;return t.jsxs(t.Fragment,{children:[S&&Qo.createPortal(t.jsx(Zx,{onClose:()=>D(!1),onProjectCreated:M=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),ye&&Qo.createPortal(t.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[t.jsx("div",{className:"p-6",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.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:t.jsx(Ea,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:b("deleteConfirmation.deleteProject")}),t.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[b("deleteConfirmation.confirmDelete")," ",t.jsx("span",{className:"font-medium text-foreground",children:ye.project.displayName||ye.project.name}),"?"]}),ye.sessionCount>0&&t.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:[t.jsx("p",{className:"text-sm text-red-700 dark:text-red-300 font-medium",children:b("deleteConfirmation.sessionCount",{count:ye.sessionCount})}),t.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:b("deleteConfirmation.allConversationsDeleted")})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:b("deleteConfirmation.cannotUndo")})]})]})}),t.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[t.jsx(_e,{variant:"outline",className:"flex-1",onClick:()=>qe(null),children:b("actions.cancel")}),t.jsxs(_e,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:yt,children:[t.jsx(ir,{className:"w-4 h-4 mr-2"}),b("actions.delete")]})]})]})}),document.body),Nt&&Qo.createPortal(t.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[t.jsx("div",{className:"p-6",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.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:t.jsx(Ea,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:b("deleteConfirmation.deleteSession")}),t.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[b("deleteConfirmation.confirmDelete")," ",t.jsx("span",{className:"font-medium text-foreground",children:Nt.sessionTitle||b("sessions.unnamed")}),"?"]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:b("deleteConfirmation.cannotUndo")})]})]})}),t.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[t.jsx(_e,{variant:"outline",className:"flex-1",onClick:()=>X(null),children:b("actions.cancel")}),t.jsxs(_e,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:Tt,children:[t.jsx(ir,{className:"w-4 h-4 mr-2"}),b("actions.delete")]})]})]})}),document.body),t.jsxs("div",{className:"h-full flex flex-col bg-muted/40 md:select-none",style:w&&A?{paddingTop:"44px"}:{},children:[t.jsxs("div",{className:"md:flex-shrink-0 md:px-3 md:pt-3",children:[t.jsxs("div",{className:"hidden h-[60px] items-center justify-between gap-3 rounded-2xl bg-background/70 px-3 md:flex",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-foreground text-background flex-shrink-0",children:t.jsx(Vn,{className:"w-4 h-4 text-primary-foreground"})}),t.jsx("div",{className:"min-w-0",children:t.jsx("h1",{className:"text-base font-semibold leading-none text-foreground truncate",children:b("app.title")})})]}),L&&t.jsx(_e,{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:L,title:b("tooltips.hideSidebar"),children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),t.jsx("div",{className:"chat-header bg-white p-3 dark:bg-background md:hidden",style:w&&A?{paddingTop:"16px"}:{},children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 bg-primary rounded-lg flex items-center justify-center",children:t.jsx(Vn,{className:"w-4 h-4 text-primary-foreground"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-lg font-semibold text-foreground",children:b("app.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.title")})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.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()=>{ne(!0);try{await m()}finally{ne(!1)}},disabled:O,children:t.jsx(Tr,{className:`w-4 h-4 text-foreground ${O?"animate-spin":""}`})}),!tt&&t.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:()=>D(!0),children:t.jsx(Sn,{className:"w-4 h-4"})})]})]})})]}),!d&&!A&&!tt&&t.jsx("div",{className:"hidden"}),e.length>0&&!d&&!tt&&t.jsx("div",{className:"px-3 py-3 md:px-3",children:t.jsxs("div",{className:"relative",children:[t.jsx(Sa,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t.jsx(gt,{type:"text",placeholder:b("projects.searchPlaceholder"),value:Be,onChange:M=>Ze(M.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"}),Be&&t.jsx("button",{onClick:()=>Ze(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:t.jsx(lr,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.length>0&&!d&&It&&t.jsx("div",{className:"px-3 pb-2",children:t.jsxs(_e,{variant:"subtle",className:"h-9 w-full justify-start gap-2 rounded-lg px-3 text-sm",onClick:()=>a(It),children:[t.jsx(ln,{className:"h-4 w-4"}),b("sessions.newSession")]})}),t.jsx(ou,{className:"flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-2 py-2 md:px-3 md:py-2",children:t.jsx("div",{className:"space-y-1 overflow-x-hidden pb-safe-area-inset-bottom",children:d?t.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:t.jsx("div",{className:"w-full max-w-[320px] text-center space-y-4",children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:u&&u.total>0?t.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${u.current/u.total*100}%`}}):t.jsx("div",{className:"h-full w-1/3 rounded-full bg-primary animate-pulse"})}),u?.currentProject&&t.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?t.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.current,"/",u.total,t.jsx("span",{className:"ml-1 text-sm text-muted-foreground",children:b("projects.projects")})]}):t.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.loadingProjects")})]})})}):e.length===0?t.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[t.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:t.jsx(ta,{className:"w-6 h-6 text-muted-foreground"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:b("projects.noProjects")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.runClaudeCli")})]}):Ft.length===0?t.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[t.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:t.jsx(Sa,{className:"w-6 h-6 text-muted-foreground"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:b("projects.noMatchingProjects")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.tryDifferentSearch")})]}):Ft.map(M=>{const ge=I.has(M.name),Re=r?.name===M.name,Q=Qe(M.name),C=xt.has(M.name),F=tt&&M.name===j,pe=F||ge,je=M.displayName||M.name,mt=t0(je,A?22:28);return t.jsxs("div",{className:ut("space-y-2",C&&"pointer-events-none opacity-50"),children:[!F&&t.jsxs("div",{className:"group md:group",children:[t.jsx("div",{className:"md:hidden",children:t.jsxs("div",{className:ut("mx-1 flex min-h-10 items-center gap-2 px-2 py-2 text-muted-foreground transition-colors active:scale-[0.98]",Re?"text-foreground":"hover:text-foreground"),onClick:()=>{r?.name!==M.name&&s(M),we(M.name)},onTouchEnd:Z(()=>{r?.name!==M.name&&s(M),we(M.name)}),children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[t.jsx("div",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ge?t.jsx(on,{className:ut("h-4 w-4",Q?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):t.jsx(ta,{className:ut("h-4 w-4",Q?"text-yellow-600 dark:text-yellow-400":Re?"text-foreground":"text-muted-foreground")})}),t.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:P===M.name?t.jsx("input",{type:"text",value:ve,onChange:H=>ae(H.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:H=>H.stopPropagation(),onKeyDown:H=>{H.key==="Enter"&&ot(M.name),H.key==="Escape"&&et()},style:{fontSize:"16px"}}):t.jsx("div",{className:ut(sa,Re&&"font-semibold"),children:mt})})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:P===M.name?t.jsxs(t.Fragment,{children:[t.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(),ot(M.name)},title:b("tooltips.save"),children:t.jsx(Gt,{className:"h-3.5 w-3.5"})}),t.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(),et()},title:b("tooltips.cancel"),children:t.jsx(lr,{className:"h-3.5 w-3.5"})})]}):t.jsxs(Cs,{children:[t.jsx(Es,{asChild:!0,children:t.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:H=>H.stopPropagation(),"aria-label":b("actions.settings"),children:t.jsx(js,{className:"h-4 w-4"})})}),t.jsx(Is,{children:t.jsxs(Ts,{side:$t,align:nr,sideOffset:Bt,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:[t.jsxs(xr,{className:kn,onSelect:H=>{H.preventDefault(),St(M)},children:[t.jsx(xl,{className:"h-4 w-4"}),b("tooltips.renameProject")]}),t.jsxs(xr,{className:kn,onSelect:H=>{H.preventDefault(),Xe(M.name)},children:[t.jsx(vl,{className:ut("h-4 w-4",Q&&"fill-yellow-400 text-yellow-500")}),b(Q?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),t.jsx(wl,{className:"my-1 h-px bg-border"}),t.jsxs(xr,{className:As,onSelect:H=>{H.preventDefault(),Ot(M)},children:[t.jsx(ir,{className:"h-4 w-4"}),b("tooltips.deleteProject")]})]})})]})})]})}),t.jsxs("div",{role:"button",tabIndex:0,className:ut("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===M.name?"h-auto":"h-9",Re?"text-foreground":"hover:text-foreground"),onClick:()=>{r?.name!==M.name&&s(M),we(M.name)},onTouchEnd:Z(()=>{r?.name!==M.name&&s(M),we(M.name)}),onKeyDown:H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),r?.name!==M.name&&s(M),we(M.name))},title:M.fullPath||je,children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[t.jsx("div",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ge?t.jsx(on,{className:ut("h-4 w-4",Q?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):t.jsx(ta,{className:ut("h-4 w-4",Q?"text-yellow-600 dark:text-yellow-400":Re?"text-foreground":"text-muted-foreground")})}),t.jsx("div",{className:"min-w-0 flex-1 overflow-hidden text-left",children:P===M.name?t.jsx("input",{type:"text",value:ve,onChange:H=>ae(H.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:H=>{H.key==="Enter"&&ot(M.name),H.key==="Escape"&&et()},onClick:H=>H.stopPropagation()}):t.jsx("div",{className:ut(sa,Re&&"font-semibold"),children:mt})})]}),t.jsx("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:P===M.name?t.jsxs(t.Fragment,{children:[t.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(),ot(M.name)},title:b("tooltips.save"),children:t.jsx(Gt,{className:"h-3.5 w-3.5"})}),t.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(),et()},title:b("tooltips.cancel"),children:t.jsx(lr,{className:"h-3.5 w-3.5"})})]}):t.jsxs(Cs,{children:[t.jsx(Es,{asChild:!0,children:t.jsx("button",{className:ut("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:H=>H.stopPropagation(),"aria-label":b("actions.settings"),children:t.jsx(js,{className:"h-4 w-4"})})}),t.jsx(Is,{children:t.jsxs(Ts,{side:$t,align:nr,sideOffset:Bt,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:[t.jsxs(xr,{className:kn,onSelect:H=>{H.preventDefault(),St(M)},children:[t.jsx(xl,{className:"h-4 w-4"}),b("tooltips.renameProject")]}),t.jsxs(xr,{className:kn,onSelect:H=>{H.preventDefault(),Xe(M.name)},children:[t.jsx(vl,{className:ut("h-4 w-4",Q&&"fill-yellow-400 text-yellow-500")}),b(Q?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),t.jsx(wl,{className:"my-1 h-px bg-border"}),t.jsxs(xr,{className:As,onSelect:H=>{H.preventDefault(),Ot(M)},children:[t.jsx(ir,{className:"h-4 w-4"}),b("tooltips.deleteProject")]})]})})]})})]})]}),pe&&t.jsxs("div",{className:ut("space-y-1",F?"px-1 md:px-0":"px-0"),children:[he.has(M.name)?We(M).length===0&&!R[M.name]?t.jsx("div",{className:"px-3 py-2 text-left",children:t.jsx("p",{className:"text-xs text-muted-foreground",children:b("sessions.noSessions")})}):We(M).map(H=>{const _t=H.__provider==="codex",$=H.__provider==="gemini",U=H.__provider==="opencode",le=_t||$||U,Oe=Ce===H.id&&!_t,T=n?.id===H.id,te=_t?H.summary||H.name||b("projects.codexSession"):U?H.summary||H.name||b("projects.opencodeSession"):H.summary||H.name||b("projects.newSession"),oe=le&&H.createdAt||H.lastActivity,ke=nt===H.id||fe===H.id;return t.jsxs("div",{className:"group/session relative w-full min-w-0 max-w-full",onMouseEnter:()=>De(H.id),onMouseLeave:()=>De(K=>K===H.id?null:K),children:[t.jsx("div",{className:"w-full min-w-0 max-w-full md:hidden",children:t.jsxs("div",{className:ut("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",T?"chat-sidebar-item-active":"chat-sidebar-item"),onClick:()=>{s(M),Ae(H,M.name)},onTouchEnd:Z(()=>{s(M),Ae(H,M.name)}),children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(jl,{provider:H.__provider})}),t.jsx("div",{className:"min-w-0 flex-1 basis-0 overflow-hidden",children:Oe?t.jsx("input",{type:"text",value:re,onChange:K=>Ee(K.target.value),onKeyDown:K=>{K.stopPropagation(),K.key==="Enter"?updateSessionSummary(M.name,H.id,re):K.key==="Escape"&&(be(null),Ee(""))},onClick:K=>K.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}):t.jsx("div",{className:sa,title:te,children:te})}),t.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:Oe?t.jsxs(t.Fragment,{children:[t.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:K=>{K.stopPropagation(),updateSessionSummary(M.name,H.id,re)},title:b("tooltips.save"),children:t.jsx(Gt,{className:"h-3.5 w-3.5"})}),t.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:K=>{K.stopPropagation(),be(null),Ee("")},title:b("tooltips.cancel"),children:t.jsx(lr,{className:"h-3.5 w-3.5"})})]}):t.jsx(t.Fragment,{children:t.jsxs(Cs,{children:[t.jsx(Es,{asChild:!0,children:t.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:K=>K.stopPropagation(),"aria-label":b("actions.settings"),children:t.jsx(js,{className:"h-4 w-4"})})}),t.jsx(Is,{children:t.jsxs(Ts,{side:$t,align:nr,sideOffset:Bt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:K=>K.stopPropagation(),children:[!_t&&t.jsxs(xr,{className:kn,onSelect:K=>{K.preventDefault(),be(H.id),Ee(H.summary||H.name||b("projects.newSession"))},children:[t.jsx(yl,{className:"h-4 w-4"}),b("tooltips.editSessionName")]}),t.jsxs(xr,{className:As,onSelect:K=>{K.preventDefault(),Ke(M.name,H.id,te,H.__provider)},children:[t.jsx(ir,{className:"h-4 w-4"}),b("tooltips.deleteSession")]})]})})]})})})]})}),t.jsx("div",{className:"hidden w-full min-w-0 max-w-full md:block",children:t.jsxs("div",{className:ut("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",T?"chat-sidebar-item-active":"chat-sidebar-item"),children:[t.jsxs("button",{className:"flex w-full min-w-0 items-center gap-2 overflow-hidden text-left",onClick:()=>Ae(H,M.name),onTouchEnd:Z(()=>Ae(H,M.name)),children:[t.jsx("span",{className:ut("flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-opacity",T||Oe?"opacity-100":"opacity-0 group-hover/session:opacity-100"),children:t.jsx(jl,{provider:H.__provider})}),Oe?t.jsx("input",{type:"text",value:re,onChange:K=>Ee(K.target.value),onKeyDown:K=>{K.stopPropagation(),K.key==="Enter"?updateSessionSummary(M.name,H.id,re):K.key==="Escape"&&(be(null),Ee(""))},onClick:K=>K.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}):t.jsx("span",{className:"block min-w-0 w-full flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-sm text-foreground",title:te,children:te})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-end pl-1",children:Oe?t.jsxs(t.Fragment,{children:[t.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:K=>{K.stopPropagation(),updateSessionSummary(M.name,H.id,re)},title:b("tooltips.save"),children:t.jsx(Gt,{className:"h-3.5 w-3.5"})}),t.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:K=>{K.stopPropagation(),be(null),Ee("")},title:b("tooltips.cancel"),children:t.jsx(lr,{className:"h-3.5 w-3.5"})})]}):t.jsx(t.Fragment,{children:ke?t.jsxs(Cs,{onOpenChange:K=>Ge(K?H.id:null),children:[t.jsx(Es,{asChild:!0,children:t.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:K=>K.stopPropagation(),onFocus:()=>De(H.id),"aria-label":b("actions.settings"),children:t.jsx(js,{className:"h-4 w-4"})})}),t.jsx(Is,{children:t.jsxs(Ts,{side:$t,align:nr,sideOffset:Bt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:K=>K.stopPropagation(),children:[!_t&&t.jsxs(xr,{className:kn,onSelect:K=>{K.preventDefault(),be(H.id),Ee(H.summary||H.name||b("projects.newSession"))},children:[t.jsx(yl,{className:"h-4 w-4"}),b("tooltips.editSessionName")]}),t.jsxs(xr,{className:As,onSelect:K=>{K.preventDefault(),Ke(M.name,H.id,te,H.__provider)},children:[t.jsx(ir,{className:"h-4 w-4"}),b("tooltips.deleteSession")]})]})})]}):t.jsx("span",{className:"text-[11px] text-muted-foreground",children:e0(oe,B,b)})})})]})})]},H.id)}):Array.from({length:3}).map((H,_t)=>t.jsx("div",{className:"flex h-9 items-center rounded-lg px-3",children:t.jsx("div",{className:"h-3 w-full animate-pulse rounded bg-muted",style:{width:`${60+_t*15}%`}})},_t)),We(M).length>0&&M.sessionMeta?.hasMore!==!1&&t.jsx(_e,{variant:"subtle",size:"sm",className:"mt-2 w-full justify-center gap-2 rounded-xl text-muted-foreground hover:text-foreground",onClick:()=>At(M),disabled:R[M.name],children:R[M.name]?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),b("sessions.loading")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ar,{className:"w-3 h-3"}),b("sessions.showMore")]})})]})]},M.name)})})}),p&&t.jsxs("div",{className:"px-3 py-3 flex-shrink-0",children:[t.jsx("div",{className:"hidden md:block",children:t.jsxs(_e,{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:k,children:[t.jsxs("div",{className:"relative",children:[t.jsx("svg",{className:"w-4 h-4 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:x?.title||`Version ${h}`}),t.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:b("version.updateAvailable")})]})]})}),t.jsx("div",{className:"md:hidden p-3 pb-2",children:t.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:k,children:[t.jsxs("div",{className:"relative",children:[t.jsx("svg",{className:"w-5 h-5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),t.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[t.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:x?.title||`Version ${h}`}),t.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:b("version.updateAvailable")})]})]})})]}),t.jsx("div",{className:"md:p-2 flex-shrink-0",children:t.jsxs("div",{className:"hidden md:flex items-center justify-between gap-2",children:[!tt&&t.jsxs(_e,{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:()=>D(!0),title:b("tooltips.createProject"),children:[t.jsx(Sn,{className:"w-4 h-4"}),t.jsx("span",{className:"text-xs leading-none",children:b("projects.newProject").includes("Project")?"New":b("projects.newProject").substring(0,2)})]}),t.jsxs(_e,{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()=>{ne(!0);try{await m()}finally{ne(!1)}},disabled:O,title:b("tooltips.refresh"),children:[t.jsx(Tr,{className:`w-4 h-4 ${O?"animate-spin":""}`}),t.jsx("span",{className:"text-xs leading-none",children:b("actions.refresh")||"Sync"})]})]})})]})]})}var oa={exports:{}},aa,Sl;function r0(){if(Sl)return aa;Sl=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return aa=e,aa}var ia,Cl;function n0(){if(Cl)return ia;Cl=1;var e=r0();function r(){}function n(){}return n.resetWarningCache=r,ia=function(){function s(l,c,d,u,m,p){if(p!==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:r};return a.PropTypes=a,a},ia}var El;function s0(){return El||(El=1,oa.exports=n0()()),oa.exports}var o0=s0();const dt=Rc(o0),a0=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 An(e,r,n){const s=i0(e),{webkitRelativePath:o}=e,a=typeof r=="string"?r:typeof o=="string"&&o.length>0?o:`./${e.name}`;return typeof s.path!="string"&&Il(s,"path",a),Il(s,"relativePath",a),s}function i0(e){const{name:r}=e;if(r&&r.lastIndexOf(".")!==-1&&!e.type){const s=r.split(".").pop().toLowerCase(),o=a0.get(s);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e}function Il(e,r,n){Object.defineProperty(e,r,{value:n,writable:!1,configurable:!1,enumerable:!0})}const l0=[".DS_Store","Thumbs.db"];function c0(e){return pn(this,void 0,void 0,function*(){return Vs(e)&&d0(e.dataTransfer)?f0(e.dataTransfer,e.type):u0(e)?p0(e):Array.isArray(e)&&e.every(r=>"getFile"in r&&typeof r.getFile=="function")?m0(e):[]})}function d0(e){return Vs(e)}function u0(e){return Vs(e)&&Vs(e.target)}function Vs(e){return typeof e=="object"&&e!==null}function p0(e){return Aa(e.target.files).map(r=>An(r))}function m0(e){return pn(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>n.getFile()))).map(n=>An(n))})}function f0(e,r){return pn(this,void 0,void 0,function*(){if(e.items){const n=Aa(e.items).filter(o=>o.kind==="file");if(r!=="drop")return n;const s=yield Promise.all(n.map(h0));return Tl(au(s))}return Tl(Aa(e.files).map(n=>An(n)))})}function Tl(e){return e.filter(r=>l0.indexOf(r.name)===-1)}function Aa(e){if(e===null)return[];const r=[];for(let n=0;n<e.length;n++){const s=e[n];r.push(s)}return r}function h0(e){if(typeof e.webkitGetAsEntry!="function")return Al(e);const r=e.webkitGetAsEntry();return r&&r.isDirectory?iu(r):Al(e,r)}function au(e){return e.reduce((r,n)=>[...r,...Array.isArray(n)?au(n):[n]],[])}function Al(e,r){return pn(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 l=yield a.getFile();return l.handle=a,An(l)}}const s=e.getAsFile();if(!s)throw new Error(`${e} is not a File`);return An(s,(n=r?.fullPath)!==null&&n!==void 0?n:void 0)})}function g0(e){return pn(this,void 0,void 0,function*(){return e.isDirectory?iu(e):x0(e)})}function iu(e){const r=e.createReader();return new Promise((n,s)=>{const o=[];function a(){r.readEntries(l=>pn(this,void 0,void 0,function*(){if(l.length){const c=Promise.all(l.map(g0));o.push(c),a()}else try{const c=yield Promise.all(o);n(c)}catch(c){s(c)}}),l=>{s(l)})}a()})}function x0(e){return pn(this,void 0,void 0,function*(){return new Promise((r,n)=>{e.file(s=>{const o=An(s,e.fullPath);r(o)},s=>{n(s)})})})}var _s={},_l;function y0(){return _l||(_l=1,_s.__esModule=!0,_s.default=function(e,r){if(e&&r){var n=Array.isArray(r)?r:r.split(",");if(n.length===0)return!0;var s=e.name||"",o=(e.type||"").toLowerCase(),a=o.replace(/\/.*$/,"");return n.some(function(l){var c=l.trim().toLowerCase();return c.charAt(0)==="."?s.toLowerCase().endsWith(c):c.endsWith("/*")?a===c.replace(/\/.*$/,""):o===c})}return!0}),_s}var v0=y0();const la=Rc(v0);function Ml(e){return k0(e)||w0(e)||cu(e)||b0()}function b0(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
252
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function w0(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function k0(e){if(Array.isArray(e))return _a(e)}function Dl(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function Rl(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Dl(Object(n),!0).forEach(function(s){lu(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Dl(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function lu(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Xn(e,r){return S0(e)||N0(e,r)||cu(e,r)||j0()}function j0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
253
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function cu(e,r){if(e){if(typeof e=="string")return _a(e,r);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,r)}}function _a(e,r){(r==null||r>e.length)&&(r=e.length);for(var n=0,s=new Array(r);n<r;n++)s[n]=e[n];return s}function N0(e,r){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,l,c;try{for(n=n.call(e);!(o=(l=n.next()).done)&&(s.push(l.value),!(r&&s.length===r));o=!0);}catch(d){a=!0,c=d}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw c}}return s}}function S0(e){if(Array.isArray(e))return e}var C0=typeof la=="function"?la:la.default,E0="file-invalid-type",I0="file-too-large",T0="file-too-small",A0="too-many-files",_0=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=r.split(","),s=n.length>1?"one of ".concat(n.join(", ")):n[0];return{code:E0,message:"File type must be ".concat(s)}},Pl=function(r){return{code:I0,message:"File is larger than ".concat(r," ").concat(r===1?"byte":"bytes")}},Ll=function(r){return{code:T0,message:"File is smaller than ".concat(r," ").concat(r===1?"byte":"bytes")}},M0={code:A0,message:"Too many files"};function du(e,r){var n=e.type==="application/x-moz-file"||C0(e,r);return[n,n?null:_0(r)]}function uu(e,r,n){if(rn(e.size))if(rn(r)&&rn(n)){if(e.size>n)return[!1,Pl(n)];if(e.size<r)return[!1,Ll(r)]}else{if(rn(r)&&e.size<r)return[!1,Ll(r)];if(rn(n)&&e.size>n)return[!1,Pl(n)]}return[!0,null]}function rn(e){return e!=null}function D0(e){var r=e.files,n=e.accept,s=e.minSize,o=e.maxSize,a=e.multiple,l=e.maxFiles,c=e.validator;return!a&&r.length>1||a&&l>=1&&r.length>l?!1:r.every(function(d){var u=du(d,n),m=Xn(u,1),p=m[0],h=uu(d,s,o),g=Xn(h,1),x=g[0],k=c?c(d):null;return p&&x&&!k})}function Js(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function Ms(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(r){return r==="Files"||r==="application/x-moz-file"}):!!e.target&&!!e.target.files}function Ol(e){e.preventDefault()}function R0(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function P0(e){return e.indexOf("Edge/")!==-1}function L0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return R0(e)||P0(e)}function yr(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return function(s){for(var o=arguments.length,a=new Array(o>1?o-1:0),l=1;l<o;l++)a[l-1]=arguments[l];return r.some(function(c){return!Js(s)&&c&&c.apply(void 0,[s].concat(a)),Js(s)})}}function O0(){return"showOpenFilePicker"in window}function F0(e){if(rn(e)){var r=Object.entries(e).filter(function(n){var s=Xn(n,2),o=s[0],a=s[1],l=!0;return pu(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.')),l=!1),(!Array.isArray(a)||!a.every(mu))&&(console.warn('Skipped "'.concat(o,'" because an invalid file extension was provided.')),l=!1),l}).reduce(function(n,s){var o=Xn(s,2),a=o[0],l=o[1];return Rl(Rl({},n),{},lu({},a,l))},{});return[{description:"Files",accept:r}]}return e}function $0(e){if(rn(e))return Object.entries(e).reduce(function(r,n){var s=Xn(n,2),o=s[0],a=s[1];return[].concat(Ml(r),[o],Ml(a))},[]).filter(function(r){return pu(r)||mu(r)}).join(",")}function z0(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function B0(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function pu(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||e==="application/*"||/\w+\/[-+.\w]+/g.test(e)}function mu(e){return/^.*\.[\w]+$/.test(e)}var W0=["children"],U0=["open"],H0=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],G0=["refKey","onChange","onClick"];function q0(e){return J0(e)||V0(e)||fu(e)||K0()}function K0(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
254
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function V0(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function J0(e){if(Array.isArray(e))return Ma(e)}function ca(e,r){return Q0(e)||X0(e,r)||fu(e,r)||Y0()}function Y0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
255
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fu(e,r){if(e){if(typeof e=="string")return Ma(e,r);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,r)}}function Ma(e,r){(r==null||r>e.length)&&(r=e.length);for(var n=0,s=new Array(r);n<r;n++)s[n]=e[n];return s}function X0(e,r){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,l,c;try{for(n=n.call(e);!(o=(l=n.next()).done)&&(s.push(l.value),!(r&&s.length===r));o=!0);}catch(d){a=!0,c=d}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw c}}return s}}function Q0(e){if(Array.isArray(e))return e}function Fl(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function jt(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Fl(Object(n),!0).forEach(function(s){Da(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fl(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function Da(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Ys(e,r){if(e==null)return{};var n=Z0(e,r),s,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)s=a[o],!(r.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(n[s]=e[s])}return n}function Z0(e,r){if(e==null)return{};var n={},s=Object.keys(e),o,a;for(a=0;a<s.length;a++)o=s[a],!(r.indexOf(o)>=0)&&(n[o]=e[o]);return n}var yi=i.forwardRef(function(e,r){var n=e.children,s=Ys(e,W0),o=gu(s),a=o.open,l=Ys(o,U0);return i.useImperativeHandle(r,function(){return{open:a}},[a]),dn.createElement(i.Fragment,null,n(jt(jt({},l),{},{open:a})))});yi.displayName="Dropzone";var hu={disabled:!1,getFilesFromEvent:c0,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};yi.defaultProps=hu;yi.propTypes={children:dt.func,accept:dt.objectOf(dt.arrayOf(dt.string)),multiple:dt.bool,preventDropOnDocument:dt.bool,noClick:dt.bool,noKeyboard:dt.bool,noDrag:dt.bool,noDragEventsBubbling:dt.bool,minSize:dt.number,maxSize:dt.number,maxFiles:dt.number,disabled:dt.bool,getFilesFromEvent:dt.func,onFileDialogCancel:dt.func,onFileDialogOpen:dt.func,useFsAccessApi:dt.bool,autoFocus:dt.bool,onDragEnter:dt.func,onDragLeave:dt.func,onDragOver:dt.func,onDrop:dt.func,onDropAccepted:dt.func,onDropRejected:dt.func,onError:dt.func,validator:dt.func};var Ra={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function gu(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=jt(jt({},hu),e),n=r.accept,s=r.disabled,o=r.getFilesFromEvent,a=r.maxSize,l=r.minSize,c=r.multiple,d=r.maxFiles,u=r.onDragEnter,m=r.onDragLeave,p=r.onDragOver,h=r.onDrop,g=r.onDropAccepted,x=r.onDropRejected,k=r.onFileDialogCancel,w=r.onFileDialogOpen,A=r.useFsAccessApi,L=r.autoFocus,j=r.preventDropOnDocument,S=r.noClick,D=r.noKeyboard,b=r.noDrag,I=r.noDragEventsBubbling,G=r.onError,P=r.validator,V=i.useMemo(function(){return $0(n)},[n]),ve=i.useMemo(function(){return F0(n)},[n]),ae=i.useMemo(function(){return typeof w=="function"?w:$l},[w]),R=i.useMemo(function(){return typeof k=="function"?k:$l},[k]),q=i.useRef(null),de=i.useRef(null),se=i.useReducer(ey,Ra),he=ca(se,2),Se=he[0],B=he[1],z=Se.isFocused,_=Se.isFileDialogActive,N=i.useRef(typeof window<"u"&&window.isSecureContext&&A&&O0()),O=function(){!N.current&&_&&setTimeout(function(){if(de.current){var Z=de.current.files;Z.length||(B({type:"closeDialog"}),R())}},300)};i.useEffect(function(){return window.addEventListener("focus",O,!1),function(){window.removeEventListener("focus",O,!1)}},[de,_,R,N]);var ne=i.useRef([]),Ce=function(Z){q.current&&q.current.contains(Z.target)||(Z.preventDefault(),ne.current=[])};i.useEffect(function(){return j&&(document.addEventListener("dragover",Ol,!1),document.addEventListener("drop",Ce,!1)),function(){j&&(document.removeEventListener("dragover",Ol),document.removeEventListener("drop",Ce))}},[q,j]),i.useEffect(function(){return!s&&L&&q.current&&q.current.focus(),function(){}},[q,L,s]);var be=i.useCallback(function(W){G?G(W):console.error(W)},[G]),re=i.useCallback(function(W){W.preventDefault(),W.persist(),qe(W),ne.current=[].concat(q0(ne.current),[W.target]),Ms(W)&&Promise.resolve(o(W)).then(function(Z){if(!(Js(W)&&!I)){var we=Z.length,Ae=we>0&&D0({files:Z,accept:V,minSize:l,maxSize:a,multiple:c,maxFiles:d,validator:P}),Xe=we>0&&!Ae;B({isDragAccept:Ae,isDragReject:Xe,isDragActive:!0,type:"setDraggedFiles"}),u&&u(W)}}).catch(function(Z){return be(Z)})},[o,u,be,I,V,l,a,c,d,P]),Ee=i.useCallback(function(W){W.preventDefault(),W.persist(),qe(W);var Z=Ms(W);if(Z&&W.dataTransfer)try{W.dataTransfer.dropEffect="copy"}catch{}return Z&&p&&p(W),!1},[p,I]),nt=i.useCallback(function(W){W.preventDefault(),W.persist(),qe(W);var Z=ne.current.filter(function(Ae){return q.current&&q.current.contains(Ae)}),we=Z.indexOf(W.target);we!==-1&&Z.splice(we,1),ne.current=Z,!(Z.length>0)&&(B({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),Ms(W)&&m&&m(W))},[q,m,I]),De=i.useCallback(function(W,Z){var we=[],Ae=[];W.forEach(function(Xe){var Qe=du(Xe,V),We=ca(Qe,2),Et=We[0],ie=We[1],St=uu(Xe,l,a),et=ca(St,2),ot=et[0],Ke=et[1],Tt=P?P(Xe):null;if(Et&&ot&&!Tt)we.push(Xe);else{var Ot=[ie,Ke];Tt&&(Ot=Ot.concat(Tt)),Ae.push({file:Xe,errors:Ot.filter(function(yt){return yt})})}}),(!c&&we.length>1||c&&d>=1&&we.length>d)&&(we.forEach(function(Xe){Ae.push({file:Xe,errors:[M0]})}),we.splice(0)),B({acceptedFiles:we,fileRejections:Ae,isDragReject:Ae.length>0,type:"setFiles"}),h&&h(we,Ae,Z),Ae.length>0&&x&&x(Ae,Z),we.length>0&&g&&g(we,Z)},[B,c,V,l,a,d,h,g,x,P]),fe=i.useCallback(function(W){W.preventDefault(),W.persist(),qe(W),ne.current=[],Ms(W)&&Promise.resolve(o(W)).then(function(Z){Js(W)&&!I||De(Z,W)}).catch(function(Z){return be(Z)}),B({type:"reset"})},[o,De,be,I]),Ge=i.useCallback(function(){if(N.current){B({type:"openDialog"}),ae();var W={multiple:c,types:ve};window.showOpenFilePicker(W).then(function(Z){return o(Z)}).then(function(Z){De(Z,null),B({type:"closeDialog"})}).catch(function(Z){z0(Z)?(R(Z),B({type:"closeDialog"})):B0(Z)?(N.current=!1,de.current?(de.current.value=null,de.current.click()):be(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."))):be(Z)});return}de.current&&(B({type:"openDialog"}),ae(),de.current.value=null,de.current.click())},[B,ae,R,A,De,be,ve,c]),bt=i.useCallback(function(W){!q.current||!q.current.isEqualNode(W.target)||(W.key===" "||W.key==="Enter"||W.keyCode===32||W.keyCode===13)&&(W.preventDefault(),Ge())},[q,Ge]),st=i.useCallback(function(){B({type:"focus"})},[]),Be=i.useCallback(function(){B({type:"blur"})},[]),Ze=i.useCallback(function(){S||(L0()?setTimeout(Ge,0):Ge())},[S,Ge]),xt=function(Z){return s?null:Z},wt=function(Z){return D?null:xt(Z)},ye=function(Z){return b?null:xt(Z)},qe=function(Z){I&&Z.stopPropagation()},Nt=i.useMemo(function(){return function(){var W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},Z=W.refKey,we=Z===void 0?"ref":Z,Ae=W.role,Xe=W.onKeyDown,Qe=W.onFocus,We=W.onBlur,Et=W.onClick,ie=W.onDragEnter,St=W.onDragOver,et=W.onDragLeave,ot=W.onDrop,Ke=Ys(W,H0);return jt(jt(Da({onKeyDown:wt(yr(Xe,bt)),onFocus:wt(yr(Qe,st)),onBlur:wt(yr(We,Be)),onClick:xt(yr(Et,Ze)),onDragEnter:ye(yr(ie,re)),onDragOver:ye(yr(St,Ee)),onDragLeave:ye(yr(et,nt)),onDrop:ye(yr(ot,fe)),role:typeof Ae=="string"&&Ae!==""?Ae:"presentation"},we,q),!s&&!D?{tabIndex:0}:{}),Ke)}},[q,bt,st,Be,Ze,re,Ee,nt,fe,D,b,s]),X=i.useCallback(function(W){W.stopPropagation()},[]),Te=i.useMemo(function(){return function(){var W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},Z=W.refKey,we=Z===void 0?"ref":Z,Ae=W.onChange,Xe=W.onClick,Qe=Ys(W,G0),We=Da({accept:V,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:xt(yr(Ae,fe)),onClick:xt(yr(Xe,X)),tabIndex:-1},we,de);return jt(jt({},We),Qe)}},[de,n,c,fe,s]);return jt(jt({},Se),{},{isFocused:z&&!s,getRootProps:Nt,getInputProps:Te,rootRef:q,inputRef:de,open:xt(Ge)})}function ey(e,r){switch(r.type){case"focus":return jt(jt({},e),{},{isFocused:!0});case"blur":return jt(jt({},e),{},{isFocused:!1});case"openDialog":return jt(jt({},Ra),{},{isFileDialogActive:!0});case"closeDialog":return jt(jt({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return jt(jt({},e),{},{isDragActive:r.isDragActive,isDragAccept:r.isDragAccept,isDragReject:r.isDragReject});case"setFiles":return jt(jt({},e),{},{acceptedFiles:r.acceptedFiles,fileRejections:r.fileRejections,isDragReject:r.isDragReject});case"reset":return jt({},Ra);default:return e}}function $l(){}const Hn=({children:e,content:r,position:n="top",className:s="",delay:o=500})=>{const[a,l]=i.useState(!1),[c,d]=i.useState(null),u=()=>{const g=setTimeout(()=>{l(!0)},o);d(g)},m=()=>{c&&(clearTimeout(c),d(null)),l(!1)},p=()=>{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 r?t.jsxs("div",{className:"relative inline-block",onMouseEnter:u,onMouseLeave:m,children:[e,a&&t.jsxs("div",{className:ut("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",p(),s),children:[r,t.jsx("div",{className:ut("absolute w-0 h-0 border-4 border-transparent",h())})]})]}):e};function ty(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function zl(e){return e==null?null:typeof e=="string"?{content:e,isError:!1,toolUseResult:null}:{content:ty(e.content??e.output??e.result??""),isError:!!e.isError,toolUseResult:e.toolUseResult||null,exitCode:e.exitCode??e.exit_code}}function Bl(e,r){return e||""}function ry(e){const r=String(e||"").replace(/\\\s*\n\s*/g," ").trim();if(!r)return"";const s=r.split(/\s*(?:&&|\|\||;|\|)\s*/).map(o=>o.trim()).filter(Boolean).map(o=>o.split(/\s+/)[0]).filter(Boolean);return s.length===0?r:s.slice(0,4).join(" · ")+(s.length>4?"…":"")}function ny(e,r,n){return r?.file_path?r.file_path:r?.path?r.path:e==="Read"&&typeof n=="string"?n:""}function sy(e,r,n,s){const o=ny(e,r,r),a=Bl(o);if(e==="Bash"){const l=r?.command||"";return{activityKind:"command",title:s("activity.actions.runCommand"),summary:ry(l)||s("activity.actions.commandPending"),filePath:o,icon:ih,heavy:!0}}if(e==="Grep"||e==="Glob"){const l=r?.pattern||r?.glob||"",c=Bl(r?.path||""),d=[];return l&&d.push(l),c&&d.push(c),{activityKind:"search",title:s("activity.actions.searchContent"),summary:d.join(" · ")||s("activity.actions.searchPending"),filePath:r?.path||"",icon:Sa,heavy:!1}}return e==="Read"?{activityKind:"read",title:s("activity.actions.readFile"),summary:a||s("activity.actions.readPending"),filePath:o,icon:yf,heavy:!1}:e==="Edit"||e==="ApplyPatch"?{activityKind:"edit",title:s("activity.actions.updateFile"),summary:a||s("activity.actions.filePending"),filePath:o,icon:ff,heavy:!0}:e==="Write"?{activityKind:"write",title:s("activity.actions.createFile"),summary:a||s("activity.actions.filePending"),filePath:o,icon:gf,heavy:!0}:e==="TodoWrite"?{activityKind:"todo-write",title:s("activity.actions.updateTodo"),summary:s("activity.actions.todoSummary"),filePath:"",icon:gl,heavy:!0}:e==="TodoRead"?{activityKind:"todo-read",title:s("activity.actions.readTodo"),summary:s("activity.actions.todoSummary"),filePath:"",icon:gl,heavy:!1}:e==="exit_plan_mode"?{activityKind:"plan",title:s("activity.actions.generatePlan"),summary:s("activity.actions.planSummary"),filePath:"",icon:oi,heavy:!0}:{activityKind:"tool",title:s("activity.actions.runTool"),summary:e,filePath:o,icon:gh,heavy:!0}}function oy({children:e,tone:r="default"}){const n=r==="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 t.jsx("pre",{className:ut("overflow-x-auto rounded-lg border px-3 py-2 text-xs whitespace-pre-wrap break-words font-mono",n),children:e})}function ay({status:e,messages:r=[],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=[...r].reverse().find(a=>a?.isToolUse);if(o&&!zl(o.toolResult)){const a=ti(o.toolInput)||{},l=zl(o.toolResult),c=sy(o.toolName,a,null,s);return{phaseText:l?.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 iy({request:e,permissionEntry:r,alreadyAllowed:n,rawInput:s,onAllowOnce:o,onAllowRemember:a,onDeny:l,className:c}){const{t:d}=Lt("chat"),u=d(n?"activity.permission.rememberSaved":"activity.permission.remember"),m=Oc(e.toolName);return t.jsx("div",{className:ut("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:t.jsxs("div",{className:"flex items-start gap-3",children:[t.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:t.jsx(Rm,{className:"h-4 w-4"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("div",{className:"text-sm font-semibold text-amber-950 dark:text-amber-100",children:d("activity.permission.title")}),t.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:m})]}),t.jsx("div",{className:"mt-1 text-xs text-amber-800 dark:text-amber-200",children:d("activity.requestTool",{tool:m||d("messageTypes.tool")})}),r?t.jsxs("div",{className:"mt-2 text-xs text-amber-700/90 dark:text-amber-300/80",children:[d("activity.permission.rule")," ",t.jsx("span",{className:"font-mono",children:r})]}):null,s?t.jsxs("details",{className:"mt-3 group",children:[t.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:[t.jsx(Ar,{className:"h-3.5 w-3.5 transition-transform group-open:rotate-180"}),d("activity.permission.viewInput")]}),t.jsx(oy,{tone:"default",children:s})]}):null,t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[t.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")}),t.jsx("button",{type:"button",onClick:a,disabled:!r,className:ut("inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium transition-colors",r?"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}),t.jsx("button",{type:"button",onClick:l,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 ly(e){if(typeof e=="string")return e;let r=e+"";return r=="0"&&1/e==-1/0?"-0":r}function cy(e){return e==null?"":ly(e)}function br(e){return typeof e=="string"}function xu(e){return typeof e=="number"}function dy(e){return e===!0||e===!1||uy(e)&&vu(e)=="[object Boolean]"}function yu(e){return typeof e=="object"}function uy(e){return yu(e)&&e!==null}function er(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 py="Incorrect 'index' type",my=e=>`Invalid value for key ${e}`,fy=e=>`Pattern length exceeds max of ${e}.`,hy=e=>`Missing ${e} property in key`,gy=e=>`Property 'weight' in key '${e}' must be a positive integer`,Wl=Object.prototype.hasOwnProperty;class xy{constructor(r){this._keys=[],this._keyMap={};let n=0;r.forEach(s=>{let o=bu(s);this._keys.push(o),this._keyMap[o.id]=o,n+=o.weight}),this._keys.forEach(s=>{s.weight/=n})}get(r){return this._keyMap[r]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function bu(e){let r=null,n=null,s=null,o=1,a=null;if(br(e)||Mr(e))s=e,r=Ul(e),n=Pa(e);else{if(!Wl.call(e,"name"))throw new Error(hy("name"));const l=e.name;if(s=l,Wl.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(gy(l));r=Ul(l),n=Pa(l),a=e.getFn}return{path:r,id:n,weight:o,src:s,getFn:a}}function Ul(e){return Mr(e)?e:e.split(".")}function Pa(e){return Mr(e)?e.join("."):e}function yy(e,r){let n=[],s=!1;const o=(a,l,c)=>{if(er(a))if(!l[c])n.push(a);else{let d=l[c];const u=a[d];if(!er(u))return;if(c===l.length-1&&(br(u)||xu(u)||dy(u)))n.push(cy(u));else if(Mr(u)){s=!0;for(let m=0,p=u.length;m<p;m+=1)o(u[m],l,c+1)}else l.length&&o(u,l,c+1)}};return o(e,br(r)?r.split("."):r,0),s?n:n[0]}const vy={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},by={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,r)=>e.score===r.score?e.idx<r.idx?-1:1:e.score<r.score?-1:1},wy={location:0,threshold:.6,distance:100},ky={useExtendedSearch:!1,getFn:yy,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Me={...by,...vy,...wy,...ky};const jy=/[^ ]+/g;function Ny(e=1,r=3){const n=new Map,s=Math.pow(10,r);return{get(o){const a=o.match(jy).length;if(n.has(a))return n.get(a);const l=1/Math.pow(a,.5*e),c=parseFloat(Math.round(l*s)/s);return n.set(a,c),c},clear(){n.clear()}}}class vi{constructor({getFn:r=Me.getFn,fieldNormWeight:n=Me.fieldNormWeight}={}){this.norm=Ny(n,3),this.getFn=r,this.isCreated=!1,this.setIndexRecords()}setSources(r=[]){this.docs=r}setIndexRecords(r=[]){this.records=r}setKeys(r=[]){this.keys=r,this._keysMap={},r.forEach((n,s)=>{this._keysMap[n.id]=s})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,br(this.docs[0])?this.docs.forEach((r,n)=>{this._addString(r,n)}):this.docs.forEach((r,n)=>{this._addObject(r,n)}),this.norm.clear())}add(r){const n=this.size();br(r)?this._addString(r,n):this._addObject(r,n)}removeAt(r){this.records.splice(r,1);for(let n=r,s=this.size();n<s;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(r,n){return r[this._keysMap[n]]}size(){return this.records.length}_addString(r,n){if(!er(r)||da(r))return;let s={v:r,i:n,n:this.norm.get(r)};this.records.push(s)}_addObject(r,n){let s={i:n,$:{}};this.keys.forEach((o,a)=>{let l=o.getFn?o.getFn(r):this.getFn(r,o.path);if(er(l)){if(Mr(l)){let c=[];const d=[{nestedArrIndex:-1,value:l}];for(;d.length;){const{nestedArrIndex:u,value:m}=d.pop();if(er(m))if(br(m)&&!da(m)){let p={v:m,i:u,n:this.norm.get(m)};c.push(p)}else Mr(m)&&m.forEach((p,h)=>{d.push({nestedArrIndex:h,value:p})})}s.$[a]=c}else if(br(l)&&!da(l)){let c={v:l,n:this.norm.get(l)};s.$[a]=c}}}),this.records.push(s)}toJSON(){return{keys:this.keys,records:this.records}}}function wu(e,r,{getFn:n=Me.getFn,fieldNormWeight:s=Me.fieldNormWeight}={}){const o=new vi({getFn:n,fieldNormWeight:s});return o.setKeys(e.map(bu)),o.setSources(r),o.create(),o}function Sy(e,{getFn:r=Me.getFn,fieldNormWeight:n=Me.fieldNormWeight}={}){const{keys:s,records:o}=e,a=new vi({getFn:r,fieldNormWeight:n});return a.setKeys(s),a.setIndexRecords(o),a}function Ds(e,{errors:r=0,currentLocation:n=0,expectedLocation:s=0,distance:o=Me.distance,ignoreLocation:a=Me.ignoreLocation}={}){const l=r/e.length;if(a)return l;const c=Math.abs(s-n);return o?l+c/o:c?1:l}function Cy(e=[],r=Me.minMatchCharLength){let n=[],s=-1,o=-1,a=0;for(let l=e.length;a<l;a+=1){let c=e[a];c&&s===-1?s=a:!c&&s!==-1&&(o=a-1,o-s+1>=r&&n.push([s,o]),s=-1)}return e[a-1]&&a-s>=r&&n.push([s,a-1]),n}const nn=32;function Ey(e,r,n,{location:s=Me.location,distance:o=Me.distance,threshold:a=Me.threshold,findAllMatches:l=Me.findAllMatches,minMatchCharLength:c=Me.minMatchCharLength,includeMatches:d=Me.includeMatches,ignoreLocation:u=Me.ignoreLocation}={}){if(r.length>nn)throw new Error(fy(nn));const m=r.length,p=e.length,h=Math.max(0,Math.min(s,p));let g=a,x=h;const k=c>1||d,w=k?Array(p):[];let A;for(;(A=e.indexOf(r,x))>-1;){let I=Ds(r,{currentLocation:A,expectedLocation:h,distance:o,ignoreLocation:u});if(g=Math.min(I,g),x=A+m,k){let G=0;for(;G<m;)w[A+G]=1,G+=1}}x=-1;let L=[],j=1,S=m+p;const D=1<<m-1;for(let I=0;I<m;I+=1){let G=0,P=S;for(;G<P;)Ds(r,{errors:I,currentLocation:h+P,expectedLocation:h,distance:o,ignoreLocation:u})<=g?G=P:S=P,P=Math.floor((S-G)/2+G);S=P;let V=Math.max(1,h-P+1),ve=l?p:Math.min(h+P,p)+m,ae=Array(ve+2);ae[ve+1]=(1<<I)-1;for(let q=ve;q>=V;q-=1){let de=q-1,se=n[e.charAt(de)];if(k&&(w[de]=+!!se),ae[q]=(ae[q+1]<<1|1)&se,I&&(ae[q]|=(L[q+1]|L[q])<<1|1|L[q+1]),ae[q]&D&&(j=Ds(r,{errors:I,currentLocation:de,expectedLocation:h,distance:o,ignoreLocation:u}),j<=g)){if(g=j,x=de,x<=h)break;V=Math.max(1,2*h-x)}}if(Ds(r,{errors:I+1,currentLocation:h,expectedLocation:h,distance:o,ignoreLocation:u})>g)break;L=ae}const b={isMatch:x>=0,score:Math.max(.001,j)};if(k){const I=Cy(w,c);I.length?d&&(b.indices=I):b.isMatch=!1}return b}function Iy(e){let r={};for(let n=0,s=e.length;n<s;n+=1){const o=e.charAt(n);r[o]=(r[o]||0)|1<<s-n-1}return r}const Xs=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 ku{constructor(r,{location:n=Me.location,threshold:s=Me.threshold,distance:o=Me.distance,includeMatches:a=Me.includeMatches,findAllMatches:l=Me.findAllMatches,minMatchCharLength:c=Me.minMatchCharLength,isCaseSensitive:d=Me.isCaseSensitive,ignoreDiacritics:u=Me.ignoreDiacritics,ignoreLocation:m=Me.ignoreLocation}={}){if(this.options={location:n,threshold:s,distance:o,includeMatches:a,findAllMatches:l,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:m},r=d?r:r.toLowerCase(),r=u?Xs(r):r,this.pattern=r,this.chunks=[],!this.pattern.length)return;const p=(g,x)=>{this.chunks.push({pattern:g,alphabet:Iy(g),startIndex:x})},h=this.pattern.length;if(h>nn){let g=0;const x=h%nn,k=h-x;for(;g<k;)p(this.pattern.substr(g,nn),g),g+=nn;if(x){const w=h-nn;p(this.pattern.substr(w),w)}}else p(this.pattern,0)}searchIn(r){const{isCaseSensitive:n,ignoreDiacritics:s,includeMatches:o}=this.options;if(r=n?r:r.toLowerCase(),r=s?Xs(r):r,this.pattern===r){let k={isMatch:!0,score:0};return o&&(k.indices=[[0,r.length-1]]),k}const{location:a,distance:l,threshold:c,findAllMatches:d,minMatchCharLength:u,ignoreLocation:m}=this.options;let p=[],h=0,g=!1;this.chunks.forEach(({pattern:k,alphabet:w,startIndex:A})=>{const{isMatch:L,score:j,indices:S}=Ey(r,k,w,{location:a+A,distance:l,threshold:c,findAllMatches:d,minMatchCharLength:u,includeMatches:o,ignoreLocation:m});L&&(g=!0),h+=j,L&&S&&(p=[...p,...S])});let x={isMatch:g,score:g?h/this.chunks.length:1};return g&&o&&(x.indices=p),x}}class Vr{constructor(r){this.pattern=r}static isMultiMatch(r){return Hl(r,this.multiRegex)}static isSingleMatch(r){return Hl(r,this.singleRegex)}search(){}}function Hl(e,r){const n=e.match(r);return n?n[1]:null}class Ty extends Vr{constructor(r){super(r)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(r){const n=r===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class Ay extends Vr{constructor(r){super(r)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(r){const s=r.indexOf(this.pattern)===-1;return{isMatch:s,score:s?0:1,indices:[0,r.length-1]}}}class _y extends Vr{constructor(r){super(r)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(r){const n=r.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class My extends Vr{constructor(r){super(r)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(r){const n=!r.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,r.length-1]}}}class Dy extends Vr{constructor(r){super(r)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(r){const n=r.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[r.length-this.pattern.length,r.length-1]}}}class Ry extends Vr{constructor(r){super(r)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(r){const n=!r.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,r.length-1]}}}class ju extends Vr{constructor(r,{location:n=Me.location,threshold:s=Me.threshold,distance:o=Me.distance,includeMatches:a=Me.includeMatches,findAllMatches:l=Me.findAllMatches,minMatchCharLength:c=Me.minMatchCharLength,isCaseSensitive:d=Me.isCaseSensitive,ignoreDiacritics:u=Me.ignoreDiacritics,ignoreLocation:m=Me.ignoreLocation}={}){super(r),this._bitapSearch=new ku(r,{location:n,threshold:s,distance:o,includeMatches:a,findAllMatches:l,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:m})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(r){return this._bitapSearch.searchIn(r)}}class Nu extends Vr{constructor(r){super(r)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(r){let n=0,s;const o=[],a=this.pattern.length;for(;(s=r.indexOf(this.pattern,n))>-1;)n=s+a,o.push([s,n-1]);const l=!!o.length;return{isMatch:l,score:l?0:1,indices:o}}}const La=[Ty,Nu,_y,My,Ry,Dy,Ay,ju],Gl=La.length,Py=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Ly="|";function Oy(e,r={}){return e.split(Ly).map(n=>{let s=n.trim().split(Py).filter(a=>a&&!!a.trim()),o=[];for(let a=0,l=s.length;a<l;a+=1){const c=s[a];let d=!1,u=-1;for(;!d&&++u<Gl;){const m=La[u];let p=m.isMultiMatch(c);p&&(o.push(new m(p,r)),d=!0)}if(!d)for(u=-1;++u<Gl;){const m=La[u];let p=m.isSingleMatch(c);if(p){o.push(new m(p,r));break}}}return o})}const Fy=new Set([ju.type,Nu.type]);class $y{constructor(r,{isCaseSensitive:n=Me.isCaseSensitive,ignoreDiacritics:s=Me.ignoreDiacritics,includeMatches:o=Me.includeMatches,minMatchCharLength:a=Me.minMatchCharLength,ignoreLocation:l=Me.ignoreLocation,findAllMatches:c=Me.findAllMatches,location:d=Me.location,threshold:u=Me.threshold,distance:m=Me.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:s,includeMatches:o,minMatchCharLength:a,findAllMatches:c,ignoreLocation:l,location:d,threshold:u,distance:m},r=n?r:r.toLowerCase(),r=s?Xs(r):r,this.pattern=r,this.query=Oy(this.pattern,this.options)}static condition(r,n){return n.useExtendedSearch}searchIn(r){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:s,isCaseSensitive:o,ignoreDiacritics:a}=this.options;r=o?r:r.toLowerCase(),r=a?Xs(r):r;let l=0,c=[],d=0;for(let u=0,m=n.length;u<m;u+=1){const p=n[u];c.length=0,l=0;for(let h=0,g=p.length;h<g;h+=1){const x=p[h],{isMatch:k,indices:w,score:A}=x.search(r);if(k){if(l+=1,d+=A,s){const L=x.constructor.type;Fy.has(L)?c=[...c,...w]:c.push(w)}}else{d=0,l=0,c.length=0;break}}if(l){let h={isMatch:!0,score:d/l};return s&&(h.indices=c),h}}return{isMatch:!1,score:1}}}const Oa=[];function zy(...e){Oa.push(...e)}function Fa(e,r){for(let n=0,s=Oa.length;n<s;n+=1){let o=Oa[n];if(o.condition(e,r))return new o(e,r)}return new ku(e,r)}const Qs={AND:"$and",OR:"$or"},$a={PATH:"$path",PATTERN:"$val"},za=e=>!!(e[Qs.AND]||e[Qs.OR]),By=e=>!!e[$a.PATH],Wy=e=>!Mr(e)&&yu(e)&&!za(e),ql=e=>({[Qs.AND]:Object.keys(e).map(r=>({[r]:e[r]}))});function Su(e,r,{auto:n=!0}={}){const s=o=>{let a=Object.keys(o);const l=By(o);if(!l&&a.length>1&&!za(o))return s(ql(o));if(Wy(o)){const d=l?o[$a.PATH]:a[0],u=l?o[$a.PATTERN]:o[d];if(!br(u))throw new Error(my(d));const m={keyId:Pa(d),pattern:u};return n&&(m.searcher=Fa(u,r)),m}let c={children:[],operator:a[0]};return a.forEach(d=>{const u=o[d];Mr(u)&&u.forEach(m=>{c.children.push(s(m))})}),c};return za(e)||(e=ql(e)),s(e)}function Uy(e,{ignoreFieldNorm:r=Me.ignoreFieldNorm}){e.forEach(n=>{let s=1;n.matches.forEach(({key:o,norm:a,score:l})=>{const c=o?o.weight:null;s*=Math.pow(l===0&&c?Number.EPSILON:l,(c||1)*(r?1:a))}),n.score=s})}function Hy(e,r){const n=e.matches;r.matches=[],er(n)&&n.forEach(s=>{if(!er(s.indices)||!s.indices.length)return;const{indices:o,value:a}=s;let l={indices:o,value:a};s.key&&(l.key=s.key.src),s.idx>-1&&(l.refIndex=s.idx),r.matches.push(l)})}function Gy(e,r){r.score=e.score}function qy(e,r,{includeMatches:n=Me.includeMatches,includeScore:s=Me.includeScore}={}){const o=[];return n&&o.push(Hy),s&&o.push(Gy),e.map(a=>{const{idx:l}=a,c={item:r[l],refIndex:l};return o.length&&o.forEach(d=>{d(a,c)}),c})}class Ln{constructor(r,n={},s){this.options={...Me,...n},this.options.useExtendedSearch,this._keyStore=new xy(this.options.keys),this.setCollection(r,s)}setCollection(r,n){if(this._docs=r,n&&!(n instanceof vi))throw new Error(py);this._myIndex=n||wu(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(r){er(r)&&(this._docs.push(r),this._myIndex.add(r))}remove(r=()=>!1){const n=[];for(let s=0,o=this._docs.length;s<o;s+=1){const a=this._docs[s];r(a,s)&&(this.removeAt(s),s-=1,o-=1,n.push(a))}return n}removeAt(r){this._docs.splice(r,1),this._myIndex.removeAt(r)}getIndex(){return this._myIndex}search(r,{limit:n=-1}={}){const{includeMatches:s,includeScore:o,shouldSort:a,sortFn:l,ignoreFieldNorm:c}=this.options;let d=br(r)?br(this._docs[0])?this._searchStringList(r):this._searchObjectList(r):this._searchLogical(r);return Uy(d,{ignoreFieldNorm:c}),a&&d.sort(l),xu(n)&&n>-1&&(d=d.slice(0,n)),qy(d,this._docs,{includeMatches:s,includeScore:o})}_searchStringList(r){const n=Fa(r,this.options),{records:s}=this._myIndex,o=[];return s.forEach(({v:a,i:l,n:c})=>{if(!er(a))return;const{isMatch:d,score:u,indices:m}=n.searchIn(a);d&&o.push({item:a,idx:l,matches:[{score:u,value:a,norm:c,indices:m}]})}),o}_searchLogical(r){const n=Su(r,this.options),s=(c,d,u)=>{if(!c.children){const{keyId:p,searcher:h}=c,g=this._findMatches({key:this._keyStore.get(p),value:this._myIndex.getValueForItemAtKeyId(d,p),searcher:h});return g&&g.length?[{idx:u,item:d,matches:g}]:[]}const m=[];for(let p=0,h=c.children.length;p<h;p+=1){const g=c.children[p],x=s(g,d,u);if(x.length)m.push(...x);else if(c.operator===Qs.AND)return[]}return m},o=this._myIndex.records,a={},l=[];return o.forEach(({$:c,i:d})=>{if(er(c)){let u=s(n,c,d);u.length&&(a[d]||(a[d]={idx:d,item:c,matches:[]},l.push(a[d])),u.forEach(({matches:m})=>{a[d].matches.push(...m)}))}}),l}_searchObjectList(r){const n=Fa(r,this.options),{keys:s,records:o}=this._myIndex,a=[];return o.forEach(({$:l,i:c})=>{if(!er(l))return;let d=[];s.forEach((u,m)=>{d.push(...this._findMatches({key:u,value:l[m],searcher:n}))}),d.length&&a.push({idx:c,item:l,matches:d})}),a}_findMatches({key:r,value:n,searcher:s}){if(!er(n))return[];let o=[];if(Mr(n))n.forEach(({v:a,i:l,n:c})=>{if(!er(a))return;const{isMatch:d,score:u,indices:m}=s.searchIn(a);d&&o.push({score:u,key:r,value:a,idx:l,norm:c,indices:m})});else{const{v:a,n:l}=n,{isMatch:c,score:d,indices:u}=s.searchIn(a);c&&o.push({score:d,key:r,value:a,norm:l,indices:u})}return o}}Ln.version="7.1.0";Ln.createIndex=wu;Ln.parseIndex=Sy;Ln.config=Me;Ln.parseQuery=Su;zy($y);const Ky=({commands:e=[],selectedIndex:r=-1,onSelect:n,onClose:s,position:o={top:0,left:0},isOpen:a=!1,frequentCommands:l=[]})=>{const c=i.useRef(null),d=i.useRef(null),m=(()=>{const L=window.innerWidth<640,j=window.innerHeight;return L?{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,j-316))}px`,left:`${o.left}px`,width:"min(400px, calc(100vw - 32px))",maxWidth:"calc(100vw - 32px)",maxHeight:"300px"}})();if(i.useEffect(()=>{const L=j=>{c.current&&!c.current.contains(j.target)&&a&&s()};if(a)return document.addEventListener("mousedown",L),()=>{document.removeEventListener("mousedown",L)}},[a,s]),i.useEffect(()=>{if(d.current&&c.current){const L=c.current.getBoundingClientRect(),j=d.current.getBoundingClientRect();j.bottom>L.bottom?d.current.scrollIntoView({block:"nearest",behavior:"smooth"}):j.top<L.top&&d.current.scrollIntoView({block:"nearest",behavior:"smooth"})}},[r]),!a)return null;if(e.length===0)return t.jsx("div",{ref:c,className:"command-menu command-menu-empty",style:{...m,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 p=l.length>0,h=e.reduce((L,j)=>{const S=j.namespace||j.type||"other";return L[S]||(L[S]=[]),L[S].push(j),L},{});p&&(h.frequent=l);const x=(p?["frequent","builtin","project","user","other"]:["builtin","project","user","other"]).filter(L=>h[L]),k={frequent:"⭐ Frequently Used",builtin:"Built-in Commands",project:"Project Commands",user:"User Commands",other:"Other Commands"};let w=0;const A=[];return x.forEach(L=>{h[L].forEach(j=>{A.push({...j,globalIndex:w++,namespace:L})})}),t.jsxs("div",{ref:c,role:"listbox","aria-label":"Available commands",className:"command-menu",style:{...m,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(L=>t.jsxs("div",{className:"command-group",children:[x.length>1&&t.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"#6b7280",padding:"8px 12px 4px",letterSpacing:"0.05em"},children:k[L]||L}),h[L].map(j=>{const S=A.find(b=>b.name===j.name&&b.namespace===L),D=S&&S.globalIndex===r;return t.jsxs("div",{ref:D?d:null,role:"option","aria-selected":D,className:"command-item",onMouseEnter:()=>n&&n(j,S.globalIndex,!0),onClick:()=>n&&n(j,S.globalIndex,!1),style:{display:"flex",alignItems:"flex-start",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",backgroundColor:D?"#eff6ff":"transparent",transition:"background-color 100ms ease-in-out",marginBottom:"2px"},onMouseDown:b=>b.preventDefault(),children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:j.description?"4px":0},children:[t.jsxs("span",{style:{fontSize:"16px",flexShrink:0},children:[L==="builtin"&&"⚡",L==="project"&&"📁",L==="user"&&"👤",L==="other"&&"📝"]}),t.jsx("span",{style:{fontWeight:600,fontSize:"14px",color:"#111827",fontFamily:"monospace"},children:j.name}),j.metadata?.type&&t.jsx("span",{className:"command-metadata-badge",style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",backgroundColor:"#f3f4f6",color:"#6b7280",fontWeight:500},children:j.metadata.type})]}),j.description&&t.jsx("div",{style:{fontSize:"13px",color:"#6b7280",marginLeft:"24px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:j.description})]}),D&&t.jsx("span",{style:{marginLeft:"8px",color:"#3b82f6",fontSize:"12px",fontWeight:600},children:"↵"})]},`${L}-${j.name}`)})]},L)),t.jsx("style",{children:`
256
- .command-menu {
257
- background-color: white;
258
- border: 1px solid #e5e7eb;
259
- }
260
- .command-menu-empty {
261
- color: #6b7280;
262
- }
263
-
264
- @media (prefers-color-scheme: dark) {
265
- .command-menu {
266
- background-color: #1f2937 !important;
267
- border: 1px solid #374151 !important;
268
- }
269
- .command-menu-empty {
270
- color: #9ca3af !important;
271
- }
272
- .command-item[aria-selected="true"] {
273
- background-color: #1e40af !important;
274
- }
275
- .command-item span:not(.command-metadata-badge) {
276
- color: #f3f4f6 !important;
277
- }
278
- .command-metadata-badge {
279
- background-color: #f3f4f6 !important;
280
- color: #6b7280 !important;
281
- }
282
- .command-item div {
283
- color: #d1d5db !important;
284
- }
285
- .command-group > div:first-child {
286
- color: #9ca3af !important;
287
- }
288
- }
289
- `})]})},Cu={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"},bi={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"},Eu={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"},Iu={OPTIONS:[{value:"kimi-k2.5",label:"Kimi K2.5"}],DEFAULT:"kimi-k2.5"},Le={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 mr(e="evt"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}:${crypto.randomUUID()}`:`${e}:${Date.now()}:${Math.random().toString(36).slice(2,10)}`}function Tu(e){if(!e)return new Date().toISOString();if(e instanceof Date)return e.toISOString();const r=new Date(e);return Number.isNaN(r.getTime())?new Date().toISOString():r.toISOString()}function Ht({kind:e,provider:r="claude",sessionId:n=null,timestamp:s,payload:o={},extensions:a={},rawRef:l=null,eventId:c=null}){return{eventId:c||mr(e),kind:e,provider:r,sessionId:n,timestamp:Tu(s),payload:o,extensions:a,rawRef:l}}function Au(e){return!!(e&&typeof e=="object"&&typeof e.kind=="string"&&typeof e.eventId=="string")}function ua({kindPrefix:e="assistant_text",text:r,provider:n,sessionId:s,timestamp:o,messageId:a,extensions:l={},rawRef:c=null}){if(typeof r!="string"||!r.trim())return[];const d=a||mr(e),u={...l,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:r},extensions:u,rawRef:c}),Ht({kind:`${e}_end`,provider:n,sessionId:s,timestamp:o,payload:{messageId:d},extensions:u,rawRef:c})]}function Vy(e){const r=String(e||"").trim();if(!r||r.startsWith("# AGENTS.md instructions for ")||r.includes("<environment_context>"))return"";if(r.startsWith("[DYNAMIC CONTEXT V1]")){const s=`
290
-
291
- [USER MESSAGE]
292
- `,o=r.indexOf(s);return o>=0?r.slice(o+s.length).trim():""}const n=r.match(/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i);return n?String(n[1]||"").trim():r}function pa(e){const r=String(e||"").trim();return!r||r.startsWith("[System Context]")||r.startsWith("[Attached Context]")||r.startsWith("[Dynamic Context]")||r.startsWith("[Hidden Context]")||r.startsWith("# AGENTS.md instructions for ")||r.startsWith("[DYNAMIC CONTEXT V1]")?!0:/^<dynamic_context(?:\s|>)/i.test(r)||r.includes("<environment_context>")}function Nn(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e)}catch{return String(e)}}function Jy(e){const r=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&&r.set(s.tool_use_id,{content:s.content,isError:!!s.is_error,timestamp:n.timestamp,toolUseResult:n.toolUseResult||null});return r}function Zs(e,r){for(let n=e.length-1;n>=0;n-=1)if(r(e[n],n))return n;return-1}function Kl(e="",r=""){return r?e?e.endsWith(r)?e:`${e}${r}`:r:e}function Rs(e,{messageId:r,timestamp:n,provider:s,isThinking:o=!1,kind:a="assistant"}){const l=Zs(e,d=>d?.eventMessageId===r&&!!d?.isStreaming&&!d.isToolUse&&!!d.isThinking==!!o);if(l>=0){const d={...e[l]};return d.isStreaming=!0,s&&(d.provider=s),n&&(d.timestamp=d.timestamp||n),e[l]=d,{messages:e,index:l}}const c={type:a,content:"",timestamp:n,provider:s,isStreaming:!0,eventMessageId:r};return o&&(c.isThinking=!0),e.push(c),{messages:e,index:e.length-1}}function Ps(e,{toolCallId:r,toolName:n,timestamp:s,provider:o}){const a=Zs(e,l=>l?.isToolUse&&(l.toolId===r||l.toolCallId===r));if(a>=0){const l={...e[a]};return n&&(l.toolName=n),o&&(l.provider=o),s&&!l.timestamp&&(l.timestamp=s),e[a]=l,{messages:e,index:a}}return e.push({type:"assistant",content:"",timestamp:s,provider:o,isToolUse:!0,toolName:n||"Unknown Tool",toolId:r,toolCallId:r}),{messages:e,index:e.length-1}}function Yy(e=[],r="claude",n=null){if(!Array.isArray(e))return[];const s=[],o=Jy(e);for(const a of e){const l=Tu(a?.timestamp),c={provider:r,timestamp:l,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(m=>m?.type==="text").map(m=>m?.text||"").join(`
293
- `):d=typeof a.message.content=="string"?a.message.content:String(a.message.content||"");const u=Vy(d);u&&(!pa(d)||u!==d)&&s.push(Ht({kind:Le.USER_MESSAGE,provider:r,sessionId:n,timestamp:l,payload:{text:u},rawRef:c}));continue}if(a?.type==="thinking"&&a?.message?.content){s.push(...ua({kindPrefix:"reasoning",text:a.message.content,provider:r,sessionId:n,timestamp:l,rawRef:c}));continue}if(a?.type==="tool_use"&&a?.toolName){const d=a.toolCallId||mr("tool"),u=a.toolResult||null;s.push(Ht({kind:Le.TOOL_CALL_START,provider:r,sessionId:n,timestamp:l,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),s.push(Ht({kind:Le.TOOL_CALL_INPUT,provider:r,sessionId:n,timestamp:l,payload:{toolCallId:d,input:a.toolInput||""},rawRef:c})),s.push(Ht({kind:Le.TOOL_CALL_END,provider:r,sessionId:n,timestamp:l,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),u&&s.push(Ht({kind:Le.TOOL_RESULT,provider:r,sessionId:n,timestamp:u.timestamp||l,payload:{toolCallId:d,content:Nn(u.content),isError:!!u.isError,toolUseResult:u.toolUseResult||null},rawRef:c}));continue}if(a?.type==="tool_result"){s.push(Ht({kind:Le.TOOL_RESULT,provider:r,sessionId:n,timestamp:l,payload:{toolCallId:a.toolCallId||null,content:Nn(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:r,sessionId:n,timestamp:l,rawRef:c}));else if(d?.type==="tool_use"){const u=d.id||mr("tool"),m=o.get(d.id);s.push(Ht({kind:Le.TOOL_CALL_START,provider:r,sessionId:n,timestamp:l,payload:{toolCallId:u,toolName:d.name},rawRef:c})),s.push(Ht({kind:Le.TOOL_CALL_INPUT,provider:r,sessionId:n,timestamp:l,payload:{toolCallId:u,input:Nn(d.input||{})},rawRef:c})),s.push(Ht({kind:Le.TOOL_CALL_END,provider:r,sessionId:n,timestamp:l,payload:{toolCallId:u,toolName:d.name},rawRef:c})),m&&s.push(Ht({kind:Le.TOOL_RESULT,provider:r,sessionId:n,timestamp:m.timestamp||l,payload:{toolCallId:u,content:Nn(m.content),isError:!!m.isError,toolUseResult:m.toolUseResult||null},rawRef:c}))}}else pa(a.message.content)||s.push(...ua({text:a.message.content,provider:r,sessionId:n,timestamp:l,rawRef:c}));continue}a?.type&&/error/i.test(a.type)&&s.push(Ht({kind:Le.ERROR,provider:r,sessionId:n,timestamp:l,payload:{message:a.error||a.message||"Provider error"},rawRef:c}))}return s.sort((a,l)=>new Date(a.timestamp)-new Date(l.timestamp))}function _u(e=[],r,n="claude"){const s=Array.isArray(e)?[...e]:[];if(!Au(r))return s;const o=r.provider||n,a=r.timestamp||new Date().toISOString(),l=r.payload||{};switch(r.kind){case Le.USER_MESSAGE:s.push({type:"user",content:l.text||"",timestamp:a,provider:o});break;case Le.ASSISTANT_TEXT_START:{const c=l.messageId||r.extensions?.messageId||mr("assistant_text");Rs(s,{messageId:c,timestamp:a,provider:o,isThinking:!1});break}case Le.ASSISTANT_TEXT_DELTA:{const c=l.messageId||r.extensions?.messageId||mr("assistant_text"),{index:d}=Rs(s,{messageId:c,timestamp:a,provider:o,isThinking:!1}),u={...s[d]};u.content=Kl(u.content||"",l.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||o,s[d]=u;break}case Le.ASSISTANT_TEXT_END:{const c=l.messageId||r.extensions?.messageId;if(!c)break;const d=Zs(s,u=>u?.eventMessageId===c&&!u.isToolUse&&!u.isThinking);d>=0&&(s[d]={...s[d],isStreaming:!1});break}case Le.REASONING_START:{const c=l.messageId||r.extensions?.messageId||mr("reasoning");Rs(s,{messageId:c,timestamp:a,provider:o,isThinking:!0});break}case Le.REASONING_DELTA:{const c=l.messageId||r.extensions?.messageId||mr("reasoning"),{index:d}=Rs(s,{messageId:c,timestamp:a,provider:o,isThinking:!0}),u={...s[d]};u.content=Kl(u.content||"",l.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||o,u.isThinking=!0,s[d]=u;break}case Le.REASONING_END:{const c=l.messageId||r.extensions?.messageId;if(!c)break;const d=Zs(s,u=>u?.eventMessageId===c&&!!u.isThinking);d>=0&&(s[d]={...s[d],isStreaming:!1,isThinking:!0});break}case Le.TOOL_CALL_START:{const c=l.toolCallId||mr("tool"),{index:d}=Ps(s,{toolCallId:c,toolName:l.toolName,timestamp:a,provider:o});s[d]={...s[d],toolName:l.toolName||s[d].toolName};break}case Le.TOOL_CALL_INPUT:{const c=l.toolCallId||mr("tool"),{index:d}=Ps(s,{toolCallId:c,toolName:l.toolName,timestamp:a,provider:o});s[d]={...s[d],toolInput:Nn(l.input||""),provider:s[d].provider||o};break}case Le.TOOL_CALL_END:{const c=l.toolCallId||r.extensions?.toolCallId;if(!c)break;const{index:d}=Ps(s,{toolCallId:c,toolName:l.toolName,timestamp:a,provider:o});s[d]={...s[d],toolName:l.toolName||s[d].toolName};break}case Le.TOOL_RESULT:{const c=l.toolCallId||r.extensions?.toolCallId||mr("tool"),{index:d}=Ps(s,{toolCallId:c,toolName:l.toolName,timestamp:a,provider:o});s[d]={...s[d],toolResult:{content:Nn(l.content||""),isError:!!l.isError,toolUseResult:l.toolUseResult||null,timestamp:a},toolError:!!l.isError,provider:s[d].provider||o};break}case Le.APPROVAL_REQUEST:l.message&&s.push({type:"assistant",content:l.message,timestamp:a,provider:o,isApprovalRequest:!0,approvalRequest:l});break;case Le.APPROVAL_RESOLVED:l.message&&s.push({type:"assistant",content:l.message,timestamp:a,provider:o,approvalResolution:l});break;case Le.SYSTEM_NOTICE:if(l.message){const c=s[s.length-1];c&&c.type==="assistant"&&!c.isToolUse&&(c.content||"").trim()===String(l.message).trim()||s.push({type:"assistant",content:l.message,timestamp:a,provider:o,isSystemNotice:!0})}break;case Le.ERROR:s.push({type:"error",content:l.message||"Provider error",timestamp:a,provider:o,rawRef:r.rawRef||null,extensions:r.extensions||{}});break}return s}function Mu(e=[],r="claude"){return Array.isArray(e)?e.length>0&&!Au(e[0])?Mu(Yy(e,r),r):e.reduce((n,s)=>_u(n,s,r),[]):[]}const Vl={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"]}},Jl={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 Yl(e){return Vl[e]||Vl.claude}function Xl(e){return Jl[e]||Jl.claude}function Xy(e){return e==="claude"||e==="codex"}function Qy(e){if(e==="think")return"low";if(e==="think-hard")return"medium";if(e==="think-harder")return"high";if(e==="ultrathink")return"xhigh"}const ce={IDLE:"idle",CONNECTING:"connecting",QUEUED:"queued",STREAMING:"streaming",AWAITING_APPROVAL:"awaiting_approval",COMPLETED:"completed",ABORTED:"aborted",ERRORED:"errored"},eo=new Set([ce.CONNECTING,ce.QUEUED,ce.STREAMING,ce.AWAITING_APPROVAL]);function Ir(e){return e==null?"":String(e).replace(/\r\n/g,`
294
- `).trim()}function Ql(e){return!e||typeof e!="object"?{content:"",isError:!1}:{content:Ir(e.content),isError:!!e.isError}}function Zy(e,r){if(!e||!r)return!1;const n=String(e.type||""),s=String(r.type||"");if(n!==s)return!1;const o=!!e.isToolUse,a=!!r.isToolUse;if(o!==a)return!1;if(o&&a){const l=Ql(e.toolResult),c=Ql(r.toolResult);return Ir(e.toolName)===Ir(r.toolName)&&Ir(e.toolInput)===Ir(r.toolInput)&&l.content===c.content&&l.isError===c.isError}return!!e.isThinking!=!!r.isThinking?!1:Ir(e.content)===Ir(r.content)}function ev(e,r){const n=Math.min(e.length,r.length);let s=0;for(;s<n&&Zy(e[s],r[s]);)s+=1;return s}function tv(e=[],r=[],n={}){const s=Array.isArray(e)?e:[],o=Array.isArray(r)?r:[],a=!!n.preserveLocalTail;if(s.length===0)return o;if(o.length===0)return a?s:o;const l=ev(s,o);return l===s.length&&l===o.length?o:a&&l===o.length&&s.length>o.length?s:o}function Ls(e,r){return typeof r=="function"?r(e):r}function Zl(e,r={}){const n=eo.has(e),s=eo.has(e);return{isLoading:n,canAbortSession:s,...r}}function Ba(e,r=ce.IDLE){const n=String(e||"").trim().toLowerCase();return Object.values(ce).includes(n)?n:r}function rv(e,r){return!e||typeof e!="object"?r:e.kind===Le.SESSION_STATE_CHANGED?Ba(e.payload?.state,r):e.kind===Le.APPROVAL_REQUEST?ce.AWAITING_APPROVAL:e.kind===Le.APPROVAL_RESOLVED?ce.STREAMING:e.kind===Le.ERROR?ce.ERRORED:e.kind===Le.ASSISTANT_TEXT_START||e.kind===Le.ASSISTANT_TEXT_DELTA||e.kind===Le.REASONING_START||e.kind===Le.REASONING_DELTA||e.kind===Le.TOOL_CALL_START||e.kind===Le.TOOL_CALL_INPUT||e.kind===Le.TOOL_CALL_END||e.kind===Le.TOOL_RESULT||e.kind===Le.SYSTEM_NOTICE?ce.STREAMING:r}function nv(e,r){const n=r?.payload||{},s=n.requestId||r?.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:r?.sessionId||n.sessionId||null,receivedAt:r?.timestamp||new Date().toISOString()}]}function sv(e,r){const s=(r?.payload||{}).requestId||r?.extensions?.requestId||null;return s?e.filter(o=>o?.requestId!==s):e}function ov(e,r){return r?e===ce.AWAITING_APPROVAL||eo.has(e)?e:ce.STREAMING:e===ce.COMPLETED||e===ce.ABORTED||e===ce.ERRORED?e:ce.IDLE}function av(e=[]){return{messages:e,pendingPermissionRequests:[],phase:ce.IDLE,isLoading:!1,canAbortSession:!1}}function iv(e,r){switch(r.type){case"replace_messages":return{...e,messages:Ls(e.messages,r.value)};case"replace_permissions":return{...e,pendingPermissionRequests:Ls(e.pendingPermissionRequests,r.value)};case"set_phase":{const n=Ba(r.phase,e.phase);return{...e,phase:n,...Zl(n,r.overrides)}}case"set_loading":{const n=!!Ls(e.isLoading,r.value),s=ov(e.phase,n);return{...e,phase:s,isLoading:n,canAbortSession:n?e.canAbortSession||eo.has(s):!1}}case"set_can_abort":return{...e,canAbortSession:!!Ls(e.canAbortSession,r.value)};case"apply_conversation_event":{const n=_u(e.messages,r.event,r.provider),s=rv(r.event,e.phase);let o=e.pendingPermissionRequests;if(r.event?.kind===Le.APPROVAL_REQUEST)o=nv(o,r.event);else if(r.event?.kind===Le.APPROVAL_RESOLVED)o=sv(o,r.event);else if(r.event?.kind===Le.SESSION_STATE_CHANGED){const a=Ba(r.event?.payload?.state,"");(a===ce.COMPLETED||a===ce.ABORTED||a===ce.ERRORED||a===ce.IDLE)&&(o=[])}return{...e,messages:n,pendingPermissionRequests:o,phase:s,...Zl(s)}}default:return e}}const lv=["claude","codex","gemini","opencode"];function Yt(e){const r=String(e||"").trim().toLowerCase();return lv.includes(r)?r:"claude"}function cv(e){return new Promise((r,n)=>{if(!(e instanceof Blob)){n(new Error("无效的图片文件"));return}const s=new FileReader;s.onload=()=>r(typeof s.result=="string"?s.result:""),s.onerror=()=>n(s.error||new Error("读取图片失败")),s.readAsDataURL(e)})}async function dv(e=[]){const r=Array.isArray(e)?e:[];return Promise.all(r.map(async(n,s)=>{const o=await cv(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 uv(e){switch(e){case"codex":return bi;case"gemini":return Eu;case"opencode":return Iu;case"claude":default:return Cu}}function ho(e){return`${Yt(e)}-model`}function wi(e){return`${ho(e)}-selection-source`}function Os(e){const r=Yt(e),n=ho(r),s=wi(r);return localStorage.getItem(s)!=="manual"?"":localStorage.getItem(n)||""}function pv(e,r){const n=Yt(e);localStorage.setItem(ho(n),r),localStorage.setItem(wi(n),"manual")}function mv(e){const r=Yt(e);localStorage.removeItem(ho(r)),localStorage.removeItem(wi(r))}function fv(e,r){return!e||!r?!1:e.eventId&&r.eventId?e.eventId===r.eventId:e.kind===r.kind&&e.provider===r.provider&&e.sessionId===r.sessionId&&e.timestamp===r.timestamp&&JSON.stringify(e.payload||{})===JSON.stringify(r.payload||{})}function tn(e){return e&&e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function hv(e){if(!e||typeof e!="string")return e;try{return e.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return e}}function gv(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wa(e){if(typeof e!="string")return"";try{return decodeURIComponent(e).trim()}catch{return e.trim()}}function xv(e,r){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"),l=String(e?.provider||e?.__provider||"");return`${a}:${l}:${s}:${r}:${o}`}const _n="1",ec=5,tc="replace",Ua="append",Fs="unknown",yv="installed",ma="not_installed",vv="checking",bv=["claude","codex","gemini","opencode"],wv=300*1e3,kv=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 Du(e){if(typeof e!="string")return!1;const r=e.trim().toLowerCase();return r.length>0&&r!=="custom"&&r!=="default"}const jv=new Set(bi.OPTIONS.map(e=>String(e?.value||"").trim().toLowerCase()).filter(Boolean));function Nv(e){if(!Du(e))return!1;const r=e.trim().toLowerCase();return jv.has(r)?!0:/^(gpt-\d|o[1345](?:$|[-.])|codex(?:$|[-.]))/i.test(r)}function Sv(e,r){return Yt(e)==="codex"?Nv(r):Du(r)}function $s(e){return typeof e=="string"&&/^codex-\d+$/.test(e.trim())}function Cv(e){if(typeof e!="string")return"";const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]||e}function go(e,{allowEmptyPath:r=!0}={}){return typeof e=="string"?!r&&!e.trim()?null:{path:e,displayName:""}:!_r(e)||typeof e.path!="string"||!r&&!e.path.trim()||e.displayName!==void 0&&typeof e.displayName!="string"?null:{path:e.path,displayName:e.displayName||""}}function Cn(e){return go(e)?.path||""}function Ev(e){const r=go(e);return r?wr(r.displayName)?r.displayName:Cv(r.path):""}function Iv(e,r=72){if(typeof e!="string")return"";const n=e.trim().replace(/\s+/g," ");if(n.length<=r)return n;const s=n.split(/\s*>\s*/).filter(Boolean);if(s.length<=1)return`...${n.slice(-(r-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>r)break;o.unshift(d),a=u}const l=`... > ${o.join(" > ")}`;return l.length<=r?l:`...${l.slice(-(r-3))}`}function rc(e){if(!e)return"";const r=[];wr(e.label)&&r.push(e.label.trim());const n=Iv(e.selector);return n&&r.push(n),r.join(" · ")}function Tv(e){return e?wr(e.systemContext)||wr(Cn(e.currentFile))||Array.isArray(e.selectedElements)&&e.selectedElements.length>0?!0:_r(e.extensions)&&Object.keys(e.extensions).length>0:!1}function Av(e){return e?wr(e.systemContext)||wr(Cn(e.currentFile))?!0:Array.isArray(e.selectedElements)&&e.selectedElements.length>0:!1}function Ru(e){if(!_r(e)||e.version!==_n||typeof e.systemContext!="string")return null;const r=go(e.currentFile);if(!r||!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:_n,systemContext:e.systemContext,currentFile:r,selectedElements:n};return e.extensions!==void 0&&(s.extensions={...e.extensions}),s}function _v(e){if(!_r(e)||e.version!==void 0&&e.version!==_n||e.systemContext!==void 0&&typeof e.systemContext!="string"||e.selectedElements!==void 0&&!Array.isArray(e.selectedElements))return null;const r={};if(e.systemContext!==void 0&&(r.systemContext=e.systemContext),e.currentFile!==void 0){const n=go(e.currentFile);if(!n)return null;r.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})}r.selectedElements=n}if(e.extensions!==void 0){if(!_r(e.extensions))return null;r.extensions={...e.extensions}}return r}function Mv(e){return`${e.tag}::${e.selector}::${e.label}`}function Dv(e){if(!Array.isArray(e)||e.length===0)return[];const r=new Set,n=[];for(const s of e){const o=Mv(s);r.has(o)||(r.add(o),n.push(s))}return n}function Rv(){return{version:_n,systemContext:"",currentFile:{path:"",displayName:""},selectedElements:[]}}function Pv(e,r){const n=Ru(e)||Rv(),s=_v(r);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=Dv([...Array.isArray(n.selectedElements)?n.selectedElements:[],...s.selectedElements])),s.extensions!==void 0&&(o.extensions=s.extensions),o}function Lv(e){return typeof e!="string"?tc:e.trim().toLowerCase()===Ua?Ua:tc}function nc(e){if(e==null||e==="")return null;let r=e;if(typeof e=="string"){const s=Wa(e);if(!s)return null;try{r=JSON.parse(s)}catch{return console.warn("[DynamicContext] Ignored invalid context JSON string."),null}}const n=Ru(r);return n||(console.warn("[DynamicContext] Ignored invalid context payload."),null)}function Ov(e){if(!e)return null;const r={version:_n,systemContext:e.systemContext||"",currentFile:Cn(e.currentFile),selectedElements:Array.isArray(e.selectedElements)?e.selectedElements:[]};return e.extensions!==void 0&&(r.extensions=e.extensions),r}function Fv(e,r){return`<dynamic_context version="${_n}">
295
- ${JSON.stringify(e,null,2)}
296
- </dynamic_context>
297
-
298
- <user_message>
299
- ${r}
300
- </user_message>`}let sc=!1;function $v(e){const r=String(e||"").trim();if(!r||r.startsWith("# AGENTS.md instructions for ")||r.includes("<environment_context>"))return"";if(r.startsWith("[DYNAMIC CONTEXT V1]")){const s=`
301
-
302
- [USER MESSAGE]
303
- `,o=r.indexOf(s);return o>=0?r.slice(o+s.length).trim():""}const n=r.match(/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i);return n?String(n[1]||"").trim():r}function fa(e=[]){return Array.isArray(e)?e.flatMap(r=>{if(!r||typeof r!="object")return[];if(typeof r.content!="string")return[r];const n=$v(r.content);return n?n===r.content?[r]:[{...r,content:n}]:[]}):[]}function zv(e=[],r=[]){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n+=1){const s=e[n],o=r[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:r})=>{const n=hv(String(e??"")),s=i.useMemo(()=>[Wm,Um],[]),o=i.useMemo(()=>[Hm],[]);return t.jsx("div",{className:r,children:t.jsx(Gm,{remarkPlugins:s,rehypePlugins:o,components:Gv,children:n})})};function Ga(e){try{return typeof e!="string"?e:e.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(r,n)=>{let s=parseInt(n,10);if(!Number.isFinite(s))return r;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),l=-o.getTimezoneOffset(),c=l>=0?"+":"-",d=Math.abs(l),u=Math.floor(d/60),m=d%60,p=`GMT${c}${u}${m?":"+String(m).padStart(2,"0"):""}`,x=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,L=>L.toUpperCase()),k=x?`${p} (${x})`:p,w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],A=`${o.getDate()} ${w[o.getMonth()]} ${o.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${a} ${k}** - ${A}`})}catch{return e}}const Mt={setItem:(e,r)=>{try{if(e.startsWith("chat_messages_")&&typeof r=="string")try{const n=JSON.parse(r);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);r=JSON.stringify(s)}}catch(n){console.warn("Could not parse chat messages for truncation:",n)}localStorage.setItem(e,r)}catch(n){if(n.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const s=Object.keys(localStorage),o=s.filter(l=>l.startsWith("chat_messages_")).sort();o.length>3&&o.slice(0,o.length-3).forEach(l=>{localStorage.removeItem(l),console.log(`Removed old chat data: ${l}`)}),s.filter(l=>l.startsWith("draft_input_")).forEach(l=>{localStorage.removeItem(l)});try{localStorage.setItem(e,r)}catch(l){if(console.error("Failed to save to localStorage even after cleanup:",l),e.startsWith("chat_messages_")&&typeof r=="string")try{const c=JSON.parse(r);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(r){return console.error("localStorage getItem error:",r),null}},removeItem:e=>{try{localStorage.removeItem(e)}catch(r){console.error("localStorage removeItem error:",r)}}},Pu="claude-settings";function ki(){const e=Mt.getItem(Pu);if(!e)return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"};try{const r=JSON.parse(e);return{...r,allowedTools:Array.isArray(r.allowedTools)?r.allowedTools:[],disallowedTools:Array.isArray(r.disallowedTools)?r.disallowedTools:[],skipPermissions:!!r.skipPermissions,projectSortOrder:r.projectSortOrder||"name"}}catch{return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"}}}function qa(e,r){if(!e)return null;if(e!=="Bash")return e;const n=ti(r),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 oc(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Bv(e,r){if(r!=="claude"||!e?.toolResult?.isError)return null;const n=e?.toolName,s=qa(n,e.toolInput);if(!s)return null;const a=ki().allowedTools.includes(s);return{toolName:n,entry:s,isAllowed:a}}function Wv(e){if(!e)return{success:!1};const r=ki(),n=r.allowedTools.includes(e),s=n?r.allowedTools:[...r.allowedTools,e],o=r.disallowedTools.filter(l=>l!==e),a={...r,allowedTools:s,disallowedTools:o,lastUpdated:new Date().toISOString()};return Mt.setItem(Pu,JSON.stringify(a)),{success:!0,alreadyAllowed:n,updatedSettings:a}}function Ka({phaseText:e,detailText:r="",canAbort:n=!0,startedAt:s=Date.now(),elapsedSeconds:o}={}){return{phaseText:e,detailText:r,canAbort:n,startedAt:s,elapsedSeconds:o}}function Uv(e,r,n=null){const s=n?.startedAt||Date.now(),o=typeof e=="string"?e:e?.message||e?.status||e?.text||"",a=String(o||"").trim(),l=a.toLowerCase();let c=r("activity.stage.working");return l.includes("permission")?c=r("activity.stage.waitingPermission"):l.includes("think")?c=r("activity.stage.thinking"):l.includes("search")||l.includes("grep")||l.includes("glob")?c=r("activity.stage.searching"):l.includes("command")||l.includes("bash")?c=r("activity.stage.runningCommand"):l.includes("read")?c=r("activity.stage.readingFile"):l.includes("write")||l.includes("edit")||l.includes("patch")?c=r("activity.stage.editingFile"):l.includes("todo")?c=r("activity.stage.updatingTodo"):(l.includes("respond")||l.includes("reply"))&&(c=r("activity.stage.generatingReply")),Ka({phaseText:c,detailText:a,canAbort:e?.can_interrupt!==!1,startedAt:s,elapsedSeconds:e?.elapsedSeconds})}const Hv=({node:e,inline:r,className:n,children:s,...o})=>{const{t:a}=Lt("chat"),[l,c]=dn.useState(!1),d=Array.isArray(s)?s.join(""):String(s??""),u=/[\r\n]/.test(d);if(r||e&&e.type==="inlineCode"||!u)return t.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,k=()=>{const w=()=>{c(!0),setTimeout(()=>c(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(x).then(w).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),w()});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),w()}}catch{}};return t.jsxs("div",{className:"relative group my-2",children:[g&&g!=="text"&&t.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:g}),t.jsx("button",{type:"button",onClick:k,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(l?"codeBlock.copied":"codeBlock.copyCode"),"aria-label":a(l?"codeBlock.copied":"codeBlock.copyCode"),children:l?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:t.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")]}):t.jsxs("span",{className:"flex items-center gap-1",children:[t.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:[t.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),t.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),a("codeBlock.copy")]})}),t.jsx(qm,{language:g,style:Km,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})]})},Gv={code:Hv,blockquote:({children:e})=>t.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:r})=>t.jsx("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:r}),p:({children:e})=>t.jsx("div",{className:"mb-2 last:mb-0",children:e}),table:({children:e})=>t.jsx("div",{className:"overflow-x-auto my-2",children:t.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:e})}),thead:({children:e})=>t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e}),th:({children:e})=>t.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})=>t.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:e})};i.memo(({message:e,index:r,prevMessage:n,createDiff:s,onFileOpen:o,onShowSettings:a,onGrantToolPermission:l,autoExpandTools:c,showRawParameters:d,showThinking:u,selectedProject:m,provider:p,isActiveStreamingCard:h})=>{const{t:g}=Lt("chat"),x=e.provider||e.__provider||p||"claude",k=x==="codex",w=x==="gemini",A=x==="opencode",L=n&&n.type===e.type&&(n.type==="assistant"||n.type==="user"||n.type==="tool"||n.type==="error");return Bv(e,p),t.jsx("div",{className:`chat-message ${e.type} ${L?"grouped":""} ${e.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:e.type==="user"?t.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:[t.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:[t.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:e.content}),e.images&&e.images.length>0&&t.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:e.images.map((j,S)=>t.jsx("img",{src:j.data,alt:j.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(j.data,"_blank")},S))}),t.jsx("div",{className:"text-xs text-primary-foreground/80 mt-1 text-right",children:new Date(e.timestamp).toLocaleTimeString()})]}),!L&&t.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"})]}):t.jsxs("div",{className:"w-full",children:[!L&&t.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.type==="error"?t.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"?t.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:"🔧"}):t.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:k?t.jsx(ss,{className:"w-full h-full"}):w?t.jsx(mo,{className:"w-full h-full"}):A?t.jsx(fo,{className:"h-full w-auto max-w-full text-gray-900 dark:text-white"}):t.jsx(Pn,{className:"w-full h-full"})}),t.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"):k?g("messageTypes.codex"):w?g("messageTypes.gemini"):A?"OpenCode":g("messageTypes.claude")})]}),t.jsxs("div",{className:"w-full",children:[e.isToolUse?t.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?t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:t.jsxs("details",{className:"group",open:h,children:[t.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:[t.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),t.jsx("span",{children:g("thinking.emoji")})]}),t.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:t.jsx(Ha,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:e.content})})]})}):t.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[u&&e.reasoning&&t.jsxs("details",{className:"mb-3",open:h,children:[t.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")}),t.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:t.jsx("div",{className:"whitespace-pre-wrap",children:e.reasoning})})]}),(()=>{const j=Ga(String(e.content||"")),S=j.trim();if((S.startsWith("{")||S.startsWith("["))&&(S.endsWith("}")||S.endsWith("]")))try{const D=JSON.parse(S),b=JSON.stringify(D,null,2);return t.jsxs("div",{className:"my-2",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{className:"font-medium",children:"JSON Response"})]}),t.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:t.jsx("pre",{className:"p-4 overflow-x-auto",children:t.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:b})})})]})}catch{}return e.type==="assistant"?t.jsx(Ha,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:j}):t.jsx("div",{className:"whitespace-pre-wrap",children:j})})()]}),t.jsx("div",{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 ${L?"opacity-0 group-hover:opacity-100":""}`,children:new Date(e.timestamp).toLocaleTimeString()})]})]})})});const qv=({file:e,onRemove:r,uploadProgress:n,error:s})=>{const[o,a]=i.useState(null);return i.useEffect(()=>{const l=URL.createObjectURL(e);return a(l),()=>URL.revokeObjectURL(l)},[e]),t.jsxs("div",{className:"relative group",children:[t.jsx("img",{src:o,alt:e.name,className:"w-20 h-20 object-cover rounded"}),n!==void 0&&n<100&&t.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:t.jsxs("div",{className:"text-white text-xs",children:[n,"%"]})}),s&&t.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:t.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),t.jsx("button",{onClick:r,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-0 group-hover:opacity-100",children:t.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})};function Kv({selectedProject:e,selectedSession:r,ws:n,sendMessage:s,latestMessage:o,onFileOpen:a,onInputFocusChange:l,onSessionActive:c,onSessionInactive:d,onSessionProcessing:u,onSessionNotProcessing:m,processingSessions:p,onReplaceTemporarySession:h,onNavigateToSession:g,onShowSettings:x,autoExpandTools:k,showRawParameters:w,showThinking:A,autoScrollToBottom:L,sendByCtrlEnter:j,externalMessageUpdate:S,urlProvider:D,urlModel:b,urlContext:I,urlPrompt:G,integrationClientId:P,latestIntegrationMessage:V,sendIntegrationMessage:ve,newSessionResetNonce:ae=0}){const{t:R}=Lt("chat"),[q,de]=i.useState(()=>typeof window<"u"&&e&&Mt.getItem(`draft_input_${e.name}`)||""),se=i.useMemo(()=>{if(typeof window<"u"&&e){const f=Mt.getItem(`chat_messages_${e.name}`);return f?fa(JSON.parse(f)):[]}return[]},[e]),[he,Se]=i.useReducer(iv,se,av),B=he.messages,z=he.phase,_=he.isLoading,N=he.canAbortSession,O=he.pendingPermissionRequests,ne=e?.fullPath||e?.path||null,Ce=i.useRef(!1),be=i.useRef(B),re=i.useRef(e),Ee=i.useRef(!1),nt=i.useRef(ae),De=i.useRef(sc),[fe,Ge]=i.useState(r?.id||null),[bt,st]=i.useState(!1),[Be,Ze]=i.useState([]),[xt,wt]=i.useState(!1),[ye,qe]=i.useState(!1),[Nt,X]=i.useState(0),[Te,W]=i.useState(!1),[Z,we]=i.useState(0),Ae=100,[Xe,Qe]=i.useState(!1),[We,Et]=i.useState(()=>{const f=Yt(localStorage.getItem("selected-provider"));return Yl(f).defaultMode}),ie=i.useCallback(f=>{Se({type:"replace_messages",value:f})},[]),St=i.useCallback(f=>{Se({type:"replace_permissions",value:f})},[]),et=i.useCallback(f=>{Se({type:"set_loading",value:f})},[]),ot=i.useCallback(f=>{Se({type:"set_can_abort",value:f})},[]),Ke=i.useCallback((f,y)=>{Se({type:"set_phase",phase:f,overrides:y})},[]),Tt=i.useCallback((f,y)=>{Se({type:"apply_conversation_event",event:f,provider:y})},[]),Ot=i.useCallback(f=>{!f||typeof f!="object"||Ze(y=>{const v=Array.isArray(y)?y:[];return v.some(E=>fv(E,f))?v:[...v,f]})},[]),yt=i.useRef({sessionId:null,startedAt:0}),At=i.useCallback(f=>{yt.current={sessionId:f||null,startedAt:Date.now()}},[]),rr=i.useCallback(f=>{!f||!yt.current.startedAt||(yt.current={...yt.current,sessionId:f})},[]),tt=i.useCallback((f=null)=>{const y=yt.current;y.startedAt&&(f&&y.sessionId&&y.sessionId!==f||(yt.current={sessionId:null,startedAt:0}))},[]),Ft=i.useCallback((f,y=null)=>{if(y&&y!=="session-status")return!1;const v=yt.current;return!!(v.startedAt&&f&&v.sessionId===f&&Date.now()-v.startedAt<kv&&(z===ce.CONNECTING||z===ce.QUEUED||z===ce.STREAMING||z===ce.AWAITING_APPROVAL||z===ce.COMPLETED||z===ce.ABORTED||z===ce.ERRORED))},[z]),[It,$t]=i.useState([]),[nr,Bt]=i.useState(new Map),[M,ge]=i.useState(new Map),Re=i.useRef(null),Q=i.useRef(null),C=i.useRef(null),F=i.useRef(null),pe=i.useRef(null),je=i.useRef(!1),mt=i.useRef(!1),H=i.useRef(0),_t=i.useRef(!1),$=i.useRef(null),U=i.useRef(""),le=i.useRef(null),Oe=i.useCallback(()=>{le.current&&(clearTimeout(le.current),le.current=null),U.current=""},[]),T=i.useRef(null),te=i.useRef(new Set),oe=i.useRef(new Map),ke=i.useRef(S),K=i.useRef(null),[Ve,rt]=i.useState(""),[Ct,ft]=i.useState(!1),[lt,Ye]=i.useState([]),[Rt,Wt]=i.useState([]),[Vt,Pr]=i.useState([]),[zt,hn]=i.useState(-1),[Ii,as]=i.useState(0),[Ti,is]=i.useState(-1),[yo,On]=i.useState(!1),vo=i.useRef({height:0,top:0}),[bo,Lr]=i.useState(!1),[Or,wo]=i.useState([]),[Jr,ko]=i.useState([]),[ls,Fr]=i.useState(""),[dp,Yr]=i.useState(!1),[hr,$r]=i.useState(null),[jo,zr]=i.useState(-1),[Ai,Br]=i.useState(-1),[Fn,up]=i.useState(100),[No,kt]=i.useState(null),_i=i.useRef(null),[Xr,cs]=i.useState("none"),[So,pp]=i.useState(!1),[Mi,mp]=i.useState(!1),Co=i.useRef(null),Eo=i.useRef(null),[ue,ds]=i.useState(()=>Yt(localStorage.getItem("selected-provider"))),Wr=i.useMemo(()=>Yl(ue),[ue]),Qr=i.useMemo(()=>Xl(ue),[ue]),Io=i.useCallback((f,{short:y=!1}={})=>{let v=R("codex.modes.default");return f==="acceptEdits"?v=R("codex.modes.acceptEdits"):f==="bypassPermissions"?v=R("codex.modes.bypassPermissions"):f==="plan"&&(v=R("codex.modes.plan")),y?v.replace(/\s*模式$/,"").replace(/\s*Mode$/,""):v},[R]),fp=i.useMemo(()=>Io(We,{short:!0}),[Io,We]),Di=i.useMemo(()=>R("codex.permissionMode").replace(/^权限/,"").replace(/^Permission\s+/i,""),[R]),[To,Ao]=i.useState({});i.useEffect(()=>{_i.current=No},[No]),i.useEffect(()=>()=>{oe.current.forEach(f=>clearTimeout(f)),oe.current.clear()},[]);const[hp,Ri]=i.useState({}),[gp,Pi]=i.useState({}),Li=i.useRef(null),$n=i.useCallback(async(f,{force:y=!1}={})=>{if(!bv.includes(f))return null;Ri(v=>({...v,[f]:!0})),Pi(v=>({...v,[f]:null})),Ao(v=>({...v,[f]:{status:vv}}));try{const E=await ee(`/api/cli/providers/${f}/installation-status${y?"?force=true":""}`),Y=await E.json().catch(()=>({}));if(!E.ok||Y?.success!==!0)throw new Error(Y?.error||`Failed to check ${f} installation`);const me=Y.installed?yv:ma;return Ao(Ne=>({...Ne,[f]:{status:me,command:Y.command||null,resolvedPath:Y.resolvedPath||null,reason:Y.reason||null,installHint:Y.installHint||null,checkedAt:Y.checkedAt||null,cacheHit:!!Y.cacheHit}})),me}catch(v){return Ao(E=>({...E,[f]:{status:Fs}})),Pi(E=>({...E,[f]:v.message})),Fs}finally{Ri(v=>({...v,[f]:!1}))}},[]),Oi=i.useCallback(()=>{if(!D||r)return null;const f=D.trim().toLowerCase();return{claude:"claude",anthropic:"claude",codex:"codex",openai:"codex",gemini:"gemini",google:"gemini",opencode:"opencode"}[f]||null},[D,r]),Fi=i.useCallback(()=>{if(!b)return null;const f=b.trim().toLowerCase();if(!f)return null;const y={claude:Cu.OPTIONS.some(E=>E.value===f),codex:bi.OPTIONS.some(E=>E.value===f),gemini:Eu.OPTIONS.some(E=>E.value===f),opencode:Iu.OPTIONS.some(E=>E.value===f)},v=Object.entries(y).filter(([,E])=>E).map(([E])=>E);return v.length===0?null:v.length===1?{provider:v[0],model:f}:y[ue]?{provider:ue,model:f}:{provider:v[0],model:f}},[b,ue]),[_o,Mo]=i.useState(()=>Os("claude")),[Do,Ro]=i.useState(()=>Os("codex")),[Po,Lo]=i.useState(()=>Os("gemini")),[Oo,Fo]=i.useState(()=>Os("opencode")),[$i,$o]=i.useState({}),[yw,zi]=i.useState({}),[xp,Bi]=i.useState({}),us=ue==="claude"?_o:ue==="codex"?Do:ue==="gemini"?Po:Oo,Wi=i.useMemo(()=>uv(ue).OPTIONS,[ue]),zo=i.useMemo(()=>($i[ue]||[]).map(f=>({value:f,label:f})),[$i,ue]),Zr=r?.__provider===ue&&Sv(ue,r?.model)?r.model.trim():"",Xt=Zr||us,ps=i.useMemo(()=>{const f=zo.length>0?zo:Wi;return!Zr||f.some(y=>y.value===Zr)?f:[{value:Zr,label:Zr},...f]},[zo,Wi,Zr]),yp=ps.find(f=>f.value===Xt)?.label||Xt||R("providerSelection.selectModel"),vp=!!Zr,ms=ue==="opencode"&&!!xp.opencode,fs=i.useCallback(f=>{if(!f)return;const y=Yt(f);ds(y),localStorage.setItem("selected-provider",y),$n(y)},[$n]),gn=i.useMemo(()=>nc(I),[I]),[vw,Bo]=i.useState(gn),[Nr,xn]=i.useState(gn),[hs,gs]=i.useState(!1),Ui=i.useRef(gn),Hi=i.useRef(ue);i.useEffect(()=>{const f=Oi();if(f&&(Li.current!==f&&(Li.current=f,$n(f)),f!==ue)){const y=Yt(f);ds(y),localStorage.setItem("selected-provider",y)}},[Oi,ue,$n]),i.useEffect(()=>{if(!b||r)return;const f=Fi();if(f){if(f.provider!==ue){const y=Yt(f.provider);ds(y),localStorage.setItem("selected-provider",y)}f.provider==="claude"?Mo(f.model):f.provider==="codex"?Ro(f.model):f.provider==="gemini"?Lo(f.model):f.provider==="opencode"&&Fo(f.model)}},[b,Fi,ue,r]),i.useEffect(()=>{const f=ps.map(y=>y.value);us&&(f.includes(us)||(ue==="claude"?Mo(""):ue==="codex"?Ro(""):ue==="gemini"?Lo(""):ue==="opencode"&&Fo(""),mv(ue)))},[ue,us,ps]),i.useEffect(()=>{if(!e)return;const f=e.fullPath||e.path;if(!f)return;const y=`runtime-models:v2:${ue}:${f}`,v=ti(Mt.getItem(y)),E=Array.isArray(v?.models)?v.models:[],Y=typeof v?.currentModel=="string"?v.currentModel.trim():"",me=Number(v?.timestamp||0);if(E.length>0&&Date.now()-me<wv){$o($e=>({...$e,[ue]:E})),Y&&zi($e=>({...$e,[ue]:{...$e?.[ue]||{},currentModel:Y}}));return}let Ue=!1;return Bi($e=>({...$e,[ue]:!0})),pt.providerDiscovery(ue,f).then(async $e=>{if(!$e.ok)throw new Error(`HTTP ${$e.status}`);return $e.json()}).then($e=>{if(Ue)return;const vt=Array.isArray($e?.models)?$e.models.map(at=>at.id):[],Pt=typeof $e?.currentModel=="string"?$e.currentModel.trim():"";zi(at=>({...at,[ue]:$e})),$o(at=>({...at,[ue]:vt})),vt.length>0&&Mt.setItem(y,JSON.stringify({models:vt,currentModel:Pt||"",timestamp:Date.now()}))}).catch(()=>{Ue||$o($e=>({...$e,[ue]:E}))}).finally(()=>{Ue||Bi($e=>({...$e,[ue]:!1}))}),()=>{Ue=!0}},[ue,e,So]),i.useEffect(()=>{if(!So)return;const f=y=>{Co.current&&!Co.current.contains(y.target)&&pp(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[So]),i.useEffect(()=>{if(!Mi)return;const f=y=>{Eo.current&&!Eo.current.contains(y.target)&&mp(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[Mi]),i.useEffect(()=>{Ce.current=_},[_]),i.useEffect(()=>{be.current=B},[B]),i.useEffect(()=>{re.current=e},[e]),i.useEffect(()=>{nt.current!==ae&&(nt.current=ae,!r&&(Oe(),tt(),T.current=null,sessionStorage.removeItem("pendingSessionId"),Ge(null),Ze([]),ie([]),St([]),Qe(!1),Ke(ce.IDLE),kt(null),ot(!1),de(""),$r(null),On(!1),e?.name&&(Mt.removeItem(`chat_messages_${e.name}`),Mt.removeItem(`draft_input_${e.name}`))))},[tt,ae,Oe,e?.name,r,ot,ie,St,Ke]),i.useEffect(()=>{Ui.current=Nr},[Nr]),i.useEffect(()=>{if(De.current)return;const f=Wa(G);f&&(de(f),Ee.current=!0,De.current=!0,sc=!0)},[G]),i.useEffect(()=>{Bo(gn),xn(gn),gs(!1)},[gn]);const pr=i.useCallback((f,y,v={})=>{!y||typeof ve!="function"||ve({type:f,requestId:y,payload:{...v,clientId:P||null}})},[P,ve]),Gi=i.useCallback((f,y=null)=>{if(!_r(f?.context)){console.warn("[DynamicContext] Ignored integration.context.update because context is not an object."),pr("integration.error",y,{code:"INVALID_PAYLOAD",message:"context must be an object"});return}if(Lv(f.mode)===Ua){const Y=Pv(Ui.current,f.context);if(!Y){console.warn("[DynamicContext] Ignored invalid append context payload."),pr("integration.error",y,{code:"INVALID_PAYLOAD",message:"append context payload is invalid"});return}Bo(Y),xn(Y),gs(!1),pr("integration.ack",y,{accepted:!0,applied:!0});return}const E=nc(f.context);if(!E){pr("integration.error",y,{code:"INVALID_PAYLOAD",message:"context payload does not satisfy contextV1"});return}Bo(E),xn(E),gs(!1),pr("integration.ack",y,{accepted:!0,applied:!0})},[pr]),qi=i.useCallback((f,y=null)=>{if(typeof f?.prompt!="string"){pr("integration.error",y,{code:"INVALID_PAYLOAD",message:"prompt must be a string"});return}const v=Wa(f.prompt);if(de(v),Ee.current=!0,f.autoSend===!0&&v&&re.current&&!Ce.current&&zn.current){const E={preventDefault:()=>{}};zn.current(E,v)}pr("integration.ack",y,{accepted:!0,applied:!0})},[pr]),Ki=i.useCallback((f=null)=>{pr("integration.ack",f,{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:r?.id||null})},[r?.id,pr]);i.useEffect(()=>{if(!V?.__messageSeq)return;const y=V?.type;if(y==="integration.context.update"){Gi(V.payload||{},V.requestId||null);return}if(y==="integration.prompt.update"){qi(V.payload||{},V.requestId||null);return}y==="integration.ping"&&Ki(V.requestId||null)},[Gi,qi,V,Ki]);const sr=i.useMemo(()=>hs||!Nr||!Av(Nr)?null:Nr,[hs,Nr]),bp=i.useMemo(()=>sr?.selectedElements?.length?sr.selectedElements.slice(0,ec):[],[sr]),Wo=i.useMemo(()=>sr?.selectedElements?.length?sr.selectedElements.slice(ec):[],[sr]),wp=i.useCallback(()=>{xn(f=>!f||!wr(f.systemContext)?f:{...f,systemContext:""})},[]),kp=i.useCallback(()=>{xn(f=>!f||!wr(Cn(f.currentFile))?f:{...f,currentFile:{path:"",displayName:""}})},[]),jp=i.useCallback(f=>{xn(y=>{if(!y||!Array.isArray(y.selectedElements)||y.selectedElements.length===0)return y;const v=y.selectedElements.findIndex(E=>E.tag===f.tag&&E.selector===f.selector&&E.label===f.label);return v<0?y:{...y,selectedElements:y.selectedElements.filter((E,Y)=>Y!==v)}})},[]);i.useEffect(()=>{if(r?.id){const f=localStorage.getItem(`permissionMode-${r.id}`);f&&Wr.modes.includes(f)?Et(f):Et(Wr.defaultMode)}},[r?.id,Wr]),i.useEffect(()=>{Wr.modes.includes(We)||Et(Wr.defaultMode)},[We,Wr]),i.useEffect(()=>{if(!Qr.enabled){Xr!==Qr.defaultMode&&cs(Qr.defaultMode);return}Qr.modes.includes(Xr)||cs(Qr.defaultMode)},[Qr,Xr]),i.useEffect(()=>{if(r&&r.__provider&&r.__provider!==ue){const f=Yt(r.__provider);ds(f),localStorage.setItem("selected-provider",f)}if(r?.id&&r?.__provider)try{const f=localStorage.getItem("session-provider-map"),y=f?JSON.parse(f):{};y[r.id]!==r.__provider&&(y[r.id]=r.__provider,localStorage.setItem("session-provider-map",JSON.stringify(y)))}catch{}},[r]),i.useEffect(()=>{Hi.current!==ue&&(St([]),Hi.current=ue)},[ue]),i.useEffect(()=>{St(f=>f.filter(y=>!y.sessionId||y.sessionId===r?.id))},[r?.id]),i.useEffect(()=>{(async()=>{if(e)try{const y=await ee("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:e.path})});if(!y.ok)throw new Error("Failed to fetch commands");const v=await y.json(),E=[...(v.builtIn||[]).map(Ne=>({...Ne,type:"built-in"})),...(v.custom||[]).map(Ne=>({...Ne,type:"custom"}))];wo(E);const Y=`command_history_${e.name}`,me=Mt.getItem(Y);if(me)try{const Ne=JSON.parse(me),Ue=E.sort(($e,vt)=>{const Pt=Ne[$e.name]||0;return(Ne[vt.name]||0)-Pt});wo(Ue)}catch(Ne){console.error("Error parsing command history:",Ne)}}catch(y){console.error("Error fetching slash commands:",y),wo([])}})()},[e]);const Uo=i.useMemo(()=>Or.length?new Ln(Or,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[Or]);i.useEffect(()=>{if(!ls){ko(Or);return}if(!Uo){ko([]);return}const f=Uo.search(ls);ko(f.map(y=>y.item))},[ls,Or,Uo]);const Np=i.useMemo(()=>{if(!e||Or.length===0)return[];const f=`command_history_${e.name}`,y=Mt.getItem(f);if(!y)return[];try{const v=JSON.parse(y);return Or.map(Y=>({...Y,usageCount:v[Y.name]||0})).filter(Y=>Y.usageCount>0).sort((Y,me)=>me.usageCount-Y.usageCount).slice(0,5)}catch(v){return console.error("Error parsing command history:",v),[]}},[e,Or]),Sp=i.useCallback((f,y,v)=>{if(!f||!e)return;if(v){zr(y);return}const E=`command_history_${e.name}`,Y=Mt.getItem(E);let me={};try{me=Y?JSON.parse(Y):{}}catch(Ne){console.error("Error parsing command history:",Ne)}me[f.name]=(me[f.name]||0)+1,Mt.setItem(E,JSON.stringify(me)),Vi(f)},[e]),Cp=i.useCallback(f=>{const{action:y,data:v}=f;switch(y){case"clear":ie([]),Ze([]);break;case"help":ie(E=>[...E,{role:"assistant",content:v.content,timestamp:Date.now()}]);break;case"model":{const E=Object.entries(v.available||{}).filter(([,me])=>Array.isArray(me)&&me.length>0).map(([me,Ne])=>`**${me.charAt(0).toUpperCase()+me.slice(1)}**: ${Ne.join(", ")}`).join(`
304
-
305
- `),Y=v.current.provider==="opencode"?v.opencodeDiscovery?"_OpenCode source: runtime provider registry._":"_OpenCode source: local fallback list._":"";ie(me=>[...me,{role:"assistant",content:`**Current Model**: ${v.current.model}
306
-
307
- **Available Models**:
308
-
309
- ${E}${Y?`
310
-
311
- ${Y}`:""}`,timestamp:Date.now()}])}break;case"cost":{const E=`**Token Usage**: ${v.tokenUsage.used.toLocaleString()} / ${v.tokenUsage.total.toLocaleString()} (${v.tokenUsage.percentage}%)
312
-
313
- **Estimated Cost**:
314
- - Input: $${v.cost.input}
315
- - Output: $${v.cost.output}
316
- - **Total**: $${v.cost.total}
317
-
318
- **Model**: ${v.model}`;ie(Y=>[...Y,{role:"assistant",content:E,timestamp:Date.now()}]);break}case"status":{const E=`**System Status**
319
-
320
- - Version: ${v.version}
321
- - Uptime: ${v.uptime}
322
- - Model: ${v.model}
323
- - Provider: ${v.provider}
324
- - Node.js: ${v.nodeVersion}
325
- - Platform: ${v.platform}`;ie(Y=>[...Y,{role:"assistant",content:E,timestamp:Date.now()}]);break}case"memory":v.error?ie(E=>[...E,{role:"assistant",content:`⚠️ ${v.message}`,timestamp:Date.now()}]):(ie(E=>[...E,{role:"assistant",content:`📝 ${v.message}
326
-
327
- Path: \`${v.path}\``,timestamp:Date.now()}]),v.exists&&a&&a(v.path));break;case"config":x&&x();break;case"rewind":v.error?ie(E=>[...E,{role:"assistant",content:`⚠️ ${v.message}`,timestamp:Date.now()}]):(ie(E=>E.slice(0,-v.steps*2)),ie(E=>[...E,{role:"assistant",content:`⏪ ${v.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",y)}},[a,x]),zn=i.useRef(null),Ep=i.useCallback(async(f,y)=>{const{content:v,hasBashCommands:E,hasFileIncludes:Y}=f;if(E&&!window.confirm("这条命令包含将要执行的 Bash 命令,是否继续?")){ie(Ne=>[...Ne,{role:"assistant",content:"❌ 已取消命令执行",timestamp:Date.now()}]);return}de(v),setTimeout(()=>{if(zn.current){const me={preventDefault:()=>{}};zn.current(me)}},50)},[]),Vi=i.useCallback(async f=>{if(!(!f||!e))try{const y=q.match(new RegExp(`${f.name}\\s*(.*)`)),v=y&&y[1]?y[1].trim().split(/\s+/):[],E={projectPath:e.path,projectName:e.name,sessionId:fe,provider:ue,...Xt?{model:Xt}:{},tokenUsage:hr},Y=await ee("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:f.name,commandPath:f.path,args:v,context:E})});if(!Y.ok)throw new Error("Failed to execute command");const me=await Y.json();me.type==="builtin"?Cp(me):me.type==="custom"&&await Ep(me,v),de(""),Lr(!1),Br(-1),Fr(""),zr(-1)}catch(y){console.error("Error executing command:",y),ie(v=>[...v,{role:"assistant",content:`Error executing command: ${y.message}`,timestamp:Date.now()}])}},[q,e,fe,ue,Do,Po,Oo,_o,hr]),Ip=i.useMemo(()=>{const f=new Map;return(y,v)=>{const E=`${y.length}-${v.length}-${y.slice(0,50)}`;if(f.has(E))return f.get(E);const Y=Tp(y,v);if(f.set(E,Y),f.size>100){const me=f.keys().next().value;f.delete(me)}return Y}},[]),Sr=i.useCallback(async(f,y,v=!1,E="claude",Y=null)=>{if(!f||!y)return[];const me=!v;me?wt(!0):qe(!0);try{const Ne=Y??(v?H.current:0),Ue=ne,$e=await pt.sessionEvents(E,y,f,Ue,Ae,Ne);if(!$e.ok)throw new Error("Failed to load session messages");const vt=await $e.json();if(me&&vt.tokenUsage&&$r(vt.tokenUsage),vt.hasMore!==void 0){W(vt.hasMore),we(vt.total);const Pt=Ne+(vt.events?.length||0);return H.current=Pt,X(Pt),vt.events||[]}else{const Pt=vt.events||vt.messages||[];return W(!1),we(Pt.length),H.current=Pt.length,X(Pt.length),Pt}}catch(Ne){return console.error("Error loading session messages:",Ne),[]}finally{me?wt(!1):qe(!1)}},[ne]),Tp=(f,y)=>{const v=f.split(`
328
- `),E=y.split(`
329
- `),Y=[];let me=0,Ne=0;for(;me<v.length||Ne<E.length;){const Ue=v[me],$e=E[Ne];me>=v.length?(Y.push({type:"added",content:$e,lineNum:Ne+1}),Ne++):Ne>=E.length?(Y.push({type:"removed",content:Ue,lineNum:me+1}),me++):Ue===$e?(me++,Ne++):(Y.push({type:"removed",content:Ue,lineNum:me+1}),Y.push({type:"added",content:$e,lineNum:Ne+1}),me++,Ne++)}return Y},Ap=(f,y="claude")=>Mu(f,y).map(v=>({...v,provider:v.provider||y})),Ut=r?.__provider||ue||"claude",Ji=i.useMemo(()=>Ap(Be,Ut),[Be,Ut]),Ur=i.useCallback((f=[])=>{let y=null;for(const v of f)if(!(!v||typeof v!="object")){if(v.kind==="error"){y=ce.ERRORED;continue}if(v.kind==="session_state_changed"){const E=String(v.payload?.state||"").trim().toLowerCase();Object.values(ce).includes(E)&&(y=E);continue}if(v.kind==="approval_request"){y=ce.AWAITING_APPROVAL;continue}if(v.kind==="approval_resolved"){y=ce.STREAMING;continue}(v.kind==="assistant_text_start"||v.kind==="assistant_text_delta"||v.kind==="reasoning_start"||v.kind==="reasoning_delta"||v.kind==="tool_call_start"||v.kind==="tool_call_input"||v.kind==="tool_call_end"||v.kind==="tool_result"||v.kind==="system_notice")&&(y=ce.STREAMING)}return y},[]),xs=i.useCallback((f=[])=>{const y=Ur(f);return y===ce.COMPLETED||y===ce.ABORTED||y===ce.ERRORED?y:null},[Ur]),Yi=i.useCallback(f=>!(f===ce.COMPLETED||f===ce.ABORTED||f===ce.ERRORED),[]),yn=i.useCallback((f,y)=>y&&(Ke(y),(y===ce.COMPLETED||y===ce.ABORTED||y===ce.ERRORED)&&(tt(f),kt(null),f&&(d&&d(f),m&&m(f))),y),[tt,d,m,Ke]),Xi=i.useCallback(async(f,y)=>{const v=re.current;if(!v?.name||!f)return null;const E=await Sr(v.name,f,!1,y||Ut);return Array.isArray(E)&&E.length>0&&Ze(E),Ur(E)},[Ut,Ur,Sr]),Hr=i.useCallback(async(f,y)=>{const v=await Xi(f,y);return yn(f,v)},[Xi,yn]),Qi=i.useCallback((f,y=[])=>{const v=Ur(y);return yn(f,v),v},[Ur,yn]),Zi=i.useCallback((f,y)=>y===ce.COMPLETED||y===ce.ABORTED||y===ce.ERRORED?(yn(f,y),y):null,[yn]),Ho=i.useCallback((f,y)=>{if(!f)return;const v=oe.current.get(f);v&&clearTimeout(v);const E=setTimeout(()=>{oe.current.delete(f);const Y=r?.id||fe||null;!Y||Y!==f||(Hr(f,y),s&&s({type:"check-session-status",sessionId:f,provider:y||Ut}))},1200);oe.current.set(f,E)},[Ut,fe,Hr,r?.id,s]),Cr=i.useCallback(()=>{pe.current&&(pe.current.scrollTop=pe.current.scrollHeight)},[]),ys=i.useCallback(()=>{if(!pe.current)return!1;const{scrollTop:f,scrollHeight:y,clientHeight:v}=pe.current;return y-f-v<50},[]),vs=i.useCallback(async(f=null)=>{const y=f||pe.current;if(!y||mt.current||ye||!Te||!r||!e)return!1;const v=r.__provider||ue||"claude";mt.current=!0;const E=y.scrollHeight,Y=y.scrollTop,me=H.current;try{const Ne=await Sr(e.name,r.id,!0,v,me);return Ne.length>0&&($.current={height:E,top:Y},Ze(Ue=>[...Ne,...Ue])),!0}finally{mt.current=!1}},[Te,ye,r,e,Sr,ue]),bs=i.useCallback(async()=>{if(pe.current){const f=pe.current,y=ys();On(!y),f.scrollTop<100?_t.current||await vs(f)&&(_t.current=!0):_t.current=!1}},[ys,vs]);i.useLayoutEffect(()=>{if(!$.current||!pe.current)return;const{height:f,top:y}=$.current,v=pe.current,Y=v.scrollHeight-f;v.scrollTop=y+Math.max(Y,0),$.current=null},[B.length]),i.useEffect(()=>{(async()=>{if(r&&e){const y=r.__provider||Yt(localStorage.getItem("selected-provider"));je.current=!0,sessionStorage.removeItem("pendingSessionId");const v=fe!==null&&fe!==r.id;let E=null;if(v?(Xe||(Oe(),tt(),T.current=null,ie([]),Ze([]),kt(null),ot(!1)),H.current=0,X(0),W(!1),we(0),$r(null),et(!1)):fe===null&&(H.current=0,X(0),W(!1),we(0)),Ge(r.id),Xe)Qe(!1);else{const Y=await Sr(e.name,r.id,!1,r.__provider||y||"claude");Ze(Y),E=Qi(r.id,Y),E||Ke(ce.IDLE),n&&s&&Yi(E)&&s({type:"check-session-status",sessionId:r.id,provider:y})}}else{const v=T.current?.sessionId||null||Ce.current&&(fe||yt.current.sessionId)||null,E=!!(v||Ce.current);Xe||E||(Oe(),tt(),T.current=null,ie([]),Ze([]),kt(null),ot(!1),et(!1)),Ge(v),H.current=0,X(0),W(!1),we(0),$r(null)}setTimeout(()=>{je.current=!1},250)})()},[r?.id,r?.__provider,e?.name,e?.fullPath,e?.path,Sr,Cr,Xe,Oe,tt,Qi,s,Ke,Yi,n]),i.useEffect(()=>{const f=ke.current;if(S<=f||(ke.current=S,!r||!e))return;(async()=>{try{const v=r.__provider||Yt(localStorage.getItem("selected-provider")),E=await Sr(e.name,r.id,!1,r.__provider||v||"claude");Ze(E),L&&ys()&&setTimeout(()=>Cr(),200)}catch(v){console.error("Error reloading messages from external update:",v)}})()},[S,r,e,Sr,ys,L,Cr]),i.useEffect(()=>{ke.current=S},[S,e?.name,r?.id]),i.useEffect(()=>{r?.id&&(T.current=null)},[r?.id]),i.useEffect(()=>{const f=r?.id||fe||null,y=yt.current,v=!!(y.startedAt&&(!y.sessionId||!f||y.sessionId===f)&&z!==ce.IDLE);ie(E=>tv(E,Ji,{preserveLocalTail:v}))},[Ji,fe,z,r?.id,ie]),i.useEffect(()=>{l&&l(bt)},[bt,l]),i.useEffect(()=>{e&&q!==""?Mt.setItem(`draft_input_${e.name}`,q):e&&q===""&&Mt.removeItem(`draft_input_${e.name}`)},[q,e]),i.useEffect(()=>{e&&B.length>0&&Mt.setItem(`chat_messages_${e.name}`,JSON.stringify(fa(B)))},[B,e]),i.useEffect(()=>{const f=fa(B);zv(B,f)||ie(f)},[B,ie]),i.useEffect(()=>{if(e){if(Ee.current){Ee.current=!1;return}const f=Mt.getItem(`draft_input_${e.name}`)||"";f!==q&&de(f)}},[e?.name]),i.useEffect(()=>{fe&&_&&u&&u(fe)},[_,fe,u]),i.useEffect(()=>{if(fe&&p){const f=p.has(fe),y=xs(Be);if(f&&y){m&&m(fe);return}f&&!_&&z!==ce.COMPLETED&&z!==ce.ABORTED&&z!==ce.ERRORED&&Ke(ce.STREAMING,{canAbortSession:!0})}},[fe,xs,_,m,p,z,Be]),i.useEffect(()=>{if(o){const f=o.data?.message||o.data,v=["projects_updated","session-created"].includes(o.type),E=new Set(["claude-complete","codex-complete","session-aborted","claude-error","codex-error"]),me=o.type==="claude-response"&&f&&f.type==="system"&&f.subtype==="init"?f?.session_id:null,Ne=sessionStorage.getItem("pendingSessionId");let Ue=r?.id||fe||T.current?.sessionId||null;const $e=me&&(!Ue||me===Ue),vt=v||$e,Pt=!o.sessionId&&T.current&&!T.current.sessionId&&(/error/i.test(o.type||"")||o.type==="conversation-event"&&o.event?.kind==="error"),at=He=>{He&&(d&&d(He),m&&m(He))};if(!vt){if(!Ue&&o.sessionId&&!$s(o.sessionId)&&T.current&&!T.current.sessionId&&(Ue=o.sessionId,T.current.sessionId=o.sessionId,Ge(o.sessionId)),!Ue&&(o.sessionId&&E.has(o.type)&&at(o.sessionId),!Pt)||!o.sessionId&&!Pt)return;if(!Pt&&o.sessionId!==Ue){const He=$s(Ue),ht=!!(o.sessionId&&Ne&&o.sessionId===Ne);if(He&&(ht||!$s(o.sessionId||"")))Ge(o.sessionId),T.current&&(T.current.sessionId=o.sessionId);else{o.sessionId&&E.has(o.type)&&at(o.sessionId),console.log("??-?,? Skipping message for different session:",o.sessionId,"current:",Ue);return}}}const ks=o?.event?.sessionId||o.sessionId||Ue||null,or=!!(ks&&te.current.has(ks));if(o.type==="conversation-event"&&o.event){const He=o.event.sessionId||o.sessionId||Ue||null,ht=o.event.rawRef?.type||null,ar=o.event.kind==="session_state_changed"?String(o.event.payload?.state||"").trim().toLowerCase():"";if(He&&te.current.add(He),ar==="idle"&&Ft(He,ht)){Ho(He,o.event.provider||Ut);return}if(!!(He&&(He===(r?.id||null)||He===(fe||null)||He===(T.current?.sessionId||null)))&&Ot(o.event),Tt(o.event,o.event.provider||Ut),o.event.kind==="approval_request"&&Ke(ce.AWAITING_APPROVAL),o.event.kind==="approval_resolved"&&Ke(ce.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")&&Ke(ce.STREAMING),(o.event.kind==="error"||o.event.payload?.state==="errored")&&(tt(He),Ke(ce.ERRORED),kt(null),He&&(at(He),Hr(He,o.event.provider||Ut))),o.event.kind==="session_state_changed"){const Qt=ar;Qt==="streaming"?(Ke(ce.STREAMING),He&&u&&u(He)):Qt==="awaiting_approval"?(Ke(ce.AWAITING_APPROVAL),He&&u&&u(He)):Qt==="completed"?(tt(He),Ke(ce.COMPLETED),kt(null),He&&(at(He),Hr(He,o.event.provider||Ut))):Qt==="aborted"?(tt(He),Ke(ce.ABORTED),kt(null),He&&(at(He),Hr(He,o.event.provider||Ut))):Qt==="errored"&&(tt(He),Ke(ce.ERRORED),kt(null),He&&(at(He),Hr(He,o.event.provider||Ut)))}return}switch(o.type){case"ws-connection-state":o.state==="connecting"&&(z===ce.QUEUED||_)?Ke(ce.CONNECTING,{canAbortSession:!1}):o.state==="connected"&&z===ce.CONNECTING&&Ke(ce.QUEUED);break;case"connection-error":Ke(ce.ERRORED),kt(null),ie(J=>[...J,{type:"error",content:o.error||"Unable to reach the chat server. Message was not sent.",timestamp:new Date}]);break;case"error":Ke(ce.ERRORED),ot(!1),kt(null),ie(J=>[...J,{type:"error",content:o.error||"The chat server reported an unexpected error.",timestamp:new Date}]);break;case"session-created":if(o.sessionId){const J=Yt(o.provider||Ut),xe=T.current?.sessionId||fe||null,Pe=$s(o.sessionId);if(!(!fe||J==="codex"&&o.sessionId!==fe)||Pe)break;sessionStorage.setItem("pendingSessionId",o.sessionId);try{const it=localStorage.getItem("session-provider-map"),ct=it?JSON.parse(it):{};ct[o.sessionId]=J,localStorage.setItem("session-provider-map",JSON.stringify(ct))}catch{}T.current&&(T.current.sessionId=o.sessionId),Ge(o.sessionId),rr(o.sessionId),u&&u(o.sessionId),Qe(!0),h&&h(o.sessionId,xe),St(it=>it.map(ct=>ct.sessionId?ct:{...ct,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 He=or&&!(o.data?.type==="system"&&o.data?.subtype==="init");if(!He&&f&&typeof f=="object"&&f.type){if(f.type==="content_block_delta"&&f.delta?.text){const J=tn(f.delta.text);U.current+=J,le.current||(le.current=setTimeout(()=>{const xe=U.current;U.current="",le.current=null,xe&&ie(Pe=>{const Je=[...Pe],it=Je[Je.length-1];return it&&it.type==="assistant"&&!it.isToolUse&&it.isStreaming?it.content=(it.content||"")+xe:Je.push({type:"assistant",content:xe,timestamp:new Date,isStreaming:!0}),Je})},100));return}if(f.type==="content_block_stop"){le.current&&(clearTimeout(le.current),le.current=null);const J=U.current;U.current="",J&&ie(xe=>{const Pe=[...xe],Je=Pe[Pe.length-1];return Je&&Je.type==="assistant"&&!Je.isToolUse&&Je.isStreaming?Je.content=(Je.content||"")+J:Pe.push({type:"assistant",content:J,timestamp:new Date,isStreaming:!0}),Pe}),ie(xe=>{const Pe=[...xe],Je=Pe[Pe.length-1];return Je&&Je.type==="assistant"&&Je.isStreaming&&(Je.isStreaming=!1),Pe});return}}if(o.data.type==="system"&&o.data.subtype==="init"&&o.data.session_id&&fe&&o.data.session_id!==fe&&$e){console.log("🔄 Claude CLI session duplication detected:",{originalSession:fe,newSession:o.data.session_id}),Qe(!0),g&&g(o.data.session_id);return}if(o.data.type==="system"&&o.data.subtype==="init"&&o.data.session_id&&!fe&&$e){console.log("🔄 New session init detected:",{newSession:o.data.session_id}),Qe(!0),g&&g(o.data.session_id);return}if(o.data.type==="system"&&o.data.subtype==="init"&&o.data.session_id&&fe&&o.data.session_id===fe&&$e){console.log("🔄 System init message for current session, ignoring");return}if(He)break;if(Array.isArray(f.content)){for(const J of f.content)if(J.type==="tool_use"){const xe=J.input?JSON.stringify(J.input,null,2):"";ie(Pe=>[...Pe,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:J.name,toolInput:xe,toolId:J.id,toolResult:null}])}else if(J.type==="text"&&J.text?.trim()){let xe=tn(J.text);xe=Ga(xe),ie(Pe=>[...Pe,{type:"assistant",content:xe,timestamp:new Date}])}}else if(typeof f.content=="string"&&f.content.trim()){let J=tn(f.content);J=Ga(J),ie(xe=>[...xe,{type:"assistant",content:J,timestamp:new Date}])}if(f.role==="user"&&Array.isArray(f.content))for(const J of f.content)J.type==="tool_result"&&ie(xe=>xe.map(Pe=>Pe.isToolUse&&Pe.toolId===J.tool_use_id?{...Pe,toolResult:{content:J.content,isError:J.is_error,timestamp:new Date}}:Pe));break;case"claude-output":if(or)break;{const J=String(o.data||"");J.trim()&&(U.current+=U.current?`
330
- ${J}`:J,le.current||(le.current=setTimeout(()=>{const xe=U.current;U.current="",le.current=null,xe&&ie(Pe=>{const Je=[...Pe],it=Je[Je.length-1];return it&&it.type==="assistant"&&!it.isToolUse&&it.isStreaming?it.content=it.content?`${it.content}
331
- ${xe}`:xe:Je.push({type:"assistant",content:xe,timestamp:new Date,isStreaming:!0}),Je})},100)))}break;case"claude-interactive-prompt":ie(J=>[...J,{type:"assistant",content:o.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":{if(or||ue!=="claude"||!o.requestId)break;St(J=>J.some(xe=>xe.requestId===o.requestId)?J:[...J,{requestId:o.requestId,toolName:o.toolName||"UnknownTool",input:o.input,context:o.context,sessionId:o.sessionId||null,receivedAt:new Date}]),et(!0),ot(!0),kt(Ka({phaseText:R("activity.stage.waitingPermission"),detailText:o.toolName?R("activity.requestTool",{tool:Oc(o.toolName)}):R("activity.permission.title"),canAbort:!0}));break}case"claude-permission-cancelled":{if(or||!o.requestId)break;St(J=>{const xe=J.filter(Pe=>Pe.requestId!==o.requestId);return xe.length===0&&kt(null),xe});break}case"claude-error":if(or)break;tt(o.sessionId||fe||null),et(!1),ot(!1),kt(null),ie(J=>[...J,{type:"error",content:`出错了:${o.error}`,timestamp:new Date}]);break;case"claude-complete":if(or)break;const ht=o.sessionId||fe||sessionStorage.getItem("pendingSessionId");tt(ht),(ht===fe||!fe)&&(et(!1),ot(!1),kt(null)),ht&&(d&&d(ht),m&&m(ht));const ar=sessionStorage.getItem("pendingSessionId");ar&&!fe&&o.exitCode===0&&(Ge(ar),sessionStorage.removeItem("pendingSessionId"),console.log("✅ New session complete, ID set to:",ar)),e&&o.exitCode===0&&Mt.removeItem(`chat_messages_${e.name}`),St([]);break;case"codex-response":const ze=o.data;if(ze){if(or)break;if(ze.type==="item_delta"&&ze.delta){const J=tn(String(ze.delta));if(J){const xe=`codex:${ze.itemType||"item"}:${ze.itemId||"unknown"}`;ie(Pe=>{const Je=[...Pe];let it=-1;for(let ct=Je.length-1;ct>=0;ct--){const gr=Je[ct];if(gr?.codexItemKey===xe&&gr.type==="assistant"&&!gr.isToolUse){it=ct;break}}if(it===-1)Je.push({type:"assistant",content:J,timestamp:new Date,isStreaming:!0,isThinking:!!ze.isReasoning,codexItemKey:xe});else{const ct=Je[it],gr=ct.content||"";gr.endsWith(J)||(ct.content=gr+J),ct.isStreaming=!0}return Je})}break}if(ze.type==="item_done"){const J=`codex:${ze.itemType||"item"}:${ze.itemId||"unknown"}`,xe=typeof ze.content=="string"?tn(ze.content):"";ie(Pe=>{const Je=[...Pe];let it=-1;for(let ct=Je.length-1;ct>=0;ct--){const gr=Je[ct];if(gr?.codexItemKey===J&&gr.type==="assistant"&&!gr.isToolUse){it=ct;break}}if(it!==-1){const ct=Je[it];xe&&xe!==(ct.content||"")&&(ct.content=xe),ct.isStreaming=!1}else xe.trim()&&Je.push({type:"assistant",content:xe,timestamp:new Date,isStreaming:!1,isThinking:!!ze.isReasoning});return Je});break}if(ze.type==="item")switch(ze.itemType){case"agent_message":if(ze.message?.content?.trim()){const J=tn(ze.message.content);ie(xe=>{const Pe=xe[xe.length-1];return Pe&&Pe.type==="assistant"&&!Pe.isToolUse&&!Pe.isThinking&&(Pe.content||"").trim()===J.trim()?xe:[...xe,{type:"assistant",content:J,timestamp:new Date}]})}break;case"reasoning":if(ze.message?.content?.trim()){const J=tn(ze.message.content);ie(xe=>{const Pe=xe[xe.length-1];return Pe&&Pe.type==="assistant"&&!Pe.isToolUse&&Pe.isThinking&&(Pe.content||"").trim()===J.trim()?xe:[...xe,{type:"assistant",content:J,timestamp:new Date,isThinking:!0}]})}break;case"command_execution":ze.command&&ie(J=>[...J,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:ze.command,toolResult:ze.output||null,exitCode:ze.exitCode}]);break;case"file_change":if(ze.changes?.length>0){const J=ze.changes.map(xe=>`${xe.kind}: ${xe.path}`).join(`
332
- `);ie(xe=>[...xe,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:J,toolResult:`Status: ${ze.status}`}])}break;case"mcp_tool_call":ie(J=>[...J,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${ze.server}:${ze.tool}`,toolInput:JSON.stringify(ze.arguments,null,2),toolResult:ze.result?JSON.stringify(ze.result,null,2):ze.error?.message||null}]);break;case"error":ze.message?.content&&ie(J=>[...J,{type:"error",content:ze.message.content,timestamp:new Date}]);break;default:console.log("[Codex] Unhandled item type:",ze.itemType,ze)}ze.type==="turn_complete"&&et(!1),ze.type==="turn_failed"&&(et(!1),ie(J=>[...J,{type:"error",content:ze.error?.message||"Turn failed",timestamp:new Date}]))}break;case"codex-complete":if(or)break;const Qt=o.sessionId||fe||sessionStorage.getItem("pendingSessionId");tt(Qt),(Qt===fe||!fe)&&(et(!1),ot(!1),kt(null),ie(J=>J.map(xe=>xe?.codexItemKey&&xe.isStreaming?{...xe,isStreaming:!1}:xe))),Qt&&(d&&d(Qt),m&&m(Qt));const Xo=sessionStorage.getItem("pendingSessionId"),ll=o.actualSessionId||Xo;Xo&&!fe&&(Ge(ll),Qe(!0),g&&g(ll),sessionStorage.removeItem("pendingSessionId"),console.log("Codex session complete, ID set to:",Xo)),e&&Qt&&Sr(e.name,Qt,!1,"codex").then(J=>{Array.isArray(J)&&J.length>0&&Ze(J)}).catch(J=>{console.error("Error reloading Codex session after completion:",J)}),e&&Mt.removeItem(`chat_messages_${e.name}`);break;case"codex-error":if(or)break;tt(o.sessionId||fe||null),et(!1),ot(!1),ie(J=>J.map(xe=>xe?.codexItemKey&&xe.isStreaming?{...xe,isStreaming:!1}:xe)),ie(J=>[...J,{type:"error",content:o.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{if(or)break;const J=o.sessionId||fe;tt(J),J===fe&&(et(!1),ot(!1),kt(null)),J&&(d&&d(J),m&&m(J)),St([]),ie(xe=>[...xe,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}]);break}case"session-status":{if(or)break;const J=o.sessionId,xe=o.provider||r?.__provider||Ut,Pe=J===fe||r&&J===r.id,Je=Ur(Be),it=xs(Be);if(Pe&&o.isProcessing){if(it){Zi(J,it);break}et(!0),ot(!0),u&&u(J)}else if(Pe&&o.isProcessing===!1){if(Ft(J,"session-status")){Ho(J,xe);break}Hr(J,xe).then(ct=>{if(!(ct===ce.COMPLETED||ct===ce.ABORTED||ct===ce.ERRORED)){if(Je===ce.STREAMING||Je===ce.AWAITING_APPROVAL){Ke(Je);return}et(!1),ot(!1),kt(null)}})}break}case"claude-status":const Jt=o.data;if(Jt){let J={text:"Working...",tokens:0,can_interrupt:!0};Jt.message?J.text=Jt.message:Jt.status?J.text=Jt.status:typeof Jt=="string"&&(J.text=Jt),Jt.tokens?J.tokens=Jt.tokens:Jt.token_count&&(J.tokens=Jt.token_count),Jt.can_interrupt!==void 0&&(J.can_interrupt=Jt.can_interrupt),kt(Uv(Jt,R,_i.current)),et(!0),ot(J.can_interrupt)}break}}},[Ut,Ot,tt,fe,Ur,xs,_,o,Hr,Zi,z,Ho,r,Ft,rr,R]),i.useEffect(()=>{e&&_p()},[e]);const _p=async()=>{try{const f=await pt.getFiles(e.name);if(f.ok){const y=await f.json(),v=el(y);Ye(v)}}catch(f){console.error("Error fetching files:",f)}},el=(f,y="")=>{let v=[];for(const E of f){const Y=y?`${y}/${E.name}`:E.name;E.type==="directory"&&E.children?v=v.concat(el(E.children,Y)):E.type==="file"&&v.push({name:E.name,path:Y,relativePath:E.path})}return v};i.useEffect(()=>{const f=q.slice(0,Ii),y=f.lastIndexOf("@");if(y!==-1){const v=f.slice(y+1);if(v.includes(" "))ft(!1),is(-1);else{is(y),ft(!0);const E=lt.filter(Y=>Y.name.toLowerCase().includes(v.toLowerCase())||Y.path.toLowerCase().includes(v.toLowerCase())).slice(0,10);Pr(E),hn(-1)}}else ft(!1),is(-1)},[q,Ii,lt]);const Go=i.useMemo(()=>!q||Rt.length===0?[]:Rt.filter(f=>q.includes(f)),[Rt,q]),Bn=i.useMemo(()=>Go.length===0?[]:Array.from(new Set(Go)).sort((y,v)=>v.length-y.length),[Go]),qo=i.useMemo(()=>{if(Bn.length===0)return null;const f=Bn.map(gv).join("|");return new RegExp(`(${f})`,"g")},[Bn]),tl=i.useMemo(()=>new Set(Bn),[Bn]),Mp=i.useCallback(f=>f?qo?f.split(qo).map((v,E)=>tl.has(v)?t.jsx("span",{className:"bg-primary/20 -ml-0.5 dark:bg-primary/25 px-0.5 rounded-md box-decoration-clone text-transparent",children:v},`mention-${E}`):t.jsx("span",{children:v},`text-${E}`)):f:"",[qo,tl]);i.useEffect(()=>{const f=setTimeout(()=>{rt(q)},150);return()=>clearTimeout(f)},[q]);const vn=i.useMemo(()=>r||B.length<=Fn?B:B.slice(-Fn),[B,Fn,r]),Dp=i.useMemo(()=>{const f=vn.map((v,E)=>({...v,__threadMessageId:xv(v,E)}));return f.length===0||!_||f.some(v=>v?.type!=="assistant"?!1:!!(v.isStreaming||v.isToolUse||v.isThinking||v.reasoning))?f:[...f,{id:"__assistant-loading-indicator__",type:"assistant",content:"",timestamp:new Date,isLoadingIndicator:!0,__provider:r?.__provider||ue||"claude"}]},[vn,_,r?.__provider,ue]);i.useMemo(()=>{if(!_||vn.length===0)return-1;for(let f=vn.length-1;f>=0;f--){const y=vn[f];if(y.type==="assistant"&&(y.isStreaming||y.isToolUse||y.isThinking||y.reasoning))return f}return-1},[vn,_]),i.useEffect(()=>{if(!L&&pe.current){const f=pe.current;vo.current={height:f.scrollHeight,top:f.scrollTop}}}),i.useEffect(()=>{if(pe.current&&B.length>0)if(L)yo||setTimeout(()=>Cr(),50);else{const f=pe.current,y=vo.current.height,v=vo.current.top,Y=f.scrollHeight-y;Y>0&&v>0&&(f.scrollTop=v+Y)}},[B.length,yo,Cr,L]),i.useEffect(()=>{pe.current&&B.length>0&&!je.current&&(On(!1),setTimeout(()=>{Cr()},200))},[r?.id,e?.name]),i.useEffect(()=>{const f=pe.current;if(f)return f.addEventListener("scroll",bs),()=>f.removeEventListener("scroll",bs)},[bs]),i.useEffect(()=>{if(Q.current){Q.current.style.height="auto",Q.current.style.height=Q.current.scrollHeight+"px";const f=parseInt(window.getComputedStyle(Q.current).lineHeight),y=Q.current.scrollHeight>f*2;Yr(y)}},[]),i.useEffect(()=>{Q.current&&!q.trim()&&(Q.current.style.height="auto",Yr(!1))},[q]),i.useEffect(()=>{if(!e||!r?.id||r.id.startsWith("new-session-")){$r(null);return}if((r.__provider||ue||"claude")!=="claude")return;(async()=>{try{const v=`/api/projects/${e.name}/sessions/${r.id}/token-usage`,E=await ee(v);if(E.ok){const Y=await E.json();$r(Y)}else $r(null)}catch(v){console.error("Failed to fetch initial token usage:",v)}})()},[r?.id,r?.__provider,e?.path]),i.useCallback(f=>{f.trim()&&de(y=>{const v=y.trim()?`${y} ${f}`:f;return setTimeout(()=>{if(Q.current){Q.current.style.height="auto",Q.current.style.height=Q.current.scrollHeight+"px";const E=parseInt(window.getComputedStyle(Q.current).lineHeight),Y=Q.current.scrollHeight>E*2;Yr(Y)}},0),v})},[]);const Rp=i.useCallback(()=>{up(f=>f+100)},[]),Pp=i.useCallback(()=>{vs()},[vs]),ws=i.useCallback(f=>{const y=f.filter(v=>{try{if(!v||typeof v!="object")return console.warn("Invalid file object:",v),!1;if(!v.type||!v.type.startsWith("image/"))return!1;if(!v.size||v.size>5242880){const E=v.name||"Unknown file";return ge(Y=>{const me=new Map(Y);return me.set(E,"File too large (max 5MB)"),me}),!1}return!0}catch(E){return console.error("Error validating file:",E,v),!1}});y.length>0&&$t(v=>[...v,...y].slice(0,5))},[]),Lp=i.useCallback(async f=>{const y=Array.from(f.clipboardData.items);for(const v of y)if(v.type.startsWith("image/")){const E=v.getAsFile();E&&ws([E])}if(y.length===0&&f.clipboardData.files.length>0){const E=Array.from(f.clipboardData.files).filter(Y=>Y.type.startsWith("image/"));E.length>0&&ws(E)}},[ws]),{getRootProps:Op,getInputProps:Fp,isDragActive:$p,open:zp}=gu({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:ws,noClick:!0,noKeyboard:!0}),en=i.useCallback(async(f,y=null)=>{f.preventDefault();const v=typeof y=="string"?y:q,E=r?.__provider||ue||"claude";if((To[E]?.status||Fs)===ma||!v.trim()||_||!e)return;let me=v;const Ne=Xl(E),Ue=Ne.enabled?Pm.find(ht=>ht.id===Xr):null;Ne.strategy==="prompt-prefix"&&Ue&&Ue.prefix&&(me=`${Ue.prefix}: ${v}`);const $e=!hs&&Tv(Nr)?Ov(Nr):null;$e&&(me=Fv($e,me)),Ke(ce.QUEUED),kt(Ka({phaseText:R("activity.stage.generatingReply"),detailText:R("activity.detail.preparingReply"),canAbort:!0}));let vt=[];if(It.length>0){if(!Xy(E)){Ke(ce.IDLE),ot(!1),kt(null),ie(ht=>[...ht,{type:"error",content:`${E} 当前不支持图片输入`,timestamp:new Date}]);return}try{vt=await dv(It)}catch(ht){console.error("Image preparation failed:",ht),Ke(ce.IDLE),ot(!1),kt(null),ie(ar=>[...ar,{type:"error",content:`图片处理失败:${ht.message}`,timestamp:new Date}]);return}}const Pt={type:"user",content:v,images:vt,timestamp:new Date};ie(ht=>[...ht,Pt]),On(!1),setTimeout(()=>Cr(),100);const at=fe||r?.id;At(at||r?.id||null),at&&Ot(Ht({kind:"user_message",provider:E,sessionId:at,timestamp:Pt.timestamp,payload:{text:v}}));const ks=at||`new-session-${Date.now()}`;!at&&!r?.id&&(T.current={sessionId:null,startedAt:Date.now()}),c&&c(ks);const He=(()=>{try{const ht=ue==="codex"?"codex-settings":"claude-settings",ar=Mt.getItem(ht);if(ar)return JSON.parse(ar)}catch(ht){console.error("Error loading tools settings:",ht)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();if(E==="codex"){const ht=Ne.enabled&&Ne.strategy==="native-effort"?Qy(Xr):void 0;s({type:"codex-command",command:me,sessionId:at,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:at,resume:!!at,permissionMode:We==="plan"?"default":We,...Xt?{model:Xt}:{},...ht?{modelReasoningEffort:ht}:{},images:vt}})}else s(E==="gemini"?{type:"gemini-command",command:me,sessionId:at,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:at,resume:!!at,permissionMode:We==="plan"?"default":We,...Xt?{model:Xt}:{}}}:E==="opencode"?{type:"opencode-command",command:me,sessionId:at,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:at,resume:!!at,permissionMode:We==="plan"?"default":We,...Xt?{model:Xt}:{}}}:{type:"claude-command",command:me,options:{projectPath:e.path,cwd:e.fullPath,sessionId:at,resume:!!at,toolsSettings:He,permissionMode:We,...Xt?{model:Xt}:{},images:vt}});$e&&gs(!0),de(""),$t([]),Bt(new Map),ge(new Map),Yr(!1),cs("none"),Q.current&&(Q.current.style.height="auto"),e&&Mt.removeItem(`draft_input_${e.name}`)},[q,_,e,It,fe,r,ue,To,We,c,_o,Do,Po,Oo,s,de,$t,Bt,ge,Yr,Q,ie,et,ot,kt,On,Cr,Xr,Nr,hs,At,Ot]),rl=i.useCallback(f=>!f||ue!=="claude"?{success:!1}:Wv(f.entry),[ue]),Ko=i.useCallback((f,y)=>{const E=(Array.isArray(f)?f:[f]).filter(Boolean);E.length!==0&&(E.forEach(Y=>{s({type:"claude-permission-response",requestId:Y,allow:!!y?.allow,updatedInput:y?.updatedInput,message:y?.message,rememberEntry:y?.rememberEntry})}),St(Y=>{const me=Y.filter(Ne=>!E.includes(Ne.requestId));return me.length===0&&kt(null),me}))},[s]);i.useEffect(()=>{zn.current=en},[en]);const nl=f=>{if(!f)return;const y=q.slice(0,Ai),v=q.slice(Ai),E=v.indexOf(" "),Y=E!==-1?v.slice(E):"",me=y+f.name+" "+Y;de(me),Lr(!1),Br(-1),Fr(""),zr(-1),K.current&&clearTimeout(K.current),Vi(f)},Bp=f=>{if(bo&&Jr.length>0){if(f.key==="ArrowDown"){f.preventDefault(),zr(y=>y<Jr.length-1?y+1:0);return}if(f.key==="ArrowUp"){f.preventDefault(),zr(y=>y>0?y-1:Jr.length-1);return}if(f.key==="Tab"||f.key==="Enter"){f.preventDefault(),jo>=0?nl(Jr[jo]):Jr.length>0&&nl(Jr[0]);return}if(f.key==="Escape"){f.preventDefault(),Lr(!1),Br(-1),Fr(""),zr(-1),K.current&&clearTimeout(K.current);return}}if(Ct&&Vt.length>0){if(f.key==="ArrowDown"){f.preventDefault(),hn(y=>y<Vt.length-1?y+1:0);return}if(f.key==="ArrowUp"){f.preventDefault(),hn(y=>y>0?y-1:Vt.length-1);return}if(f.key==="Tab"||f.key==="Enter"){f.preventDefault(),zt>=0?Vo(Vt[zt]):Vt.length>0&&Vo(Vt[0]);return}if(f.key==="Escape"){f.preventDefault(),ft(!1);return}}if(f.key==="Tab"&&!Ct&&!bo){f.preventDefault();const y=Wr.modes,E=(y.indexOf(We)+1)%y.length,Y=y[E];Et(Y),r?.id&&localStorage.setItem(`permissionMode-${r.id}`,Y);return}if(f.key==="Enter"){if(f.nativeEvent.isComposing)return;(f.ctrlKey||f.metaKey)&&!f.shiftKey?(f.preventDefault(),en(f)):!f.shiftKey&&!f.ctrlKey&&!f.metaKey&&(j||(f.preventDefault(),en(f)))}},Vo=f=>{const y=q.slice(0,Ti),v=q.slice(Ti),E=v.indexOf(" "),Y=E!==-1?v.slice(E):"",me=y+f.path+" "+Y,Ne=y.length+f.path.length+1;Q.current&&!Q.current.matches(":focus")&&Q.current.focus(),de(me),as(Ne),Wt(Ue=>Ue.includes(f.path)?Ue:[...Ue,f.path]),ft(!1),is(-1),Q.current&&requestAnimationFrame(()=>{Q.current&&(Q.current.setSelectionRange(Ne,Ne),Q.current.matches(":focus")||Q.current.focus())})},Wp=f=>{const y=f.target.value,v=f.target.selectionStart;if(!fe&&y.trim(),de(y),as(v),!y.trim()){f.target.style.height="auto",Yr(!1),Lr(!1),Br(-1),Fr("");return}const E=y.slice(0,v);if((E.match(/```/g)||[]).length%2===1){Lr(!1),Br(-1),Fr("");return}const Ne=/(^|\s)\/(\S*)$/,Ue=E.match(Ne);if(Ue){const $e=Ue.index+Ue[1].length,vt=Ue[2];Br($e),Lr(!0),zr(-1),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{Fr(vt)},150)}else Lr(!1),Br(-1),Fr(""),K.current&&clearTimeout(K.current)},sl=i.useCallback(f=>{!F.current||!f||(F.current.scrollTop=f.scrollTop,F.current.scrollLeft=f.scrollLeft)},[]),Up=f=>{as(f.target.selectionStart)},Hp=()=>{fe&&N&&s({type:"abort-session",sessionId:fe,provider:ue})};if(!e)return t.jsx("div",{className:"flex h-full items-center justify-center px-4 py-8 sm:px-6",children:t.jsxs("div",{className:"max-w-lg px-8 py-10 text-center text-muted-foreground",children:[t.jsx("div",{className:"mx-auto mb-5 flex h-14 w-14 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:t.jsx(Vn,{className:"h-7 w-7"})}),t.jsx("p",{className:"text-base font-medium text-foreground",children:"Select a project to start chatting"})]})});const Er=r?.__provider||ue||"claude",Jo=To[Er],Yo=(Jo?.status||Fs)===ma,Gp=Jo?.reason||gp[Er]||null,ol=Jo?.installHint||null,al=!!hp[Er],bn=_||Yo,wn=ay({status:No,messages:B,pendingPermissionRequests:O,t:R}),qp=_&&!!wn,Kp=Er==="opencode"?"OpenCode":R(`messageTypes.${Er}`),il=R("input.providerNotInstalledWithName",{provider:Kp}),Vp=ue==="codex"?"Codex":ue==="gemini"?"Gemini":ue==="opencode"?"OpenCode":"Claude",Jp=B.length===0?null:t.jsxs(t.Fragment,{children:[ye&&t.jsx("div",{className:"pb-3 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),t.jsx("p",{className:"text-sm",children:R("session.loading.olderMessages")})]})}),Te&&!ye&&t.jsx("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:Z>0&&t.jsxs("span",{children:[R("session.messages.showingOf",{shown:Be.length,total:Z})," •",t.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:Pp,children:R("session.messages.loadEarlier")}),t.jsx("span",{className:"ml-1 text-xs",children:R("session.messages.scrollToLoad")})]})}),!r&&!Te&&B.length>Fn&&t.jsxs("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:[R("session.messages.showingLast",{count:Fn,total:B.length})," •",t.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:Rp,children:R("session.messages.loadEarlier")})]})]}),Yp=B.length===0?null:t.jsx(t.Fragment,{children:O.map(f=>{const y=oc(f.input),v=qa(f.toolName,y),E=ki(),Y=v?E.allowedTools.includes(v):!1,me=v?O.filter(Ne=>qa(Ne.toolName,oc(Ne.input))===v).map(Ne=>Ne.requestId):[f.requestId];return t.jsx(iy,{request:f,permissionEntry:v,alreadyAllowed:Y,rawInput:y,className:"mx-1 my-3 sm:mx-0",onAllowOnce:()=>Ko(f.requestId,{allow:!0}),onAllowRemember:()=>{v&&!Y&&rl({entry:v,toolName:f.toolName}),Ko(me,{allow:!0,rememberEntry:v})},onDeny:()=>Ko(f.requestId,{allow:!1,message:R("activity.permission.deniedMessage")})},f.requestId)})});return t.jsxs(t.Fragment,{children:[t.jsx("style",{children:`
333
- details[open] .details-chevron {
334
- transform: rotate(180deg);
335
- }
336
- `}),t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:xt&&B.length===0?t.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:t.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),t.jsx("p",{children:R("session.loading.sessionMessages")})]})}):B.length===0?t.jsxs("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:[!r&&!fe&&t.jsxs("div",{className:"w-full max-w-3xl text-center",children:[t.jsx("h2",{className:"mb-2 text-3xl font-semibold tracking-tight text-foreground sm:text-4xl",children:R("providerSelection.title")}),t.jsx("p",{className:"mx-auto mb-8 max-w-xl text-base text-muted-foreground",children:R("providerSelection.description")}),t.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-2",children:[t.jsx("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{fs("claude")},className:`group relative w-full h-auto rounded-xl px-3 py-3 transition-colors duration-150 ${ue==="claude"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"}`,children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Pn,{className:"h-10 w-10 flex-shrink-0"}),t.jsx("div",{className:"text-left",children:t.jsx("p",{className:"text-base font-medium text-foreground",children:"Claude Code"})})]})}),t.jsx("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{fs("codex")},className:`group relative w-full h-auto rounded-xl px-3 py-3 transition-colors duration-150 ${ue==="codex"?"border-foreground bg-accent/70 text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"}`,children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ss,{className:"h-10 w-10 flex-shrink-0"}),t.jsx("div",{className:"text-left",children:t.jsx("p",{className:"text-base font-medium text-foreground",children:"Codex"})})]})}),t.jsx("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{fs("gemini")},className:`group relative w-full h-auto rounded-xl px-3 py-3 transition-colors duration-150 ${ue==="gemini"?"border-foreground bg-accent/70 text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"}`,children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(mo,{className:"h-10 w-10 flex-shrink-0"}),t.jsx("div",{className:"text-left",children:t.jsx("p",{className:"text-base font-medium text-foreground",children:"Gemini"})})]})}),t.jsx("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{fs("opencode")},className:`group relative w-full h-auto rounded-xl px-3 py-3 transition-colors duration-150 ${ue==="opencode"?"border-foreground bg-accent/70 text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"}`,children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(fo,{className:"h-10 w-auto max-w-full flex-shrink-0 text-foreground"}),t.jsx("div",{className:"text-left",children:t.jsx("p",{className:"text-base font-medium text-foreground",children:"OpenCode"})})]})})]})]}),r&&t.jsxs("div",{className:"px-6 text-center text-muted-foreground sm:px-4",children:[t.jsx("p",{className:"mb-3 text-2xl font-semibold text-foreground",children:R("session.continue.title")}),t.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:R("session.continue.description")})]})]}):t.jsx(Lm,{messages:Dp,convertMessage:Om,isRunning:_,scrollContainerRef:pe,onScroll:bs,messagesEndRef:Re,provider:ue,providerLabel:Vp,createDiff:Ip,onFileOpen:a,onShowSettings:x,onGrantToolPermission:rl,showRawParameters:w,autoExpandTools:k,selectedProject:e,markdownRenderer:Ha,topContent:Jp,bottomContent:Yp})}),t.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:[t.jsx("div",{className:"flex-1",children:t.jsx(Fm,{phaseText:wn?.phaseText,detailText:wn?.detailText,elapsedSeconds:wn?.elapsedSeconds,startedAt:wn?.startedAt,canAbort:wn?.canAbort,isLoading:qp,onAbort:Hp,provider:ue})}),t.jsx("div",{ref:C,className:"mx-auto mb-3 w-full max-w-4xl"}),t.jsxs("form",{onSubmit:en,className:"relative mx-auto w-full max-w-4xl",children:[yo&&B.length>0&&t.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:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})}),$p&&t.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center rounded-2xl border border-dashed border-primary bg-primary/5",children:t.jsxs("div",{className:"rounded-xl border border-border/70 bg-background p-4",children:[t.jsx("svg",{className:"w-8 h-8 text-primary mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("p",{className:"text-sm font-medium",children:"将图片拖到这里"})]})}),It.length>0&&t.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:It.map((f,y)=>t.jsx(qv,{file:f,onRemove:()=>{$t(v=>v.filter((E,Y)=>Y!==y))},uploadProgress:nr.get(f.name),error:M.get(f.name)},y))})}),sr&&t.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[wr(sr.systemContext)&&t.jsx(Hn,{content:sr.systemContext,className:"whitespace-normal break-words max-w-sm",delay:200,children:t.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:[t.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:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5h16M4 12h16M4 19h16"})}),t.jsx("span",{className:"truncate",children:R("input.dynamicContext.systemChip")}),t.jsx("button",{type:"button",onClick:wp,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:R("input.dynamicContext.removeSystem"),"aria-label":R("input.dynamicContext.removeSystem"),children:t.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),wr(Cn(sr.currentFile))&&t.jsx(Hn,{content:Cn(sr.currentFile),className:"whitespace-normal break-words max-w-sm",delay:200,children:t.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:[t.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:t.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"})}),t.jsx("span",{className:"truncate",children:Ev(sr.currentFile)}),t.jsx("button",{type:"button",onClick:kp,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:R("input.dynamicContext.removeCurrentFile"),"aria-label":R("input.dynamicContext.removeCurrentFile"),children:t.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),bp.map((f,y)=>t.jsx(Hn,{content:rc(f),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-normal break-words",delay:200,children:t.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:[t.jsx("svg",{className:"w-3.5 h-3.5 text-primary flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 15l2 5L7 17l3-10 10 3-5 2z"})}),t.jsx("span",{className:"truncate",children:f.tag||R("input.dynamicContext.elementFallback")}),t.jsx("button",{type:"button",onClick:()=>jp(f),className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:R("input.dynamicContext.removeElement"),"aria-label":R("input.dynamicContext.removeElement"),children:t.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},`${f.selector}-${y}`)),Wo.length>0&&t.jsx(Hn,{content:Wo.map(rc).join(`
337
- `),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-pre-wrap break-words",delay:200,children:t.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:["+",Wo.length]})})]})}),Ct&&Vt.length>0&&t.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:Vt.map((f,y)=>t.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 touch-manipulation ${y===zt?"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:v=>{v.preventDefault(),v.stopPropagation()},onClick:v=>{v.preventDefault(),v.stopPropagation(),Vo(f)},children:[t.jsx("div",{className:"font-medium text-sm",children:f.name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:f.path})]},f.path))}),t.jsx(Ky,{commands:Jr,selectedIndex:jo,onSelect:Sp,onClose:()=>{Lr(!1),Br(-1),Fr(""),zr(-1)},position:{top:Q.current?Math.max(16,Q.current.getBoundingClientRect().top-316):0,left:Q.current?Q.current.getBoundingClientRect().left:16,bottom:Q.current?window.innerHeight-Q.current.getBoundingClientRect().top+8:90},isOpen:bo,frequentCommands:ls?[]:Np}),t.jsxs("div",{...Op(),className:`chat-composer-shell relative overflow-visible rounded-[20px] transition-all duration-200 ${dp?"chat-input-expanded":""} ${bt?"border-primary/40 ring-2 ring-primary/10":"hover:border-border hover:shadow-md"}`,children:[t.jsx("input",{...Fp()}),t.jsx("div",{ref:F,"aria-hidden":"true",className:"absolute inset-0 pointer-events-none overflow-hidden rounded-[24px]",children:t.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:Mp(q)})}),t.jsxs("div",{className:"relative z-10 flex flex-col",children:[t.jsx("div",{className:"relative px-4 pt-4",children:t.jsx("textarea",{ref:Q,value:q,onChange:Wp,onClick:Up,onKeyDown:Bp,onPaste:Lp,onScroll:f=>sl(f.target),onFocus:()=>st(!0),onBlur:()=>st(!1),onInput:f=>{f.target.style.height="auto",f.target.style.height=f.target.scrollHeight+"px",as(f.target.selectionStart),sl(f.target);const y=parseInt(window.getComputedStyle(f.target).lineHeight),v=f.target.scrollHeight>y*2;Yr(v)},placeholder:Yo?il:R("input.placeholder",{provider:Er==="codex"?R("messageTypes.codex"):Er==="gemini"?R("messageTypes.gemini"):Er==="opencode"?"OpenCode":R("messageTypes.claude")}),disabled:bn,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"}})}),Yo&&t.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:[t.jsx("div",{children:Gp||il}),ol&&t.jsx("div",{className:"mt-1 font-mono text-[11px] opacity-90 break-all",children:ol}),t.jsx("div",{className:"mt-2",children:t.jsx("button",{type:"button",onClick:()=>$n(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:al,children:R(al?"input.checkingInstallation":"input.recheckInstallation")})})]}),t.jsxs("div",{className:"flex items-end justify-between gap-2 px-3 pb-3 pt-2 sm:items-center",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 sm:flex-nowrap sm:gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{bn||zp()},disabled:bn,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:R("input.attachImages"),children:[t.jsx(ln,{className:"h-4 w-4 sm:hidden"}),t.jsx("svg",{className:"hidden h-5 w-5 sm:block",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})]}),t.jsx("div",{ref:Co,className:"relative min-w-0 max-w-full flex-[0_1_auto]",children:t.jsxs(dl,{value:Xt||void 0,onValueChange:f=>{ue==="claude"?Mo(f):ue==="codex"?Ro(f):ue==="gemini"?Lo(f):ue==="opencode"&&Fo(f),pv(ue,f)},disabled:bn||ms||vp,children:[t.jsx(ul,{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:t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[ms&&t.jsx(qr,{className:"h-3.5 w-3.5 flex-shrink-0 animate-spin text-muted-foreground"}),t.jsx("span",{className:"truncate text-xs font-normal text-muted-foreground",children:ms?R("input.loadingModels"):yp}),t.jsx(Ar,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),t.jsx(pl,{children:ms?t.jsx(ea,{value:"__loading",disabled:!0,children:R("input.loadingModels")}):ps.map(({value:f,label:y})=>t.jsx(ea,{value:f,children:y},f))})]})}),t.jsx("div",{className:"relative min-w-0 max-w-full flex-[0_1_auto]",ref:Eo,children:t.jsxs(dl,{value:We,onValueChange:f=>{Et(f),r&&localStorage.setItem(`permissionMode-${r.id}`,f)},disabled:bn,children:[t.jsx(ul,{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:t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("span",{className:"truncate text-xs font-normal text-muted-foreground",children:fp||Di||R("input.clickToChangeMode")}),t.jsx(Ar,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),t.jsx(pl,{children:t.jsxs($m,{children:[t.jsx(zm,{children:Di}),Wr.modes.map(f=>t.jsx(ea,{value:f,children:Io(f,{short:!0})},f))]})})]})}),Qr.enabled&&t.jsx(Bm,{selectedMode:Xr,onModeChange:cs,className:"sm:flex-none"}),hr!==null&&t.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:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:(()=>{if(typeof hr?.percentage=="number")return`${Math.min(100,Math.max(0,hr.percentage))}%`;if(typeof hr?.used=="number"&&typeof hr?.total=="number"&&hr.total>0){const f=Math.round(hr.used/hr.total*100);return`${Math.min(100,Math.max(0,f))}%`}return"0%"})()})]}),t.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700 mx-1 hidden sm:block"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"relative group hidden sm:block",children:[t.jsx("button",{type:"button",className:"rounded-lg p-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",title:R("input.commands"),children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.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:t.jsx("p",{children:R(j?"input.hintText.ctrlEnter":"input.hintText.enter")})})]}),t.jsx("button",{type:"submit",disabled:!q.trim()||bn,onMouseDown:f=>{f.preventDefault(),en(f)},onTouchStart:f=>{f.preventDefault(),en(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:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h12m-5-5 5 5-5 5"})})})]})]})]})]})]})]})]})]})}const Vv=dn.memo(Kv);class Dt{constructor(r,n,s,o){this.fromA=r,this.toA=n,this.fromB=s,this.toB=o}offset(r,n=r){return new Dt(this.fromA+r,this.toA+r,this.fromB+n,this.toB+n)}}function cn(e,r,n,s,o,a){if(e==s)return[];let l=Ni(e,r,n,s,o,a),c=Si(e,r+l,n,s,o+l,a);r+=l,n-=c,o+=l,a-=c;let d=n-r,u=a-o;if(!d||!u)return[new Dt(r,n,o,a)];if(d>u){let p=e.slice(r,n).indexOf(s.slice(o,a));if(p>-1)return[new Dt(r,r+p,o,o),new Dt(r+p+u,n,a,a)]}else if(u>d){let p=s.slice(o,a).indexOf(e.slice(r,n));if(p>-1)return[new Dt(r,r,o,o+p),new Dt(n,n,o+p+d,a)]}if(d==1||u==1)return[new Dt(r,n,o,a)];let m=Fu(e,r,n,s,o,a);if(m){let[p,h,g]=m;return cn(e,r,p,s,o,h).concat(cn(e,p+g,n,s,h+g,a))}return Jv(e,r,n,s,o,a)}let Gn=1e9,qn=0,ji=!1;function Jv(e,r,n,s,o,a){let l=n-r,c=a-o;if(Gn<1e9&&Math.min(l,c)>Gn*16||qn>0&&Date.now()>qn)return Math.min(l,c)>Gn*64?[new Dt(r,n,o,a)]:ac(e,r,n,s,o,a);let d=Math.ceil((l+c)/2);ha.reset(d),ga.reset(d);let u=(g,x)=>e.charCodeAt(r+g)==s.charCodeAt(o+x),m=(g,x)=>e.charCodeAt(n-g-1)==s.charCodeAt(a-x-1),p=(l-c)%2!=0?ga:null,h=p?null:ha;for(let g=0;g<d;g++){if(g>Gn||qn>0&&!(g&63)&&Date.now()>qn)return ac(e,r,n,s,o,a);let x=ha.advance(g,l,c,d,p,!1,u)||ga.advance(g,l,c,d,h,!0,m);if(x)return Yv(e,r,n,r+x[0],s,o,a,o+x[1])}return[new Dt(r,n,o,a)]}class Lu{constructor(){this.vec=[]}reset(r){this.len=r<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[r+1]=0,this.start=this.end=0}advance(r,n,s,o,a,l,c){for(let d=-r+this.start;d<=r-this.end;d+=2){let u=o+d,m=d==-r||d!=r&&this.vec[u-1]<this.vec[u+1]?this.vec[u+1]:this.vec[u-1]+1,p=m-d;for(;m<n&&p<s&&c(m,p);)m++,p++;if(this.vec[u]=m,m>n)this.end+=2;else if(p>s)this.start+=2;else if(a){let h=o+(n-s)-d;if(h>=0&&h<this.len&&a.vec[h]!=-1)if(l){let g=a.vec[h];if(g>=n-m)return[g,o+g-h]}else{let g=n-a.vec[h];if(m>=g)return[m,p]}}}return null}}const ha=new Lu,ga=new Lu;function Yv(e,r,n,s,o,a,l,c){let d=!1;return!Mn(e,s)&&++s==n&&(d=!0),!Mn(o,c)&&++c==l&&(d=!0),d?[new Dt(r,n,a,l)]:cn(e,r,s,o,a,c).concat(cn(e,s,n,o,c,l))}function Ou(e,r){let n=1,s=Math.min(e,r);for(;n<s;)n=n<<1;return n}function Ni(e,r,n,s,o,a){if(r==n||r==a||e.charCodeAt(r)!=s.charCodeAt(o))return 0;let l=Ou(n-r,a-o);for(let c=r,d=o;;){let u=c+l,m=d+l;if(u>n||m>a||e.slice(c,u)!=s.slice(d,m)){if(l==1)return c-r-(Mn(e,c)?0:1);l=l>>1}else{if(u==n||m==a)return u-r;c=u,d=m}}}function Si(e,r,n,s,o,a){if(r==n||o==a||e.charCodeAt(n-1)!=s.charCodeAt(a-1))return 0;let l=Ou(n-r,a-o);for(let c=n,d=a;;){let u=c-l,m=d-l;if(u<r||m<o||e.slice(u,c)!=s.slice(m,d)){if(l==1)return n-c-(Mn(e,c)?0:1);l=l>>1}else{if(u==r||m==o)return n-u;c=u,d=m}}}function Va(e,r,n,s,o,a,l,c){let d=s.slice(o,a),u=null;for(;;){if(u||l<c)return u;for(let m=r+l;;){Mn(e,m)||m++;let p=m+l;if(Mn(e,p)||(p+=p==m+1?1:-1),p>=n)break;let h=e.slice(m,p),g=-1;for(;(g=d.indexOf(h,g+1))!=-1;){let x=Ni(e,p,n,s,o+g+h.length,a),k=Si(e,r,m,s,o,o+g),w=h.length+x+k;(!u||u[2]<w)&&(u=[m-k,o+g-k,w])}m=p}if(c<0)return u;l=l>>1}}function Fu(e,r,n,s,o,a){let l=n-r,c=a-o;if(l<c){let d=Fu(s,o,a,e,r,n);return d&&[d[1],d[0],d[2]]}return l<4||c*2<l?null:Va(e,r,n,s,o,a,Math.floor(l/4),-1)}function ac(e,r,n,s,o,a){ji=!0;let l=n-r,c=a-o,d;if(l<c){let h=Va(s,o,a,e,r,n,Math.floor(l/6),50);d=h&&[h[1],h[0],h[2]]}else d=Va(e,r,n,s,o,a,Math.floor(c/6),50);if(!d)return[new Dt(r,n,o,a)];let[u,m,p]=d;return cn(e,r,u,s,o,m).concat(cn(e,u+p,n,s,m+p,a))}function $u(e,r){for(let n=1;n<e.length;n++){let s=e[n-1],o=e[n];s.toA>o.fromA-r&&s.toB>o.fromB-r&&(e[n-1]=new Dt(s.fromA,o.toA,s.fromB,o.toB),e.splice(n--,1))}}function Xv(e,r,n){for(;;){$u(n,1);let s=!1;for(let o=0;o<n.length;o++){let a=n[o],l,c;(l=Ni(e,a.fromA,a.toA,r,a.fromB,a.toB))&&(a=n[o]=new Dt(a.fromA+l,a.toA,a.fromB+l,a.toB)),(c=Si(e,a.fromA,a.toA,r,a.fromB,a.toB))&&(a=n[o]=new Dt(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 m=a.fromA-(o?n[o-1].toA:0),p=(o<n.length-1?n[o+1].fromA:e.length)-a.toA;if(!m||!p)continue;let h=d?e.slice(a.fromA,a.toA):r.slice(a.fromB,a.toB);m<=h.length&&e.slice(a.fromA-m,a.fromA)==h.slice(h.length-m)?(n[o]=new Dt(a.fromA-m,a.toA-m,a.fromB-m,a.toB-m),s=!0):p<=h.length&&e.slice(a.toA,a.toA+p)==h.slice(0,p)&&(n[o]=new Dt(a.fromA+p,a.toA+p,a.fromB+p,a.toB+p),s=!0)}if(!s)break}return n}function Qv(e,r,n){for(let s=0,o=0;o<e.length;o++){let a=e[o],l=a.toA-a.fromA,c=a.toB-a.fromB;if(l&&c||l>3||c>3){let d=o==e.length-1?r.length:e[o+1].fromA,u=a.fromA-s,m=d-a.toA,p=lc(r,a.fromA,u),h=ic(r,a.toA,m),g=a.fromA-p,x=h-a.toA;if((!l||!c)&&g&&x){let k=Math.max(l,c),[w,A,L]=l?[r,a.fromA,a.toA]:[n,a.fromB,a.toB];k>g&&r.slice(p,a.fromA)==w.slice(L-g,L)?(a=e[o]=new Dt(p,p+l,a.fromB-g,a.toB-g),p=a.fromA,h=ic(r,a.toA,d-a.toA)):k>x&&r.slice(a.toA,h)==w.slice(A,A+x)&&(a=e[o]=new Dt(h-l,h,a.fromB+x,a.toB+x),h=a.toA,p=lc(r,a.fromA,a.fromA-s)),g=a.fromA-p,x=h-a.toA}if(g||x)a=e[o]=new Dt(a.fromA-g,a.toA+x,a.fromB-g,a.toB+x);else if(l){if(!c){let k=dc(r,a.fromA,a.toA),w,A=k<0?-1:cc(r,a.toA,a.fromA);k>-1&&(w=k-a.fromA)<=m&&r.slice(a.fromA,k)==r.slice(a.toA,a.toA+w)?a=e[o]=a.offset(w):A>-1&&(w=a.toA-A)<=u&&r.slice(a.fromA-w,a.fromA)==r.slice(A,a.toA)&&(a=e[o]=a.offset(-w))}}else{let k=dc(n,a.fromB,a.toB),w,A=k<0?-1:cc(n,a.toB,a.fromB);k>-1&&(w=k-a.fromB)<=m&&n.slice(a.fromB,k)==n.slice(a.toB,a.toB+w)?a=e[o]=a.offset(w):A>-1&&(w=a.toB-A)<=u&&n.slice(a.fromB-w,a.fromB)==n.slice(A,a.toB)&&(a=e[o]=a.offset(-w))}}s=a.toA}return $u(e,3),e}let an;try{an=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function zu(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Bu(e,r){if(r==e.length)return 0;let n=e.charCodeAt(r);return n<192?zu(n)?1:0:an?!Hu(n)||r==e.length-1?an.test(String.fromCharCode(n))?1:0:an.test(e.slice(r,r+2))?2:0:0}function Wu(e,r){if(!r)return 0;let n=e.charCodeAt(r-1);return n<192?zu(n)?1:0:an?!Gu(n)||r==1?an.test(String.fromCharCode(n))?1:0:an.test(e.slice(r-2,r))?2:0:0}const Uu=8;function ic(e,r,n){if(r==e.length||!Wu(e,r))return r;for(let s=r,o=r+n,a=0;a<Uu;a++){let l=Bu(e,s);if(!l||s+l>o)return s;s+=l}return r}function lc(e,r,n){if(!r||!Bu(e,r))return r;for(let s=r,o=r-n,a=0;a<Uu;a++){let l=Wu(e,s);if(!l||s-l<o)return s;s-=l}return r}function cc(e,r,n){for(;r!=n;r--)if(e.charCodeAt(r-1)==10)return r;return-1}function dc(e,r,n){for(;r!=n;r++)if(e.charCodeAt(r)==10)return r;return-1}const Hu=e=>e>=55296&&e<=56319,Gu=e=>e>=56320&&e<=57343;function Mn(e,r){return!r||r==e.length||!Hu(e.charCodeAt(r-1))||!Gu(e.charCodeAt(r))}function Zv(e,r,n){var s;return Gn=((s=n?.scanLimit)!==null&&s!==void 0?s:1e9)>>1,qn=n?.timeout?Date.now()+n.timeout:0,ji=!1,Xv(e,r,cn(e,0,e.length,r,0,r.length))}function qu(){return!ji}function Ku(e,r,n){return Qv(Zv(e,r,n),e,r)}const Dr=to.define({combine:e=>e[0]}),eb=Ya.define(),Vu=to.define(),dr=Qn.define({create(e){return null},update(e,r){for(let n of r.effects)n.is(eb)&&(e=n.value);for(let n of r.state.facet(Vu))e=n(e,r);return e}});function xa(e){let r=e.field(dr,!1);if(!r)return null;let n=e.facet(Dr);return{chunks:r,side:n?n.side:null}}class En{constructor(r,n,s,o,a,l=!0){this.changes=r,this.fromA=n,this.toA=s,this.fromB=o,this.toB=a,this.precise=l}offset(r,n){return r||n?new En(this.changes,this.fromA+r,this.toA+r,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(r,n,s){let o=Ku(r.toString(),n.toString(),s);return Ju(o,r,n,0,0,qu())}static updateA(r,n,s,o,a){return hc(fc(r,o,!0,s.length),r,n,s,a)}static updateB(r,n,s,o,a){return hc(fc(r,o,!1,n.length),r,n,s,a)}}function uc(e,r,n,s){let o=n.lineAt(e),a=s.lineAt(r);return o.to==e&&a.to==r&&e<n.length&&r<s.length?[e+1,r+1]:[o.from,a.from]}function pc(e,r,n,s){let o=n.lineAt(e),a=s.lineAt(r);return o.from==e&&a.from==r?[e,r]:[o.to+1,a.to+1]}function Ju(e,r,n,s,o,a){let l=[];for(let c=0;c<e.length;c++){let d=e[c],[u,m]=uc(d.fromA+s,d.fromB+o,r,n),[p,h]=pc(d.toA+s,d.toB+o,r,n),g=[d.offset(-u+s,-m+o)];for(;c<e.length-1;){let x=e[c+1],[k,w]=uc(x.fromA+s,x.fromB+o,r,n);if(k>p+1&&w>h+1)break;g.push(x.offset(-u+s,-m+o)),[p,h]=pc(x.toA+s,x.toB+o,r,n),c++}l.push(new En(g,u,Math.max(u,p),m,Math.max(m,h),a))}return l}const zs=1e3;function mc(e,r,n,s){let o=0,a=e.length;for(;;){if(o==a){let m=0,p=0;o&&({toA:m,toB:p}=e[o-1]);let h=r-(n?m:p);return[m+h,p+h]}let l=o+a>>1,c=e[l],[d,u]=n?[c.fromA,c.toA]:[c.fromB,c.toB];if(d>r)a=l;else if(u<=r)o=l+1;else return s?[c.fromA,c.fromB]:[c.toA,c.toB]}}function fc(e,r,n,s){let o=[];return r.iterChangedRanges((a,l,c,d)=>{let u=0,m=n?r.length:s,p=0,h=n?s:r.length;a>zs&&([u,p]=mc(e,a-zs,n,!0)),l<r.length-zs&&([m,h]=mc(e,l+zs,n,!1));let g=d-c-(l-a),x,[k,w]=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:m,toB:h,diffA:x.diffA+k,diffB:x.diffB+w}:o.push({fromA:u,toA:m,fromB:p,toB:h,diffA:k,diffB:w})}),o}function hc(e,r,n,s,o){if(!e.length)return r;let a=[];for(let l=0,c=0,d=0,u=0;;l++){let m=l==e.length?null:e[l],p=m?m.fromA+c:n.length,h=m?m.fromB+d:s.length;for(;u<r.length;){let w=r[u];if(w.toA+c>p||w.toB+d>h)break;a.push(w.offset(c,d)),u++}if(!m)break;let g=m.toA+c+m.diffA,x=m.toB+d+m.diffB,k=Ku(n.sliceString(p,g),s.sliceString(h,x),o);for(let w of Ju(k,n,s,p,h,qu()))a.push(w);for(c+=m.diffA,d+=m.diffB;u<r.length;){let w=r[u];if(w.fromA+c>g&&w.fromB+d>x)break;u++}}return a}const tb={scanLimit:500},Yu=ro.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=yc(e))}update(e){(e.docChanged||e.viewportChanged||rb(e.startState,e.state)||nb(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=yc(e.view))}},{decorations:e=>e.deco});function rb(e,r){return e.field(dr,!1)!=r.field(dr,!1)}function nb(e,r){return e.facet(Dr)!=r.facet(Dr)}const gc=Rr.line({class:"cm-changedLine"}),Xu=Rr.mark({class:"cm-changedText"}),sb=Rr.mark({tagName:"ins",class:"cm-insertedLine"}),ob=Rr.mark({tagName:"del",class:"cm-deletedLine"}),xc=new class extends Xa{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function ab(e,r,n,s,o,a){let l=n?e.fromA:e.fromB,c=n?e.toA:e.toB,d=0;if(l!=c){o.add(l,l,gc),o.add(l,c,n?ob:sb),a&&a.add(l,l,xc);for(let u=r.iterRange(l,c-1),m=l;!u.next().done;){if(u.lineBreak){m++,o.add(m,m,gc),a&&a.add(m,m,xc);continue}let p=m+u.value.length;if(s)for(;d<e.changes.length;){let h=e.changes[d],g=l+(n?h.fromA:h.fromB),x=l+(n?h.toA:h.toB),k=Math.max(m,g),w=Math.min(p,x);if(k<w&&o.add(k,w,Xu),x<p)d++;else break}m=p}}}function yc(e){let r=e.state.field(dr),{side:n,highlightChanges:s,markGutter:o,overrideChunk:a}=e.state.facet(Dr),l=n=="a",c=new Ws,d=o?new Ws:null,{from:u,to:m}=e.viewport;for(let p of r){if((l?p.fromA:p.fromB)>=m)break;(l?p.toA:p.toB)>u&&(!a||!a(e.state,p,c,d))&&ab(p,e.state.doc,l,s,c,d)}return{deco:c.finish(),gutter:d&&d.finish()}}const Ja=Ya.define({map:(e,r)=>r.mapPos(e)});class ib extends Qa{constructor(r){super(),this.lines=r}eq(r){return this.lines==r.lines}toDOM(r){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=r.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",s=>{let o=r.posAtDOM(s.target);r.dispatch({effects:Ja.of(o)});let{side:a,sibling:l}=r.state.facet(Dr);l&&l().dispatch({effects:Ja.of(lb(o,r.state.field(dr),a=="a"))})}),n}ignoreEvent(r){return r instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function lb(e,r,n){let s=0,o=0;for(let a=0;;a++){let l=a<r.length?r[a]:null;if(!l||(n?l.fromA:l.fromB)>=e)return o+(e-s);[s,o]=n?[l.toA,l.toB]:[l.toB,l.toA]}}const cb=Qn.define({create(e){return Rr.none},update(e,r){e=e.map(r.changes);for(let n of r.effects)n.is(Ja)&&(e=e.update({filter:s=>s!=n.value}));return e},provide:e=>fr.decorations.from(e)});function db({margin:e=3,minSize:r=4}){return cb.init(n=>ub(n,e,r))}function ub(e,r,n){let s=new Ws,o=e.facet(Dr).side=="a",a=e.field(dr),l=1;for(let c=0;;c++){let d=c<a.length?a[c]:null,u=c?l+r:1,m=d?e.doc.lineAt(o?d.fromA:d.fromB).number-1-r:e.doc.lines,p=m-u+1;if(p>=n&&s.add(e.doc.line(u).from,e.doc.line(m).to,Rr.replace({widget:new ib(p),block:!0})),!d)break;l=e.doc.lineAt(Math.min(e.doc.length,o?d.toA:d.toB)).number}return s.finish()}const pb=fr.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"}}),mb=new class extends Xa{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},fb=_c.low(Xp({class:"cm-changeGutter",markers:e=>{var r;return((r=e.plugin(Yu))===null||r===void 0?void 0:r.gutter)||Zp.empty},widgetMarker:(e,r)=>r instanceof Qu?mb:null}));function hb(e){var r;let n=typeof e.original=="string"?Ac.of(e.original.split(/\r?\n/)):e.original,s=e.diffConfig||tb;return[_c.low(Yu),vb,pb,fr.editorAttributes.of({class:"cm-merge-b"}),Vu.of((o,a)=>{let l=a.effects.find(c=>c.is(Ci));return l&&(o=En.updateA(o,l.value.doc,a.startState.doc,l.value.changes,s)),a.docChanged&&(o=En.updateB(o,a.state.field(Dn),a.newDoc,a.changes,s)),o}),Dr.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(r=e.mergeControls)!==null&&r!==void 0?r:!0,overrideChunk:e.allowInlineDiffs?jb:void 0,side:"b"}),Dn.init(()=>n),e.gutter!==!1?fb:[],e.collapseUnchanged?db(e.collapseUnchanged):[],dr.init(o=>En.build(n,o.doc,s))]}const Ci=Ya.define(),Dn=Qn.define({create:()=>Ac.empty,update(e,r){for(let n of r.effects)n.is(Ci)&&(e=n.value.doc);return e}}),vc=new WeakMap;class Qu extends Qa{constructor(r){super(),this.buildDOM=r,this.dom=null}eq(r){return this.dom==r.dom}toDOM(r){return this.dom||(this.dom=this.buildDOM(r))}}function gb(e,r,n){let s=vc.get(r.changes);if(s)return s;let o=l=>{let{highlightChanges:c,syntaxHighlightDeletions:d,syntaxHighlightDeletionsMaxLength:u,mergeControls:m}=e.facet(Dr),p=document.createElement("div");if(p.className="cm-deletedChunk",m){let S=p.appendChild(document.createElement("div"));S.className="cm-chunkButtons";let D=I=>{I.preventDefault(),xb(l,l.posAtDOM(p))},b=I=>{I.preventDefault(),yb(l,l.posAtDOM(p))};if(typeof m=="function")S.appendChild(m("accept",D)),S.appendChild(m("reject",b));else{let I=S.appendChild(document.createElement("button"));I.name="accept",I.textContent=e.phrase("Accept"),I.onmousedown=D;let G=S.appendChild(document.createElement("button"));G.name="reject",G.textContent=e.phrase("Reject"),G.onmousedown=b}}if(n||r.fromA>=r.toA)return p;let h=l.state.field(Dn).sliceString(r.fromA,r.endA),g=d&&e.facet(Mc),x=L(),k=r.changes,w=0,A=!1;function L(){let S=p.appendChild(document.createElement("div"));return S.className="cm-deletedLine",S.appendChild(document.createElement("del"))}function j(S,D,b){for(let I=S;I<D;){if(h.charAt(I)==`
338
- `){x.firstChild||x.appendChild(document.createElement("br")),x=L(),I++;continue}let G=D,P=b+(A?" cm-deletedText":""),V=!1,ve=h.indexOf(`
339
- `,I);if(ve>-1&&ve<D&&(G=ve),c&&w<k.length){let ae=Math.max(0,A?k[w].toA:k[w].fromA);ae<=G&&(G=ae,A&&w++,V=!0)}if(G>I){let ae=document.createTextNode(h.slice(I,G));if(P){let R=x.appendChild(document.createElement("span"));R.className=P,R.appendChild(ae)}else x.appendChild(ae);I=G}V&&(A=!A)}}if(g&&r.toA-r.fromA<=u){let S=g.parser.parse(h),D=0;ba(S,{style:b=>Dc(e,b)},(b,I,G)=>{b>D&&j(D,b,""),j(b,I,G),D=I}),j(D,h.length,"")}else j(0,h.length,"");return x.firstChild||x.appendChild(document.createElement("br")),p},a=Rr.widget({block:!0,side:-1,widget:new Qu(o)});return vc.set(r.changes,a),a}function xb(e,r){let{state:n}=e,s=r??n.selection.main.head,o=e.state.field(dr).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)),l=e.state.field(Dn);o.fromB!=o.toB&&o.toA<=l.length&&(a+=e.state.lineBreak);let c=Qp.of({from:o.fromA,to:Math.min(l.length,o.toA),insert:a},l.length);return e.dispatch({effects:Ci.of({doc:c.apply(l),changes:c}),userEvent:"accept"}),!0}function yb(e,r){let{state:n}=e,s=r??n.selection.main.head,o=n.field(dr).find(c=>c.fromB<=s&&c.endB>=s);if(!o)return!1;let l=n.field(Dn).sliceString(o.fromA,Math.max(o.fromA,o.toA-1));return o.fromA!=o.toA&&o.toB<=n.doc.length&&(l+=n.lineBreak),e.dispatch({changes:{from:o.fromB,to:Math.min(n.doc.length,o.toB),insert:l},userEvent:"revert"}),!0}function bc(e){let r=new Ws;for(let n of e.field(dr)){let s=e.facet(Dr).overrideChunk&&Zu(e,n);r.add(n.fromB,n.fromB,gb(e,n,!!s))}return r.finish()}const vb=Qn.define({create:e=>bc(e),update(e,r){return r.state.field(dr,!1)!=r.startState.field(dr,!1)?bc(r.state):e},provide:e=>fr.decorations.from(e)}),wc=new WeakMap;function Zu(e,r){let n=wc.get(r);if(n!==void 0)return n;n=null;let s=e.field(Dn),o=e.doc,a=s.lineAt(r.endA).number-s.lineAt(r.fromA).number+1,l=o.lineAt(r.endB).number-o.lineAt(r.fromB).number+1;e:if(a==l&&a<10){let c=[],d=0,u=r.fromA,m=r.fromB;for(let p of r.changes){if(p.fromA<p.toA){d+=p.toA-p.fromA;let h=s.sliceString(u+p.fromA,u+p.toA);if(/\n/.test(h))break e;c.push(Rr.widget({widget:new bb(h),side:-1}).range(m+p.fromB))}p.fromB<p.toB&&c.push(Xu.range(m+p.fromB,m+p.toB))}d<r.endA-r.fromA-a*2&&(n=c)}return wc.set(r,n),n}class bb extends Qa{constructor(r){super(),this.text=r}eq(r){return this.text==r.text}toDOM(r){let n=document.createElement("del");return n.className="cm-deletedText",n.textContent=this.text,n}}const wb=new class extends Xa{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},kb=Rr.line({class:"cm-inlineChangedLine"});function jb(e,r,n,s){let o=Zu(e,r),a=0;if(!o)return!1;for(let l=e.doc.lineAt(r.fromB);;){for(s&&s.add(l.from,l.from,wb),n.add(l.from,l.from,kb);a<o.length&&o[a].to<=l.to;){let c=o[a++];n.add(c.from,c.to,c.value)}if(l.to>=r.endB)break;l=e.doc.lineAt(l.to+1)}return!0}var Nb=function(e,r){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&r.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++)r.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(n[s[o]]=e[s[o]]);return n};const qt=to.define({combine:e=>{const r=[];for(let n of e){if(!n)continue;const{create:s,gutters:o}=n,a=Nb(n,["create","gutters"]);r.push(Object.assign(Object.assign({},a),{enabled:!0,gutters:o?o.filter(l=>Object.keys(l).length>0):void 0}))}return em(r,{enabled:r.length>0,displayText:"characters",eventHandlers:{},showOverlay:"always",gutters:[]})}}),Zt={PixelMultiplier:2,SizeRatio:4,MaxWidth:120},Sb=fr.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"}}}}),Gr=Zt.PixelMultiplier*Zt.SizeRatio,Cb=ro.fromClass(class{constructor(e){this.view=e,this._isDragging=!1,e.state.facet(qt).enabled&&this.create(e)}create(e){this.container=In("div",{class:"cm-minimap-overlay-container"}),this.dom=In("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 r=e.dom.querySelector(".cm-minimap-inner");r&&r.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 r=e.startState.facet(qt).enabled,n=e.state.facet(qt).enabled;if(r&&!n){this.remove();return}!r&&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/Gr;this.dom.style.height=e+"px"}computeTop(){if(!this._isDragging&&this.dom){const{clientHeight:e,scrollHeight:r,scrollTop:n}=this.view.scrollDOM,s=r-e,o=n/Gr,a=e/Gr,l=e-a;let c=n/s;isNaN(c)&&(c=0);const d=l*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:r,scrollHeight:n}=this.view.scrollDOM;r===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:r,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,l=n.getBoundingClientRect().top,c=(r-l)*Gr,d=a/(o-s),m=(s*Gr-s)*d,p=Math.max(0,a-m);this.view.scrollDOM.scrollTop=p+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 r=e.clientY-this._dragStartY,n=r<0,s=r>0;this._dragStartY=e.clientY;const o=this.dom.getBoundingClientRect().height,a=this.dom.getBoundingClientRect().y,l=a+o,c=parseFloat(this.dom.style.top),d=this.view.scrollDOM.scrollTop,u=this.view.scrollDOM.clientHeight,m=this.view.scrollDOM.scrollHeight,p=d===0,h=Math.round(d)>=Math.round(m-u);if(p&&n||p&&e.clientY<a||h&&s||h&&e.clientY>l)return;const g=this.view.scrollDOM.scrollHeight,x=this.view.scrollDOM.clientHeight,k=(g-x)/Gr,w=x-x/Gr,A=c+r,L=A/w,j=(g-x)*L,S=A*Gr;this.view.scrollDOM.scrollTop=Math.max(j,S);const D=Math.min(Math.max(0,A),Math.min(w,k));this.dom.style.top=D+"px"}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.computeTop())}}}),Eb=[Sb,Cb];class Ei{constructor(r){this.map=new Map,this.view=r}get(r){return this.map.get(r)}set(r,n){this.map.set(r,n)}}function kc(e){var r;if(!e.facet(qt).enabled)return[];const n=[],s=e.doc.iterLines(),o=tm(e).iter();let a=0;for(s.next();!s.done;){const l=s.value;let c=a,d=c+l.length;for(;o.value&&o.to<c;)o.next();const{from:u,to:m}=o,p=c>=u&&c<m,h=d>u&&d<=m;if(p){let g=(r=n.pop())!==null&&r!==void 0?r:[],x=g.pop();x&&x.folded&&(x.to=m),x&&g.push(x),(!x||!x.folded)&&g.push({from:u,to:m,folded:!0}),h||g.push({from:m,to:d,folded:!1}),n.push(g)}else h?n.push([{from:c,to:u,folded:!1},{from:u,to:m,folded:!0}]):n.push([{from:c,to:d,folded:!1}]);a=d+1,s.next()}return n}const Rn=Qn.define({create:e=>kc(e),update:(e,r)=>xo([r])||r.docChanged?kc(r.state):e});function xo(e){return e.find(r=>r.effects.find(n=>n.is(rm)||n.is(nm)))}class Ib extends Ei{constructor(r){super(r),this.count=void 0}shouldUpdate(r){if(!r.state.facet(qt).enabled)return!1;if(r.docChanged)return!0;for(const n of r.transactions)for(const s of n.effects)if(s.is(sm))return!0;return!!(xo(r.transactions)||this.count===void 0)}update(r){if(!this.shouldUpdate(r))return;this.map.clear();const n=r.state.field(Rn);this.count=om(r.state),am(r.state,(s,o,a)=>{const l=this.findLine(o,n),c=this.findLine(a,n);let d=s.severity;for(let u=l;u<=c;u++){const m=this.get(u);m&&(d=[d,m].sort(this.sort.bind(this)).slice(0,1)[0]),this.set(u,d)}})}drawLine(r,n){const{context:s,lineHeight:o,offsetX:a,offsetY:l}=r,c=this.get(n);c&&(s.globalAlpha=.65,s.beginPath(),s.rect(a,l,s.canvas.width-a,o),s.fillStyle=this.color(c),s.fill())}findLine(r,n){return n.findIndex(o=>{const a=o.slice(0,1)[0],l=o.slice(-1)[0];return!a||!l?!1:a.from<=r&&r<=l.to})+1}color(r){return r==="error"?"#d11":r==="warning"?"orange":"#999"}sort(r,n){return this.score(n)-this.score(r)}score(r){switch(r){case"error":return 3;case"warning":return 2;default:return 1}}}function Tb(e){return new Ib(e)}class Ab extends Ei{constructor(r){super(r),this.getDrawInfo(),this._themeClasses=r.dom.classList.value}shouldUpdate(r){return r.state.facet(qt).enabled?!!(r.docChanged||r.selectionSet||this._themeClasses!==this.view.dom.classList.value||xo(r.transactions)):!1}update(r){if(!this.shouldUpdate(r))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}=r.state.selection;let s=0;for(const[o,a]of r.state.field(Rn).entries()){const l=[];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 m=n[s],p={from:c+Math.max(u.from,m.from)-u.from,to:c+Math.min(u.to,m.to)-u.from,extends:m.to>u.to},h=l.slice(-1)[0];if(h&&h.to===p.from){let{to:g}=p;u.folded&&p.extends?g=p.from+1:u.folded&&!p.extends&&(g=h.to),l[l.length-1]=Object.assign(Object.assign({},h),{to:g,extends:p.extends})}else u.folded||l.push(p);if(p.extends)break;s++}while(s<n.length&&u.to>=n[s].from);c+=u.folded?1:u.to-u.from}if(l.length===0)continue;const d=o+1;this.map.set(d,l)}}drawLine(r,n){let{context:s,lineHeight:o,charWidth:a,offsetX:l,offsetY:c}=r;const d=this.get(n);if(d)for(const u of d){const m=l+u.from*a,p=(u.to-u.from)*a,h=s.canvas.width-m;u.extends&&(s.globalAlpha=.65,s.beginPath(),s.rect(m,c,h,o),s.fillStyle=this.getDrawInfo().backgroundColor,s.fill()),s.globalAlpha=1,s.beginPath(),s.rect(m,c,p,o),s.fillStyle=this.getDrawInfo().backgroundColor,s.fill()}}getDrawInfo(){if(this._drawInfo)return this._drawInfo;const r=document.createElement("span");r.setAttribute("class","cm-selectionBackground"),this.view.dom.appendChild(r);const s={backgroundColor:window.getComputedStyle(r).backgroundColor};return this._drawInfo=s,this.view.dom.removeChild(r),s}}function _b(e){return new Ab(e)}class Mb extends Ei{constructor(r){super(r),this._fontInfoMap=new Map,this._themeClasses=new Set(r.dom.classList.values()),r.state.facet(qt).enabled&&this.updateImpl(r.state)}shouldUpdate(r){return!!(r.docChanged||r.state.facet(qt)!==r.startState.facet(qt)||this.themeChanged()||xo(r.transactions))}update(r){this.shouldUpdate(r)&&(this._highlightingCallbackId&&(typeof window.requestIdleCallback<"u"?cancelIdleCallback(this._highlightingCallbackId):clearTimeout(this._highlightingCallbackId)),this.updateImpl(r.state,r.changes))}updateImpl(r,n){var s;this.map.clear(),this._displayText=r.facet(qt).displayText,this.themeChanged()&&this._fontInfoMap.clear();let o;if(this._previousTree&&n){const p=cl.addTree(this._previousTree),h=[];n.iterChangedRanges((g,x,k,w)=>h.push({fromA:g,toA:x,fromB:k,toB:w})),o=cl.applyChanges(p,h)}const a=r.doc.toString(),l=(s=r.facet(Mc))===null||s===void 0?void 0:s.parser,c=l?l.parse(a,o):void 0;this._previousTree=c;const d={style:p=>Dc(r,p)};let u=[];if(c){const p=r.doc.lineAt(this.view.viewport.from).number,h=r.doc.lineAt(this.view.viewport.to).number,g=h-p,x=p/(r.doc.lines-g),{SizeRatio:k,PixelMultiplier:w}=Zt,A=g*k*w,L=x*A,j=Math.max(1,Math.floor(p-L)),S=Math.min(h+Math.floor(A-L),r.doc.lines);ba(c,d,(D,b,I)=>{u.push({from:D,to:b,tags:I})},r.doc.line(j).from,r.doc.line(S).to)}this.updateMapImpl(r,u),u=[];const m=()=>{c&&(ba(c,d,(p,h,g)=>{u.push({from:p,to:h,tags:g})}),this.updateMapImpl(r,u),this._highlightingCallbackId=void 0)};this._highlightingCallbackId=typeof window.requestIdleCallback<"u"?requestIdleCallback(m):setTimeout(m)}updateMapImpl(r,n){this.map.clear();const s=r.doc.toString(),o=n.values();let a=o.next();for(const[l,c]of r.field(Rn).entries()){const d=[];for(const m of c){if(m.from===m.to)continue;if(m.folded){d.push({text:"…",tags:""});continue}let p=m.from;for(;!a.done&&a.value.from<m.to;){const{from:h,to:g,tags:x}=a.value;if(g<p){a=o.next();continue}h>p&&d.push({text:s.slice(p,h),tags:""});const k=Math.max(h,m.from),w=Math.min(g,m.to);if(d.push({text:s.slice(k,w),tags:x}),p=w,g>w)break;a=o.next()}p!==m.to&&d.push({text:s.slice(p,m.to),tags:""})}const u=l+1;this.map.set(u,d)}}measure(r){const{color:n,font:s,lineHeight:o}=this.getFontInfo("");return r.textBaseline="ideographic",r.fillStyle=n,r.font=s,{charWidth:r.measureText("_").width,lineHeight:o}}beforeDraw(){this._fontInfoMap.clear()}drawLine(r,n){const s=this.get(n);if(!s)return;let{context:o,charWidth:a,lineHeight:l,offsetX:c,offsetY:d}=r,u;o.textBaseline="ideographic";for(const m of s){const p=this.getFontInfo(m.tags);switch((!u||u.color!==p.color)&&(o.fillStyle=p.color),(!u||u.font!==p.font)&&(o.font=p.font),u=p,l=Math.max(l,p.lineHeight),this._displayText){case"characters":{o.fillText(m.text,c,d+l),c+=m.text.length*a;break}case"blocks":{const h=/\S+/g;let g;for(;(g=h.exec(m.text))!==null;){const x=c+g.index*a;let k=(h.lastIndex-g.index)*a;if(x>o.canvas.width)break;x+k>o.canvas.width&&(k=o.canvas.width-x);const w=2/Zt.SizeRatio,A=l-w;o.fillStyle=p.color,o.globalAlpha=.65,o.beginPath(),o.rect(x,d,k,A),o.fill()}c+=m.text.length*a;break}}}}getFontInfo(r){const n=this._fontInfoMap.get(r);if(n)return n;const s=In("span",{class:r}),o=In("div",{class:"cm-line",style:"display: none"},s);this.view.contentDOM.appendChild(o);const a=window.getComputedStyle(s),l=parseFloat(a.lineHeight)/Zt.SizeRatio,c={color:a.color,font:`${a.fontStyle} ${a.fontWeight} ${l}px ${a.fontFamily}`,lineHeight:l};return this._fontInfoMap.set(r,c),this.view.contentDOM.removeChild(o),c}themeChanged(){const r=this._themeClasses,n=new Set(this.view.dom.classList.values());if(this._themeClasses=n,!r||(r.delete("cm-focused"),n.delete("cm-focused"),r.size!==n.size))return!0;let s=!0;return r.forEach(o=>{n.has(o)||(s=!1)}),!s}}function Db(e){return new Mb(e)}const ep=4;function Rb(e,r,n){const s=e[n];s&&(r.context.fillStyle=s,r.context.globalAlpha=1,r.context.beginPath(),r.context.rect(r.offsetX,r.offsetY,ep,r.lineHeight),r.context.fill())}const Pb=fr.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"}}),jc=6,Lb=ro.fromClass(class{constructor(e){this.view=e,this.text=Db(e),this.selection=_b(e),this.diagnostic=Tb(e),e.state.facet(Kn)&&this.create(e)}create(e){const r=e.state.facet(Kn);if(!r)throw Error("Expected nonnull");this.inner=In("div",{class:"cm-minimap-inner"}),this.canvas=In("canvas"),this.dom=r.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 r=e.startState.facet(Kn),n=e.state.facet(Kn);if(r&&!n){this.remove();return}!r&&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<=Zt.MaxWidth*jc){const r=e/(Zt.MaxWidth*jc);return Zt.MaxWidth*r}return Zt.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()*Zt.PixelMultiplier;const e=this.view.dom.getBoundingClientRect().height;this.inner.style.minHeight=e+"px",this.canvas.height=e*Zt.PixelMultiplier,this.canvas.style.height=e+"px";const r=this.canvas.getContext("2d");if(!r)return;r.clearRect(0,0,this.canvas.width,this.canvas.height);const{charWidth:n,lineHeight:s}=this.text.measure(r);let{startIndex:o,endIndex:a,offsetY:l}=this.canvasStartAndEndIndex(r,s);const c=this.view.state.facet(qt).gutters;for(let d=o;d<a;d++){const u=this.view.state.field(Rn);if(d>=u.length)break;const m={offsetX:0,offsetY:l,context:r,lineHeight:s,charWidth:n};if(c.length){m.offsetX+=2;for(let p of c)Rb(p,m,d+1),m.offsetX+=ep;m.offsetX+=2}this.text.drawLine(m,d+1),this.selection.drawLine(m,d+1),this.diagnostic.drawLine(m,d+1),l+=s}r.restore()}canvasStartAndEndIndex(e,r){let{top:n,bottom:s}=this.view.documentPadding;n/=Zt.SizeRatio,s/=Zt.SizeRatio;const o=e.canvas.height,{clientHeight:a,scrollHeight:l,scrollTop:c}=this.view.scrollDOM;let d=c/(l-a);isNaN(d)&&(d=0);const u=this.view.state.field(Rn).length,m=n+s+u*r,p=Math.max(0,d*(m-o)),h=Math.max(0,n-p),g=Math.round(Math.max(0,p-n)/r),x=Math.round((o-h)/r);return{startIndex:g,endIndex:g+x,offsetY:h}}updateBoxShadow(){if(!this.canvas)return;const{clientWidth:e,scrollWidth:r,scrollLeft:n}=this.view.scrollDOM;e+n<r?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=>fr.scrollMargins.of(r=>{var n;const s=(n=r.plugin(e))===null||n===void 0?void 0:n.getWidth();return s?{right:s}:null})}),Kn=to.define({combine:e=>{var r;return(r=e.find(n=>n!==null))!==null&&r!==void 0?r:null},enables:e=>[[qt.compute([e],r=>r.facet(e)),Pb,Rn,Lb,Eb]]});function Nc({file:e,onClose:r,projectPath:n,isSidebar:s=!1,isExpanded:o=!1,onToggleExpand:a=null}){const{t:l}=Lt("codeEditor"),[c,d]=i.useState(""),[u,m]=i.useState(!0),[p,h]=i.useState(!1),[g,x]=i.useState(!1),[k,w]=i.useState(()=>{const _=localStorage.getItem("codeEditorTheme");return _?_==="dark":!0}),[A,L]=i.useState(!1),[j,S]=i.useState(!!e.diffInfo),[D,b]=i.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[I,G]=i.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[P,V]=i.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[ve,ae]=i.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),R=i.useRef(null),q=i.useMemo(()=>{if(!e.diffInfo||!j||!I)return[];const _={};return[Kn.compute(["doc"],N=>{const ne=xa(N)?.chunks||[];return Object.keys(_).forEach(Ce=>delete _[Ce]),ne.forEach(Ce=>{const be=N.doc.lineAt(Ce.fromB).number,re=N.doc.lineAt(Math.min(Ce.toB,N.doc.length)).number;for(let Ee=be;Ee<=re;Ee++)_[Ee]=k?"rgba(34, 197, 94, 0.8)":"rgba(34, 197, 94, 1)"}),{create:()=>({dom:document.createElement("div")}),displayText:"blocks",showOverlay:"always",gutters:[_]}})]},[e.diffInfo,j,I,k]),de=i.useMemo(()=>!e.diffInfo||!j?[]:[ro.fromClass(class{constructor(_){setTimeout(()=>{const O=xa(_.state)?.chunks||[];if(O.length>0){const ne=O[0];_.dispatch({effects:fr.scrollIntoView(ne.fromB,{y:"center"})})}},100)}update(){}destroy(){}})],[e.diffInfo,j]),se=i.useMemo(()=>{const _=N=>{const O=document.createElement("div");O.className="cm-editor-toolbar-panel";let ne=0;const Ce=()=>{const be=e.diffInfo&&j,Ee=(be?xa(N.state):null)?.chunks||[],nt=Ee.length;let De='<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';if(De+='<div style="display: flex; align-items: center; gap: 8px;">',be&&(De+=`
340
- <span style="font-weight: 500;">${nt>0?`${ne+1}/${nt}`:"0"} ${l("toolbar.changes")}</span>
341
- <button class="cm-diff-nav-btn cm-diff-nav-prev" title="${l("toolbar.previousChange")}" ${nt===0?"disabled":""}>
342
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
343
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
344
- </svg>
345
- </button>
346
- <button class="cm-diff-nav-btn cm-diff-nav-next" title="${l("toolbar.nextChange")}" ${nt===0?"disabled":""}>
347
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
348
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
349
- </svg>
350
- </button>
351
- `),De+="</div>",De+='<div style="display: flex; align-items: center; gap: 4px;">',e.diffInfo&&(De+=`
352
- <button class="cm-toolbar-btn cm-toggle-diff-btn" title="${l(j?"toolbar.hideDiff":"toolbar.showDiff")}">
353
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
354
- ${j?'<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" />'}
355
- </svg>
356
- </button>
357
- `),De+=`
358
- <button class="cm-toolbar-btn cm-settings-btn" title="${l("toolbar.settings")}">
359
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
360
- <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" />
361
- </svg>
362
- </button>
363
- `,s&&a&&(De+=`
364
- <button class="cm-toolbar-btn cm-expand-btn" title="${l(o?"toolbar.collapse":"toolbar.expand")}">
365
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
366
- ${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" />'}
367
- </svg>
368
- </button>
369
- `),De+="</div>",De+="</div>",O.innerHTML=De,be){const Ge=O.querySelector(".cm-diff-nav-prev"),bt=O.querySelector(".cm-diff-nav-next");Ge?.addEventListener("click",()=>{if(Ee.length===0)return;ne=ne>0?ne-1:Ee.length-1;const st=Ee[ne];st&&N.dispatch({effects:fr.scrollIntoView(st.fromB,{y:"center"})}),Ce()}),bt?.addEventListener("click",()=>{if(Ee.length===0)return;ne=ne<Ee.length-1?ne+1:0;const st=Ee[ne];st&&N.dispatch({effects:fr.scrollIntoView(st.fromB,{y:"center"})}),Ce()})}e.diffInfo&&O.querySelector(".cm-toggle-diff-btn")?.addEventListener("click",()=>{S(!j)}),O.querySelector(".cm-settings-btn")?.addEventListener("click",()=>{window.openSettings&&window.openSettings("appearance")}),s&&a&&O.querySelector(".cm-expand-btn")?.addEventListener("click",()=>{a()})};return Ce(),{top:!0,dom:O,update:Ce}};return[im.of(_)]},[e.diffInfo,j,s,o,a]),he=_=>{const N=_.split(".").pop()?.toLowerCase();switch(N){case"js":case"jsx":case"ts":case"tsx":return[hm({jsx:!0,typescript:N.includes("ts")})];case"py":return[fm()];case"html":case"htm":return[mm()];case"css":case"scss":case"less":return[pm()];case"json":return[um()];case"md":case"markdown":return[dm()];default:return[]}};i.useEffect(()=>{(async()=>{try{if(m(!0),e.diffInfo&&e.diffInfo.new_string!==void 0&&e.diffInfo.old_string!==void 0){d(e.diffInfo.new_string),m(!1);return}const N=await pt.readFile(e.projectName,e.path);if(!N.ok)throw new Error(`Failed to load file: ${N.status} ${N.statusText}`);const O=await N.json();d(O.content)}catch(N){console.error("Error loading file:",N),d(`// Error loading file: ${N.message}
370
- // File: ${e.name}
371
- // Path: ${e.path}`)}finally{m(!1)}})()},[e,n]);const Se=async()=>{h(!0);try{console.log("Saving file:",{projectName:e.projectName,path:e.path,contentLength:c?.length});const _=await pt.saveFile(e.projectName,e.path,c);if(console.log("Save response:",{status:_.status,ok:_.ok,contentType:_.headers.get("content-type")}),!_.ok){const O=_.headers.get("content-type");if(O&&O.includes("application/json")){const ne=await _.json();throw new Error(ne.error||`Save failed: ${_.status}`)}else{const ne=await _.text();throw console.error("Non-JSON error response:",ne),new Error(`Save failed: ${_.status} ${_.statusText}`)}}const N=await _.json();console.log("Save successful:",N),L(!0),setTimeout(()=>L(!1),2e3)}catch(_){console.error("Error saving file:",_),alert(`Error saving file: ${_.message}`)}finally{h(!1)}},B=()=>{const _=new Blob([c],{type:"text/plain"}),N=URL.createObjectURL(_),O=document.createElement("a");O.href=N,O.download=e.name,document.body.appendChild(O),O.click(),document.body.removeChild(O),URL.revokeObjectURL(N)},z=()=>{x(!g)};return i.useEffect(()=>{localStorage.setItem("codeEditorTheme",k?"dark":"light")},[k]),i.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",D.toString())},[D]),i.useEffect(()=>{const _=()=>{const N=localStorage.getItem("codeEditorTheme");N&&w(N==="dark");const O=localStorage.getItem("codeEditorWordWrap");O!==null&&b(O==="true");const ne=localStorage.getItem("codeEditorShowMinimap");ne!==null&&G(ne!=="false");const Ce=localStorage.getItem("codeEditorLineNumbers");Ce!==null&&V(Ce!=="false");const be=localStorage.getItem("codeEditorFontSize");be&&ae(be)};return window.addEventListener("storage",_),window.addEventListener("codeEditorSettingsChanged",_),()=>{window.removeEventListener("storage",_),window.removeEventListener("codeEditorSettingsChanged",_)}},[]),i.useEffect(()=>{const _=N=>{(N.ctrlKey||N.metaKey)&&(N.key==="s"?(N.preventDefault(),Se()):N.key==="Escape"&&(N.preventDefault(),r()))};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[c]),u?t.jsxs(t.Fragment,{children:[t.jsx("style",{children:`
372
- .code-editor-loading {
373
- background-color: ${k?"#111827":"#ffffff"} !important;
374
- }
375
- .code-editor-loading:hover {
376
- background-color: ${k?"#111827":"#ffffff"} !important;
377
- }
378
- `}),s?t.jsx("div",{className:"w-full h-full flex items-center justify-center bg-background",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"}),t.jsx("span",{className:"text-gray-900 dark:text-white",children:l("loading",{fileName:e.name})})]})}):t.jsx("div",{className:"fixed inset-0 z-40 md:bg-black/50 md:flex md:items-center md:justify-center",children:t.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:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"}),t.jsx("span",{className:"text-gray-900 dark:text-white",children:l("loading",{fileName:e.name})})]})})})]}):t.jsxs(t.Fragment,{children:[t.jsx("style",{children:`
379
- /* Light background for full line changes */
380
- .cm-deletedChunk {
381
- background-color: ${k?"rgba(239, 68, 68, 0.15)":"rgba(255, 235, 235, 1)"} !important;
382
- border-left: 3px solid ${k?"rgba(239, 68, 68, 0.6)":"rgb(239, 68, 68)"} !important;
383
- padding-left: 4px !important;
384
- }
385
-
386
- .cm-insertedChunk {
387
- background-color: ${k?"rgba(34, 197, 94, 0.15)":"rgba(230, 255, 237, 1)"} !important;
388
- border-left: 3px solid ${k?"rgba(34, 197, 94, 0.6)":"rgb(34, 197, 94)"} !important;
389
- padding-left: 4px !important;
390
- }
391
-
392
- /* Override linear-gradient underline and use solid darker background for partial changes */
393
- .cm-editor.cm-merge-b .cm-changedText {
394
- background: ${k?"rgba(34, 197, 94, 0.4)":"rgba(34, 197, 94, 0.3)"} !important;
395
- padding-top: 2px !important;
396
- padding-bottom: 2px !important;
397
- margin-top: -2px !important;
398
- margin-bottom: -2px !important;
399
- }
400
-
401
- .cm-editor .cm-deletedChunk .cm-changedText {
402
- background: ${k?"rgba(239, 68, 68, 0.4)":"rgba(239, 68, 68, 0.3)"} !important;
403
- padding-top: 2px !important;
404
- padding-bottom: 2px !important;
405
- margin-top: -2px !important;
406
- margin-bottom: -2px !important;
407
- }
408
-
409
- /* Minimap gutter styling */
410
- .cm-gutter.cm-gutter-minimap {
411
- background-color: ${k?"#1e1e1e":"#f5f5f5"};
412
- }
413
-
414
- /* Editor toolbar panel styling */
415
- .cm-editor-toolbar-panel {
416
- padding: 8px 12px;
417
- background-color: ${k?"#1f2937":"#ffffff"};
418
- border-bottom: 1px solid ${k?"#374151":"#e5e7eb"};
419
- color: ${k?"#d1d5db":"#374151"};
420
- font-size: 14px;
421
- }
422
-
423
- .cm-diff-nav-btn,
424
- .cm-toolbar-btn {
425
- padding: 4px;
426
- background: transparent;
427
- border: none;
428
- cursor: pointer;
429
- border-radius: 4px;
430
- display: inline-flex;
431
- align-items: center;
432
- justify-content: center;
433
- color: inherit;
434
- transition: background-color 0.2s;
435
- }
436
-
437
- .cm-diff-nav-btn:hover,
438
- .cm-toolbar-btn:hover {
439
- background-color: ${k?"#374151":"#f3f4f6"};
440
- }
441
-
442
- .cm-diff-nav-btn:disabled {
443
- opacity: 0.5;
444
- cursor: not-allowed;
445
- }
446
- `}),t.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:t.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:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border flex-shrink-0 min-w-0",children:[t.jsx("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("h3",{className:"font-medium text-gray-900 dark:text-white truncate",children:e.name}),e.diffInfo&&t.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:l("header.showingChanges")})]}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 truncate",children:e.path})]})}),t.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[t.jsx("button",{onClick:B,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:l("actions.download"),children:t.jsx(ka,{className:"w-5 h-5 md:w-4 md:h-4"})}),t.jsx("button",{onClick:Se,disabled:p,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?t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),t.jsx("span",{className:"hidden sm:inline",children:l("actions.saved")})]}):t.jsxs(t.Fragment,{children:[t.jsx(Zf,{className:"w-5 h-5 md:w-4 md:h-4"}),t.jsx("span",{className:"hidden sm:inline",children:l(p?"actions.saving":"actions.save")})]})}),!s&&t.jsx("button",{onClick:z,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:l(g?"actions.exitFullscreen":"actions.fullscreen"),children:g?t.jsx(qf,{className:"w-4 h-4"}):t.jsx(Bc,{className:"w-4 h-4"})}),t.jsx("button",{onClick:r,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:l("actions.close"),children:t.jsx(lr,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(lm,{ref:R,value:c,onChange:d,extensions:[...he(e.name),...se,...e.diffInfo&&j&&e.diffInfo.old_string!==void 0?[hb({original:e.diffInfo.old_string,mergeControls:!1,highlightChanges:!0,syntaxHighlightDeletions:!1,gutter:!0}),...q,...de]:[],...D?[fr.lineWrapping]:[]],theme:k?cm:void 0,height:"100%",style:{fontSize:`${ve}px`,height:"100%"},basicSetup:{lineNumbers:P,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),t.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-border bg-muted flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[t.jsxs("span",{children:[l("footer.lines")," ",c.split(`
447
- `).length]}),t.jsxs("span",{children:[l("footer.characters")," ",c.length]})]}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:l("footer.shortcuts")})]})]})})]})}var Ob=ef(),Fb=tf(),$b=rf(),ya={exports:{}},Sc;function zb(){return Sc||(Sc=1,function(e,r){(function(n,s){e.exports=s()})(self,()=>(()=>{var n={6:(l,c)=>{function d(m){try{const p=new URL(m),h=p.password&&p.username?`${p.protocol}//${p.username}:${p.password}@${p.host}`:p.username?`${p.protocol}//${p.username}@${p.host}`:`${p.protocol}//${p.host}`;return m.toLocaleLowerCase().startsWith(h.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(c,"__esModule",{value:!0}),c.LinkComputer=c.WebLinkProvider=void 0,c.WebLinkProvider=class{constructor(m,p,h,g={}){this._terminal=m,this._regex=p,this._handler=h,this._options=g}provideLinks(m,p){const h=u.computeLink(m,this._regex,this._terminal,this._handler);p(this._addCallbacks(h))}_addCallbacks(m){return m.map(p=>(p.leave=this._options.leave,p.hover=(h,g)=>{if(this._options.hover){const{range:x}=p;this._options.hover(h,g,x)}},p))}};class u{static computeLink(p,h,g,x){const k=new RegExp(h.source,(h.flags||"")+"g"),[w,A]=u._getWindowedLineStrings(p-1,g),L=w.join("");let j;const S=[];for(;j=k.exec(L);){const D=j[0];if(!d(D))continue;const[b,I]=u._mapStrIdx(g,A,0,j.index),[G,P]=u._mapStrIdx(g,b,I,D.length);if(b===-1||I===-1||G===-1||P===-1)continue;const V={start:{x:I+1,y:b+1},end:{x:P,y:G+1}};S.push({range:V,text:D,activate:x})}return S}static _getWindowedLineStrings(p,h){let g,x=p,k=p,w=0,A="";const L=[];if(g=h.buffer.active.getLine(p)){const j=g.translateToString(!0);if(g.isWrapped&&j[0]!==" "){for(w=0;(g=h.buffer.active.getLine(--x))&&w<2048&&(A=g.translateToString(!0),w+=A.length,L.push(A),g.isWrapped&&A.indexOf(" ")===-1););L.reverse()}for(L.push(j),w=0;(g=h.buffer.active.getLine(++k))&&g.isWrapped&&w<2048&&(A=g.translateToString(!0),w+=A.length,L.push(A),A.indexOf(" ")===-1););}return[L,x]}static _mapStrIdx(p,h,g,x){const k=p.buffer.active,w=k.getNullCell();let A=g;for(;x;){const L=k.getLine(h);if(!L)return[-1,-1];for(let j=A;j<L.length;++j){L.getCell(j,w);const S=w.getChars();if(w.getWidth()&&(x-=S.length||1,j===L.length-1&&S==="")){const D=k.getLine(h+1);D&&D.isWrapped&&(D.getCell(0,w),w.getWidth()===2&&(x+=1))}if(x<0)return[h,j]}h++,A=0}return[h,A]}}c.LinkComputer=u}},s={};function o(l){var c=s[l];if(c!==void 0)return c.exports;var d=s[l]={exports:{}};return n[l](d,d.exports,o),d.exports}var a={};return(()=>{var l=a;Object.defineProperty(l,"__esModule",{value:!0}),l.WebLinksAddon=void 0;const c=o(6),d=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function u(m,p){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=p}else console.warn("Opening link blocked as opener could not be cleared")}l.WebLinksAddon=class{constructor(m=u,p={}){this._handler=m,this._options=p}activate(m){this._terminal=m;const p=this._options,h=p.urlRegex||d;this._linkProvider=this._terminal.registerLinkProvider(new c.WebLinkProvider(this._terminal,h,this._handler,p))}dispose(){this._linkProvider?.dispose()}}})(),a})())}(ya)),ya.exports}var Bb=zb();const Wb=`
448
- .xterm .xterm-screen {
449
- outline: none !important;
450
- }
451
- .xterm:focus .xterm-screen {
452
- outline: none !important;
453
- }
454
- .xterm-screen:focus {
455
- outline: none !important;
456
- }
457
- `;if(typeof document<"u"){const e=document.createElement("style");e.type="text/css",e.innerText=Wb,document.head.appendChild(e)}function Ub({selectedProject:e,selectedSession:r,initialCommand:n,isPlainShell:s=!1,onProcessComplete:o,minimal:a=!1,autoConnect:l=!1}){const{t:c}=Lt("chat"),d=i.useRef(null),u=i.useRef(null),m=i.useRef(null),p=i.useRef(null),[h,g]=i.useState(!1),[x,k]=i.useState(!1),[w,A]=i.useState(!1),[L,j]=i.useState(null),[S,D]=i.useState(!1),b=i.useRef(e),I=i.useRef(r),G=i.useRef(n),P=i.useRef(s),V=i.useRef(o);i.useEffect(()=>{b.current=e,I.current=r,G.current=n,P.current=s,V.current=o});const ve=i.useCallback(async()=>{if(!(S||h))try{let Se;if(!Qx){const B=localStorage.getItem("auth-token");if(!B){console.error("No authentication token found for Shell WebSocket connection");return}Se=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(B)}`}p.current=new WebSocket(Se),p.current.onopen=()=>{g(!0),D(!1),setTimeout(()=>{m.current&&u.current&&(m.current.fit(),p.current.send(JSON.stringify({type:"init",projectPath:b.current.fullPath||b.current.path,sessionId:P.current?null:I.current?.id,hasSession:P.current?!1:!!I.current,provider:P.current?"plain-shell":I.current?.__provider||"claude",cols:u.current.cols,rows:u.current.rows,initialCommand:G.current,isPlainShell:P.current})))},100)},p.current.onmessage=B=>{try{const z=JSON.parse(B.data);if(z.type==="output"){let _=z.data;if(P.current&&V.current){const N=_.replace(/\x1b\[[0-9;]*m/g,"");if(N.includes("Process exited with code 0"))V.current(0);else if(N.match(/Process exited with code (\d+)/)){const O=parseInt(N.match(/Process exited with code (\d+)/)[1]);O!==0&&V.current(O)}}u.current&&u.current.write(_)}else z.type==="url_open"&&window.open(z.url,"_blank")}catch(z){console.error("[Shell] Error handling WebSocket message:",z,B.data)}},p.current.onclose=B=>{g(!1),D(!1),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H"))},p.current.onerror=B=>{g(!1),D(!1)}}catch{g(!1),D(!1)}},[S,h]),ae=i.useCallback(()=>{!x||h||S||(D(!0),ve())},[x,h,S,ve]),R=i.useCallback(()=>{p.current&&(p.current.close(),p.current=null),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H")),g(!1),D(!1)},[]),q=i.useMemo(()=>r?r.summary||r.name||"New Session":null,[r]),de=i.useMemo(()=>q?q.slice(0,30):null,[q]),se=i.useMemo(()=>q?q.slice(0,50):null,[q]),he=()=>{A(!0),p.current&&(p.current.close(),p.current=null),u.current&&(u.current.dispose(),u.current=null,m.current=null),g(!1),k(!1),setTimeout(()=>{A(!1)},200)};return i.useEffect(()=>{const Se=r?.id||null;L!==null&&L!==Se&&x&&R(),j(Se)},[r?.id,x,R]),i.useEffect(()=>{if(!d.current||!e||w||u.current)return;u.current=new Ob.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"]}}),m.current=new Fb.FitAddon;const Se=new $b.WebglAddon,B=new Bb.WebLinksAddon;u.current.loadAddon(m.current),u.current.loadAddon(B);try{u.current.loadAddon(Se)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}u.current.open(d.current),u.current.attachCustomKeyEventHandler(_=>(_.ctrlKey||_.metaKey)&&_.key==="c"&&u.current.hasSelection()?(document.execCommand("copy"),!1):(_.ctrlKey||_.metaKey)&&_.key==="v"?(navigator.clipboard.readText().then(N=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:N}))}).catch(()=>{}),!1):!0),setTimeout(()=>{m.current&&(m.current.fit(),u.current&&p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows})))},100),k(!0),u.current.onData(_=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:_}))});const z=new ResizeObserver(()=>{m.current&&u.current&&setTimeout(()=>{m.current.fit(),p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows}))},50)});return d.current&&z.observe(d.current),()=>{z.disconnect(),p.current&&(p.current.readyState===WebSocket.OPEN||p.current.readyState===WebSocket.CONNECTING)&&p.current.close(),p.current=null,u.current&&(u.current.dispose(),u.current=null)}},[e?.path||e?.fullPath,w]),i.useEffect(()=>{!l||!x||S||h||ae()},[l,x,S,h,ae]),e?a?t.jsx("div",{className:"h-full w-full bg-gray-900",children:t.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):t.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[t.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:`w-2 h-2 rounded-full ${h?"bg-green-500":"bg-red-500"}`}),r&&t.jsxs("span",{className:"text-xs text-primary/80",children:["(",de,"...)"]}),!r&&t.jsx("span",{className:"text-xs text-gray-400",children:c("shell.status.newSession")}),!x&&t.jsx("span",{className:"text-xs text-yellow-400",children:c("shell.status.initializing")}),w&&t.jsx("span",{className:"text-xs text-primary",children:c("shell.status.restarting")})]}),t.jsxs("div",{className:"flex items-center space-x-3",children:[h&&t.jsxs("button",{onClick:R,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:[t.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),t.jsx("span",{children:c("shell.actions.disconnect")})]}),t.jsxs("button",{onClick:he,disabled:w||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:[t.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:c("shell.actions.restart")})]})]})]})}),t.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[t.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!x&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:t.jsx("div",{className:"text-white",children:c("shell.loading")})}),x&&!h&&!S&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:t.jsxs("div",{className:"text-center max-w-sm w-full",children:[t.jsxs("button",{onClick:ae,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:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),t.jsx("span",{children:c("shell.actions.connect")})]}),t.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}):r?c("shell.resumeSession",{displayName:se}):c("shell.startSession")})]})}),S&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:t.jsxs("div",{className:"text-center max-w-sm w-full",children:[t.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[t.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),t.jsx("span",{className:"text-base font-medium",children:c("shell.connecting")})]}),t.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})})]})})]})]}):t.jsx("div",{className:"h-full flex items-center justify-center",children:t.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[t.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:t.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx("h3",{className:"text-lg font-semibold mb-2",children:c("shell.selectProject.title")}),t.jsx("p",{children:c("shell.selectProject.description")})]})})}function tp({project:e,session:r=null,command:n=null,isPlainShell:s=null,autoConnect:o=!0,onComplete:a=null,onClose:l=null,title:c=null,className:d="",showHeader:u=!0,compact:m=!1,minimal:p=!1}){const[h,g]=i.useState(!1),x=s!==null?s:n!==null,k=i.useCallback(w=>{g(!0),a&&a(w)},[a]);return e?t.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[!p&&u&&c&&t.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-200",children:c}),h&&t.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),l&&t.jsx("button",{onClick:l,className:"text-gray-400 hover:text-white",title:"Close",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),t.jsx("div",{className:"flex-1 w-full min-h-0",children:t.jsx(Ub,{selectedProject:e,selectedSession:r,initialCommand:n,isPlainShell:x,onProcessComplete:k,minimal:p,autoConnect:p?!0:o})})]}):t.jsx("div",{className:`h-full flex items-center justify-center ${d}`,children:t.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[t.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:t.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Project Selected"}),t.jsx("p",{children:"A project is required to open a shell"})]})})}async function Hb(e,r){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 l=await pt.transcribe(n);if(!l.ok){const d=await l.json().catch(()=>({}));throw new Error(d.error||`Transcription error: ${l.status} ${l.statusText}`)}return(await l.json()).text||""}catch(l){throw l.name==="TypeError"&&l.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):l}}function Gb({onTranscript:e,className:r=""}){const[n,s]=i.useState("idle"),[o,a]=i.useState(null),[l,c]=i.useState(!0),d=i.useRef(null),u=i.useRef(null),m=i.useRef([]),p=i.useRef(0);i.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),m.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const j=await navigator.mediaDevices.getUserMedia({audio:!0});u.current=j;const S=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",D=new MediaRecorder(j,{mimeType:S});d.current=D,D.ondataavailable=b=>{b.data.size>0&&m.current.push(b.data)},D.onstop=async()=>{console.log("Recording stopped, creating blob...");const b=new Blob(m.current,{type:S});u.current&&(u.current.getTracks().forEach(V=>V.stop()),u.current=null),s("transcribing");const I=window.localStorage.getItem("whisperMode")||"default",G=I==="prompt"||I==="vibe"||I==="instructions"||I==="architect";let P;G&&(P=setTimeout(()=>{s("processing")},2e3));try{const V=await Hb(b);V&&e&&e(V)}catch(V){console.error("Transcription error:",V),a(V.message)}finally{P&&clearTimeout(P),s("idle")}},D.start(),s("recording"),console.log("Recording started successfully")}catch(j){console.error("Failed to start recording:",j);let S="Microphone access failed";j.name==="NotAllowedError"?S="Microphone access denied. Please allow microphone permissions.":j.name==="NotFoundError"?S="No microphone found. Please check your audio devices.":j.name==="NotSupportedError"?S="Microphone not supported by this browser.":j.name==="NotReadableError"?S="Microphone is being used by another application.":j.message.includes("HTTPS")&&(S=j.message),a(S),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(j=>j.stop()),u.current=null),s("idle"))},x=j=>{if(j&&(j.preventDefault(),j.stopPropagation()),!l)return;const S=Date.now();if(S-p.current<300){console.log("Ignoring rapid tap");return}p.current=S,console.log("Button clicked, current state:",n),n==="idle"?h():n==="recording"&&g()};i.useEffect(()=>()=>{u.current&&u.current.getTracks().forEach(j=>j.stop())},[]);const k=()=>{if(!l)return{icon:t.jsx(Bs,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(n){case"recording":return{icon:t.jsx(Bs,{className:"w-5 h-5 text-white"}),className:"bg-red-500 hover:bg-red-600 animate-pulse",disabled:!1};case"transcribing":return{icon:t.jsx(qr,{className:"w-5 h-5 animate-spin"}),className:"bg-primary hover:bg-primary/90",disabled:!0};case"processing":return{icon:t.jsx(Fc,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:t.jsx(Bs,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:w,className:A,disabled:L}=k();return t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button",style:{backgroundColor:n==="recording"?"#ef4444":n==="transcribing"?"#3b82f6":n==="processing"?"#a855f7":"#374151"},className:`
458
- flex items-center justify-center
459
- w-12 h-12 rounded-full
460
- text-white transition-all duration-200
461
- focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-ring
462
- dark:ring-offset-gray-800
463
- touch-action-manipulation
464
- ${L?"cursor-not-allowed opacity-75":"cursor-pointer"}
465
- ${n==="recording"?"animate-pulse":""}
466
- hover:opacity-90
467
- ${r}
468
- `,onClick:x,disabled:L,children:w}),o&&t.jsx("div",{className:`absolute top-full mt-2 left-1/2 transform -translate-x-1/2
469
- bg-red-500 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-10
470
- animate-fade-in`,children:o}),n==="recording"&&t.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),n==="processing"&&t.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}function Cc({diff:e,fileName:r,isMobile:n,wrapText:s}){if(!e)return t.jsx("div",{className:"p-4 text-center text-gray-500 dark:text-gray-400 text-sm",children:"No diff available"});const o=(a,l)=>{const c=a.startsWith("+")&&!a.startsWith("+++"),d=a.startsWith("-")&&!a.startsWith("---"),u=a.startsWith("@@");return t.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},l)};return t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-background/95 shadow-sm",children:[r&&t.jsx("div",{className:"border-b border-border/70 px-3 py-2 text-xs font-medium text-muted-foreground",children:r}),e.split(`
471
- `).map((a,l)=>o(a,l))]})}function qb({selectedProject:e,isMobile:r,onFileOpen:n}){const[s,o]=i.useState(null),[a,l]=i.useState({}),[c,d]=i.useState(!1),[u,m]=i.useState(""),[p,h]=i.useState(new Set),[g,x]=i.useState(new Set),[k,w]=i.useState(!1),[A,L]=i.useState(""),[j,S]=i.useState([]),[D,b]=i.useState(!0),[I,G]=i.useState(!1),[P,V]=i.useState(!1),[ve,ae]=i.useState(!1),[R,q]=i.useState(""),[de,se]=i.useState(!1),[he,Se]=i.useState("changes"),[B,z]=i.useState([]),[_,N]=i.useState(new Set),[O,ne]=i.useState({}),[Ce,be]=i.useState(!1),[re,Ee]=i.useState(null),[nt,De]=i.useState(!1),[fe,Ge]=i.useState(!1),[bt,st]=i.useState(!1),[Be,Ze]=i.useState(!1),[xt,wt]=i.useState(r),[ye,qe]=i.useState(null),[Nt,X]=i.useState(!1),Te=i.useRef(null),W=i.useRef(null),[Z,we]=i.useState(()=>localStorage.getItem("selected-provider")||"claude");i.useEffect(()=>{const C=()=>{const F=localStorage.getItem("selected-provider")||"claude";we(F)};return window.addEventListener("storage",C),()=>window.removeEventListener("storage",C)},[]),i.useEffect(()=>{e&&(Ae(),Xe(),Qe(),he==="history"&&rr())},[e,he]),i.useEffect(()=>{const C=F=>{W.current&&!W.current.contains(F.target)&&V(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]);const Ae=async()=>{if(e){d(!0);try{const F=await(await ee(`/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),L(F.branch||"main");const pe=new Set([...F.modified||[],...F.added||[],...F.deleted||[],...F.untracked||[]]);x(pe);for(const je of F.modified||[])yt(je);for(const je of F.added||[])yt(je);for(const je of F.deleted||[])yt(je);for(const je of F.untracked||[])yt(je)}}catch(C){console.error("Error fetching git status:",C)}finally{d(!1)}}},Xe=async()=>{try{const F=await(await ee(`/api/git/branches?project=${encodeURIComponent(e.name)}`)).json();!F.error&&F.branches&&S(F.branches)}catch(C){console.error("Error fetching branches:",C)}},Qe=async()=>{if(e)try{const F=await(await ee(`/api/git/remote-status?project=${encodeURIComponent(e.name)}`)).json();F.error?Ee(null):Ee(F)}catch(C){console.error("Error fetching remote status:",C),Ee(null)}},We=async C=>{try{const pe=await(await ee("/api/git/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:C})})).json();pe.success?(L(C),V(!1),Ae()):console.error("Failed to switch branch:",pe.error)}catch(F){console.error("Error switching branch:",F)}},Et=async()=>{if(R.trim()){se(!0);try{const F=await(await ee("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:R.trim()})})).json();F.success?(L(R.trim()),ae(!1),V(!1),q(""),Xe(),Ae()):console.error("Failed to create branch:",F.error)}catch(C){console.error("Error creating branch:",C)}finally{se(!1)}}},ie=async()=>{De(!0);try{const F=await(await ee("/api/git/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),Qe()):console.error("Fetch failed:",F.error)}catch(C){console.error("Error fetching from remote:",C)}finally{De(!1)}},St=async()=>{Ge(!0);try{const F=await(await ee("/api/git/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),Qe()):console.error("Pull failed:",F.error)}catch(C){console.error("Error pulling from remote:",C)}finally{Ge(!1)}},et=async()=>{st(!0);try{const F=await(await ee("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),Qe()):console.error("Push failed:",F.error)}catch(C){console.error("Error pushing to remote:",C)}finally{st(!1)}},ot=async()=>{Ze(!0);try{const F=await(await ee("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:A})})).json();F.success?(Ae(),Qe()):console.error("Publish failed:",F.error)}catch(C){console.error("Error publishing branch:",C)}finally{Ze(!1)}},Ke=async C=>{try{const pe=await(await ee("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:C})})).json();pe.success?(x(je=>{const mt=new Set(je);return mt.delete(C),mt}),Ae()):console.error("Discard failed:",pe.error)}catch(F){console.error("Error discarding changes:",F)}},Tt=async C=>{try{const pe=await(await ee("/api/git/delete-untracked",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:C})})).json();pe.success?(x(je=>{const mt=new Set(je);return mt.delete(C),mt}),Ae()):console.error("Delete failed:",pe.error)}catch(F){console.error("Error deleting untracked file:",F)}},Ot=async()=>{if(!ye)return;const{type:C,file:F,message:pe}=ye;qe(null);try{switch(C){case"discard":await Ke(F);break;case"delete":await Tt(F);break;case"commit":await Bt();break;case"pull":await St();break;case"push":await et();break;case"publish":await ot();break}}catch(je){console.error(`Error executing ${C}:`,je)}},yt=async C=>{try{const pe=await(await ee(`/api/git/diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(C)}`)).json();!pe.error&&pe.diff&&l(je=>({...je,[C]:pe.diff}))}catch(F){console.error("Error fetching file diff:",F)}},At=async C=>{if(n)try{const pe=await(await ee(`/api/git/file-with-diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(C)}`)).json();if(pe.error){console.error("Error fetching file with diff:",pe.error),n(C);return}const je={old_string:pe.oldContent||"",new_string:pe.currentContent||""};n(C,je)}catch(F){console.error("Error opening file:",F),n(C)}},rr=async()=>{try{const F=await(await ee(`/api/git/commits?project=${encodeURIComponent(e.name)}&limit=10`)).json();!F.error&&F.commits&&z(F.commits)}catch(C){console.error("Error fetching commits:",C)}},tt=async C=>{try{const pe=await(await ee(`/api/git/commit-diff?project=${encodeURIComponent(e.name)}&commit=${C}`)).json();!pe.error&&pe.diff&&ne(je=>({...je,[C]:pe.diff}))}catch(F){console.error("Error fetching commit diff:",F)}},Ft=async()=>{be(!0);try{const F=await(await ee("/api/git/generate-commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,files:Array.from(g),provider:Z})})).json();F.message?m(F.message):console.error("Failed to generate commit message:",F.error)}catch(C){console.error("Error generating commit message:",C)}finally{be(!1)}},It=C=>{h(F=>{const pe=new Set(F);return pe.has(C)?pe.delete(C):pe.add(C),pe})},$t=C=>{N(F=>{const pe=new Set(F);return pe.has(C)?pe.delete(C):(pe.add(C),O[C]||tt(C)),pe})},nr=C=>{x(F=>{const pe=new Set(F);return pe.has(C)?pe.delete(C):pe.add(C),pe})},Bt=async()=>{if(!(!u.trim()||g.size===0)){w(!0);try{const F=await(await ee("/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?(m(""),x(new Set),Ae(),Qe()):console.error("Commit failed:",F.error)}catch(C){console.error("Error committing changes:",C)}finally{w(!1)}}},M=async()=>{X(!0);try{const F=await(await ee("/api/git/initial-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),Qe()):(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{X(!1)}},ge=C=>{switch(C){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"U":return"Untracked";default:return C}},Re=C=>{const F=_.has(C.hash),pe=O[C.hash];return t.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700 last:border-0",children:[t.jsxs("div",{className:"flex items-start p-3 hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer",onClick:()=>$t(C.hash),children:[t.jsx("div",{className:"mr-2 mt-1 p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:F?t.jsx(Ar,{className:"w-3 h-3"}):t.jsx(sn,{className:"w-3 h-3"})}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:C.message}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[C.author," • ",C.date]})]}),t.jsx("span",{className:"text-xs font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:C.hash.substring(0,7)})]})})]}),F&&pe&&t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"max-h-96 overflow-y-auto p-2",children:[t.jsx("div",{className:"text-xs font-mono text-gray-600 dark:text-gray-400 mb-2",children:C.stats}),t.jsx(Cc,{diff:pe,fileName:"commit",isMobile:r,wrapText:D})]})})]},C.hash)},Q=(C,F)=>{const pe=p.has(C),je=g.has(C),mt=a[C];return t.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700 last:border-0",children:[t.jsxs("div",{className:`flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 ${r?"px-2 py-1.5":"px-3 py-2"}`,children:[t.jsx("input",{type:"checkbox",checked:je,onChange:()=>nr(C),onClick:H=>H.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 ${r?"mr-1.5":"mr-2"}`}),t.jsxs("div",{className:"flex items-center flex-1",children:[t.jsx("div",{className:`p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded cursor-pointer ${r?"mr-1":"mr-2"}`,onClick:H=>{H.stopPropagation(),It(C)},children:t.jsx(sn,{className:`w-3 h-3 transition-transform duration-200 ease-in-out ${pe?"rotate-90":"rotate-0"}`})}),t.jsx("span",{className:`flex-1 truncate ${r?"text-xs":"text-sm"} cursor-pointer hover:text-primary hover:underline`,onClick:H=>{H.stopPropagation(),At(C)},title:"Click to open file",children:C}),t.jsxs("div",{className:"flex items-center gap-1",children:[(F==="M"||F==="D")&&t.jsxs("button",{onClick:H=>{H.stopPropagation(),qe({type:"discard",file:C,message:`Discard all changes to "${C}"? This action cannot be undone.`})},className:`${r?"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:[t.jsx(ir,{className:"w-3 h-3"}),r&&t.jsx("span",{children:"Discard"})]}),F==="U"&&t.jsxs("button",{onClick:H=>{H.stopPropagation(),qe({type:"delete",file:C,message:`Delete untracked file "${C}"? This action cannot be undone.`})},className:`${r?"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:[t.jsx(ir,{className:"w-3 h-3"}),r&&t.jsx("span",{children:"Delete"})]}),t.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:ge(F),children:F})]})]})]}),t.jsxs("div",{className:`bg-gray-50 dark:bg-gray-900 transition-all duration-400 ease-in-out overflow-hidden ${pe&&mt?"max-h-[600px] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-1"}`,children:[t.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.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}),t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:ge(F)})]}),r&&t.jsx("button",{onClick:H=>{H.stopPropagation(),b(!D)},className:"text-xs text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",title:D?"Switch to horizontal scroll":"Switch to text wrap",children:D?"↔️ Scroll":"↩️ Wrap"})]}),t.jsx("div",{className:"max-h-96 overflow-y-auto",children:mt&&t.jsx(Cc,{diff:mt,fileName:C,isMobile:r,wrapText:D})})]})]},C)};return e?t.jsxs("div",{className:"h-full flex flex-col bg-background",children:[t.jsxs("div",{className:`flex items-center justify-between border-b border-gray-200 dark:border-gray-700 ${r?"px-3 py-2":"px-4 py-3"}`,children:[t.jsxs("div",{className:"relative",ref:W,children:[t.jsxs("button",{onClick:()=>V(!P),className:`flex items-center hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors ${r?"space-x-1 px-2 py-1":"space-x-2 px-3 py-1.5"}`,children:[t.jsx(Kr,{className:`text-gray-600 dark:text-gray-400 ${r?"w-3 h-3":"w-4 h-4"}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:`font-medium ${r?"text-xs":"text-sm"}`,children:A}),re?.hasRemote&&t.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[re.ahead>0&&t.jsxs("span",{className:"text-green-600 dark:text-green-400",title:`${re.ahead} commit${re.ahead!==1?"s":""} ahead`,children:["↑",re.ahead]}),re.behind>0&&t.jsxs("span",{className:"text-primary",title:`${re.behind} commit${re.behind!==1?"s":""} behind`,children:["↓",re.behind]}),re.isUpToDate&&t.jsx("span",{className:"text-gray-500 dark:text-gray-400",title:"Up to date with remote",children:"✓"})]})]}),t.jsx(Ar,{className:`w-3 h-3 text-gray-500 transition-transform ${P?"rotate-180":""}`})]}),P&&t.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:[t.jsx("div",{className:"py-1 max-h-64 overflow-y-auto",children:j.map(C=>t.jsx("button",{onClick:()=>We(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:t.jsxs("div",{className:"flex items-center space-x-2",children:[C===A&&t.jsx(Gt,{className:"w-3 h-3 text-green-600 dark:text-green-400"}),t.jsx("span",{className:C===A?"font-medium":"",children:C})]})},C))}),t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 py-1",children:t.jsxs("button",{onClick:()=>{ae(!0),V(!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:[t.jsx(ln,{className:"w-3 h-3"}),t.jsx("span",{children:"Create new branch"})]})})]})]}),t.jsxs("div",{className:`flex items-center ${r?"gap-1":"gap-2"}`,children:[re?.hasRemote&&t.jsxs(t.Fragment,{children:[!re?.hasUpstream&&t.jsxs("button",{onClick:()=>qe({type:"publish",message:`Publish branch "${A}" to ${re.remoteName}?`}),disabled:Be,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 ${re.remoteName}`,children:[t.jsx(Ns,{className:`w-3 h-3 ${Be?"animate-pulse":""}`}),t.jsx("span",{children:Be?"Publishing...":"Publish"})]}),re?.hasUpstream&&!re?.isUpToDate&&t.jsxs(t.Fragment,{children:[re.behind>0&&t.jsxs("button",{onClick:()=>qe({type:"pull",message:`Pull ${re.behind} commit${re.behind!==1?"s":""} from ${re.remoteName}?`}),disabled:fe,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 ${re.behind} commit${re.behind!==1?"s":""} from ${re.remoteName}`,children:[t.jsx(ka,{className:`w-3 h-3 ${fe?"animate-pulse":""}`}),t.jsx("span",{children:fe?"Pulling...":`Pull ${re.behind}`})]}),re.ahead>0&&t.jsxs("button",{onClick:()=>qe({type:"push",message:`Push ${re.ahead} commit${re.ahead!==1?"s":""} to ${re.remoteName}?`}),disabled:bt,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 ${re.ahead} commit${re.ahead!==1?"s":""} to ${re.remoteName}`,children:[t.jsx(Ns,{className:`w-3 h-3 ${bt?"animate-pulse":""}`}),t.jsx("span",{children:bt?"Pushing...":`Push ${re.ahead}`})]}),(re.ahead>0||re.behind>0&&re.ahead>0)&&t.jsxs("button",{onClick:ie,disabled:nt,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 ${re.remoteName}`,children:[t.jsx(Tr,{className:`w-3 h-3 ${nt?"animate-spin":""}`}),t.jsx("span",{children:nt?"Fetching...":"Fetch"})]})]})]}),t.jsx("button",{onClick:()=>{Ae(),Xe(),Qe()},disabled:c,className:`hover:bg-gray-100 dark:hover:bg-gray-800 rounded ${r?"p-1":"p-1.5"}`,children:t.jsx(Tr,{className:`${c?"animate-spin":""} ${r?"w-3 h-3":"w-4 h-4"}`})})]})]}),s?.error?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-gray-500 dark:text-gray-400 px-6 py-12",children:[t.jsx(Kr,{className:"w-20 h-20 mb-6 opacity-30"}),t.jsx("h3",{className:"text-xl font-medium mb-3 text-center",children:s.error}),s.details&&t.jsx("p",{className:"text-sm text-center leading-relaxed mb-6 max-w-md",children:s.details}),t.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:t.jsxs("p",{className:"text-sm text-primary text-center",children:[t.jsx("strong",{children:"Tip:"})," Run ",t.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."]})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`flex border-b border-gray-200 dark:border-gray-700 transition-all duration-300 ease-in-out ${p.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[t.jsx("button",{onClick:()=>Se("changes"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${he==="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:t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(oi,{className:"w-4 h-4"}),t.jsx("span",{children:"Changes"})]})}),t.jsx("button",{onClick:()=>Se("history"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${he==="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:t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(hl,{className:"w-4 h-4"}),t.jsx("span",{children:"History"})]})})]}),he==="changes"&&t.jsx(t.Fragment,{children:t.jsx("div",{className:`transition-all duration-300 ease-in-out ${p.size===0?"max-h-96 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:r&&xt?t.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700",children:t.jsxs("button",{onClick:()=>wt(!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:[t.jsx(ra,{className:"w-4 h-4"}),t.jsxs("span",{children:["Commit ",g.size," file",g.size!==1?"s":""]}),t.jsx(Ar,{className:"w-3 h-3"})]})}):t.jsx(t.Fragment,{children:t.jsxs("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:[r&&t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-sm font-medium",children:"Commit Changes"}),t.jsx("button",{onClick:()=>wt(!0),className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-800 rounded",children:t.jsx(Ar,{className:"w-4 h-4 rotate-180"})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("textarea",{ref:Te,value:u,onChange:C=>m(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)&&Bt()}}),t.jsxs("div",{className:"absolute right-2 top-2 flex gap-1",children:[t.jsx("button",{onClick:Ft,disabled:g.size===0||Ce,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:Ce?t.jsx(Tr,{className:"w-4 h-4 animate-spin"}):t.jsx(ri,{className:"w-4 h-4"})}),t.jsx("div",{style:{display:"none"},children:t.jsx(Gb,{onTranscript:C=>m(C),mode:"default",className:"p-1.5"})})]})]}),t.jsxs("div",{className:"flex items-center justify-between mt-2",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[g.size," file",g.size!==1?"s":""," selected"]}),t.jsxs("button",{onClick:()=>qe({type:"commit",message:`Commit ${g.size} file${g.size!==1?"s":""} with message: "${u.trim()}"?`}),disabled:!u.trim()||g.size===0||k,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:[t.jsx(Gt,{className:"w-3 h-3"}),t.jsx("span",{children:k?"Committing...":"Commit"})]})]})]})})})}),he==="changes"&&s&&!s.error&&t.jsxs("div",{className:`border-b border-gray-200 dark:border-gray-700 flex items-center justify-between transition-all duration-300 ease-in-out ${r?"px-3 py-1.5":"px-4 py-2"} ${p.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[t.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)," ",r?"":"files"," selected"]}),t.jsxs("div",{className:`flex ${r?"gap-1":"gap-2"}`,children:[t.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:r?"All":"Select All"}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:()=>x(new Set),className:"text-primary hover:text-primary text-xs",children:r?"None":"Deselect All"})]})]}),!s?.error&&!r&&t.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("button",{onClick:()=>G(!I),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:[t.jsx(Mf,{className:"w-3 h-3"}),t.jsx("span",{children:"File Status Guide"}),I?t.jsx(Ar,{className:"w-3 h-3"}):t.jsx(sn,{className:"w-3 h-3"})]}),I&&t.jsx("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-800 text-xs",children:t.jsxs("div",{className:`${r?"grid grid-cols-2 gap-3 justify-items-center":"flex justify-center gap-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.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"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Modified"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.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"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Added"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.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"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Deleted"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.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"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Untracked"})]})]})})]})]}),he==="changes"&&!s?.error&&t.jsx("div",{className:`flex-1 overflow-y-auto ${r?"pb-mobile-nav":""}`,children:c?t.jsx("div",{className:"flex items-center justify-center h-32",children:t.jsx(Tr,{className:"w-6 h-6 animate-spin text-gray-400"})}):s?.hasCommits===!1?t.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t.jsx(Kr,{className:"w-16 h-16 mb-4 opacity-30 text-gray-400 dark:text-gray-500"}),t.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-900 dark:text-white",children:"No commits yet"}),t.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."}),t.jsx("button",{onClick:M,disabled:Nt,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:Nt?t.jsxs(t.Fragment,{children:[t.jsx(Tr,{className:"w-4 h-4 animate-spin"}),t.jsx("span",{children:"Creating Initial Commit..."})]}):t.jsxs(t.Fragment,{children:[t.jsx(ra,{className:"w-4 h-4"}),t.jsx("span",{children:"Create Initial Commit"})]})})]}):!s||!s.modified?.length&&!s.added?.length&&!s.deleted?.length&&!s.untracked?.length?t.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:[t.jsx(ra,{className:"w-12 h-12 mb-2 opacity-50"}),t.jsx("p",{className:"text-sm",children:"No changes detected"})]}):t.jsxs("div",{className:r?"pb-4":"",children:[s.modified?.map(C=>Q(C,"M")),s.added?.map(C=>Q(C,"A")),s.deleted?.map(C=>Q(C,"D")),s.untracked?.map(C=>Q(C,"U"))]})}),he==="history"&&!s?.error&&t.jsx("div",{className:`flex-1 overflow-y-auto ${r?"pb-mobile-nav":""}`,children:c?t.jsx("div",{className:"flex items-center justify-center h-32",children:t.jsx(Tr,{className:"w-6 h-6 animate-spin text-gray-400"})}):B.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:[t.jsx(hl,{className:"w-12 h-12 mb-2 opacity-50"}),t.jsx("p",{className:"text-sm",children:"No commits found"})]}):t.jsx("div",{className:r?"pb-4":"",children:B.map(C=>Re(C))})}),ve&&t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>ae(!1)}),t.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full",children:t.jsxs("div",{className:"p-6",children:[t.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Create New Branch"}),t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Branch Name"}),t.jsx("input",{type:"text",value:R,onChange:C=>q(C.target.value),onKeyDown:C=>{C.key==="Enter"&&!de&&Et()},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})]}),t.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,")"]}),t.jsxs("div",{className:"flex justify-end space-x-3",children:[t.jsx("button",{onClick:()=>{ae(!1),q("")},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"}),t.jsx("button",{onClick:Et,disabled:!R.trim()||de,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:de?t.jsxs(t.Fragment,{children:[t.jsx(Tr,{className:"w-3 h-3 animate-spin"}),t.jsx("span",{children:"Creating..."})]}):t.jsxs(t.Fragment,{children:[t.jsx(ln,{className:"w-3 h-3"}),t.jsx("span",{children:"Create Branch"})]})})]})]})})]}),ye&&t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>qe(null)}),t.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full",children:t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center mb-4",children:[t.jsx("div",{className:`p-2 rounded-full mr-3 ${ye.type==="discard"||ye.type==="delete"?"bg-red-100 dark:bg-red-900":"bg-yellow-100 dark:bg-yellow-900"}`,children:t.jsx(Ea,{className:`w-5 h-5 ${ye.type==="discard"||ye.type==="delete"?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400"}`})}),t.jsx("h3",{className:"text-lg font-semibold",children:ye.type==="discard"?"Discard Changes":ye.type==="delete"?"Delete File":ye.type==="commit"?"Confirm Commit":ye.type==="pull"?"Confirm Pull":ye.type==="publish"?"Publish Branch":"Confirm Push"})]}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:ye.message}),t.jsxs("div",{className:"flex justify-end space-x-3",children:[t.jsx("button",{onClick:()=>qe(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"}),t.jsx("button",{onClick:Ot,className:`px-4 py-2 text-sm text-white rounded-md ${ye.type==="discard"||ye.type==="delete"?"bg-red-600 hover:bg-red-700":ye.type==="commit"?"bg-primary hover:bg-primary/90":ye.type==="pull"?"bg-green-600 hover:bg-green-700":ye.type==="publish"?"bg-purple-600 hover:bg-purple-700":"bg-orange-600 hover:bg-orange-700"} flex items-center space-x-2`,children:ye.type==="discard"?t.jsxs(t.Fragment,{children:[t.jsx(ir,{className:"w-4 h-4"}),t.jsx("span",{children:"Discard"})]}):ye.type==="delete"?t.jsxs(t.Fragment,{children:[t.jsx(ir,{className:"w-4 h-4"}),t.jsx("span",{children:"Delete"})]}):ye.type==="commit"?t.jsxs(t.Fragment,{children:[t.jsx(Gt,{className:"w-4 h-4"}),t.jsx("span",{children:"Commit"})]}):ye.type==="pull"?t.jsxs(t.Fragment,{children:[t.jsx(ka,{className:"w-4 h-4"}),t.jsx("span",{children:"Pull"})]}):ye.type==="publish"?t.jsxs(t.Fragment,{children:[t.jsx(Ns,{className:"w-4 h-4"}),t.jsx("span",{children:"Publish"})]}):t.jsxs(t.Fragment,{children:[t.jsx(Ns,{className:"w-4 h-4"}),t.jsx("span",{children:"Push"})]})})]})]})})]})]}):t.jsx("div",{className:"h-full flex items-center justify-center text-gray-500 dark:text-gray-400",children:t.jsx("p",{children:"Select a project to view source control"})})}class Kb extends dn.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0}}componentDidCatch(r,n){console.error("ErrorBoundary caught an error:",r,n),this.setState({error:r,errorInfo:n})}render(){return this.state.hasError?t.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:t.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[t.jsxs("div",{className:"flex items-center mb-4",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:t.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"})})}),t.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"Something went wrong"})]}),t.jsxs("div",{className:"text-sm text-red-700",children:[t.jsx("p",{className:"mb-2",children:"An error occurred while loading the chat interface."}),this.props.showDetails&&this.state.error&&t.jsxs("details",{className:"mt-4",children:[t.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"Error Details"}),t.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]})]})]}),t.jsx("div",{className:"mt-4",children:t.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 Vb=Xx,rp=i.forwardRef(({className:e,...r},n)=>t.jsx(tu,{ref:n,className:ut("inline-flex h-10 items-center justify-center rounded-xl bg-muted/60 p-1 text-muted-foreground",e),...r}));rp.displayName=tu.displayName;const np=i.forwardRef(({className:e,...r},n)=>t.jsx(ru,{ref:n,className:ut("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),...r}));np.displayName=ru.displayName;const Jb=i.forwardRef(({className:e,...r},n)=>t.jsx(nu,{ref:n,className:ut("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20",e),...r}));Jb.displayName=nu.displayName;function Yb({selectedProject:e,selectedSession:r,activeTab:n,setActiveTab:s,ws:o,sendMessage:a,latestMessage:l,isMobile:c,isPWA:d,onMenuClick:u,isLoading:m,onInputFocusChange:p,onSessionActive:h,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:k,processingSessions:w,onReplaceTemporarySession:A,onNavigateToSession:L,onShowSettings:j,autoExpandTools:S,showRawParameters:D,showThinking:b,autoScrollToBottom:I,sendByCtrlEnter:G,externalMessageUpdate:P,urlProvider:V,urlModel:ve,urlContext:ae,urlPrompt:R,integrationClientId:q,latestIntegrationMessage:de,sendIntegrationMessage:se,onShowNewProject:he,onNewSession:Se,newSessionResetNonce:B}){const{t:z}=Lt(),[_,N]=i.useState(null),[O,ne]=i.useState(600),[Ce,be]=i.useState(!1),[re,Ee]=i.useState(!1),nt=i.useRef(null),De=(ye,qe=null)=>{const Nt={name:ye.split("/").pop(),path:ye,projectName:e?.name,diffInfo:qe};N(Nt)},fe=()=>{N(null),Ee(!1)},Ge=()=>{Ee(!re)},bt=ye=>{c||(be(!0),ye.preventDefault())};if(i.useEffect(()=>{n==="files"&&s("chat")},[n,s]),i.useEffect(()=>{const ye=Nt=>{if(!Ce)return;const X=nt.current?.parentElement;if(!X)return;const Te=X.getBoundingClientRect(),W=Te.right-Nt.clientX,Z=300,we=Te.width*.8;W>=Z&&W<=we&&ne(W)},qe=()=>{be(!1)};return Ce&&(document.addEventListener("mousemove",ye),document.addEventListener("mouseup",qe),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",ye),document.removeEventListener("mouseup",qe),document.body.style.cursor="",document.body.style.userSelect=""}},[Ce]),m)return t.jsxs("div",{className:"h-full flex flex-col",children:[c&&t.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:t.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:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[t.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:t.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"}})}),t.jsx("h2",{className:"text-xl font-semibold",children:z("mainContent.loading")})]})})]});if(!e)return t.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[c&&t.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:t.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:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),t.jsx("div",{className:"flex flex-1 items-center justify-center px-4 py-8 sm:px-6",children:t.jsxs("div",{className:"w-full max-w-xl px-8 py-10 text-center text-muted-foreground",children:[t.jsx("div",{className:"mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:t.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:z("mainContent.chooseProject")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:z("mainContent.selectProjectDescription")}),t.jsx("div",{className:"mx-auto flex w-fit items-center",children:t.jsxs("button",{onClick:he,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:z("tooltips.createProject")||"New Chat",children:[t.jsx(Sn,{className:"w-5 h-5"}),t.jsx("span",{children:z("tooltips.createProject")||"New Chat"})]})})]})})]});const st=r?.__provider||r?.provider||"claude",Be=st==="openai"?"codex":st,Ze=Be==="codex"&&typeof r?.id=="string"?r.id.trim():"",xt=Ze?`codex://threads/${encodeURIComponent(Ze)}`:"",wt=()=>{xt&&(window.location.href=xt)};return t.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[t.jsx("div",{className:"chat-header flex-shrink-0 px-3 py-3 sm:px-4 sm:py-3 pwa-header-safe",children:t.jsxs("div",{className:"relative flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center space-x-2",children:[c&&t.jsx("button",{onClick:u,onTouchStart:ye=>{ye.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:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),t.jsxs("div",{className:"flex flex-1 items-center gap-3 overflow-x-auto scrollbar-hide min-w-0",children:[n==="chat"&&r&&t.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl bg-muted/60",children:Be==="codex"?t.jsx(ss,{className:"w-4 h-4"}):Be==="gemini"?t.jsx(mo,{className:"w-4 h-4"}):Be==="opencode"?t.jsx(fo,{className:"h-4 w-auto max-w-full"}):t.jsx(Pn,{className:"w-4 h-4"})}),t.jsx("div",{className:"min-w-0 flex-1",children:n==="chat"&&r?t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"overflow-x-auto whitespace-nowrap scrollbar-hide text-sm font-semibold text-gray-900 dark:text-white sm:text-base",children:Be==="codex"?r.summary||r.name||"Codex Session":Be==="gemini"?r.summary||r.name||"Gemini Session":Be==="opencode"?r.summary||r.name||"OpenCode Session":r.summary||"New Session"}),t.jsx("div",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:e.displayName})]}):n==="chat"&&!r?t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:z("mainContent.newSession")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:n==="git"?z("tabs.git"):"Project"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]})})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[n==="chat"&&Be==="codex"&&xt&&t.jsx("button",{onClick:wt,className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:z("mainContent.openInCodexClient"),"aria-label":z("mainContent.openInCodexClient"),children:t.jsx(ja,{className:"w-5 h-5"})}),t.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:z("tooltips.newChat","New Chat"),children:t.jsx(Wf,{className:"w-5 h-5"})}),t.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:t.jsx(Vb,{value:n,onValueChange:s,children:t.jsx(rp,{children:t.jsx(Hn,{content:z("tabs.chat"),position:"bottom",children:t.jsx(np,{value:"chat",children:t.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[t.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:t.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"})}),t.jsx("span",{className:"hidden lg:inline",children:z("tabs.chat")})]})})})})})})]})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[t.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${_?"mr-0":""} ${re?"hidden":""}`,children:[t.jsx("div",{className:`h-full ${n==="chat"?"block":"hidden"}`,children:t.jsx(Kb,{showDetails:!0,children:t.jsx(Vv,{selectedProject:e,selectedSession:r,ws:o,sendMessage:a,latestMessage:l,onFileOpen:De,onInputFocusChange:p,onSessionActive:h,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:k,processingSessions:w,onReplaceTemporarySession:A,onNavigateToSession:L,onShowSettings:j,autoExpandTools:S,showRawParameters:D,showThinking:b,autoScrollToBottom:I,sendByCtrlEnter:G,externalMessageUpdate:P,urlProvider:V,urlModel:ve,urlContext:ae,urlPrompt:R,integrationClientId:q,latestIntegrationMessage:de,sendIntegrationMessage:se,newSessionResetNonce:B},`${e?.name||"no-project"}:${r?.id||`new-${B}`}`)})}),n==="shell"&&t.jsx("div",{className:"h-full w-full overflow-hidden",children:t.jsx(tp,{project:e,session:r,showHeader:!1})}),n==="git"&&t.jsx("div",{className:"chat-surface h-full overflow-hidden",children:t.jsx(qb,{selectedProject:e,isMobile:c,onFileOpen:De})}),t.jsx("div",{className:`h-full overflow-hidden ${n==="preview"?"block":"hidden"}`})]}),_&&!c&&t.jsxs(t.Fragment,{children:[!re&&t.jsx("div",{ref:nt,onMouseDown:bt,className:"group relative w-1 flex-shrink-0 cursor-col-resize bg-border/70 transition-colors hover:bg-primary",title:"Drag to resize",children:t.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"})}),t.jsx("div",{className:`chat-surface h-full flex-shrink-0 overflow-hidden bg-muted/20 ${re?"flex-1":""}`,style:re?{}:{width:`${O}px`},children:t.jsx(Nc,{file:_,onClose:fe,projectPath:e?.path,isSidebar:!0,isExpanded:re,onToggleExpand:Ge})})]})]}),_&&c&&t.jsx(Nc,{file:_,onClose:fe,projectPath:e?.path,isSidebar:!1})]})}const Xb=dn.memo(Yb),sp="0.2.1",op=()=>{const[e,r]=i.useState(!1),[n,s]=i.useState(null),[o,a]=i.useState(null);return i.useEffect(()=>{(async()=>{try{const c=await ee("/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),r(!!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 r(!1),s(null),a(null)}catch(c){console.error("Version check failed:",c.message||c),r(!1),s(null),a(null)}})()},[]),{updateAvailable:e,latestVersion:n,currentVersion:sp,releaseInfo:o}};function Qb(){const{t:e}=Lt("settings"),[r,n]=i.useState([]),[s,o]=i.useState([]),[a,l]=i.useState(!0),[c,d]=i.useState(!1),[u,m]=i.useState(!1),[p,h]=i.useState(""),[g,x]=i.useState(""),[k,w]=i.useState(""),[A,L]=i.useState(""),[j,S]=i.useState({}),[D,b]=i.useState(null),[I,G]=i.useState(null),{updateAvailable:P,latestVersion:V,releaseInfo:ve}=op();i.useEffect(()=>{ae()},[]);const ae=async()=>{try{l(!0);const _=await(await ee("/api/settings/api-keys")).json();n(_.apiKeys||[]);const O=await(await ee("/api/settings/credentials?type=github_token")).json();o(O.credentials||[])}catch(z){console.error("Error fetching settings:",z)}finally{l(!1)}},R=async()=>{if(p.trim())try{const _=await(await ee("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:p})})).json();_.success&&(G(_.apiKey),h(""),d(!1),ae())}catch(z){console.error("Error creating API key:",z)}},q=async z=>{if(confirm(e("apiKeys.confirmDelete")))try{await ee(`/api/settings/api-keys/${z}`,{method:"DELETE"}),ae()}catch(_){console.error("Error deleting API key:",_)}},de=async(z,_)=>{try{await ee(`/api/settings/api-keys/${z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!_})}),ae()}catch(N){console.error("Error toggling API key:",N)}},se=async()=>{if(!(!g.trim()||!k.trim()))try{(await(await ee("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:g,credentialType:"github_token",credentialValue:k,description:A})})).json()).success&&(x(""),w(""),L(""),m(!1),ae())}catch(z){console.error("Error creating GitHub credential:",z)}},he=async z=>{if(confirm(e("apiKeys.github.confirmDelete")))try{await ee(`/api/settings/credentials/${z}`,{method:"DELETE"}),ae()}catch(_){console.error("Error deleting GitHub credential:",_)}},Se=async(z,_)=>{try{await ee(`/api/settings/credentials/${z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!_})}),ae()}catch(N){console.error("Error toggling GitHub credential:",N)}},B=(z,_)=>{navigator.clipboard.writeText(z),b(_),setTimeout(()=>b(null),2e3)};return a?t.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):t.jsxs("div",{className:"space-y-8",children:[I&&t.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[t.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:e("apiKeys.newKey.alertTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e("apiKeys.newKey.alertMessage")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:I.apiKey}),t.jsx(_e,{size:"sm",variant:"outline",onClick:()=>B(I.apiKey,"new"),children:D==="new"?t.jsx(Gt,{className:"h-4 w-4"}):t.jsx(Jm,{className:"h-4 w-4"})})]}),t.jsx(_e,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>G(null),children:e("apiKeys.newKey.iveSavedIt")})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ai,{className:"h-5 w-5"}),t.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),t.jsxs(_e,{size:"sm",onClick:()=>d(!c),children:[t.jsx(ln,{className:"h-4 w-4 mr-1"}),e("apiKeys.newButton")]})]}),t.jsxs("div",{className:"mb-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e("apiKeys.description")}),t.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"),t.jsx(ja,{className:"h-3 w-3"})]})]}),c&&t.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[t.jsx(gt,{placeholder:e("apiKeys.form.placeholder"),value:p,onChange:z=>h(z.target.value),className:"mb-2"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(_e,{onClick:R,children:e("apiKeys.form.createButton")}),t.jsx(_e,{variant:"outline",onClick:()=>d(!1),children:e("apiKeys.form.cancelButton")})]})]}),t.jsx("div",{className:"space-y-2",children:r.length===0?t.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.empty")}):r.map(z=>t.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium",children:z.key_name}),t.jsx("code",{className:"text-xs text-muted-foreground",children:z.api_key}),t.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.list.created")," ",new Date(z.created_at).toLocaleDateString(),z.last_used&&` • ${e("apiKeys.list.lastUsed")} ${new Date(z.last_used).toLocaleDateString()}`]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{size:"sm",variant:z.is_active?"outline":"secondary",onClick:()=>de(z.id,z.is_active),children:z.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),t.jsx(_e,{size:"sm",variant:"ghost",onClick:()=>q(z.id),children:t.jsx(ir,{className:"h-4 w-4"})})]})]},z.id))})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Cf,{className:"h-5 w-5"}),t.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.github.title")})]}),t.jsxs(_e,{size:"sm",onClick:()=>m(!u),children:[t.jsx(ln,{className:"h-4 w-4 mr-1"}),e("apiKeys.github.addButton")]})]}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:e("apiKeys.github.descriptionAlt")}),u&&t.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[t.jsx(gt,{placeholder:e("apiKeys.github.form.namePlaceholder"),value:g,onChange:z=>x(z.target.value)}),t.jsxs("div",{className:"relative",children:[t.jsx(gt,{type:j.new?"text":"password",placeholder:e("apiKeys.github.form.tokenPlaceholder"),value:k,onChange:z=>w(z.target.value),className:"pr-10"}),t.jsx("button",{type:"button",onClick:()=>S({...j,new:!j.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:j.new?t.jsx($c,{className:"h-4 w-4"}):t.jsx(si,{className:"h-4 w-4"})})]}),t.jsx(gt,{placeholder:e("apiKeys.github.form.descriptionPlaceholder"),value:A,onChange:z=>L(z.target.value)}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(_e,{onClick:se,children:e("apiKeys.github.form.addButton")}),t.jsx(_e,{variant:"outline",onClick:()=>{m(!1),x(""),w(""),L("")},children:e("apiKeys.github.form.cancelButton")})]}),t.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:e("apiKeys.github.form.howToCreate")})]}),t.jsx("div",{className:"space-y-2",children:s.length===0?t.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.github.empty")}):s.map(z=>t.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium",children:z.credential_name}),z.description&&t.jsx("div",{className:"text-xs text-muted-foreground",children:z.description}),t.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.github.added")," ",new Date(z.created_at).toLocaleDateString()]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{size:"sm",variant:z.is_active?"outline":"secondary",onClick:()=>Se(z.id,z.is_active),children:z.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),t.jsx(_e,{size:"sm",variant:"ghost",onClick:()=>he(z.id),children:t.jsx(ir,{className:"h-4 w-4"})})]})]},z.id))})]}),t.jsx("div",{className:"pt-6 border-t border-border/50",children:t.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[t.jsxs("a",{href:ve?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",sp]}),P&&V&&t.jsxs("a",{href:ve?.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:[t.jsx("span",{className:"text-[10px]",children:e("apiKeys.version.updateAvailable",{version:V})}),t.jsx(ja,{className:"h-2.5 w-2.5"})]})]})})]})}function Zb(){const{t:e}=Lt("settings"),[r,n]=i.useState(""),[s,o]=i.useState(""),[a,l]=i.useState(!1),[c,d]=i.useState(!1),[u,m]=i.useState(null);i.useEffect(()=>{p()},[]);const p=async()=>{try{l(!0);const g=await ee("/api/user/git-config");if(g.ok){const x=await g.json();n(x.gitName||""),o(x.gitEmail||"")}}catch(g){console.error("Error loading git config:",g)}finally{l(!1)}},h=async()=>{try{d(!0);const g=await ee("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:s})});if(g.ok)m("success"),setTimeout(()=>m(null),3e3);else{const x=await g.json();m("error"),console.error("Failed to save git config:",x.error)}}catch(g){console.error("Error saving git config:",g),m("error")}finally{d(!1)}};return t.jsx("div",{className:"space-y-8",children:t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx(Kr,{className:"h-5 w-5"}),t.jsx("h3",{className:"text-lg font-semibold",children:e("git.title")})]}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:e("git.description")}),t.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:e("git.name.label")}),t.jsx(gt,{id:"settings-git-name",type:"text",value:r,onChange:g=>n(g.target.value),placeholder:"John Doe",disabled:a,className:"w-full"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e("git.name.help")})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:e("git.email.label")}),t.jsx(gt,{id:"settings-git-email",type:"email",value:s,onChange:g=>o(g.target.value),placeholder:"john@example.com",disabled:a,className:"w-full"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e("git.email.help")})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{onClick:h,disabled:c||!r||!s,children:e(c?"git.actions.saving":"git.actions.save")}),u==="success"&&t.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[t.jsx(Gt,{className:"w-4 h-4"}),e("git.status.success")]})]})]})]})})}const ew=["claude","cursor","codex","gemini","opencode"],Ec=["lark","dingtalk"],Ic={lark:{appId:"",appSecret:"",hasAppSecret:!1,encryptKey:"",verificationToken:"",hasEncryptKey:!1,hasVerificationToken:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""},dingtalk:{clientId:"",clientSecret:"",hasClientSecret:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""}},va={running:!1,status:"stopped",error:null};function tw({projects:e=[]}){const{t:r}=Lt("settings"),[n,s]=i.useState("lark"),[o,a]=i.useState(Ic),[l,c]=i.useState({lark:{...va},dingtalk:{...va}}),[d,u]=i.useState({lark:[],dingtalk:[]}),[m,p]=i.useState(!1),[h,g]=i.useState(!1),[x,k]=i.useState(!1),[w,A]=i.useState(!1),[L,j]=i.useState(null),[S,D]=i.useState(null),[b,I]=i.useState({userId:"",displayName:"",note:""}),G=i.useMemo(()=>e.map(N=>({label:N.displayName||N.name||N.path||N.fullPath,value:N.path||N.fullPath||""})).filter(N=>N.value),[e]),P=o[n]||Ic[n],V=l[n]||va,ve=d[n]||[],ae=async(N,O=!1)=>{O||D(null);const[ne,Ce,be]=await Promise.all([ee(`/api/channels/${N}/config`),ee(`/api/channels/${N}/status`),ee(`/api/channels/${N}/allowed-users`)]),re=await ne.json(),Ee=await Ce.json(),nt=await be.json();re?.success&&re?.config&&a(De=>({...De,[N]:{...De[N],...re.config}})),Ee?.success&&Ee?.status&&c(De=>({...De,[N]:Ee.status})),nt?.success&&u(De=>({...De,[N]:nt.users||[]}))},R=async(N=!1)=>{p(!0);try{await Promise.all(Ec.map(O=>ae(O,N)))}catch(O){D(O.message||r("channels.errors.loadFailed","加载渠道设置失败"))}finally{p(!1)}};i.useEffect(()=>{R()},[]);const q=N=>{a(O=>({...O,[n]:{...O[n],...N}}))},de=async()=>{p(!0),j(null),D(null);try{const N=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},O=await ee(`/api/channels/${n}/config`,{method:"PUT",body:JSON.stringify(N)}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||r("channels.errors.saveFailed","保存失败"));q(n==="dingtalk"?{...ne.config,clientSecret:""}:{...ne.config,appSecret:"",encryptKey:"",verificationToken:""}),j(r(`channels.messages.${n}.configSaved`,n==="dingtalk"?"DingTalk 配置已保存":"Lark 配置已保存")),await ae(n,!0)}catch(N){D(N.message||r("channels.errors.saveFailed","保存失败"))}finally{p(!1)}},se=async()=>{if(n==="dingtalk"){const N=String(P.clientId||"").trim(),O=String(P.clientSecret||"").trim();if(!N||!O&&!P.hasClientSecret){D(r("channels.errors.testNeedCredentialsDingTalk","测试连接需要填写 Client ID 和 Client Secret"));return}}else{const N=String(P.appId||"").trim(),O=String(P.appSecret||"").trim();if(!N||!O&&!P.hasAppSecret){D(r("channels.errors.testNeedCredentials","测试连接需要填写 App ID 和 App Secret"));return}}g(!0),D(null),j(null);try{const N=await ee(`/api/channels/${n}/test`,{method:"POST",body:JSON.stringify(n==="dingtalk"?{clientId:P.clientId,clientSecret:P.clientSecret}:{appId:P.appId,appSecret:P.appSecret})}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||r("channels.errors.testFailed","连接测试失败"));j(r(`channels.messages.${n}.testSuccess`,n==="dingtalk"?"DingTalk 连接测试成功":"Lark 连接测试成功"))}catch(N){D(N.message||r("channels.errors.testFailed","连接测试失败"))}finally{g(!1)}},he=async()=>{k(!0),D(null),j(null);try{const N=await ee(`/api/channels/${n}/start`,{method:"POST"}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||r("channels.errors.startFailed","启动失败"));c(ne=>({...ne,[n]:O.status||ne[n]})),j(r(`channels.messages.${n}.started`,n==="dingtalk"?"DingTalk 已启动":"Lark 已启动")),await ae(n,!0)}catch(N){D(N.message||r("channels.errors.startFailed","启动失败"))}finally{k(!1)}},Se=async()=>{A(!0),D(null),j(null);try{const N=await ee(`/api/channels/${n}/stop`,{method:"POST"}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||r("channels.errors.stopFailed","停止失败"));c(ne=>({...ne,[n]:O.status||ne[n]})),j(r(`channels.messages.${n}.stopped`,n==="dingtalk"?"DingTalk 已停止":"Lark 已停止")),await ae(n,!0)}catch(N){D(N.message||r("channels.errors.stopFailed","停止失败"))}finally{A(!1)}},B=async()=>{if(!b.userId.trim()){D(r("channels.errors.userIdRequired","请输入用户ID"));return}p(!0),D(null),j(null);try{const O=await ee(`/api/channels/${n}/allowed-users`,{method:"POST",body:JSON.stringify(b)}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||r("channels.errors.addUserFailed","新增用户失败"));I({userId:"",displayName:"",note:""}),j(r("channels.messages.userAdded","用户已添加")),await ae(n,!0)}catch(O){D(O.message||r("channels.errors.addUserFailed","新增用户失败"))}finally{p(!1)}},z=async N=>{p(!0),D(null);try{const O=await ee(`/api/channels/${n}/allowed-users/${N.id}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!N.isActive})}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||r("channels.errors.toggleUserFailed","更新用户状态失败"));await ae(n,!0)}catch(O){D(O.message||r("channels.errors.toggleUserFailed","更新用户状态失败"))}finally{p(!1)}},_=async N=>{if(window.confirm(r("channels.confirmDeleteUser","确定要删除这个用户ID吗?"))){p(!0),D(null);try{const O=await ee(`/api/channels/${n}/allowed-users/${N}`,{method:"DELETE"}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||r("channels.errors.deleteUserFailed","删除用户失败"));await ae(n,!0)}catch(O){D(O.message||r("channels.errors.deleteUserFailed","删除用户失败"))}finally{p(!1)}}};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:r("channels.title","第三方 IM")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:r(`channels.platformDescriptions.${n}`,n==="dingtalk"?"配置 DingTalk 机器人连接、默认执行环境,并通过用户ID白名单控制访问。":"配置飞书机器人连接、默认执行环境,并通过用户ID白名单控制访问。")})]}),t.jsx("div",{className:"border-b border-border",children:t.jsx("div",{className:"flex items-end gap-1 -mb-px",role:"tablist","aria-label":r("channels.title","第三方 IM"),children:Ec.map(N=>{const O=N===n;return t.jsx("button",{type:"button",role:"tab","aria-selected":O,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 ${O?"border-primary text-primary bg-primary/5":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,onClick:()=>{s(N),j(null),D(null)},children:r(`channels.platforms.${N}`,N==="dingtalk"?"DingTalk / 钉钉":"Lark / 飞书")},N)})})}),(L||S)&&t.jsx("div",{className:`rounded-lg border p-3 text-sm ${S?"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:S||L}),t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[t.jsx("h4",{className:"font-medium text-foreground",children:r("channels.connection.title","连接配置")}),n==="dingtalk"?t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"Client ID"}),t.jsx(gt,{value:P.clientId,onChange:N=>q({clientId:N.target.value}),placeholder:"dingxxxxxxxx"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"Client Secret"}),t.jsx(gt,{type:"password",value:P.clientSecret,onChange:N=>q({clientSecret:N.target.value}),placeholder:P.hasClientSecret?"••••••••(已保存)":"输入 Client Secret"})]})]}):t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"App ID"}),t.jsx(gt,{value:P.appId,onChange:N=>q({appId:N.target.value}),placeholder:"cli_xxx"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"App Secret"}),t.jsx(gt,{type:"password",value:P.appSecret,onChange:N=>q({appSecret:N.target.value}),placeholder:P.hasAppSecret?"••••••••(已保存)":"输入 App Secret"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:r("channels.defaults.backend","默认后端")}),t.jsx("select",{value:P.defaultBackend,onChange:N=>q({defaultBackend:N.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:ew.map(N=>t.jsx("option",{value:N,children:N},N))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:r("channels.defaults.project","默认项目")}),t.jsxs("select",{value:P.defaultProjectPath,onChange:N=>q({defaultProjectPath:N.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:[t.jsx("option",{value:"",children:r("channels.defaults.projectPlaceholder","请选择项目")}),G.map(N=>t.jsx("option",{value:N.value,children:N.label},N.value))]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{onClick:de,disabled:m,children:r("channels.actions.saveConfig","保存配置")}),t.jsx(_e,{variant:"outline",onClick:se,disabled:h,children:h?r("channels.actions.testing","测试中..."):r("channels.actions.test","测试连接")})]})]}),t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[t.jsx("h4",{className:"font-medium text-foreground",children:r("channels.runtime.title","运行状态")}),t.jsxs("div",{className:"text-sm text-muted-foreground",children:[r("channels.runtime.currentStatus","当前状态"),": ",t.jsx("span",{className:"font-medium text-foreground",children:V.status||"stopped"}),V.error?t.jsx("span",{className:"text-red-500 ml-2",children:V.error}):null]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{onClick:he,disabled:x||V.running,children:x?r("channels.actions.starting","启动中..."):r("channels.actions.start","启动")}),t.jsx(_e,{variant:"outline",onClick:Se,disabled:w||!V.running,children:w?r("channels.actions.stopping","停止中..."):r("channels.actions.stop","停止")}),t.jsx(_e,{variant:"ghost",onClick:()=>void ae(n),disabled:m,children:r("channels.actions.refresh","刷新")})]})]}),t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[t.jsx("h4",{className:"font-medium text-foreground",children:r("channels.allowedUsers.title","允许用户ID(白名单)")}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-2",children:[t.jsx(gt,{placeholder:r("channels.allowedUsers.userId","用户ID"),value:b.userId,onChange:N=>I(O=>({...O,userId:N.target.value}))}),t.jsx(gt,{placeholder:r("channels.allowedUsers.displayName","显示名(可选)"),value:b.displayName,onChange:N=>I(O=>({...O,displayName:N.target.value}))}),t.jsx(gt,{placeholder:r("channels.allowedUsers.note","备注(可选)"),value:b.note,onChange:N=>I(O=>({...O,note:N.target.value}))}),t.jsx(_e,{onClick:B,disabled:m,children:r("channels.allowedUsers.add","新增")})]}),t.jsx("div",{className:"space-y-2",children:ve.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:r("channels.allowedUsers.empty","暂无白名单用户")}):ve.map(N=>t.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:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:N.userId}),t.jsxs("div",{className:"text-sm text-muted-foreground",children:[N.displayName||"-",N.note?` · ${N.note}`:""]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`text-xs px-2 py-1 rounded ${N.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:N.isActive?r("channels.allowedUsers.active","启用"):r("channels.allowedUsers.inactive","停用")}),t.jsx(_e,{size:"sm",variant:"outline",onClick:()=>void z(N),children:N.isActive?r("channels.allowedUsers.disable","停用"):r("channels.allowedUsers.enable","启用")}),t.jsx(_e,{size:"sm",variant:"ghost",onClick:()=>void _(N.id),children:r("channels.allowedUsers.delete","删除")})]})]},N.id))})]}),t.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/10 dark:border-primary/40 dark:bg-primary/15 p-4",children:[t.jsx("h5",{className:"font-medium text-foreground mb-2",children:r("channels.help.title","使用说明")}),t.jsxs("ul",{className:"text-sm text-muted-foreground list-disc pl-5 space-y-1",children:[t.jsx("li",{children:r(`channels.help.${n}.step1`,n==="dingtalk"?"未绑定用户给机器人发消息时,机器人会返回该用户的钉钉用户ID。":"未绑定用户给机器人发消息时,机器人会返回该用户的飞书用户ID。")}),t.jsx("li",{children:r(`channels.help.${n}.step2`,"管理员将该ID加入白名单后,用户即可正常对话。")}),t.jsx("li",{children:r(`channels.help.${n}.step3`,"请先配置默认项目,否则机器人不会执行任务。")})]})]})]})}function ap({isOpen:e,onClose:r,provider:n="claude",project:s,onComplete:o,customCommand:a,isAuthenticated:l=!1}){if(!e)return null;const c=()=>{if(a)return a;switch(n){case"claude":return l?"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 l?"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=m=>{o?.(m),m===0&&r()};return t.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:t.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:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:d()}),t.jsx("button",{onClick:r,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:t.jsx(lr,{className:"w-6 h-6"})})]}),t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(tp,{project:s,command:c(),onComplete:u,minimal:!0})})]})})}function ip({compact:e=!1}){const{i18n:r,t:n}=Lt("settings"),s=o=>{const a=o.target.value;r.changeLanguage(a)};return e?t.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:[t.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[t.jsx(zc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),n("account.language")]}),t.jsx("select",{value:r.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:ml.map(o=>t.jsx("option",{value:o.value,children:o.nativeName},o.value))})]}):t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:n("account.languageLabel")}),t.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("account.languageDescription")})]}),t.jsx("select",{value:r.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:ml.map(o=>t.jsx("option",{value:o.value,children:o.nativeName},o.value))})]})})}function rw({isOpen:e,onClose:r,projects:n=[],initialTab:s="appearance"}){const{isDarkMode:o,toggleDarkMode:a}=ei(),{t:l}=Lt("settings"),[c,d]=i.useState([]),[u,m]=i.useState([]),[p,h]=i.useState(""),[g,x]=i.useState(""),[k,w]=i.useState(!1),[A,L]=i.useState(!1),[j,S]=i.useState(null),[D,b]=i.useState("name"),[I,G]=i.useState([]),[P,V]=i.useState(!1),[ve,ae]=i.useState(null),[R,q]=i.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[de,se]=i.useState(!1),[he,Se]=i.useState({}),[B,z]=i.useState({}),[_,N]=i.useState({}),[O,ne]=i.useState(s),[Ce,be]=i.useState(""),re=["appearance","git","api","channels"],[Ee,nt]=i.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[De,fe]=i.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[Ge,bt]=i.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[st,Be]=i.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Ze,xt]=i.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[wt,ye]=i.useState([]),[qe,Nt]=i.useState("default"),[X,Te]=i.useState(!1),[W,Z]=i.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[we,Ae]=i.useState(null),[Xe,Qe]=i.useState(!1),[We,Et]=i.useState(!1),[ie,St]=i.useState(""),[et,ot]=i.useState(null),[Ke,Tt]=i.useState({authenticated:!1,email:null,loading:!0,error:null}),[Ot,yt]=i.useState({authenticated:!1,email:null,loading:!0,error:null}),[At,rr]=i.useState({authenticated:!1,email:null,loading:!0,error:null}),tt=async()=>{try{const $=await ee("/api/codex/mcp/config/read");if($.ok){const le=await $.json();if(le.success&&le.servers){ye(le.servers);return}}const U=await ee("/api/codex/mcp/cli/list");if(U.ok){const le=await U.json();if(le.success&&le.servers){const Oe=le.servers.map(T=>({id:T.name,name:T.name,type:T.type||"stdio",scope:"user",config:{command:T.command||"",args:T.args||[],env:T.env||{}}}));ye(Oe)}}}catch($){console.error("Error fetching Codex MCP servers:",$)}},Ft=async()=>{try{const $=await ee("/api/mcp/config/read");if($.ok){const Oe=await $.json();if(Oe.success&&Oe.servers){G(Oe.servers);return}}const U=await ee("/api/mcp/cli/list");if(U.ok){const Oe=await U.json();if(Oe.success&&Oe.servers){const T=Oe.servers.map(te=>({id:te.name,name:te.name,type:te.type,scope:"user",config:{command:te.command||"",args:te.args||[],env:te.env||{},url:te.url||"",headers:te.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));G(T);return}}const le=await ee("/api/mcp/servers?scope=user");if(le.ok){const Oe=await le.json();G(Oe.servers||[])}else console.error("Failed to fetch MCP servers")}catch($){console.error("Error fetching MCP servers:",$)}},It=async $=>{try{ve&&await $t(ve.id,"user");const U=await ee("/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(U.ok){const le=await U.json();if(le.success)return await Ft(),!0;throw new Error(le.error||"Failed to save server via Claude CLI")}else{const le=await U.json();throw new Error(le.error||"Failed to save server")}}catch(U){throw console.error("Error saving MCP server:",U),U}},$t=async($,U="user")=>{try{const le=await ee(`/api/mcp/cli/remove/${$}?scope=${U}`,{method:"DELETE"});if(le.ok){const Oe=await le.json();if(Oe.success)return await Ft(),!0;throw new Error(Oe.error||"Failed to delete server via Claude CLI")}else{const Oe=await le.json();throw new Error(Oe.error||"Failed to delete server")}}catch(le){throw console.error("Error deleting MCP server:",le),le}},nr=async $=>{try{we&&await Bt(we.id);const U=await ee("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:$.name,command:$.config?.command,args:$.config?.args||[],env:$.config?.env||{}})});if(U.ok){const le=await U.json();if(le.success)return await tt(),!0;throw new Error(le.error||"Failed to save Codex MCP server")}else{const le=await U.json();throw new Error(le.error||"Failed to save server")}}catch(U){throw console.error("Error saving Codex MCP server:",U),U}},Bt=async $=>{try{const U=await ee(`/api/codex/mcp/cli/remove/${$}`,{method:"DELETE"});if(U.ok){const le=await U.json();if(le.success)return await tt(),!0;throw new Error(le.error||"Failed to delete Codex MCP server")}else{const le=await U.json();throw new Error(le.error||"Failed to delete server")}}catch(U){throw console.error("Error deleting Codex MCP server:",U),U}},M=()=>{Z({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),Ae(null),Te(!1)},ge=async $=>{$.preventDefault(),Qe(!0);try{we&&await Bt(we.name),await nr(W),M(),S("success")}catch(U){alert(`Error: ${U.message}`),S("error")}finally{Qe(!1)}};i.useEffect(()=>{e&&(Re(),Q(),C(),F(),ne(re.includes(s)?s:"appearance"))},[e,s]),i.useEffect(()=>{localStorage.setItem("codeEditorTheme",Ee),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ee]),i.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",De.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[De]),i.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",Ge.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ge]),i.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",st.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[st]),i.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Ze),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ze]);const Re=async()=>{try{const $=localStorage.getItem("claude-settings");if($){const le=JSON.parse($);d(le.allowedTools||[]),m(le.disallowedTools||[]),w(le.skipPermissions||!1),b(le.projectSortOrder||"name")}else d([]),m([]),w(!1),b("name");const U=localStorage.getItem("codex-settings");if(U){const le=JSON.parse(U);Nt(le.permissionMode||"default")}else Nt("default");await Ft(),await tt()}catch($){console.error("Error loading tool settings:",$),d([]),m([]),w(!1),b("name")}},Q=async()=>{try{const $=await ee("/api/cli/claude/status");if($.ok){const U=await $.json();Tt({authenticated:U.authenticated,email:U.email,loading:!1,error:U.error||null})}else Tt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch($){console.error("Error checking Claude auth status:",$),Tt({authenticated:!1,email:null,loading:!1,error:$.message})}},C=async()=>{try{const $=await ee("/api/cli/codex/status");if($.ok){const U=await $.json();yt({authenticated:U.authenticated,email:U.email,loading:!1,error:U.error||null})}else yt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch($){console.error("Error checking Codex auth status:",$),yt({authenticated:!1,email:null,loading:!1,error:$.message})}},F=async()=>{try{const $=await ee("/api/cli/gemini/status");if($.ok){const U=await $.json();rr({authenticated:U.authenticated,email:U.email,loading:!1,error:U.error||null})}else rr({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch($){console.error("Error checking Gemini auth status:",$),rr({authenticated:!1,email:null,loading:!1,error:$.message})}},pe=$=>{$===0&&(S("success"),ie==="claude"?Q():ie==="codex"?C():ie==="gemini"&&F())},je=()=>{L(!0),S(null);try{const $={allowedTools:c,disallowedTools:u,skipPermissions:k,projectSortOrder:D,lastUpdated:new Date().toISOString()},U={permissionMode:qe,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify($)),localStorage.setItem("codex-settings",JSON.stringify(U)),S("success"),setTimeout(()=>{r()},1e3)}catch($){console.error("Error saving tool settings:",$),S("error")}finally{L(!1)}},mt=()=>{q({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),ae(null),V(!1),be("")},H=async $=>{$.preventDefault(),se(!0);try{if(R.importMode==="json"){const U=await ee("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:R.name,jsonConfig:R.jsonInput,scope:R.scope,projectPath:R.projectPath})});if(U.ok){const le=await U.json();if(le.success)await Ft(),mt(),S("success");else throw new Error(le.error||"Failed to add server via JSON")}else{const le=await U.json();throw new Error(le.error||"Failed to add server")}}else await It(R),mt(),S("success")}catch(U){alert(`Error: ${U.message}`),S("error")}finally{se(!1)}},_t=($,U)=>{q(le=>({...le,config:{...le.config,[$]:U}}))};return e?t.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[t.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:[t.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Wc,{className:"w-5 h-5 md:w-6 md:h-6 text-primary"}),t.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:l("title")})]}),t.jsx(_e,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:t.jsx(lr,{className:"w-5 h-5"})})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.jsx("div",{className:"border-b border-border",children:t.jsxs("div",{className:"flex px-4 md:px-6",children:[t.jsx("button",{onClick:()=>ne("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="appearance"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:l("mainTabs.appearance")}),t.jsxs("button",{onClick:()=>ne("git"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="git"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[t.jsx(Kr,{className:"w-4 h-4 inline mr-2"}),l("mainTabs.git")]}),t.jsxs("button",{onClick:()=>ne("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="api"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[t.jsx(ai,{className:"w-4 h-4 inline mr-2"}),l("mainTabs.apiTokens")]}),t.jsxs("button",{onClick:()=>ne("channels"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="channels"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[t.jsx(rh,{className:"w-4 h-4 inline mr-2"}),l("mainTabs.channels","Channels")]})]})}),t.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[O==="appearance"&&t.jsx("div",{className:"space-y-6 md:space-y-8",children:O==="appearance"&&t.jsxs("div",{className:"space-y-6 md:space-y-8",children:[t.jsx("div",{className:"space-y-4",children:t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.darkMode.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.darkMode.description")})]}),t.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:[t.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),t.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?t.jsx(Na,{className:"w-3.5 h-3.5 text-gray-700"}):t.jsx(Ca,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),t.jsx("div",{className:"space-y-4",children:t.jsx(ip,{})}),t.jsx("div",{className:"space-y-4",children:t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.projectSorting.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.projectSorting.description")})]}),t.jsxs("select",{value:D,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:[t.jsx("option",{value:"name",children:l("appearanceSettings.projectSorting.alphabetical")}),t.jsx("option",{value:"date",children:l("appearanceSettings.projectSorting.recentActivity")})]})]})})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:l("appearanceSettings.codeEditor.title")}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.theme.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.theme.description")})]}),t.jsxs("button",{onClick:()=>nt(Ee==="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":Ee==="dark","aria-label":"Toggle editor theme",children:[t.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),t.jsx("span",{className:`${Ee==="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:Ee==="dark"?t.jsx(Na,{className:"w-3.5 h-3.5 text-gray-700"}):t.jsx(Ca,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.wordWrap.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.wordWrap.description")})]}),t.jsxs("button",{onClick:()=>fe(!De),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":De,"aria-label":"Toggle word wrap",children:[t.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),t.jsx("span",{className:`${De?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.showMinimap.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.showMinimap.description")})]}),t.jsxs("button",{onClick:()=>bt(!Ge),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":Ge,"aria-label":"Toggle minimap",children:[t.jsx("span",{className:"sr-only",children:"Toggle minimap"}),t.jsx("span",{className:`${Ge?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.lineNumbers.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.lineNumbers.description")})]}),t.jsxs("button",{onClick:()=>Be(!st),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":st,"aria-label":"Toggle line numbers",children:[t.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),t.jsx("span",{className:`${st?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.fontSize.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.fontSize.description")})]}),t.jsxs("select",{value:Ze,onChange:$=>xt($.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:[t.jsx("option",{value:"10",children:"10px"}),t.jsx("option",{value:"11",children:"11px"}),t.jsx("option",{value:"12",children:"12px"}),t.jsx("option",{value:"13",children:"13px"}),t.jsx("option",{value:"14",children:"14px"}),t.jsx("option",{value:"15",children:"15px"}),t.jsx("option",{value:"16",children:"16px"}),t.jsx("option",{value:"18",children:"18px"}),t.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),O==="git"&&t.jsx(Zb,{}),P&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:t.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[t.jsx("h3",{className:"text-lg font-medium text-foreground",children:l(ve?"mcpForm.title.edit":"mcpForm.title.add")}),t.jsx(_e,{variant:"ghost",size:"sm",onClick:mt,children:t.jsx(lr,{className:"w-4 h-4"})})]}),t.jsxs("form",{onSubmit:H,className:"p-4 space-y-4",children:[!ve&&t.jsxs("div",{className:"flex gap-2 mb-4",children:[t.jsx("button",{type:"button",onClick:()=>q($=>({...$,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${R.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:l("mcpForm.importMode.form")}),t.jsx("button",{type:"button",onClick:()=>q($=>({...$,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${R.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:l("mcpForm.importMode.json")})]}),R.importMode==="form"&&ve&&t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[t.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:l("mcpForm.scope.label")}),t.jsxs("div",{className:"flex items-center gap-2",children:[R.scope==="user"?t.jsx(fl,{className:"w-4 h-4"}):t.jsx(on,{className:"w-4 h-4"}),t.jsx("span",{className:"text-sm",children:R.scope==="user"?l("mcpForm.scope.userGlobal"):l("mcpForm.scope.projectLocal")}),R.scope==="local"&&R.projectPath&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",R.projectPath]})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:l("mcpForm.scope.cannotChange")})]}),R.importMode==="form"&&!ve&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.scope.label")," *"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:()=>q($=>({...$,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${R.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:t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(fl,{className:"w-4 h-4"}),t.jsx("span",{children:l("mcpForm.scope.userGlobal")})]})}),t.jsx("button",{type:"button",onClick:()=>q($=>({...$,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${R.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:t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(on,{className:"w-4 h-4"}),t.jsx("span",{children:l("mcpForm.scope.projectLocal")})]})})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:R.scope==="user"?l("mcpForm.scope.userDescription"):l("mcpForm.scope.projectDescription")})]}),R.scope==="local"&&!ve&&t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.selectProject")," *"]}),t.jsxs("select",{value:R.projectPath,onChange:$=>q(U=>({...U,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:R.scope==="local",children:[t.jsxs("option",{value:"",children:[l("mcpForm.fields.selectProject"),"..."]}),n.map($=>t.jsx("option",{value:$.path||$.fullPath,children:$.displayName||$.name},$.name))]}),R.projectPath&&t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:l("mcpForm.projectPath",{path:R.projectPath})})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{className:R.importMode==="json"?"md:col-span-2":"",children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.serverName")," *"]}),t.jsx(gt,{value:R.name,onChange:$=>{q(U=>({...U,name:$.target.value}))},placeholder:l("mcpForm.placeholders.serverName"),required:!0})]}),R.importMode==="form"&&t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.transportType")," *"]}),t.jsxs("select",{value:R.type,onChange:$=>{q(U=>({...U,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:[t.jsx("option",{value:"stdio",children:"stdio"}),t.jsx("option",{value:"sse",children:"SSE"}),t.jsx("option",{value:"http",children:"HTTP"})]})]})]}),ve&&R.raw&&R.importMode==="form"&&t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[t.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:l("mcpForm.configDetails",{configFile:ve.scope==="global"?"~/.claude.json":"project config"})}),t.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(R.raw,null,2)})]}),R.importMode==="json"&&t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.jsonConfig")," *"]}),t.jsx("textarea",{value:R.jsonInput,onChange:$=>{q(U=>({...U,jsonInput:$.target.value}));try{if($.target.value.trim()){const U=JSON.parse($.target.value);U.type?U.type==="stdio"&&!U.command?be(l("mcpForm.validation.stdioRequiresCommand")):(U.type==="http"||U.type==="sse")&&!U.url?be(l("mcpForm.validation.httpRequiresUrl",{type:U.type})):be(""):be(l("mcpForm.validation.missingType"))}}catch{$.target.value.trim()?be(l("mcpForm.validation.invalidJson")):be("")}},className:`w-full px-3 py-2 border ${Ce?"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:`{
472
- "type": "stdio",
473
- "command": "/path/to/server",
474
- "args": ["--api-key", "abc123"],
475
- "env": {
476
- "CACHE_DIR": "/tmp"
477
- }
478
- }`,required:!0}),Ce&&t.jsx("p",{className:"text-xs text-red-500 mt-1",children:Ce}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[l("mcpForm.validation.jsonHelp"),t.jsx("br",{}),"• stdio: ",'{"type":"stdio","command":"npx","args":["@upstash/context7-mcp"]}',t.jsx("br",{}),"• http/sse: ",'{"type":"http","url":"https://api.example.com/mcp"}']})]})}),R.importMode==="form"&&R.type==="stdio"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.command")," *"]}),t.jsx(gt,{value:R.config.command,onChange:$=>_t("command",$.target.value),placeholder:"/path/to/mcp-server",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:l("mcpForm.fields.arguments")}),t.jsx("textarea",{value:Array.isArray(R.config.args)?R.config.args.join(`
479
- `):"",onChange:$=>_t("args",$.target.value.split(`
480
- `).filter(U=>U.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
481
- abc123`})]})]}),R.importMode==="form"&&(R.type==="sse"||R.type==="http")&&t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.url")," *"]}),t.jsx(gt,{value:R.config.url,onChange:$=>_t("url",$.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),R.importMode==="form"&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:l("mcpForm.fields.envVars")}),t.jsx("textarea",{value:Object.entries(R.config.env||{}).map(([$,U])=>`${$}=${U}`).join(`
482
- `),onChange:$=>{const U={};$.target.value.split(`
483
- `).forEach(le=>{const[Oe,...T]=le.split("=");Oe&&Oe.trim()&&(U[Oe.trim()]=T.join("=").trim())}),_t("env",U)},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
484
- DEBUG=true`})]}),R.importMode==="form"&&(R.type==="sse"||R.type==="http")&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:l("mcpForm.fields.headers")}),t.jsx("textarea",{value:Object.entries(R.config.headers||{}).map(([$,U])=>`${$}=${U}`).join(`
485
- `),onChange:$=>{const U={};$.target.value.split(`
486
- `).forEach(le=>{const[Oe,...T]=le.split("=");Oe&&Oe.trim()&&(U[Oe.trim()]=T.join("=").trim())}),_t("headers",U)},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
487
- X-API-Key=your-key`})]}),t.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[t.jsx(_e,{type:"button",variant:"outline",onClick:mt,children:l("mcpForm.actions.cancel")}),t.jsx(_e,{type:"submit",disabled:de,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:l(de?"mcpForm.actions.saving":ve?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),X&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:t.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[t.jsx("h3",{className:"text-lg font-medium text-foreground",children:l(we?"mcpForm.title.edit":"mcpForm.title.add")}),t.jsx(_e,{variant:"ghost",size:"sm",onClick:M,children:t.jsx(lr,{className:"w-4 h-4"})})]}),t.jsxs("form",{onSubmit:ge,className:"p-4 space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.serverName")," *"]}),t.jsx(gt,{value:W.name,onChange:$=>Z(U=>({...U,name:$.target.value})),placeholder:l("mcpForm.placeholders.serverName"),required:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.command")," *"]}),t.jsx(gt,{value:W.config?.command||"",onChange:$=>Z(U=>({...U,config:{...U.config,command:$.target.value}})),placeholder:"npx @my-org/mcp-server",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:l("mcpForm.fields.arguments")}),t.jsx("textarea",{value:(W.config?.args||[]).join(`
488
- `),onChange:$=>Z(U=>({...U,config:{...U.config,args:$.target.value.split(`
489
- `).filter(le=>le.trim())}})),placeholder:`--port
490
- 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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:l("mcpForm.fields.envVars")}),t.jsx("textarea",{value:Object.entries(W.config?.env||{}).map(([$,U])=>`${$}=${U}`).join(`
491
- `),onChange:$=>{const U={};$.target.value.split(`
492
- `).forEach(le=>{const[Oe,...T]=le.split("=");Oe&&T.length>0&&(U[Oe.trim()]=T.join("=").trim())}),Z(le=>({...le,config:{...le.config,env:U}}))},placeholder:`API_KEY=xxx
493
- 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"})]}),t.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border",children:[t.jsx(_e,{type:"button",variant:"outline",onClick:M,children:l("mcpForm.actions.cancel")}),t.jsx(_e,{type:"submit",disabled:Xe||!W.name||!W.config?.command,className:"bg-green-600 hover:bg-green-700 text-white",children:l(Xe?"mcpForm.actions.saving":we?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),O==="api"&&t.jsx("div",{className:"space-y-6 md:space-y-8",children:t.jsx(Qb,{})}),O==="channels"&&t.jsx("div",{className:"space-y-6 md:space-y-8",children:t.jsx(tw,{projects:n})})]})]}),t.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:[t.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:[j==="success"&&t.jsxs("div",{className:"text-green-600 dark:text-green-400 text-sm flex items-center gap-1",children:[t.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})}),l("saveStatus.success")]}),j==="error"&&t.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[t.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})}),l("saveStatus.error")]})]}),t.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[t.jsx(_e,{variant:"outline",onClick:r,disabled:A,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:l("footerActions.cancel")}),O!=="channels"&&t.jsx(_e,{onClick:je,disabled:A,className:"flex-1 sm:flex-none h-10 bg-primary hover:bg-primary/90 disabled:opacity-50 touch-manipulation",children:A?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-4 h-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),l("saveStatus.saving")]}):l("footerActions.save")})]})]})]}),t.jsx(ap,{isOpen:We,onClose:()=>Et(!1),provider:ie,project:et,onComplete:pe,isAuthenticated:ie==="claude"?Ke.authenticated:ie==="codex"?Ot.authenticated:!1},ie)]}):null}const nw=({isOpen:e,onToggle:r,autoExpandTools:n,onAutoExpandChange:s,showRawParameters:o,onShowRawParametersChange:a,showThinking:l,onShowThinkingChange:c,autoScrollToBottom:d,onAutoScrollChange:u,sendByCtrlEnter:m,onSendByCtrlEnterChange:p,isMobile:h})=>{const{t:g}=Lt("settings"),[x,k]=i.useState(e),[w,A]=i.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:L}=ei(),[j,S]=i.useState(()=>{const _=localStorage.getItem("quickSettingsHandlePosition");if(_)try{return JSON.parse(_).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[D,b]=i.useState(!1),[I,G]=i.useState(0),[P,V]=i.useState(0),[ve,ae]=i.useState(!1),R=i.useRef(null),q=i.useRef({min:10,max:90}),de=5;i.useEffect(()=>{k(e)},[e]),i.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:j}))},[j]);const se=i.useCallback(()=>h?{bottom:`${window.innerHeight*j/100}px`}:{top:`${j}%`,transform:"translateY(-50%)"},[j,h]),he=i.useCallback(_=>{_.stopPropagation();const N=_.type.includes("touch")?_.touches[0].clientY:_.clientY;G(N),V(j),ae(!1),b(!1)},[j]),Se=i.useCallback(_=>{if(I===0)return;const N=_.type.includes("touch")?_.touches[0].clientY:_.clientY,O=Math.abs(N-I);if(!D&&O>de&&(b(!0),ae(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",_.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!D)return;_.type.includes("touch")&&_.preventDefault();const ne=N-I;let Ce;h?Ce=-(ne/window.innerHeight)*100:Ce=ne/window.innerHeight*100;let be=P+Ce;be=Math.max(q.current.min,Math.min(q.current.max,be)),S(be)},[D,I,P,h,de]),B=i.useCallback(()=>{b(!1),G(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);i.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),i.useEffect(()=>{if(I!==0){const _=Ce=>Se(Ce),N=()=>B(),O=Ce=>Se(Ce),ne=()=>B();return document.addEventListener("mousemove",_),document.addEventListener("mouseup",N),document.addEventListener("touchmove",O,{passive:!1}),document.addEventListener("touchend",ne),()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",N),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",ne)}}},[I,Se,B]);const z=_=>{if(ve){_.preventDefault(),ae(!1);return}const N=!x;k(N),r(N)};return t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:R,onClick:z,onMouseDown:_=>{he(_)},onTouchStart:_=>{he(_)},className:`fixed ${x?"right-64":"right-0"} z-50 ${D?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${D?"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 ${D?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...se(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":g(D?"quickSettings.dragHandle.dragging":x?"quickSettings.dragHandle.closePanel":"quickSettings.dragHandle.openPanel"),title:g(D?"quickSettings.dragHandle.draggingStatus":"quickSettings.dragHandle.toggleAndMove"),children:D?t.jsx(Tf,{className:"h-5 w-5 text-primary"}):x?t.jsx(sn,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):t.jsx(ni,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),t.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:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:t.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx(oh,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),g("quickSettings.title")]})}),t.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${h?"pb-mobile-nav":""}`,children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.appearance")}),t.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:[t.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[L?t.jsx(Na,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):t.jsx(Ca,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.darkMode")]}),t.jsx(Ym,{})]}),t.jsx("div",{children:t.jsx(ip,{compact:!0})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.toolDisplay")}),t.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:[t.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[t.jsx(Bc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.autoExpandTools")]}),t.jsx("input",{type:"checkbox",checked:n,onChange:_=>s(_.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"})]}),t.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:[t.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[t.jsx(si,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.showRawParameters")]}),t.jsx("input",{type:"checkbox",checked:o,onChange:_=>a(_.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"})]}),t.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:[t.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[t.jsx(Fc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.showThinking")]}),t.jsx("input",{type:"checkbox",checked:l,onChange:_=>c(_.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"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.viewOptions")}),t.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:[t.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[t.jsx(of,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.autoScrollToBottom")]}),t.jsx("input",{type:"checkbox",checked:d,onChange:_=>u(_.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"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.inputSettings")}),t.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:[t.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[t.jsx(zc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.sendByCtrlEnter")]}),t.jsx("input",{type:"checkbox",checked:m,onChange:_=>p(_.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"})]}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 ml-3",children:g("quickSettings.sendByCtrlEnterDescription")})]}),t.jsxs("div",{className:"space-y-2",style:{display:"none"},children:[t.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.whisperDictation")}),t.jsxs("div",{className:"space-y-2",children:[t.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:[t.jsx("input",{type:"radio",name:"whisperMode",value:"default",checked:w==="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"}),t.jsxs("div",{className:"ml-3 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[t.jsx(Bs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.whisper.modes.default")]}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:g("quickSettings.whisper.modes.defaultDescription")})]})]}),t.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:[t.jsx("input",{type:"radio",name:"whisperMode",value:"prompt",checked:w==="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"}),t.jsxs("div",{className:"ml-3 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[t.jsx(ri,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.whisper.modes.prompt")]}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:g("quickSettings.whisper.modes.promptDescription")})]})]}),t.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:[t.jsx("input",{type:"radio",name:"whisperMode",value:"vibe",checked:w==="vibe"||w==="instructions"||w==="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"}),t.jsxs("div",{className:"ml-3 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[t.jsx(oi,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.whisper.modes.vibe")]}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:g("quickSettings.whisper.modes.vibeDescription")})]})]})]})]})]})]})}),x&&t.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:z})]})},lp=i.createContext({user:null,token:null,login:()=>{},register:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,hasCompletedOnboarding:!0,refreshOnboardingStatus:()=>{},error:null}),os=()=>{const e=i.useContext(lp);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},sw=({children:e})=>{const[r,n]=i.useState(null),[s,o]=i.useState(localStorage.getItem("auth-token")),[a,l]=i.useState(!0),[c,d]=i.useState(!1),[u,m]=i.useState(!0),[p,h]=i.useState(null);i.useEffect(()=>{k()},[]);const g=async()=>{try{const S=await pt.user.onboardingStatus();if(S.ok){const D=await S.json();m(D.hasCompletedOnboarding)}}catch(S){console.error("Error checking onboarding status:",S),m(!0)}},x=async()=>{await g()},k=async()=>{try{if(l(!0),h(null),(await(await pt.auth.status()).json()).needsSetup){d(!0),l(!1);return}if(s)try{const b=await pt.auth.user();if(b.ok){const I=await b.json();n(I.user),d(!1),await g()}else localStorage.removeItem("auth-token"),o(null),n(null)}catch(b){console.error("Token verification failed:",b),localStorage.removeItem("auth-token"),o(null),n(null)}}catch(S){console.error("[AuthContext] Auth status check failed:",S),h("Failed to check authentication status")}finally{l(!1)}},j={user:r,token:s,login:async(S,D)=>{try{h(null);const b=await pt.auth.login(S,D),I=await b.json();return b.ok?(o(I.token),n(I.user),localStorage.setItem("auth-token",I.token),{success:!0}):(h(I.error||"Login failed"),{success:!1,error:I.error||"Login failed"})}catch(b){console.error("Login error:",b);const I="Network error. Please try again.";return h(I),{success:!1,error:I}}},register:async(S,D)=>{try{h(null);const b=await pt.auth.register(S,D),I=await b.json();return b.ok?(o(I.token),n(I.user),d(!1),localStorage.setItem("auth-token",I.token),{success:!0}):(h(I.error||"Registration failed"),{success:!1,error:I.error||"Registration failed"})}catch(b){console.error("Registration error:",b);const I="Network error. Please try again.";return h(I),{success:!1,error:I}}},logout:()=>{o(null),n(null),localStorage.removeItem("auth-token"),s&&pt.auth.logout().catch(S=>{console.error("Logout endpoint error:",S)})},isLoading:a,needsSetup:c,hasCompletedOnboarding:u,refreshOnboardingStatus:x,error:p};return t.jsx(lp.Provider,{value:j,children:e})},cp=i.createContext(null),ow=()=>{const e=i.useContext(cp);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},aw=e=>{const r=window.location.protocol==="https:"?"wss:":"ws:";return e?`${r}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},iw=()=>{const e=i.useRef(null),r=i.useRef(!1),[n,s]=i.useState(null),[o,a]=i.useState(!1),l=i.useRef(null),c=i.useRef(!1),d=i.useRef([]),u=i.useRef([]),m=i.useRef(null),p=i.useRef(0),{token:h}=os(),g=i.useCallback(()=>{if(m.current||r.current)return;const b=()=>{if(m.current=null,r.current){u.current=[];return}const I=u.current.shift();I&&(p.current+=1,s({...I,__messageSeq:p.current}),u.current.length>0&&(m.current=setTimeout(b,0)))};m.current=setTimeout(b,0)},[]),x=i.useCallback(b=>{u.current.push(b),g()},[g]),k=i.useCallback((b,I)=>{x({type:"connection-error",error:I,provider:b?.provider||(typeof b?.type=="string"?b.type.replace(/-command$/,""):"claude"),sessionId:b?.sessionId||b?.options?.sessionId||null,clientRequestId:b?.clientRequestId||null})},[x]),w=i.useCallback(b=>{b.timeoutId&&(clearTimeout(b.timeoutId),b.timeoutId=null)},[]),A=i.useCallback(b=>{if(b.readyState!==WebSocket.OPEN)return;d.current.splice(0,d.current.length).forEach(G=>{w(G),b.send(JSON.stringify(G.payload))})},[w]),L=i.useCallback(b=>{if(!b||typeof b!="object"||b.clientRequestId)return b;const I=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`;return{...b,clientRequestId:I}},[]),j=i.useCallback(()=>{if(r.current||c.current)return;const b=e.current;if(!(b&&(b.readyState===WebSocket.OPEN||b.readyState===WebSocket.CONNECTING)))try{const I=aw(h);if(!I){d.current.splice(0,d.current.length).forEach(V=>{w(V),k(V.payload,"No authentication token found for WebSocket connection")});return}c.current=!0;const G=new WebSocket(I);e.current=G,G.onopen=()=>{c.current=!1,a(!0),e.current=G,x({type:"ws-connection-state",state:"connected"}),A(G)},G.onmessage=P=>{try{const V=JSON.parse(P.data);x(V)}catch(V){console.error("Error parsing WebSocket message:",V)}},G.onclose=()=>{c.current=!1,a(!1),e.current===G&&(e.current=null),x({type:"ws-connection-state",state:"disconnected"}),l.current=setTimeout(()=>{r.current||j()},3e3)},G.onerror=P=>{console.error("WebSocket error:",P)}}catch(I){c.current=!1,console.error("Error creating WebSocket connection:",I)}},[w,k,A,h]);i.useEffect(()=>(r.current=!1,j(),()=>{c.current=!1,l.current&&clearTimeout(l.current),m.current&&(clearTimeout(m.current),m.current=null),u.current=[],e.current&&(e.current.close(),e.current=null)}),[j,h]),i.useEffect(()=>()=>{r.current=!0,c.current=!1,l.current&&clearTimeout(l.current),m.current&&(clearTimeout(m.current),m.current=null),u.current=[],d.current.splice(0,d.current.length).forEach(I=>w(I)),e.current&&(e.current.close(),e.current=null)},[w]);const S=i.useCallback(b=>{const I=L(b),G=e.current;if(G&&G.readyState===WebSocket.OPEN){try{G.send(JSON.stringify(I))}catch(V){throw V}return}x({type:"ws-connection-state",state:"connecting",sessionId:I?.sessionId||I?.options?.sessionId||null,clientRequestId:I?.clientRequestId||null});const P={payload:I,timeoutId:setTimeout(()=>{d.current=d.current.filter(V=>V!==P),k(I,"Unable to reach the chat server. Message was not sent.")},1e4)};d.current.push(P),j()},[j,k,x,L]);return i.useMemo(()=>({ws:e.current,sendMessage:S,latestMessage:n,isConnected:o}),[S,n,o])},lw=({children:e})=>{const r=iw();return t.jsx(cp.Provider,{value:r,children:e})},cw=()=>{const[e,r]=i.useState(""),[n,s]=i.useState(""),[o,a]=i.useState(""),[l,c]=i.useState(!1),[d,u]=i.useState(""),{register:m}=os(),p=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 m(e,n);g.success||u(g.error),c(!1)};return t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:t.jsx("div",{className:"w-full max-w-md",children:t.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"flex justify-center mb-4",children:t.jsx(Pn,{size:64})}),t.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Welcome to Axhub Genie"}),t.jsx("p",{className:"text-muted-foreground mt-2",children:"Set up your account to get started"})]}),t.jsxs("form",{onSubmit:p,className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-foreground mb-1",children:"Username"}),t.jsx("input",{type:"text",id:"username",value:e,onChange:h=>r(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:l})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:"Password"}),t.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:l})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"confirmPassword",className:"block text-sm font-medium text-foreground mb-1",children:"Confirm Password"}),t.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:l})]}),d&&t.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:t.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:d})}),t.jsx("button",{type:"submit",disabled:l,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:l?"Setting up...":"Create Account"})]}),t.jsx("div",{className:"text-center",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"This is a single-user system. Only one account can be created."})})]})})})},dw=()=>{const{t:e}=Lt("auth"),[r,n]=i.useState(""),[s,o]=i.useState(""),[a,l]=i.useState(!1),[c,d]=i.useState(""),{login:u}=os(),m=async p=>{if(p.preventDefault(),d(""),!r||!s){d(e("errors.requiredFields"));return}l(!0);const h=await u(r,s);h.success||d(h.error),l(!1)};return t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:t.jsx("div",{className:"w-full max-w-md",children:t.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"flex justify-center mb-4",children:t.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:t.jsx(Vn,{className:"w-8 h-8 text-primary-foreground"})})}),t.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e("login.title")}),t.jsx("p",{className:"text-muted-foreground mt-2",children:e("login.description")})]}),t.jsxs("form",{onSubmit:m,className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-foreground mb-1",children:e("login.username")}),t.jsx("input",{type:"text",id:"username",value:r,onChange:p=>n(p.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})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:e("login.password")}),t.jsx("input",{type:"password",id:"password",value:s,onChange:p=>o(p.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&&t.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:t.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:c})}),t.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")})]}),t.jsx("div",{className:"text-center",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter your credentials to access Axhub Genie"})})]})})})},uw=({onComplete:e})=>{const[r,n]=i.useState(0),[s,o]=i.useState(""),[a,l]=i.useState(""),[c,d]=i.useState(!1),[u,m]=i.useState(""),[p,h]=i.useState(null),[g]=i.useState({name:"default",fullPath:""}),[x,k]=i.useState({authenticated:!1,email:null,loading:!0,error:null}),[w,A]=i.useState({authenticated:!1,email:null,loading:!0,error:null}),{user:L}=os(),j=i.useRef(void 0);i.useEffect(()=>{S()},[]);const S=async()=>{try{const se=await ee("/api/user/git-config");if(se.ok){const he=await se.json();he.gitName&&o(he.gitName),he.gitEmail&&l(he.gitEmail)}}catch(se){console.error("Error loading git config:",se)}};i.useEffect(()=>{const se=j.current;j.current=p,(se===void 0||se!==null&&p===null)&&(D(),b())},[p]);const D=async()=>{try{const se=await ee("/api/cli/claude/status");if(se.ok){const he=await se.json();k({authenticated:he.authenticated,email:he.email,loading:!1,error:he.error||null})}else k({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(se){console.error("Error checking Claude auth status:",se),k({authenticated:!1,email:null,loading:!1,error:se.message})}},b=async()=>{try{const se=await ee("/api/cli/codex/status");if(se.ok){const he=await se.json();A({authenticated:he.authenticated,email:he.email,loading:!1,error:he.error||null})}else A({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(se){console.error("Error checking Codex auth status:",se),A({authenticated:!1,email:null,loading:!1,error:se.message})}},I=()=>h("claude"),G=()=>h("codex"),P=se=>{se===0&&(p==="claude"?D():p==="codex"&&b())},V=async()=>{if(m(""),r===0){if(!s.trim()||!a.trim()){m("Both git name and email are required");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)){m("Please enter a valid email address");return}d(!0);try{const he=await ee("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:s,gitEmail:a})});if(!he.ok){const Se=await he.json();throw new Error(Se.error||"Failed to save git configuration")}n(r+1)}catch(he){m(he.message)}finally{d(!1)}return}n(r+1)},ve=()=>{m(""),n(r-1)},ae=async()=>{d(!0),m("");try{const se=await ee("/api/user/complete-onboarding",{method:"POST"});if(!se.ok){const he=await se.json();throw new Error(he.error||"Failed to complete onboarding")}e&&e()}catch(se){m(se.message)}finally{d(!1)}},R=[{title:"Git Configuration",description:"Set up your git identity for commits",icon:Kr,required:!0},{title:"Connect Agents",description:"Connect your AI coding assistants",icon:Of,required:!1}],q=()=>{switch(r){case 0:return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("div",{className:"w-16 h-16 bg-primary/15 dark:bg-primary/25 rounded-full flex items-center justify-center mx-auto mb-4",children:t.jsx(Kr,{className:"w-8 h-8 text-primary"})}),t.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Git Configuration"}),t.jsx("p",{className:"text-muted-foreground",children:"Configure your git identity to ensure proper attribution for your commits"})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"gitName",className:"flex items-center gap-2 text-sm font-medium text-foreground mb-2",children:[t.jsx(fh,{className:"w-4 h-4"}),"Git Name ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",id:"gitName",value:s,onChange:se=>o(se.target.value),className:"w-full px-4 py-3 border border-border rounded-lg bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:"John Doe",required:!0,disabled:c}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This will be used as: git config --global user.name"})]}),t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"gitEmail",className:"flex items-center gap-2 text-sm font-medium text-foreground mb-2",children:[t.jsx($f,{className:"w-4 h-4"}),"Git Email ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"email",id:"gitEmail",value:a,onChange:se=>l(se.target.value),className:"w-full px-4 py-3 border border-border rounded-lg bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:"john@example.com",required:!0,disabled:c}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This will be used as: git config --global user.email"})]})]})]});case 1:return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"text-center mb-6",children:[t.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Connect Your AI Agents"}),t.jsx("p",{className:"text-muted-foreground",children:"Login to one or more AI coding assistants. All are optional."})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:`border rounded-lg p-4 transition-colors ${x.authenticated?"bg-primary/10 dark:bg-primary/20 border-primary/30 dark:border-primary/60":"border-border bg-card"}`,children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 bg-primary/15 dark:bg-primary/25 rounded-full flex items-center justify-center",children:t.jsx(Pn,{size:20})}),t.jsxs("div",{children:[t.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["Claude Code",x.authenticated&&t.jsx(Gt,{className:"w-4 h-4 text-green-500"})]}),t.jsx("div",{className:"text-xs text-muted-foreground",children:x.loading?"Checking...":x.authenticated?x.email||"Connected":"Not connected"})]})]}),!x.authenticated&&!x.loading&&t.jsx("button",{onClick:I,className:"bg-primary hover:bg-primary/90 text-white text-sm font-medium py-2 px-4 rounded-lg transition-colors",children:"Login"})]})}),t.jsx("div",{className:`border rounded-lg p-4 transition-colors ${w.authenticated?"bg-gray-100 dark:bg-gray-800/50 border-gray-300 dark:border-gray-600":"border-border bg-card"}`,children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:t.jsx(ss,{className:"w-5 h-5"})}),t.jsxs("div",{children:[t.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["OpenAI Codex",w.authenticated&&t.jsx(Gt,{className:"w-4 h-4 text-green-500"})]}),t.jsx("div",{className:"text-xs text-muted-foreground",children:w.loading?"Checking...":w.authenticated?w.email||"Connected":"Not connected"})]})]}),!w.authenticated&&!w.loading&&t.jsx("button",{onClick:G,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white text-sm font-medium py-2 px-4 rounded-lg transition-colors",children:"Login"})]})})]}),t.jsx("div",{className:"text-center text-sm text-muted-foreground pt-2",children:t.jsx("p",{children:"You can configure these later in Settings."})})]});default:return null}},de=()=>{switch(r){case 0:return s.trim()&&a.trim()&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a);case 1:return!0;default:return!1}};return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:t.jsxs("div",{className:"w-full max-w-2xl",children:[t.jsx("div",{className:"mb-8",children:t.jsx("div",{className:"flex items-center justify-between",children:R.map((se,he)=>t.jsxs(dn.Fragment,{children:[t.jsxs("div",{className:"flex flex-col items-center flex-1",children:[t.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center border-2 transition-colors duration-200 ${he<r?"bg-green-500 border-green-500 text-white":he===r?"bg-primary border-primary text-white":"bg-background border-border text-muted-foreground"}`,children:he<r?t.jsx(Gt,{className:"w-6 h-6"}):typeof se.icon=="function"?t.jsx(se.icon,{}):t.jsx(se.icon,{className:"w-6 h-6"})}),t.jsxs("div",{className:"mt-2 text-center",children:[t.jsx("p",{className:`text-sm font-medium ${he===r?"text-foreground":"text-muted-foreground"}`,children:se.title}),se.required&&t.jsx("span",{className:"text-xs text-red-500",children:"Required"})]})]}),he<R.length-1&&t.jsx("div",{className:`flex-1 h-0.5 mx-2 transition-colors duration-200 ${he<r?"bg-green-500":"bg-border"}`})]},he))})}),t.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8",children:[q(),u&&t.jsx("div",{className:"mt-6 p-4 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-lg",children:t.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:u})}),t.jsxs("div",{className:"flex items-center justify-between mt-8 pt-6 border-t border-border",children:[t.jsxs("button",{onClick:ve,disabled:r===0||c,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",children:[t.jsx(ni,{className:"w-4 h-4"}),"Previous"]}),t.jsx("div",{className:"flex items-center gap-3",children:r<R.length-1?t.jsx("button",{onClick:V,disabled:!de()||c,className:"flex items-center gap-2 px-6 py-3 bg-primary hover:bg-primary/90 disabled:bg-primary/60 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors duration-200",children:c?t.jsxs(t.Fragment,{children:[t.jsx(qr,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):t.jsxs(t.Fragment,{children:["Next",t.jsx(sn,{className:"w-4 h-4"})]})}):t.jsx("button",{onClick:ae,disabled:c,className:"flex items-center gap-2 px-6 py-3 bg-green-600 hover:bg-green-700 disabled:bg-green-400 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors duration-200",children:c?t.jsxs(t.Fragment,{children:[t.jsx(qr,{className:"w-4 h-4 animate-spin"}),"Completing..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Gt,{className:"w-4 h-4"}),"Complete Setup"]})})})]})]})]})}),p&&t.jsx(ap,{isOpen:!!p,onClose:()=>h(null),provider:p,project:g,onComplete:P})]})},pw=()=>t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"flex justify-center mb-4",children:t.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:t.jsx(Vn,{className:"w-8 h-8 text-primary-foreground"})})}),t.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Axhub Genie"}),t.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[t.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce"}),t.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),t.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),t.jsx("p",{className:"text-muted-foreground mt-2",children:"Loading..."})]})}),mw=({children:e})=>{const{user:r,isLoading:n,needsSetup:s,hasCompletedOnboarding:o,refreshOnboardingStatus:a}=os();return n?t.jsx(pw,{}):s?t.jsx(cw,{}):r?o?e:t.jsx(uw,{onComplete:a}):t.jsx(dw,{})};function jn(e,r){const[n,s]=i.useState(()=>{if(typeof window>"u")return r;try{const a=window.localStorage.getItem(e);return a?JSON.parse(a):r}catch(a){return console.log(a),r}});return[n,a=>{if(!(typeof window>"u"))try{const l=a instanceof Function?a(n):a;window.localStorage.setItem(e,JSON.stringify(l)),s(l)}catch(l){console.log(l)}}]}const fw=3e3;function Wn(e){return typeof e=="string"&&e.trim().length>0}function hw(e="integration"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}_${crypto.randomUUID()}`:`${e}_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function gw(){return typeof window>"u"?null:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/agent/ws`}function xw({enabled:e,channel:r,clientId:n,sessionId:s}){const o=i.useRef(null),a=i.useRef(null),l=i.useRef(!1),c=i.useRef(!1),d=i.useRef(0),u=i.useRef(Wn(s)?s.trim():null),[m,p]=i.useState(null),[h,g]=i.useState(!1),x=i.useMemo(()=>e===!0&&Wn(r)&&Wn(n),[e,r,n]);i.useEffect(()=>{u.current=Wn(s)?s.trim():null},[s]);const k=i.useCallback(D=>{d.current+=1,p({...D,__messageSeq:d.current})},[]),w=i.useCallback(()=>{const D=o.current;D&&(D.close(),o.current=null),g(!1),l.current=!1},[]),A=i.useCallback((D,b=o.current)=>!D||!b||b.readyState!==WebSocket.OPEN?!1:(b.send(JSON.stringify({type:"integration.ack",requestId:D,payload:{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:u.current}})),!0),[]),L=i.useCallback((D=o.current)=>{!x||!D||D.readyState!==WebSocket.OPEN||D.send(JSON.stringify({type:"integration.connect",requestId:hw("integration_connect"),payload:{role:"frontend-page",channel:r.trim(),clientId:n.trim(),pageUrl:typeof window<"u"?window.location.href:null,sessionId:Wn(s)?s.trim():null,capabilities:["context.update","prompt.update","presence.report"]}}))},[r,n,x,s]),j=i.useCallback(()=>{if(!x||c.current||l.current)return;const D=o.current;if(D&&(D.readyState===WebSocket.OPEN||D.readyState===WebSocket.CONNECTING))return;const b=gw();if(!b)return;l.current=!0;const I=new WebSocket(b);o.current=I,I.onopen=()=>{l.current=!1,o.current=I,g(!0),L(I)},I.onmessage=G=>{try{const P=JSON.parse(G.data);P&&typeof P.type=="string"&&P.type.startsWith("integration.")&&(P.type==="integration.ping"&&A(P.requestId||null,I),k(P))}catch(P){console.error("Error parsing integration WebSocket message:",P)}},I.onclose=()=>{o.current===I&&(o.current=null),l.current=!1,g(!1),!c.current&&x&&(a.current=setTimeout(()=>{a.current=null,j()},fw))},I.onerror=G=>{console.error("Integration WebSocket error:",G)}},[L,k,x,A]);i.useEffect(()=>{if(c.current=!1,!x){a.current&&(clearTimeout(a.current),a.current=null),w();return}return j(),()=>{a.current&&(clearTimeout(a.current),a.current=null),w()}},[w,j,x]),i.useEffect(()=>()=>{c.current=!0,a.current&&(clearTimeout(a.current),a.current=null),w()},[w]),i.useEffect(()=>{x&&L()},[L,x,s]);const S=i.useCallback(D=>{const b=o.current;return!b||b.readyState!==WebSocket.OPEN?!1:(b.send(JSON.stringify(D)),!0)},[]);return{integrationWs:o.current,latestIntegrationMessage:m,sendIntegrationMessage:S,isIntegrationConnected:h,isIntegrationEnabled:x}}function Tc(){const e=vm(),{sessionId:r}=bm(),[n]=wm(),{t:s}=Lt("common");i.useRef(0);const{updateAvailable:o,latestVersion:a,currentVersion:l,releaseInfo:c}=op(),[d,u]=i.useState(!1),[m,p]=i.useState([]),[h,g]=i.useState(null),[x,k]=i.useState(null),[w,A]=i.useState(0),[L,j]=i.useState("chat"),[S,D]=i.useState(!1),b=S&&!1,[I,G]=i.useState(!1),[P,V]=i.useState(!0),[ve,ae]=i.useState(null),[R,q]=i.useState(!1),[de,se]=i.useState(!1),[he,Se]=i.useState("appearance"),[B,z]=i.useState(!1),[_,N]=jn("autoExpandTools",!1),[O,ne]=jn("showRawParameters",!1),[Ce,be]=jn("showThinking",!0),[re,Ee]=jn("autoScrollToBottom",!0),[nt,De]=jn("sendByCtrlEnter",!1),[fe,Ge]=jn("sidebarVisible",!0),[bt,st]=i.useState(!1),[Be,Ze]=i.useState(new Set),[xt,wt]=i.useState(new Set),ye=i.useRef({sessionId:null,status:"idle"}),qe=i.useCallback((T,te="claude")=>{if(!T)return te;try{const oe=localStorage.getItem("session-provider-map");if(!oe)return te;const K=JSON.parse(oe)?.[T];return typeof K=="string"&&K?K:te}catch{return te}},[]),[Nt,X]=i.useState(0),Te=i.useRef({selectionKey:null}),W=i.useRef({attemptedKeys:new Set}),Z=n.get("cwd")||n.get("workdir"),we=n.get("project")||n.get("projectName"),Ae=n.get("provider")||n.get("tool")||n.get("cli"),Xe=n.get("model"),Qe=n.get("context"),We=n.get("prompt"),Et=n.get("integrationWs"),ie=n.get("integrationClientId"),St=n.get("integrationChannel"),et=n.toString(),Ke=m.find(T=>!!(Z&&(T.fullPath===Z||T.path===Z)||we&&(T.fullPath===we||T.path===we)))?.name||null,Tt=i.useCallback((T,te)=>{const oe=n.toString(),ke=oe?`${T}?${oe}`:T;e(ke,te)},[e,n]),{ws:Ot,sendMessage:yt,latestMessage:At}=ow(),{latestIntegrationMessage:rr,sendIntegrationMessage:tt}=xw({enabled:Et==="1",clientId:ie,channel:St,sessionId:x?.id||r||null}),Ft=i.useCallback(T=>typeof T!="string"?!1:/^new-session-\d+$/i.test(T)||/^codex-\d+$/i.test(T),[]),It=i.useRef(null),[$t,nr]=i.useState(!1);i.useEffect(()=>{L==="files"&&j("chat")},[L]),i.useEffect(()=>{const T=()=>{const te=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");nr(te),document.addEventListener("touchstart",{}),te?(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 T(),window.matchMedia("(display-mode: standalone)").addEventListener("change",T),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",T)}},[]),i.useEffect(()=>{const T=()=>{D(window.innerWidth<768)};return T(),window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[]),i.useEffect(()=>{Re()},[]),i.useEffect(()=>{if(!Z&&!we||m.length===0)return;const T=`${Z||""}::${we||""}`;if(Te.current.selectionKey===T)return;if(x){Te.current.selectionKey=T;return}let te=null;if(Z&&(te=m.find(oe=>oe.fullPath===Z||oe.path===Z)),!te&&we){const oe=we.trim().toLowerCase();te=m.find(ke=>[ke.name,ke.displayName,ke.path,ke.fullPath].some(Ve=>typeof Ve=="string"&&Ve.toLowerCase()===oe))}te&&g(te),Te.current.selectionKey=T},[Z,we,m,x]),i.useEffect(()=>{if(!Z||!Z.trim()||P||x)return;const T=Z.trim();if(m.some(Ve=>Ve.fullPath===T||Ve.path===T))return;const oe=`cwd:${T}`;if(W.current.attemptedKeys.has(oe))return;W.current.attemptedKeys.add(oe);let ke=!1;return(async()=>{try{const Ve=await pt.createProject(T),rt=await Ve.json().catch(()=>({}));if(!Ve.ok){const Ct=rt?.error||"Unknown error";if(Ct.includes("Project already configured")){await Re();return}console.warn(`[URL] Failed to auto-create project for cwd "${T}": ${Ct}`);return}if(ke)return;rt?.project&&g(rt.project),await Re()}catch(Ve){console.error(`[URL] Error auto-creating project for cwd "${T}":`,Ve)}})(),()=>{ke=!0}},[Z,m,P,x]);const Bt=(T,te,oe,ke)=>{if(!oe||!ke)return!0;const K=T?.find(Ye=>Ye.name===oe.name),Ve=te?.find(Ye=>Ye.name===oe.name);if(!K||!Ve)return!1;const rt=Ye=>[...Ye.sessions||[],...Ye.codexSessions||[],...Ye.geminiSessions||[],...Ye.opencodeSessions||[]].find(Wt=>Wt.id===ke.id),Ct=rt(K),ft=rt(Ve);return!Ct||!ft?!1:Ct.id===ft.id&&Ct.title===ft.title&&Ct.created_at===ft.created_at&&Ct.updated_at===ft.updated_at},M=(T,te)=>!T||!te?T!==te:T.name!==te.name||T.displayName!==te.displayName||T.fullPath!==te.fullPath||T.path!==te.path,ge=T=>{if(!T)return!1;if(r===T)return!0;const te=ye.current;return te?.sessionId===T&&te?.status!=="missing"&&te?.status!=="error"?!0:Be.has(T)||xt.has(T)};i.useEffect(()=>{if(At){if(At.type==="loading_progress"){It.current&&(clearTimeout(It.current),It.current=null),ae(At),At.phase==="complete"&&(It.current=setTimeout(()=>{ae(null),It.current=null},500));return}if(At.type==="projects_updated"){if(At.changedFile&&x&&h){const ke=At.changedFile.replace(/\\/g,"/").split("/"),K=ke[ke.length-1]||"",Ve=K.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]||K.replace(".jsonl","");if((At.changedSessionId||Ve)===x.id){const Ct=Be.has(x.id),ft=x.__provider==="codex";(!Ct||ft)&&X(lt=>lt+1)}}if(x&&Be.has(x.id)||Be.size>0&&Array.from(Be).some(oe=>oe.startsWith("new-session-"))){const oe=At.projects;if(!Bt(m,oe,h,x))return}const te=At.projects;if(p(te),h){const oe=te.find(ke=>ke.name===h.name);if(oe&&(M(h,oe)&&g(oe),x)){const K=[...oe.sessions||[],...oe.codexSessions||[],...oe.geminiSessions||[],...oe.opencodeSessions||[]].find(Ve=>Ve.id===x.id);if(!K)ge(x.id)||k(null);else{const Ve={...K,__provider:x.__provider||qe(K.id,"claude"),__projectName:x.__projectName||oe.name};(Ve.title!==x.title||Ve.updated_at!==x.updated_at||Ve.__provider!==x.__provider||Ve.__projectName!==x.__projectName)&&k(Ve)}}}}}return()=>{It.current&&(clearTimeout(It.current),It.current=null)}},[Be,At,xt,qe,h,x,r]);const Re=async(T={})=>{const{background:te=!1}=T;try{te||V(!0);const ke=await(await pt.projects()).json();p(K=>K.length===0||ke.some((rt,Ct)=>{const ft=K[Ct];return ft?rt.name!==ft.name||rt.displayName!==ft.displayName||rt.fullPath!==ft.fullPath||JSON.stringify(rt.sessionMeta)!==JSON.stringify(ft.sessionMeta)||JSON.stringify(rt.sessions)!==JSON.stringify(ft.sessions)||JSON.stringify(rt.codexSessions)!==JSON.stringify(ft.codexSessions)||JSON.stringify(rt.geminiSessions)!==JSON.stringify(ft.geminiSessions)||JSON.stringify(rt.opencodeSessions)!==JSON.stringify(ft.opencodeSessions):!0})||ke.length!==K.length?ke:K)}catch(oe){console.error("Error fetching projects:",oe)}finally{te||V(!1)}};window.refreshProjects=(T={})=>Re({background:!0,...T}),window.openSettings=i.useCallback((T="appearance")=>{Se(T),se(!0)},[]),i.useEffect(()=>{if(!r||m.length===0)return;const T=x?.id||null;h?.name;const te=T!==r,oe=Ae||x?.__provider||localStorage.getItem("selected-provider")||"claude",ke=qe(r,oe),K=`${r}::${et}`,Ve=Ft(r),rt=(lt,Ye,Rt)=>{if(!lt||!Ye)return!1;const Wt=m.find(zt=>zt.name===lt.name)||lt,Pr={...Ye,__provider:Rt||ke,__projectName:Wt.name};return g(zt=>zt?.name===Wt.name?zt:Wt),k(zt=>zt?.id===Pr.id&&zt?.__provider===Pr.__provider&&zt?.__projectName===Pr.__projectName?zt:Pr),te&&j("chat"),ye.current={sessionId:r,status:"resolved",resolutionKey:K},!0};for(const lt of m){const Ye=[{items:lt.sessions,provider:qe(r,oe)},{items:lt.codexSessions,provider:"codex"},{items:lt.geminiSessions,provider:"gemini"},{items:lt.opencodeSessions,provider:"opencode"}];for(const Rt of Ye){const Wt=Rt.items?.find(Vt=>Vt.id===r);if(Wt){rt(lt,Wt,Rt.provider);return}}}if(h&&(k({id:r,title:"New Session",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),__provider:ke,__projectName:h.name}),te&&j("chat"),ye.current={sessionId:r,status:"placeholder",resolutionKey:K}),Ve||ye.current.sessionId===r&&ye.current.status==="resolving"&&ye.current.resolutionKey===K)return;ye.current={sessionId:r,status:"resolving",resolutionKey:K};let Ct=!1;return(async()=>{try{const lt=await pt.resolveSession(r,ke),Ye=await lt.json().catch(()=>({}));if(Ct)return;if(!lt.ok||!Ye?.found||!Ye?.project||!Ye?.session){ye.current={sessionId:r,status:"missing",resolutionKey:K};return}if(Ye?.provider)try{const zt=localStorage.getItem("session-provider-map"),hn=zt?JSON.parse(zt):{};hn[r]=Ye.provider,localStorage.setItem("session-provider-map",JSON.stringify(hn))}catch{}if(!rt(Ye.project,Ye.session,Ye.provider||ke))return;const Wt=new URLSearchParams(et);(Ye.project.fullPath||Ye.project.path)&&Wt.set("project",Ye.project.fullPath||Ye.project.path),Ye.provider&&Wt.set("provider",Ye.provider);const Vt=`/session/${r}${Wt.toString()?`?${Wt.toString()}`:""}`,Pr=`${window.location.pathname}${window.location.search}`;Vt!==Pr&&e(Vt,{replace:!0})}catch(lt){Ct||(console.error("Error resolving session route:",lt),ye.current={sessionId:r,status:"error",resolutionKey:K})}})(),()=>{Ct=!0}},[Ft,e,m,qe,et,h?.name,x?.id,r]);const Q=T=>{g(T),k(null),Tt("/"),S&&G(!1)},C=T=>{if(k(T),L!=="git"&&L!=="preview"&&j("chat"),S){const te=T.__projectName,oe=h?.name;te!==oe&&G(!1)}Tt(`/session/${T.id}`)},F=T=>{if(T?.name&&typeof window<"u")try{localStorage.removeItem(`chat_messages_${T.name}`),localStorage.removeItem(`draft_input_${T.name}`)}catch(te){console.warn("Failed to clear local chat cache for new session:",te)}g(T),k(null),A(te=>te+1),j("chat"),Tt("/"),S&&G(!1)},pe=T=>{x?.id===T&&(k(null),Tt("/")),p(te=>te.map(oe=>({...oe,sessions:oe.sessions?.filter(ke=>ke.id!==T)||[],sessionMeta:{...oe.sessionMeta,total:Math.max(0,(oe.sessionMeta?.total||0)-1)}})))},je=async()=>{try{const te=await(await pt.projects()).json();if(p(oe=>te.some((K,Ve)=>{const rt=oe[Ve];return rt?K.name!==rt.name||K.displayName!==rt.displayName||K.fullPath!==rt.fullPath||JSON.stringify(K.sessionMeta)!==JSON.stringify(rt.sessionMeta)||JSON.stringify(K.sessions)!==JSON.stringify(rt.sessions):!0})||te.length!==oe.length?te:oe),h){const oe=te.find(ke=>ke.name===h.name);if(oe&&(M(h,oe)&&g(oe),x)){const K=[...oe.sessions||[],...oe.codexSessions||[],...oe.geminiSessions||[],...oe.opencodeSessions||[]].find(Ve=>Ve.id===x.id);if(!K)ge(x.id)||k(null);else{const Ve={...K,__provider:x.__provider||qe(K.id,"claude"),__projectName:x.__projectName||oe.name};(Ve.title!==x.title||Ve.updated_at!==x.updated_at||Ve.__provider!==x.__provider||Ve.__projectName!==x.__projectName)&&k(Ve)}}}}catch(T){console.error("Error refreshing sidebar:",T)}},mt=T=>{h?.name===T&&(g(null),k(null),Tt("/")),p(te=>te.filter(oe=>oe.name!==T))},H=i.useCallback(T=>{T&&Ze(te=>new Set([...te,T]))},[]),_t=i.useCallback(T=>{T&&Ze(te=>{const oe=new Set(te);return oe.delete(T),oe})},[]),$=i.useCallback(T=>{T&&wt(te=>new Set([...te,T]))},[]),U=i.useCallback(T=>{T&&wt(te=>{const oe=new Set(te);return oe.delete(T),oe})},[]),le=i.useCallback((T,te=null)=>{T&&(Ze(oe=>{const ke=new Set;for(const K of oe)te&&K===te||K.startsWith("new-session-")||ke.add(K);return ke.add(T),ke}),wt(oe=>{const ke=new Set;for(const K of oe)te&&K===te||K.startsWith("new-session-")||ke.add(K);return ke.add(T),ke}))},[]),Oe=()=>{const{t:T}=Lt("common"),[te,oe]=i.useState(!1),[ke,K]=i.useState(""),[Ve,rt]=i.useState("");if(!d)return null;const Ct=lt=>lt?lt.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,`
494
-
495
- `).trim():"",ft=async()=>{oe(!0),K(`Starting update...
496
- `),rt("");try{const lt=await ee("/api/system/update",{method:"POST"}),Ye=await lt.json();lt.ok?(K(Rt=>Rt+Ye.output+`
497
- `),K(Rt=>Rt+`
498
- ✅ Update completed successfully!
499
- `),K(Rt=>Rt+`Please restart the server to apply changes.
500
- `)):(rt(Ye.error||"Update failed"),K(Rt=>Rt+`
501
- ❌ Update failed: `+(Ye.error||"Unknown error")+`
502
- `))}catch(lt){rt(lt.message),K(Ye=>Ye+`
503
- ❌ Update failed: `+lt.message+`
504
- `)}finally{oe(!1)}};return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[t.jsx("button",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>u(!1),"aria-label":T("versionUpdate.ariaLabels.closeModal")}),t.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:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 bg-primary/15 dark:bg-primary/25 rounded-lg flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:T("versionUpdate.title")}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:c?.title||T("versionUpdate.newVersionReady")})]})]}),t.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:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex justify-between items-center p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg",children:[t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:T("versionUpdate.currentVersion")}),t.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:l})]}),t.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:[t.jsx("span",{className:"text-sm font-medium text-primary",children:T("versionUpdate.latestVersion")}),t.jsx("span",{className:"text-sm text-primary font-mono",children:a})]})]}),c?.body&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:T("versionUpdate.whatsNew")}),c?.htmlUrl&&t.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:[T("versionUpdate.viewFullRelease"),t.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})]})]}),t.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:t.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:Ct(c.body)})})]}),ke&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:T("versionUpdate.updateProgress")}),t.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:t.jsx("pre",{className:"text-xs text-green-400 font-mono whitespace-pre-wrap",children:ke})})]}),!te&&!ke&&t.jsxs("div",{className:"space-y-3",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:T("versionUpdate.manualUpgrade")}),t.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-lg p-3 border",children:t.jsx("code",{className:"text-sm text-gray-800 dark:text-gray-200 font-mono",children:"npm update -g @axhub/genie"})}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:T("versionUpdate.manualUpgradeHint")})]}),t.jsxs("div",{className:"flex gap-2 pt-2",children:[t.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:T(ke?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!ke&&t.jsxs(t.Fragment,{children:[t.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:T("versionUpdate.buttons.copyCommand")}),t.jsx("button",{onClick:ft,disabled:te,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:te?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),T("versionUpdate.buttons.updating")]}):T("versionUpdate.buttons.updateNow")})]})]})]})]})};return t.jsxs("div",{className:"chat-app-shell fixed inset-0 flex overflow-hidden bg-background",style:{"--mobile-nav-total":"0px"},children:[!S&&t.jsx("div",{className:`chat-sidebar h-full flex-shrink-0 overflow-hidden transition-all duration-300 ${fe?"w-[22rem]":"w-[4.25rem]"}`,children:t.jsx("div",{className:"h-full overflow-hidden",children:fe?t.jsx(Nl,{projects:m,selectedProject:h,selectedSession:x,onProjectSelect:Q,onSessionSelect:C,onNewSession:F,onSessionDelete:pe,onProjectDelete:mt,isLoading:P,loadingProgress:ve,onRefresh:je,onShowSettings:()=>se(!0),updateAvailable:o,latestVersion:a,currentVersion:l,releaseInfo:c,onShowVersionModal:()=>u(!0),isPWA:$t,isMobile:S,onToggleSidebar:()=>Ge(!1),lockedProjectName:Ke,showNewProject:bt,setShowNewProject:st}):t.jsxs("div",{className:"h-full flex flex-col items-center gap-3 py-4",children:[t.jsx("button",{onClick:()=>Ge(!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:t.jsx(sn,{className:"w-4 h-4 text-foreground"})}),t.jsx("button",{onClick:()=>se(!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:t.jsx(Wc,{className:"w-5 h-5 text-muted-foreground hover:text-foreground transition-colors"})}),o&&t.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:[t.jsx(ri,{className:"w-5 h-5 text-primary"}),t.jsx("span",{className:"absolute top-1 right-1 w-2 h-2 bg-primary rounded-full animate-pulse"})]})]})})}),S&&t.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${I?"opacity-100 visible":"opacity-0 invisible"}`,children:[t.jsx("button",{className:"fixed inset-0 bg-black/40 transition-opacity duration-150 ease-out",onClick:T=>{T.stopPropagation(),G(!1)},onTouchStart:T=>{T.preventDefault(),T.stopPropagation(),G(!1)},"aria-label":s("versionUpdate.ariaLabels.closeSidebar")}),t.jsx("div",{className:`chat-sidebar relative h-full w-[85vw] max-w-sm bg-white shadow-xl transform dark:bg-background sm:w-80 ${I?"translate-x-0":"-translate-x-full"}`,onClick:T=>T.stopPropagation(),onTouchStart:T=>T.stopPropagation(),children:t.jsx(Nl,{projects:m,selectedProject:h,selectedSession:x,onProjectSelect:Q,onSessionSelect:C,onNewSession:F,onSessionDelete:pe,onProjectDelete:mt,isLoading:P,loadingProgress:ve,onRefresh:je,onShowSettings:()=>se(!0),updateAvailable:o,latestVersion:a,currentVersion:l,releaseInfo:c,onShowVersionModal:()=>u(!0),isPWA:$t,isMobile:S,onToggleSidebar:()=>Ge(!1),lockedProjectName:Ke,showNewProject:bt,setShowNewProject:st})})]}),t.jsx("div",{className:"chat-shell flex-1 flex min-w-0 flex-col overflow-hidden ",children:t.jsx(Xb,{selectedProject:h,selectedSession:x,activeTab:L,setActiveTab:j,ws:Ot,sendMessage:yt,latestMessage:At,isMobile:S,isPWA:$t,onMenuClick:()=>G(!0),isLoading:P,onInputFocusChange:q,onSessionActive:H,onSessionInactive:_t,onSessionProcessing:$,onSessionNotProcessing:U,processingSessions:xt,onReplaceTemporarySession:le,onNavigateToSession:T=>Tt(`/session/${T}`),onShowSettings:()=>se(!0),autoExpandTools:_,showRawParameters:O,showThinking:Ce,autoScrollToBottom:re,sendByCtrlEnter:nt,externalMessageUpdate:Nt,urlProvider:Ae,urlModel:Xe,urlContext:Qe,urlPrompt:We,integrationClientId:ie,latestIntegrationMessage:rr,sendIntegrationMessage:tt,onShowNewProject:()=>st(!0),onNewSession:F,newSessionResetNonce:w})}),b,L==="chat"&&t.jsx(nw,{isOpen:B,onToggle:z,autoExpandTools:_,onAutoExpandChange:N,showRawParameters:O,onShowRawParametersChange:ne,showThinking:Ce,onShowThinkingChange:be,autoScrollToBottom:re,onAutoScrollChange:Ee,sendByCtrlEnter:nt,onSendByCtrlEnterChange:De,isMobile:S}),t.jsx(rw,{isOpen:de,onClose:()=>se(!1),projects:m,initialTab:he}),t.jsx(Oe,{})]})}function Aw(){return t.jsx(Xm,{i18n:nf,children:t.jsx(Qm,{children:t.jsx(sw,{children:t.jsx(lw,{children:t.jsx(mw,{children:t.jsx(xm,{basename:window.__ROUTER_BASENAME__||"",children:t.jsxs(ym,{children:[t.jsx(Zo,{path:"/",element:t.jsx(Tc,{})}),t.jsx(Zo,{path:"/session/:sessionId",element:t.jsx(Tc,{})}),t.jsx(Zo,{path:"/review",element:t.jsx(Zm,{})})]})})})})})})})}export{Aw as default};